Skip to content

Commit acdf764

Browse files
author
Andreas Gruenbacher
committed
gfs2: Get rid of demote_ok checks
JIRA: https://issues.redhat.com/browse/RHEL-67675 The demote_ok glock operation is only still used to prevent the inode glocks of the "jindex" and "rindex" directories from getting recycled while they are still referenced by sdp->sd_jindex and sdp->sd_rindex. However, the LRU walking code will no longer recycle glocks which are referenced, so the demote_ok glock operation is obsolete and can be removed. Each of a glock's holders in the gl_holders list is holding a reference on the glock, so when the list of holders isn't empty in demote_ok(), the existing reference count check will already prevent the glock from getting released. This means that demote_ok() is obsolete as well. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> (cherry picked from commit 713f883)
1 parent 92ffbf9 commit acdf764

File tree

4 files changed

+1
-44
lines changed

4 files changed

+1
-44
lines changed

Documentation/filesystems/gfs2-glocks.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ Field Purpose
6262
go_sync Called before remote state change (e.g. to sync dirty data)
6363
go_xmote_bh Called after remote state change (e.g. to refill cache)
6464
go_inval Called if remote state change requires invalidating the cache
65-
go_demote_ok Returns boolean value of whether its ok to demote a glock
66-
(e.g. checks timeout, and that there is no cached data)
6765
go_instantiate Called when a glock has been acquired
6866
go_held Called every time a glock holder is acquired
6967
go_dump Called to print content of object for debugfs file, or on
@@ -96,7 +94,6 @@ Operation GLF_LOCK bit lock held gl_lockref.lock spinlock held
9694
go_sync Yes No
9795
go_xmote_bh Yes No
9896
go_inval Yes No
99-
go_demote_ok Sometimes Yes
10097
go_instantiate No No
10198
go_held No No
10299
go_dump Sometimes Yes

fs/gfs2/glock.c

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -217,27 +217,6 @@ struct gfs2_glock *gfs2_glock_hold(struct gfs2_glock *gl)
217217
return gl;
218218
}
219219

220-
/**
221-
* demote_ok - Check to see if it's ok to unlock a glock
222-
* @gl: the glock
223-
*
224-
* Returns: 1 if it's ok
225-
*/
226-
227-
static int demote_ok(const struct gfs2_glock *gl)
228-
{
229-
const struct gfs2_glock_operations *glops = gl->gl_ops;
230-
231-
if (gl->gl_state == LM_ST_UNLOCKED)
232-
return 0;
233-
if (!list_empty(&gl->gl_holders))
234-
return 0;
235-
if (glops->go_demote_ok)
236-
return glops->go_demote_ok(gl);
237-
return 1;
238-
}
239-
240-
241220
static void gfs2_glock_add_to_lru(struct gfs2_glock *gl)
242221
{
243222
spin_lock(&lru_lock);
@@ -2026,7 +2005,7 @@ __acquires(&lru_lock)
20262005
clear_bit(GLF_LRU, &gl->gl_flags);
20272006
freed++;
20282007
gl->gl_lockref.count++;
2029-
if (demote_ok(gl))
2008+
if (gl->gl_state != LM_ST_UNLOCKED)
20302009
request_demote(gl, LM_ST_UNLOCKED, 0, false);
20312010
gfs2_glock_queue_work(gl, 0);
20322011
spin_unlock(&gl->gl_lockref.lock);

fs/gfs2/glops.c

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -381,23 +381,6 @@ static void inode_go_inval(struct gfs2_glock *gl, int flags)
381381
gfs2_clear_glop_pending(ip);
382382
}
383383

384-
/**
385-
* inode_go_demote_ok - Check to see if it's ok to unlock an inode glock
386-
* @gl: the glock
387-
*
388-
* Returns: 1 if it's ok
389-
*/
390-
391-
static int inode_go_demote_ok(const struct gfs2_glock *gl)
392-
{
393-
struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
394-
395-
if (sdp->sd_jindex == gl->gl_object || sdp->sd_rindex == gl->gl_object)
396-
return 0;
397-
398-
return 1;
399-
}
400-
401384
static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
402385
{
403386
const struct gfs2_dinode *str = buf;
@@ -721,7 +704,6 @@ const struct gfs2_glock_operations gfs2_meta_glops = {
721704
const struct gfs2_glock_operations gfs2_inode_glops = {
722705
.go_sync = inode_go_sync,
723706
.go_inval = inode_go_inval,
724-
.go_demote_ok = inode_go_demote_ok,
725707
.go_instantiate = inode_go_instantiate,
726708
.go_held = inode_go_held,
727709
.go_dump = inode_go_dump,

fs/gfs2/incore.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,6 @@ struct gfs2_glock_operations {
218218
int (*go_sync) (struct gfs2_glock *gl);
219219
int (*go_xmote_bh)(struct gfs2_glock *gl);
220220
void (*go_inval) (struct gfs2_glock *gl, int flags);
221-
int (*go_demote_ok) (const struct gfs2_glock *gl);
222221
int (*go_instantiate) (struct gfs2_glock *gl);
223222
int (*go_held)(struct gfs2_holder *gh);
224223
void (*go_dump)(struct seq_file *seq, struct gfs2_glock *gl,

0 commit comments

Comments
 (0)