Whamcloud - gitweb
EX-9588 lipe: lipe_scan3 compatibility for EXA5.2.8
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 26 Apr 2024 04:02:14 +0000 (22:02 -0600)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 27 Apr 2024 22:32:40 +0000 (22:32 +0000)
Add a compatibility implementation of llapi_layout_compress_get()
so lipe_scan3 can run on EXA5.2.8 that has an old liblustreapi.so
without this function.

Test-Parameters: trivial testlist=sanity-lipe-scan3,sanity-lipe-find3
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I7de9164467ea889ee2d47c7fbb18bfd7acce7057
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/54924
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Vitaliy Kuznetsov <vkuznetsov@ddn.com>
lipe/src/lipe_scan3/ls3_stats.c

index f4c1d8b..d0b0458 100644 (file)
@@ -2506,6 +2506,75 @@ static void ls3_stats_update_user_report_range(ls3_stats_users_reports report_ty
        pthread_mutex_unlock(&report_ptr->report_template_mutex);
 }
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 16, 53, 0)
+/* compatibility so lipe_scan3 can run on EXA5 that is missing this function */
+
+struct llapi_layout_comp {
+       uint64_t        llc_pattern;
+       struct { /* For plain layout. */
+               uint64_t        llc_stripe_size;
+               uint64_t        llc_stripe_count;
+               uint64_t        llc_stripe_offset;
+               /**
+                * Add 1 so user always gets back a null terminated string.
+                */
+               char            llc_pool_name[LOV_MAXPOOLNAME + 1];
+               /**
+                * Number of objects in llc_objects array if was initialized.
+                */
+               uint32_t        llc_objects_count;
+               uint8_t         llc_compr_type;
+               uint8_t         llc_compr_lvl;
+               uint8_t         llc_compr_chunk_log_bits;
+               struct lov_user_ost_data_v1 *llc_objects;
+       };
+};
+
+#ifndef LLAPI_LAYOUT_MAGIC
+#define LLAPI_LAYOUT_MAGIC 0x11AD1107 /* LLAPILOT */
+#endif
+
+struct llapi_layout {
+       uint32_t        llot_magic; /* LLAPI_LAYOUT_MAGIC */
+       uint32_t        llot_gen;
+       uint32_t        llot_flags;
+       bool            llot_is_composite;
+       uint16_t        llot_mirror_count;
+       /* Cursor pointing to one of the components in llot_comp_list */
+       struct llapi_layout_comp *llot_cur_comp;
+       struct lipe_list_head     llot_comp_list;
+};
+
+static struct llapi_layout_comp *
+__llapi_layout_cur_comp(const struct llapi_layout *layout)
+{
+       if (layout == NULL || layout->llot_magic != LLAPI_LAYOUT_MAGIC) {
+               errno = EINVAL;
+               return NULL;
+       }
+       if (layout->llot_cur_comp == NULL)
+               errno = EINVAL;
+
+       return layout->llot_cur_comp;
+}
+
+int llapi_layout_compress_get(struct llapi_layout *layout,
+                             __u8 *type, __u8 *level)
+{
+       struct llapi_layout_comp *comp;
+
+       comp = __llapi_layout_cur_comp(layout);
+       if (comp == NULL)
+               return -1;
+
+       if (type)
+               *type = comp->llc_compr_type;
+       if (level)
+               *level = comp->llc_compr_lvl;
+
+       return 0;
+}
+#endif
 
 int ls3_stats_update_info(struct ls3_object_attrs *loa_all)
 {
@@ -2676,12 +2745,12 @@ int ls3_stats_update_info(struct ls3_object_attrs *loa_all)
                if (rc < 0 || compr_type == LL_COMPR_TYPE_NONE)
                        return 0;       /* skip compression statistics */
 
-               /* TODO: Сompression statistics from MDT by type & lvl */
+               /* TODO: Compression statistics from MDT by type & lvl */
 
        } else {
                struct filter_fid ptr_filter_fid;
                struct ost_layout ptr_ost_layout;
-               struct ost_layout_compr layout_compr;
+               struct ost_layout_compr layout_compr;
 
                ptr_filter_fid = loa_all->loa_filter_fid;
                layout_compr = ptr_filter_fid.ff_layout_compr;
@@ -2697,7 +2766,7 @@ int ls3_stats_update_info(struct ls3_object_attrs *loa_all)
                if (layout_compr.ol_compr_type == LL_COMPR_TYPE_NONE)
                        return 0;       /* skip compression statistics */
 
-               /* TODO: Сompression statistics from OST by type & lvl
+               /* TODO: Compression statistics from OST by type & lvl
                 *       with using struct ost_layout_compr */
        }