summaryrefslogtreecommitdiffstats
path: root/fs/ceph/caps.c
diff options
context:
space:
mode:
authorYan, Zheng <zheng.z.yan@intel.com>2014-04-16 20:55:50 -0400
committerYan, Zheng <zheng.z.yan@intel.com>2014-06-05 21:29:52 -0400
commitf98a128a55ff85d0087de89f304f10bd75e792aa (patch)
treebdaa64075f36354d7f221a8b7d93fbc4bdb8f322 /fs/ceph/caps.c
parent461f758ac0bad40fe8e0959f415dae38efa16c12 (diff)
ceph: update inode fields according to issued caps
Cap message and request reply from non-auth MDS may carry stale information (corresponding locks are in LOCK states) even they have the newest inode version. So client should update inode fields according to issued caps. Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r--fs/ceph/caps.c58
1 files changed, 32 insertions, 26 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index de39a03f5b71..5f6d24ede794 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2476,7 +2476,8 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2476 2476
2477 __check_cap_issue(ci, cap, newcaps); 2477 __check_cap_issue(ci, cap, newcaps);
2478 2478
2479 if ((issued & CEPH_CAP_AUTH_EXCL) == 0) { 2479 if ((newcaps & CEPH_CAP_AUTH_SHARED) &&
2480 (issued & CEPH_CAP_AUTH_EXCL) == 0) {
2480 inode->i_mode = le32_to_cpu(grant->mode); 2481 inode->i_mode = le32_to_cpu(grant->mode);
2481 inode->i_uid = make_kuid(&init_user_ns, le32_to_cpu(grant->uid)); 2482 inode->i_uid = make_kuid(&init_user_ns, le32_to_cpu(grant->uid));
2482 inode->i_gid = make_kgid(&init_user_ns, le32_to_cpu(grant->gid)); 2483 inode->i_gid = make_kgid(&init_user_ns, le32_to_cpu(grant->gid));
@@ -2485,7 +2486,8 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2485 from_kgid(&init_user_ns, inode->i_gid)); 2486 from_kgid(&init_user_ns, inode->i_gid));
2486 } 2487 }
2487 2488
2488 if ((issued & CEPH_CAP_LINK_EXCL) == 0) { 2489 if ((newcaps & CEPH_CAP_AUTH_SHARED) &&
2490 (issued & CEPH_CAP_LINK_EXCL) == 0) {
2489 set_nlink(inode, le32_to_cpu(grant->nlink)); 2491 set_nlink(inode, le32_to_cpu(grant->nlink));
2490 if (inode->i_nlink == 0 && 2492 if (inode->i_nlink == 0 &&
2491 (newcaps & (CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL))) 2493 (newcaps & (CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL)))
@@ -2512,31 +2514,35 @@ static void handle_cap_grant(struct inode *inode, struct ceph_mds_caps *grant,
2512 if ((issued & CEPH_CAP_FILE_CACHE) && ci->i_rdcache_gen > 1) 2514 if ((issued & CEPH_CAP_FILE_CACHE) && ci->i_rdcache_gen > 1)
2513 queue_revalidate = 1; 2515 queue_revalidate = 1;
2514 2516
2515 /* size/ctime/mtime/atime? */ 2517 if (newcaps & CEPH_CAP_ANY_RD) {
2516 queue_trunc = ceph_fill_file_size(inode, issued, 2518 /* ctime/mtime/atime? */
2517 le32_to_cpu(grant->truncate_seq), 2519 ceph_decode_timespec(&mtime, &grant->mtime);
2518 le64_to_cpu(grant->truncate_size), 2520 ceph_decode_timespec(&atime, &grant->atime);
2519 size); 2521 ceph_decode_timespec(&ctime, &grant->ctime);
2520 ceph_decode_timespec(&mtime, &grant->mtime); 2522 ceph_fill_file_time(inode, issued,
2521 ceph_decode_timespec(&atime, &grant->atime); 2523 le32_to_cpu(grant->time_warp_seq),
2522 ceph_decode_timespec(&ctime, &grant->ctime); 2524 &ctime, &mtime, &atime);
2523 ceph_fill_file_time(inode, issued, 2525 }
2524 le32_to_cpu(grant->time_warp_seq), &ctime, &mtime, 2526
2525 &atime); 2527 if (newcaps & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)) {
2526 2528 /* file layout may have changed */
2527 2529 ci->i_layout = grant->layout;
2528 /* file layout may have changed */ 2530 /* size/truncate_seq? */
2529 ci->i_layout = grant->layout; 2531 queue_trunc = ceph_fill_file_size(inode, issued,
2530 2532 le32_to_cpu(grant->truncate_seq),
2531 /* max size increase? */ 2533 le64_to_cpu(grant->truncate_size),
2532 if (ci->i_auth_cap == cap && max_size != ci->i_max_size) { 2534 size);
2533 dout("max_size %lld -> %llu\n", ci->i_max_size, max_size); 2535 /* max size increase? */
2534 ci->i_max_size = max_size; 2536 if (ci->i_auth_cap == cap && max_size != ci->i_max_size) {
2535 if (max_size >= ci->i_wanted_max_size) { 2537 dout("max_size %lld -> %llu\n",
2536 ci->i_wanted_max_size = 0; /* reset */ 2538 ci->i_max_size, max_size);
2537 ci->i_requested_max_size = 0; 2539 ci->i_max_size = max_size;
2540 if (max_size >= ci->i_wanted_max_size) {
2541 ci->i_wanted_max_size = 0; /* reset */
2542 ci->i_requested_max_size = 0;
2543 }
2544 wake = 1;
2538 } 2545 }
2539 wake = 1;
2540 } 2546 }
2541 2547
2542 /* check cap bits */ 2548 /* check cap bits */