Whamcloud - gitweb
LU-9335 pfl: calculate PFL file LOVEA correctly 11/26611/2
authorBobi Jam <bobijam.xu@intel.com>
Thu, 13 Apr 2017 16:37:25 +0000 (00:37 +0800)
committerAndreas Dilger <andreas.dilger@intel.com>
Fri, 14 Apr 2017 15:52:35 +0000 (15:52 +0000)
PFL file could contain uninstantiated component, so it could still
keeps the specified -1 stripe count, lov_mds_md_size() should heed
this case, otherwise its LOVEA size could be errneous big.

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Change-Id: Iff741b8ebb1b54d9b27859822735b488e645d85c
Reviewed-on: https://review.whamcloud.com/26611
Reviewed-by: Jinshan Xiong <jinshan.xiong@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/lov/lov_internal.h

index 548fd50..f11721c 100644 (file)
@@ -94,11 +94,20 @@ static inline size_t lov_comp_md_size(const struct lov_stripe_md *lsm)
 
        size = sizeof(struct lov_comp_md_v1);
        for (entry = 0; entry < lsm->lsm_entry_count; entry++) {
+               u16 stripe_count;
+
                lsme = lsm->lsm_entries[entry];
 
+               /**
+                * uninstantiated component could still keep -1 stripe count
+                * and does not have objects
+                */
+               stripe_count = lsme->lsme_stripe_count;
+               if (stripe_count == (u16)-1)
+                       stripe_count = 0;
+
                size += sizeof(*lsme);
-               size += lov_mds_md_size(lsme->lsme_stripe_count,
-                                       lsme->lsme_magic);
+               size += lov_mds_md_size(stripe_count, lsme->lsme_magic);
        }
 
        return size;