diff options
author | Trond Myklebust <trond.myklebust@hammerspace.com> | 2019-08-12 18:04:36 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-09-06 10:22:23 +0200 |
commit | 4f4be79c9ee7f36996163c6cf7056dae94e1b17e (patch) | |
tree | 14254a0d5cdff9ba1694032ea362bc736613edbb /fs | |
parent | b5891b624b9a5d3dd65b6c5a6601480bcb1a3dc3 (diff) | |
download | linux-stable-4f4be79c9ee7f36996163c6cf7056dae94e1b17e.tar.gz linux-stable-4f4be79c9ee7f36996163c6cf7056dae94e1b17e.tar.bz2 linux-stable-4f4be79c9ee7f36996163c6cf7056dae94e1b17e.zip |
NFS: Ensure O_DIRECT reports an error if the bytes read/written is 0
[ Upstream commit eb2c50da9e256dbbb3ff27694440e4c1900cfef8 ]
If the attempt to resend the I/O results in no bytes being read/written,
we must ensure that we report the error.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Fixes: 0a00b77b331a ("nfs: mirroring support for direct io")
Cc: stable@vger.kernel.org # v3.20+
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/direct.c | 27 | ||||
-rw-r--r-- | fs/nfs/pagelist.c | 1 |
2 files changed, 19 insertions, 9 deletions
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 0fd811ac08b5..f516ace8f45d 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c @@ -400,15 +400,21 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr) unsigned long bytes = 0; struct nfs_direct_req *dreq = hdr->dreq; - if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) - goto out_put; - spin_lock(&dreq->lock); - if (test_bit(NFS_IOHDR_ERROR, &hdr->flags) && (hdr->good_bytes == 0)) + if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) dreq->error = hdr->error; - else + + if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) { + spin_unlock(&dreq->lock); + goto out_put; + } + + if (hdr->good_bytes != 0) nfs_direct_good_bytes(dreq, hdr); + if (test_bit(NFS_IOHDR_EOF, &hdr->flags)) + dreq->error = 0; + spin_unlock(&dreq->lock); while (!list_empty(&hdr->pages)) { @@ -774,16 +780,19 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr) bool request_commit = false; struct nfs_page *req = nfs_list_entry(hdr->pages.next); - if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) - goto out_put; - nfs_init_cinfo_from_dreq(&cinfo, dreq); spin_lock(&dreq->lock); if (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) dreq->error = hdr->error; - if (dreq->error == 0) { + + if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) { + spin_unlock(&dreq->lock); + goto out_put; + } + + if (hdr->good_bytes != 0) { nfs_direct_good_bytes(dreq, hdr); if (nfs_write_need_commit(hdr)) { if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES) diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 7f0b9409202c..d23ea74b5d20 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -1248,6 +1248,7 @@ int nfs_pageio_resend(struct nfs_pageio_descriptor *desc, if (!list_empty(&pages)) { int err = desc->pg_error < 0 ? desc->pg_error : -EIO; hdr->completion_ops->error_cleanup(&pages, err); + nfs_set_pgio_error(hdr, err, hdr->io_start); return err; } return 0; |