POOL_DIR=$POOL_ROOT/dir_tst
POOL_FILE=$POOL_ROOT/file_tst
+skip_pools()
+{
+ [ -z "$($LCTL get_param -n mdc.*.connect_flags | grep pools)" ] &&
+ skip "missing pools support on server" && return 1
+ remote_mgs_nodsh && skip "remote MGS with nodsh" && return 1
+ return 0
+}
+
check_file_in_pool()
{
file=$1
mdtlov=$(get_mdtlov_proc_path $FSNAME)
test_200a() {
- [ -z "$(lctl get_param -n mdc.*.connect_flags | grep pools)" ] &&
- skip "missing pools support on server" && return
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
- do_facet mgs $LCTL pool_new $FSNAME.$POOL
- do_facet mgs $LCTL get_param -n lov.$mdtlov.pools.$POOL
- [ $? == 0 ] || error "Pool creation of $POOL failed"
+ skip_pools || return
+ do_facet mgs $LCTL pool_new $FSNAME.$POOL
+ # 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() {
- [ -z "$(lctl get_param -n mdc.*.connect_flags | grep pools)" ] &&
- skip "missing pools support on server" && return
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
- TGT=$(seq -f $FSNAME-OST%04g_UUID $TGTPOOL_FIRST $TGTPOOL_STEP \
- $TGTPOOL_MAX | tr '\n' ' ')
- 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.$mdtlov.pools.$POOL |
- sort | tr '\n' ' ')
- [ "$res" = "$TGT" ] || error "Pool ($res) do not match requested ($TGT)"
+ skip_pools || 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]
+ 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() {
- [ -z "$(lctl get_param -n mdc.*.connect_flags | grep pools)" ] &&
- skip "missing pools support on server" && return
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
- mkdir -p $POOL_DIR
- $SETSTRIPE -c 2 -p $POOL $POOL_DIR
- [ $? = 0 ] || error "Cannot set pool $POOL to $POOL_DIR"
+ skip_pools || 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() {
- [ -z "$(lctl get_param -n mdc.*.connect_flags | grep pools)" ] &&
- skip "missing pools support on server" && return
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ skip_pools || 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() {
- [ -z "$(lctl get_param -n mdc.*.connect_flags | grep pools)" ] &&
- skip "missing pools support on server" && return
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ skip_pools || return
failed=0
for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
file=$POOL_DIR/file-$i
run_test 200e "Check files allocation from directory pool =============="
test_200f() {
- [ -z "$(lctl get_param -n mdc.*.connect_flags | grep pools)" ] &&
- skip "missing pools support on server" && return
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
+ skip_pools || return
mkdir -p $POOL_FILE
failed=0
for i in $(seq -w 1 $(($TGT_COUNT * 3))); do
run_test 200f "Create files in a pool ==================================="
test_200g() {
- [ -z "$(lctl get_param -n mdc.*.connect_flags | grep pools)" ] &&
- skip "missing pools support on server" && return
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
- TGT=$(do_facet mgs $LCTL get_param -n lov.$mdtlov.pools.$POOL |
- head -1)
- do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
- res=$(do_facet mgs $LCTL get_param -n lov.$mdtlov.pools.$POOL |
- grep $TGT)
- [ "$res" = "" ] || error "$TGT not removed from $FSNAME.$POOL"
+ skip_pools || return
+ TGT=$($LCTL get_param -n lov.$FSNAME-*.pools.$POOL | head -1)
+ do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
+ 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() {
- [ -z "$(lctl get_param -n mdc.*.connect_flags | grep pools)" ] &&
- skip "missing pools support on server" && return
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
- for TGT in $(do_facet mgs $LCTL get_param -n lov.$mdtlov.pools.$POOL); do
- do_facet mgs $LCTL pool_remove $FSNAME.$POOL $TGT
- done
- res=$(do_facet mgs $LCTL get_param -n lov.$mdtlov.pools.$POOL)
- [ "$res" = "" ] || error "Pool $FSNAME.$POOL cannot be drained"
+ skip_pools || 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
+ 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() {
- [ -z "$(lctl get_param -n mdc.*.connect_flags | grep pools)" ] &&
- skip "missing pools support on server" && return
- remote_mds_nodsh && skip "remote MDS with nodsh" && return
- do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
- res=$(do_facet mgs "$LCTL get_param -n lov.$mdtlov.pools.$POOL 2>/dev/null")
- [ "$res" = "" ] || error "Pool $FSNAME.$POOL is not destroyed"
+ skip_pools || return
+ do_facet mgs $LCTL pool_destroy $FSNAME.$POOL
+ # 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 ============================================"
local WAIT=0
local sleep=5
while [ $WAIT -lt $MAX ]; do
- sleep $sleep
RESULT=$(do_node $node "$TEST")
- if [ $RESULT -eq $FINAL ]; then
- echo "Updated after $WAIT sec: wanted $FINAL got $RESULT"
+ if [ "$RESULT" == "$FINAL" ]; then
+ echo "Updated after $WAIT sec: wanted '$FINAL' got '$RESULT'"
return 0
fi
- WAIT=$((WAIT + sleep))
echo "Waiting $((MAX - WAIT)) secs for update"
+ WAIT=$((WAIT + sleep))
+ sleep $sleep
done
- echo "Update not seen after $MAX sec: wanted $FINAL got $RESULT"
+ echo "Update not seen after $MAX sec: wanted '$FINAL' got '$RESULT'"
return 3
}
remote_ost && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
}
+remote_mgs_nodsh()
+{
+ local MGS
+ MGS=$(facet_host mgs)
+ remote_node $MGS && [ "$PDSH" = "no_dsh" -o -z "$PDSH" -o -z "$ost_HOST" ]
+}
+
remote_servers () {
remote_ost && remote_mds
}
do_disconnect(NULL, 1);
rc = do_device("mgsioc", mgs);
if (rc) {
- fprintf(stderr,
+ fprintf(stderr,
"This command must be run on the MGS.\n");
errno = ENODEV;
return -1;
"/proc/fs/lustre/lov/%s-*/target_obd",
fsname);
rc = glob(pattern, GLOB_BRACE, NULL, &glob_info);
- if (rc)
+ if (rc == GLOB_NOMATCH)
+ return -ENODEV;
+ else if (rc)
return -EINVAL;
- if (glob_info.gl_pathc == 0) {
- globfree(&glob_info);
- 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--;
struct lustre_cfg *lcfg;
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;