Skip to content

Commit 713f883

Browse files
author
Andreas Gruenbacher
committed
gfs2: Get rid of demote_ok checks
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 <[email protected]>
1 parent 3f4475b commit 713f883

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
@@ -61,8 +61,6 @@ Field Purpose
6161
go_sync Called before remote state change (e.g. to sync dirty data)
6262
go_xmote_bh Called after remote state change (e.g. to refill cache)
6363
go_inval Called if remote state change requires invalidating the cache
64-
go_demote_ok Returns boolean value of whether its ok to demote a glock
65-
(e.g. checks timeout, and that there is no cached data)
6664
go_instantiate Called when a glock has been acquired
6765
go_held Called every time a glock holder is acquired
6866
go_dump Called to print content of object for debugfs file, or on
@@ -95,7 +93,6 @@ Operation GLF_LOCK bit lock held gl_lockref.lock spinlock held
9593
go_sync Yes No
9694
go_xmote_bh Yes No
9795
go_inval Yes No
98-
go_demote_ok Sometimes Yes
9996
go_instantiate No No
10097
go_held No No
10198
go_dump Sometimes Yes

fs/gfs2/glock.c

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

219-
/**
220-
* demote_ok - Check to see if it's ok to unlock a glock
221-
* @gl: the glock
222-
*
223-
* Returns: 1 if it's ok
224-
*/
225-
226-
static int demote_ok(const struct gfs2_glock *gl)
227-
{
228-
const struct gfs2_glock_operations *glops = gl->gl_ops;
229-
230-
if (gl->gl_state == LM_ST_UNLOCKED)
231-
return 0;
232-
if (!list_empty(&gl->gl_holders))
233-
return 0;
234-
if (glops->go_demote_ok)
235-
return glops->go_demote_ok(gl);
236-
return 1;
237-
}
238-
239-
240219
static void gfs2_glock_add_to_lru(struct gfs2_glock *gl)
241220
{
242221
spin_lock(&lru_lock);
@@ -2049,7 +2028,7 @@ __acquires(&lru_lock)
20492028
clear_bit(GLF_LRU, &gl->gl_flags);
20502029
freed++;
20512030
gl->gl_lockref.count++;
2052-
if (demote_ok(gl))
2031+
if (gl->gl_state != LM_ST_UNLOCKED)
20532032
request_demote(gl, LM_ST_UNLOCKED, 0, false);
20542033
gfs2_glock_queue_work(gl, 0);
20552034
spin_unlock(&gl->gl_lockref.lock);

fs/gfs2/glops.c

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

388-
/**
389-
* inode_go_demote_ok - Check to see if it's ok to unlock an inode glock
390-
* @gl: the glock
391-
*
392-
* Returns: 1 if it's ok
393-
*/
394-
395-
static int inode_go_demote_ok(const struct gfs2_glock *gl)
396-
{
397-
struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
398-
399-
if (sdp->sd_jindex == gl->gl_object || sdp->sd_rindex == gl->gl_object)
400-
return 0;
401-
402-
return 1;
403-
}
404-
405388
static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
406389
{
407390
struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
@@ -722,7 +705,6 @@ const struct gfs2_glock_operations gfs2_meta_glops = {
722705
const struct gfs2_glock_operations gfs2_inode_glops = {
723706
.go_sync = inode_go_sync,
724707
.go_inval = inode_go_inval,
725-
.go_demote_ok = inode_go_demote_ok,
726708
.go_instantiate = inode_go_instantiate,
727709
.go_held = inode_go_held,
728710
.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, const struct gfs2_glock *gl,

0 commit comments

Comments
 (0)