]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.0.18/pnfs-obj-must-return-layout-on-io-error.patch
5.1-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 3.0.18 / pnfs-obj-must-return-layout-on-io-error.patch
1 From fe0fe83585f88346557868a803a479dfaaa0688a Mon Sep 17 00:00:00 2001
2 From: Boaz Harrosh <bharrosh@panasas.com>
3 Date: Fri, 6 Jan 2012 09:31:20 +0200
4 Subject: pnfs-obj: Must return layout on IO error
5
6 From: Boaz Harrosh <bharrosh@panasas.com>
7
8 commit fe0fe83585f88346557868a803a479dfaaa0688a upstream.
9
10 As mandated by the standard. In case of an IO error, a pNFS
11 objects layout driver must return it's layout. This is because
12 all device errors are reported to the server as part of the
13 layout return buffer.
14
15 This is implemented the same way PNFS_LAYOUTRET_ON_SETATTR
16 is done, through a bit flag on the pnfs_layoutdriver_type->flags
17 member. The flag is set by the layout driver that wants a
18 layout_return preformed at pnfs_ld_{write,read}_done in case
19 of an error.
20 (Though I have not defined a wrapper like pnfs_ld_layoutret_on_setattr
21 because this code is never called outside of pnfs.c and pnfs IO
22 paths)
23
24 Without this patch 3.[0-2] Kernels leak memory and have an annoying
25 WARN_ON after every IO error utilizing the pnfs-obj driver.
26
27 Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
28 Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
29 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
30
31 ---
32 fs/nfs/objlayout/objio_osd.c | 3 ++-
33 fs/nfs/pnfs.c | 12 ++++++++++++
34 fs/nfs/pnfs.h | 1 +
35 3 files changed, 15 insertions(+), 1 deletion(-)
36
37 --- a/fs/nfs/objlayout/objio_osd.c
38 +++ b/fs/nfs/objlayout/objio_osd.c
39 @@ -1006,7 +1006,8 @@ static bool objio_pg_test(struct nfs_pag
40 static struct pnfs_layoutdriver_type objlayout_type = {
41 .id = LAYOUT_OSD2_OBJECTS,
42 .name = "LAYOUT_OSD2_OBJECTS",
43 - .flags = PNFS_LAYOUTRET_ON_SETATTR,
44 + .flags = PNFS_LAYOUTRET_ON_SETATTR |
45 + PNFS_LAYOUTRET_ON_ERROR,
46
47 .alloc_layout_hdr = objlayout_alloc_layout_hdr,
48 .free_layout_hdr = objlayout_free_layout_hdr,
49 --- a/fs/nfs/pnfs.c
50 +++ b/fs/nfs/pnfs.c
51 @@ -1119,6 +1119,14 @@ pnfs_ld_write_done(struct nfs_write_data
52 data->mds_ops->rpc_release(data);
53 return 0;
54 }
55 + if (NFS_SERVER(data->inode)->pnfs_curr_ld->flags &
56 + PNFS_LAYOUTRET_ON_ERROR) {
57 + /* Don't lo_commit on error, Server will needs to
58 + * preform a file recovery.
59 + */
60 + clear_bit(NFS_INO_LAYOUTCOMMIT, &NFS_I(data->inode)->flags);
61 + pnfs_return_layout(data->inode);
62 + }
63
64 dprintk("%s: pnfs_error=%d, retry via MDS\n", __func__,
65 data->pnfs_error);
66 @@ -1167,6 +1175,10 @@ pnfs_ld_read_done(struct nfs_read_data *
67 return 0;
68 }
69
70 + if (NFS_SERVER(data->inode)->pnfs_curr_ld->flags &
71 + PNFS_LAYOUTRET_ON_ERROR)
72 + pnfs_return_layout(data->inode);
73 +
74 dprintk("%s: pnfs_error=%d, retry via MDS\n", __func__,
75 data->pnfs_error);
76 status = nfs_initiate_read(data, NFS_CLIENT(data->inode),
77 --- a/fs/nfs/pnfs.h
78 +++ b/fs/nfs/pnfs.h
79 @@ -68,6 +68,7 @@ enum {
80 enum layoutdriver_policy_flags {
81 /* Should the pNFS client commit and return the layout upon a setattr */
82 PNFS_LAYOUTRET_ON_SETATTR = 1 << 0,
83 + PNFS_LAYOUTRET_ON_ERROR = 1 << 1,
84 };
85
86 struct nfs4_deviceid_node;