}
test_200a() {
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ remote_mgs_nodsh && skip "remote MGS with nodsh" && return
do_facet mgs $LCTL pool_new $FSNAME.$POOL
- do_facet mgs $LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL
- [ $? == 0 ] || error "Pool creation of $POOL failed"
+ # get param should return err until pool is created
+ wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null || echo foo" "" || error "Pool creation of $POOL failed"
}
run_test 200a "Create new pool =========================================="
test_200b() {
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
- TGT=$(seq -f $FSNAME-OST%04g_UUID $TGTPOOL_FIRST $TGTPOOL_STEP \
- $TGTPOOL_MAX | tr '\n' ' ')
+ remote_mgs_nodsh && skip "remote MGS with nodsh" && return
+ TGT=$(for i in `seq $TGTPOOL_FIRST $TGTPOOL_STEP $TGTPOOL_MAX`; do printf "$FSNAME-OST%04x_UUID " $i; done)
do_facet mgs $LCTL pool_add $FSNAME.$POOL \
- $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]_UUID
- res=$(do_facet mgs $LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL | sort \
- | tr '\n' ' ')
- [ "$res" = "$TGT" ] || error "Pool content ($res) do not match requested ($TGT)"
+ $FSNAME-OST[$TGTPOOL_FIRST-$TGTPOOL_MAX/$TGTPOOL_STEP]
+ wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | sort -u | tr '\n' ' ' " "$TGT" || error "Add to pool failed"
}
run_test 200b "Add targets to a pool ===================================="
test_200c() {
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ remote_mgs_nodsh && skip "remote MGS with nodsh" && return
mkdir -p $POOL_DIR
$SETSTRIPE -c 2 -p $POOL $POOL_DIR
[ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
run_test 200c "Set pool on a directory ================================="
test_200d() {
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ remote_mgs_nodsh && skip "remote MGS with nodsh" && return
res=$($GETSTRIPE $POOL_DIR | grep pool: | cut -f8 -d " ")
[ "$res" = $POOL ] || error "Pool on $POOL_DIR is not $POOL"
}
run_test 200d "Check pool on a directory ==============================="
test_200e() {
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ remote_mgs_nodsh && skip "remote MGS with nodsh" && return
failed=0
for i in $(seq -w 1 $(($TGT_COUNT * 3)))
do
run_test 200e "Check files allocation from directory pool =============="
test_200f() {
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ remote_mgs_nodsh && skip "remote MGS with nodsh" && return
mkdir -p $POOL_FILE
failed=0
for i in $(seq -w 1 $(($TGT_COUNT * 3)))
run_test 200f "Create files in a pool ==================================="
test_200g() {
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
- TGT=$(do_facet mgs $LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL | head -1)
+ remote_mgs_nodsh && skip "remote MGS with nodsh" && return
+ TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
- res=$(do_facet mgs $LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL | grep $TGT)
- [ "$res" = "" ] || error "$TGT not removed from $FSNAME.$POOL"
+ wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL | grep $TGT" "" || error "$TGT not removed from $FSNAME.$POOL"
}
run_test 200g "Remove a target from a pool ============================="
test_200h() {
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
- for TGT in $(do_facet mgs $LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL)
+ remote_mgs_nodsh && skip "remote MGS with nodsh" && return
+ for TGT in $($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | sort -u)
do
do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
done
- res=$(do_facet mgs $LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL)
- [ "$res" = "" ] || error "Pool $FSNAME.$POOL cannot be drained"
+ wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL" ""\
+ || error "Pool $FSNAME.$POOL cannot be drained"
}
run_test 200h "Remove all targets from a pool =========================="
test_200i() {
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ remote_mgs_nodsh && skip "remote MGS with nodsh" && return
do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
- res=$(do_facet mgs "$LCTL get_param -n lov.$FSNAME-MDT0000-mdtlov.pools.$POOL 2>/dev/null")
- [ "$res" = "" ] || error "Pool $FSNAME.$POOL is not destroyed"
+ # get param should return err once pool is gone
+ wait_update $HOSTNAME "lctl get_param -n lov.$FSNAME-*.pools.$POOL 2>/dev/null || echo foo" "foo" && return 0
+ error "Pool $FSNAME.$POOL is not destroyed"
}
run_test 200i "Remove a pool ============================================"
"/proc/fs/lustre/lov/%s-*/target_obd",
fsname);
rc = glob(pattern, GLOB_BRACE, NULL, &glob_info);
- if (rc)
- return -EINVAL;
-
- if (glob_info.gl_pathc == 0) {
- globfree(&glob_info);
+ if (rc == GLOB_NOMATCH)
+ return -ENODEV;
+ else if (rc)
return -EINVAL;
- }
strcpy(path, glob_info.gl_pathv[0]);
+ globfree(&glob_info);
return 0;
}
"/proc/fs/lustre/lov/%s-*/pools/%s",
fsname, poolname);
rc = glob(pattern, GLOB_BRACE, NULL, &glob_info);
+ /* If no pools, make sure the lov is available */
+ if ((rc == GLOB_NOMATCH) &&
+ (find_target_obdpath(fsname, poolpath) == -ENODEV))
+ return -ENODEV;
if (rc)
return -EINVAL;
- if (glob_info.gl_pathc == 0) {
- globfree(&glob_info);
- return -EINVAL;
- }
-
strcpy(poolpath, glob_info.gl_pathv[0]);
+ globfree(&glob_info);
return 0;
}
while (fgets(buffer, sizeof(buffer), fd) != NULL) {
if (poolname == NULL) {
- /* we search ostname in target_obd */
- if (strncmp(buffer + 3, ostname, len) == 0) {
+ char *ptr;
+ /* Search for an ostname in the list of OSTs
+ Line format is IDX: fsname-OSTxxxx_UUID STATUS */
+ ptr = strchr(buffer, ' ');
+ if ((ptr != NULL) &&
+ (strncmp(ptr + 1, ostname, len) == 0)) {
fclose(fd);
return 1;
}
} else {
- /* we search a non empty pool or
- an ostname in a pool */
+ /* Search for an ostname in a pool,
+ (or an existing non-empty pool if no ostname) */
if ((ostname == NULL) ||
(strncmp(buffer, ostname, len) == 0)) {
fclose(fd);
if (rc < 0) {
fprintf(stderr, "Pool %s.%s not found\n",
fsname, poolname);
- return -ENOENT;
+ return rc;
}
if (rc == 1) {
fprintf(stderr, "Pool %s.%s not empty, "
if (rc < 0) {
fprintf(stderr, "Pool %s.%s not found\n",
fsname, poolname);
- return -ENOENT;
+ return rc;
}
if (rc == 1) {
fprintf(stderr, "OST %s already in pool %s.%s\n",
if (rc < 0) {
fprintf(stderr, "Pool %s.%s not found\n",
fsname, poolname);
- return -ENOENT;
+ return rc;
}
if (rc == 0) {
fprintf(stderr, "OST %s not found in pool %s.%s\n",
case LCFG_POOL_NEW: {
do {
rc = search_ost(fsname, poolname, NULL);
+ if (rc == -ENODEV)
+ return;
if (rc < 0)
sleep(2);
cpt--;
}
case LCFG_POOL_DEL: {
do {
- rc = search_ost(fsname, poolname, NULL);
- if (rc >= 0)
+ rc = search_ost(fsname, poolname, NULL);
+ if (rc == -ENODEV)
+ return;
+ if (rc >= 0)
sleep(2);
- cpt--;
+ cpt--;
} while ((rc >= 0) && (cpt > 0));
if (rc < 0)
fprintf(stderr, "Pool %s.%s destroyed\n",
case LCFG_POOL_ADD: {
do {
rc = search_ost(fsname, poolname, ostname);
+ if (rc == -ENODEV)
+ return;
if (rc != 1)
sleep(2);
cpt--;
case LCFG_POOL_REM: {
do {
rc = search_ost(fsname, poolname, ostname);
+ if (rc == -ENODEV)
+ return;
if (rc == 1)
sleep(2);
cpt--;
char rawbuf[MAX_IOC_BUFLEN], *buf = rawbuf;
rc = check_pool_cmd(cmd, fsname, poolname, ostname);
- if (rc)
+ if (rc == -ENODEV)
+ fprintf(stderr, "Can't verify pool command since there "
+ "is no local MDT or client, proceeding anyhow...\n");
+ else if (rc)
return rc;
lustre_cfg_bufs_reset(&bufs, NULL);
end++;
start++;
/* put in format the printf format (the rule without the range) */
- sprintf(format, "%s%%.4d%s", rule, end);
+ sprintf(format, "%s%%.4x%s", rule, end);
array_idx = 0;
array_sz = 0;
/* loop on , separator */
do {
/* extract the 3 fields */
- rc = sscanf(start, "%u-%u/%u", &lo, &hi, &step);
+ rc = sscanf(start, "%x-%x/%u", &lo, &hi, &step);
switch (rc) {
case 0: {
return 0;
if (rc)
break;
- rc = pool_cmd(cmd, argv[0], argv[1],
- fsname, poolname, NULL);
+ rc = pool_cmd(cmd, argv[0], argv[1], fsname, poolname, NULL);
if (rc)
break;