ceph: flush all the caps release when syncing the whole filesystem
v2 cover ceph: flush all the caps release when syncing the whole filesystem
From: Xiubo Li <[email protected]>
V2:
- missed the first patch in V1.
Xiubo Li (2):
ceph: rename ceph_flush_cap_releases to
ceph_flush_session_cap_releases
ceph: flush all the caps release when syncing the whole filesystem
fs/ceph/caps.c | 24 +++++++++++++++++++++++- fs/ceph/mds_client.c | 11 ++++++----- fs/ceph/mds_client.h | 4 ++-- fs/ceph/super.c | 1 + fs/ceph/super.h | 1 + 5 files changed, 33 insertions(+), 8 deletions(-)
Signature · 1 line
2.43.0
PATCH v2 1/2 ceph: rename ceph_flush_cap_releases to ceph_flush_session_cap_releases
From: Xiubo Li <[email protected]>
Prepare for adding a helper to flush the cap releases for all sessions.
URL: https://tracker.ceph.com/issues/67221
--- fs/ceph/caps.c | 2 +- fs/ceph/mds_client.c | 10 +++++----- fs/ceph/mds_client.h | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-)
fs/ceph/caps.c +1 -1
@@ -4630,7 +4630,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,__ceph_queue_cap_release (session, cap);spin_unlock (&session->s_cap_lock); } -ceph_flush_cap_releases (mdsc, session); +ceph_flush_session_cap_releases (mdsc, session); goto done; bad:
fs/ceph/mds_client.c +5 -5
@@ -2266,7 +2266,7 @@ int ceph_trim_caps(struct ceph_mds_client *mdsc, trim_caps - remaining); } -ceph_flush_cap_releases (mdsc, session); +ceph_flush_session_cap_releases (mdsc, session);return 0 ; }
@@ -2448,7 +2448,7 @@ static void ceph_cap_release_work(struct work_struct *work)ceph_put_mds_session (session); } -void ceph_flush_cap_releases (struct ceph_mds_client *mdsc, +void ceph_flush_session_cap_releases (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) {struct ceph_client *cl = mdsc->fsc->client;
@@ -2475,7 +2475,7 @@ void __ceph_queue_cap_release(struct ceph_mds_session *session, session->s_num_cap_releases++;if (!(session->s_num_cap_releases %CEPH_CAPS_PER_RELEASE )) -ceph_flush_cap_releases (session->s_mdsc, session); +ceph_flush_session_cap_releases (session->s_mdsc, session); }static void ceph_cap_reclaim_work (struct work_struct *work)
@@ -4368,7 +4368,7 @@ static void handle_session(struct ceph_mds_session *session,/* flush cap releases */ spin_lock (&session->s_cap_lock);if (session->s_num_cap_releases) -ceph_flush_cap_releases (mdsc, session); +ceph_flush_session_cap_releases (mdsc, session);spin_unlock (&session->s_cap_lock);send_flushmsg_ack (mdsc, session, seq);
@@ -5474,7 +5474,7 @@ static void delayed_work(struct work_struct *work) }mutex_unlock (&mdsc->mutex); -ceph_flush_cap_releases (mdsc, s); +ceph_flush_session_cap_releases (mdsc, s);mutex_lock (&s->s_mutex);if (renew_caps)
fs/ceph/mds_client.h +2 -2
@@ -602,8 +602,8 @@ extern void ceph_mdsc_iterate_sessions(struct ceph_mds_client *mdsc,extern struct ceph_msg *ceph_create_session_msg (u32 op,u64 seq);extern void __ceph_queue_cap_release (struct ceph_mds_session *session,struct ceph_cap *cap); -extern void ceph_flush_cap_releases (struct ceph_mds_client *mdsc, -struct ceph_mds_session *session); +extern void ceph_flush_session_cap_releases (struct ceph_mds_client *mdsc, +struct ceph_mds_session *session);extern void ceph_queue_cap_reclaim_work (struct ceph_mds_client *mdsc);extern void ceph_reclaim_caps_nr (struct ceph_mds_client *mdsc,int nr);extern void ceph_queue_cap_unlink_work (struct ceph_mds_client *mdsc);
Signature · 1 line
2.43.0
PATCH v2 2/2 ceph: flush all the caps release when syncing the whole filesystem
In reply to [email protected]From: Xiubo Li <[email protected]>
We have hit a race between cap releases and cap revoke request that will cause the check_caps() to miss sending a cap revoke ack to MDS. And the client will depend on the cap release to release that revoking caps, which could be delayed for some unknown reasons.
In Kclient we have figured out the RCA about race and we need a way to explictly trigger this manually could help to get rid of the caps revoke stuck issue.
URL: https://tracker.ceph.com/issues/67221
--- fs/ceph/caps.c | 22 ++++++++++++++++++++++ fs/ceph/mds_client.c | 1 + fs/ceph/super.c | 1 + fs/ceph/super.h | 1 + 4 files changed, 25 insertions(+)
fs/ceph/caps.c +22 -0
@@ -4729,6 +4729,28 @@ void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc)ceph_mdsc_iterate_sessions (mdsc, flush_dirty_session_caps, true); } +/* +* Flush all cap releases to the mds +*/ +static void flush_cap_releases (struct ceph_mds_session *s) +{ +struct ceph_mds_client *mdsc = s->s_mdsc; +struct ceph_client *cl = mdsc->fsc->client; + +doutc (cl,"begin\n" ); +spin_lock (&s->s_cap_lock); +if (s->s_num_cap_releases) +ceph_flush_session_cap_releases (mdsc, s); +spin_unlock (&s->s_cap_lock); +doutc (cl,"done\n" ); + +} + +void ceph_flush_cap_releases (struct ceph_mds_client *mdsc) +{ +ceph_mdsc_iterate_sessions (mdsc, flush_cap_releases, true); +} +void __ceph_touch_fmode (struct ceph_inode_info *ci,struct ceph_mds_client *mdsc,int fmode) {
fs/ceph/mds_client.c +1 -0
@@ -5904,6 +5904,7 @@ void ceph_mdsc_sync(struct ceph_mds_client *mdsc) want_tid = mdsc->last_tid;mutex_unlock (&mdsc->mutex); +ceph_flush_cap_releases (mdsc);ceph_flush_dirty_caps (mdsc);spin_lock (&mdsc->cap_dirty_lock); want_flush = mdsc->last_cap_flush_tid;
fs/ceph/super.c +1 -0
@@ -126,6 +126,7 @@ static int ceph_sync_fs(struct super_block *sb, int wait)if (!wait) {doutc (cl,"(non-blocking)\n" );ceph_flush_dirty_caps (fsc->mdsc); +ceph_flush_cap_releases (fsc->mdsc);doutc (cl,"(non-blocking) done\n" );return 0 ; }
fs/ceph/super.h +1 -0
@@ -1273,6 +1273,7 @@ extern bool __ceph_should_report_size(struct ceph_inode_info *ci);extern void ceph_check_caps (struct ceph_inode_info *ci,int flags);extern unsigned long ceph_check_delayed_caps (struct ceph_mds_client *mdsc);extern void ceph_flush_dirty_caps (struct ceph_mds_client *mdsc); +extern void ceph_flush_cap_releases (struct ceph_mds_client *mdsc);extern int ceph_drop_caps_for_unlink (struct inode *inode);extern int ceph_encode_inode_release (void **p,struct inode *inode,int mds,int drop,int unless,int force);
Signature · 1 line
2.43.0
Ilya Dryomov
maintainerQuoted 71 lines · On Tue, Jul 30, 2024 at 7:41 AM <[email protected]> wrote:
From: Xiubo Li <[email protected]>
We have hit a race between cap releases and cap revoke request that will cause the
check_caps()to miss sending a cap revoke ack to MDS. And the client will depend on the cap release to release that revoking caps, which could be delayed for some unknown reasons.In Kclient we have figured out the RCA about race and we need a way to explictly trigger this manually could help to get rid of the caps revoke stuck issue.
URL: https://tracker.ceph.com/issues/67221
Signed-off-by Xiubo Li <[email protected]>--- fs/ceph/caps.c | 22 ++++++++++++++++++++++ fs/ceph/mds_client.c | 1 + fs/ceph/super.c | 1 + fs/ceph/super.h | 1 + 4 files changed, 25 insertions(+)fs/ceph/caps.c +22
-0@@ -4729,6 +4729,28 @@ void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc)ceph_mdsc_iterate_sessions (mdsc, flush_dirty_session_caps, true); } +/* +* Flush all cap releases to the mds +*/ +static void flush_cap_releases (struct ceph_mds_session *s) +{ +struct ceph_mds_client *mdsc = s->s_mdsc; +struct ceph_client *cl = mdsc->fsc->client; + +doutc (cl,"begin\n" ); +spin_lock (&s->s_cap_lock); +if (s->s_num_cap_releases) +ceph_flush_session_cap_releases (mdsc, s); +spin_unlock (&s->s_cap_lock); +doutc (cl,"done\n" ); + +} + +void ceph_flush_cap_releases (struct ceph_mds_client *mdsc) +{ +ceph_mdsc_iterate_sessions (mdsc, flush_cap_releases, true); +} +void __ceph_touch_fmode (struct ceph_inode_info *ci,struct ceph_mds_client *mdsc,int fmode) {fs/ceph/mds_client.c +1
-0@@ -5904,6 +5904,7 @@ void ceph_mdsc_sync(struct ceph_mds_client *mdsc) want_tid = mdsc->last_tid;mutex_unlock (&mdsc->mutex); +ceph_flush_cap_releases (mdsc);ceph_flush_dirty_caps (mdsc);spin_lock (&mdsc->cap_dirty_lock); want_flush = mdsc->last_cap_flush_tid;fs/ceph/super.c +0
-0
fs/ceph/super.c static int ceph_sync_fs(struct super_block *sb, int wait) · line 129
Quoted 4 lines
fs/ceph/super.c +1
-0@@ -126,6 +126,7 @@ static int ceph_sync_fs(struct super_block *sb, int wait)if (!wait) {doutc (cl,"(non-blocking)\n" );ceph_flush_dirty_caps (fsc->mdsc); +ceph_flush_cap_releases (fsc->mdsc);
Hi Xiubo,
Is there a significance to flushing cap releases before dirty caps on the blocking path and doing it vice versa (i.e. flushing cap releases after dirty caps) on the non-blocking path?
Thanks,
Ilya
Quoted 77 lines · Ilya Dryomov
Quoted 70 lines · On Tue, Jul 30, 2024 at 7:41 AM <[email protected]> wrote:
From: Xiubo Li <[email protected]>
We have hit a race between cap releases and cap revoke request that will cause the
check_caps()to miss sending a cap revoke ack to MDS. And the client will depend on the cap release to release that revoking caps, which could be delayed for some unknown reasons.In Kclient we have figured out the RCA about race and we need a way to explictly trigger this manually could help to get rid of the caps revoke stuck issue.
URL: https://tracker.ceph.com/issues/67221
Signed-off-by Xiubo Li <[email protected]>--- fs/ceph/caps.c | 22 ++++++++++++++++++++++ fs/ceph/mds_client.c | 1 + fs/ceph/super.c | 1 + fs/ceph/super.h | 1 + 4 files changed, 25 insertions(+)fs/ceph/caps.c +22
-0@@ -4729,6 +4729,28 @@ void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc)ceph_mdsc_iterate_sessions (mdsc, flush_dirty_session_caps, true); } +/* +* Flush all cap releases to the mds +*/ +static void flush_cap_releases (struct ceph_mds_session *s) +{ +struct ceph_mds_client *mdsc = s->s_mdsc; +struct ceph_client *cl = mdsc->fsc->client; + +doutc (cl,"begin\n" ); +spin_lock (&s->s_cap_lock); +if (s->s_num_cap_releases) +ceph_flush_session_cap_releases (mdsc, s); +spin_unlock (&s->s_cap_lock); +doutc (cl,"done\n" ); + +} + +void ceph_flush_cap_releases (struct ceph_mds_client *mdsc) +{ +ceph_mdsc_iterate_sessions (mdsc, flush_cap_releases, true); +} +void __ceph_touch_fmode (struct ceph_inode_info *ci,struct ceph_mds_client *mdsc,int fmode) {fs/ceph/mds_client.c +1
-0@@ -5904,6 +5904,7 @@ void ceph_mdsc_sync(struct ceph_mds_client *mdsc) want_tid = mdsc->last_tid;mutex_unlock (&mdsc->mutex); +ceph_flush_cap_releases (mdsc);ceph_flush_dirty_caps (mdsc);spin_lock (&mdsc->cap_dirty_lock); want_flush = mdsc->last_cap_flush_tid;fs/ceph/super.c +0
-0fs/ceph/super.c static int ceph_sync_fs(struct super_block *sb, int wait) · line 129
Quoted 4 lines
fs/ceph/super.c +1
-0@@ -126,6 +126,7 @@ static int ceph_sync_fs(struct super_block *sb, int wait)if (!wait) {doutc (cl,"(non-blocking)\n" );ceph_flush_dirty_caps (fsc->mdsc); +ceph_flush_cap_releases (fsc->mdsc);Hi Xiubo,
Quoted 3 lines
Is there a significance to flushing cap releases before dirty caps on the blocking path and doing it vice versa (i.e. flushing cap releases after dirty caps) on the non-blocking path?
Hi Ilya,
The dirty caps and the cap releases are not related.
If caps are dirty it should be in the dirty list anyway in theory. Else when the file is closed or inode is released will it be in the release lists.
Thanks
- Xiubo
Quoted 4 lines
Thanks,
Ilya
Ilya Dryomov
maintainerQuoted 84 lines · Xiubo Li
Quoted 77 lines · Ilya Dryomov
Quoted 70 lines · On Tue, Jul 30, 2024 at 7:41 AM <[email protected]> wrote:
From: Xiubo Li <[email protected]>
We have hit a race between cap releases and cap revoke request that will cause the
check_caps()to miss sending a cap revoke ack to MDS. And the client will depend on the cap release to release that revoking caps, which could be delayed for some unknown reasons.In Kclient we have figured out the RCA about race and we need a way to explictly trigger this manually could help to get rid of the caps revoke stuck issue.
URL: https://tracker.ceph.com/issues/67221
Signed-off-by Xiubo Li <[email protected]>--- fs/ceph/caps.c | 22 ++++++++++++++++++++++ fs/ceph/mds_client.c | 1 + fs/ceph/super.c | 1 + fs/ceph/super.h | 1 + 4 files changed, 25 insertions(+)fs/ceph/caps.c +22
-0@@ -4729,6 +4729,28 @@ void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc)ceph_mdsc_iterate_sessions (mdsc, flush_dirty_session_caps, true); } +/* +* Flush all cap releases to the mds +*/ +static void flush_cap_releases (struct ceph_mds_session *s) +{ +struct ceph_mds_client *mdsc = s->s_mdsc; +struct ceph_client *cl = mdsc->fsc->client; + +doutc (cl,"begin\n" ); +spin_lock (&s->s_cap_lock); +if (s->s_num_cap_releases) +ceph_flush_session_cap_releases (mdsc, s); +spin_unlock (&s->s_cap_lock); +doutc (cl,"done\n" ); + +} + +void ceph_flush_cap_releases (struct ceph_mds_client *mdsc) +{ +ceph_mdsc_iterate_sessions (mdsc, flush_cap_releases, true); +} +void __ceph_touch_fmode (struct ceph_inode_info *ci,struct ceph_mds_client *mdsc,int fmode) {fs/ceph/mds_client.c +1
-0@@ -5904,6 +5904,7 @@ void ceph_mdsc_sync(struct ceph_mds_client *mdsc) want_tid = mdsc->last_tid;mutex_unlock (&mdsc->mutex); +ceph_flush_cap_releases (mdsc);ceph_flush_dirty_caps (mdsc);spin_lock (&mdsc->cap_dirty_lock); want_flush = mdsc->last_cap_flush_tid;fs/ceph/super.c +0
-0fs/ceph/super.c static int ceph_sync_fs(struct super_block *sb, int wait) · line 129
Quoted 4 lines
fs/ceph/super.c +1
-0@@ -126,6 +126,7 @@ static int ceph_sync_fs(struct super_block *sb, int wait)if (!wait) {doutc (cl,"(non-blocking)\n" );ceph_flush_dirty_caps (fsc->mdsc); +ceph_flush_cap_releases (fsc->mdsc);Hi Xiubo,
Quoted 3 lines
Is there a significance to flushing cap releases before dirty caps on the blocking path and doing it vice versa (i.e. flushing cap releases after dirty caps) on the non-blocking path?
Quoted 7 lines
Hi Ilya,
The dirty caps and the cap releases are not related.
If caps are dirty it should be in the dirty list anyway in theory. Else when the file is closed or inode is released will it be in the release lists.
So doing
ceph_flush_dirty_caps(mdsc);
ceph_flush_cap_releases(mdsc);in both cases just so that it's consistent is fine, right?
Thanks,
Ilya
Quoted 90 lines · Ilya Dryomov
Quoted 82 lines · Xiubo Li
Quoted 77 lines · Ilya Dryomov
Quoted 70 lines · On Tue, Jul 30, 2024 at 7:41 AM <[email protected]> wrote:
From: Xiubo Li <[email protected]>
We have hit a race between cap releases and cap revoke request that will cause the
check_caps()to miss sending a cap revoke ack to MDS. And the client will depend on the cap release to release that revoking caps, which could be delayed for some unknown reasons.In Kclient we have figured out the RCA about race and we need a way to explictly trigger this manually could help to get rid of the caps revoke stuck issue.
URL: https://tracker.ceph.com/issues/67221
Signed-off-by Xiubo Li <[email protected]>--- fs/ceph/caps.c | 22 ++++++++++++++++++++++ fs/ceph/mds_client.c | 1 + fs/ceph/super.c | 1 + fs/ceph/super.h | 1 + 4 files changed, 25 insertions(+)fs/ceph/caps.c +22
-0@@ -4729,6 +4729,28 @@ void ceph_flush_dirty_caps(struct ceph_mds_client *mdsc)ceph_mdsc_iterate_sessions (mdsc, flush_dirty_session_caps, true); } +/* +* Flush all cap releases to the mds +*/ +static void flush_cap_releases (struct ceph_mds_session *s) +{ +struct ceph_mds_client *mdsc = s->s_mdsc; +struct ceph_client *cl = mdsc->fsc->client; + +doutc (cl,"begin\n" ); +spin_lock (&s->s_cap_lock); +if (s->s_num_cap_releases) +ceph_flush_session_cap_releases (mdsc, s); +spin_unlock (&s->s_cap_lock); +doutc (cl,"done\n" ); + +} + +void ceph_flush_cap_releases (struct ceph_mds_client *mdsc) +{ +ceph_mdsc_iterate_sessions (mdsc, flush_cap_releases, true); +} +void __ceph_touch_fmode (struct ceph_inode_info *ci,struct ceph_mds_client *mdsc,int fmode) {fs/ceph/mds_client.c +1
-0@@ -5904,6 +5904,7 @@ void ceph_mdsc_sync(struct ceph_mds_client *mdsc) want_tid = mdsc->last_tid;mutex_unlock (&mdsc->mutex); +ceph_flush_cap_releases (mdsc);ceph_flush_dirty_caps (mdsc);spin_lock (&mdsc->cap_dirty_lock); want_flush = mdsc->last_cap_flush_tid;fs/ceph/super.c +0
-0fs/ceph/super.c static int ceph_sync_fs(struct super_block *sb, int wait) · line 129
Quoted 4 lines
fs/ceph/super.c +1
-0@@ -126,6 +126,7 @@ static int ceph_sync_fs(struct super_block *sb, int wait)if (!wait) {doutc (cl,"(non-blocking)\n" );ceph_flush_dirty_caps (fsc->mdsc); +ceph_flush_cap_releases (fsc->mdsc);Hi Xiubo,
Quoted 3 lines
Is there a significance to flushing cap releases before dirty caps on the blocking path and doing it vice versa (i.e. flushing cap releases after dirty caps) on the non-blocking path?
Quoted 7 lines
Hi Ilya,
The dirty caps and the cap releases are not related.
If caps are dirty it should be in the dirty list anyway in theory. Else when the file is closed or inode is released will it be in the release lists.
Quoted 6 lines
So doing
ceph_flush_dirty_caps(mdsc); ceph_flush_cap_releases(mdsc);in both cases just so that it's consistent is fine, right?
Yeah.
Quoted 4 lines
Thanks,
Ilya