Skip to content

Commit fb6791d

Browse files
teiglandswhiteho
authored andcommitted
GFS2: skip dlm_unlock calls in unmount
When unmounting, gfs2 does a full dlm_unlock operation on every cached lock. This can create a very large amount of work and can take a long time to complete. However, the vast majority of these dlm unlock operations are unnecessary because after all the unlocks are done, gfs2 leaves the dlm lockspace, which automatically clears the locks of the leaving node, without unlocking each one individually. So, gfs2 can skip explicit dlm unlocks, and use dlm_release_lockspace to remove the locks implicitly. The one exception is when the lock's lvb is being used. In this case, dlm_unlock is called because it may update the lvb of the resource. Signed-off-by: David Teigland <teigland@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent aa8920c commit fb6791d

3 files changed

Lines changed: 10 additions & 0 deletions

File tree

‎fs/gfs2/glock.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,7 @@ static void dump_glock_func(struct gfs2_glock *gl)
15261526

15271527
void gfs2_gl_hash_clear(struct gfs2_sbd *sdp)
15281528
{
1529+
set_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags);
15291530
glock_hash_walk(clear_glock, sdp);
15301531
flush_workqueue(glock_workqueue);
15311532
wait_event(sdp->sd_glock_wait, atomic_read(&sdp->sd_glock_disposal) == 0);

‎fs/gfs2/incore.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ enum {
539539
SDF_DEMOTE = 5,
540540
SDF_NOJOURNALID = 6,
541541
SDF_RORECOVERY = 7, /* read only recovery */
542+
SDF_SKIP_DLM_UNLOCK = 8,
542543
};
543544

544545
#define GFS2_FSNAME_LEN 256

‎fs/gfs2/lock_dlm.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,14 @@ static void gdlm_put_lock(struct gfs2_glock *gl)
289289
gfs2_glstats_inc(gl, GFS2_LKS_DCOUNT);
290290
gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT);
291291
gfs2_update_request_times(gl);
292+
293+
/* don't want to skip dlm_unlock writing the lvb when lock is ex */
294+
if (test_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags) &&
295+
gl->gl_state != LM_ST_EXCLUSIVE) {
296+
gfs2_glock_free(gl);
297+
return;
298+
}
299+
292300
error = dlm_unlock(ls->ls_dlm, gl->gl_lksb.sb_lkid, DLM_LKF_VALBLK,
293301
NULL, gl);
294302
if (error) {

0 commit comments

Comments
 (0)