diff mbox series

[2/3] ceph: don't WARN if we're force umounting

Message ID 20210818080603.195722-3-xiubli@redhat.com
State New
Headers show
Series ceph: remove the capsnaps when removing the caps | expand

Commit Message

Xiubo Li Aug. 18, 2021, 8:06 a.m. UTC
From: Xiubo Li <xiubli@redhat.com>

Force umount will try to close the sessions by setting the session
state to _CLOSING, so in ceph_kill_sb after that it will warn on it.

URL: https://tracker.ceph.com/issues/52295
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/mds_client.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Jeff Layton Aug. 23, 2021, 1:49 p.m. UTC | #1
On Wed, 2021-08-18 at 16:06 +0800, xiubli@redhat.com wrote:
> From: Xiubo Li <xiubli@redhat.com>

> 

> Force umount will try to close the sessions by setting the session

> state to _CLOSING, so in ceph_kill_sb after that it will warn on it.

> 

> URL: https://tracker.ceph.com/issues/52295

> Signed-off-by: Xiubo Li <xiubli@redhat.com>

> ---

>  fs/ceph/mds_client.c | 9 +++++++--

>  1 file changed, 7 insertions(+), 2 deletions(-)

> 

> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c

> index a632e1c7cef2..0302af53e079 100644

> --- a/fs/ceph/mds_client.c

> +++ b/fs/ceph/mds_client.c

> @@ -4558,6 +4558,8 @@ static void maybe_recover_session(struct ceph_mds_client *mdsc)

>  

>  bool check_session_state(struct ceph_mds_session *s)

>  {

> +	struct ceph_fs_client *fsc = s->s_mdsc->fsc;

> +

>  	switch (s->s_state) {

>  	case CEPH_MDS_SESSION_OPEN:

>  		if (s->s_ttl && time_after(jiffies, s->s_ttl)) {

> @@ -4566,8 +4568,11 @@ bool check_session_state(struct ceph_mds_session *s)

>  		}

>  		break;

>  	case CEPH_MDS_SESSION_CLOSING:

> -		/* Should never reach this when we're unmounting */

> -		WARN_ON_ONCE(s->s_ttl);

> +		/*

> +		 * Should never reach this when none force unmounting

> +		 */

> +		if (READ_ONCE(fsc->mount_state) != CEPH_MOUNT_SHUTDOWN)

> +			WARN_ON_ONCE(s->s_ttl);


How about something like this instead?

    WARN_ON_ONCE(s->s_ttl && READ_ONCE(fsc->mount_state) != CEPH_MOUNT_SHUTDOWN);


>  		fallthrough;

>  	case CEPH_MDS_SESSION_NEW:

>  	case CEPH_MDS_SESSION_RESTARTING:


-- 
Jeff Layton <jlayton@kernel.org>
Xiubo Li Aug. 24, 2021, 1:07 a.m. UTC | #2
On 8/23/21 9:49 PM, Jeff Layton wrote:
> On Wed, 2021-08-18 at 16:06 +0800, xiubli@redhat.com wrote:

>> From: Xiubo Li <xiubli@redhat.com>

>>

>> Force umount will try to close the sessions by setting the session

>> state to _CLOSING, so in ceph_kill_sb after that it will warn on it.

>>

>> URL: https://tracker.ceph.com/issues/52295

>> Signed-off-by: Xiubo Li <xiubli@redhat.com>

>> ---

>>   fs/ceph/mds_client.c | 9 +++++++--

>>   1 file changed, 7 insertions(+), 2 deletions(-)

>>

>> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c

>> index a632e1c7cef2..0302af53e079 100644

>> --- a/fs/ceph/mds_client.c

>> +++ b/fs/ceph/mds_client.c

>> @@ -4558,6 +4558,8 @@ static void maybe_recover_session(struct ceph_mds_client *mdsc)

>>   

>>   bool check_session_state(struct ceph_mds_session *s)

>>   {

>> +	struct ceph_fs_client *fsc = s->s_mdsc->fsc;

>> +

>>   	switch (s->s_state) {

>>   	case CEPH_MDS_SESSION_OPEN:

>>   		if (s->s_ttl && time_after(jiffies, s->s_ttl)) {

>> @@ -4566,8 +4568,11 @@ bool check_session_state(struct ceph_mds_session *s)

>>   		}

>>   		break;

>>   	case CEPH_MDS_SESSION_CLOSING:

>> -		/* Should never reach this when we're unmounting */

>> -		WARN_ON_ONCE(s->s_ttl);

>> +		/*

>> +		 * Should never reach this when none force unmounting

>> +		 */

>> +		if (READ_ONCE(fsc->mount_state) != CEPH_MOUNT_SHUTDOWN)

>> +			WARN_ON_ONCE(s->s_ttl);

> How about something like this instead?

>

>      WARN_ON_ONCE(s->s_ttl && READ_ONCE(fsc->mount_state) != CEPH_MOUNT_SHUTDOWN);



This looks good to me too. Will fix it.

Thanks


>

>>   		fallthrough;

>>   	case CEPH_MDS_SESSION_NEW:

>>   	case CEPH_MDS_SESSION_RESTARTING:
diff mbox series

Patch

diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index a632e1c7cef2..0302af53e079 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -4558,6 +4558,8 @@  static void maybe_recover_session(struct ceph_mds_client *mdsc)
 
 bool check_session_state(struct ceph_mds_session *s)
 {
+	struct ceph_fs_client *fsc = s->s_mdsc->fsc;
+
 	switch (s->s_state) {
 	case CEPH_MDS_SESSION_OPEN:
 		if (s->s_ttl && time_after(jiffies, s->s_ttl)) {
@@ -4566,8 +4568,11 @@  bool check_session_state(struct ceph_mds_session *s)
 		}
 		break;
 	case CEPH_MDS_SESSION_CLOSING:
-		/* Should never reach this when we're unmounting */
-		WARN_ON_ONCE(s->s_ttl);
+		/*
+		 * Should never reach this when none force unmounting
+		 */
+		if (READ_ONCE(fsc->mount_state) != CEPH_MOUNT_SHUTDOWN)
+			WARN_ON_ONCE(s->s_ttl);
 		fallthrough;
 	case CEPH_MDS_SESSION_NEW:
 	case CEPH_MDS_SESSION_RESTARTING: