mds: update dentry lease for async create
PATCH 1/1 mds: update dentry lease for async create
Otherwise ceph_d_delete() may return 1 for the dentry, which makes dput() prune the dentry and clear parent dir's complete flag.
--- fs/ceph/file.c | 3 +++ 1 file changed, 3 insertions(+)
fs/ceph/file.c +3 -0
@@ -480,6 +480,9 @@ static int try_prep_async_create(struct inode *dir, struct dentry *dentry,if (d_in_lookup (dentry)) {if (!__ceph_dir_is_complete (ci)) goto no_async; +spin_lock (&dentry->d_lock); + di->lease_shared_gen =atomic_read (&ci->i_shared_gen); +spin_unlock (&dentry->d_lock); }else if (atomic_read (&ci->i_shared_gen) !=READ_ONCE (di->lease_shared_gen)) { goto no_async;
Signature · 1 line
2.21.1
Quoted 13 lines · Zheng
Otherwise
ceph_d_delete()may return 1 for the dentry, which makesdput()prune the dentry and clear parent dir's complete flag.Signed-off-by "Yan, Zheng" <[email protected]>--- fs/ceph/file.c | 3 +++ 1 file changed, 3 insertions(+)fs/ceph/file.c +0
-0
fs/ceph/file.c static int try_prep_async_create(struct inode *dir, struct dentry *dentry, · line 488
Quoted 9 lines
fs/ceph/file.c +3
-0@@ -480,6 +480,9 @@ static int try_prep_async_create(struct inode *dir, struct dentry *dentry,if (d_in_lookup (dentry)) {if (!__ceph_dir_is_complete (ci)) goto no_async; +spin_lock (&dentry->d_lock); + di->lease_shared_gen =atomic_read (&ci->i_shared_gen); +spin_unlock (&dentry->d_lock); }else if (atomic_read (&ci->i_shared_gen) !=READ_ONCE (di->lease_shared_gen)) { goto no_async;
Good catch, merged into testing (with small update to changelog s/mds:/ceph:/)
Thanks!
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 18 lines · Jeff Layton
Quoted 17 lines · Zheng
Otherwise
ceph_d_delete()may return 1 for the dentry, which makesdput()prune the dentry and clear parent dir's complete flag.Signed-off-by "Yan, Zheng" <[email protected]>--- fs/ceph/file.c | 3 +++ 1 file changed, 3 insertions(+)fs/ceph/file.c +1
-0@@ -480,6 +480,9 @@ static int try_prep_async_create(struct inode *dir, struct dentry *dentry,if (d_in_lookup (dentry)) {if (!__ceph_dir_is_complete (ci)) goto no_async; +spin_lock (&dentry->d_lock);
Quoted 9 lines
fs/ceph/file.c static int try_prep_async_create(struct inode *dir, struct dentry *dentry, · line 488
Quoted 5 lines
fs/ceph/file.c +2
-0+ di->lease_shared_gen =atomic_read (&ci->i_shared_gen); +spin_unlock (&dentry->d_lock); }else if (atomic_read (&ci->i_shared_gen) !=READ_ONCE (di->lease_shared_gen)) { goto no_async;Good catch, merged into testing (with small update to changelog s/mds:/ceph:/)
One related comment though. This patch implies that lease_shared_gen is protected by the d_lock, but it's not held when it's assigned in ceph_lookup. Should it be?
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 29 lines · Jeff Layton
Quoted 18 lines · Jeff Layton
Quoted 17 lines · Zheng
Otherwise
ceph_d_delete()may return 1 for the dentry, which makesdput()prune the dentry and clear parent dir's complete flag.Signed-off-by "Yan, Zheng" <[email protected]>--- fs/ceph/file.c | 3 +++ 1 file changed, 3 insertions(+)fs/ceph/file.c +1
-0@@ -480,6 +480,9 @@ static int try_prep_async_create(struct inode *dir, struct dentry *dentry,if (d_in_lookup (dentry)) {if (!__ceph_dir_is_complete (ci)) goto no_async; +spin_lock (&dentry->d_lock);Quoted 9 lines
fs/ceph/file.c static int try_prep_async_create(struct inode *dir, struct dentry *dentry, · line 488
Quoted 5 lines
fs/ceph/file.c +2
-0+ di->lease_shared_gen =atomic_read (&ci->i_shared_gen); +spin_unlock (&dentry->d_lock); }else if (atomic_read (&ci->i_shared_gen) !=READ_ONCE (di->lease_shared_gen)) { goto no_async;Good catch, merged into testing (with small update to changelog s/mds:/ceph:/)
Quoted 4 lines
One related comment though. This patch implies that
lease_shared_genis protected by thed_lock, but it's not held when it's assigned inceph_lookup. Should it be?
we only assign and compare lease_shared_gen, I think it doesn't matter if it's protected by d_lock or not
Quoted 30 lines · Zheng
Quoted 29 lines · Jeff Layton
Quoted 27 lines · Jeff Layton
Quoted 13 lines · Zheng
Otherwise
ceph_d_delete()may return 1 for the dentry, which makesdput()prune the dentry and clear parent dir's complete flag.Signed-off-by "Yan, Zheng" <[email protected]>--- fs/ceph/file.c | 3 +++ 1 file changed, 3 insertions(+)fs/ceph/file.c +0
-0fs/ceph/file.c static int try_prep_async_create(struct inode *dir, struct dentry *dentry, · line 488
Quoted 9 lines
fs/ceph/file.c +3
-0@@ -480,6 +480,9 @@ static int try_prep_async_create(struct inode *dir, struct dentry *dentry,if (d_in_lookup (dentry)) {if (!__ceph_dir_is_complete (ci)) goto no_async; +spin_lock (&dentry->d_lock); + di->lease_shared_gen =atomic_read (&ci->i_shared_gen); +spin_unlock (&dentry->d_lock); }else if (atomic_read (&ci->i_shared_gen) !=READ_ONCE (di->lease_shared_gen)) { goto no_async;Good catch, merged into testing (with small update to changelog s/mds:/ceph:/)
Quoted 8 lines
Quoted 4 lines
One related comment though. This patch implies that
lease_shared_genis protected by thed_lock, but it's not held when it's assigned inceph_lookup. Should it be?we only assign and compare
lease_shared_gen, I think it doesn't matter if it's protected byd_lockor not
That's the case here too. Do we need the d_lock in try_prep_async_create? Maybe lease_shared_gen should also be an atomic_t?
Signature · 1 line
Jeff Layton <[email protected]>