diff options
| author | Alexandros Batsakis <batsakis@netapp.com> | 2011-01-06 06:36:31 -0500 |
|---|---|---|
| committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2011-01-06 14:46:32 -0500 |
| commit | 36840370845629e6cb4324d1dd4aff6778670503 (patch) | |
| tree | b295dba561cefecd6845c4402a52df5f7894f520 | |
| parent | 43f1b3da8b35d706d6c47880fc211d2519b4a587 (diff) | |
pnfs: update nfs4_callback_recallany to handle layouts
While here, update the code a bit.
Signed-off-by: Alexandros Batsakis <batsakis@netapp.com>
Signed-off-by: Fred Isaman <iisaman@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
| -rw-r--r-- | fs/nfs/callback.h | 8 | ||||
| -rw-r--r-- | fs/nfs/callback_proc.c | 29 |
2 files changed, 34 insertions, 3 deletions
diff --git a/fs/nfs/callback.h b/fs/nfs/callback.h index f6768ac09190..d3b44f9bd747 100644 --- a/fs/nfs/callback.h +++ b/fs/nfs/callback.h | |||
| @@ -119,6 +119,14 @@ extern int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, | |||
| 119 | 119 | ||
| 120 | #define RCA4_TYPE_MASK_RDATA_DLG 0 | 120 | #define RCA4_TYPE_MASK_RDATA_DLG 0 |
| 121 | #define RCA4_TYPE_MASK_WDATA_DLG 1 | 121 | #define RCA4_TYPE_MASK_WDATA_DLG 1 |
| 122 | #define RCA4_TYPE_MASK_DIR_DLG 2 | ||
| 123 | #define RCA4_TYPE_MASK_FILE_LAYOUT 3 | ||
| 124 | #define RCA4_TYPE_MASK_BLK_LAYOUT 4 | ||
| 125 | #define RCA4_TYPE_MASK_OBJ_LAYOUT_MIN 8 | ||
| 126 | #define RCA4_TYPE_MASK_OBJ_LAYOUT_MAX 9 | ||
| 127 | #define RCA4_TYPE_MASK_OTHER_LAYOUT_MIN 12 | ||
| 128 | #define RCA4_TYPE_MASK_OTHER_LAYOUT_MAX 15 | ||
| 129 | #define RCA4_TYPE_MASK_ALL 0xf31f | ||
| 122 | 130 | ||
| 123 | struct cb_recallanyargs { | 131 | struct cb_recallanyargs { |
| 124 | struct sockaddr *craa_addr; | 132 | struct sockaddr *craa_addr; |
diff --git a/fs/nfs/callback_proc.c b/fs/nfs/callback_proc.c index 6619c05b55a0..4bb91cb2620d 100644 --- a/fs/nfs/callback_proc.c +++ b/fs/nfs/callback_proc.c | |||
| @@ -230,6 +230,17 @@ __be32 nfs4_callback_layoutrecall(struct cb_layoutrecallargs *args, | |||
| 230 | return cpu_to_be32(res); | 230 | return cpu_to_be32(res); |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | static void pnfs_recall_all_layouts(struct nfs_client *clp) | ||
| 234 | { | ||
| 235 | struct cb_layoutrecallargs args; | ||
| 236 | |||
| 237 | /* Pretend we got a CB_LAYOUTRECALL(ALL) */ | ||
| 238 | memset(&args, 0, sizeof(args)); | ||
| 239 | args.cbl_recall_type = RETURN_ALL; | ||
| 240 | /* FIXME we ignore errors, what should we do? */ | ||
| 241 | do_callback_layoutrecall(clp, &args); | ||
| 242 | } | ||
| 243 | |||
| 233 | int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid) | 244 | int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, const nfs4_stateid *stateid) |
| 234 | { | 245 | { |
| 235 | if (delegation == NULL) | 246 | if (delegation == NULL) |
| @@ -421,29 +432,41 @@ out: | |||
| 421 | return status; | 432 | return status; |
| 422 | } | 433 | } |
| 423 | 434 | ||
| 435 | static bool | ||
| 436 | validate_bitmap_values(unsigned long mask) | ||
| 437 | { | ||
| 438 | return (mask & ~RCA4_TYPE_MASK_ALL) == 0; | ||
| 439 | } | ||
| 440 | |||
| 424 | __be32 nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy, | 441 | __be32 nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy, |
| 425 | struct cb_process_state *cps) | 442 | struct cb_process_state *cps) |
| 426 | { | 443 | { |
| 427 | __be32 status; | 444 | __be32 status; |
| 428 | fmode_t flags = 0; | 445 | fmode_t flags = 0; |
| 429 | 446 | ||
| 430 | status = htonl(NFS4ERR_OP_NOT_IN_SESSION); | 447 | status = cpu_to_be32(NFS4ERR_OP_NOT_IN_SESSION); |
| 431 | if (!cps->clp) /* set in cb_sequence */ | 448 | if (!cps->clp) /* set in cb_sequence */ |
| 432 | goto out; | 449 | goto out; |
| 433 | 450 | ||
| 434 | dprintk("NFS: RECALL_ANY callback request from %s\n", | 451 | dprintk("NFS: RECALL_ANY callback request from %s\n", |
| 435 | rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR)); | 452 | rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR)); |
| 436 | 453 | ||
| 454 | status = cpu_to_be32(NFS4ERR_INVAL); | ||
| 455 | if (!validate_bitmap_values(args->craa_type_mask)) | ||
| 456 | goto out; | ||
| 457 | |||
| 458 | status = cpu_to_be32(NFS4_OK); | ||
| 437 | if (test_bit(RCA4_TYPE_MASK_RDATA_DLG, (const unsigned long *) | 459 | if (test_bit(RCA4_TYPE_MASK_RDATA_DLG, (const unsigned long *) |
| 438 | &args->craa_type_mask)) | 460 | &args->craa_type_mask)) |
| 439 | flags = FMODE_READ; | 461 | flags = FMODE_READ; |
| 440 | if (test_bit(RCA4_TYPE_MASK_WDATA_DLG, (const unsigned long *) | 462 | if (test_bit(RCA4_TYPE_MASK_WDATA_DLG, (const unsigned long *) |
| 441 | &args->craa_type_mask)) | 463 | &args->craa_type_mask)) |
| 442 | flags |= FMODE_WRITE; | 464 | flags |= FMODE_WRITE; |
| 443 | 465 | if (test_bit(RCA4_TYPE_MASK_FILE_LAYOUT, (const unsigned long *) | |
| 466 | &args->craa_type_mask)) | ||
| 467 | pnfs_recall_all_layouts(cps->clp); | ||
| 444 | if (flags) | 468 | if (flags) |
| 445 | nfs_expire_all_delegation_types(cps->clp, flags); | 469 | nfs_expire_all_delegation_types(cps->clp, flags); |
| 446 | status = htonl(NFS4_OK); | ||
| 447 | out: | 470 | out: |
| 448 | dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); | 471 | dprintk("%s: exit with status = %d\n", __func__, ntohl(status)); |
| 449 | return status; | 472 | return status; |
