Skip to content

Commit 582d2f7

Browse files
committed
GFS2: Wait for async DIO in glock state changes
We need to wait for any outstanding DIO to complete in a couple of situations. Firstly, in case we are changing out of deferred mode (in inode_go_sync) where GLF_DIRTY will not be set. That call could be prefixed with a test for gl_state == LM_ST_DEFERRED but it doesn't seem worth it bearing in mind that the test for outstanding DIO is very quick anyway, in the usual case that there is none. The second case is in inode_go_lock which will catch the cases where we have a cached EX lock, but where we grant deferred locks against it so that there is no glock state transistion. We only need to wait if the state is not deferred, since DIO is valid anyway in that state. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
1 parent dfd1118 commit 582d2f7

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎fs/gfs2/glops.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,11 @@ static void inode_go_sync(struct gfs2_glock *gl)
192192

193193
if (ip && !S_ISREG(ip->i_inode.i_mode))
194194
ip = NULL;
195-
if (ip && test_and_clear_bit(GIF_SW_PAGED, &ip->i_flags))
196-
unmap_shared_mapping_range(ip->i_inode.i_mapping, 0, 0);
195+
if (ip) {
196+
if (test_and_clear_bit(GIF_SW_PAGED, &ip->i_flags))
197+
unmap_shared_mapping_range(ip->i_inode.i_mapping, 0, 0);
198+
inode_dio_wait(&ip->i_inode);
199+
}
197200
if (!test_and_clear_bit(GLF_DIRTY, &gl->gl_flags))
198201
return;
199202

@@ -410,6 +413,9 @@ static int inode_go_lock(struct gfs2_holder *gh)
410413
return error;
411414
}
412415

416+
if (gh->gh_state != LM_ST_DEFERRED)
417+
inode_dio_wait(&ip->i_inode);
418+
413419
if ((ip->i_diskflags & GFS2_DIF_TRUNC_IN_PROG) &&
414420
(gl->gl_state == LM_ST_EXCLUSIVE) &&
415421
(gh->gh_state == LM_ST_EXCLUSIVE)) {

0 commit comments

Comments
 (0)