summaryrefslogtreecommitdiffstats
path: root/fs/ceph/caps.c
diff options
context:
space:
mode:
authorYan, Zheng <zyan@redhat.com>2016-03-06 20:35:06 -0500
committerIlya Dryomov <idryomov@gmail.com>2016-07-27 20:55:38 -0400
commit779fe0fb8e1883d5c479ac6bd85fbd237deed1f7 (patch)
treece9876a5f4201a7aa9f2daef838ccf7ff1827128 /fs/ceph/caps.c
parentcd08e0a274ba6215b79c83809b331e8af17196ba (diff)
ceph: rados pool namespace support
This patch adds codes that decode pool namespace information in cap message and request reply. Pool namespace is saved in i_layout, it will be passed to libceph when doing read/write. Signed-off-by: Yan, Zheng <zyan@redhat.com>
Diffstat (limited to 'fs/ceph/caps.c')
-rw-r--r--fs/ceph/caps.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index f24722dce167..0a9406a8a794 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2779,12 +2779,11 @@ static void invalidate_aliases(struct inode *inode)
2779 */ 2779 */
2780static void handle_cap_grant(struct ceph_mds_client *mdsc, 2780static void handle_cap_grant(struct ceph_mds_client *mdsc,
2781 struct inode *inode, struct ceph_mds_caps *grant, 2781 struct inode *inode, struct ceph_mds_caps *grant,
2782 u64 inline_version, 2782 struct ceph_string **pns, u64 inline_version,
2783 void *inline_data, int inline_len, 2783 void *inline_data, u32 inline_len,
2784 struct ceph_buffer *xattr_buf, 2784 struct ceph_buffer *xattr_buf,
2785 struct ceph_mds_session *session, 2785 struct ceph_mds_session *session,
2786 struct ceph_cap *cap, int issued, 2786 struct ceph_cap *cap, int issued)
2787 u32 pool_ns_len)
2788 __releases(ci->i_ceph_lock) 2787 __releases(ci->i_ceph_lock)
2789 __releases(mdsc->snap_rwsem) 2788 __releases(mdsc->snap_rwsem)
2790{ 2789{
@@ -2896,11 +2895,18 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
2896 if (newcaps & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)) { 2895 if (newcaps & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)) {
2897 /* file layout may have changed */ 2896 /* file layout may have changed */
2898 s64 old_pool = ci->i_layout.pool_id; 2897 s64 old_pool = ci->i_layout.pool_id;
2898 struct ceph_string *old_ns;
2899
2899 ceph_file_layout_from_legacy(&ci->i_layout, &grant->layout); 2900 ceph_file_layout_from_legacy(&ci->i_layout, &grant->layout);
2900 ci->i_pool_ns_len = pool_ns_len; 2901 old_ns = rcu_dereference_protected(ci->i_layout.pool_ns,
2901 if (ci->i_layout.pool_id != old_pool) 2902 lockdep_is_held(&ci->i_ceph_lock));
2903 rcu_assign_pointer(ci->i_layout.pool_ns, *pns);
2904
2905 if (ci->i_layout.pool_id != old_pool || *pns != old_ns)
2902 ci->i_ceph_flags &= ~CEPH_I_POOL_PERM; 2906 ci->i_ceph_flags &= ~CEPH_I_POOL_PERM;
2903 2907
2908 *pns = old_ns;
2909
2904 /* size/truncate_seq? */ 2910 /* size/truncate_seq? */
2905 queue_trunc = ceph_fill_file_size(inode, issued, 2911 queue_trunc = ceph_fill_file_size(inode, issued,
2906 le32_to_cpu(grant->truncate_seq), 2912 le32_to_cpu(grant->truncate_seq),
@@ -3423,20 +3429,18 @@ void ceph_handle_caps(struct ceph_mds_session *session,
3423 struct ceph_cap *cap; 3429 struct ceph_cap *cap;
3424 struct ceph_mds_caps *h; 3430 struct ceph_mds_caps *h;
3425 struct ceph_mds_cap_peer *peer = NULL; 3431 struct ceph_mds_cap_peer *peer = NULL;
3426 struct ceph_snap_realm *realm; 3432 struct ceph_snap_realm *realm = NULL;
3433 struct ceph_string *pool_ns = NULL;
3427 int mds = session->s_mds; 3434 int mds = session->s_mds;
3428 int op, issued; 3435 int op, issued;
3429 u32 seq, mseq; 3436 u32 seq, mseq;
3430 struct ceph_vino vino; 3437 struct ceph_vino vino;
3431 u64 cap_id;
3432 u64 size, max_size;
3433 u64 tid; 3438 u64 tid;
3434 u64 inline_version = 0; 3439 u64 inline_version = 0;
3435 void *inline_data = NULL; 3440 void *inline_data = NULL;
3436 u32 inline_len = 0; 3441 u32 inline_len = 0;
3437 void *snaptrace; 3442 void *snaptrace;
3438 size_t snaptrace_len; 3443 size_t snaptrace_len;
3439 u32 pool_ns_len = 0;
3440 void *p, *end; 3444 void *p, *end;
3441 3445
3442 dout("handle_caps from mds%d\n", mds); 3446 dout("handle_caps from mds%d\n", mds);
@@ -3450,11 +3454,8 @@ void ceph_handle_caps(struct ceph_mds_session *session,
3450 op = le32_to_cpu(h->op); 3454 op = le32_to_cpu(h->op);
3451 vino.ino = le64_to_cpu(h->ino); 3455 vino.ino = le64_to_cpu(h->ino);
3452 vino.snap = CEPH_NOSNAP; 3456 vino.snap = CEPH_NOSNAP;
3453 cap_id = le64_to_cpu(h->cap_id);
3454 seq = le32_to_cpu(h->seq); 3457 seq = le32_to_cpu(h->seq);
3455 mseq = le32_to_cpu(h->migrate_seq); 3458 mseq = le32_to_cpu(h->migrate_seq);
3456 size = le64_to_cpu(h->size);
3457 max_size = le64_to_cpu(h->max_size);
3458 3459
3459 snaptrace = h + 1; 3460 snaptrace = h + 1;
3460 snaptrace_len = le32_to_cpu(h->snap_trace_len); 3461 snaptrace_len = le32_to_cpu(h->snap_trace_len);
@@ -3493,6 +3494,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
3493 u64 flush_tid; 3494 u64 flush_tid;
3494 u32 caller_uid, caller_gid; 3495 u32 caller_uid, caller_gid;
3495 u32 osd_epoch_barrier; 3496 u32 osd_epoch_barrier;
3497 u32 pool_ns_len;
3496 /* version >= 5 */ 3498 /* version >= 5 */
3497 ceph_decode_32_safe(&p, end, osd_epoch_barrier, bad); 3499 ceph_decode_32_safe(&p, end, osd_epoch_barrier, bad);
3498 /* version >= 6 */ 3500 /* version >= 6 */
@@ -3502,6 +3504,11 @@ void ceph_handle_caps(struct ceph_mds_session *session,
3502 ceph_decode_32_safe(&p, end, caller_gid, bad); 3504 ceph_decode_32_safe(&p, end, caller_gid, bad);
3503 /* version >= 8 */ 3505 /* version >= 8 */
3504 ceph_decode_32_safe(&p, end, pool_ns_len, bad); 3506 ceph_decode_32_safe(&p, end, pool_ns_len, bad);
3507 if (pool_ns_len > 0) {
3508 ceph_decode_need(&p, end, pool_ns_len, bad);
3509 pool_ns = ceph_find_or_create_string(p, pool_ns_len);
3510 p += pool_ns_len;
3511 }
3505 } 3512 }
3506 3513
3507 /* lookup ino */ 3514 /* lookup ino */
@@ -3522,7 +3529,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
3522 cap = ceph_get_cap(mdsc, NULL); 3529 cap = ceph_get_cap(mdsc, NULL);
3523 cap->cap_ino = vino.ino; 3530 cap->cap_ino = vino.ino;
3524 cap->queue_release = 1; 3531 cap->queue_release = 1;
3525 cap->cap_id = cap_id; 3532 cap->cap_id = le64_to_cpu(h->cap_id);
3526 cap->mseq = mseq; 3533 cap->mseq = mseq;
3527 cap->seq = seq; 3534 cap->seq = seq;
3528 spin_lock(&session->s_cap_lock); 3535 spin_lock(&session->s_cap_lock);
@@ -3557,10 +3564,9 @@ void ceph_handle_caps(struct ceph_mds_session *session,
3557 } 3564 }
3558 handle_cap_import(mdsc, inode, h, peer, session, 3565 handle_cap_import(mdsc, inode, h, peer, session,
3559 &cap, &issued); 3566 &cap, &issued);
3560 handle_cap_grant(mdsc, inode, h, 3567 handle_cap_grant(mdsc, inode, h, &pool_ns,
3561 inline_version, inline_data, inline_len, 3568 inline_version, inline_data, inline_len,
3562 msg->middle, session, cap, issued, 3569 msg->middle, session, cap, issued);
3563 pool_ns_len);
3564 if (realm) 3570 if (realm)
3565 ceph_put_snap_realm(mdsc, realm); 3571 ceph_put_snap_realm(mdsc, realm);
3566 goto done_unlocked; 3572 goto done_unlocked;
@@ -3582,10 +3588,9 @@ void ceph_handle_caps(struct ceph_mds_session *session,
3582 case CEPH_CAP_OP_GRANT: 3588 case CEPH_CAP_OP_GRANT:
3583 __ceph_caps_issued(ci, &issued); 3589 __ceph_caps_issued(ci, &issued);
3584 issued |= __ceph_caps_dirty(ci); 3590 issued |= __ceph_caps_dirty(ci);
3585 handle_cap_grant(mdsc, inode, h, 3591 handle_cap_grant(mdsc, inode, h, &pool_ns,
3586 inline_version, inline_data, inline_len, 3592 inline_version, inline_data, inline_len,
3587 msg->middle, session, cap, issued, 3593 msg->middle, session, cap, issued);
3588 pool_ns_len);
3589 goto done_unlocked; 3594 goto done_unlocked;
3590 3595
3591 case CEPH_CAP_OP_FLUSH_ACK: 3596 case CEPH_CAP_OP_FLUSH_ACK:
@@ -3616,6 +3621,7 @@ done:
3616 mutex_unlock(&session->s_mutex); 3621 mutex_unlock(&session->s_mutex);
3617done_unlocked: 3622done_unlocked:
3618 iput(inode); 3623 iput(inode);
3624 ceph_put_string(pool_ns);
3619 return; 3625 return;
3620 3626
3621bad: 3627bad: