Skip to content

Commit 51a491f

Browse files
Mike SnitzerAnna Schumaker
authored andcommitted
nfs/localio: remove unecessary ENOTBLK handling in DIO WRITE support
Each filesystem is meant to fallback to retrying DIO in terms buffered IO when it might encounter -ENOTBLK when issuing DIO (which can happen if the VFS cannot invalidate the page cache). So NFS doesn't need special handling for -ENOTBLK. Also, explicitly initialize a couple DIO related iocb members rather than simply rely on data structure zeroing. Fixes: c817248 ("nfs/localio: add proper O_DIRECT support for READ and WRITE") Reported-by: Christoph Hellwig <[email protected]> Signed-off-by: Mike Snitzer <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent fb2cba0 commit 51a491f

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

fs/nfs/localio.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ nfs_local_iocb_alloc(struct nfs_pgio_header *hdr,
315315

316316
iocb->hdr = hdr;
317317
iocb->kiocb.ki_flags &= ~IOCB_APPEND;
318+
iocb->kiocb.ki_complete = NULL;
318319
iocb->aio_complete_work = NULL;
319320

320321
iocb->end_iter_index = -1;
@@ -484,6 +485,7 @@ nfs_local_iters_init(struct nfs_local_kiocb *iocb, int rw)
484485
/* Use buffered IO */
485486
iocb->offset[0] = hdr->args.offset;
486487
iov_iter_bvec(&iocb->iters[0], rw, iocb->bvec, v, len);
488+
iocb->iter_is_dio_aligned[0] = false;
487489
iocb->n_iters = 1;
488490
}
489491

@@ -803,7 +805,7 @@ static void nfs_local_call_write(struct work_struct *work)
803805
iocb->kiocb.ki_complete = nfs_local_write_aio_complete;
804806
iocb->aio_complete_work = nfs_local_write_aio_complete_work;
805807
}
806-
retry:
808+
807809
iocb->kiocb.ki_pos = iocb->offset[i];
808810
status = filp->f_op->write_iter(&iocb->kiocb, &iocb->iters[i]);
809811
if (status != -EIOCBQUEUED) {
@@ -823,15 +825,6 @@ static void nfs_local_call_write(struct work_struct *work)
823825
nfs_local_pgio_done(iocb->hdr, status);
824826
break;
825827
}
826-
} else if (unlikely(status == -ENOTBLK &&
827-
(iocb->kiocb.ki_flags & IOCB_DIRECT))) {
828-
/* VFS will return -ENOTBLK if DIO WRITE fails to
829-
* invalidate the page cache. Retry using buffered IO.
830-
*/
831-
iocb->kiocb.ki_flags &= ~IOCB_DIRECT;
832-
iocb->kiocb.ki_complete = NULL;
833-
iocb->aio_complete_work = NULL;
834-
goto retry;
835828
}
836829
nfs_local_pgio_done(iocb->hdr, status);
837830
if (iocb->hdr->task.tk_status)

0 commit comments

Comments
 (0)