.br
.B lfs getname [-h]|[path ...]
.br
-.B lfs getstripe [--obd|-O <uuid>] [--quiet|-q] [--verbose|-v]
- \fB[--stripe-count|-c ] [--stripe-index|-i] [--mdt-index|-M] [--fid|-F]
- \fB[--stripe-size|-S] [--directory|-d] [--layout|-L] [--generation|-g]
- \fB[--component-id|-I [comp_id]] [--component-flags [comp_flags]]
- \fB[--component-count] [--component-start [+-][N][kMGTPE]]
- \fB[--component-end|-E [+-][N][kMGTPE]]
- \fB[--pool|-p] [--recursive|-r] [--raw|-R] <dirname|filename> ...\fR
+.B lfs getstripe [\fB--obd\fR|\fB-O\fR <\fIuuid\fR>] [\fB--quiet\fR|\fB-q\fR]
+ [\fB--verbose\fR|\fB-v\fR] [\fB--stripe-count\fR|\fB-c\fR]
+ [\fB--stripe-index\fR|\fB-i\fR] [\fB--mdt-index\fR|\fB-M\fR]
+ [\fB--fid\fR|\fB-F\fR] [\fB--stripe-size\fR|\fB-S\fR]
+ [\fB--directory\fR|\fB-d\fR] [\fB--layout\fR|\fB-L\fR]
+ [\fB--generation\fR|\fB-g\fR]
+ [\fB--component-id\fR[=\fIcomp_id\fR]|\fB-I\fR[\fIcomp_id\fR]]
+ [\fB--component-flags\fR[=\fIcomp_flags\fR]] [\fB--component-count\fR]
+ [\fB--component-start\fR[=[+-]\fIN\fR[kMGTPE]]]
+ [\fB--component-end\fR[=[+-]\fIN\fR[kMGTPE]]|\fB-E\fR[[+-]\fIN\fR[kMGTPE]]]
+ [\fB--pool\fR|\fB-p\fR] [\fB--recursive\fR|\fB-r\fR] [\fB--raw\fR|\fB-R\fR]
+ <\fIdirname\fR|\fIfilename\fR> ...
.br
.B lfs migrate \fB-m <mdt_index>\fR
.IR directory
that is located on a lustre mounted file system then only the OSTs belonging
to that filesystem are displayed.
.TP
-.B getstripe [--obd|-O <uuid>] [--quiet|-q] [--verbose|-v]
- \fB[--count | -c ] [--index | -i | --offset | -o ]
- \fB[--pool | -p ] [--size | -s ] [--directory | -d ]
- \fB[--layout | -L ] [--fid | -F ] [--generation | -g ]
- \fB[--component-id|-I [comp_id]]
- \fB[--component-flags [comp_flags]]
- \fB[--component-count] [--component-start [+-][N][kMGTPE]]
- \fB[--component-end|-E [+-][N][kMGTPE]]
- \fB[--recursive | -r ] [--raw | -R ] <dirname|filename>\fR
+.B getstripe [\fB--obd\fR|\fB-O\fR <\fIuuid\fR>] [\fB--quiet\fR|\fB-q\fR]
+ [\fB--verbose\fR|\fB-v\fR] [\fB--stripe-count\fR|\fB-c\fR]
+ [\fB--stripe-index\fR|\fB-i\fR] [\fB--mdt-index\fR|\fB-M\fR]
+ [\fB--fid\fR|\fB-F\fR] [\fB--stripe-size\fR|\fB-S\fR]
+ [\fB--directory\fR|\fB-d\fR] [\fB--layout\fR|\fB-L\fR]
+ [\fB--generation\fR|\fB-g\fR]
+ [\fB--component-id\fR[=\fIcomp_id\fR]|\fB-I\fR[\fIcomp_id\fR]]
+ [\fB--component-flags\fR[=\fIcomp_flags\fR]] [\fB--component-count\fR]
+ [\fB--component-start\fR[=[+-]\fIN\fR[kMGTPE]]]
+ [\fB--component-end\fR[=[+-]\fIN\fR[kMGTPE]]|\fB-E\fR[[+-]\fIN\fR[kMGTPE]]]
+ [\fB--pool\fR|\fB-p\fR] [\fB--recursive\fR|\fB-r\fR] [\fB--raw\fR|\fB-R\fR]
+ <\fIdirname\fR|\fIfilename\fR> ...
.br
List the striping information for a given filename or directory tree.
By default the stripe count, size, and offset will be returned. If you
.B --generation
option.
You can limit the displayed content by specifing argument for
-.B --component-id
+.B --component-id|-I
.B --component-flags
.B --component-start
-.B --component-end
-options. For example, "--component-id 1" will only display the information
-for component 1.
+.B --component-end|-E
+options. For example, "--component-id=2" or "-I2" will only display the layout
+attributes for the component with id equal to 2.
.TP
.B fid2path [--link <linkno>] <fsname|rootpath> <fid> ...
Print out the pathname(s) for the specified \fIfid\fR(s) from the filesystem
.B $ lfs getstripe -v /mnt/lustre/file1
Lists the detailed object allocation of a given file
.TP
-.B $ lfs getstripe -v --component-id 2 /mnt/lustre/file1
+.B $ lfs getstripe -v -I2 /mnt/lustre/file1
Lists the detailed information of the component 2 in a given file
.TP
-.B $ lfs getstripe -E -64M /mnt/lustre/file1
-Lists the information of the components in a file which has at least 64M extent end
+.B $ lfs getstripe --component-flags=^init -I /mnt/lustre/file1
+Print only the component IDs for all the uninstantiated components
+.TP
+.B $ lfs getstripe -E-64M /mnt/lustre/file1
+Lists the information of the components in a file which has at most 64M extent end
+.TP
+.B $ lfs getstripe -I3 --component-start /mnt/lustre/file1
+Print only the component start for the component with ID of 3
.TP
.B $ lfs find /mnt/lustre
Efficiently lists all files in a given directory and its subdirectories
Recursively list all files in a given directory that have objects on OST2-UUID.
.TP
.B $ lfs find --component-count +3 /mnt/lustre
-Recursively list all files that have at most 3 components.
+Recursively list all files that have at least 3 components.
.TP
.B $ lfs check servers
Check the status of all servers (MDT, OST)
$LFS getstripe -v $name || error "(7.1) cannot getstripe on $name"
- local pattern=$($LFS getstripe -L -I 1 $name)
+ local pattern=$($LFS getstripe -L -I1 $name)
[[ "$pattern" = "$PATTERN_WITHOUT_HOLE" ]] ||
error "(7.2.1) NOT expect pattern flag hole, but got $pattern"
- pattern=$($LFS getstripe -L -I 2 $name)
+ pattern=$($LFS getstripe -L -I2 $name)
[[ "$pattern" = "$PATTERN_WITHOUT_HOLE" ]] ||
error "(7.2.2) NOT expect pattern flag hole, but got $pattern"
- local stripes=$($LFS getstripe -c -I 1 $name)
+ local stripes=$($LFS getstripe -c -I1 $name)
[ $stripes -eq 2 ] ||
error "(7.3.1) expect 2 stripes, but got $stripes"
- stripes=$($LFS getstripe -c -I 2 $name)
+ stripes=$($LFS getstripe -c -I2 $name)
[ $stripes -eq 2 ] ||
error "(7.3.2) expect 2 stripes, but got $stripes"
- local e_start=$($LFS getstripe -I 1 $name |
+ local e_start=$($LFS getstripe -I1 $name |
awk '/lcme_extent.e_start:/ { print $2 }')
[ $e_start -eq 0 ] ||
error "(7.4.1) expect the COMP1 start at 0, got $e_start"
- local e_end=$($LFS getstripe -I 1 $name |
+ local e_end=$($LFS getstripe -I1 $name |
awk '/lcme_extent.e_end:/ { print $2 }')
[ $e_end -eq 2097152 ] ||
error "(7.4.2) expect the COMP1 end at 2097152, got $e_end"
- e_start=$($LFS getstripe -I 2 $name |
+ e_start=$($LFS getstripe -I2 $name |
awk '/lcme_extent.e_start:/ { print $2 }')
[ $e_start -eq 2097152 ] ||
error "(7.5.1) expect the COMP2 start at 2097152, got $e_start"
- e_end=$($LFS getstripe -I 2 $name |
+ e_end=$($LFS getstripe -I2 $name |
awk '/lcme_extent.e_end:/ { print $2 }')
[ "$e_end" = "EOF" ] ||
error "(7.5.2) expect the COMP2 end at (EOF), got $e_end"
$LFS getstripe -v $name || error "(8.1) cannot getstripe on $name"
- pattern=$($LFS getstripe -L -I 1 $name)
+ pattern=$($LFS getstripe -L -I1 $name)
[[ "$pattern" = "$PATTERN_WITH_HOLE" ]] ||
error "(8.2.1) expect pattern flag hole, but got $pattern"
- pattern=$($LFS getstripe -L -I 2 $name)
+ pattern=$($LFS getstripe -L -I2 $name)
[[ "$pattern" = "$PATTERN_WITH_HOLE" ]] ||
error "(8.2.2) expect pattern flag hole, but got $pattern"
- stripes=$($LFS getstripe -c -I 1 $name)
+ stripes=$($LFS getstripe -c -I1 $name)
[ $stripes -eq 2 ] ||
error "(8.3.2) expect 2 stripes, but got $stripes"
- stripes=$($LFS getstripe -c -I 2 $name)
+ stripes=$($LFS getstripe -c -I2 $name)
[ $stripes -eq 2 ] ||
error "(8.3.2) expect 2 stripes, but got $stripes"
- e_start=$($LFS getstripe -I 1 $name |
+ e_start=$($LFS getstripe -I1 $name |
awk '/lcme_extent.e_start:/ { print $2 }')
[ $e_start -eq 0 ] ||
error "(8.4.1) expect the COMP1 start at 0, got $e_start"
- e_end=$($LFS getstripe -I 1 $name |
+ e_end=$($LFS getstripe -I1 $name |
awk '/lcme_extent.e_end:/ { print $2 }')
[ $e_end -eq 2097152 ] ||
error "(8.4.2) expect the COMP1 end at 2097152, got $e_end"
- e_start=$($LFS getstripe -I 2 $name |
+ e_start=$($LFS getstripe -I2 $name |
awk '/lcme_extent.e_start:/ { print $2 }')
[ $e_start -eq 2097152 ] ||
error "(8.5.1) expect the COMP2 start at 2097152, got $e_start"
- e_end=$($LFS getstripe -I 2 $name |
+ e_end=$($LFS getstripe -I2 $name |
awk '/lcme_extent.e_end:/ { print $2 }')
[ "$e_end" = "EOF" ] ||
error "(8.5.2) expect the COMP2 end at (EOF), got $e_end"
$LFS getstripe -v $name || error "(9.1) cannot getstripe on $name"
- pattern=$($LFS getstripe -L -I 1 $name)
+ pattern=$($LFS getstripe -L -I1 $name)
[[ "$pattern" = "$PATTERN_WITH_HOLE" ]] ||
error "(9.2.1) expect pattern flag hole, but got $pattern"
- pattern=$($LFS getstripe -L -I 2 $name)
+ pattern=$($LFS getstripe -L -I2 $name)
[[ "$pattern" = "$PATTERN_WITH_HOLE" ]] ||
error "(9.2.2) expect pattern flag hole, but got $pattern"
- stripes=$($LFS getstripe -c -I 1 $name)
+ stripes=$($LFS getstripe -c -I1 $name)
[ $stripes -eq 2 ] ||
error "(9.3.2) expect 2 stripes, but got $stripes"
- stripes=$($LFS getstripe -c -I 2 $name)
+ stripes=$($LFS getstripe -c -I2 $name)
[ $stripes -eq 2 ] ||
error "(9.3.2) expect 2 stripes, but got $stripes"
- e_start=$($LFS getstripe -I 1 $name |
+ e_start=$($LFS getstripe -I1 $name |
awk '/lcme_extent.e_start:/ { print $2 }')
[ $e_start -eq 0 ] ||
error "(9.4.1) expect the COMP1 start at 0, got $e_start"
- e_end=$($LFS getstripe -I 1 $name |
+ e_end=$($LFS getstripe -I1 $name |
awk '/lcme_extent.e_end:/ { print $2 }')
[ $e_end -eq 2097152 ] ||
error "(9.4.2) expect the COMP1 end at 2097152, got $e_end"
- e_start=$($LFS getstripe -I 2 $name |
+ e_start=$($LFS getstripe -I2 $name |
awk '/lcme_extent.e_start:/ { print $2 }')
[ $e_start -eq 2097152 ] ||
error "(9.5.1) expect the COMP2 start at 2097152, got $e_start"
- e_end=$($LFS getstripe -I 2 $name |
+ e_end=$($LFS getstripe -I2 $name |
awk '/lcme_extent.e_end:/ { print $2 }')
[ "$e_end" = "EOF" ] ||
error "(9.5.2) expect the COMP2 end at (EOF), got $e_end"
#instantiate all components, so that objs are allocted
dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
- local ost_idx1=$($LFS getstripe -I 1 -i $comp_file)
- local ost_idx2=$($LFS getstripe -I 2 -i $comp_file)
+ local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
+ local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
[ $ost_idx1 -eq $ost_idx2 ] && error "$ost_idx1 == $ost_idx2"
#instantiate all components, so that objs are allocted
dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
- local ost_idx1=$($LFS getstripe -I 1 -i $comp_file)
- local ost_idx2=$($LFS getstripe -I 2 -i $comp_file)
+ local ost_idx1=$($LFS getstripe -I1 -i $comp_file)
+ local ost_idx2=$($LFS getstripe -I2 -i $comp_file)
[ $ost_idx1 -ne $ost_idx2 ] && error "$ost_idx1 != $ost_idx2"
#instantiate all components, so that objs are allocted
dd if=/dev/zero of=$comp_file bs=1k count=1 seek=65k
- local ost_idx=$($LFS getstripe -I 1 -i $comp_file)
+ local ost_idx=$($LFS getstripe -I1 -i $comp_file)
[ $ost_idx -ne 0 ] &&
error "component 1 ost_idx $ost_idx != 0"
- ost_idx=$($LFS getstripe -I 2 -i $comp_file)
+ ost_idx=$($LFS getstripe -I2 -i $comp_file)
[ $ost_idx -ne 0 ] &&
error "component 2 ost_idx $ost_idx != 0"
-E -1 -c 4 -S 4M $parent ||
error "Set default layout to $parent failed"
- sh rundbench -C -D $parent 2 || error "debench failed"
+ sh rundbench -C -D $parent 2 || error "dbench failed"
rm -fr $parent || error "Delete dir $parent failed"
}
-run_test 8 "Run debench over composite files"
+run_test 8 "Run dbench over composite files"
test_9() {
local comp_file=$DIR/$tdir/$tfile
# instantiate the 2nd component
dd if=/dev/zero of=$comp_file bs=1k count=1 seek=2k
- local f1=$($LFS getstripe -I 2 $comp_file |
+ local f1=$($LFS getstripe -I2 $comp_file |
awk '/l_fid:/ {print $7}')
echo "before MDS recovery, the ost fid of 2nd component is $f1"
fail $SINGLEMDS
- local f2=$($LFS getstripe -I 2 $comp_file |
+ local f2=$($LFS getstripe -I2 $comp_file |
awk '/l_fid:/ {print $7}')
echo "after MDS recovery, the ost fid of 2nd component is $f2"
[ $f1 == $f2 ] || error "$f1 != $f2"
$LFS setstripe -E 1m -E 2m -E 3m -E -1 $comp_file ||
error "Create $comp_file failed"
- local f1=$($LFS getstripe -I 1 $comp_file | grep "l_fid")
+ local f1=$($LFS getstripe -I1 $comp_file | grep "l_fid")
[[ -z $f1 ]] && error "1: 1st component uninstantiated"
- local f2=$($LFS getstripe -I 2 $comp_file | grep "l_fid")
+ local f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
[[ -n $f2 ]] && error "1: 2nd component instantiated"
- local f3=$($LFS getstripe -I 3 $comp_file | grep "l_fid")
+ local f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
[[ -n $f3 ]] && error "1: 3rd component instantiated"
- local f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid")
+ local f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
[[ -n $f4 ]] && error "1: 4th component instantiated"
# the first 2 components instantiated
$TRUNCATE $comp_file $((1024*1024*1+1))
- f2=$($LFS getstripe -I 2 $comp_file | grep "l_fid")
+ f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
[[ -z $f2 ]] && error "2: 2nd component uninstantiated"
- f3=$($LFS getstripe -I 3 $comp_file | grep "l_fid")
+ f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
[[ -n $f3 ]] && error "2: 3rd component instantiated"
- f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid")
+ f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
[[ -n $f4 ]] && error "2: 4th component instantiated"
# the first 3 components instantiated
$TRUNCATE $comp_file $((1024*1024*3))
$TRUNCATE $comp_file $((1024*1024*1+1))
- f2=$($LFS getstripe -I 2 $comp_file | grep "l_fid")
+ f2=$($LFS getstripe -I2 $comp_file | grep "l_fid")
[[ -z $f2 ]] && error "2: 2nd component uninstantiated"
- f3=$($LFS getstripe -I 3 $comp_file | grep "l_fid")
+ f3=$($LFS getstripe -I3 $comp_file | grep "l_fid")
[[ -z $f3 ]] && error "3: 3rd component uninstantiated"
- f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid")
+ f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
[[ -n $f4 ]] && error "3: 4th component instantiated"
# all 4 components instantiated, using append write
rwv -f $comp_file -w -a -n 2 $((1024*1023)) 1
ls -l $comp_file
- f4=$($LFS getstripe -I 4 $comp_file | grep "l_fid")
+ f4=$($LFS getstripe -I4 $comp_file | grep "l_fid")
[[ -z $f4 ]] && error "4: 4th component uninstantiated"
return 0
" [--pool|-p] [--stripe-size|-S] [--directory|-d]\n"
" [--mdt|-m] [--recursive|-r] [--raw|-R] [--yaml|-y]\n"
" [--layout|-L] [--fid|-F] [--generation|-g]\n"
- " [--component-id|-I [comp_id]]\n"
- " [--component-flags [comp_flags]]\n"
- " [--component-count [comp_count]]\n"
- " [--component-start [comp_start]]\n"
- " [--component-end|-E [comp_end]]\n"
+ " [--component-id[=comp_id]|-I[comp_id]]\n"
+ " [--component-flags[=comp_flags]]\n"
+ " [--component-count]\n"
+ " [--component-start[=[+-]comp_start]]\n"
+ " [--component-end[=[+-]comp_end]|-E[[+-]comp_end]]\n"
" <directory|filename> ..."},
{"setdirstripe", lfs_setdirstripe, 0,
"To create a striped directory on a specified MDT. This can only\n"
return -EINVAL;
}
- /* Current component of 'head' should be tail of component list. */
+ /* 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;
+ }
+
rc = llapi_layout_comp_extent_get(head, &start, &prev_end);
if (rc) {
fprintf(stderr, "Get prev extent failed. %s\n",
return 0;
}
+static inline bool arg_is_eof(char *arg)
+{
+ return !strncmp(arg, "-1", strlen("-1")) ||
+ !strncmp(arg, "EOF", strlen("EOF")) ||
+ !strncmp(arg, "eof", strlen("eof"));
+}
+
enum {
LFS_POOL_OPT = 3,
LFS_COMP_COUNT_OPT,
setstripe_args_init(&lsa);
}
- if (!strncmp(optarg, "-1", strlen("-1")) ||
- !strncmp(optarg, "EOF", strlen("EOF")) ||
- !strncmp(optarg, "eof", strlen("eof"))) {
+ if (arg_is_eof(optarg)) {
lsa.lsa_comp_end = LUSTRE_EOF;
} else {
result = llapi_parse_size(optarg,
break;
case 'I':
comp_id = strtoul(optarg, &end, 0);
- if (*end != '\0' || comp_id == 0) {
+ if (*end != '\0' || comp_id == 0 ||
+ comp_id > LCME_ID_MAX) {
fprintf(stderr, "error: %s: bad comp ID "
"'%s'\n", argv[0], optarg);
goto error;
goto error;
}
- /* support --component-id option for migrate later. */
- if (migrate_mode && comp_id != 0) {
- fprintf(stderr, "error: %s: -I isn't supported yet.\n",
- argv[0]);
+ if (!comp_del && !comp_set && comp_id != 0) {
+ fprintf(stderr, "error: %s: -I can only be used with "
+ "--component-del.\n", argv[0]);
goto error;
}
break;
case LFS_COMP_FLAGS_OPT:
rc = comp_name2flags(¶m.fp_comp_flags, optarg);
- if (rc) {
+ if (rc || comp_flags_is_neg(param.fp_comp_flags)) {
fprintf(stderr, "error: bad component flags "
"'%s'\n", optarg);
goto err;
optarg++;
}
- rc = llapi_parse_size(optarg, ¶m.fp_comp_end,
- ¶m.fp_comp_end_units, 0);
+ if (arg_is_eof(optarg)) {
+ param.fp_comp_end = LUSTRE_EOF;
+ param.fp_comp_end_units = 1;
+ rc = 0;
+ } else {
+ rc = llapi_parse_size(optarg,
+ ¶m.fp_comp_end,
+ ¶m.fp_comp_end_units, 0);
+ }
if (rc) {
fprintf(stderr, "error: bad component end "
"'%s'\n", optarg);
struct option long_opts[] = {
{"comp-count", no_argument, 0, LFS_COMP_COUNT_OPT},
{"component-count", no_argument, 0, LFS_COMP_COUNT_OPT},
- {"comp-flags", required_argument, 0, LFS_COMP_FLAGS_OPT},
- {"component-flags", required_argument, 0, LFS_COMP_FLAGS_OPT},
- {"comp-start", required_argument, 0, LFS_COMP_START_OPT},
- {"component-start", required_argument, 0, LFS_COMP_START_OPT},
+ {"comp-flags", optional_argument, 0, LFS_COMP_FLAGS_OPT},
+ {"component-flags", optional_argument, 0, LFS_COMP_FLAGS_OPT},
+ {"comp-start", optional_argument, 0, LFS_COMP_START_OPT},
+ {"component-start", optional_argument, 0, LFS_COMP_START_OPT},
#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 59, 0)
/* This formerly implied "stripe-count", but was explicitly
* made "stripe-count" for consistency with other options,
{"stripe_count", no_argument, 0, 'c'},
{"directory", no_argument, 0, 'd'},
{"default", no_argument, 0, 'D'},
- {"comp-end", required_argument, 0, 'E'},
- {"component-end", required_argument, 0, 'E'},
+ {"comp-end", optional_argument, 0, 'E'},
+ {"component-end", optional_argument, 0, 'E'},
{"fid", no_argument, 0, 'F'},
{"generation", no_argument, 0, 'g'},
/* dirstripe {"mdt-hash", required_argument, 0, 'H'}, */
#endif
{"stripe-index", no_argument, 0, 'i'},
{"stripe_index", no_argument, 0, 'i'},
- {"comp-id", required_argument, 0, 'I'},
- {"component-id", required_argument, 0, 'I'},
+ {"comp-id", optional_argument, 0, 'I'},
+ {"component-id", optional_argument, 0, 'I'},
{"layout", no_argument, 0, 'L'},
{"mdt", no_argument, 0, 'm'},
{"mdt-index", no_argument, 0, 'm'},
int c, rc;
char *end, *tmp;
- while ((c = getopt_long(argc, argv, "cdDE:FghiI:LmMoO:pqrRsSvy",
+ while ((c = getopt_long(argc, argv, "cdDE::FghiI::LmMoO:pqrRsSvy",
long_opts, NULL)) != -1) {
switch (c) {
case 'c':
break;
case LFS_COMP_FLAGS_OPT:
if (optarg != NULL) {
- rc = comp_name2flags(¶m->fp_comp_flags,
- optarg);
+ __u32 *flags = ¶m->fp_comp_flags;
+ rc = comp_name2flags(flags, optarg);
if (rc != 0) {
- param->fp_verbose |=
- VERBOSE_COMP_FLAGS;
- param->fp_max_depth = 0;
- optind--;
+ fprintf(stderr, "error: %s bad "
+ "component flags '%s'.\n",
+ argv[0], optarg);
+ return CMD_HELP;
} else {
param->fp_check_comp_flags = 1;
+ param->fp_exclude_comp_flags =
+ comp_flags_is_neg(*flags);
+ comp_flags_clear_neg(flags);
}
} else {
param->fp_verbose |= VERBOSE_COMP_FLAGS;
if (optarg != NULL) {
tmp = optarg;
if (tmp[0] == '+') {
- param->fp_comp_start_sign = 1;
+ param->fp_comp_start_sign = -1;
tmp++;
} else if (tmp[0] == '-') {
- param->fp_comp_start_sign = -1;
+ param->fp_comp_start_sign = 1;
tmp++;
}
rc = llapi_parse_size(tmp,
¶m->fp_comp_start,
¶m->fp_comp_start_units, 0);
if (rc != 0) {
- param->fp_verbose |= VERBOSE_COMP_START;
- param->fp_max_depth = 0;
- optind--;
+ fprintf(stderr, "error: %s bad "
+ "component start '%s'.\n",
+ argv[0], tmp);
+ return CMD_HELP;
} else {
param->fp_check_comp_start = 1;
}
if (optarg != NULL) {
tmp = optarg;
if (tmp[0] == '+') {
- param->fp_comp_end_sign = 1;
+ param->fp_comp_end_sign = -1;
tmp++;
} else if (tmp[0] == '-') {
- param->fp_comp_end_sign = -1;
+ param->fp_comp_end_sign = 1;
tmp++;
}
- rc = llapi_parse_size(tmp,
+
+ if (arg_is_eof(tmp)) {
+ param->fp_comp_end = LUSTRE_EOF;
+ param->fp_comp_end_units = 1;
+ rc = 0;
+ } else {
+ rc = llapi_parse_size(tmp,
¶m->fp_comp_end,
¶m->fp_comp_end_units, 0);
+ }
if (rc != 0) {
- param->fp_verbose |= VERBOSE_COMP_END;
- param->fp_max_depth = 0;
- optind--;
- } else {
- param->fp_check_comp_end = 1;
+ fprintf(stderr, "error: %s bad "
+ "component end '%s'.\n",
+ argv[0], tmp);
+ return CMD_HELP;
}
+ param->fp_check_comp_end = 1;
} else {
param->fp_verbose |= VERBOSE_COMP_END;
param->fp_max_depth = 0;
case 'I':
if (optarg != NULL) {
param->fp_comp_id = strtoul(optarg, &end, 0);
- if (*end != '\0') {
- param->fp_verbose |= VERBOSE_COMP_ID;
- param->fp_max_depth = 0;
- optind--;
+ if (*end != '\0' || param->fp_comp_id == 0 ||
+ param->fp_comp_id > LCME_ID_MAX) {
+ fprintf(stderr, "error: %s bad "
+ "component id '%s'\n",
+ argv[0], optarg);
+ return CMD_HELP;
} else {
param->fp_check_comp_id = 1;
}
return true;
}
+static int find_comp_end_cmp(unsigned long long end, struct find_param *param)
+{
+ int match;
+
+ if (param->fp_comp_end == LUSTRE_EOF) {
+ if (param->fp_comp_end_sign == 0) /* equal to EOF */
+ match = end == LUSTRE_EOF ? 1 : -1;
+ else if (param->fp_comp_end_sign > 0) /* at most EOF */
+ match = end == LUSTRE_EOF ? -1 : 1;
+ else /* at least EOF */
+ match = -1;
+ if (param->fp_exclude_comp_end)
+ match = ~match + 1;
+ } else {
+ unsigned long long margin;
+
+ margin = end == LUSTRE_EOF ? 0 : param->fp_comp_end_units;
+ match = find_value_cmp(end, param->fp_comp_end,
+ param->fp_comp_end_sign,
+ param->fp_exclude_comp_end, margin, 0);
+ }
+
+ return match;
+}
+
/**
* An example of "getstripe -v" for a two components PFL file:
*
for (i = 0; i < comp_v1->lcm_entry_count; i++) {
entry = &comp_v1->lcm_entries[i];
- if (param->fp_check_comp_flags &&
- !(param->fp_comp_flags & entry->lcme_flags))
- continue;
+ if (param->fp_check_comp_flags) {
+ if ((param->fp_exclude_comp_flags &&
+ (param->fp_comp_flags & entry->lcme_flags)) ||
+ (!param->fp_exclude_comp_flags &&
+ !(param->fp_comp_flags & entry->lcme_flags)))
+ continue;
+ }
if (param->fp_check_comp_id &&
param->fp_comp_id != entry->lcme_id)
}
if (param->fp_check_comp_end) {
- unsigned long long margin;
-
- margin = entry->lcme_extent.e_end == LUSTRE_EOF ?
- 0 : param->fp_comp_end_units;
-
- match = find_value_cmp(entry->lcme_extent.e_end,
- param->fp_comp_end,
- param->fp_comp_end_sign,
- 0, margin, 0);
+ match = find_comp_end_cmp(entry->lcme_extent.e_end,
+ param);
if (match == -1)
continue;
}
if (param->fp_check_comp_end) {
for (i = 0; i < comp_v1->lcm_entry_count; i++) {
- unsigned long long margin;
entry = &comp_v1->lcm_entries[i];
- margin = entry->lcme_extent.e_end == LUSTRE_EOF ?
- 0 : param->fp_comp_end_units;
-
- ret = find_value_cmp(entry->lcme_extent.e_end,
- param->fp_comp_end,
- param->fp_comp_end_sign,
- param->fp_exclude_comp_end, margin,
- 0);
+ ret = find_comp_end_cmp(entry->lcme_extent.e_end,
+ param);
/* If any extent end matches */
if (ret != -1)
break;