staging: lustre: llite: enforce pool name length limit
authorLi Xi <lixi@ddn.com>
Sun, 18 Sep 2016 20:37:46 +0000 (16:37 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Sep 2016 07:40:36 +0000 (09:40 +0200)
The pool related codes have some inconsistency about the length
of pool name. Creating and setting a pool name of length 16
to a directory will succeed. However, creating a file under
that directory will fail.

This patch disables any pool name which is longer or equal to
16. And it changes LOV_MAXPOOLNAME from 16 to 15 which might
cause some invalid LLOG records of OST pools with 16 byte names.
It is not a problem since invalid LLOG records are just ignored.
And OST pools with 16 byte names won't work well anyway on the
old versions. There will be problem of inconsistency if part of
the servers have this patch and part of the servers don't. But
it would be safe to assume that this is not a normal
configuration.

Signed-off-by: Li Xi <lixi@ddn.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5054
Reviewed-on: http://review.whamcloud.com/10306
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/include/lustre/lustre_idl.h
drivers/staging/lustre/lustre/include/lustre/lustre_user.h
drivers/staging/lustre/lustre/include/lustre_lmv.h
drivers/staging/lustre/lustre/include/obd.h
drivers/staging/lustre/lustre/ptlrpc/wiretest.c

index 6ff6615e7beed604610c40c30353e7bd67fc9615..56b5129eb28cdb6e245ec2c3b65bbf477d514732 100644 (file)
@@ -1620,7 +1620,7 @@ struct lov_mds_md_v3 {        /* LOV EA mds/wire data (little-endian) */
        /* lmm_stripe_count used to be __u32 */
        __u16 lmm_stripe_count;   /* num stripes in use for this object */
        __u16 lmm_layout_gen;     /* layout generation number */
-       char  lmm_pool_name[LOV_MAXPOOLNAME]; /* must be 32bit aligned */
+       char  lmm_pool_name[LOV_MAXPOOLNAME + 1]; /* must be 32bit aligned */
        struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */
 };
 
@@ -2498,7 +2498,7 @@ struct lmv_mds_md_v1 {
        __u32 lmv_padding1;
        __u64 lmv_padding2;
        __u64 lmv_padding3;
-       char lmv_pool_name[LOV_MAXPOOLNAME];    /* pool name */
+       char lmv_pool_name[LOV_MAXPOOLNAME + 1];/* pool name */
        struct lu_fid lmv_stripe_fids[0];       /* FIDs for each stripe */
 };
 
index 5e907afe98d4a241cefad1720c7292a285a8f267..79cd8768b5e1eedc7065dde3668f694093522e12 100644 (file)
@@ -295,8 +295,8 @@ enum ll_lease_type {
 #define LOV_PATTERN_F_HOLE     0x40000000 /* there is hole in LOV EA */
 #define LOV_PATTERN_F_RELEASED 0x80000000 /* HSM released file */
 
-#define LOV_MAXPOOLNAME 16
-#define LOV_POOLNAMEF "%.16s"
+#define LOV_MAXPOOLNAME 15
+#define LOV_POOLNAMEF "%.15s"
 
 #define LOV_MIN_STRIPE_BITS 16   /* maximum PAGE_SIZE (ia64), power of 2 */
 #define LOV_MIN_STRIPE_SIZE (1 << LOV_MIN_STRIPE_BITS)
@@ -354,7 +354,7 @@ struct lov_user_md_v3 {        /* LOV EA user data (host-endian) */
                                           * used when reading
                                           */
        };
-       char  lmm_pool_name[LOV_MAXPOOLNAME]; /* pool name */
+       char  lmm_pool_name[LOV_MAXPOOLNAME + 1];   /* pool name */
        struct lov_user_ost_data_v1 lmm_objects[0]; /* per-stripe data */
 } __packed;
 
@@ -414,7 +414,7 @@ struct lmv_user_md_v1 {
        __u32   lum_padding1;
        __u32   lum_padding2;
        __u32   lum_padding3;
-       char    lum_pool_name[LOV_MAXPOOLNAME];
+       char    lum_pool_name[LOV_MAXPOOLNAME + 1];
        struct  lmv_user_mds_data  lum_objects[0];
 } __packed;
 
index 5a2fc3054d94fa678dc1debb35c33575a0cfa68b..388161ea0bd67f6cbb72c956cf2b3f9448c12267 100644 (file)
@@ -48,7 +48,7 @@ struct lmv_stripe_md {
        __u32   lsm_md_layout_version;
        __u32   lsm_md_default_count;
        __u32   lsm_md_default_index;
-       char    lsm_md_pool_name[LOV_MAXPOOLNAME];
+       char    lsm_md_pool_name[LOV_MAXPOOLNAME + 1];
        struct lmv_oinfo lsm_md_oinfo[0];
 };
 
index b84600a28daabc8c1bc9c5224285e47fad08912a..1c884c00d6f76e7e4e20b2cfdd9615abb2192b56 100644 (file)
@@ -99,7 +99,7 @@ struct lov_stripe_md {
                __u32 lw_pattern;         /* striping pattern (RAID0, RAID1) */
                __u16 lw_stripe_count;  /* number of objects being striped over */
                __u16 lw_layout_gen;       /* generation of the layout */
-               char  lw_pool_name[LOV_MAXPOOLNAME]; /* pool name */
+               char  lw_pool_name[LOV_MAXPOOLNAME + 1]; /* pool name */
        } lsm_wire;
 
        struct lov_oinfo *lsm_oinfo[0];
index 2390255f82f260627924e07d7a34e81fc57e93dc..b33fd7ba689610a860d4ac7043412e4090cf9227 100644 (file)
@@ -1383,7 +1383,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_layout_gen));
        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_layout_gen) == 2, "found %lld\n",
                 (long long)(int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_layout_gen));
-       CLASSERT(LOV_MAXPOOLNAME == 16);
+       CLASSERT(LOV_MAXPOOLNAME == 15);
        LASSERTF((int)offsetof(struct lov_mds_md_v3, lmm_pool_name[16]) == 48, "found %lld\n",
                 (long long)(int)offsetof(struct lov_mds_md_v3, lmm_pool_name[16]));
        LASSERTF((int)sizeof(((struct lov_mds_md_v3 *)0)->lmm_pool_name[16]) == 1, "found %lld\n",