Skip to content

Commit 86c30a0

Browse files
author
Andreas Gruenbacher
committed
gfs2: Add new go_held glock operation
Right now, inode_go_instantiate() contains functionality that relates to how a glock is held rather than the glock itself, like waiting for pending direct I/O to complete and completing interrupted truncates. This code is meant to be run each time a holder is acquired, but go_instantiate is actually only called once, when the glock is instantiated. To fix that, introduce a new go_held glock operation that is called each time a glock holder is acquired. Move the holder specific code in inode_go_instantiate() over to inode_go_held(). Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent de3f906 commit 86c30a0

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

fs/gfs2/glock.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@ int gfs2_instantiate(struct gfs2_holder *gh)
488488

489489
again:
490490
if (!test_bit(GLF_INSTANTIATE_NEEDED, &gl->gl_flags))
491-
return 0;
491+
goto done;
492492

493493
/*
494494
* Since we unlock the lockref lock, we set a flag to indicate
@@ -511,7 +511,13 @@ int gfs2_instantiate(struct gfs2_holder *gh)
511511
if (!ret)
512512
clear_bit(GLF_INSTANTIATE_NEEDED, &gl->gl_flags);
513513
clear_and_wake_up_bit(GLF_INSTANTIATE_IN_PROG, &gl->gl_flags);
514-
return ret;
514+
if (ret)
515+
return ret;
516+
517+
done:
518+
if (glops->go_held)
519+
return glops->go_held(gh);
520+
return 0;
515521
}
516522

517523
/**

fs/gfs2/glops.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,21 @@ static int inode_go_instantiate(struct gfs2_holder *gh)
489489
{
490490
struct gfs2_glock *gl = gh->gh_gl;
491491
struct gfs2_inode *ip = gl->gl_object;
492-
int error = 0;
493492

494493
if (!ip) /* no inode to populate - read it in later */
495-
goto out;
494+
return 0;
496495

497-
error = gfs2_inode_refresh(ip);
498-
if (error)
499-
goto out;
496+
return gfs2_inode_refresh(ip);
497+
}
498+
499+
static int inode_go_held(struct gfs2_holder *gh)
500+
{
501+
struct gfs2_glock *gl = gh->gh_gl;
502+
struct gfs2_inode *ip = gl->gl_object;
503+
int error = 0;
504+
505+
if (!ip) /* no inode to populate - read it in later */
506+
return 0;
500507

501508
if (gh->gh_state != LM_ST_DEFERRED)
502509
inode_dio_wait(&ip->i_inode);
@@ -506,7 +513,6 @@ static int inode_go_instantiate(struct gfs2_holder *gh)
506513
(gh->gh_state == LM_ST_EXCLUSIVE))
507514
error = gfs2_truncatei_resume(ip);
508515

509-
out:
510516
return error;
511517
}
512518

@@ -730,6 +736,7 @@ const struct gfs2_glock_operations gfs2_inode_glops = {
730736
.go_inval = inode_go_inval,
731737
.go_demote_ok = inode_go_demote_ok,
732738
.go_instantiate = inode_go_instantiate,
739+
.go_held = inode_go_held,
733740
.go_dump = inode_go_dump,
734741
.go_type = LM_TYPE_INODE,
735742
.go_flags = GLOF_ASPACE | GLOF_LRU | GLOF_LVB,

fs/gfs2/incore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ struct gfs2_glock_operations {
220220
void (*go_inval) (struct gfs2_glock *gl, int flags);
221221
int (*go_demote_ok) (const struct gfs2_glock *gl);
222222
int (*go_instantiate) (struct gfs2_holder *gh);
223+
int (*go_held)(struct gfs2_holder *gh);
223224
void (*go_dump)(struct seq_file *seq, struct gfs2_glock *gl,
224225
const char *fs_id_buf);
225226
void (*go_callback)(struct gfs2_glock *gl, bool remote);

0 commit comments

Comments
 (0)