Whamcloud - gitweb
LU-17025 llapi: restore 'pool=ignore' functionality 55/54355/8
authorRajeev Mishra <rajeevm@hpe.com>
Mon, 11 Mar 2024 18:53:11 +0000 (18:53 +0000)
committerOleg Drokin <green@whamcloud.com>
Tue, 30 Apr 2024 06:51:04 +0000 (06:51 +0000)
Changes to llapi_stripe_param_verify() and related llapi file
creation functions to verify that the given pool name is valid
introduced a bug that disallowed the 'ignore' pool name, which
is used to create files without any pool name.

Allow the reserved pool names from lov_pool_is_reserved() to be
used even (especially!) if the named pool does not exist.

Revert the changes to ost-pools.sh::test_32() that created the
'ignore_pool' pool, and go back to checking that 'ignore' will
create a file that does not use any pool.

Change the pool name validation to only do fsname lookup if the
pool name is actually specified, instead of looking up fsname
but not actually using it for anything.

Fixes: ee7dfc5ad1 ("LU-17025 llapi: Verify stripe pool name")
Signed-off-by: Rajeev Mishra <rajeevm@hpe.com>
Change-Id: I9368f28a41fd9af6b6f0e9468df0e7dfd728db1c
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54355
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Petros Koutoupis <petros.koutoupis@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/tests/ost-pools.sh
lustre/utils/liblustreapi.c
lustre/utils/liblustreapi_layout.c

index e275403..12b0ff6 100755 (executable)
@@ -1930,20 +1930,16 @@ test_32() { # LU-15707
        ( $LFS getstripe -p $DIR/$tdir | grep -q $pool ) ||
                error "fail to set pool on $DIR/$tdir"
 
-       local ig_pool="ignore_pool"
-
-       pool_add $ig_pool || error "add $ig_pool failed"
-
-       $LFS setstripe -p $ig_pool $DIR/$tdir/$tfile ||
+       $LFS setstripe -p ignore $DIR/$tdir/$tfile ||
                error "setstripe fail on $DIR/$tdir/$tfile"
 
-       ( $LFS getstripe -p $DIR/$tdir/$tfile | grep -q $ig_pool ) ||
+       ! ( $LFS getstripe -p $DIR/$tdir/$tfile | egrep -q "[^ ]+" ) ||
                error "fail to create $DIR/$tdir/$tfile without pool"
 
        # Test with start index
        local got idx
        for ((idx = 0; idx < OSTCOUNT; idx++)); do
-               $LFS setstripe -p $ig_pool -i $idx $DIR/$tdir/$tfile.$idx ||
+               $LFS setstripe -p ignore -i $idx $DIR/$tdir/$tfile.$idx ||
                        error "setstripe -i fail on $DIR/$tdir/$tfile.$idx"
 
                got=$($LFS getstripe -i $DIR/$tdir/$tfile.$idx)
@@ -1952,7 +1948,7 @@ test_32() { # LU-15707
        done
 
        # Test with ost list
-       $LFS setstripe -p $ig_pool -o 1,0 $DIR/$tdir/$tfile.1_0 ||
+       $LFS setstripe -p ignore -o 1,0 $DIR/$tdir/$tfile.1_0 ||
                error "setstripe --ost fail on $DIR/$tdir/$tfile.1_0"
 
        got=$($LFS getstripe -i $DIR/$tdir/$tfile.1_0)
index bafd87f..464f711 100644 (file)
@@ -424,14 +424,16 @@ static int llapi_stripe_param_verify(const struct llapi_stripe_param *param,
                        goto out;
                }
 
-               /* Make sure the pool exists */
-               rc = llapi_search_ost(fsname, *pool_name, NULL);
-               if (rc < 0) {
-                       llapi_error(LLAPI_MSG_ERROR, rc,
-                                   "pool '%s fsname %s' does not exist",
-                                         *pool_name, fsname);
-                       rc = -EINVAL;
-                       goto out;
+               if (!lov_pool_is_ignored((const char *) *pool_name)) {
+                       /* Make sure the pool exists */
+                       rc = llapi_search_ost(fsname, *pool_name, NULL);
+                       if (rc < 0) {
+                               llapi_error(LLAPI_MSG_ERROR, rc,
+                                           "pool '%s fsname %s' does not exist",
+                                           *pool_name, fsname);
+                               rc = -EINVAL;
+                               goto out;
+                       }
                }
        }
 
@@ -561,14 +563,16 @@ int llapi_file_open_param(const char *name, int flags, mode_t mode,
        struct lov_user_md *lum = NULL;
        const char *pool_name = param->lsp_pool;
        size_t lum_size;
-       int fd, rc;
+       int fd, rc = 0;
 
        /* Make sure we are on a Lustre file system */
-       rc = llapi_search_fsname(name, fsname);
-       if (rc) {
-               llapi_error(LLAPI_MSG_ERROR, rc,
-                           "'%s' is not on a Lustre filesystem", name);
-               return rc;
+       if (pool_name && !lov_pool_is_ignored(pool_name)) {
+               rc = llapi_search_fsname(name, fsname);
+               if (rc) {
+                       llapi_error(LLAPI_MSG_ERROR, rc,
+                                   "'%s' is not on a Lustre filesystem", name);
+                       return rc;
+               }
        }
 
        /* Check if the stripe pattern is sane. */
index 05f4dae..640cc7d 100644 (file)
@@ -1775,6 +1775,9 @@ int llapi_layout_file_open(const char *path, int open_flags, mode_t mode,
        struct lov_user_md *lum;
        size_t lum_size;
        char fsname[MAX_OBD_NAME + 1] = { 0 };
+       struct llapi_layout_comp *comp;
+
+       comp = __llapi_layout_cur_comp(layout);
 
        if (path == NULL ||
            (layout != NULL && layout->llot_magic != LLAPI_LAYOUT_MAGIC)) {
@@ -1784,10 +1787,13 @@ int llapi_layout_file_open(const char *path, int open_flags, mode_t mode,
 
        if (layout) {
                /* Make sure we are on a Lustre file system */
-               rc = llapi_search_fsname(path, fsname);
-               if (rc) {
-                       errno = ENOTTY;
-                       return -1;
+               if (comp->llc_pool_name[0] != '\0' &&
+                   !lov_pool_is_ignored(comp->llc_pool_name)) {
+                       rc = llapi_search_fsname(path, fsname);
+                       if (rc) {
+                               errno = ENOTTY;
+                               return -1;
+                       }
                }
                rc = llapi_layout_v2_sanity((struct llapi_layout *)layout,
                                            false,
@@ -2405,6 +2411,7 @@ int llapi_layout_file_comp_add(const char *path,
        struct llapi_layout *existing_layout = NULL;
        struct lov_user_md *lum = NULL;
        char fsname[MAX_OBD_NAME + 1] = { 0 };
+       struct llapi_layout_comp *comp;
 
        if (path == NULL || layout == NULL ||
            layout->llot_magic != LLAPI_LAYOUT_MAGIC) {
@@ -2433,11 +2440,16 @@ int llapi_layout_file_comp_add(const char *path,
                goto out;
        }
 
-       rc = llapi_search_fsname(path, fsname);
-       if (rc) {
-               tmp_errno = -rc;
-               rc = -1;
-               goto out;
+       comp = __llapi_layout_cur_comp(layout);
+
+       if (comp->llc_pool_name[0] != '\0' &&
+           !lov_pool_is_ignored(comp->llc_pool_name)) {
+               rc = llapi_search_fsname(path, fsname);
+               if (rc) {
+                       tmp_errno = -rc;
+                       rc = -1;
+                       goto out;
+               }
        }
 
        rc = llapi_layout_v2_sanity(existing_layout, false, false, fsname);
@@ -2736,11 +2748,16 @@ int llapi_layout_file_comp_set(const char *path, uint32_t *ids, uint32_t *flags,
                goto out;
        }
 
-       rc = llapi_search_fsname(path, fsname);
-       if (rc) {
-               tmp_errno = -rc;
-               rc = -1;
-               goto out;
+       comp = __llapi_layout_cur_comp(layout);
+
+       if (comp && comp->llc_pool_name[0] != '\0' &&
+           !lov_pool_is_ignored(comp->llc_pool_name)) {
+               rc = llapi_search_fsname(path, fsname);
+               if (rc) {
+                       tmp_errno = -rc;
+                       rc = -1;
+                       goto out;
+               }
        }
 
        rc = llapi_layout_v2_sanity(existing_layout, false, false, fsname);
@@ -3596,7 +3613,8 @@ static inline int verify_pool_name(char *fsname, struct llapi_layout *layout)
        comp = __llapi_layout_cur_comp(layout);
        if (!comp)
                return 0;
-       if (comp->llc_pool_name[0] == '\0')
+       if (comp->llc_pool_name[0] == '\0' ||
+           lov_pool_is_ignored(comp->llc_pool_name))
                return 0;
        /* check if the pool name exist */
        if (llapi_search_ost(fsname, comp->llc_pool_name, NULL) < 0)