Whamcloud - gitweb
LU-13260 lov: fix size check when stripe is zero 48/38048/2
authorYang Sheng <ys@whamcloud.com>
Wed, 19 Feb 2020 11:08:33 +0000 (19:08 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 6 Apr 2020 21:17:00 +0000 (21:17 +0000)
Set correct max size while stripe is zero.

Lustre-change: https://review.whamcloud.com/37623
Lustre-commit: fe57ce6adf1a00e14269b230d07a4548a58d77c3

Fixes: f3f6515562 (LU-8998 lov: add composite layout unpacking)
Signed-off-by: Yang Sheng <ys@whamcloud.com>
Change-Id: I9b76283fcc65f58e3be6adf49f035236687ac85c
Reviewed-by: Bobi Jam <bobijam@hotmail.com>
Reviewed-by: Emoly Liu <emoly@whamcloud.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/38048
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/lov/lov_ea.c

index b44cbd1..1d38863 100644 (file)
@@ -207,8 +207,12 @@ lsme_unpack(struct lov_obd *lov, struct lov_mds_md *lmm, size_t buf_size,
 
        /* with Data-on-MDT set maxbytes to stripe size */
        if (lsme_is_dom(lsme)) {
-               lov_bytes = lsme->lsme_stripe_size;
-               goto out_dom;
+               if (maxbytes) {
+                       lov_bytes = lsme->lsme_stripe_size;
+                       goto out_dom1;
+               } else {
+                       goto out_dom2;
+               }
        }
 
        for (i = 0; i < stripe_count; i++) {
@@ -249,18 +253,21 @@ lsme_unpack(struct lov_obd *lov, struct lov_mds_md *lmm, size_t buf_size,
                        min_stripe_maxbytes = lov_bytes;
        }
 
-       if (min_stripe_maxbytes == 0)
-               min_stripe_maxbytes = LUSTRE_EXT3_STRIPE_MAXBYTES;
+       if (maxbytes) {
+               if (min_stripe_maxbytes == 0)
+                       min_stripe_maxbytes = LUSTRE_EXT3_STRIPE_MAXBYTES;
 
-       lov_bytes = min_stripe_maxbytes * stripe_count;
+               if (stripe_count == 0)
+                       stripe_count = lov->desc.ld_tgt_count;
 
-out_dom:
-       if (maxbytes) {
-               if (lov_bytes < min_stripe_maxbytes) /* handle overflow */
-                       *maxbytes = MAX_LFS_FILESIZE;
+               if (min_stripe_maxbytes <= LLONG_MAX / stripe_count)
+                       lov_bytes = min_stripe_maxbytes * stripe_count;
                else
-                       *maxbytes = lov_bytes;
+                       lov_bytes = MAX_LFS_FILESIZE;
+out_dom1:
+               *maxbytes = min_t(loff_t, lov_bytes, MAX_LFS_FILESIZE);
        }
+out_dom2:
 
        return lsme;