Skip to content

Commit 06e908c

Browse files
AstralBobAndreas Gruenbacher
authored andcommitted
gfs2: Allow node-wide exclusive glock sharing
Introduce a new LM_FLAG_NODE_SCOPE glock holder flag: when taking a glock in LM_ST_EXCLUSIVE (EX) mode and with the LM_FLAG_NODE_SCOPE flag set, the exclusive lock is shared among all local processes who are holding the glock in EX mode and have the LM_FLAG_NODE_SCOPE flag set. From the point of view of other nodes, the lock is still held exclusively. A future patch will start using this flag to improve performance with rgrp sharing. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 9e51460 commit 06e908c

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

fs/gfs2/glock.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,23 @@ void gfs2_glock_put(struct gfs2_glock *gl)
313313
static inline int may_grant(const struct gfs2_glock *gl, const struct gfs2_holder *gh)
314314
{
315315
const struct gfs2_holder *gh_head = list_first_entry(&gl->gl_holders, const struct gfs2_holder, gh_list);
316-
if ((gh->gh_state == LM_ST_EXCLUSIVE ||
317-
gh_head->gh_state == LM_ST_EXCLUSIVE) && gh != gh_head)
318-
return 0;
316+
317+
if (gh != gh_head) {
318+
/**
319+
* Here we make a special exception to grant holders who agree
320+
* to share the EX lock with other holders who also have the
321+
* bit set. If the original holder has the LM_FLAG_NODE_SCOPE bit
322+
* is set, we grant more holders with the bit set.
323+
*/
324+
if (gh_head->gh_state == LM_ST_EXCLUSIVE &&
325+
(gh_head->gh_flags & LM_FLAG_NODE_SCOPE) &&
326+
gh->gh_state == LM_ST_EXCLUSIVE &&
327+
(gh->gh_flags & LM_FLAG_NODE_SCOPE))
328+
return 1;
329+
if ((gh->gh_state == LM_ST_EXCLUSIVE ||
330+
gh_head->gh_state == LM_ST_EXCLUSIVE))
331+
return 0;
332+
}
319333
if (gl->gl_state == gh->gh_state)
320334
return 1;
321335
if (gh->gh_flags & GL_EXACT)
@@ -2030,6 +2044,8 @@ static const char *hflags2str(char *buf, u16 flags, unsigned long iflags)
20302044
*p++ = 'A';
20312045
if (flags & LM_FLAG_PRIORITY)
20322046
*p++ = 'p';
2047+
if (flags & LM_FLAG_NODE_SCOPE)
2048+
*p++ = 'n';
20332049
if (flags & GL_ASYNC)
20342050
*p++ = 'a';
20352051
if (flags & GL_EXACT)

fs/gfs2/glock.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,19 @@ enum {
7575
* request and directly join the other shared lock. A shared lock request
7676
* without the priority flag might be forced to wait until the deferred
7777
* requested had acquired and released the lock.
78+
*
79+
* LM_FLAG_NODE_SCOPE
80+
* This holder agrees to share the lock within this node. In other words,
81+
* the glock is held in EX mode according to DLM, but local holders on the
82+
* same node can share it.
7883
*/
7984

8085
#define LM_FLAG_TRY 0x0001
8186
#define LM_FLAG_TRY_1CB 0x0002
8287
#define LM_FLAG_NOEXP 0x0004
8388
#define LM_FLAG_ANY 0x0008
8489
#define LM_FLAG_PRIORITY 0x0010
90+
#define LM_FLAG_NODE_SCOPE 0x0020
8591
#define GL_ASYNC 0x0040
8692
#define GL_EXACT 0x0080
8793
#define GL_SKIP 0x0100

0 commit comments

Comments
 (0)