]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
ceph: fully initialize new layout
authorSage Weil <sage@inktank.com>
Mon, 14 May 2012 19:34:38 +0000 (12:34 -0700)
committerAlex Elder <elder@dreamhost.com>
Wed, 16 May 2012 19:28:27 +0000 (14:28 -0500)
When we are setting a new layout, fully initialize the structure:
 - zero it out
 - always set preferred_osd to -1

Signed-off-by: Sage Weil <sage@inktank.com>
Reviewed-by: Alex Elder <elder@inktank.com>
fs/ceph/ioctl.c
fs/ceph/ioctl.h

index 0e2f021109eed3321ae2ab0f93df972317b4301e..c0b7314b90f9f0ffde96281def0c4afe5749a10b 100644 (file)
@@ -80,22 +80,29 @@ static long ceph_ioctl_set_layout(struct file *file, void __user *arg)
 
        /* validate changed params against current layout */
        err = ceph_do_getattr(file->f_dentry->d_inode, CEPH_STAT_CAP_LAYOUT);
-       if (!err) {
-               nl.stripe_unit = ceph_file_layout_su(ci->i_layout);
-               nl.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
-               nl.object_size = ceph_file_layout_object_size(ci->i_layout);
-               nl.data_pool = le32_to_cpu(ci->i_layout.fl_pg_pool);
-       } else
+       if (err)
                return err;
 
+       memset(&nl, 0, sizeof(nl));
        if (l.stripe_count)
                nl.stripe_count = l.stripe_count;
+       else
+               nl.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);
        if (l.stripe_unit)
                nl.stripe_unit = l.stripe_unit;
+       else
+               nl.stripe_unit = ceph_file_layout_su(ci->i_layout);
        if (l.object_size)
                nl.object_size = l.object_size;
+       else
+               nl.object_size = ceph_file_layout_object_size(ci->i_layout);
        if (l.data_pool)
                nl.data_pool = l.data_pool;
+       else
+               nl.data_pool = ceph_file_layout_pg_pool(ci->i_layout);
+
+       /* this is obsolete, and always -1 */
+       nl.preferred_osd = le64_to_cpu(-1);
 
        err = __validate_layout(mdsc, &nl);
        if (err)
index be4a604873331dc7c547950650a899b514f56d26..c77028afb1e1e6b52315a73d013a26fb5c9c7f5b 100644 (file)
@@ -34,6 +34,8 @@
 struct ceph_ioctl_layout {
        __u64 stripe_unit, stripe_count, object_size;
        __u64 data_pool;
+
+       /* obsolete.  new values ignored, always return -1 */
        __s64 preferred_osd;
 };