Skip to content

Commit 81ffbf6

Browse files
committed
GFS2: Add origin indicator to glock callbacks
This patch adds a bool indicating whether the demote request was originated locally or remotely. This is then used by the iopen ->go_callback() to make 100% sure that it will only respond to remote callbacks. Since ->evict_inode() uses GL_NOCACHE when it attempts to get an exclusive lock on the iopen lock, this may result in extra scheduling of the workqueue in case that the exclusive promotion request failed. This patch prevents that from happening. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent 16ca941 commit 81ffbf6

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

‎fs/gfs2/glock.c‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -912,7 +912,7 @@ int gfs2_glock_wait(struct gfs2_holder *gh)
912912
*/
913913

914914
static void handle_callback(struct gfs2_glock *gl, unsigned int state,
915-
unsigned long delay)
915+
unsigned long delay, bool remote)
916916
{
917917
int bit = delay ? GLF_PENDING_DEMOTE : GLF_DEMOTE;
918918

@@ -925,7 +925,7 @@ static void handle_callback(struct gfs2_glock *gl, unsigned int state,
925925
gl->gl_demote_state = LM_ST_UNLOCKED;
926926
}
927927
if (gl->gl_ops->go_callback)
928-
gl->gl_ops->go_callback(gl);
928+
gl->gl_ops->go_callback(gl, remote);
929929
trace_gfs2_demote_rq(gl);
930930
}
931931

@@ -1091,7 +1091,7 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
10911091

10921092
spin_lock(&gl->gl_spin);
10931093
if (gh->gh_flags & GL_NOCACHE)
1094-
handle_callback(gl, LM_ST_UNLOCKED, 0);
1094+
handle_callback(gl, LM_ST_UNLOCKED, 0, false);
10951095

10961096
list_del_init(&gh->gh_list);
10971097
if (find_first_holder(gl) == NULL) {
@@ -1296,7 +1296,7 @@ void gfs2_glock_cb(struct gfs2_glock *gl, unsigned int state)
12961296
}
12971297

12981298
spin_lock(&gl->gl_spin);
1299-
handle_callback(gl, state, delay);
1299+
handle_callback(gl, state, delay, true);
13001300
spin_unlock(&gl->gl_spin);
13011301
if (queue_delayed_work(glock_workqueue, &gl->gl_work, delay) == 0)
13021302
gfs2_glock_put(gl);
@@ -1409,7 +1409,7 @@ __acquires(&lru_lock)
14091409
spin_unlock(&lru_lock);
14101410
spin_lock(&gl->gl_spin);
14111411
if (demote_ok(gl))
1412-
handle_callback(gl, LM_ST_UNLOCKED, 0);
1412+
handle_callback(gl, LM_ST_UNLOCKED, 0, false);
14131413
WARN_ON(!test_and_clear_bit(GLF_LOCK, &gl->gl_flags));
14141414
smp_mb__after_clear_bit();
14151415
if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)
@@ -1534,7 +1534,7 @@ static void clear_glock(struct gfs2_glock *gl)
15341534

15351535
spin_lock(&gl->gl_spin);
15361536
if (gl->gl_state != LM_ST_UNLOCKED)
1537-
handle_callback(gl, LM_ST_UNLOCKED, 0);
1537+
handle_callback(gl, LM_ST_UNLOCKED, 0, false);
15381538
spin_unlock(&gl->gl_spin);
15391539
gfs2_glock_hold(gl);
15401540
if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0)

‎fs/gfs2/glops.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,12 +515,12 @@ static int trans_go_demote_ok(const struct gfs2_glock *gl)
515515
*
516516
* gl_spin lock is held while calling this
517517
*/
518-
static void iopen_go_callback(struct gfs2_glock *gl)
518+
static void iopen_go_callback(struct gfs2_glock *gl, bool remote)
519519
{
520520
struct gfs2_inode *ip = (struct gfs2_inode *)gl->gl_object;
521521
struct gfs2_sbd *sdp = gl->gl_sbd;
522522

523-
if (sdp->sd_vfs->s_flags & MS_RDONLY)
523+
if (!remote || (sdp->sd_vfs->s_flags & MS_RDONLY))
524524
return;
525525

526526
if (gl->gl_demote_state == LM_ST_UNLOCKED &&

‎fs/gfs2/incore.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ struct gfs2_glock_operations {
210210
int (*go_lock) (struct gfs2_holder *gh);
211211
void (*go_unlock) (struct gfs2_holder *gh);
212212
int (*go_dump)(struct seq_file *seq, const struct gfs2_glock *gl);
213-
void (*go_callback) (struct gfs2_glock *gl);
213+
void (*go_callback)(struct gfs2_glock *gl, bool remote);
214214
const int go_type;
215215
const unsigned long go_flags;
216216
#define GLOF_ASPACE 1

0 commit comments

Comments
 (0)