Skip to contentSkip to conversation

gfs2: on withdraw, force dlm to do unclean shutdown

PATCH New Bob Peterson 2 participants 2 messages Sep 13, 2018 – Sep 19, 2018 1 message not in the archive GFS2 file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 gfs2: on withdraw, force dlm to do unclean shutdown

Hi,

Before this patch, any gfs2 withdraw caused the dlm lockspace to be unmounted with option 2, which tells dlm to do a clean unmount. However, if gfs2 does a withdraw we don't want dlm to think the file system is cleanly unmounted and thus fail to set the proper sequence number to get the journal replayed. This patch causes the dlm to go through a forced shutdown, which ought to force a journal replay in withdraw situations.

---
 fs/gfs2/glock.h      | 2 +-
 fs/gfs2/lock_dlm.c   | 4 ++--
 fs/gfs2/ops_fstype.c | 2 +-
 fs/gfs2/util.c       | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
fs/gfs2/glock.h +1 -1
index 5e12220cc0c2..b46b34a4fef0 100644
@@ -126,7 +126,7 @@ struct lm_lockops {
 	void (*lm_first_done) (struct gfs2_sbd *sdp);
 	void (*lm_recovery_result) (struct gfs2_sbd *sdp, unsigned int jid,
 				    unsigned int result);
-	void (*lm_unmount) (struct gfs2_sbd *sdp);
+	void (*lm_unmount) (struct gfs2_sbd *sdp, int force_replay);
 	void (*lm_withdraw) (struct gfs2_sbd *sdp);
 	void (*lm_put_lock) (struct gfs2_glock *gl);
 	int (*lm_lock) (struct gfs2_glock *gl, unsigned int req_state,
fs/gfs2/lock_dlm.c +2 -2
index ac7caa267ed6..dd31b37d7814 100644
@@ -1304,7 +1304,7 @@ static void gdlm_first_done(struct gfs2_sbd *sdp)
 		fs_err(sdp, "mount first_done error %d\n", error);
 }
 
-static void gdlm_unmount(struct gfs2_sbd *sdp)
+static void gdlm_unmount(struct gfs2_sbd *sdp, int force_replay)
 {
 	struct lm_lockstruct *ls = &sdp->sd_lockstruct;
 
@@ -1321,7 +1321,7 @@ static void gdlm_unmount(struct gfs2_sbd *sdp)
 	/* mounted_lock and control_lock will be purged in dlm recovery */
 release:
 	if (ls->ls_dlm) {
-		dlm_release_lockspace(ls->ls_dlm, 2);
+		dlm_release_lockspace(ls->ls_dlm, force_replay ? 3 : 2);
 		ls->ls_dlm = NULL;
 	}
 
fs/gfs2/ops_fstype.c +1 -1
index c2469833b4fb..cdb0e4a71dbf 100644
@@ -1000,7 +1000,7 @@ void gfs2_lm_unmount(struct gfs2_sbd *sdp)
 	const struct lm_lockops *lm = sdp->sd_lockstruct.ls_ops;
 	if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) &&
 	    lm->lm_unmount)
-		lm->lm_unmount(sdp);
+		lm->lm_unmount(sdp, 0);
 }
 
 static int wait_on_journal(struct gfs2_sbd *sdp)
fs/gfs2/util.c +1 -1
index b072b10fb635..b5a6e958432d 100644
@@ -69,7 +69,7 @@ int gfs2_lm_withdraw(struct gfs2_sbd *sdp, const char *fmt, ...)
 
 		if (lm->lm_unmount) {
 			fs_err(sdp, "telling LM to unmount\n");
-			lm->lm_unmount(sdp);
+			lm->lm_unmount(sdp, 1);
 		}
 		set_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags);
 		fs_err(sdp, "withdrawn\n");
#2 lore raw

PATCH 1/1 gfs2: on withdraw, force dlm to do unclean shutdown

Bob,

Quoted 7 lines · Bob Peterson

Before this patch, any gfs2 withdraw caused the dlm lockspace to be unmounted with option 2, which tells dlm to do a clean unmount. However, if gfs2 does a withdraw we don't want dlm to think the file system is cleanly unmounted and thus fail to set the proper sequence number to get the journal replayed. This patch causes the dlm to go through a forced shutdown, which ought to force a journal replay in withdraw situations.

I see that this change will cause release_lockspace() to skip calling do_uevent() in the force_replay case. Could you please explain how this fixes the error scenario?

Quoted 13 lines
---
 fs/gfs2/glock.h      | 2 +-
 fs/gfs2/lock_dlm.c   | 4 ++--
 fs/gfs2/ops_fstype.c | 2 +-
 fs/gfs2/util.c       | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
fs/gfs2/glock.h +0 -0
index 5e12220cc0c2..b46b34a4fef0 100644

fs/gfs2/glock.h struct lm_lockops { · line 129

Quoted 5 lines
fs/gfs2/glock.h +1 -1
@@ -126,7 +126,7 @@ struct lm_lockops {
        void (*lm_first_done) (struct gfs2_sbd *sdp);
        void (*lm_recovery_result) (struct gfs2_sbd *sdp, unsigned int jid,
                                    unsigned int result);
-       void (*lm_unmount) (struct gfs2_sbd *sdp);
+       void (*lm_unmount) (struct gfs2_sbd *sdp, int force_replay);

Can you make this a bool and use true / false instead?

Quoted 44 lines
fs/gfs2/glock.h +0 -0
        void (*lm_withdraw) (struct gfs2_sbd *sdp);
        void (*lm_put_lock) (struct gfs2_glock *gl);
        int (*lm_lock) (struct gfs2_glock *gl, unsigned int req_state,
fs/gfs2/lock_dlm.c +2 -2
index ac7caa267ed6..dd31b37d7814 100644
@@ -1304,7 +1304,7 @@ static void gdlm_first_done(struct gfs2_sbd *sdp)
                fs_err(sdp, "mount first_done error %d\n", error);
 }
 
-static void gdlm_unmount(struct gfs2_sbd *sdp)
+static void gdlm_unmount(struct gfs2_sbd *sdp, int force_replay)
 {
        struct lm_lockstruct *ls = &sdp->sd_lockstruct;
 
@@ -1321,7 +1321,7 @@ static void gdlm_unmount(struct gfs2_sbd *sdp)
        /* mounted_lock and control_lock will be purged in dlm recovery */
 release:
        if (ls->ls_dlm) {
-               dlm_release_lockspace(ls->ls_dlm, 2);
+               dlm_release_lockspace(ls->ls_dlm, force_replay ? 3 : 2);
                ls->ls_dlm = NULL;
        }
 
fs/gfs2/ops_fstype.c +1 -1
index c2469833b4fb..cdb0e4a71dbf 100644
@@ -1000,7 +1000,7 @@ void gfs2_lm_unmount(struct gfs2_sbd *sdp)
        const struct lm_lockops *lm = sdp->sd_lockstruct.ls_ops;
        if (likely(!test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) &&
            lm->lm_unmount)
-               lm->lm_unmount(sdp);
+               lm->lm_unmount(sdp, 0);
 }
 
 static int wait_on_journal(struct gfs2_sbd *sdp)
fs/gfs2/util.c +0 -0
index b072b10fb635..b5a6e958432d 100644

fs/gfs2/util.c int gfs2_lm_withdraw(struct gfs2_sbd *sdp, const char *fmt, ...) · line 75

Quoted 8 lines
fs/gfs2/util.c +1 -1
@@ -69,7 +69,7 @@ int gfs2_lm_withdraw(struct gfs2_sbd *sdp, const char *fmt, ...)
 
                if (lm->lm_unmount) {
                        fs_err(sdp, "telling LM to unmount\n");
-                       lm->lm_unmount(sdp);
+                       lm->lm_unmount(sdp, 1);
                }
                set_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags);
                fs_err(sdp, "withdrawn\n");

Thanks,
Andreas