ceph: retransmit REQUEST_CLOSE every second if we don't get a response
PATCH 1/1 ceph: retransmit REQUEST_CLOSE every second if we don't get a response
Patrick reported a case where the MDS and client client had racing session messages to one anothe. The MDS was sending caps to the client and the client was sending a CEPH_SESSION_REQUEST_CLOSE message in order to unmount.
Because they were sending at the same time, the REQUEST_CLOSE had too old a sequence number, and the MDS dropped it on the floor. On the client, this would have probably manifested as a 60s hang during umount. The MDS ended up blocklisting the client.
Once we've decided to issue a REQUEST_CLOSE, we're finished with the session, so just keep sending them until the MDS acknowledges that.
Change the code to retransmit a REQUEST_CLOSE every second if the session hasn't changed state yet. Give up and throw a warning after mount_timeout elapses if we haven't gotten a response.
URL: https://tracker.ceph.com/issues/47563
--- fs/ceph/mds_client.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-)
fs/ceph/mds_client.c +32 -21
@@ -1878,7 +1878,7 @@ static int request_close_session(struct ceph_mds_session *session)static int __close_session (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) { -if (session->s_state >=CEPH_MDS_SESSION_CLOSING ) +if (session->s_state >CEPH_MDS_SESSION_CLOSING )return 0 ; session->s_state =CEPH_MDS_SESSION_CLOSING ;return request_close_session (session);
@@ -4692,38 +4692,49 @@ static bool done_closing_sessions(struct ceph_mds_client *mdsc, int skipped)return atomic_read (&mdsc->num_sessions) <= skipped; } +static bool umount_timed_out (unsigned long timeo) +{ +if (time_before (jiffies, timeo)) +return false; +pr_warn ("ceph: unable to close all sessions\n" ); +return true; +} +/* * called after sb is ro. */ void ceph_mdsc_close_sessions (struct ceph_mds_client *mdsc) { -struct ceph_options *opts = mdsc->fsc->client->options;struct ceph_mds_session *session; -int i; -int skipped =0 ; +int i, ret; +int skipped; +unsigned long timeo = jiffies + +ceph_timeout_jiffies (mdsc->fsc->client->options->mount_timeout);dout ("close_sessions\n" );/* close sessions */ -mutex_lock (&mdsc->mutex); -for (i =0 ; i < mdsc->max_sessions; i++) { - session =__ceph_lookup_mds_session (mdsc, i); -if (!session) -continue ; -mutex_unlock (&mdsc->mutex); -mutex_lock (&session->s_mutex); -if (__close_session (mdsc, session) <=0 ) - skipped++; -mutex_unlock (&session->s_mutex); -ceph_put_mds_session (session); +do { + skipped =0 ;mutex_lock (&mdsc->mutex); - } -mutex_unlock (&mdsc->mutex); +for (i =0 ; i < mdsc->max_sessions; i++) { + session =__ceph_lookup_mds_session (mdsc, i); +if (!session) +continue ; +mutex_unlock (&mdsc->mutex); +mutex_lock (&session->s_mutex); +if (__close_session (mdsc, session) <=0 ) + skipped++; +mutex_unlock (&session->s_mutex); +ceph_put_mds_session (session); +mutex_lock (&mdsc->mutex); + } +mutex_unlock (&mdsc->mutex); -dout ("waiting for sessions to close\n" ); -wait_event_timeout (mdsc->session_close_wq, -done_closing_sessions (mdsc, skipped), -ceph_timeout_jiffies (opts->mount_timeout)); +dout ("waiting for sessions to close\n" ); + ret =wait_event_timeout (mdsc->session_close_wq, +done_closing_sessions (mdsc, skipped),HZ ); + }while (!ret && !umount_timed_out (timeo));/* tear down remaining sessions */ mutex_lock (&mdsc->mutex);
Signature · 1 line
2.26.2
Ilya Dryomov
maintainerQuoted 109 lines · Jeff Layton
Patrick reported a case where the MDS and client client had racing session messages to one anothe. The MDS was sending caps to the client and the client was sending a
CEPH_SESSION_REQUEST_CLOSEmessage in order to unmount.Because they were sending at the same time, the
REQUEST_CLOSEhad too old a sequence number, and the MDS dropped it on the floor. On the client, this would have probably manifested as a 60s hang during umount. The MDS ended up blocklisting the client.Once we've decided to issue a
REQUEST_CLOSE, we're finished with the session, so just keep sending them until the MDS acknowledges that.Change the code to retransmit a
REQUEST_CLOSEevery second if the session hasn't changed state yet. Give up and throw a warning aftermount_timeoutelapses if we haven't gotten a response.URL: https://tracker.ceph.com/issues/47563
Reported-by Patrick Donnelly <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/mds_client.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-)fs/ceph/mds_client.c +32
-22@@ -1878,7 +1878,7 @@ static int request_close_session(struct ceph_mds_session *session)static int __close_session (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) { -if (session->s_state >=CEPH_MDS_SESSION_CLOSING ) +if (session->s_state >CEPH_MDS_SESSION_CLOSING )return 0 ; session->s_state =CEPH_MDS_SESSION_CLOSING ;return request_close_session (session);@@ -4692,38 +4692,49 @@ static bool done_closing_sessions(struct ceph_mds_client *mdsc, int skipped)return atomic_read (&mdsc->num_sessions) <= skipped; } +static bool umount_timed_out (unsigned long timeo) +{ +if (time_before (jiffies, timeo)) +return false; +pr_warn ("ceph: unable to close all sessions\n" ); +return true; +} +/* * called after sb is ro. */ void ceph_mdsc_close_sessions (struct ceph_mds_client *mdsc) { -struct ceph_options *opts = mdsc->fsc->client->options;struct ceph_mds_session *session; -int i; -int skipped =0 ; +int i, ret; +int skipped; +unsigned long timeo = jiffies + +ceph_timeout_jiffies (mdsc->fsc->client->options->mount_timeout);dout ("close_sessions\n" );/* close sessions */ -mutex_lock (&mdsc->mutex); -for (i =0 ; i < mdsc->max_sessions; i++) { - session =__ceph_lookup_mds_session (mdsc, i); -if (!session) -continue ; -mutex_unlock (&mdsc->mutex); -mutex_lock (&session->s_mutex); -if (__close_session (mdsc, session) <=0 ) - skipped++; -mutex_unlock (&session->s_mutex); -ceph_put_mds_session (session); +do { + skipped =0 ;mutex_lock (&mdsc->mutex); - } -mutex_unlock (&mdsc->mutex); +for (i =0 ; i < mdsc->max_sessions; i++) { + session =__ceph_lookup_mds_session (mdsc, i); +if (!session) +continue ; +mutex_unlock (&mdsc->mutex); +mutex_lock (&session->s_mutex); +if (__close_session (mdsc, session) <=0 ) + skipped++; +mutex_unlock (&session->s_mutex); +ceph_put_mds_session (session); +mutex_lock (&mdsc->mutex); + } +mutex_unlock (&mdsc->mutex); -dout ("waiting for sessions to close\n" ); -wait_event_timeout (mdsc->session_close_wq, -done_closing_sessions (mdsc, skipped), -ceph_timeout_jiffies (opts->mount_timeout)); +dout ("waiting for sessions to close\n" ); + ret =wait_event_timeout (mdsc->session_close_wq, +done_closing_sessions (mdsc, skipped),HZ ); + }while (!ret && !umount_timed_out (timeo));/* tear down remaining sessions */ mutex_lock (&mdsc->mutex); --
Quoted 2 lines
2.26.2
Hi Jeff,
This seems wrong to me, at least conceptually. Is the same patch getting applied to ceph-fuse?
Pretending to not know anything about the client <-> MDS protocol, two questions immediately come to mind. Why is MDS allowed to drop REQUEST_CLOSE? If the client is really done with the session, why does it block on the acknowledgement from the MDS?
Thanks,
Ilya
Quoted 114 lines · Ilya Dryomov
Quoted 108 lines · Jeff Layton
Patrick reported a case where the MDS and client client had racing session messages to one anothe. The MDS was sending caps to the client and the client was sending a
CEPH_SESSION_REQUEST_CLOSEmessage in order to unmount.Because they were sending at the same time, the
REQUEST_CLOSEhad too old a sequence number, and the MDS dropped it on the floor. On the client, this would have probably manifested as a 60s hang during umount. The MDS ended up blocklisting the client.Once we've decided to issue a
REQUEST_CLOSE, we're finished with the session, so just keep sending them until the MDS acknowledges that.Change the code to retransmit a
REQUEST_CLOSEevery second if the session hasn't changed state yet. Give up and throw a warning aftermount_timeoutelapses if we haven't gotten a response.URL: https://tracker.ceph.com/issues/47563
Reported-by Patrick Donnelly <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/mds_client.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-)fs/ceph/mds_client.c +32
-22@@ -1878,7 +1878,7 @@ static int request_close_session(struct ceph_mds_session *session)static int __close_session (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) { -if (session->s_state >=CEPH_MDS_SESSION_CLOSING ) +if (session->s_state >CEPH_MDS_SESSION_CLOSING )return 0 ; session->s_state =CEPH_MDS_SESSION_CLOSING ;return request_close_session (session);@@ -4692,38 +4692,49 @@ static bool done_closing_sessions(struct ceph_mds_client *mdsc, int skipped)return atomic_read (&mdsc->num_sessions) <= skipped; } +static bool umount_timed_out (unsigned long timeo) +{ +if (time_before (jiffies, timeo)) +return false; +pr_warn ("ceph: unable to close all sessions\n" ); +return true; +} +/* * called after sb is ro. */ void ceph_mdsc_close_sessions (struct ceph_mds_client *mdsc) { -struct ceph_options *opts = mdsc->fsc->client->options;struct ceph_mds_session *session; -int i; -int skipped =0 ; +int i, ret; +int skipped; +unsigned long timeo = jiffies + +ceph_timeout_jiffies (mdsc->fsc->client->options->mount_timeout);dout ("close_sessions\n" );/* close sessions */ -mutex_lock (&mdsc->mutex); -for (i =0 ; i < mdsc->max_sessions; i++) { - session =__ceph_lookup_mds_session (mdsc, i); -if (!session) -continue ; -mutex_unlock (&mdsc->mutex); -mutex_lock (&session->s_mutex); -if (__close_session (mdsc, session) <=0 ) - skipped++; -mutex_unlock (&session->s_mutex); -ceph_put_mds_session (session); +do { + skipped =0 ;mutex_lock (&mdsc->mutex); - } -mutex_unlock (&mdsc->mutex); +for (i =0 ; i < mdsc->max_sessions; i++) { + session =__ceph_lookup_mds_session (mdsc, i); +if (!session) +continue ; +mutex_unlock (&mdsc->mutex); +mutex_lock (&session->s_mutex); +if (__close_session (mdsc, session) <=0 ) + skipped++; +mutex_unlock (&session->s_mutex); +ceph_put_mds_session (session); +mutex_lock (&mdsc->mutex); + } +mutex_unlock (&mdsc->mutex); -dout ("waiting for sessions to close\n" ); -wait_event_timeout (mdsc->session_close_wq, -done_closing_sessions (mdsc, skipped), -ceph_timeout_jiffies (opts->mount_timeout)); +dout ("waiting for sessions to close\n" ); + ret =wait_event_timeout (mdsc->session_close_wq, +done_closing_sessions (mdsc, skipped),HZ ); + }while (!ret && !umount_timed_out (timeo));/* tear down remaining sessions */ mutex_lock (&mdsc->mutex); --Quoted 2 lines
2.26.2
Hi Jeff,
Quoted 3 lines
This seems wrong to me, at least conceptually. Is the same patch getting applied to ceph-fuse?
It's a grotesque workaround, I will grant you. I'm not sure what we want to do for ceph-fuse yet but it does seem to have the same issue. Probably, we should plan to do a similar fix there once we settle on the right approach.
Quoted 3 lines
Pretending to not know anything about the client <-> MDS protocol, two questions immediately come to mind. Why is MDS allowed to drop
REQUEST_CLOSE?
It really seems like a protocol design flaw.
IIUC, the idea overall with the low-level ceph protocol seems to be that the client should retransmit (or reevaluate, in the case of caps) calls that were in flight when the seq number changes.
The REQUEST_CLOSE handling seems to have followed suit on the MDS side, but it doesn't really make a lot of sense for that, IMO.
Quoted 3 lines
If the client is really done with the session, why does it block on the acknowledgement from the MDS?
That's certainly one thing we could do instead. That would likely prevent the unmount hangs, but would do nothing for the MDS deciding to blacklist it. Maybe that's good enough though and we should fix that problem on the MDS side by having it ignore the seq number on REQUEST_CLOSE?
Signature · 1 line
Jeff Layton <[email protected]>
Ilya Dryomov
maintainerQuoted 129 lines · Jeff Layton
Quoted 114 lines · Ilya Dryomov
Quoted 108 lines · Jeff Layton
Patrick reported a case where the MDS and client client had racing session messages to one anothe. The MDS was sending caps to the client and the client was sending a
CEPH_SESSION_REQUEST_CLOSEmessage in order to unmount.Because they were sending at the same time, the
REQUEST_CLOSEhad too old a sequence number, and the MDS dropped it on the floor. On the client, this would have probably manifested as a 60s hang during umount. The MDS ended up blocklisting the client.Once we've decided to issue a
REQUEST_CLOSE, we're finished with the session, so just keep sending them until the MDS acknowledges that.Change the code to retransmit a
REQUEST_CLOSEevery second if the session hasn't changed state yet. Give up and throw a warning aftermount_timeoutelapses if we haven't gotten a response.URL: https://tracker.ceph.com/issues/47563
Reported-by Patrick Donnelly <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/mds_client.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-)fs/ceph/mds_client.c +32
-22@@ -1878,7 +1878,7 @@ static int request_close_session(struct ceph_mds_session *session)static int __close_session (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) { -if (session->s_state >=CEPH_MDS_SESSION_CLOSING ) +if (session->s_state >CEPH_MDS_SESSION_CLOSING )return 0 ; session->s_state =CEPH_MDS_SESSION_CLOSING ;return request_close_session (session);@@ -4692,38 +4692,49 @@ static bool done_closing_sessions(struct ceph_mds_client *mdsc, int skipped)return atomic_read (&mdsc->num_sessions) <= skipped; } +static bool umount_timed_out (unsigned long timeo) +{ +if (time_before (jiffies, timeo)) +return false; +pr_warn ("ceph: unable to close all sessions\n" ); +return true; +} +/* * called after sb is ro. */ void ceph_mdsc_close_sessions (struct ceph_mds_client *mdsc) { -struct ceph_options *opts = mdsc->fsc->client->options;struct ceph_mds_session *session; -int i; -int skipped =0 ; +int i, ret; +int skipped; +unsigned long timeo = jiffies + +ceph_timeout_jiffies (mdsc->fsc->client->options->mount_timeout);dout ("close_sessions\n" );/* close sessions */ -mutex_lock (&mdsc->mutex); -for (i =0 ; i < mdsc->max_sessions; i++) { - session =__ceph_lookup_mds_session (mdsc, i); -if (!session) -continue ; -mutex_unlock (&mdsc->mutex); -mutex_lock (&session->s_mutex); -if (__close_session (mdsc, session) <=0 ) - skipped++; -mutex_unlock (&session->s_mutex); -ceph_put_mds_session (session); +do { + skipped =0 ;mutex_lock (&mdsc->mutex); - } -mutex_unlock (&mdsc->mutex); +for (i =0 ; i < mdsc->max_sessions; i++) { + session =__ceph_lookup_mds_session (mdsc, i); +if (!session) +continue ; +mutex_unlock (&mdsc->mutex); +mutex_lock (&session->s_mutex); +if (__close_session (mdsc, session) <=0 ) + skipped++; +mutex_unlock (&session->s_mutex); +ceph_put_mds_session (session); +mutex_lock (&mdsc->mutex); + } +mutex_unlock (&mdsc->mutex); -dout ("waiting for sessions to close\n" ); -wait_event_timeout (mdsc->session_close_wq, -done_closing_sessions (mdsc, skipped), -ceph_timeout_jiffies (opts->mount_timeout)); +dout ("waiting for sessions to close\n" ); + ret =wait_event_timeout (mdsc->session_close_wq, +done_closing_sessions (mdsc, skipped),HZ ); + }while (!ret && !umount_timed_out (timeo));/* tear down remaining sessions */ mutex_lock (&mdsc->mutex); --Quoted 2 lines
2.26.2
Hi Jeff,
Quoted 3 lines
This seems wrong to me, at least conceptually. Is the same patch getting applied to ceph-fuse?
It's a grotesque workaround, I will grant you. I'm not sure what we want to do for ceph-fuse yet but it does seem to have the same issue. Probably, we should plan to do a similar fix there once we settle on the right approach.
Quoted 3 lines
Pretending to not know anything about the client <-> MDS protocol, two questions immediately come to mind. Why is MDS allowed to drop
REQUEST_CLOSE?
Quoted 8 lines
It really seems like a protocol design flaw.
IIUC, the idea overall with the low-level ceph protocol seems to be that the client should retransmit (or reevaluate, in the case of caps) calls that were in flight when the seq number changes.
The
REQUEST_CLOSEhandling seems to have followed suit on the MDS side, but it doesn't really make a lot of sense for that, IMO.
(edit of my reply to https://github.com/ceph/ceph/pull/37619)
After taking a look at the MDS code, it really seemed like it had been written with the expectation that REQUEST_CLOSE would be resent, so I dug around. I don't fully understand these "push" sequence numbers yet, but there is probably some race that requires the client to confirm that it saw the sequence number, even if the session is about to go. Sage is probably the only one who might remember at this point.
The kernel client already has the code to retry REQUEST_CLOSE, only every five seconds instead every second. See check_session_state() which is called from delayed_work() in mds_client.c. It looks like it got broken by Xiubo's commit fa9967734227 ("ceph: fix potential mdsc use-after-free crash") which conditioned delayed_work() on mdsc->stopping -- hence the misbehaviour.
Thanks,
Ilya
Quoted 144 lines · Ilya Dryomov
Quoted 125 lines · Jeff Layton
Quoted 113 lines · Ilya Dryomov
Quoted 108 lines · Jeff Layton
Patrick reported a case where the MDS and client client had racing session messages to one anothe. The MDS was sending caps to the client and the client was sending a
CEPH_SESSION_REQUEST_CLOSEmessage in order to unmount.Because they were sending at the same time, the
REQUEST_CLOSEhad too old a sequence number, and the MDS dropped it on the floor. On the client, this would have probably manifested as a 60s hang during umount. The MDS ended up blocklisting the client.Once we've decided to issue a
REQUEST_CLOSE, we're finished with the session, so just keep sending them until the MDS acknowledges that.Change the code to retransmit a
REQUEST_CLOSEevery second if the session hasn't changed state yet. Give up and throw a warning aftermount_timeoutelapses if we haven't gotten a response.URL: https://tracker.ceph.com/issues/47563
Reported-by Patrick Donnelly <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/mds_client.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-)fs/ceph/mds_client.c +32
-22@@ -1878,7 +1878,7 @@ static int request_close_session(struct ceph_mds_session *session)static int __close_session (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) { -if (session->s_state >=CEPH_MDS_SESSION_CLOSING ) +if (session->s_state >CEPH_MDS_SESSION_CLOSING )return 0 ; session->s_state =CEPH_MDS_SESSION_CLOSING ;return request_close_session (session);@@ -4692,38 +4692,49 @@ static bool done_closing_sessions(struct ceph_mds_client *mdsc, int skipped)return atomic_read (&mdsc->num_sessions) <= skipped; } +static bool umount_timed_out (unsigned long timeo) +{ +if (time_before (jiffies, timeo)) +return false; +pr_warn ("ceph: unable to close all sessions\n" ); +return true; +} +/* * called after sb is ro. */ void ceph_mdsc_close_sessions (struct ceph_mds_client *mdsc) { -struct ceph_options *opts = mdsc->fsc->client->options;struct ceph_mds_session *session; -int i; -int skipped =0 ; +int i, ret; +int skipped; +unsigned long timeo = jiffies + +ceph_timeout_jiffies (mdsc->fsc->client->options->mount_timeout);dout ("close_sessions\n" );/* close sessions */ -mutex_lock (&mdsc->mutex); -for (i =0 ; i < mdsc->max_sessions; i++) { - session =__ceph_lookup_mds_session (mdsc, i); -if (!session) -continue ; -mutex_unlock (&mdsc->mutex); -mutex_lock (&session->s_mutex); -if (__close_session (mdsc, session) <=0 ) - skipped++; -mutex_unlock (&session->s_mutex); -ceph_put_mds_session (session); +do { + skipped =0 ;mutex_lock (&mdsc->mutex); - } -mutex_unlock (&mdsc->mutex); +for (i =0 ; i < mdsc->max_sessions; i++) { + session =__ceph_lookup_mds_session (mdsc, i); +if (!session) +continue ; +mutex_unlock (&mdsc->mutex); +mutex_lock (&session->s_mutex); +if (__close_session (mdsc, session) <=0 ) + skipped++; +mutex_unlock (&session->s_mutex); +ceph_put_mds_session (session); +mutex_lock (&mdsc->mutex); + } +mutex_unlock (&mdsc->mutex); -dout ("waiting for sessions to close\n" ); -wait_event_timeout (mdsc->session_close_wq, -done_closing_sessions (mdsc, skipped), -ceph_timeout_jiffies (opts->mount_timeout)); +dout ("waiting for sessions to close\n" ); + ret =wait_event_timeout (mdsc->session_close_wq, +done_closing_sessions (mdsc, skipped),HZ ); + }while (!ret && !umount_timed_out (timeo));/* tear down remaining sessions */ mutex_lock (&mdsc->mutex); --Quoted 2 lines
2.26.2
Hi Jeff,
Quoted 3 lines
This seems wrong to me, at least conceptually. Is the same patch getting applied to ceph-fuse?
It's a grotesque workaround, I will grant you. I'm not sure what we want to do for ceph-fuse yet but it does seem to have the same issue. Probably, we should plan to do a similar fix there once we settle on the right approach.
Quoted 3 lines
Pretending to not know anything about the client <-> MDS protocol, two questions immediately come to mind. Why is MDS allowed to drop
REQUEST_CLOSE?Quoted 8 lines
It really seems like a protocol design flaw.
IIUC, the idea overall with the low-level ceph protocol seems to be that the client should retransmit (or reevaluate, in the case of caps) calls that were in flight when the seq number changes.
The
REQUEST_CLOSEhandling seems to have followed suit on the MDS side, but it doesn't really make a lot of sense for that, IMO.(edit of my reply to https://github.com/ceph/ceph/pull/37619)
After taking a look at the MDS code, it really seemed like it had been written with the expectation that
REQUEST_CLOSEwould be resent, so I dug around. I don't fully understand these "push" sequence numbers yet, but there is probably some race that requires the client to confirm that it saw the sequence number, even if the session is about to go. Sage is probably the only one who might remember at this point.
Quoted 6 lines
The kernel client already has the code to retry
REQUEST_CLOSE, only every five seconds instead every second. Seecheck_session_state()which is called fromdelayed_work()inmds_client.c. It looks like it got broken by Xiubo's commitfa9967734227("ceph: fix potential mdsc use-after-free crash") which conditioneddelayed_work()onmdsc->stopping-- hence the misbehaviour.
Without this commit it will hit this issue too. The umount old code will try to close sessions asynchronously, and then tries to cancel the delayed work, during which the last queued delayed_work() timer might be fired. This commit makes it easier to be reproduced.
Thanks,
Xiubo
Quoted 4 lines
Thanks,
Ilya
Quoted 152 lines · Xiubo Li
Quoted 144 lines · Ilya Dryomov
Quoted 125 lines · Jeff Layton
Quoted 113 lines · Ilya Dryomov
Quoted 108 lines · Jeff Layton
Patrick reported a case where the MDS and client client had racing session messages to one anothe. The MDS was sending caps to the client and the client was sending a
CEPH_SESSION_REQUEST_CLOSEmessage in order to unmount.Because they were sending at the same time, the
REQUEST_CLOSEhad too old a sequence number, and the MDS dropped it on the floor. On the client, this would have probably manifested as a 60s hang during umount. The MDS ended up blocklisting the client.Once we've decided to issue a
REQUEST_CLOSE, we're finished with the session, so just keep sending them until the MDS acknowledges that.Change the code to retransmit a
REQUEST_CLOSEevery second if the session hasn't changed state yet. Give up and throw a warning aftermount_timeoutelapses if we haven't gotten a response.URL: https://tracker.ceph.com/issues/47563
Reported-by Patrick Donnelly <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/mds_client.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-)fs/ceph/mds_client.c +32
-22@@ -1878,7 +1878,7 @@ static int request_close_session(struct ceph_mds_session *session)static int __close_session (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) { -if (session->s_state >=CEPH_MDS_SESSION_CLOSING ) +if (session->s_state >CEPH_MDS_SESSION_CLOSING )return 0 ; session->s_state =CEPH_MDS_SESSION_CLOSING ;return request_close_session (session);@@ -4692,38 +4692,49 @@ static bool done_closing_sessions(struct ceph_mds_client *mdsc, int skipped)return atomic_read (&mdsc->num_sessions) <= skipped; } +static bool umount_timed_out (unsigned long timeo) +{ +if (time_before (jiffies, timeo)) +return false; +pr_warn ("ceph: unable to close all sessions\n" ); +return true; +} +/* * called after sb is ro. */ void ceph_mdsc_close_sessions (struct ceph_mds_client *mdsc) { -struct ceph_options *opts = mdsc->fsc->client->options;struct ceph_mds_session *session; -int i; -int skipped =0 ; +int i, ret; +int skipped; +unsigned long timeo = jiffies + +ceph_timeout_jiffies (mdsc->fsc->client->options->mount_timeout);dout ("close_sessions\n" );/* close sessions */ -mutex_lock (&mdsc->mutex); -for (i =0 ; i < mdsc->max_sessions; i++) { - session =__ceph_lookup_mds_session (mdsc, i); -if (!session) -continue ; -mutex_unlock (&mdsc->mutex); -mutex_lock (&session->s_mutex); -if (__close_session (mdsc, session) <=0 ) - skipped++; -mutex_unlock (&session->s_mutex); -ceph_put_mds_session (session); +do { + skipped =0 ;mutex_lock (&mdsc->mutex); - } -mutex_unlock (&mdsc->mutex); +for (i =0 ; i < mdsc->max_sessions; i++) { + session =__ceph_lookup_mds_session (mdsc, i); +if (!session) +continue ; +mutex_unlock (&mdsc->mutex); +mutex_lock (&session->s_mutex); +if (__close_session (mdsc, session) <=0 ) + skipped++; +mutex_unlock (&session->s_mutex); +ceph_put_mds_session (session); +mutex_lock (&mdsc->mutex); + } +mutex_unlock (&mdsc->mutex); -dout ("waiting for sessions to close\n" ); -wait_event_timeout (mdsc->session_close_wq, -done_closing_sessions (mdsc, skipped), -ceph_timeout_jiffies (opts->mount_timeout)); +dout ("waiting for sessions to close\n" ); + ret =wait_event_timeout (mdsc->session_close_wq, +done_closing_sessions (mdsc, skipped),HZ ); + }while (!ret && !umount_timed_out (timeo));/* tear down remaining sessions */ mutex_lock (&mdsc->mutex); --Quoted 2 lines
2.26.2
Hi Jeff,
Quoted 3 lines
This seems wrong to me, at least conceptually. Is the same patch getting applied to ceph-fuse?
It's a grotesque workaround, I will grant you. I'm not sure what we want to do for ceph-fuse yet but it does seem to have the same issue. Probably, we should plan to do a similar fix there once we settle on the right approach.
Quoted 3 lines
Pretending to not know anything about the client <-> MDS protocol, two questions immediately come to mind. Why is MDS allowed to drop
REQUEST_CLOSE?Quoted 8 lines
It really seems like a protocol design flaw.
IIUC, the idea overall with the low-level ceph protocol seems to be that the client should retransmit (or reevaluate, in the case of caps) calls that were in flight when the seq number changes.
The
REQUEST_CLOSEhandling seems to have followed suit on the MDS side, but it doesn't really make a lot of sense for that, IMO.(edit of my reply to https://github.com/ceph/ceph/pull/37619)
After taking a look at the MDS code, it really seemed like it had been written with the expectation that
REQUEST_CLOSEwould be resent, so I dug around. I don't fully understand these "push" sequence numbers yet, but there is probably some race that requires the client to confirm that it saw the sequence number, even if the session is about to go. Sage is probably the only one who might remember at this point.Quoted 6 lines
The kernel client already has the code to retry
REQUEST_CLOSE, only every five seconds instead every second. Seecheck_session_state()which is called fromdelayed_work()inmds_client.c. It looks like it got broken by Xiubo's commitfa9967734227("ceph: fix potential mdsc use-after-free crash") which conditioneddelayed_work()onmdsc->stopping-- hence the misbehaviour.
Quoted 5 lines
Without this commit it will hit this issue too. The umount old code will try to close sessions asynchronously, and then tries to cancel the delayed work, during which the last queued
delayed_work()timer might be fired. This commit makes it easier to be reproduced.
Fixing the potential races to ensure that this is retransmitted is an option, but I'm not sure it's the best one. Here's what I think we probably ought to do:
1/ fix the MDS to just ignore the sequence number on REQUEST_CLOSE. I don't see that the sequence number has any value on that call, as it's an indicator that the client is finished with the session, and it's never going to change its mind and do something different if the sequence is wrong. I have a PR for that here:
https://github.com/ceph/ceph/pull/37619
2/ fix the clients to not wait on the REQUEST_CLOSE reply. As soon as the call is sent, tear down the session and proceed with unmounting. The client doesn't really care what the MDS has to say after that point, so we may as well not wait on it before proceeding.
Thoughts?
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 167 lines · Jeff Layton
Quoted 151 lines · Xiubo Li
Quoted 144 lines · Ilya Dryomov
Quoted 125 lines · Jeff Layton
Quoted 113 lines · Ilya Dryomov
Quoted 108 lines · Jeff Layton
Patrick reported a case where the MDS and client client had racing session messages to one anothe. The MDS was sending caps to the client and the client was sending a
CEPH_SESSION_REQUEST_CLOSEmessage in order to unmount.Because they were sending at the same time, the
REQUEST_CLOSEhad too old a sequence number, and the MDS dropped it on the floor. On the client, this would have probably manifested as a 60s hang during umount. The MDS ended up blocklisting the client.Once we've decided to issue a
REQUEST_CLOSE, we're finished with the session, so just keep sending them until the MDS acknowledges that.Change the code to retransmit a
REQUEST_CLOSEevery second if the session hasn't changed state yet. Give up and throw a warning aftermount_timeoutelapses if we haven't gotten a response.URL: https://tracker.ceph.com/issues/47563
Reported-by Patrick Donnelly <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/mds_client.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-)fs/ceph/mds_client.c +32
-22@@ -1878,7 +1878,7 @@ static int request_close_session(struct ceph_mds_session *session)static int __close_session (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) { -if (session->s_state >=CEPH_MDS_SESSION_CLOSING ) +if (session->s_state >CEPH_MDS_SESSION_CLOSING )return 0 ; session->s_state =CEPH_MDS_SESSION_CLOSING ;return request_close_session (session);@@ -4692,38 +4692,49 @@ static bool done_closing_sessions(struct ceph_mds_client *mdsc, int skipped)return atomic_read (&mdsc->num_sessions) <= skipped; } +static bool umount_timed_out (unsigned long timeo) +{ +if (time_before (jiffies, timeo)) +return false; +pr_warn ("ceph: unable to close all sessions\n" ); +return true; +} +/* * called after sb is ro. */ void ceph_mdsc_close_sessions (struct ceph_mds_client *mdsc) { -struct ceph_options *opts = mdsc->fsc->client->options;struct ceph_mds_session *session; -int i; -int skipped =0 ; +int i, ret; +int skipped; +unsigned long timeo = jiffies + +ceph_timeout_jiffies (mdsc->fsc->client->options->mount_timeout);dout ("close_sessions\n" );/* close sessions */ -mutex_lock (&mdsc->mutex); -for (i =0 ; i < mdsc->max_sessions; i++) { - session =__ceph_lookup_mds_session (mdsc, i); -if (!session) -continue ; -mutex_unlock (&mdsc->mutex); -mutex_lock (&session->s_mutex); -if (__close_session (mdsc, session) <=0 ) - skipped++; -mutex_unlock (&session->s_mutex); -ceph_put_mds_session (session); +do { + skipped =0 ;mutex_lock (&mdsc->mutex); - } -mutex_unlock (&mdsc->mutex); +for (i =0 ; i < mdsc->max_sessions; i++) { + session =__ceph_lookup_mds_session (mdsc, i); +if (!session) +continue ; +mutex_unlock (&mdsc->mutex); +mutex_lock (&session->s_mutex); +if (__close_session (mdsc, session) <=0 ) + skipped++; +mutex_unlock (&session->s_mutex); +ceph_put_mds_session (session); +mutex_lock (&mdsc->mutex); + } +mutex_unlock (&mdsc->mutex); -dout ("waiting for sessions to close\n" ); -wait_event_timeout (mdsc->session_close_wq, -done_closing_sessions (mdsc, skipped), -ceph_timeout_jiffies (opts->mount_timeout)); +dout ("waiting for sessions to close\n" ); + ret =wait_event_timeout (mdsc->session_close_wq, +done_closing_sessions (mdsc, skipped),HZ ); + }while (!ret && !umount_timed_out (timeo));/* tear down remaining sessions */ mutex_lock (&mdsc->mutex); --Quoted 2 lines
2.26.2
Hi Jeff,
Quoted 3 lines
This seems wrong to me, at least conceptually. Is the same patch getting applied to ceph-fuse?
It's a grotesque workaround, I will grant you. I'm not sure what we want to do for ceph-fuse yet but it does seem to have the same issue. Probably, we should plan to do a similar fix there once we settle on the right approach.
Quoted 3 lines
Pretending to not know anything about the client <-> MDS protocol, two questions immediately come to mind. Why is MDS allowed to drop
REQUEST_CLOSE?Quoted 8 lines
It really seems like a protocol design flaw.
IIUC, the idea overall with the low-level ceph protocol seems to be that the client should retransmit (or reevaluate, in the case of caps) calls that were in flight when the seq number changes.
The
REQUEST_CLOSEhandling seems to have followed suit on the MDS side, but it doesn't really make a lot of sense for that, IMO.(edit of my reply to https://github.com/ceph/ceph/pull/37619)
After taking a look at the MDS code, it really seemed like it had been written with the expectation that
REQUEST_CLOSEwould be resent, so I dug around. I don't fully understand these "push" sequence numbers yet, but there is probably some race that requires the client to confirm that it saw the sequence number, even if the session is about to go. Sage is probably the only one who might remember at this point.Quoted 6 lines
The kernel client already has the code to retry
REQUEST_CLOSE, only every five seconds instead every second. Seecheck_session_state()which is called fromdelayed_work()inmds_client.c. It looks like it got broken by Xiubo's commitfa9967734227("ceph: fix potential mdsc use-after-free crash") which conditioneddelayed_work()onmdsc->stopping-- hence the misbehaviour.Quoted 5 lines
Without this commit it will hit this issue too. The umount old code will try to close sessions asynchronously, and then tries to cancel the delayed work, during which the last queued
delayed_work()timer might be fired. This commit makes it easier to be reproduced.Fixing the potential races to ensure that this is retransmitted is an option, but I'm not sure it's the best one. Here's what I think we probably ought to do:
1/ fix the MDS to just ignore the sequence number on
REQUEST_CLOSE. I don't see that the sequence number has any value on that call, as it's an indicator that the client is finished with the session, and it's never going to change its mind and do something different if the sequence is wrong. I have a PR for that here:
Quoted 8 lines
https://github.com/ceph/ceph/pull/376192/ fix the clients to not wait on the
REQUEST_CLOSEreply. As soon as the call is sent, tear down the session and proceed with unmounting. The client doesn't really care what the MDS has to say after that point, so we may as well not wait on it before proceeding.Thoughts?
I am thinking possibly we can just check the session's state when the client receives a request from MDS which will increase the s_seq number, if the session is in CLOSING state, the client needs to resend the REQUEST_CLOSE request again.
Thanks.
Xiubo
Ilya Dryomov
maintainerQuoted 176 lines · Xiubo Li
Quoted 174 lines · Jeff Layton
Quoted 151 lines · Xiubo Li
Quoted 144 lines · Ilya Dryomov
Quoted 125 lines · Jeff Layton
Quoted 113 lines · Ilya Dryomov
Quoted 108 lines · Jeff Layton
Patrick reported a case where the MDS and client client had racing session messages to one anothe. The MDS was sending caps to the client and the client was sending a
CEPH_SESSION_REQUEST_CLOSEmessage in order to unmount.Because they were sending at the same time, the
REQUEST_CLOSEhad too old a sequence number, and the MDS dropped it on the floor. On the client, this would have probably manifested as a 60s hang during umount. The MDS ended up blocklisting the client.Once we've decided to issue a
REQUEST_CLOSE, we're finished with the session, so just keep sending them until the MDS acknowledges that.Change the code to retransmit a
REQUEST_CLOSEevery second if the session hasn't changed state yet. Give up and throw a warning aftermount_timeoutelapses if we haven't gotten a response.URL: https://tracker.ceph.com/issues/47563
Reported-by Patrick Donnelly <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/mds_client.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-)fs/ceph/mds_client.c +32
-22@@ -1878,7 +1878,7 @@ static int request_close_session(struct ceph_mds_session *session)static int __close_session (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) { -if (session->s_state >=CEPH_MDS_SESSION_CLOSING ) +if (session->s_state >CEPH_MDS_SESSION_CLOSING )return 0 ; session->s_state =CEPH_MDS_SESSION_CLOSING ;return request_close_session (session);@@ -4692,38 +4692,49 @@ static bool done_closing_sessions(struct ceph_mds_client *mdsc, int skipped)return atomic_read (&mdsc->num_sessions) <= skipped; } +static bool umount_timed_out (unsigned long timeo) +{ +if (time_before (jiffies, timeo)) +return false; +pr_warn ("ceph: unable to close all sessions\n" ); +return true; +} +/* * called after sb is ro. */ void ceph_mdsc_close_sessions (struct ceph_mds_client *mdsc) { -struct ceph_options *opts = mdsc->fsc->client->options;struct ceph_mds_session *session; -int i; -int skipped =0 ; +int i, ret; +int skipped; +unsigned long timeo = jiffies + +ceph_timeout_jiffies (mdsc->fsc->client->options->mount_timeout);dout ("close_sessions\n" );/* close sessions */ -mutex_lock (&mdsc->mutex); -for (i =0 ; i < mdsc->max_sessions; i++) { - session =__ceph_lookup_mds_session (mdsc, i); -if (!session) -continue ; -mutex_unlock (&mdsc->mutex); -mutex_lock (&session->s_mutex); -if (__close_session (mdsc, session) <=0 ) - skipped++; -mutex_unlock (&session->s_mutex); -ceph_put_mds_session (session); +do { + skipped =0 ;mutex_lock (&mdsc->mutex); - } -mutex_unlock (&mdsc->mutex); +for (i =0 ; i < mdsc->max_sessions; i++) { + session =__ceph_lookup_mds_session (mdsc, i); +if (!session) +continue ; +mutex_unlock (&mdsc->mutex); +mutex_lock (&session->s_mutex); +if (__close_session (mdsc, session) <=0 ) + skipped++; +mutex_unlock (&session->s_mutex); +ceph_put_mds_session (session); +mutex_lock (&mdsc->mutex); + } +mutex_unlock (&mdsc->mutex); -dout ("waiting for sessions to close\n" ); -wait_event_timeout (mdsc->session_close_wq, -done_closing_sessions (mdsc, skipped), -ceph_timeout_jiffies (opts->mount_timeout)); +dout ("waiting for sessions to close\n" ); + ret =wait_event_timeout (mdsc->session_close_wq, +done_closing_sessions (mdsc, skipped),HZ ); + }while (!ret && !umount_timed_out (timeo));/* tear down remaining sessions */ mutex_lock (&mdsc->mutex); --Quoted 2 lines
2.26.2
Hi Jeff,
Quoted 3 lines
This seems wrong to me, at least conceptually. Is the same patch getting applied to ceph-fuse?
It's a grotesque workaround, I will grant you. I'm not sure what we want to do for ceph-fuse yet but it does seem to have the same issue. Probably, we should plan to do a similar fix there once we settle on the right approach.
Quoted 3 lines
Pretending to not know anything about the client <-> MDS protocol, two questions immediately come to mind. Why is MDS allowed to drop
REQUEST_CLOSE?Quoted 8 lines
It really seems like a protocol design flaw.
IIUC, the idea overall with the low-level ceph protocol seems to be that the client should retransmit (or reevaluate, in the case of caps) calls that were in flight when the seq number changes.
The
REQUEST_CLOSEhandling seems to have followed suit on the MDS side, but it doesn't really make a lot of sense for that, IMO.(edit of my reply to https://github.com/ceph/ceph/pull/37619)
After taking a look at the MDS code, it really seemed like it had been written with the expectation that
REQUEST_CLOSEwould be resent, so I dug around. I don't fully understand these "push" sequence numbers yet, but there is probably some race that requires the client to confirm that it saw the sequence number, even if the session is about to go. Sage is probably the only one who might remember at this point.Quoted 6 lines
The kernel client already has the code to retry
REQUEST_CLOSE, only every five seconds instead every second. Seecheck_session_state()which is called fromdelayed_work()inmds_client.c. It looks like it got broken by Xiubo's commitfa9967734227("ceph: fix potential mdsc use-after-free crash") which conditioneddelayed_work()onmdsc->stopping-- hence the misbehaviour.Quoted 5 lines
Without this commit it will hit this issue too. The umount old code will try to close sessions asynchronously, and then tries to cancel the delayed work, during which the last queued
delayed_work()timer might be fired. This commit makes it easier to be reproduced.Fixing the potential races to ensure that this is retransmitted is an option, but I'm not sure it's the best one. Here's what I think we probably ought to do:
1/ fix the MDS to just ignore the sequence number on
REQUEST_CLOSE. I don't see that the sequence number has any value on that call, as it's an indicator that the client is finished with the session, and it's never going to change its mind and do something different if the sequence is wrong. I have a PR for that here:https://github.com/ceph/ceph/pull/376192/ fix the clients to not wait on the
REQUEST_CLOSEreply. As soon as the call is sent, tear down the session and proceed with unmounting. The client doesn't really care what the MDS has to say after that point, so we may as well not wait on it before proceeding.
Quoted 6 lines
Quoted 1 line
Thoughts?
I am thinking possibly we can just check the session's state when the client receives a request from MDS which will increase the
s_seqnumber, if the session is in CLOSING state, the client needs to resend theREQUEST_CLOSErequest again.
This is what ceph-fuse does, so I believe it is a viable approach.
As for changing the MDS to ignore the sequence number and changing the clients to not wait for the reply, I don't think so. It would be a protocol change (more or less) and I don't think it should be done until everyone has a clear understanding of the races that the sequence number is supposed to protect against. That might mean waiting for Sage to chime in...
Both clients have the code to resend REQUEST_CLOSE, added over ten years ago specifically to handle the case of MDS dropping the original message. Perhaps it's bogus at this point, but I'd be wary of ignoring it without having the full history.
Thanks,
Ilya
Quoted 175 lines · Xiubo Li
Quoted 174 lines · Jeff Layton
Quoted 151 lines · Xiubo Li
Quoted 144 lines · Ilya Dryomov
Quoted 125 lines · Jeff Layton
Quoted 113 lines · Ilya Dryomov
Quoted 108 lines · Jeff Layton
Patrick reported a case where the MDS and client client had racing session messages to one anothe. The MDS was sending caps to the client and the client was sending a
CEPH_SESSION_REQUEST_CLOSEmessage in order to unmount.Because they were sending at the same time, the
REQUEST_CLOSEhad too old a sequence number, and the MDS dropped it on the floor. On the client, this would have probably manifested as a 60s hang during umount. The MDS ended up blocklisting the client.Once we've decided to issue a
REQUEST_CLOSE, we're finished with the session, so just keep sending them until the MDS acknowledges that.Change the code to retransmit a
REQUEST_CLOSEevery second if the session hasn't changed state yet. Give up and throw a warning aftermount_timeoutelapses if we haven't gotten a response.URL: https://tracker.ceph.com/issues/47563
Reported-by Patrick Donnelly <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/mds_client.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-)fs/ceph/mds_client.c +32
-22@@ -1878,7 +1878,7 @@ static int request_close_session(struct ceph_mds_session *session)static int __close_session (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) { -if (session->s_state >=CEPH_MDS_SESSION_CLOSING ) +if (session->s_state >CEPH_MDS_SESSION_CLOSING )return 0 ; session->s_state =CEPH_MDS_SESSION_CLOSING ;return request_close_session (session);@@ -4692,38 +4692,49 @@ static bool done_closing_sessions(struct ceph_mds_client *mdsc, int skipped)return atomic_read (&mdsc->num_sessions) <= skipped; } +static bool umount_timed_out (unsigned long timeo) +{ +if (time_before (jiffies, timeo)) +return false; +pr_warn ("ceph: unable to close all sessions\n" ); +return true; +} +/* * called after sb is ro. */ void ceph_mdsc_close_sessions (struct ceph_mds_client *mdsc) { -struct ceph_options *opts = mdsc->fsc->client->options;struct ceph_mds_session *session; -int i; -int skipped =0 ; +int i, ret; +int skipped; +unsigned long timeo = jiffies + +ceph_timeout_jiffies (mdsc->fsc->client->options->mount_timeout);dout ("close_sessions\n" );/* close sessions */ -mutex_lock (&mdsc->mutex); -for (i =0 ; i < mdsc->max_sessions; i++) { - session =__ceph_lookup_mds_session (mdsc, i); -if (!session) -continue ; -mutex_unlock (&mdsc->mutex); -mutex_lock (&session->s_mutex); -if (__close_session (mdsc, session) <=0 ) - skipped++; -mutex_unlock (&session->s_mutex); -ceph_put_mds_session (session); +do { + skipped =0 ;mutex_lock (&mdsc->mutex); - } -mutex_unlock (&mdsc->mutex); +for (i =0 ; i < mdsc->max_sessions; i++) { + session =__ceph_lookup_mds_session (mdsc, i); +if (!session) +continue ; +mutex_unlock (&mdsc->mutex); +mutex_lock (&session->s_mutex); +if (__close_session (mdsc, session) <=0 ) + skipped++; +mutex_unlock (&session->s_mutex); +ceph_put_mds_session (session); +mutex_lock (&mdsc->mutex); + } +mutex_unlock (&mdsc->mutex); -dout ("waiting for sessions to close\n" ); -wait_event_timeout (mdsc->session_close_wq, -done_closing_sessions (mdsc, skipped), -ceph_timeout_jiffies (opts->mount_timeout)); +dout ("waiting for sessions to close\n" ); + ret =wait_event_timeout (mdsc->session_close_wq, +done_closing_sessions (mdsc, skipped),HZ ); + }while (!ret && !umount_timed_out (timeo));/* tear down remaining sessions */ mutex_lock (&mdsc->mutex); --Quoted 2 lines
2.26.2
Hi Jeff,
Quoted 3 lines
This seems wrong to me, at least conceptually. Is the same patch getting applied to ceph-fuse?
It's a grotesque workaround, I will grant you. I'm not sure what we want to do for ceph-fuse yet but it does seem to have the same issue. Probably, we should plan to do a similar fix there once we settle on the right approach.
Quoted 3 lines
Pretending to not know anything about the client <-> MDS protocol, two questions immediately come to mind. Why is MDS allowed to drop
REQUEST_CLOSE?Quoted 8 lines
It really seems like a protocol design flaw.
IIUC, the idea overall with the low-level ceph protocol seems to be that the client should retransmit (or reevaluate, in the case of caps) calls that were in flight when the seq number changes.
The
REQUEST_CLOSEhandling seems to have followed suit on the MDS side, but it doesn't really make a lot of sense for that, IMO.(edit of my reply to https://github.com/ceph/ceph/pull/37619)
After taking a look at the MDS code, it really seemed like it had been written with the expectation that
REQUEST_CLOSEwould be resent, so I dug around. I don't fully understand these "push" sequence numbers yet, but there is probably some race that requires the client to confirm that it saw the sequence number, even if the session is about to go. Sage is probably the only one who might remember at this point.Quoted 6 lines
The kernel client already has the code to retry
REQUEST_CLOSE, only every five seconds instead every second. Seecheck_session_state()which is called fromdelayed_work()inmds_client.c. It looks like it got broken by Xiubo's commitfa9967734227("ceph: fix potential mdsc use-after-free crash") which conditioneddelayed_work()onmdsc->stopping-- hence the misbehaviour.Quoted 5 lines
Without this commit it will hit this issue too. The umount old code will try to close sessions asynchronously, and then tries to cancel the delayed work, during which the last queued
delayed_work()timer might be fired. This commit makes it easier to be reproduced.Fixing the potential races to ensure that this is retransmitted is an option, but I'm not sure it's the best one. Here's what I think we probably ought to do:
1/ fix the MDS to just ignore the sequence number on
REQUEST_CLOSE. I don't see that the sequence number has any value on that call, as it's an indicator that the client is finished with the session, and it's never going to change its mind and do something different if the sequence is wrong. I have a PR for that here:https://github.com/ceph/ceph/pull/376192/ fix the clients to not wait on the
REQUEST_CLOSEreply. As soon as the call is sent, tear down the session and proceed with unmounting. The client doesn't really care what the MDS has to say after that point, so we may as well not wait on it before proceeding.
Quoted 7 lines
Quoted 1 line
Thoughts?
I am thinking possibly we can just check the session's state when the client receives a request from MDS which will increase the
s_seqnumber, if the session is in CLOSING state, the client needs to resend theREQUEST_CLOSErequest again.
That could be done, but that means adding extra complexity to the session handling code, which could really stand to be simplified instead.
mdsc->stopping and session->s_state seem to be protected by the mdsc->mutex, but session->s_seq is protected by the session->s_mutex.
There are 4 types of messages that increment the s_seq -- caps, leases, quotas and snaps. All of those would need to be changed to check for and retransmit REQUEST_CLOSE if one is outstanding.
So yeah, that could be done on the client side. If we were to do that, should we couple it with the MDS side fix to make it ignore the seq on REQUEST_CLOSE?
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 186 lines · Jeff Layton
Quoted 175 lines · Xiubo Li
Quoted 174 lines · Jeff Layton
Quoted 151 lines · Xiubo Li
Quoted 144 lines · Ilya Dryomov
Quoted 125 lines · Jeff Layton
Quoted 113 lines · Ilya Dryomov
Quoted 108 lines · Jeff Layton
Patrick reported a case where the MDS and client client had racing session messages to one anothe. The MDS was sending caps to the client and the client was sending a
CEPH_SESSION_REQUEST_CLOSEmessage in order to unmount.Because they were sending at the same time, the
REQUEST_CLOSEhad too old a sequence number, and the MDS dropped it on the floor. On the client, this would have probably manifested as a 60s hang during umount. The MDS ended up blocklisting the client.Once we've decided to issue a
REQUEST_CLOSE, we're finished with the session, so just keep sending them until the MDS acknowledges that.Change the code to retransmit a
REQUEST_CLOSEevery second if the session hasn't changed state yet. Give up and throw a warning aftermount_timeoutelapses if we haven't gotten a response.URL: https://tracker.ceph.com/issues/47563
Reported-by Patrick Donnelly <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/mds_client.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-)fs/ceph/mds_client.c +32
-22@@ -1878,7 +1878,7 @@ static int request_close_session(struct ceph_mds_session *session)static int __close_session (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) { -if (session->s_state >=CEPH_MDS_SESSION_CLOSING ) +if (session->s_state >CEPH_MDS_SESSION_CLOSING )return 0 ; session->s_state =CEPH_MDS_SESSION_CLOSING ;return request_close_session (session);@@ -4692,38 +4692,49 @@ static bool done_closing_sessions(struct ceph_mds_client *mdsc, int skipped)return atomic_read (&mdsc->num_sessions) <= skipped; } +static bool umount_timed_out (unsigned long timeo) +{ +if (time_before (jiffies, timeo)) +return false; +pr_warn ("ceph: unable to close all sessions\n" ); +return true; +} +/* * called after sb is ro. */ void ceph_mdsc_close_sessions (struct ceph_mds_client *mdsc) { -struct ceph_options *opts = mdsc->fsc->client->options;struct ceph_mds_session *session; -int i; -int skipped =0 ; +int i, ret; +int skipped; +unsigned long timeo = jiffies + +ceph_timeout_jiffies (mdsc->fsc->client->options->mount_timeout);dout ("close_sessions\n" );/* close sessions */ -mutex_lock (&mdsc->mutex); -for (i =0 ; i < mdsc->max_sessions; i++) { - session =__ceph_lookup_mds_session (mdsc, i); -if (!session) -continue ; -mutex_unlock (&mdsc->mutex); -mutex_lock (&session->s_mutex); -if (__close_session (mdsc, session) <=0 ) - skipped++; -mutex_unlock (&session->s_mutex); -ceph_put_mds_session (session); +do { + skipped =0 ;mutex_lock (&mdsc->mutex); - } -mutex_unlock (&mdsc->mutex); +for (i =0 ; i < mdsc->max_sessions; i++) { + session =__ceph_lookup_mds_session (mdsc, i); +if (!session) +continue ; +mutex_unlock (&mdsc->mutex); +mutex_lock (&session->s_mutex); +if (__close_session (mdsc, session) <=0 ) + skipped++; +mutex_unlock (&session->s_mutex); +ceph_put_mds_session (session); +mutex_lock (&mdsc->mutex); + } +mutex_unlock (&mdsc->mutex); -dout ("waiting for sessions to close\n" ); -wait_event_timeout (mdsc->session_close_wq, -done_closing_sessions (mdsc, skipped), -ceph_timeout_jiffies (opts->mount_timeout)); +dout ("waiting for sessions to close\n" ); + ret =wait_event_timeout (mdsc->session_close_wq, +done_closing_sessions (mdsc, skipped),HZ ); + }while (!ret && !umount_timed_out (timeo));/* tear down remaining sessions */ mutex_lock (&mdsc->mutex); --Quoted 2 lines
2.26.2
Hi Jeff,
Quoted 3 lines
This seems wrong to me, at least conceptually. Is the same patch getting applied to ceph-fuse?
It's a grotesque workaround, I will grant you. I'm not sure what we want to do for ceph-fuse yet but it does seem to have the same issue. Probably, we should plan to do a similar fix there once we settle on the right approach.
Quoted 3 lines
Pretending to not know anything about the client <-> MDS protocol, two questions immediately come to mind. Why is MDS allowed to drop
REQUEST_CLOSE?Quoted 8 lines
It really seems like a protocol design flaw.
IIUC, the idea overall with the low-level ceph protocol seems to be that the client should retransmit (or reevaluate, in the case of caps) calls that were in flight when the seq number changes.
The
REQUEST_CLOSEhandling seems to have followed suit on the MDS side, but it doesn't really make a lot of sense for that, IMO.(edit of my reply to https://github.com/ceph/ceph/pull/37619)
After taking a look at the MDS code, it really seemed like it had been written with the expectation that
REQUEST_CLOSEwould be resent, so I dug around. I don't fully understand these "push" sequence numbers yet, but there is probably some race that requires the client to confirm that it saw the sequence number, even if the session is about to go. Sage is probably the only one who might remember at this point.Quoted 6 lines
The kernel client already has the code to retry
REQUEST_CLOSE, only every five seconds instead every second. Seecheck_session_state()which is called fromdelayed_work()inmds_client.c. It looks like it got broken by Xiubo's commitfa9967734227("ceph: fix potential mdsc use-after-free crash") which conditioneddelayed_work()onmdsc->stopping-- hence the misbehaviour.Quoted 5 lines
Without this commit it will hit this issue too. The umount old code will try to close sessions asynchronously, and then tries to cancel the delayed work, during which the last queued
delayed_work()timer might be fired. This commit makes it easier to be reproduced.Fixing the potential races to ensure that this is retransmitted is an option, but I'm not sure it's the best one. Here's what I think we probably ought to do:
1/ fix the MDS to just ignore the sequence number on
REQUEST_CLOSE. I don't see that the sequence number has any value on that call, as it's an indicator that the client is finished with the session, and it's never going to change its mind and do something different if the sequence is wrong. I have a PR for that here:https://github.com/ceph/ceph/pull/376192/ fix the clients to not wait on the
REQUEST_CLOSEreply. As soon as the call is sent, tear down the session and proceed with unmounting. The client doesn't really care what the MDS has to say after that point, so we may as well not wait on it before proceeding.Quoted 6 lines
Quoted 1 line
Thoughts?
I am thinking possibly we can just check the session's state when the client receives a request from MDS which will increase the
s_seqnumber, if the session is in CLOSING state, the client needs to resend theREQUEST_CLOSErequest again.That could be done, but that means adding extra complexity to the session handling code, which could really stand to be simplified instead.
Quoted 6 lines
mdsc->stoppingandsession->s_stateseem to be protected by themdsc->mutex, butsession->s_seqis protected by thesession->s_mutex.There are 4 types of messages that increment the
s_seq-- caps, leases, quotas and snaps. All of those would need to be changed to check for and retransmitREQUEST_CLOSEif one is outstanding.
How about deferring resending the CLOSE request in the above case ?
Quoted 3 lines
So yeah, that could be done on the client side. If we were to do that, should we couple it with the MDS side fix to make it ignore the seq on
REQUEST_CLOSE?
Quoted 187 lines · Xiubo Li
Quoted 186 lines · Jeff Layton
Quoted 175 lines · Xiubo Li
Quoted 174 lines · Jeff Layton
Quoted 151 lines · Xiubo Li
Quoted 144 lines · Ilya Dryomov
Quoted 125 lines · Jeff Layton
Quoted 113 lines · Ilya Dryomov
Quoted 108 lines · Jeff Layton
Patrick reported a case where the MDS and client client had racing session messages to one anothe. The MDS was sending caps to the client and the client was sending a
CEPH_SESSION_REQUEST_CLOSEmessage in order to unmount.Because they were sending at the same time, the
REQUEST_CLOSEhad too old a sequence number, and the MDS dropped it on the floor. On the client, this would have probably manifested as a 60s hang during umount. The MDS ended up blocklisting the client.Once we've decided to issue a
REQUEST_CLOSE, we're finished with the session, so just keep sending them until the MDS acknowledges that.Change the code to retransmit a
REQUEST_CLOSEevery second if the session hasn't changed state yet. Give up and throw a warning aftermount_timeoutelapses if we haven't gotten a response.URL: https://tracker.ceph.com/issues/47563
Reported-by Patrick Donnelly <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/mds_client.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-)fs/ceph/mds_client.c +32
-22@@ -1878,7 +1878,7 @@ static int request_close_session(struct ceph_mds_session *session)static int __close_session (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) { -if (session->s_state >=CEPH_MDS_SESSION_CLOSING ) +if (session->s_state >CEPH_MDS_SESSION_CLOSING )return 0 ; session->s_state =CEPH_MDS_SESSION_CLOSING ;return request_close_session (session);@@ -4692,38 +4692,49 @@ static bool done_closing_sessions(struct ceph_mds_client *mdsc, int skipped)return atomic_read (&mdsc->num_sessions) <= skipped; } +static bool umount_timed_out (unsigned long timeo) +{ +if (time_before (jiffies, timeo)) +return false; +pr_warn ("ceph: unable to close all sessions\n" ); +return true; +} +/* * called after sb is ro. */ void ceph_mdsc_close_sessions (struct ceph_mds_client *mdsc) { -struct ceph_options *opts = mdsc->fsc->client->options;struct ceph_mds_session *session; -int i; -int skipped =0 ; +int i, ret; +int skipped; +unsigned long timeo = jiffies + +ceph_timeout_jiffies (mdsc->fsc->client->options->mount_timeout);dout ("close_sessions\n" );/* close sessions */ -mutex_lock (&mdsc->mutex); -for (i =0 ; i < mdsc->max_sessions; i++) { - session =__ceph_lookup_mds_session (mdsc, i); -if (!session) -continue ; -mutex_unlock (&mdsc->mutex); -mutex_lock (&session->s_mutex); -if (__close_session (mdsc, session) <=0 ) - skipped++; -mutex_unlock (&session->s_mutex); -ceph_put_mds_session (session); +do { + skipped =0 ;mutex_lock (&mdsc->mutex); - } -mutex_unlock (&mdsc->mutex); +for (i =0 ; i < mdsc->max_sessions; i++) { + session =__ceph_lookup_mds_session (mdsc, i); +if (!session) +continue ; +mutex_unlock (&mdsc->mutex); +mutex_lock (&session->s_mutex); +if (__close_session (mdsc, session) <=0 ) + skipped++; +mutex_unlock (&session->s_mutex); +ceph_put_mds_session (session); +mutex_lock (&mdsc->mutex); + } +mutex_unlock (&mdsc->mutex); -dout ("waiting for sessions to close\n" ); -wait_event_timeout (mdsc->session_close_wq, -done_closing_sessions (mdsc, skipped), -ceph_timeout_jiffies (opts->mount_timeout)); +dout ("waiting for sessions to close\n" ); + ret =wait_event_timeout (mdsc->session_close_wq, +done_closing_sessions (mdsc, skipped),HZ ); + }while (!ret && !umount_timed_out (timeo));/* tear down remaining sessions */ mutex_lock (&mdsc->mutex); --Quoted 2 lines
2.26.2
Hi Jeff,
Quoted 3 lines
This seems wrong to me, at least conceptually. Is the same patch getting applied to ceph-fuse?
It's a grotesque workaround, I will grant you. I'm not sure what we want to do for ceph-fuse yet but it does seem to have the same issue. Probably, we should plan to do a similar fix there once we settle on the right approach.
Quoted 3 lines
Pretending to not know anything about the client <-> MDS protocol, two questions immediately come to mind. Why is MDS allowed to drop
REQUEST_CLOSE?Quoted 8 lines
It really seems like a protocol design flaw.
IIUC, the idea overall with the low-level ceph protocol seems to be that the client should retransmit (or reevaluate, in the case of caps) calls that were in flight when the seq number changes.
The
REQUEST_CLOSEhandling seems to have followed suit on the MDS side, but it doesn't really make a lot of sense for that, IMO.(edit of my reply to https://github.com/ceph/ceph/pull/37619)
After taking a look at the MDS code, it really seemed like it had been written with the expectation that
REQUEST_CLOSEwould be resent, so I dug around. I don't fully understand these "push" sequence numbers yet, but there is probably some race that requires the client to confirm that it saw the sequence number, even if the session is about to go. Sage is probably the only one who might remember at this point.Quoted 6 lines
The kernel client already has the code to retry
REQUEST_CLOSE, only every five seconds instead every second. Seecheck_session_state()which is called fromdelayed_work()inmds_client.c. It looks like it got broken by Xiubo's commitfa9967734227("ceph: fix potential mdsc use-after-free crash") which conditioneddelayed_work()onmdsc->stopping-- hence the misbehaviour.Quoted 5 lines
Without this commit it will hit this issue too. The umount old code will try to close sessions asynchronously, and then tries to cancel the delayed work, during which the last queued
delayed_work()timer might be fired. This commit makes it easier to be reproduced.Fixing the potential races to ensure that this is retransmitted is an option, but I'm not sure it's the best one. Here's what I think we probably ought to do:
1/ fix the MDS to just ignore the sequence number on
REQUEST_CLOSE. I don't see that the sequence number has any value on that call, as it's an indicator that the client is finished with the session, and it's never going to change its mind and do something different if the sequence is wrong. I have a PR for that here:https://github.com/ceph/ceph/pull/376192/ fix the clients to not wait on the
REQUEST_CLOSEreply. As soon as the call is sent, tear down the session and proceed with unmounting. The client doesn't really care what the MDS has to say after that point, so we may as well not wait on it before proceeding.Quoted 6 lines
Quoted 1 line
Thoughts?
I am thinking possibly we can just check the session's state when the client receives a request from MDS which will increase the
s_seqnumber, if the session is in CLOSING state, the client needs to resend theREQUEST_CLOSErequest again.That could be done, but that means adding extra complexity to the session handling code, which could really stand to be simplified instead.
Quoted 9 lines
Quoted 6 lines
mdsc->stoppingandsession->s_stateseem to be protected by themdsc->mutex, butsession->s_seqis protected by thesession->s_mutex.There are 4 types of messages that increment the
s_seq-- caps, leases, quotas and snaps. All of those would need to be changed to check for and retransmitREQUEST_CLOSEif one is outstanding.How about deferring resending the CLOSE request in the above case ?
I'm not sure I follow you here. What would deferring the resend help with here? Bear in mind that the client is unmounting at this point so we really do want to get on with the business of tearing things down and not wait around any longer than we need.
Quoted 6 lines
Quoted 4 lines
So yeah, that could be done on the client side. If we were to do that, should we couple it with the MDS side fix to make it ignore the seq on
REQUEST_CLOSE?
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 194 lines · Jeff Layton
Quoted 193 lines · Xiubo Li
Quoted 192 lines · Jeff Layton
Quoted 175 lines · Xiubo Li
Quoted 174 lines · Jeff Layton
Quoted 151 lines · Xiubo Li
Quoted 144 lines · Ilya Dryomov
Quoted 125 lines · Jeff Layton
Quoted 113 lines · Ilya Dryomov
Quoted 108 lines · Jeff Layton
Patrick reported a case where the MDS and client client had racing session messages to one anothe. The MDS was sending caps to the client and the client was sending a
CEPH_SESSION_REQUEST_CLOSEmessage in order to unmount.Because they were sending at the same time, the
REQUEST_CLOSEhad too old a sequence number, and the MDS dropped it on the floor. On the client, this would have probably manifested as a 60s hang during umount. The MDS ended up blocklisting the client.Once we've decided to issue a
REQUEST_CLOSE, we're finished with the session, so just keep sending them until the MDS acknowledges that.Change the code to retransmit a
REQUEST_CLOSEevery second if the session hasn't changed state yet. Give up and throw a warning aftermount_timeoutelapses if we haven't gotten a response.URL: https://tracker.ceph.com/issues/47563
Reported-by Patrick Donnelly <[email protected]>Signed-off-by Jeff Layton <[email protected]>--- fs/ceph/mds_client.c | 53 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 21 deletions(-)fs/ceph/mds_client.c +32
-22@@ -1878,7 +1878,7 @@ static int request_close_session(struct ceph_mds_session *session)static int __close_session (struct ceph_mds_client *mdsc,struct ceph_mds_session *session) { -if (session->s_state >=CEPH_MDS_SESSION_CLOSING ) +if (session->s_state >CEPH_MDS_SESSION_CLOSING )return 0 ; session->s_state =CEPH_MDS_SESSION_CLOSING ;return request_close_session (session);@@ -4692,38 +4692,49 @@ static bool done_closing_sessions(struct ceph_mds_client *mdsc, int skipped)return atomic_read (&mdsc->num_sessions) <= skipped; } +static bool umount_timed_out (unsigned long timeo) +{ +if (time_before (jiffies, timeo)) +return false; +pr_warn ("ceph: unable to close all sessions\n" ); +return true; +} +/* * called after sb is ro. */ void ceph_mdsc_close_sessions (struct ceph_mds_client *mdsc) { -struct ceph_options *opts = mdsc->fsc->client->options;struct ceph_mds_session *session; -int i; -int skipped =0 ; +int i, ret; +int skipped; +unsigned long timeo = jiffies + +ceph_timeout_jiffies (mdsc->fsc->client->options->mount_timeout);dout ("close_sessions\n" );/* close sessions */ -mutex_lock (&mdsc->mutex); -for (i =0 ; i < mdsc->max_sessions; i++) { - session =__ceph_lookup_mds_session (mdsc, i); -if (!session) -continue ; -mutex_unlock (&mdsc->mutex); -mutex_lock (&session->s_mutex); -if (__close_session (mdsc, session) <=0 ) - skipped++; -mutex_unlock (&session->s_mutex); -ceph_put_mds_session (session); +do { + skipped =0 ;mutex_lock (&mdsc->mutex); - } -mutex_unlock (&mdsc->mutex); +for (i =0 ; i < mdsc->max_sessions; i++) { + session =__ceph_lookup_mds_session (mdsc, i); +if (!session) +continue ; +mutex_unlock (&mdsc->mutex); +mutex_lock (&session->s_mutex); +if (__close_session (mdsc, session) <=0 ) + skipped++; +mutex_unlock (&session->s_mutex); +ceph_put_mds_session (session); +mutex_lock (&mdsc->mutex); + } +mutex_unlock (&mdsc->mutex); -dout ("waiting for sessions to close\n" ); -wait_event_timeout (mdsc->session_close_wq, -done_closing_sessions (mdsc, skipped), -ceph_timeout_jiffies (opts->mount_timeout)); +dout ("waiting for sessions to close\n" ); + ret =wait_event_timeout (mdsc->session_close_wq, +done_closing_sessions (mdsc, skipped),HZ ); + }while (!ret && !umount_timed_out (timeo));/* tear down remaining sessions */ mutex_lock (&mdsc->mutex); --Quoted 2 lines
2.26.2
Hi Jeff,
Quoted 3 lines
This seems wrong to me, at least conceptually. Is the same patch getting applied to ceph-fuse?
It's a grotesque workaround, I will grant you. I'm not sure what we want to do for ceph-fuse yet but it does seem to have the same issue. Probably, we should plan to do a similar fix there once we settle on the right approach.
Quoted 3 lines
Pretending to not know anything about the client <-> MDS protocol, two questions immediately come to mind. Why is MDS allowed to drop
REQUEST_CLOSE?Quoted 8 lines
It really seems like a protocol design flaw.
IIUC, the idea overall with the low-level ceph protocol seems to be that the client should retransmit (or reevaluate, in the case of caps) calls that were in flight when the seq number changes.
The
REQUEST_CLOSEhandling seems to have followed suit on the MDS side, but it doesn't really make a lot of sense for that, IMO.(edit of my reply to https://github.com/ceph/ceph/pull/37619)
After taking a look at the MDS code, it really seemed like it had been written with the expectation that
REQUEST_CLOSEwould be resent, so I dug around. I don't fully understand these "push" sequence numbers yet, but there is probably some race that requires the client to confirm that it saw the sequence number, even if the session is about to go. Sage is probably the only one who might remember at this point.Quoted 6 lines
The kernel client already has the code to retry
REQUEST_CLOSE, only every five seconds instead every second. Seecheck_session_state()which is called fromdelayed_work()inmds_client.c. It looks like it got broken by Xiubo's commitfa9967734227("ceph: fix potential mdsc use-after-free crash") which conditioneddelayed_work()onmdsc->stopping-- hence the misbehaviour.Quoted 5 lines
Without this commit it will hit this issue too. The umount old code will try to close sessions asynchronously, and then tries to cancel the delayed work, during which the last queued
delayed_work()timer might be fired. This commit makes it easier to be reproduced.Fixing the potential races to ensure that this is retransmitted is an option, but I'm not sure it's the best one. Here's what I think we probably ought to do:
1/ fix the MDS to just ignore the sequence number on
REQUEST_CLOSE. I don't see that the sequence number has any value on that call, as it's an indicator that the client is finished with the session, and it's never going to change its mind and do something different if the sequence is wrong. I have a PR for that here:https://github.com/ceph/ceph/pull/376192/ fix the clients to not wait on the
REQUEST_CLOSEreply. As soon as the call is sent, tear down the session and proceed with unmounting. The client doesn't really care what the MDS has to say after that point, so we may as well not wait on it before proceeding.Quoted 6 lines
Quoted 1 line
Thoughts?
I am thinking possibly we can just check the session's state when the client receives a request from MDS which will increase the
s_seqnumber, if the session is in CLOSING state, the client needs to resend theREQUEST_CLOSErequest again.That could be done, but that means adding extra complexity to the session handling code, which could really stand to be simplified instead.
mdsc->stoppingandsession->s_stateseem to be protected by themdsc->mutex, butsession->s_seqis protected by thesession->s_mutex.There are 4 types of messages that increment the
s_seq-- caps, leases, quotas and snaps. All of those would need to be changed to check for and retransmitREQUEST_CLOSEif one is outstanding.
Quoted 6 lines
Quoted 2 lines
How about deferring resending the CLOSE request in the above case ?
I'm not sure I follow you here. What would deferring the resend help with here? Bear in mind that the client is unmounting at this point so we really do want to get on with the business of tearing things down and not wait around any longer than we need.
Okay, please just ignore it.
BRs
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
So yeah, that could be done on the client side. If we were to do that, should we couple it with the MDS side fix to make it ignore the seq on
REQUEST_CLOSE?