]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
nfs/localio: remove unecessary ENOTBLK handling in DIO WRITE support
authorMike Snitzer <snitzer@kernel.org>
Mon, 27 Oct 2025 13:08:31 +0000 (09:08 -0400)
committerAnna Schumaker <anna.schumaker@oracle.com>
Mon, 10 Nov 2025 15:32:28 +0000 (10:32 -0500)
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: c817248fc831 ("nfs/localio: add proper O_DIRECT support for READ and WRITE")
Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
fs/nfs/localio.c

index 2c0455e91571b8c21408fe87027654a0f2621aa9..0383d6eb2f46669fe74aa643bf49eb2fcecdd014 100644 (file)
@@ -315,6 +315,7 @@ nfs_local_iocb_alloc(struct nfs_pgio_header *hdr,
 
        iocb->hdr = hdr;
        iocb->kiocb.ki_flags &= ~IOCB_APPEND;
+       iocb->kiocb.ki_complete = NULL;
        iocb->aio_complete_work = NULL;
 
        iocb->end_iter_index = -1;
@@ -484,6 +485,7 @@ nfs_local_iters_init(struct nfs_local_kiocb *iocb, int rw)
        /* Use buffered IO */
        iocb->offset[0] = hdr->args.offset;
        iov_iter_bvec(&iocb->iters[0], rw, iocb->bvec, v, len);
+       iocb->iter_is_dio_aligned[0] = false;
        iocb->n_iters = 1;
 }
 
@@ -803,7 +805,7 @@ static void nfs_local_call_write(struct work_struct *work)
                        iocb->kiocb.ki_complete = nfs_local_write_aio_complete;
                        iocb->aio_complete_work = nfs_local_write_aio_complete_work;
                }
-retry:
+
                iocb->kiocb.ki_pos = iocb->offset[i];
                status = filp->f_op->write_iter(&iocb->kiocb, &iocb->iters[i]);
                if (status != -EIOCBQUEUED) {
@@ -823,15 +825,6 @@ retry:
                                        nfs_local_pgio_done(iocb->hdr, status);
                                        break;
                                }
-                       } else if (unlikely(status == -ENOTBLK &&
-                                           (iocb->kiocb.ki_flags & IOCB_DIRECT))) {
-                               /* VFS will return -ENOTBLK if DIO WRITE fails to
-                                * invalidate the page cache. Retry using buffered IO.
-                                */
-                               iocb->kiocb.ki_flags &= ~IOCB_DIRECT;
-                               iocb->kiocb.ki_complete = NULL;
-                               iocb->aio_complete_work = NULL;
-                               goto retry;
                        }
                        nfs_local_pgio_done(iocb->hdr, status);
                        if (iocb->hdr->task.tk_status)