Skip to content

Commit a35eca9

Browse files
gregsfortytwoliewegas
authored andcommitted
ceph: let the set_layout ioctl set single traits
Previously we were validating the passed-in stripe unit, object size, and stripe count against each other (and not testing most other stuff). Instead, make sure that the composed previous layout and new values are valid, and only send the new values to the MDS. This lets users change the pool without setting the whole layout, for instance. Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
1 parent 83eaea2 commit a35eca9

1 file changed

Lines changed: 28 additions & 6 deletions

File tree

‎fs/ceph/ioctl.c‎

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,39 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
4242
struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
4343
struct ceph_mds_request *req;
4444
struct ceph_ioctl_layout l;
45+
struct ceph_inode_info *ci = ceph_inode(file->f_dentry->d_inode);
46+
struct ceph_ioctl_layout nl;
4547
int err, i;
4648

47-
/* copy and validate */
4849
if (copy_from_user(&l, arg, sizeof(l)))
4950
return -EFAULT;
5051

51-
if ((l.object_size & ~PAGE_MASK) ||
52-
(l.stripe_unit & ~PAGE_MASK) ||
53-
!l.stripe_unit ||
54-
(l.object_size &&
55-
(unsigned)l.object_size % (unsigned)l.stripe_unit))
52+
/* validate changed params against current layout */
53+
err = ceph_do_getattr(file->f_dentry->d_inode, CEPH_STAT_CAP_LAYOUT);
54+
if (!err) {
55+
nl.stripe_unit = ceph_file_layout_su(ci->i_layout);
56+
nl.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
57+
nl.object_size = ceph_file_layout_object_size(ci->i_layout);
58+
nl.data_pool = le32_to_cpu(ci->i_layout.fl_pg_pool);
59+
nl.preferred_osd =
60+
(s32)le32_to_cpu(ci->i_layout.fl_pg_preferred);
61+
} else
62+
return err;
63+
64+
if (l.stripe_count)
65+
nl.stripe_count = l.stripe_count;
66+
if (l.stripe_unit)
67+
nl.stripe_unit = l.stripe_unit;
68+
if (l.object_size)
69+
nl.object_size = l.object_size;
70+
if (l.data_pool)
71+
nl.data_pool = l.data_pool;
72+
if (l.preferred_osd)
73+
nl.preferred_osd = l.preferred_osd;
74+
75+
if ((nl.object_size & ~PAGE_MASK) ||
76+
(nl.stripe_unit & ~PAGE_MASK) ||
77+
((unsigned)nl.object_size % (unsigned)nl.stripe_unit))
5678
return -EINVAL;
5779

5880
/* make sure it's a valid data pool */

0 commit comments

Comments
 (0)