.. | .. |
---|
3 | 3 | * Copyright (c) 2014 Anna Schumaker <Anna.Schumaker@Netapp.com> |
---|
4 | 4 | */ |
---|
5 | 5 | #include <linux/fs.h> |
---|
| 6 | +#include <linux/sunrpc/addr.h> |
---|
6 | 7 | #include <linux/sunrpc/sched.h> |
---|
7 | 8 | #include <linux/nfs.h> |
---|
8 | 9 | #include <linux/nfs3.h> |
---|
.. | .. |
---|
15 | 16 | #include "pnfs.h" |
---|
16 | 17 | #include "nfs4session.h" |
---|
17 | 18 | #include "internal.h" |
---|
| 19 | +#include "delegation.h" |
---|
| 20 | +#include "nfs4trace.h" |
---|
18 | 21 | |
---|
19 | 22 | #define NFSDBG_FACILITY NFSDBG_PROC |
---|
20 | 23 | static int nfs42_do_offload_cancel_async(struct file *dst, nfs4_stateid *std); |
---|
| 24 | + |
---|
| 25 | +static void nfs42_set_netaddr(struct file *filep, struct nfs42_netaddr *naddr) |
---|
| 26 | +{ |
---|
| 27 | + struct nfs_client *clp = (NFS_SERVER(file_inode(filep)))->nfs_client; |
---|
| 28 | + unsigned short port = 2049; |
---|
| 29 | + |
---|
| 30 | + rcu_read_lock(); |
---|
| 31 | + naddr->netid_len = scnprintf(naddr->netid, |
---|
| 32 | + sizeof(naddr->netid), "%s", |
---|
| 33 | + rpc_peeraddr2str(clp->cl_rpcclient, |
---|
| 34 | + RPC_DISPLAY_NETID)); |
---|
| 35 | + naddr->addr_len = scnprintf(naddr->addr, |
---|
| 36 | + sizeof(naddr->addr), |
---|
| 37 | + "%s.%u.%u", |
---|
| 38 | + rpc_peeraddr2str(clp->cl_rpcclient, |
---|
| 39 | + RPC_DISPLAY_ADDR), |
---|
| 40 | + port >> 8, port & 255); |
---|
| 41 | + rcu_read_unlock(); |
---|
| 42 | +} |
---|
21 | 43 | |
---|
22 | 44 | static int _nfs42_proc_fallocate(struct rpc_message *msg, struct file *filep, |
---|
23 | 45 | struct nfs_lock_context *lock, loff_t offset, loff_t len) |
---|
24 | 46 | { |
---|
25 | 47 | struct inode *inode = file_inode(filep); |
---|
26 | 48 | struct nfs_server *server = NFS_SERVER(inode); |
---|
| 49 | + u32 bitmask[3]; |
---|
27 | 50 | struct nfs42_falloc_args args = { |
---|
28 | 51 | .falloc_fh = NFS_FH(inode), |
---|
29 | 52 | .falloc_offset = offset, |
---|
30 | 53 | .falloc_length = len, |
---|
31 | | - .falloc_bitmask = server->cache_consistency_bitmask, |
---|
| 54 | + .falloc_bitmask = bitmask, |
---|
32 | 55 | }; |
---|
33 | 56 | struct nfs42_falloc_res res = { |
---|
34 | 57 | .falloc_server = server, |
---|
.. | .. |
---|
40 | 63 | |
---|
41 | 64 | status = nfs4_set_rw_stateid(&args.falloc_stateid, lock->open_context, |
---|
42 | 65 | lock, FMODE_WRITE); |
---|
43 | | - if (status) |
---|
| 66 | + if (status) { |
---|
| 67 | + if (status == -EAGAIN) |
---|
| 68 | + status = -NFS4ERR_BAD_STATEID; |
---|
44 | 69 | return status; |
---|
| 70 | + } |
---|
| 71 | + |
---|
| 72 | + memcpy(bitmask, server->cache_consistency_bitmask, sizeof(bitmask)); |
---|
| 73 | + if (server->attr_bitmask[1] & FATTR4_WORD1_SPACE_USED) |
---|
| 74 | + bitmask[1] |= FATTR4_WORD1_SPACE_USED; |
---|
45 | 75 | |
---|
46 | 76 | res.falloc_fattr = nfs_alloc_fattr(); |
---|
47 | 77 | if (!res.falloc_fattr) |
---|
.. | .. |
---|
50 | 80 | status = nfs4_call_sync(server->client, server, msg, |
---|
51 | 81 | &args.seq_args, &res.seq_res, 0); |
---|
52 | 82 | if (status == 0) |
---|
53 | | - status = nfs_post_op_update_inode(inode, res.falloc_fattr); |
---|
| 83 | + status = nfs_post_op_update_inode_force_wcc(inode, |
---|
| 84 | + res.falloc_fattr); |
---|
54 | 85 | |
---|
55 | 86 | kfree(res.falloc_fattr); |
---|
56 | 87 | return status; |
---|
.. | .. |
---|
134 | 165 | } |
---|
135 | 166 | |
---|
136 | 167 | static int handle_async_copy(struct nfs42_copy_res *res, |
---|
137 | | - struct nfs_server *server, |
---|
| 168 | + struct nfs_server *dst_server, |
---|
| 169 | + struct nfs_server *src_server, |
---|
138 | 170 | struct file *src, |
---|
139 | 171 | struct file *dst, |
---|
140 | | - nfs4_stateid *src_stateid) |
---|
| 172 | + nfs4_stateid *src_stateid, |
---|
| 173 | + bool *restart) |
---|
141 | 174 | { |
---|
142 | 175 | struct nfs4_copy_state *copy, *tmp_copy; |
---|
143 | 176 | int status = NFS4_OK; |
---|
144 | 177 | bool found_pending = false; |
---|
145 | | - struct nfs_open_context *ctx = nfs_file_open_context(dst); |
---|
| 178 | + struct nfs_open_context *dst_ctx = nfs_file_open_context(dst); |
---|
| 179 | + struct nfs_open_context *src_ctx = nfs_file_open_context(src); |
---|
146 | 180 | |
---|
147 | 181 | copy = kzalloc(sizeof(struct nfs4_copy_state), GFP_NOFS); |
---|
148 | 182 | if (!copy) |
---|
149 | 183 | return -ENOMEM; |
---|
150 | 184 | |
---|
151 | | - spin_lock(&server->nfs_client->cl_lock); |
---|
152 | | - list_for_each_entry(tmp_copy, &server->nfs_client->pending_cb_stateids, |
---|
| 185 | + spin_lock(&dst_server->nfs_client->cl_lock); |
---|
| 186 | + list_for_each_entry(tmp_copy, |
---|
| 187 | + &dst_server->nfs_client->pending_cb_stateids, |
---|
153 | 188 | copies) { |
---|
154 | 189 | if (memcmp(&res->write_res.stateid, &tmp_copy->stateid, |
---|
155 | 190 | NFS4_STATEID_SIZE)) |
---|
.. | .. |
---|
159 | 194 | break; |
---|
160 | 195 | } |
---|
161 | 196 | if (found_pending) { |
---|
162 | | - spin_unlock(&server->nfs_client->cl_lock); |
---|
| 197 | + spin_unlock(&dst_server->nfs_client->cl_lock); |
---|
163 | 198 | kfree(copy); |
---|
164 | 199 | copy = tmp_copy; |
---|
165 | 200 | goto out; |
---|
.. | .. |
---|
167 | 202 | |
---|
168 | 203 | memcpy(©->stateid, &res->write_res.stateid, NFS4_STATEID_SIZE); |
---|
169 | 204 | init_completion(©->completion); |
---|
170 | | - copy->parent_state = ctx->state; |
---|
| 205 | + copy->parent_dst_state = dst_ctx->state; |
---|
| 206 | + copy->parent_src_state = src_ctx->state; |
---|
171 | 207 | |
---|
172 | | - list_add_tail(©->copies, &server->ss_copies); |
---|
173 | | - spin_unlock(&server->nfs_client->cl_lock); |
---|
| 208 | + list_add_tail(©->copies, &dst_server->ss_copies); |
---|
| 209 | + spin_unlock(&dst_server->nfs_client->cl_lock); |
---|
| 210 | + |
---|
| 211 | + if (dst_server != src_server) { |
---|
| 212 | + spin_lock(&src_server->nfs_client->cl_lock); |
---|
| 213 | + list_add_tail(©->src_copies, &src_server->ss_copies); |
---|
| 214 | + spin_unlock(&src_server->nfs_client->cl_lock); |
---|
| 215 | + } |
---|
174 | 216 | |
---|
175 | 217 | status = wait_for_completion_interruptible(©->completion); |
---|
176 | | - spin_lock(&server->nfs_client->cl_lock); |
---|
| 218 | + spin_lock(&dst_server->nfs_client->cl_lock); |
---|
177 | 219 | list_del_init(©->copies); |
---|
178 | | - spin_unlock(&server->nfs_client->cl_lock); |
---|
| 220 | + spin_unlock(&dst_server->nfs_client->cl_lock); |
---|
| 221 | + if (dst_server != src_server) { |
---|
| 222 | + spin_lock(&src_server->nfs_client->cl_lock); |
---|
| 223 | + list_del_init(©->src_copies); |
---|
| 224 | + spin_unlock(&src_server->nfs_client->cl_lock); |
---|
| 225 | + } |
---|
179 | 226 | if (status == -ERESTARTSYS) { |
---|
180 | 227 | goto out_cancel; |
---|
181 | | - } else if (copy->flags) { |
---|
| 228 | + } else if (copy->flags || copy->error == NFS4ERR_PARTNER_NO_AUTH) { |
---|
182 | 229 | status = -EAGAIN; |
---|
| 230 | + *restart = true; |
---|
183 | 231 | goto out_cancel; |
---|
184 | 232 | } |
---|
185 | 233 | out: |
---|
.. | .. |
---|
187 | 235 | memcpy(&res->write_res.verifier, ©->verf, sizeof(copy->verf)); |
---|
188 | 236 | status = -copy->error; |
---|
189 | 237 | |
---|
| 238 | +out_free: |
---|
190 | 239 | kfree(copy); |
---|
191 | 240 | return status; |
---|
192 | 241 | out_cancel: |
---|
193 | 242 | nfs42_do_offload_cancel_async(dst, ©->stateid); |
---|
194 | | - kfree(copy); |
---|
195 | | - return status; |
---|
| 243 | + if (!nfs42_files_from_same_server(src, dst)) |
---|
| 244 | + nfs42_do_offload_cancel_async(src, src_stateid); |
---|
| 245 | + goto out_free; |
---|
196 | 246 | } |
---|
197 | 247 | |
---|
198 | 248 | static int process_copy_commit(struct file *dst, loff_t pos_dst, |
---|
.. | .. |
---|
224 | 274 | struct file *dst, |
---|
225 | 275 | struct nfs_lock_context *dst_lock, |
---|
226 | 276 | struct nfs42_copy_args *args, |
---|
227 | | - struct nfs42_copy_res *res) |
---|
| 277 | + struct nfs42_copy_res *res, |
---|
| 278 | + struct nl4_server *nss, |
---|
| 279 | + nfs4_stateid *cnr_stateid, |
---|
| 280 | + bool *restart) |
---|
228 | 281 | { |
---|
229 | 282 | struct rpc_message msg = { |
---|
230 | 283 | .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COPY], |
---|
.. | .. |
---|
232 | 285 | .rpc_resp = res, |
---|
233 | 286 | }; |
---|
234 | 287 | struct inode *dst_inode = file_inode(dst); |
---|
235 | | - struct nfs_server *server = NFS_SERVER(dst_inode); |
---|
| 288 | + struct inode *src_inode = file_inode(src); |
---|
| 289 | + struct nfs_server *dst_server = NFS_SERVER(dst_inode); |
---|
| 290 | + struct nfs_server *src_server = NFS_SERVER(src_inode); |
---|
236 | 291 | loff_t pos_src = args->src_pos; |
---|
237 | 292 | loff_t pos_dst = args->dst_pos; |
---|
238 | 293 | size_t count = args->count; |
---|
239 | 294 | ssize_t status; |
---|
240 | 295 | |
---|
241 | | - status = nfs4_set_rw_stateid(&args->src_stateid, src_lock->open_context, |
---|
242 | | - src_lock, FMODE_READ); |
---|
243 | | - if (status) |
---|
244 | | - return status; |
---|
245 | | - |
---|
| 296 | + if (nss) { |
---|
| 297 | + args->cp_src = nss; |
---|
| 298 | + nfs4_stateid_copy(&args->src_stateid, cnr_stateid); |
---|
| 299 | + } else { |
---|
| 300 | + status = nfs4_set_rw_stateid(&args->src_stateid, |
---|
| 301 | + src_lock->open_context, src_lock, FMODE_READ); |
---|
| 302 | + if (status) { |
---|
| 303 | + if (status == -EAGAIN) |
---|
| 304 | + status = -NFS4ERR_BAD_STATEID; |
---|
| 305 | + return status; |
---|
| 306 | + } |
---|
| 307 | + } |
---|
246 | 308 | status = nfs_filemap_write_and_wait_range(file_inode(src)->i_mapping, |
---|
247 | 309 | pos_src, pos_src + (loff_t)count - 1); |
---|
248 | 310 | if (status) |
---|
.. | .. |
---|
250 | 312 | |
---|
251 | 313 | status = nfs4_set_rw_stateid(&args->dst_stateid, dst_lock->open_context, |
---|
252 | 314 | dst_lock, FMODE_WRITE); |
---|
253 | | - if (status) |
---|
| 315 | + if (status) { |
---|
| 316 | + if (status == -EAGAIN) |
---|
| 317 | + status = -NFS4ERR_BAD_STATEID; |
---|
254 | 318 | return status; |
---|
| 319 | + } |
---|
255 | 320 | |
---|
256 | 321 | status = nfs_sync_inode(dst_inode); |
---|
257 | 322 | if (status) |
---|
.. | .. |
---|
264 | 329 | if (!res->commit_res.verf) |
---|
265 | 330 | return -ENOMEM; |
---|
266 | 331 | } |
---|
| 332 | + set_bit(NFS_CLNT_SRC_SSC_COPY_STATE, |
---|
| 333 | + &src_lock->open_context->state->flags); |
---|
267 | 334 | set_bit(NFS_CLNT_DST_SSC_COPY_STATE, |
---|
268 | 335 | &dst_lock->open_context->state->flags); |
---|
269 | 336 | |
---|
270 | | - status = nfs4_call_sync(server->client, server, &msg, |
---|
| 337 | + status = nfs4_call_sync(dst_server->client, dst_server, &msg, |
---|
271 | 338 | &args->seq_args, &res->seq_res, 0); |
---|
272 | 339 | if (status == -ENOTSUPP) |
---|
273 | | - server->caps &= ~NFS_CAP_COPY; |
---|
| 340 | + dst_server->caps &= ~NFS_CAP_COPY; |
---|
274 | 341 | if (status) |
---|
275 | 342 | goto out; |
---|
276 | 343 | |
---|
.. | .. |
---|
282 | 349 | } |
---|
283 | 350 | |
---|
284 | 351 | if (!res->synchronous) { |
---|
285 | | - status = handle_async_copy(res, server, src, dst, |
---|
286 | | - &args->src_stateid); |
---|
| 352 | + status = handle_async_copy(res, dst_server, src_server, src, |
---|
| 353 | + dst, &args->src_stateid, restart); |
---|
287 | 354 | if (status) |
---|
288 | 355 | goto out; |
---|
289 | 356 | } |
---|
.. | .. |
---|
298 | 365 | WARN_ON_ONCE(invalidate_inode_pages2_range(dst_inode->i_mapping, |
---|
299 | 366 | pos_dst >> PAGE_SHIFT, |
---|
300 | 367 | (pos_dst + res->write_res.count - 1) >> PAGE_SHIFT)); |
---|
301 | | - |
---|
| 368 | + spin_lock(&dst_inode->i_lock); |
---|
| 369 | + NFS_I(dst_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE | |
---|
| 370 | + NFS_INO_REVAL_FORCED | NFS_INO_INVALID_SIZE | |
---|
| 371 | + NFS_INO_INVALID_ATTR | NFS_INO_INVALID_DATA); |
---|
| 372 | + spin_unlock(&dst_inode->i_lock); |
---|
| 373 | + spin_lock(&src_inode->i_lock); |
---|
| 374 | + NFS_I(src_inode)->cache_validity |= (NFS_INO_REVAL_PAGECACHE | |
---|
| 375 | + NFS_INO_REVAL_FORCED | NFS_INO_INVALID_ATIME); |
---|
| 376 | + spin_unlock(&src_inode->i_lock); |
---|
302 | 377 | status = res->write_res.count; |
---|
303 | 378 | out: |
---|
304 | 379 | if (args->sync) |
---|
.. | .. |
---|
307 | 382 | } |
---|
308 | 383 | |
---|
309 | 384 | ssize_t nfs42_proc_copy(struct file *src, loff_t pos_src, |
---|
310 | | - struct file *dst, loff_t pos_dst, |
---|
311 | | - size_t count) |
---|
| 385 | + struct file *dst, loff_t pos_dst, size_t count, |
---|
| 386 | + struct nl4_server *nss, |
---|
| 387 | + nfs4_stateid *cnr_stateid, bool sync) |
---|
312 | 388 | { |
---|
313 | 389 | struct nfs_server *server = NFS_SERVER(file_inode(dst)); |
---|
314 | 390 | struct nfs_lock_context *src_lock; |
---|
.. | .. |
---|
319 | 395 | .dst_fh = NFS_FH(file_inode(dst)), |
---|
320 | 396 | .dst_pos = pos_dst, |
---|
321 | 397 | .count = count, |
---|
322 | | - .sync = false, |
---|
| 398 | + .sync = sync, |
---|
323 | 399 | }; |
---|
324 | 400 | struct nfs42_copy_res res; |
---|
325 | 401 | struct nfs4_exception src_exception = { |
---|
.. | .. |
---|
331 | 407 | .stateid = &args.dst_stateid, |
---|
332 | 408 | }; |
---|
333 | 409 | ssize_t err, err2; |
---|
| 410 | + bool restart = false; |
---|
334 | 411 | |
---|
335 | 412 | src_lock = nfs_get_lock_context(nfs_file_open_context(src)); |
---|
336 | 413 | if (IS_ERR(src_lock)) |
---|
.. | .. |
---|
350 | 427 | inode_lock(file_inode(dst)); |
---|
351 | 428 | err = _nfs42_proc_copy(src, src_lock, |
---|
352 | 429 | dst, dst_lock, |
---|
353 | | - &args, &res); |
---|
| 430 | + &args, &res, |
---|
| 431 | + nss, cnr_stateid, &restart); |
---|
354 | 432 | inode_unlock(file_inode(dst)); |
---|
355 | 433 | |
---|
356 | 434 | if (err >= 0) |
---|
357 | 435 | break; |
---|
358 | | - if (err == -ENOTSUPP) { |
---|
| 436 | + if (err == -ENOTSUPP && |
---|
| 437 | + nfs42_files_from_same_server(src, dst)) { |
---|
359 | 438 | err = -EOPNOTSUPP; |
---|
360 | 439 | break; |
---|
361 | 440 | } else if (err == -EAGAIN) { |
---|
| 441 | + if (!restart) { |
---|
| 442 | + dst_exception.retry = 1; |
---|
| 443 | + continue; |
---|
| 444 | + } |
---|
| 445 | + break; |
---|
| 446 | + } else if (err == -NFS4ERR_OFFLOAD_NO_REQS && |
---|
| 447 | + args.sync != res.synchronous) { |
---|
| 448 | + args.sync = res.synchronous; |
---|
362 | 449 | dst_exception.retry = 1; |
---|
363 | 450 | continue; |
---|
364 | | - } else if (err == -NFS4ERR_OFFLOAD_NO_REQS && !args.sync) { |
---|
365 | | - args.sync = true; |
---|
366 | | - dst_exception.retry = 1; |
---|
367 | | - continue; |
---|
| 451 | + } else if ((err == -ESTALE || |
---|
| 452 | + err == -NFS4ERR_OFFLOAD_DENIED || |
---|
| 453 | + err == -ENOTSUPP) && |
---|
| 454 | + !nfs42_files_from_same_server(src, dst)) { |
---|
| 455 | + nfs42_do_offload_cancel_async(src, &args.src_stateid); |
---|
| 456 | + err = -EOPNOTSUPP; |
---|
| 457 | + break; |
---|
368 | 458 | } |
---|
369 | 459 | |
---|
370 | 460 | err2 = nfs4_handle_exception(server, err, &src_exception); |
---|
.. | .. |
---|
462 | 552 | return status; |
---|
463 | 553 | } |
---|
464 | 554 | |
---|
| 555 | +static int _nfs42_proc_copy_notify(struct file *src, struct file *dst, |
---|
| 556 | + struct nfs42_copy_notify_args *args, |
---|
| 557 | + struct nfs42_copy_notify_res *res) |
---|
| 558 | +{ |
---|
| 559 | + struct nfs_server *src_server = NFS_SERVER(file_inode(src)); |
---|
| 560 | + struct rpc_message msg = { |
---|
| 561 | + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COPY_NOTIFY], |
---|
| 562 | + .rpc_argp = args, |
---|
| 563 | + .rpc_resp = res, |
---|
| 564 | + }; |
---|
| 565 | + int status; |
---|
| 566 | + struct nfs_open_context *ctx; |
---|
| 567 | + struct nfs_lock_context *l_ctx; |
---|
| 568 | + |
---|
| 569 | + ctx = get_nfs_open_context(nfs_file_open_context(src)); |
---|
| 570 | + l_ctx = nfs_get_lock_context(ctx); |
---|
| 571 | + if (IS_ERR(l_ctx)) { |
---|
| 572 | + status = PTR_ERR(l_ctx); |
---|
| 573 | + goto out; |
---|
| 574 | + } |
---|
| 575 | + |
---|
| 576 | + status = nfs4_set_rw_stateid(&args->cna_src_stateid, ctx, l_ctx, |
---|
| 577 | + FMODE_READ); |
---|
| 578 | + nfs_put_lock_context(l_ctx); |
---|
| 579 | + if (status) { |
---|
| 580 | + if (status == -EAGAIN) |
---|
| 581 | + status = -NFS4ERR_BAD_STATEID; |
---|
| 582 | + goto out; |
---|
| 583 | + } |
---|
| 584 | + |
---|
| 585 | + status = nfs4_call_sync(src_server->client, src_server, &msg, |
---|
| 586 | + &args->cna_seq_args, &res->cnr_seq_res, 0); |
---|
| 587 | + if (status == -ENOTSUPP) |
---|
| 588 | + src_server->caps &= ~NFS_CAP_COPY_NOTIFY; |
---|
| 589 | + |
---|
| 590 | +out: |
---|
| 591 | + put_nfs_open_context(nfs_file_open_context(src)); |
---|
| 592 | + return status; |
---|
| 593 | +} |
---|
| 594 | + |
---|
| 595 | +int nfs42_proc_copy_notify(struct file *src, struct file *dst, |
---|
| 596 | + struct nfs42_copy_notify_res *res) |
---|
| 597 | +{ |
---|
| 598 | + struct nfs_server *src_server = NFS_SERVER(file_inode(src)); |
---|
| 599 | + struct nfs42_copy_notify_args *args; |
---|
| 600 | + struct nfs4_exception exception = { |
---|
| 601 | + .inode = file_inode(src), |
---|
| 602 | + }; |
---|
| 603 | + int status; |
---|
| 604 | + |
---|
| 605 | + if (!(src_server->caps & NFS_CAP_COPY_NOTIFY)) |
---|
| 606 | + return -EOPNOTSUPP; |
---|
| 607 | + |
---|
| 608 | + args = kzalloc(sizeof(struct nfs42_copy_notify_args), GFP_NOFS); |
---|
| 609 | + if (args == NULL) |
---|
| 610 | + return -ENOMEM; |
---|
| 611 | + |
---|
| 612 | + args->cna_src_fh = NFS_FH(file_inode(src)), |
---|
| 613 | + args->cna_dst.nl4_type = NL4_NETADDR; |
---|
| 614 | + nfs42_set_netaddr(dst, &args->cna_dst.u.nl4_addr); |
---|
| 615 | + exception.stateid = &args->cna_src_stateid; |
---|
| 616 | + |
---|
| 617 | + do { |
---|
| 618 | + status = _nfs42_proc_copy_notify(src, dst, args, res); |
---|
| 619 | + if (status == -ENOTSUPP) { |
---|
| 620 | + status = -EOPNOTSUPP; |
---|
| 621 | + goto out; |
---|
| 622 | + } |
---|
| 623 | + status = nfs4_handle_exception(src_server, status, &exception); |
---|
| 624 | + } while (exception.retry); |
---|
| 625 | + |
---|
| 626 | +out: |
---|
| 627 | + kfree(args); |
---|
| 628 | + return status; |
---|
| 629 | +} |
---|
| 630 | + |
---|
465 | 631 | static loff_t _nfs42_proc_llseek(struct file *filep, |
---|
466 | 632 | struct nfs_lock_context *lock, loff_t offset, int whence) |
---|
467 | 633 | { |
---|
.. | .. |
---|
486 | 652 | |
---|
487 | 653 | status = nfs4_set_rw_stateid(&args.sa_stateid, lock->open_context, |
---|
488 | 654 | lock, FMODE_READ); |
---|
489 | | - if (status) |
---|
| 655 | + if (status) { |
---|
| 656 | + if (status == -EAGAIN) |
---|
| 657 | + status = -NFS4ERR_BAD_STATEID; |
---|
490 | 658 | return status; |
---|
| 659 | + } |
---|
491 | 660 | |
---|
492 | 661 | status = nfs_filemap_write_and_wait_range(inode->i_mapping, |
---|
493 | 662 | offset, LLONG_MAX); |
---|
.. | .. |
---|
570 | 739 | |
---|
571 | 740 | switch (task->tk_status) { |
---|
572 | 741 | case 0: |
---|
573 | | - break; |
---|
| 742 | + return; |
---|
574 | 743 | case -NFS4ERR_BADHANDLE: |
---|
575 | 744 | case -ESTALE: |
---|
576 | 745 | pnfs_destroy_layout(NFS_I(inode)); |
---|
.. | .. |
---|
616 | 785 | case -EOPNOTSUPP: |
---|
617 | 786 | NFS_SERVER(inode)->caps &= ~NFS_CAP_LAYOUTSTATS; |
---|
618 | 787 | } |
---|
| 788 | + |
---|
| 789 | + trace_nfs4_layoutstats(inode, &data->args.stateid, task->tk_status); |
---|
619 | 790 | } |
---|
620 | 791 | |
---|
621 | 792 | static void |
---|
.. | .. |
---|
675 | 846 | return 0; |
---|
676 | 847 | } |
---|
677 | 848 | |
---|
| 849 | +static struct nfs42_layouterror_data * |
---|
| 850 | +nfs42_alloc_layouterror_data(struct pnfs_layout_segment *lseg, gfp_t gfp_flags) |
---|
| 851 | +{ |
---|
| 852 | + struct nfs42_layouterror_data *data; |
---|
| 853 | + struct inode *inode = lseg->pls_layout->plh_inode; |
---|
| 854 | + |
---|
| 855 | + data = kzalloc(sizeof(*data), gfp_flags); |
---|
| 856 | + if (data) { |
---|
| 857 | + data->args.inode = data->inode = nfs_igrab_and_active(inode); |
---|
| 858 | + if (data->inode) { |
---|
| 859 | + data->lseg = pnfs_get_lseg(lseg); |
---|
| 860 | + if (data->lseg) |
---|
| 861 | + return data; |
---|
| 862 | + nfs_iput_and_deactive(data->inode); |
---|
| 863 | + } |
---|
| 864 | + kfree(data); |
---|
| 865 | + } |
---|
| 866 | + return NULL; |
---|
| 867 | +} |
---|
| 868 | + |
---|
| 869 | +static void |
---|
| 870 | +nfs42_free_layouterror_data(struct nfs42_layouterror_data *data) |
---|
| 871 | +{ |
---|
| 872 | + pnfs_put_lseg(data->lseg); |
---|
| 873 | + nfs_iput_and_deactive(data->inode); |
---|
| 874 | + kfree(data); |
---|
| 875 | +} |
---|
| 876 | + |
---|
| 877 | +static void |
---|
| 878 | +nfs42_layouterror_prepare(struct rpc_task *task, void *calldata) |
---|
| 879 | +{ |
---|
| 880 | + struct nfs42_layouterror_data *data = calldata; |
---|
| 881 | + struct inode *inode = data->inode; |
---|
| 882 | + struct nfs_server *server = NFS_SERVER(inode); |
---|
| 883 | + struct pnfs_layout_hdr *lo = data->lseg->pls_layout; |
---|
| 884 | + unsigned i; |
---|
| 885 | + |
---|
| 886 | + spin_lock(&inode->i_lock); |
---|
| 887 | + if (!pnfs_layout_is_valid(lo)) { |
---|
| 888 | + spin_unlock(&inode->i_lock); |
---|
| 889 | + rpc_exit(task, 0); |
---|
| 890 | + return; |
---|
| 891 | + } |
---|
| 892 | + for (i = 0; i < data->args.num_errors; i++) |
---|
| 893 | + nfs4_stateid_copy(&data->args.errors[i].stateid, |
---|
| 894 | + &lo->plh_stateid); |
---|
| 895 | + spin_unlock(&inode->i_lock); |
---|
| 896 | + nfs4_setup_sequence(server->nfs_client, &data->args.seq_args, |
---|
| 897 | + &data->res.seq_res, task); |
---|
| 898 | +} |
---|
| 899 | + |
---|
| 900 | +static void |
---|
| 901 | +nfs42_layouterror_done(struct rpc_task *task, void *calldata) |
---|
| 902 | +{ |
---|
| 903 | + struct nfs42_layouterror_data *data = calldata; |
---|
| 904 | + struct inode *inode = data->inode; |
---|
| 905 | + struct pnfs_layout_hdr *lo = data->lseg->pls_layout; |
---|
| 906 | + |
---|
| 907 | + if (!nfs4_sequence_done(task, &data->res.seq_res)) |
---|
| 908 | + return; |
---|
| 909 | + |
---|
| 910 | + switch (task->tk_status) { |
---|
| 911 | + case 0: |
---|
| 912 | + return; |
---|
| 913 | + case -NFS4ERR_BADHANDLE: |
---|
| 914 | + case -ESTALE: |
---|
| 915 | + pnfs_destroy_layout(NFS_I(inode)); |
---|
| 916 | + break; |
---|
| 917 | + case -NFS4ERR_EXPIRED: |
---|
| 918 | + case -NFS4ERR_ADMIN_REVOKED: |
---|
| 919 | + case -NFS4ERR_DELEG_REVOKED: |
---|
| 920 | + case -NFS4ERR_STALE_STATEID: |
---|
| 921 | + case -NFS4ERR_BAD_STATEID: |
---|
| 922 | + spin_lock(&inode->i_lock); |
---|
| 923 | + if (pnfs_layout_is_valid(lo) && |
---|
| 924 | + nfs4_stateid_match(&data->args.errors[0].stateid, |
---|
| 925 | + &lo->plh_stateid)) { |
---|
| 926 | + LIST_HEAD(head); |
---|
| 927 | + |
---|
| 928 | + /* |
---|
| 929 | + * Mark the bad layout state as invalid, then retry |
---|
| 930 | + * with the current stateid. |
---|
| 931 | + */ |
---|
| 932 | + pnfs_mark_layout_stateid_invalid(lo, &head); |
---|
| 933 | + spin_unlock(&inode->i_lock); |
---|
| 934 | + pnfs_free_lseg_list(&head); |
---|
| 935 | + nfs_commit_inode(inode, 0); |
---|
| 936 | + } else |
---|
| 937 | + spin_unlock(&inode->i_lock); |
---|
| 938 | + break; |
---|
| 939 | + case -NFS4ERR_OLD_STATEID: |
---|
| 940 | + spin_lock(&inode->i_lock); |
---|
| 941 | + if (pnfs_layout_is_valid(lo) && |
---|
| 942 | + nfs4_stateid_match_other(&data->args.errors[0].stateid, |
---|
| 943 | + &lo->plh_stateid)) { |
---|
| 944 | + /* Do we need to delay before resending? */ |
---|
| 945 | + if (!nfs4_stateid_is_newer(&lo->plh_stateid, |
---|
| 946 | + &data->args.errors[0].stateid)) |
---|
| 947 | + rpc_delay(task, HZ); |
---|
| 948 | + rpc_restart_call_prepare(task); |
---|
| 949 | + } |
---|
| 950 | + spin_unlock(&inode->i_lock); |
---|
| 951 | + break; |
---|
| 952 | + case -ENOTSUPP: |
---|
| 953 | + case -EOPNOTSUPP: |
---|
| 954 | + NFS_SERVER(inode)->caps &= ~NFS_CAP_LAYOUTERROR; |
---|
| 955 | + } |
---|
| 956 | + |
---|
| 957 | + trace_nfs4_layouterror(inode, &data->args.errors[0].stateid, |
---|
| 958 | + task->tk_status); |
---|
| 959 | +} |
---|
| 960 | + |
---|
| 961 | +static void |
---|
| 962 | +nfs42_layouterror_release(void *calldata) |
---|
| 963 | +{ |
---|
| 964 | + struct nfs42_layouterror_data *data = calldata; |
---|
| 965 | + |
---|
| 966 | + nfs42_free_layouterror_data(data); |
---|
| 967 | +} |
---|
| 968 | + |
---|
| 969 | +static const struct rpc_call_ops nfs42_layouterror_ops = { |
---|
| 970 | + .rpc_call_prepare = nfs42_layouterror_prepare, |
---|
| 971 | + .rpc_call_done = nfs42_layouterror_done, |
---|
| 972 | + .rpc_release = nfs42_layouterror_release, |
---|
| 973 | +}; |
---|
| 974 | + |
---|
| 975 | +int nfs42_proc_layouterror(struct pnfs_layout_segment *lseg, |
---|
| 976 | + const struct nfs42_layout_error *errors, size_t n) |
---|
| 977 | +{ |
---|
| 978 | + struct inode *inode = lseg->pls_layout->plh_inode; |
---|
| 979 | + struct nfs42_layouterror_data *data; |
---|
| 980 | + struct rpc_task *task; |
---|
| 981 | + struct rpc_message msg = { |
---|
| 982 | + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LAYOUTERROR], |
---|
| 983 | + }; |
---|
| 984 | + struct rpc_task_setup task_setup = { |
---|
| 985 | + .rpc_message = &msg, |
---|
| 986 | + .callback_ops = &nfs42_layouterror_ops, |
---|
| 987 | + .flags = RPC_TASK_ASYNC, |
---|
| 988 | + }; |
---|
| 989 | + unsigned int i; |
---|
| 990 | + |
---|
| 991 | + if (!nfs_server_capable(inode, NFS_CAP_LAYOUTERROR)) |
---|
| 992 | + return -EOPNOTSUPP; |
---|
| 993 | + if (n > NFS42_LAYOUTERROR_MAX) |
---|
| 994 | + return -EINVAL; |
---|
| 995 | + data = nfs42_alloc_layouterror_data(lseg, GFP_NOFS); |
---|
| 996 | + if (!data) |
---|
| 997 | + return -ENOMEM; |
---|
| 998 | + for (i = 0; i < n; i++) { |
---|
| 999 | + data->args.errors[i] = errors[i]; |
---|
| 1000 | + data->args.num_errors++; |
---|
| 1001 | + data->res.num_errors++; |
---|
| 1002 | + } |
---|
| 1003 | + msg.rpc_argp = &data->args; |
---|
| 1004 | + msg.rpc_resp = &data->res; |
---|
| 1005 | + task_setup.callback_data = data; |
---|
| 1006 | + task_setup.rpc_client = NFS_SERVER(inode)->client; |
---|
| 1007 | + nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0, 0); |
---|
| 1008 | + task = rpc_run_task(&task_setup); |
---|
| 1009 | + if (IS_ERR(task)) |
---|
| 1010 | + return PTR_ERR(task); |
---|
| 1011 | + rpc_put_task(task); |
---|
| 1012 | + return 0; |
---|
| 1013 | +} |
---|
| 1014 | +EXPORT_SYMBOL_GPL(nfs42_proc_layouterror); |
---|
| 1015 | + |
---|
678 | 1016 | static int _nfs42_proc_clone(struct rpc_message *msg, struct file *src_f, |
---|
679 | 1017 | struct file *dst_f, struct nfs_lock_context *src_lock, |
---|
680 | 1018 | struct nfs_lock_context *dst_lock, loff_t src_offset, |
---|
.. | .. |
---|
701 | 1039 | |
---|
702 | 1040 | status = nfs4_set_rw_stateid(&args.src_stateid, src_lock->open_context, |
---|
703 | 1041 | src_lock, FMODE_READ); |
---|
704 | | - if (status) |
---|
| 1042 | + if (status) { |
---|
| 1043 | + if (status == -EAGAIN) |
---|
| 1044 | + status = -NFS4ERR_BAD_STATEID; |
---|
705 | 1045 | return status; |
---|
706 | | - |
---|
| 1046 | + } |
---|
707 | 1047 | status = nfs4_set_rw_stateid(&args.dst_stateid, dst_lock->open_context, |
---|
708 | 1048 | dst_lock, FMODE_WRITE); |
---|
709 | | - if (status) |
---|
| 1049 | + if (status) { |
---|
| 1050 | + if (status == -EAGAIN) |
---|
| 1051 | + status = -NFS4ERR_BAD_STATEID; |
---|
710 | 1052 | return status; |
---|
| 1053 | + } |
---|
711 | 1054 | |
---|
712 | 1055 | res.dst_fattr = nfs_alloc_fattr(); |
---|
713 | 1056 | if (!res.dst_fattr) |
---|
.. | .. |
---|
775 | 1118 | nfs_put_lock_context(src_lock); |
---|
776 | 1119 | return err; |
---|
777 | 1120 | } |
---|
| 1121 | + |
---|
| 1122 | +#define NFS4XATTR_MAXPAGES DIV_ROUND_UP(XATTR_SIZE_MAX, PAGE_SIZE) |
---|
| 1123 | + |
---|
| 1124 | +static int _nfs42_proc_removexattr(struct inode *inode, const char *name) |
---|
| 1125 | +{ |
---|
| 1126 | + struct nfs_server *server = NFS_SERVER(inode); |
---|
| 1127 | + struct nfs42_removexattrargs args = { |
---|
| 1128 | + .fh = NFS_FH(inode), |
---|
| 1129 | + .xattr_name = name, |
---|
| 1130 | + }; |
---|
| 1131 | + struct nfs42_removexattrres res; |
---|
| 1132 | + struct rpc_message msg = { |
---|
| 1133 | + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVEXATTR], |
---|
| 1134 | + .rpc_argp = &args, |
---|
| 1135 | + .rpc_resp = &res, |
---|
| 1136 | + }; |
---|
| 1137 | + int ret; |
---|
| 1138 | + unsigned long timestamp = jiffies; |
---|
| 1139 | + |
---|
| 1140 | + ret = nfs4_call_sync(server->client, server, &msg, &args.seq_args, |
---|
| 1141 | + &res.seq_res, 1); |
---|
| 1142 | + if (!ret) |
---|
| 1143 | + nfs4_update_changeattr(inode, &res.cinfo, timestamp, 0); |
---|
| 1144 | + |
---|
| 1145 | + return ret; |
---|
| 1146 | +} |
---|
| 1147 | + |
---|
| 1148 | +static int _nfs42_proc_setxattr(struct inode *inode, const char *name, |
---|
| 1149 | + const void *buf, size_t buflen, int flags) |
---|
| 1150 | +{ |
---|
| 1151 | + struct nfs_server *server = NFS_SERVER(inode); |
---|
| 1152 | + struct page *pages[NFS4XATTR_MAXPAGES]; |
---|
| 1153 | + struct nfs42_setxattrargs arg = { |
---|
| 1154 | + .fh = NFS_FH(inode), |
---|
| 1155 | + .xattr_pages = pages, |
---|
| 1156 | + .xattr_len = buflen, |
---|
| 1157 | + .xattr_name = name, |
---|
| 1158 | + .xattr_flags = flags, |
---|
| 1159 | + }; |
---|
| 1160 | + struct nfs42_setxattrres res; |
---|
| 1161 | + struct rpc_message msg = { |
---|
| 1162 | + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_SETXATTR], |
---|
| 1163 | + .rpc_argp = &arg, |
---|
| 1164 | + .rpc_resp = &res, |
---|
| 1165 | + }; |
---|
| 1166 | + int ret, np; |
---|
| 1167 | + unsigned long timestamp = jiffies; |
---|
| 1168 | + |
---|
| 1169 | + if (buflen > server->sxasize) |
---|
| 1170 | + return -ERANGE; |
---|
| 1171 | + |
---|
| 1172 | + if (buflen > 0) { |
---|
| 1173 | + np = nfs4_buf_to_pages_noslab(buf, buflen, arg.xattr_pages); |
---|
| 1174 | + if (np < 0) |
---|
| 1175 | + return np; |
---|
| 1176 | + } else |
---|
| 1177 | + np = 0; |
---|
| 1178 | + |
---|
| 1179 | + ret = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, |
---|
| 1180 | + &res.seq_res, 1); |
---|
| 1181 | + |
---|
| 1182 | + for (; np > 0; np--) |
---|
| 1183 | + put_page(pages[np - 1]); |
---|
| 1184 | + |
---|
| 1185 | + if (!ret) |
---|
| 1186 | + nfs4_update_changeattr(inode, &res.cinfo, timestamp, 0); |
---|
| 1187 | + |
---|
| 1188 | + return ret; |
---|
| 1189 | +} |
---|
| 1190 | + |
---|
| 1191 | +static ssize_t _nfs42_proc_getxattr(struct inode *inode, const char *name, |
---|
| 1192 | + void *buf, size_t buflen) |
---|
| 1193 | +{ |
---|
| 1194 | + struct nfs_server *server = NFS_SERVER(inode); |
---|
| 1195 | + struct page *pages[NFS4XATTR_MAXPAGES] = {}; |
---|
| 1196 | + struct nfs42_getxattrargs arg = { |
---|
| 1197 | + .fh = NFS_FH(inode), |
---|
| 1198 | + .xattr_pages = pages, |
---|
| 1199 | + .xattr_len = buflen, |
---|
| 1200 | + .xattr_name = name, |
---|
| 1201 | + }; |
---|
| 1202 | + struct nfs42_getxattrres res; |
---|
| 1203 | + struct rpc_message msg = { |
---|
| 1204 | + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_GETXATTR], |
---|
| 1205 | + .rpc_argp = &arg, |
---|
| 1206 | + .rpc_resp = &res, |
---|
| 1207 | + }; |
---|
| 1208 | + int ret, np; |
---|
| 1209 | + |
---|
| 1210 | + ret = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, |
---|
| 1211 | + &res.seq_res, 0); |
---|
| 1212 | + if (ret < 0) |
---|
| 1213 | + return ret; |
---|
| 1214 | + |
---|
| 1215 | + /* |
---|
| 1216 | + * Normally, the caching is done one layer up, but for successful |
---|
| 1217 | + * RPCS, always cache the result here, even if the caller was |
---|
| 1218 | + * just querying the length, or if the reply was too big for |
---|
| 1219 | + * the caller. This avoids a second RPC in the case of the |
---|
| 1220 | + * common query-alloc-retrieve cycle for xattrs. |
---|
| 1221 | + * |
---|
| 1222 | + * Note that xattr_len is always capped to XATTR_SIZE_MAX. |
---|
| 1223 | + */ |
---|
| 1224 | + |
---|
| 1225 | + nfs4_xattr_cache_add(inode, name, NULL, pages, res.xattr_len); |
---|
| 1226 | + |
---|
| 1227 | + if (buflen) { |
---|
| 1228 | + if (res.xattr_len > buflen) |
---|
| 1229 | + return -ERANGE; |
---|
| 1230 | + _copy_from_pages(buf, pages, 0, res.xattr_len); |
---|
| 1231 | + } |
---|
| 1232 | + |
---|
| 1233 | + np = DIV_ROUND_UP(res.xattr_len, PAGE_SIZE); |
---|
| 1234 | + while (--np >= 0) |
---|
| 1235 | + __free_page(pages[np]); |
---|
| 1236 | + |
---|
| 1237 | + return res.xattr_len; |
---|
| 1238 | +} |
---|
| 1239 | + |
---|
| 1240 | +static ssize_t _nfs42_proc_listxattrs(struct inode *inode, void *buf, |
---|
| 1241 | + size_t buflen, u64 *cookiep, bool *eofp) |
---|
| 1242 | +{ |
---|
| 1243 | + struct nfs_server *server = NFS_SERVER(inode); |
---|
| 1244 | + struct page **pages; |
---|
| 1245 | + struct nfs42_listxattrsargs arg = { |
---|
| 1246 | + .fh = NFS_FH(inode), |
---|
| 1247 | + .cookie = *cookiep, |
---|
| 1248 | + }; |
---|
| 1249 | + struct nfs42_listxattrsres res = { |
---|
| 1250 | + .eof = false, |
---|
| 1251 | + .xattr_buf = buf, |
---|
| 1252 | + .xattr_len = buflen, |
---|
| 1253 | + }; |
---|
| 1254 | + struct rpc_message msg = { |
---|
| 1255 | + .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LISTXATTRS], |
---|
| 1256 | + .rpc_argp = &arg, |
---|
| 1257 | + .rpc_resp = &res, |
---|
| 1258 | + }; |
---|
| 1259 | + u32 xdrlen; |
---|
| 1260 | + int ret, np, i; |
---|
| 1261 | + |
---|
| 1262 | + |
---|
| 1263 | + ret = -ENOMEM; |
---|
| 1264 | + res.scratch = alloc_page(GFP_KERNEL); |
---|
| 1265 | + if (!res.scratch) |
---|
| 1266 | + goto out; |
---|
| 1267 | + |
---|
| 1268 | + xdrlen = nfs42_listxattr_xdrsize(buflen); |
---|
| 1269 | + if (xdrlen > server->lxasize) |
---|
| 1270 | + xdrlen = server->lxasize; |
---|
| 1271 | + np = xdrlen / PAGE_SIZE + 1; |
---|
| 1272 | + |
---|
| 1273 | + pages = kcalloc(np, sizeof(struct page *), GFP_KERNEL); |
---|
| 1274 | + if (!pages) |
---|
| 1275 | + goto out_free_scratch; |
---|
| 1276 | + for (i = 0; i < np; i++) { |
---|
| 1277 | + pages[i] = alloc_page(GFP_KERNEL); |
---|
| 1278 | + if (!pages[i]) |
---|
| 1279 | + goto out_free_pages; |
---|
| 1280 | + } |
---|
| 1281 | + |
---|
| 1282 | + arg.xattr_pages = pages; |
---|
| 1283 | + arg.count = xdrlen; |
---|
| 1284 | + |
---|
| 1285 | + ret = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, |
---|
| 1286 | + &res.seq_res, 0); |
---|
| 1287 | + |
---|
| 1288 | + if (ret >= 0) { |
---|
| 1289 | + ret = res.copied; |
---|
| 1290 | + *cookiep = res.cookie; |
---|
| 1291 | + *eofp = res.eof; |
---|
| 1292 | + } |
---|
| 1293 | + |
---|
| 1294 | +out_free_pages: |
---|
| 1295 | + while (--np >= 0) { |
---|
| 1296 | + if (pages[np]) |
---|
| 1297 | + __free_page(pages[np]); |
---|
| 1298 | + } |
---|
| 1299 | + kfree(pages); |
---|
| 1300 | +out_free_scratch: |
---|
| 1301 | + __free_page(res.scratch); |
---|
| 1302 | +out: |
---|
| 1303 | + return ret; |
---|
| 1304 | + |
---|
| 1305 | +} |
---|
| 1306 | + |
---|
| 1307 | +ssize_t nfs42_proc_getxattr(struct inode *inode, const char *name, |
---|
| 1308 | + void *buf, size_t buflen) |
---|
| 1309 | +{ |
---|
| 1310 | + struct nfs4_exception exception = { }; |
---|
| 1311 | + ssize_t err; |
---|
| 1312 | + |
---|
| 1313 | + do { |
---|
| 1314 | + err = _nfs42_proc_getxattr(inode, name, buf, buflen); |
---|
| 1315 | + if (err >= 0) |
---|
| 1316 | + break; |
---|
| 1317 | + err = nfs4_handle_exception(NFS_SERVER(inode), err, |
---|
| 1318 | + &exception); |
---|
| 1319 | + } while (exception.retry); |
---|
| 1320 | + |
---|
| 1321 | + return err; |
---|
| 1322 | +} |
---|
| 1323 | + |
---|
| 1324 | +int nfs42_proc_setxattr(struct inode *inode, const char *name, |
---|
| 1325 | + const void *buf, size_t buflen, int flags) |
---|
| 1326 | +{ |
---|
| 1327 | + struct nfs4_exception exception = { }; |
---|
| 1328 | + int err; |
---|
| 1329 | + |
---|
| 1330 | + do { |
---|
| 1331 | + err = _nfs42_proc_setxattr(inode, name, buf, buflen, flags); |
---|
| 1332 | + if (!err) |
---|
| 1333 | + break; |
---|
| 1334 | + err = nfs4_handle_exception(NFS_SERVER(inode), err, |
---|
| 1335 | + &exception); |
---|
| 1336 | + } while (exception.retry); |
---|
| 1337 | + |
---|
| 1338 | + return err; |
---|
| 1339 | +} |
---|
| 1340 | + |
---|
| 1341 | +ssize_t nfs42_proc_listxattrs(struct inode *inode, void *buf, |
---|
| 1342 | + size_t buflen, u64 *cookiep, bool *eofp) |
---|
| 1343 | +{ |
---|
| 1344 | + struct nfs4_exception exception = { }; |
---|
| 1345 | + ssize_t err; |
---|
| 1346 | + |
---|
| 1347 | + do { |
---|
| 1348 | + err = _nfs42_proc_listxattrs(inode, buf, buflen, |
---|
| 1349 | + cookiep, eofp); |
---|
| 1350 | + if (err >= 0) |
---|
| 1351 | + break; |
---|
| 1352 | + err = nfs4_handle_exception(NFS_SERVER(inode), err, |
---|
| 1353 | + &exception); |
---|
| 1354 | + } while (exception.retry); |
---|
| 1355 | + |
---|
| 1356 | + return err; |
---|
| 1357 | +} |
---|
| 1358 | + |
---|
| 1359 | +int nfs42_proc_removexattr(struct inode *inode, const char *name) |
---|
| 1360 | +{ |
---|
| 1361 | + struct nfs4_exception exception = { }; |
---|
| 1362 | + int err; |
---|
| 1363 | + |
---|
| 1364 | + do { |
---|
| 1365 | + err = _nfs42_proc_removexattr(inode, name); |
---|
| 1366 | + if (!err) |
---|
| 1367 | + break; |
---|
| 1368 | + err = nfs4_handle_exception(NFS_SERVER(inode), err, |
---|
| 1369 | + &exception); |
---|
| 1370 | + } while (exception.retry); |
---|
| 1371 | + |
---|
| 1372 | + return err; |
---|
| 1373 | +} |
---|