NFS: Ensure O_DIRECT reports an error if the bytes read/written is 0
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: 0a00b77b33
("nfs: mirroring support for direct io")
Cc: stable@vger.kernel.org # v3.20+
This commit is contained in:
Родитель
f4340e9314
Коммит
eb2c50da9e
|
@ -401,15 +401,21 @@ static void nfs_direct_read_completion(struct nfs_pgio_header *hdr)
|
||||||
unsigned long bytes = 0;
|
unsigned long bytes = 0;
|
||||||
struct nfs_direct_req *dreq = hdr->dreq;
|
struct nfs_direct_req *dreq = hdr->dreq;
|
||||||
|
|
||||||
if (test_bit(NFS_IOHDR_REDO, &hdr->flags))
|
|
||||||
goto out_put;
|
|
||||||
|
|
||||||
spin_lock(&dreq->lock);
|
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;
|
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);
|
nfs_direct_good_bytes(dreq, hdr);
|
||||||
|
|
||||||
|
if (test_bit(NFS_IOHDR_EOF, &hdr->flags))
|
||||||
|
dreq->error = 0;
|
||||||
|
|
||||||
spin_unlock(&dreq->lock);
|
spin_unlock(&dreq->lock);
|
||||||
|
|
||||||
while (!list_empty(&hdr->pages)) {
|
while (!list_empty(&hdr->pages)) {
|
||||||
|
@ -782,16 +788,19 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr)
|
||||||
bool request_commit = false;
|
bool request_commit = false;
|
||||||
struct nfs_page *req = nfs_list_entry(hdr->pages.next);
|
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);
|
nfs_init_cinfo_from_dreq(&cinfo, dreq);
|
||||||
|
|
||||||
spin_lock(&dreq->lock);
|
spin_lock(&dreq->lock);
|
||||||
|
|
||||||
if (test_bit(NFS_IOHDR_ERROR, &hdr->flags))
|
if (test_bit(NFS_IOHDR_ERROR, &hdr->flags))
|
||||||
dreq->error = hdr->error;
|
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);
|
nfs_direct_good_bytes(dreq, hdr);
|
||||||
if (nfs_write_need_commit(hdr)) {
|
if (nfs_write_need_commit(hdr)) {
|
||||||
if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES)
|
if (dreq->flags == NFS_ODIRECT_RESCHED_WRITES)
|
||||||
|
|
|
@ -1266,6 +1266,7 @@ int nfs_pageio_resend(struct nfs_pageio_descriptor *desc,
|
||||||
if (!list_empty(&pages)) {
|
if (!list_empty(&pages)) {
|
||||||
int err = desc->pg_error < 0 ? desc->pg_error : -EIO;
|
int err = desc->pg_error < 0 ? desc->pg_error : -EIO;
|
||||||
hdr->completion_ops->error_cleanup(&pages, err);
|
hdr->completion_ops->error_cleanup(&pages, err);
|
||||||
|
nfs_set_pgio_error(hdr, err, hdr->io_start);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче