Conversation
anoopcs9
left a comment
There was a problem hiding this comment.
As mentioned below, commit message also needs the following correction:
s/ceph_fdopenat()/ceph_fdopendir
src/client/Client.h
Outdated
| std::vector<dentry> buffer; | ||
| struct dirent de; | ||
|
|
||
| int fd; // fd attached using fdopenat (-1 if none) |
There was a problem hiding this comment.
| int fd; // fd attached using fdopenat (-1 if none) | |
| int fd; // fd attached using fdopendir (-1 if none) |
There was a problem hiding this comment.
Good catch. Thanks :)
12fff05 to
b88fc2d
Compare
|
@xhernandez Thanks for the fix. We intent to backport this fix, so, this requires a redmine tracker (and link it in the commit message with |
Done |
Based on posix specification, the fd passed to fdopendir() will be closed by closedir(). However CephFS client wasn't doing that. If the user opened a directory using ceph_openat(), for example, and then passed the returned fd to ceph_fdopendir(), the created Fh associated with the new open was never destroyed. This patch records the fd used in ceph_fdopendir() so that it can be closed when ceph_closedir() is called. Fixes: https://tracker.ceph.com/issues/64479 Signed-off-by: Xavi Hernandez <xhernandez@gmail.com>
|
it would be good to have a test case for this, you can try use |
@dparmar18 How should I write this test ? I've seen that there are some CephFS tests that use libcephfs in src/test/libcephfs, but |
yeah that would be the place |
I've just realized that |
Right, that is a blocker then. I guess the what looks possible is to write a test case via a script and run it using a YAML |
I'm sorry, but I'm very new to Ceph development and I don't know much about it, specially for testing. Can you point me to some place where it's described how to write these scripts and yaml files, and how to integrate them into the regular testing procedures ? |
it should be simple, checkout |
Its a bit tricky to have test cases for thing like this fix since the way the client is written. I'd defer that for now... |
|
jenkins test make check arm64 |
* refs/pull/55619/head: client: fix leak of file handles Reviewed-by: Dhairya Parmar <dparmar@redhat.com> Reviewed-by: Venky Shankar <vshankar@redhat.com>
|
Reruning tests with #55909 and #55908 included. See - https://pulpito.ceph.com/vshankar-2024-03-04_08:26:39-fs-wip-vshankar-testing-20240304.042522-testing-default-smithi/ |
ceph/ceph#55619 eliminates the need for ceph_close() call after successful ceph_fdopendir() one. And introduces automatic file descriptor's close when corresponding ceph_closedir() is called. That hasty ceph_close() call makes file descriptor available for a new allocation which might conflict with the automatic fd close in the above ceph_closedir(). Full PeerReplayer::do_synchronize() has been reworked to close fds properly, depending on whether ceph_fdopendir() has been already applied to them. Additionally for the sake of uniformity this reworks incremental do_synchronize() in a way to do final fd closings similar to full implementation. Plus this effectively reverts ceph/ceph@bd78bdc as it looks like a wrong approach to fight broken file descriptor references. No much sense in reopening of the current snapshot's root folder on each new entry processing. Instead this patch just doesn't close it from the beginning. Fixes: https://tracker.ceph.com/issues/68853 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7a747bc)
Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c) (cherry picked from commit 442e645) Resolves: rhbz#2331338
ceph#55619 eliminates the need for ceph_close() call after successful ceph_fdopendir() one. And introduces automatic file descriptor's close when corresponding ceph_closedir() is called. That hasty ceph_close() call makes file descriptor available for a new allocation which might conflict with the automatic fd close in the above ceph_closedir(). Full PeerReplayer::do_synchronize() has been reworked to close fds properly, depending on whether ceph_fdopendir() has been already applied to them. Additionally for the sake of uniformity this reworks incremental do_synchronize() in a way to do final fd closings similar to full implementation. Plus this effectively reverts ceph@bd78bdc as it looks like a wrong approach to fight broken file descriptor references. No much sense in reopening of the current snapshot's root folder on each new entry processing. Instead this patch just doesn't close it from the beginning. Fixes: https://tracker.ceph.com/issues/68853 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7a747bc) (cherry picked from commit c4ce3c0) Resolves: rhbz#2331338
Likely ceph#55619 missed that. Resolves: rhbz#2317735 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c) (cherry picked from commit 442e645)
ceph#55619 eliminates the need for ceph_close() call after successful ceph_fdopendir() one. And introduces automatic file descriptor's close when corresponding ceph_closedir() is called. That hasty ceph_close() call makes file descriptor available for a new allocation which might conflict with the automatic fd close in the above ceph_closedir(). Full PeerReplayer::do_synchronize() has been reworked to close fds properly, depending on whether ceph_fdopendir() has been already applied to them. Additionally for the sake of uniformity this reworks incremental do_synchronize() in a way to do final fd closings similar to full implementation. Plus this effectively reverts ceph@bd78bdc as it looks like a wrong approach to fight broken file descriptor references. No much sense in reopening of the current snapshot's root folder on each new entry processing. Instead this patch just doesn't close it from the beginning. Resolves: rhbz#2317735 Fixes: https://tracker.ceph.com/issues/68853 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7a747bc) (cherry picked from commit c4ce3c0)
Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
ceph#55619 eliminates the need for ceph_close() call after successful ceph_fdopendir() one. And introduces automatic file descriptor's close when corresponding ceph_closedir() is called. That hasty ceph_close() call makes file descriptor available for a new allocation which might conflict with the automatic fd close in the above ceph_closedir(). Full PeerReplayer::do_synchronize() has been reworked to close fds properly, depending on whether ceph_fdopendir() has been already applied to them. Additionally for the sake of uniformity this reworks incremental do_synchronize() in a way to do final fd closings similar to full implementation. Plus this effectively reverts ceph@bd78bdc as it looks like a wrong approach to fight broken file descriptor references. No much sense in reopening of the current snapshot's root folder on each new entry processing. Instead this patch just doesn't close it from the beginning. Fixes: https://tracker.ceph.com/issues/68853 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7a747bc)
Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
ceph#55619 eliminates the need for ceph_close() call after successful ceph_fdopendir() one. And introduces automatic file descriptor's close when corresponding ceph_closedir() is called. That hasty ceph_close() call makes file descriptor available for a new allocation which might conflict with the automatic fd close in the above ceph_closedir(). Full PeerReplayer::do_synchronize() has been reworked to close fds properly, depending on whether ceph_fdopendir() has been already applied to them. Additionally for the sake of uniformity this reworks incremental do_synchronize() in a way to do final fd closings similar to full implementation. Plus this effectively reverts ceph@bd78bdc as it looks like a wrong approach to fight broken file descriptor references. No much sense in reopening of the current snapshot's root folder on each new entry processing. Instead this patch just doesn't close it from the beginning. Fixes: https://tracker.ceph.com/issues/68853 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7a747bc)
Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
ceph#55619 eliminates the need for ceph_close() call after successful ceph_fdopendir() one. And introduces automatic file descriptor's close when corresponding ceph_closedir() is called. That hasty ceph_close() call makes file descriptor available for a new allocation which might conflict with the automatic fd close in the above ceph_closedir(). Full PeerReplayer::do_synchronize() has been reworked to close fds properly, depending on whether ceph_fdopendir() has been already applied to them. Additionally for the sake of uniformity this reworks incremental do_synchronize() in a way to do final fd closings similar to full implementation. Plus this effectively reverts ceph@bd78bdc as it looks like a wrong approach to fight broken file descriptor references. No much sense in reopening of the current snapshot's root folder on each new entry processing. Instead this patch just doesn't close it from the beginning. Fixes: https://tracker.ceph.com/issues/68853 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7a747bc)
Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
ceph#55619 eliminates the need for ceph_close() call after successful ceph_fdopendir() one. And introduces automatic file descriptor's close when corresponding ceph_closedir() is called. That hasty ceph_close() call makes file descriptor available for a new allocation which might conflict with the automatic fd close in the above ceph_closedir(). Full PeerReplayer::do_synchronize() has been reworked to close fds properly, depending on whether ceph_fdopendir() has been already applied to them. Additionally for the sake of uniformity this reworks incremental do_synchronize() in a way to do final fd closings similar to full implementation. Plus this effectively reverts ceph@bd78bdc as it looks like a wrong approach to fight broken file descriptor references. No much sense in reopening of the current snapshot's root folder on each new entry processing. Instead this patch just doesn't close it from the beginning. Fixes: https://tracker.ceph.com/issues/68853 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7a747bc)
Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
ceph#55619 eliminates the need for ceph_close() call after successful ceph_fdopendir() one. And introduces automatic file descriptor's close when corresponding ceph_closedir() is called. That hasty ceph_close() call makes file descriptor available for a new allocation which might conflict with the automatic fd close in the above ceph_closedir(). Full PeerReplayer::do_synchronize() has been reworked to close fds properly, depending on whether ceph_fdopendir() has been already applied to them. Additionally for the sake of uniformity this reworks incremental do_synchronize() in a way to do final fd closings similar to full implementation. Plus this effectively reverts ceph@bd78bdc as it looks like a wrong approach to fight broken file descriptor references. No much sense in reopening of the current snapshot's root folder on each new entry processing. Instead this patch just doesn't close it from the beginning. Fixes: https://tracker.ceph.com/issues/68853 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7a747bc)
Likely ceph/ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
ceph/ceph#55619 eliminates the need for ceph_close() call after successful ceph_fdopendir() one. And introduces automatic file descriptor's close when corresponding ceph_closedir() is called. That hasty ceph_close() call makes file descriptor available for a new allocation which might conflict with the automatic fd close in the above ceph_closedir(). Full PeerReplayer::do_synchronize() has been reworked to close fds properly, depending on whether ceph_fdopendir() has been already applied to them. Additionally for the sake of uniformity this reworks incremental do_synchronize() in a way to do final fd closings similar to full implementation. Plus this effectively reverts ceph/ceph@bd78bdc as it looks like a wrong approach to fight broken file descriptor references. No much sense in reopening of the current snapshot's root folder on each new entry processing. Instead this patch just doesn't close it from the beginning. Fixes: https://tracker.ceph.com/issues/68853 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7a747bc)
Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
ceph#55619 eliminates the need for ceph_close() call after successful ceph_fdopendir() one. And introduces automatic file descriptor's close when corresponding ceph_closedir() is called. That hasty ceph_close() call makes file descriptor available for a new allocation which might conflict with the automatic fd close in the above ceph_closedir(). Full PeerReplayer::do_synchronize() has been reworked to close fds properly, depending on whether ceph_fdopendir() has been already applied to them. Additionally for the sake of uniformity this reworks incremental do_synchronize() in a way to do final fd closings similar to full implementation. Plus this effectively reverts ceph@bd78bdc as it looks like a wrong approach to fight broken file descriptor references. No much sense in reopening of the current snapshot's root folder on each new entry processing. Instead this patch just doesn't close it from the beginning. Fixes: https://tracker.ceph.com/issues/68853 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7a747bc)
Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
ceph#55619 eliminates the need for ceph_close() call after successful ceph_fdopendir() one. And introduces automatic file descriptor's close when corresponding ceph_closedir() is called. That hasty ceph_close() call makes file descriptor available for a new allocation which might conflict with the automatic fd close in the above ceph_closedir(). Full PeerReplayer::do_synchronize() has been reworked to close fds properly, depending on whether ceph_fdopendir() has been already applied to them. Additionally for the sake of uniformity this reworks incremental do_synchronize() in a way to do final fd closings similar to full implementation. Plus this effectively reverts ceph@bd78bdc as it looks like a wrong approach to fight broken file descriptor references. No much sense in reopening of the current snapshot's root folder on each new entry processing. Instead this patch just doesn't close it from the beginning. Fixes: https://tracker.ceph.com/issues/68853 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7a747bc)
Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
ceph#55619 eliminates the need for ceph_close() call after successful ceph_fdopendir() one. And introduces automatic file descriptor's close when corresponding ceph_closedir() is called. That hasty ceph_close() call makes file descriptor available for a new allocation which might conflict with the automatic fd close in the above ceph_closedir(). Full PeerReplayer::do_synchronize() has been reworked to close fds properly, depending on whether ceph_fdopendir() has been already applied to them. Additionally for the sake of uniformity this reworks incremental do_synchronize() in a way to do final fd closings similar to full implementation. Plus this effectively reverts ceph@bd78bdc as it looks like a wrong approach to fight broken file descriptor references. No much sense in reopening of the current snapshot's root folder on each new entry processing. Instead this patch just doesn't close it from the beginning. Fixes: https://tracker.ceph.com/issues/68853 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7a747bc)
Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit a27ed27) Conflicts: src/test/libcephfs/CMakeLists.txt libcephfs/client: pin inode/dentry for an opened directory Fixes: https://tracker.ceph.com/issues/69092 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7b8a86f) test/libcephfs: remove warning in Windows build Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit c9d7345) common/ceph_fs: Enable O_DIRECTORY|O_NOFOLLOWUP flags translation under Win in ceph_flags_sys2wire() Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 4badc83) cephfs-mirror-hostpapa-reef (cherry picked from commit e904f62) cephfs/client: dir_reset_t::reset() - add missing fd reset. Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit a27ed27) Conflicts: src/test/libcephfs/CMakeLists.txt libcephfs/client: pin inode/dentry for an opened directory Fixes: https://tracker.ceph.com/issues/69092 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7b8a86f) test/libcephfs: remove warning in Windows build Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit c9d7345) common/ceph_fs: Enable O_DIRECTORY|O_NOFOLLOWUP flags translation under Win in ceph_flags_sys2wire() Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 4badc83) cephfs-mirror-hostpapa-reef (cherry picked from commit e904f62) cephfs/client: dir_reset_t::reset() - add missing fd reset. Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit a27ed27) Conflicts: src/test/libcephfs/CMakeLists.txt libcephfs/client: pin inode/dentry for an opened directory Fixes: https://tracker.ceph.com/issues/69092 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7b8a86f) test/libcephfs: remove warning in Windows build Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit c9d7345) common/ceph_fs: Enable O_DIRECTORY|O_NOFOLLOWUP flags translation under Win in ceph_flags_sys2wire() Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 4badc83) cephfs-mirror-hostpapa-reef (cherry picked from commit e904f62) cephfs/client: dir_reset_t::reset() - add missing fd reset. Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit a27ed27) Conflicts: src/test/libcephfs/CMakeLists.txt libcephfs/client: pin inode/dentry for an opened directory Fixes: https://tracker.ceph.com/issues/69092 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7b8a86f) test/libcephfs: remove warning in Windows build Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit c9d7345) common/ceph_fs: Enable O_DIRECTORY|O_NOFOLLOWUP flags translation under Win in ceph_flags_sys2wire() Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 4badc83) cephfs-mirror-hostpapa-reef (cherry picked from commit e904f62) cephfs/client: dir_reset_t::reset() - add missing fd reset. Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit a27ed27) Conflicts: src/test/libcephfs/CMakeLists.txt libcephfs/client: pin inode/dentry for an opened directory Fixes: https://tracker.ceph.com/issues/69092 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7b8a86f) test/libcephfs: remove warning in Windows build Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit c9d7345) common/ceph_fs: Enable O_DIRECTORY|O_NOFOLLOWUP flags translation under Win in ceph_flags_sys2wire() Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 4badc83) cephfs-mirror-hostpapa-reef (cherry picked from commit e904f62) cephfs/client: dir_reset_t::reset() - add missing fd reset. Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit a27ed27) Conflicts: src/test/libcephfs/CMakeLists.txt libcephfs/client: pin inode/dentry for an opened directory Fixes: https://tracker.ceph.com/issues/69092 Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 7b8a86f) test/libcephfs: remove warning in Windows build Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit c9d7345) common/ceph_fs: Enable O_DIRECTORY|O_NOFOLLOWUP flags translation under Win in ceph_flags_sys2wire() Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 4badc83) cephfs-mirror-hostpapa-reef (cherry picked from commit e904f62) cephfs/client: dir_reset_t::reset() - add missing fd reset. Likely ceph#55619 missed that. Signed-off-by: Igor Fedotov <igor.fedotov@croit.io> (cherry picked from commit 6f1d21c)
Based on posix specification, the fd passed to fdopendir() will be closed by closedir(). However CephFS client wasn't doing that. If the user opened a directory using ceph_openat(), for example, and then passed the returned fd to ceph_fdopendir(), the created Fh associated with the new open was never destroyed.
This patch records the fd used in ceph_fdopendir() so that it can be closed when ceph_closedir() is called.
Fixes: https://tracker.ceph.com/issues/64479
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
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard cephadmjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume toxjenkins test windowsjenkins test rook e2e