NFS: Pass error information to the pgio error cleanup routine
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 13 Feb 2019 15:39:39 +0000 (10:39 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Sep 2019 08:21:00 +0000 (10:21 +0200)
[ Upstream commit df3accb849607a86278a37c35e6b313635ccc48b ]

Allow the caller to pass error information when cleaning up a failed
I/O request so that we can conditionally take action to cancel the
request altogether if the error turned out to be fatal.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/direct.c
fs/nfs/pagelist.c
fs/nfs/read.c
fs/nfs/write.c
include/linux/nfs_xdr.h

index 0c5e56702b19ee4a5caf7645f4354b529fc94b19..2256ea4394d3a2dd83aabd50f88a197a6e463d92 100644 (file)
@@ -428,7 +428,7 @@ out_put:
        hdr->release(hdr);
 }
 
-static void nfs_read_sync_pgio_error(struct list_head *head)
+static void nfs_read_sync_pgio_error(struct list_head *head, int error)
 {
        struct nfs_page *req;
 
@@ -820,7 +820,7 @@ out_put:
        hdr->release(hdr);
 }
 
-static void nfs_write_sync_pgio_error(struct list_head *head)
+static void nfs_write_sync_pgio_error(struct list_head *head, int error)
 {
        struct nfs_page *req;
 
index ae598e45b2df0c930eacf032e564e7bb7e2bbf5f..16d7f9068c7aeced6bf39d14230dac30638560e2 100644 (file)
@@ -993,7 +993,7 @@ nfs_pageio_cleanup_request(struct nfs_pageio_descriptor *desc,
        LIST_HEAD(head);
 
        nfs_list_move_request(req, &head);
-       desc->pg_completion_ops->error_cleanup(&head);
+       desc->pg_completion_ops->error_cleanup(&head, desc->pg_error);
 }
 
 /**
@@ -1129,7 +1129,8 @@ static void nfs_pageio_error_cleanup(struct nfs_pageio_descriptor *desc)
 
        for (midx = 0; midx < desc->pg_mirror_count; midx++) {
                mirror = &desc->pg_mirrors[midx];
-               desc->pg_completion_ops->error_cleanup(&mirror->pg_list);
+               desc->pg_completion_ops->error_cleanup(&mirror->pg_list,
+                               desc->pg_error);
        }
 }
 
index 48d7277c60a9793b3684e9587a69d26af410a8fb..09d5c282f50e92ef7c9735162e7cd9f63a922deb 100644 (file)
@@ -205,7 +205,7 @@ static void nfs_initiate_read(struct nfs_pgio_header *hdr,
 }
 
 static void
-nfs_async_read_error(struct list_head *head)
+nfs_async_read_error(struct list_head *head, int error)
 {
        struct nfs_page *req;
 
index 50ed3944d18304698330171a1e339653e4f3457e..3c1e46f4bce324311bf1306f55d5e82eee3ac4e6 100644 (file)
@@ -1397,20 +1397,27 @@ static void nfs_redirty_request(struct nfs_page *req)
        nfs_release_request(req);
 }
 
-static void nfs_async_write_error(struct list_head *head)
+static void nfs_async_write_error(struct list_head *head, int error)
 {
        struct nfs_page *req;
 
        while (!list_empty(head)) {
                req = nfs_list_entry(head->next);
                nfs_list_remove_request(req);
+               if (nfs_error_is_fatal(error)) {
+                       nfs_context_set_write_error(req->wb_context, error);
+                       if (nfs_error_is_fatal_on_server(error)) {
+                               nfs_write_error_remove_page(req);
+                               continue;
+                       }
+               }
                nfs_redirty_request(req);
        }
 }
 
 static void nfs_async_write_reschedule_io(struct nfs_pgio_header *hdr)
 {
-       nfs_async_write_error(&hdr->pages);
+       nfs_async_write_error(&hdr->pages, 0);
 }
 
 static const struct nfs_pgio_completion_ops nfs_async_write_completion_ops = {
index 6959968dc36a779b3cb61cf80b6c2e1b99672ff7..373fb26b5fed1cb66b641d64101e7049afaf2cd9 100644 (file)
@@ -1520,7 +1520,7 @@ struct nfs_commit_data {
 };
 
 struct nfs_pgio_completion_ops {
-       void    (*error_cleanup)(struct list_head *head);
+       void    (*error_cleanup)(struct list_head *head, int);
        void    (*init_hdr)(struct nfs_pgio_header *hdr);
        void    (*completion)(struct nfs_pgio_header *hdr);
        void    (*reschedule_io)(struct nfs_pgio_header *hdr);