Skip to content

Commit d32ddfe

Browse files
Mike SnitzerAnna Schumaker
authored andcommitted
nfs/localio: Ensure DIO WRITE's IO on stable storage upon completion
LOCALIO's misaligned DIO WRITE support requires synchronous IO for any misaligned head and/or tail that are issued using buffered IO. In addition, it is important that the O_DIRECT middle be on stable storage upon its completion via AIO. Otherwise, a misaligned DIO WRITE could mix buffered IO for the head/tail and direct IO for the DIO-aligned middle -- which could lead to problems associated with deferred writes to stable storage (such as out of order partial completions causing incorrect advancement of the file's offset, etc). Fixes: c817248 ("nfs/localio: add proper O_DIRECT support for READ and WRITE") Signed-off-by: Mike Snitzer <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent d0497dd commit d32ddfe

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fs/nfs/localio.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,12 @@ nfs_local_iters_init(struct nfs_local_kiocb *iocb, int rw)
485485
struct nfs_local_dio local_dio;
486486

487487
if (nfs_is_local_dio_possible(iocb, rw, len, &local_dio) &&
488-
nfs_local_iters_setup_dio(iocb, rw, v, len, &local_dio) != 0)
488+
nfs_local_iters_setup_dio(iocb, rw, v, len, &local_dio) != 0) {
489+
/* Ensure DIO WRITE's IO on stable storage upon completion */
490+
if (rw == ITER_SOURCE)
491+
iocb->kiocb.ki_flags |= IOCB_DSYNC|IOCB_SYNC;
489492
return; /* is DIO-aligned */
493+
}
490494
}
491495

492496
/* Use buffered IO */

0 commit comments

Comments
 (0)