From: Dominique Martinet Date: Tue, 25 Jun 2019 16:11:30 +0000 (+0200) Subject: LU-12473 llapi: fix pool_list by path X-Git-Tag: 2.12.56~9 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=3fa730299876a612695270a6c65e1ab1d3762a1f;hp=61295974fe1eb20b7e5525cf553fa2bfc43f3ba6 LU-12473 llapi: fix pool_list by path lfs/lctl pool_list would print the FS path as pool prefix. print fsname properly instead. Fixes: 8813fdf2a4f2 ("LU-5030 util: migrate liblustreapi to use cfs_get_paths()") Change-Id: I016b794fabd3d161d4651b41989637aebdf31f36 Signed-off-by: Dominique Martinet Reviewed-on: https://review.whamcloud.com/35320 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Olaf Faaland-LLNL Reviewed-by: Quentin Bouget Reviewed-by: Oleg Drokin --- diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index bc26d2d..e15d104 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -2810,6 +2810,24 @@ test_27K() { } run_test 27K "basic ops on dir with foreign LMV" +test_27L() { + remote_mds_nodsh && skip "remote MDS with nodsh" + + local POOL=${POOL:-$TESTNAME} + + if ! combined_mgs_mds ; then + mount_mgs_client + trap umount_mgs_client EXIT + fi + + pool_add $POOL || error "pool_add failed" + + lfs pool_list $MOUNT | grep -Fx "${FSNAME}.${POOL}" || + error "pool_list does not contain ${FSNAME}.${POOL}:" \ + "$(lfs pool_list $MOUNT | grep -F "${POOL}")" +} +run_test 27L "lfs pool_list gives correct pool name" + # createtest also checks that device nodes are created and # then visible correctly (#2091) test_28() { # bug 2091 diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index f81effb..429b27d 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -1578,47 +1578,45 @@ int llapi_get_poolmembers(const char *poolname, char **members, int llapi_get_poollist(const char *name, char **poollist, int list_size, char *buffer, int buffer_size) { - char rname[PATH_MAX]; glob_t pathname; char *fsname; - char *ptr; - DIR *dir; + char *ptr; + DIR *dir; struct dirent *pool; - int rc = 0; - unsigned int nb_entries = 0; - unsigned int used = 0; - unsigned int i; + int rc = 0; + unsigned int nb_entries = 0; + unsigned int used = 0; + unsigned int i; /* initialize output array */ - for (i = 0; i < list_size; i++) - poollist[i] = NULL; - - /* is name a pathname ? */ - ptr = strchr(name, '/'); - if (ptr != NULL) { - /* only absolute pathname is supported */ - if (*name != '/') - return -EINVAL; + for (i = 0; i < list_size; i++) + poollist[i] = NULL; - if (!realpath(name, rname)) { - rc = -errno; - llapi_error(LLAPI_MSG_ERROR, rc, "invalid path '%s'", - name); - return rc; - } + /* is name a pathname ? */ + ptr = strchr(name, '/'); + if (ptr != NULL) { + char fsname_buf[MAXNAMLEN]; - fsname = strdup(rname); + /* We will need fsname for printing later */ + rc = llapi_getname(name, fsname_buf, sizeof(fsname_buf)); + if (rc) + return rc; + + ptr = strrchr(fsname_buf, '-'); + if (ptr) + *ptr = '\0'; + + fsname = strdup(fsname_buf); if (!fsname) return -ENOMEM; - - rc = poolpath(&pathname, NULL, rname); } else { /* name is FSNAME */ fsname = strdup(name); if (!fsname) return -ENOMEM; - rc = poolpath(&pathname, fsname, NULL); } + + rc = poolpath(&pathname, fsname, NULL); if (rc != 0) { llapi_error(LLAPI_MSG_ERROR, rc, "Lustre filesystem '%s' not found", name);