fs: gfs2: release dlm gfs2 ls on withdraw
RFC PATCH 1/1 fs: gfs2: release dlm gfs2 ls on withdraw
This patch will introduce a new gfs2 lock ops callback for release a possible lock infrastructure e.g. dlm. There is currently an issue with gfs2 and dlm by hitting ctrl-c during mount operation (sometimes it works, most times not). The issue is here that when the gfs2 filesystem is not withdrawn we don't release the dlm lockspace again and next mount dlm_new_lockspace() will return -EEXIST. This patch will ensure that we call dlm_release_lockspace() in the error path of gfs2_fill_super() even if the filesystem isn't withdrawn yet. Moreover it will do that in all cases even if the filesystem is not withdrawn yet.
---
Hi,
no idea if the gfs2_withdrawn(sdp) should be always evaluated to "false", but then there are cases when it returns "true" and the gfs2 dlm lockspace will not be released... next mount there will be a -EEXIST, as described in the commit message.
If gfs2_withdrawn(sdp) should return "false" always maybe there is some missing wait and we should printout a warning if it's returning true... in this case and an error path we have a problem which can be observed at the next mount.
- Alex
fs/gfs2/glock.h | 1 + fs/gfs2/lock_dlm.c | 24 ++++++++++++++++++------ fs/gfs2/ops_fstype.c | 6 +++++- 3 files changed, 24 insertions(+), 7 deletions(-)
fs/gfs2/glock.h +1 -0
@@ -130,6 +130,7 @@ struct lm_lockops {void (*lm_recovery_result) (struct gfs2_sbd *sdp,unsigned int jid,unsigned int result);void (*lm_unmount) (struct gfs2_sbd *sdp); +void (*lm_release) (struct gfs2_sbd *sdp);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 +18 -6
@@ -1248,6 +1248,14 @@ static const struct dlm_lockspace_ops gdlm_lockspace_ops = { .recover_done = gdlm_recover_done, }; +static void gdlm_ls_release (struct lm_lockstruct *ls) +{ +if (ls->ls_dlm) { +dlm_release_lockspace (ls->ls_dlm,2 ); + ls->ls_dlm =NULL ; + } +} +static int gdlm_mount (struct gfs2_sbd *sdp,const char *table) {struct lm_lockstruct *ls = &sdp->sd_lockstruct;
@@ -1338,7 +1346,7 @@ static int gdlm_mount(struct gfs2_sbd *sdp, const char *table)return 0 ; fail_release: -dlm_release_lockspace (ls->ls_dlm,2 ); +gdlm_ls_release (ls); fail_free:free_recover_size (ls); fail:
@@ -1374,14 +1382,17 @@ 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 ); - ls->ls_dlm =NULL ; - } - +gdlm_ls_release (ls);free_recover_size (ls); } +static void gdlm_release (struct gfs2_sbd *sdp) +{ +struct lm_lockstruct *ls = &sdp->sd_lockstruct; + +gdlm_ls_release (ls); +} +static const match_table_t dlm_tokens = { { Opt_jid,"jid=%d" }, { Opt_id,"id=%d" },
@@ -1396,6 +1407,7 @@ const struct lm_lockops gfs2_dlm_ops = { .lm_first_done = gdlm_first_done, .lm_recovery_result = gdlm_recovery_result, .lm_unmount = gdlm_unmount, + .lm_release = gdlm_release, .lm_put_lock = gdlm_put_lock, .lm_lock = gdlm_lock, .lm_cancel = gdlm_cancel,
fs/gfs2/ops_fstype.c +5 -1
@@ -1075,8 +1075,12 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent)void gfs2_lm_unmount (struct gfs2_sbd *sdp) {const struct lm_lockops *lm = sdp->sd_lockstruct.ls_ops; -if (likely (!gfs2_withdrawn (sdp)) && lm->lm_unmount) +if (likely (!gfs2_withdrawn (sdp)) && lm->lm_unmount) { lm->lm_unmount (sdp); + }else { +if (lm->lm_release) + lm->lm_release (sdp); + } }static int wait_on_journal (struct gfs2_sbd *sdp)
Signature · 1 line
2.27.0
RFC PATCH 1/1 fs: gfs2: release dlm gfs2 ls on withdraw
Hi,
Quoted 49 lines · Alexander Aring
This patch will introduce a new gfs2 lock ops callback for release a possible lock infrastructure e.g. dlm. There is currently an issue with gfs2 and dlm by hitting ctrl-c during mount operation (sometimes it works, most times not). The issue is here that when the gfs2 filesystem is not withdrawn we don't release the dlm lockspace again and next mount
dlm_new_lockspace()will return-EEXIST. This patch will ensure that we calldlm_release_lockspace()in the error path ofgfs2_fill_super()even if the filesystem isn't withdrawn yet. Moreover it will do that in all cases even if the filesystem is not withdrawn yet.Signed-off-by Alexander Aring <[email protected]>---
Hi,no idea if the
gfs2_withdrawn(sdp)should be always evaluated to "false", but then there are cases when it returns "true" and the gfs2 dlm lockspace will not be released... next mount there will be a-EEXIST, as described in the commit message.If
gfs2_withdrawn(sdp)should return "false" always maybe there is some missing wait and we should printout a warning if it's returning true... in this case and an error path we have a problem which can be observed at the next mount.- Alex
fs/gfs2/glock.h | 1 + fs/gfs2/lock_dlm.c | 24 ++++++++++++++++++------ fs/gfs2/ops_fstype.c | 6 +++++- 3 files changed, 24 insertions(+), 7 deletions(-)fs/gfs2/glock.h +1
-0@@ -130,6 +130,7 @@ struct lm_lockops {void (*lm_recovery_result) (struct gfs2_sbd *sdp,unsigned int jid,unsigned int result);void (*lm_unmount) (struct gfs2_sbd *sdp); +void (*lm_release) (struct gfs2_sbd *sdp);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 +0
-0
fs/gfs2/lock_dlm.c static const struct dlm_lockspace_ops gdlm_lockspace_ops = { · line 1256
Quoted 9 lines
fs/gfs2/lock_dlm.c +6
-0@@ -1248,6 +1248,14 @@ static const struct dlm_lockspace_ops gdlm_lockspace_ops = { .recover_done = gdlm_recover_done, }; +static void gdlm_ls_release (struct lm_lockstruct *ls) +{ +if (ls->ls_dlm) { +dlm_release_lockspace (ls->ls_dlm,2 ); + ls->ls_dlm =NULL ; + }
I believe there must also be a:free_recover_size(ls);
fs/gfs2/lock_dlm.c static int gdlm_mount(struct gfs2_sbd *sdp, const char *table) · line 1349
Quoted 11 lines
fs/gfs2/lock_dlm.c +3
-1+} +static int gdlm_mount (struct gfs2_sbd *sdp,const char *table) {struct lm_lockstruct *ls = &sdp->sd_lockstruct;@@ -1338,7 +1346,7 @@ static int gdlm_mount(struct gfs2_sbd *sdp, const char *table)return 0 ; fail_release: -dlm_release_lockspace (ls->ls_dlm,2 ); +gdlm_ls_release (ls);
then don't change this.
Quoted 4 lines
fs/gfs2/lock_dlm.c +0
-0fail_free:free_recover_size (ls); fail:
fs/gfs2/lock_dlm.c static void gdlm_unmount(struct gfs2_sbd *sdp) · line 1386
Quoted 10 lines
fs/gfs2/lock_dlm.c +1
-5@@ -1374,14 +1382,17 @@ 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 ); - ls->ls_dlm =NULL ; - } - +gdlm_ls_release (ls);free_recover_size (ls);
remove that.
Quoted 25 lines
fs/gfs2/lock_dlm.c +8
-0} +static void gdlm_release (struct gfs2_sbd *sdp) +{ +struct lm_lockstruct *ls = &sdp->sd_lockstruct; + +gdlm_ls_release (ls); +} +static const match_table_t dlm_tokens = { { Opt_jid,"jid=%d" }, { Opt_id,"id=%d" },@@ -1396,6 +1407,7 @@ const struct lm_lockops gfs2_dlm_ops = { .lm_first_done = gdlm_first_done, .lm_recovery_result = gdlm_recovery_result, .lm_unmount = gdlm_unmount, + .lm_release = gdlm_release, .lm_put_lock = gdlm_put_lock, .lm_lock = gdlm_lock, .lm_cancel = gdlm_cancel,fs/gfs2/ops_fstype.c +0
-0
fs/gfs2/ops_fstype.c static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent) · line 1083
Quoted 10 lines
fs/gfs2/ops_fstype.c +5
-1@@ -1075,8 +1075,12 @@ static int gfs2_lm_mount(struct gfs2_sbd *sdp, int silent)void gfs2_lm_unmount (struct gfs2_sbd *sdp) {const struct lm_lockops *lm = sdp->sd_lockstruct.ls_ops; -if (likely (!gfs2_withdrawn (sdp)) && lm->lm_unmount) +if (likely (!gfs2_withdrawn (sdp)) && lm->lm_unmount) { lm->lm_unmount (sdp); + }else { +if (lm->lm_release) + lm->lm_release (sdp); + }
That means we also have a memory leak for some of the fields in "free_recover_size(ls)".
If this approach is okay, I will send a v2.
- Alex