Skip to content

libcephfs/client: pin inode/dentry for an opened directory - #60909

Merged
vshankar merged 4 commits into
ceph:mainfrom
ifed01:wip-ifed-client-cache-trim-repro
Feb 11, 2025
Merged

vshankar merged 4 commits into
ceph:mainfrom
ifed01:wip-ifed-client-cache-trim-repro

Conversation

@ifed01

@ifed01 ifed01 commented Dec 2, 2024 •

Copy link
Copy Markdown
Contributor

Reproduces: https://tracker.ceph.com/issues/69092
Fixes: https://tracker.ceph.com/issues/69092

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@ifed01 ifed01 added the tests label Dec 2, 2024
@github-actions github-actions Bot added build/ops cephfs Ceph File System labels Dec 2, 2024
@ifed01
ifed01 force-pushed the wip-ifed-client-cache-trim-repro branch from 7c63a08 to 4f122a0 Compare December 2, 2024 16:54
@ifed01
ifed01 requested review from joscollin and vshankar December 2, 2024 16:55
@ifed01 ifed01 changed the title test/libcephfs: reproduce an issue after client cache trimming test/libcephfs: reproduce internal data inconsistency after client cache trimming Dec 2, 2024
@ifed01
ifed01 force-pushed the wip-ifed-client-cache-trim-repro branch 2 times, most recently from ebb8b23 to cff1f39 Compare December 3, 2024 13:03
@ifed01 ifed01 changed the title test/libcephfs: reproduce internal data inconsistency after client cache trimming libcephfs/client: pin inode/dentry for an opened directory Dec 12, 2024
@batrick
batrick requested review from a team and dparmar18 December 18, 2024 14:39
@vshankar vshankar self-assigned this Dec 18, 2024
@dparmar18 dparmar18 self-assigned this Dec 19, 2024

@mchangir mchangir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor issue

Comment thread src/test/libcephfs/client_cache.cc Resolved
@ifed01
ifed01 force-pushed the wip-ifed-client-cache-trim-repro branch from 1573d65 to 78433c2 Compare December 26, 2024 12:00
@vshankar

Copy link
Copy Markdown
Contributor

jenkins test windows

@vshankar

Copy link
Copy Markdown
Contributor

jenkins test make check

@vshankar

Copy link
Copy Markdown
Contributor

@ifed01

ifed01 commented Dec 27, 2024

Copy link
Copy Markdown
Contributor Author

jenkins test windows

Comment thread src/client/Client.cc
if (fhp) {
*fhp = _create_fh(in, flags, cmode, perms);
// ceph_flags_sys2wire/ceph_flags_to_mode() calls above transforms O_DIRECTORY flag
// into CEPH_FILE_MODE_PIN mode. Although this mode is used at server size

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: size -> side

@vshankar vshankar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vshankar

vshankar commented Jan 2, 2025

Copy link
Copy Markdown
Contributor

jenkins test windows

2 similar comments
@vshankar

vshankar commented Jan 2, 2025

Copy link
Copy Markdown
Contributor

jenkins test windows

@vshankar

vshankar commented Jan 6, 2025

Copy link
Copy Markdown
Contributor

jenkins test windows

@vshankar

vshankar commented Jan 6, 2025

Copy link
Copy Markdown
Contributor

Windows failure seems to be real

++ echo 'src/client/Client.cc
src/test/libcephfs/CMakeLists.txt
src/test/libcephfs/client_cache.cc'
++ egrep -v '^container/'
++ wc -l
+ '[' 3 -gt 0 ']'
+ return 1

I haven't looked deeper though. @ifed01

@vshankar

vshankar commented Jan 7, 2025

Copy link
Copy Markdown
Contributor

Windows failure seems to be real

++ echo 'src/client/Client.cc
src/test/libcephfs/CMakeLists.txt
src/test/libcephfs/client_cache.cc'
++ egrep -v '^container/'
++ wc -l
+ '[' 3 -gt 0 ']'
+ return 1

I haven't looked deeper though. @ifed01

This is happening with other PRs too, so its probably unrelated to this change (however, it blocks merging).

@ifed01

ifed01 commented Jan 9, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@ifed01
ifed01 force-pushed the wip-ifed-client-cache-trim-repro branch from bf96ced to aa2d946 Compare February 5, 2025 10:52
@github-actions github-actions Bot added the common label Feb 5, 2025
@ifed01
ifed01 force-pushed the wip-ifed-client-cache-trim-repro branch from aa2d946 to 51e4e1a Compare February 5, 2025 10:53
@ifed01

ifed01 commented Feb 5, 2025

Copy link
Copy Markdown
Contributor Author

The root cause for reoccurring Windows tests failures is lack of O_DIRECTORY flag translation in ceph_flags_sys2wire() (defined in src/common/ceph_fs.cc).
This function explicitly bypasses this translation under Windows:

#ifndef _WIN32
       ceph_sys2wire(O_DIRECTORY);
       ceph_sys2wire(O_NOFOLLOW);
       // In some cases, FILE_FLAG_BACKUP_SEMANTICS may be used instead
       // of O_DIRECTORY. We may need some workarounds in order to handle
       // the fact that those flags are not available on Windows.
#endif

As a result no CEPH_FILE_MODE_PIN is returned by ceph_flags_to_mode() and opened directory gets no pinning. Which in turn exposes it to cache trimming..
@petrutlucian94 - do you think we really need that "ifndef" block given the fact that O_DIRECTORY is actually defined in include/win32/fs_compat.h?

@petrutlucian94

Copy link
Copy Markdown
Contributor

As long as those flags don't propagate to Windows functions, I think we can remove the ifdefs.

…er Win

in ceph_flags_sys2wire()

Signed-off-by: Igor Fedotov <[email protected]>
@ifed01
ifed01 force-pushed the wip-ifed-client-cache-trim-repro branch from 51e4e1a to 4badc83 Compare February 5, 2025 15:41
@ifed01 ifed01 added the win32 Specifix changes for the windows platform label Feb 5, 2025
@ifed01

ifed01 commented Feb 6, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

2 similar comments
@ifed01

ifed01 commented Feb 9, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@ifed01

ifed01 commented Feb 9, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@vshankar

Copy link
Copy Markdown
Contributor

Nice work @ifed01. Thx @petrutlucian94

@vshankar
vshankar merged commit cb5a62f into ceph:main Feb 11, 2025
@ifed01
ifed01 deleted the wip-ifed-client-cache-trim-repro branch February 11, 2025 12:51
vshankar pushed a commit to salieri11/ceph that referenced this pull request Jul 1, 2026
Hold a function-scoped DentryRef in Client::unlink() to keep the dentry
alive through the entire teardown sequence.

Without the O_DIRECTORY dentry pin (PR ceph#60909, merged after v19.2.1),
opening a directory does not call _ll_get(), so the dentry stays at
ref=1 while inode->dir is still active. When trim_cache() evicts this
dentry, Dentry::unlink() calls put() for the dir pin, ref drops to 0,
and the dentry is freed while Client::unlink() still needs it for
detach/lru_remove.

A function-scoped DentryRef guarantees the dentry survives until after
it has been properly removed from the dir and LRU, regardless of pin
state.

Signed-off-by: Igor Golikov <[email protected]>
Fixes: https://tracker.ceph.com/issues/74625
batrick pushed a commit that referenced this pull request Aug 5, 2026
Hold a function-scoped DentryRef in Client::unlink() to keep the dentry
alive through the entire teardown sequence.

Without the O_DIRECTORY dentry pin (PR #60909, merged after v19.2.1),
opening a directory does not call _ll_get(), so the dentry stays at
ref=1 while inode->dir is still active. When trim_cache() evicts this
dentry, Dentry::unlink() calls put() for the dir pin, ref drops to 0,
and the dentry is freed while Client::unlink() still needs it for
detach/lru_remove.

A function-scoped DentryRef guarantees the dentry survives until after
it has been properly removed from the dir and LRU, regardless of pin
state.

Signed-off-by: Igor Golikov <[email protected]>
Fixes: https://tracker.ceph.com/issues/74625
(cherry picked from commit ad95bb5)
sajibreadd pushed a commit to sajibreadd/ceph that referenced this pull request Aug 18, 2026
Hold a function-scoped DentryRef in Client::unlink() to keep the dentry
alive through the entire teardown sequence.

Without the O_DIRECTORY dentry pin (PR ceph#60909, merged after v19.2.1),
opening a directory does not call _ll_get(), so the dentry stays at
ref=1 while inode->dir is still active. When trim_cache() evicts this
dentry, Dentry::unlink() calls put() for the dir pin, ref drops to 0,
and the dentry is freed while Client::unlink() still needs it for
detach/lru_remove.

A function-scoped DentryRef guarantees the dentry survives until after
it has been properly removed from the dir and LRU, regardless of pin
state.

Signed-off-by: Igor Golikov <[email protected]>
Fixes: https://tracker.ceph.com/issues/74625
(cherry picked from commit ad95bb5)

Conflicts:
	src/client/Client.cc
sajibreadd-croit pushed a commit to croit/ceph that referenced this pull request Aug 28, 2026
Hold a function-scoped DentryRef in Client::unlink() to keep the dentry
alive through the entire teardown sequence.

Without the O_DIRECTORY dentry pin (PR ceph#60909, merged after v19.2.1),
opening a directory does not call _ll_get(), so the dentry stays at
ref=1 while inode->dir is still active. When trim_cache() evicts this
dentry, Dentry::unlink() calls put() for the dir pin, ref drops to 0,
and the dentry is freed while Client::unlink() still needs it for
detach/lru_remove.

A function-scoped DentryRef guarantees the dentry survives until after
it has been properly removed from the dir and LRU, regardless of pin
state.

Signed-off-by: Igor Golikov <[email protected]>
Fixes: https://tracker.ceph.com/issues/74625
(cherry picked from commit ad95bb5)

Conflicts:
	src/client/Client.cc
sajibreadd-croit pushed a commit to croit/ceph that referenced this pull request Sep 1, 2026
Hold a function-scoped DentryRef in Client::unlink() to keep the dentry
alive through the entire teardown sequence.

Without the O_DIRECTORY dentry pin (PR ceph#60909, merged after v19.2.1),
opening a directory does not call _ll_get(), so the dentry stays at
ref=1 while inode->dir is still active. When trim_cache() evicts this
dentry, Dentry::unlink() calls put() for the dir pin, ref drops to 0,
and the dentry is freed while Client::unlink() still needs it for
detach/lru_remove.

A function-scoped DentryRef guarantees the dentry survives until after
it has been properly removed from the dir and LRU, regardless of pin
state.

Signed-off-by: Igor Golikov <[email protected]>
Fixes: https://tracker.ceph.com/issues/74625
(cherry picked from commit ad95bb5)

Conflicts:
	src/client/Client.cc
(cherry picked from commit 0d93979)
sajibreadd-croit pushed a commit to croit/ceph that referenced this pull request Sep 1, 2026
Hold a function-scoped DentryRef in Client::unlink() to keep the dentry
alive through the entire teardown sequence.

Without the O_DIRECTORY dentry pin (PR ceph#60909, merged after v19.2.1),
opening a directory does not call _ll_get(), so the dentry stays at
ref=1 while inode->dir is still active. When trim_cache() evicts this
dentry, Dentry::unlink() calls put() for the dir pin, ref drops to 0,
and the dentry is freed while Client::unlink() still needs it for
detach/lru_remove.

A function-scoped DentryRef guarantees the dentry survives until after
it has been properly removed from the dir and LRU, regardless of pin
state.

Signed-off-by: Igor Golikov <[email protected]>
Fixes: https://tracker.ceph.com/issues/74625
(cherry picked from commit ad95bb5)

Conflicts:
	src/client/Client.cc
(cherry picked from commit 0d93979)
AnuragRaut08 pushed a commit to AnuragRaut08/ceph that referenced this pull request Sep 30, 2026
Hold a function-scoped DentryRef in Client::unlink() to keep the dentry
alive through the entire teardown sequence.

Without the O_DIRECTORY dentry pin (PR ceph#60909, merged after v19.2.1),
opening a directory does not call _ll_get(), so the dentry stays at
ref=1 while inode->dir is still active. When trim_cache() evicts this
dentry, Dentry::unlink() calls put() for the dir pin, ref drops to 0,
and the dentry is freed while Client::unlink() still needs it for
detach/lru_remove.

A function-scoped DentryRef guarantees the dentry survives until after
it has been properly removed from the dir and LRU, regardless of pin
state.

Signed-off-by: Igor Golikov <[email protected]>
Fixes: https://tracker.ceph.com/issues/74625
ifed01 pushed a commit to croit/ceph that referenced this pull request Nov 3, 2026
Hold a function-scoped DentryRef in Client::unlink() to keep the dentry
alive through the entire teardown sequence.

Without the O_DIRECTORY dentry pin (PR ceph#60909, merged after v19.2.1),
opening a directory does not call _ll_get(), so the dentry stays at
ref=1 while inode->dir is still active. When trim_cache() evicts this
dentry, Dentry::unlink() calls put() for the dir pin, ref drops to 0,
and the dentry is freed while Client::unlink() still needs it for
detach/lru_remove.

A function-scoped DentryRef guarantees the dentry survives until after
it has been properly removed from the dir and LRU, regardless of pin
state.

Signed-off-by: Igor Golikov <[email protected]>
Fixes: https://tracker.ceph.com/issues/74625
(cherry picked from commit ad95bb5)

Conflicts:
	src/client/Client.cc
sajibreadd-croit pushed a commit to croit/ceph that referenced this pull request Dec 1, 2026
Hold a function-scoped DentryRef in Client::unlink() to keep the dentry
alive through the entire teardown sequence.

Without the O_DIRECTORY dentry pin (PR ceph#60909, merged after v19.2.1),
opening a directory does not call _ll_get(), so the dentry stays at
ref=1 while inode->dir is still active. When trim_cache() evicts this
dentry, Dentry::unlink() calls put() for the dir pin, ref drops to 0,
and the dentry is freed while Client::unlink() still needs it for
detach/lru_remove.

A function-scoped DentryRef guarantees the dentry survives until after
it has been properly removed from the dir and LRU, regardless of pin
state.

Signed-off-by: Igor Golikov <[email protected]>
Fixes: https://tracker.ceph.com/issues/74625
(cherry picked from commit ad95bb5)

Conflicts:
	src/client/Client.cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build/ops cephfs Ceph File System common needs-review tests win32 Specifix changes for the windows platform

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants