Whamcloud - gitweb
LU-9362 lfs: getstripe print last init-ed component info 47/26947/7
authorBobi Jam <bobijam.xu@intel.com>
Thu, 4 May 2017 14:45:27 +0000 (22:45 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 16 May 2017 05:44:39 +0000 (05:44 +0000)
If getstripe asks for part of stripe information of a PFL file,
lfs should print the last instantiated component stripe info.

Signed-off-by: Bobi Jam <bobijam.xu@intel.com>
Change-Id: Iebdc4d44e47a25ef8445fda240b25975f8dbcbbe
Reviewed-on: https://review.whamcloud.com/26947
Tested-by: Jenkins
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Nunez <james.a.nunez@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/utils/liblustreapi.c

index 8563c92..08e06db 100644 (file)
@@ -2763,6 +2763,21 @@ lov_v1v3_pool_name(struct lov_user_md *v1, char *pool_name)
                pool_name[0] = '\0';
 }
 
+static inline bool
+print_last_init_comp(struct find_param *param)
+{
+       /* print all component info */
+       if ((param->fp_verbose & VERBOSE_DEFAULT) == VERBOSE_DEFAULT)
+               return false;
+
+       /* print specific component info */
+       if (param->fp_check_comp_id || param->fp_check_comp_flags ||
+           param->fp_check_comp_start || param->fp_check_comp_end)
+               return false;
+
+       return true;
+}
+
 /**
  * An example of "getstripe -v" for a two components PFL file:
  *
@@ -2858,11 +2873,6 @@ static void lov_dump_comp_v1(struct find_param *param, char *path,
                    !(param->fp_comp_flags & entry->lcme_flags))
                        continue;
 
-               if (entry->lcme_flags & LCME_FL_INIT)
-                       flags &= ~LDF_SKIP_OBJS;
-               else
-                       flags |= LDF_SKIP_OBJS;
-
                if (param->fp_check_comp_id &&
                    param->fp_comp_id != entry->lcme_id)
                        continue;
@@ -2891,6 +2901,43 @@ static void lov_dump_comp_v1(struct find_param *param, char *path,
                                continue;
                }
 
+               if (print_last_init_comp(param)) {
+                       /**
+                        * if part of stripe info is needed, we'd print only
+                        * the last instantiated component info.
+                        */
+                       if (entry->lcme_flags & LCME_FL_INIT)
+                               continue;
+                       else
+                               break;
+               }
+
+               if (entry->lcme_flags & LCME_FL_INIT)
+                       flags &= ~LDF_SKIP_OBJS;
+               else
+                       flags |= LDF_SKIP_OBJS;
+
+               lov_dump_comp_v1_entry(param, flags, i);
+
+               v1 = lov_comp_entry(comp_v1, i);
+               objects = lov_v1v3_objects(v1);
+               lov_v1v3_pool_name(v1, pool_name);
+
+               lov_dump_user_lmm_v1v3(v1, pool_name, objects, path, obdindex,
+                                      param->fp_max_depth, param->fp_verbose,
+                                      flags);
+       }
+       if (print_last_init_comp(param)) {
+               /**
+                * directory layout contains only layout template, print the
+                * last component.
+                */
+               if (i == 0)
+                       i = comp_v1->lcm_entry_count - 1;
+               else
+                       i--;
+               flags &= ~LDF_SKIP_OBJS;
+
                lov_dump_comp_v1_entry(param, flags, i);
 
                v1 = lov_comp_entry(comp_v1, i);