aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2014-02-12 08:12:42 -0500
committerTrond Myklebust <trond.myklebust@primarydata.com>2014-02-19 21:21:05 -0500
commit27999f253010bd64fd63dc80c99f8e926e2b110d (patch)
tree7ada7d5bdf9777e26050e0dc8904f178757e7dee
parente999e80ee9fc47f1febbec6823deda3537dbbd22 (diff)
NFSv4.1: Ensure that the layout recall callback matches layout stateids
It is not sufficient to compare filehandles when we receive a layout recall from the server; we also need to check that the layout stateids match. Reported-by: shaobingqing <shaobingqing@bwstor.com.cn> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
-rw-r--r--fs/nfs/callback_proc.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c
index ae2e87b95453..570c8a1d2f3d 100644
--- a/fs/nfs/callback_proc.c
+++ b/fs/nfs/callback_proc.c
@@ -112,7 +112,8 @@ out:
112 * TODO: keep track of all layouts (and delegations) in a hash table 112 * TODO: keep track of all layouts (and delegations) in a hash table
113 * hashed by filehandle. 113 * hashed by filehandle.
114 */ 114 */
115static struct pnfs_layout_hdr * get_layout_by_fh_locked(struct nfs_client *clp, struct nfs_fh *fh) 115static struct pnfs_layout_hdr * get_layout_by_fh_locked(struct nfs_client *clp,
116 struct nfs_fh *fh, nfs4_stateid *stateid)
116{ 117{
117 struct nfs_server *server; 118 struct nfs_server *server;
118 struct inode *ino; 119 struct inode *ino;
@@ -120,6 +121,8 @@ static struct pnfs_layout_hdr * get_layout_by_fh_locked(struct nfs_client *clp,
120 121
121 list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { 122 list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
122 list_for_each_entry(lo, &server->layouts, plh_layouts) { 123 list_for_each_entry(lo, &server->layouts, plh_layouts) {
124 if (!nfs4_stateid_match_other(&lo->plh_stateid, stateid))
125 continue;
123 if (nfs_compare_fh(fh, &NFS_I(lo->plh_inode)->fh)) 126 if (nfs_compare_fh(fh, &NFS_I(lo->plh_inode)->fh))
124 continue; 127 continue;
125 ino = igrab(lo->plh_inode); 128 ino = igrab(lo->plh_inode);
@@ -141,13 +144,14 @@ static struct pnfs_layout_hdr * get_layout_by_fh_locked(struct nfs_client *clp,
141 return NULL; 144 return NULL;
142} 145}
143 146
144static struct pnfs_layout_hdr * get_layout_by_fh(struct nfs_client *clp, struct nfs_fh *fh) 147static struct pnfs_layout_hdr * get_layout_by_fh(struct nfs_client *clp,
148 struct nfs_fh *fh, nfs4_stateid *stateid)
145{ 149{
146 struct pnfs_layout_hdr *lo; 150 struct pnfs_layout_hdr *lo;
147 151
148 spin_lock(&clp->cl_lock); 152 spin_lock(&clp->cl_lock);
149 rcu_read_lock(); 153 rcu_read_lock();
150 lo = get_layout_by_fh_locked(clp, fh); 154 lo = get_layout_by_fh_locked(clp, fh, stateid);
151 rcu_read_unlock(); 155 rcu_read_unlock();
152 spin_unlock(&clp->cl_lock); 156 spin_unlock(&clp->cl_lock);
153 157
@@ -162,9 +166,9 @@ static u32 initiate_file_draining(struct nfs_client *clp,
162 u32 rv = NFS4ERR_NOMATCHING_LAYOUT; 166 u32 rv = NFS4ERR_NOMATCHING_LAYOUT;
163 LIST_HEAD(free_me_list); 167 LIST_HEAD(free_me_list);
164 168
165 lo = get_layout_by_fh(clp, &args->cbl_fh); 169 lo = get_layout_by_fh(clp, &args->cbl_fh, &args->cbl_stateid);
166 if (!lo) 170 if (!lo)
167 return NFS4ERR_NOMATCHING_LAYOUT; 171 goto out;
168 172
169 ino = lo->plh_inode; 173 ino = lo->plh_inode;
170 spin_lock(&ino->i_lock); 174 spin_lock(&ino->i_lock);
@@ -179,6 +183,7 @@ static u32 initiate_file_draining(struct nfs_client *clp,
179 pnfs_free_lseg_list(&free_me_list); 183 pnfs_free_lseg_list(&free_me_list);
180 pnfs_put_layout_hdr(lo); 184 pnfs_put_layout_hdr(lo);
181 iput(ino); 185 iput(ino);
186out:
182 return rv; 187 return rv;
183} 188}
184 189