Whamcloud - gitweb
LU-9657 llapi: check if the file layout is composite 52/27752/4
authorEmoly Liu <emoly.liu@intel.com>
Wed, 28 Jun 2017 09:28:34 +0000 (17:28 +0800)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 19 Jul 2017 03:29:06 +0000 (03:29 +0000)
Add a new API llapi_layout_is_composite() to check if the file
layout is composite.

Signed-off-by: Emoly Liu <emoly.liu@intel.com>
Change-Id: Ie7d60f95feb9dfde5fbf52ea65ebd26b925bd33d
Reviewed-on: https://review.whamcloud.com/27752
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Niu Yawei <yawei.niu@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/include/lustre/lustreapi.h
lustre/utils/lfs.c
lustre/utils/liblustreapi_layout.c

index 67df286..f2d6db8 100644 (file)
@@ -816,6 +816,10 @@ int llapi_layout_file_comp_del(const char *path, uint32_t id, uint32_t flags);
 int llapi_layout_file_comp_set(const char *path,
                               const struct llapi_layout *comp,
                               uint32_t valid);
+/**
+ * Check if the file layout is composite.
+ */
+bool llapi_layout_is_composite(struct llapi_layout *layout);
 
 /** @} llapi */
 
index 5870cd8..7a48345 100644 (file)
@@ -1171,17 +1171,11 @@ static int adjust_first_extent(char *fname, struct llapi_layout *layout)
                 * into a component-create. */
                llapi_layout_free(head);
                return -ENODATA;
-       } else {
-               /* Current component of 'head' should be tail of component
-                * list by default, but we do an extra move cursor operation
-                * here to test if the layout is non-composite. */
-               rc = llapi_layout_comp_use(head, LLAPI_LAYOUT_COMP_USE_LAST);
-               if (rc < 0) {
-                       fprintf(stderr, "'%s' isn't a composite file?\n",
-                               fname);
-                       llapi_layout_free(head);
-                       return rc;
-               }
+       } else if (!llapi_layout_is_composite(head)) {
+               fprintf(stderr, "'%s' isn't a composite file.\n",
+                       fname);
+               llapi_layout_free(head);
+               return -EINVAL;
        }
 
        rc = llapi_layout_comp_extent_get(head, &start, &prev_end);
index dbf1369..0168de2 100644 (file)
@@ -2012,3 +2012,16 @@ int llapi_layout_file_comp_set(const char *path,
        errno = EOPNOTSUPP;
        return -1;
 }
+
+/**
+ * Check if the file layout is composite.
+ *
+ * \param[in] layout   the file layout to check
+ *
+ * \retval true                composite
+ * \retval false       not composite
+ */
+bool llapi_layout_is_composite(struct llapi_layout *layout)
+{
+       return layout->llot_is_composite;
+}