]>
Commit | Line | Data |
---|---|---|
ab0021f1 SL |
1 | From 83e3bc01d9c703a2f0182ad834fee4b4b41b7607 Mon Sep 17 00:00:00 2001 |
2 | From: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de> | |
3 | Date: Wed, 21 Nov 2018 12:25:41 +0100 | |
4 | Subject: flexfiles: use per-mirror specified stateid for IO | |
5 | ||
6 | [ Upstream commit bb21ce0ad227b69ec0f83279297ee44232105d96 ] | |
7 | ||
8 | rfc8435 says: | |
9 | ||
10 | For tight coupling, ffds_stateid provides the stateid to be used by | |
11 | the client to access the file. | |
12 | ||
13 | However current implementation replaces per-mirror provided stateid with | |
14 | by open or lock stateid. | |
15 | ||
16 | Ensure that per-mirror stateid is used by ff_layout_write_prepare_v4 and | |
17 | nfs4_ff_layout_prepare_ds. | |
18 | ||
19 | Signed-off-by: Tigran Mkrtchyan <tigran.mkrtchyan@desy.de> | |
20 | Signed-off-by: Rick Macklem <rmacklem@uoguelph.ca> | |
21 | Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> | |
22 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
23 | --- | |
24 | fs/nfs/flexfilelayout/flexfilelayout.c | 21 +++++++++------------ | |
25 | fs/nfs/flexfilelayout/flexfilelayout.h | 4 ++++ | |
26 | fs/nfs/flexfilelayout/flexfilelayoutdev.c | 19 +++++++++++++++++++ | |
27 | 3 files changed, 32 insertions(+), 12 deletions(-) | |
28 | ||
29 | diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c | |
30 | index cae43333ef16..86ac2c5b93fe 100644 | |
31 | --- a/fs/nfs/flexfilelayout/flexfilelayout.c | |
32 | +++ b/fs/nfs/flexfilelayout/flexfilelayout.c | |
33 | @@ -1361,12 +1361,7 @@ static void ff_layout_read_prepare_v4(struct rpc_task *task, void *data) | |
34 | task)) | |
35 | return; | |
36 | ||
37 | - if (ff_layout_read_prepare_common(task, hdr)) | |
38 | - return; | |
39 | - | |
40 | - if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context, | |
41 | - hdr->args.lock_context, FMODE_READ) == -EIO) | |
42 | - rpc_exit(task, -EIO); /* lost lock, terminate I/O */ | |
43 | + ff_layout_read_prepare_common(task, hdr); | |
44 | } | |
45 | ||
46 | static void ff_layout_read_call_done(struct rpc_task *task, void *data) | |
47 | @@ -1542,12 +1537,7 @@ static void ff_layout_write_prepare_v4(struct rpc_task *task, void *data) | |
48 | task)) | |
49 | return; | |
50 | ||
51 | - if (ff_layout_write_prepare_common(task, hdr)) | |
52 | - return; | |
53 | - | |
54 | - if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context, | |
55 | - hdr->args.lock_context, FMODE_WRITE) == -EIO) | |
56 | - rpc_exit(task, -EIO); /* lost lock, terminate I/O */ | |
57 | + ff_layout_write_prepare_common(task, hdr); | |
58 | } | |
59 | ||
60 | static void ff_layout_write_call_done(struct rpc_task *task, void *data) | |
61 | @@ -1742,6 +1732,10 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr) | |
62 | fh = nfs4_ff_layout_select_ds_fh(lseg, idx); | |
63 | if (fh) | |
64 | hdr->args.fh = fh; | |
65 | + | |
66 | + if (!nfs4_ff_layout_select_ds_stateid(lseg, idx, &hdr->args.stateid)) | |
67 | + goto out_failed; | |
68 | + | |
69 | /* | |
70 | * Note that if we ever decide to split across DSes, | |
71 | * then we may need to handle dense-like offsets. | |
72 | @@ -1804,6 +1798,9 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync) | |
73 | if (fh) | |
74 | hdr->args.fh = fh; | |
75 | ||
76 | + if (!nfs4_ff_layout_select_ds_stateid(lseg, idx, &hdr->args.stateid)) | |
77 | + goto out_failed; | |
78 | + | |
79 | /* | |
80 | * Note that if we ever decide to split across DSes, | |
81 | * then we may need to handle dense-like offsets. | |
82 | diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h | |
83 | index 411798346e48..de50a342d5a5 100644 | |
84 | --- a/fs/nfs/flexfilelayout/flexfilelayout.h | |
85 | +++ b/fs/nfs/flexfilelayout/flexfilelayout.h | |
86 | @@ -215,6 +215,10 @@ unsigned int ff_layout_fetch_ds_ioerr(struct pnfs_layout_hdr *lo, | |
87 | unsigned int maxnum); | |
88 | struct nfs_fh * | |
89 | nfs4_ff_layout_select_ds_fh(struct pnfs_layout_segment *lseg, u32 mirror_idx); | |
90 | +int | |
91 | +nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg, | |
92 | + u32 mirror_idx, | |
93 | + nfs4_stateid *stateid); | |
94 | ||
95 | struct nfs4_pnfs_ds * | |
96 | nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx, | |
97 | diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c | |
98 | index 59aa04976331..a8df2f496898 100644 | |
99 | --- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c | |
100 | +++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c | |
101 | @@ -370,6 +370,25 @@ out: | |
102 | return fh; | |
103 | } | |
104 | ||
105 | +int | |
106 | +nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg, | |
107 | + u32 mirror_idx, | |
108 | + nfs4_stateid *stateid) | |
109 | +{ | |
110 | + struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, mirror_idx); | |
111 | + | |
112 | + if (!ff_layout_mirror_valid(lseg, mirror, false)) { | |
113 | + pr_err_ratelimited("NFS: %s: No data server for mirror offset index %d\n", | |
114 | + __func__, mirror_idx); | |
115 | + goto out; | |
116 | + } | |
117 | + | |
118 | + nfs4_stateid_copy(stateid, &mirror->stateid); | |
119 | + return 1; | |
120 | +out: | |
121 | + return 0; | |
122 | +} | |
123 | + | |
124 | /** | |
125 | * nfs4_ff_layout_prepare_ds - prepare a DS connection for an RPC call | |
126 | * @lseg: the layout segment we're operating on | |
127 | -- | |
128 | 2.19.1 | |
129 |