Skip to content

Commit 21b27a7

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client
Pull ceph fix from Sage Weil: "This is a final commit we missed to align the protocol compatibility with the feature bits. It decodes a few extra fields in two different messages and reports EIO when they are used (not yet supported)" * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/sage/ceph-client: ceph: initial CEPH_FEATURE_FS_FILE_LAYOUT_V2 support
2 parents a58b9ad + 5ea5c5e commit 21b27a7

File tree

7 files changed

+49
-3
lines changed

7 files changed

+49
-3
lines changed

fs/ceph/addr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,6 +1756,10 @@ int ceph_pool_perm_check(struct ceph_inode_info *ci, int need)
17561756
u32 pool;
17571757
int ret, flags;
17581758

1759+
/* does not support pool namespace yet */
1760+
if (ci->i_pool_ns_len)
1761+
return -EIO;
1762+
17591763
if (ceph_test_mount_opt(ceph_inode_to_client(&ci->vfs_inode),
17601764
NOPOOLPERM))
17611765
return 0;

fs/ceph/caps.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2753,7 +2753,8 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
27532753
void *inline_data, int inline_len,
27542754
struct ceph_buffer *xattr_buf,
27552755
struct ceph_mds_session *session,
2756-
struct ceph_cap *cap, int issued)
2756+
struct ceph_cap *cap, int issued,
2757+
u32 pool_ns_len)
27572758
__releases(ci->i_ceph_lock)
27582759
__releases(mdsc->snap_rwsem)
27592760
{
@@ -2873,6 +2874,8 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
28732874
if (newcaps & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)) {
28742875
/* file layout may have changed */
28752876
ci->i_layout = grant->layout;
2877+
ci->i_pool_ns_len = pool_ns_len;
2878+
28762879
/* size/truncate_seq? */
28772880
queue_trunc = ceph_fill_file_size(inode, issued,
28782881
le32_to_cpu(grant->truncate_seq),
@@ -3411,6 +3414,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
34113414
u32 inline_len = 0;
34123415
void *snaptrace;
34133416
size_t snaptrace_len;
3417+
u32 pool_ns_len = 0;
34143418
void *p, *end;
34153419

34163420
dout("handle_caps from mds%d\n", mds);
@@ -3463,6 +3467,21 @@ void ceph_handle_caps(struct ceph_mds_session *session,
34633467
p += inline_len;
34643468
}
34653469

3470+
if (le16_to_cpu(msg->hdr.version) >= 8) {
3471+
u64 flush_tid;
3472+
u32 caller_uid, caller_gid;
3473+
u32 osd_epoch_barrier;
3474+
/* version >= 5 */
3475+
ceph_decode_32_safe(&p, end, osd_epoch_barrier, bad);
3476+
/* version >= 6 */
3477+
ceph_decode_64_safe(&p, end, flush_tid, bad);
3478+
/* version >= 7 */
3479+
ceph_decode_32_safe(&p, end, caller_uid, bad);
3480+
ceph_decode_32_safe(&p, end, caller_gid, bad);
3481+
/* version >= 8 */
3482+
ceph_decode_32_safe(&p, end, pool_ns_len, bad);
3483+
}
3484+
34663485
/* lookup ino */
34673486
inode = ceph_find_inode(sb, vino);
34683487
ci = ceph_inode(inode);
@@ -3518,7 +3537,8 @@ void ceph_handle_caps(struct ceph_mds_session *session,
35183537
&cap, &issued);
35193538
handle_cap_grant(mdsc, inode, h,
35203539
inline_version, inline_data, inline_len,
3521-
msg->middle, session, cap, issued);
3540+
msg->middle, session, cap, issued,
3541+
pool_ns_len);
35223542
if (realm)
35233543
ceph_put_snap_realm(mdsc, realm);
35243544
goto done_unlocked;
@@ -3542,7 +3562,8 @@ void ceph_handle_caps(struct ceph_mds_session *session,
35423562
issued |= __ceph_caps_dirty(ci);
35433563
handle_cap_grant(mdsc, inode, h,
35443564
inline_version, inline_data, inline_len,
3545-
msg->middle, session, cap, issued);
3565+
msg->middle, session, cap, issued,
3566+
pool_ns_len);
35463567
goto done_unlocked;
35473568

35483569
case CEPH_CAP_OP_FLUSH_ACK:

fs/ceph/inode.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ struct inode *ceph_alloc_inode(struct super_block *sb)
396396
ci->i_symlink = NULL;
397397

398398
memset(&ci->i_dir_layout, 0, sizeof(ci->i_dir_layout));
399+
ci->i_pool_ns_len = 0;
399400

400401
ci->i_fragtree = RB_ROOT;
401402
mutex_init(&ci->i_fragtree_mutex);
@@ -756,6 +757,7 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
756757
if (ci->i_layout.fl_pg_pool != info->layout.fl_pg_pool)
757758
ci->i_ceph_flags &= ~CEPH_I_POOL_PERM;
758759
ci->i_layout = info->layout;
760+
ci->i_pool_ns_len = iinfo->pool_ns_len;
759761

760762
queue_trunc = ceph_fill_file_size(inode, issued,
761763
le32_to_cpu(info->truncate_seq),

fs/ceph/mds_client.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,14 @@ static int parse_reply_info_in(void **p, void *end,
100100
} else
101101
info->inline_version = CEPH_INLINE_NONE;
102102

103+
if (features & CEPH_FEATURE_FS_FILE_LAYOUT_V2) {
104+
ceph_decode_32_safe(p, end, info->pool_ns_len, bad);
105+
ceph_decode_need(p, end, info->pool_ns_len, bad);
106+
*p += info->pool_ns_len;
107+
} else {
108+
info->pool_ns_len = 0;
109+
}
110+
103111
return 0;
104112
bad:
105113
return err;
@@ -2298,6 +2306,14 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
22982306
ceph_get_cap_refs(ceph_inode(req->r_old_dentry_dir),
22992307
CEPH_CAP_PIN);
23002308

2309+
/* deny access to directories with pool_ns layouts */
2310+
if (req->r_inode && S_ISDIR(req->r_inode->i_mode) &&
2311+
ceph_inode(req->r_inode)->i_pool_ns_len)
2312+
return -EIO;
2313+
if (req->r_locked_dir &&
2314+
ceph_inode(req->r_locked_dir)->i_pool_ns_len)
2315+
return -EIO;
2316+
23012317
/* issue */
23022318
mutex_lock(&mdsc->mutex);
23032319
__register_request(mdsc, req, dir);

fs/ceph/mds_client.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ struct ceph_mds_reply_info_in {
4444
u64 inline_version;
4545
u32 inline_len;
4646
char *inline_data;
47+
u32 pool_ns_len;
4748
};
4849

4950
/*

fs/ceph/super.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ struct ceph_inode_info {
287287

288288
struct ceph_dir_layout i_dir_layout;
289289
struct ceph_file_layout i_layout;
290+
size_t i_pool_ns_len;
290291
char *i_symlink;
291292

292293
/* for dirs */

include/linux/ceph/ceph_features.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#define CEPH_FEATURE_CRUSH_TUNABLES5 (1ULL<<58) /* chooseleaf stable mode */
7676
// duplicated since it was introduced at the same time as CEPH_FEATURE_CRUSH_TUNABLES5
7777
#define CEPH_FEATURE_NEW_OSDOPREPLY_ENCODING (1ULL<<58) /* New, v7 encoding */
78+
#define CEPH_FEATURE_FS_FILE_LAYOUT_V2 (1ULL<<58) /* file_layout_t */
7879

7980
/*
8081
* The introduction of CEPH_FEATURE_OSD_SNAPMAPPER caused the feature

0 commit comments

Comments
 (0)