Skip to content

Commit 7d50152

Browse files
committed
gfs2: Faster gfs2_upgrade_iopen_glock wakeups
jira LE-3201 Rebuild_History Non-Buildable kernel-rt-4.18.0-553.27.1.rt7.368.el8_10 commit-author Andreas Gruenbacher <agruenba@redhat.com> commit ee51baa Move function needs_demote() to glock.h and rename it to glock_needs_demote(). In handle_callback(), wake up the glock when setting the GLF_PENDING_DEMOTE flag as well. (Setting the GLF_DEMOTE flag already triggered a wake-up.) With that, check for glock_needs_demote() in gfs2_upgrade_iopen_glock() to wake up when either of those flags is set for the inode glock: the faster we can react to contention, the better. The GLF_PENDING_DEMOTE flag is only used for inode glocks (see gfs2_glock_cb()) so it's okay to only check for the GLF_DEMOTE flag in gfs2_drop_inode(). Still, using glock_needs_demote() there as well makes the code a little easier to read. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> (cherry picked from commit ee51baa) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 77a2dc8 commit 7d50152

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

fs/gfs2/glock.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,11 @@ static void state_change(struct gfs2_glock *gl, unsigned int new_state)
568568
gl->gl_tchange = jiffies;
569569
}
570570

571-
static void gfs2_set_demote(struct gfs2_glock *gl)
571+
static void gfs2_set_demote(int nr, struct gfs2_glock *gl)
572572
{
573573
struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
574574

575-
set_bit(GLF_DEMOTE, &gl->gl_flags);
575+
set_bit(nr, &gl->gl_flags);
576576
smp_mb();
577577
wake_up(&sdp->sd_async_glock_wait);
578578
}
@@ -1062,7 +1062,7 @@ static void glock_work_func(struct work_struct *work)
10621062

10631063
if (!delay) {
10641064
clear_bit(GLF_PENDING_DEMOTE, &gl->gl_flags);
1065-
gfs2_set_demote(gl);
1065+
gfs2_set_demote(GLF_DEMOTE, gl);
10661066
}
10671067
}
10681068
run_queue(gl, 0);
@@ -1408,10 +1408,7 @@ int gfs2_glock_async_wait(unsigned int num_gh, struct gfs2_holder *ghs)
14081408
static void handle_callback(struct gfs2_glock *gl, unsigned int state,
14091409
unsigned long delay, bool remote)
14101410
{
1411-
if (delay)
1412-
set_bit(GLF_PENDING_DEMOTE, &gl->gl_flags);
1413-
else
1414-
gfs2_set_demote(gl);
1411+
gfs2_set_demote(delay ? GLF_PENDING_DEMOTE : GLF_DEMOTE, gl);
14151412
if (gl->gl_demote_state == LM_ST_EXCLUSIVE) {
14161413
gl->gl_demote_state = state;
14171414
gl->gl_demote_time = jiffies;
@@ -1592,12 +1589,6 @@ int gfs2_glock_poll(struct gfs2_holder *gh)
15921589
return test_bit(HIF_WAIT, &gh->gh_iflags) ? 0 : 1;
15931590
}
15941591

1595-
static inline bool needs_demote(struct gfs2_glock *gl)
1596-
{
1597-
return (test_bit(GLF_DEMOTE, &gl->gl_flags) ||
1598-
test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags));
1599-
}
1600-
16011592
static void __gfs2_glock_dq(struct gfs2_holder *gh)
16021593
{
16031594
struct gfs2_glock *gl = gh->gh_gl;
@@ -1606,8 +1597,8 @@ static void __gfs2_glock_dq(struct gfs2_holder *gh)
16061597

16071598
/*
16081599
* This holder should not be cached, so mark it for demote.
1609-
* Note: this should be done before the check for needs_demote
1610-
* below.
1600+
* Note: this should be done before the glock_needs_demote
1601+
* check below.
16111602
*/
16121603
if (gh->gh_flags & GL_NOCACHE)
16131604
handle_callback(gl, LM_ST_UNLOCKED, 0, false);
@@ -1620,7 +1611,7 @@ static void __gfs2_glock_dq(struct gfs2_holder *gh)
16201611
* If there hasn't been a demote request we are done.
16211612
* (Let the remaining holders, if any, keep holding it.)
16221613
*/
1623-
if (!needs_demote(gl)) {
1614+
if (!glock_needs_demote(gl)) {
16241615
if (list_empty(&gl->gl_holders))
16251616
fast_path = 1;
16261617
}

fs/gfs2/glock.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,10 @@ static inline bool gfs2_holder_queued(struct gfs2_holder *gh)
295295
extern void gfs2_inode_remember_delete(struct gfs2_glock *gl, u64 generation);
296296
extern bool gfs2_inode_already_deleted(struct gfs2_glock *gl, u64 generation);
297297

298+
static inline bool glock_needs_demote(struct gfs2_glock *gl)
299+
{
300+
return (test_bit(GLF_DEMOTE, &gl->gl_flags) ||
301+
test_bit(GLF_PENDING_DEMOTE, &gl->gl_flags));
302+
}
303+
298304
#endif /* __GLOCK_DOT_H__ */

fs/gfs2/super.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ static int gfs2_drop_inode(struct inode *inode)
10511051
if (inode->i_nlink &&
10521052
gfs2_holder_initialized(&ip->i_iopen_gh)) {
10531053
struct gfs2_glock *gl = ip->i_iopen_gh.gh_gl;
1054-
if (test_bit(GLF_DEMOTE, &gl->gl_flags))
1054+
if (glock_needs_demote(gl))
10551055
clear_nlink(inode);
10561056
}
10571057

@@ -1323,7 +1323,7 @@ static bool gfs2_upgrade_iopen_glock(struct inode *inode)
13231323

13241324
wait_event_interruptible_timeout(sdp->sd_async_glock_wait,
13251325
!test_bit(HIF_WAIT, &gh->gh_iflags) ||
1326-
test_bit(GLF_DEMOTE, &ip->i_gl->gl_flags),
1326+
glock_needs_demote(ip->i_gl),
13271327
5 * HZ);
13281328
if (!test_bit(HIF_HOLDER, &gh->gh_iflags)) {
13291329
gfs2_glock_dq(gh);

0 commit comments

Comments
 (0)