[\fB--printf\fR \fIFORMAT\fR]
[[\fB!\fR] \fB--projid\fR \fIPROJID\fR]
[[\fB!\fR] \fB--size|\fB-s\fR [\fB-+\fR]\fIn\fR[\fBKMGTPE\fR]]
+ [\fB--skip\fR|\fB-k]\fR \fIPERCENT\fR]
[[\fB!\fR] \fB--stripe-count|\fB-c\fR [\fB+-\fR]\fIn\fR]
[[\fB!\fR] \fB--stripe-index|\fB-i\fR \fIn\fR,...]
[[\fB!\fR] \fB--stripe-size|\fB-S\fR [\fB+-\fR]\fIn\fR[\fBKMG\fR]]
\fBG\fRibi-, \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-bytes if a
suffix is given.
.TP
+.BR --skip | -k
+Skip \fIPERCENT\fR of the total that match the other filters. This is
+useful together with
+.BR lfs-migrate (1)
+to allow processing only a fraction of the files to rebalance files when new
+OSTs are added to the filesystem.
+.TP
.BR --stripe-count | -c
File has \fIn\fR stripes allocated. For composite files, this
matches the stripe count of the last initialized component.
[\fB--print\fR|\fB-P\fR] [\fB--print0\fR|\fB-0\fR]
[[\fB!\fR] \fB--projid\fR |<\fIprojid\fR>]
[[\fB!\fR] \fB--size|\fB-s\fR [\fB-+\fR]\fIn\fR[\fBKMGTPE\fR]]
+ [\fB--skip\fR|\fB-k]\fR \fIn\fR]
[[\fB!\fR] \fB--stripe-count\fR|\fB-c\fR [\fB+-\fR]\fIn\fR]
[[\fB!\fR] \fB--stripe-index\fR|\fB-i\fR \fIn\fR,...]
[[\fB!\fR] \fB--extension-size\fR|\fB-ext-size\fR|\fB-z\fR [\fB+-\fR]\fIn\fR[\fBKMG\fR]]
__u64 fp_attrs;
__u64 fp_neg_attrs;
struct xattr_match_info *fp_xattr_match_info;
+ unsigned long int fp_skip_percent;
+ unsigned long long fp_skip_total;
+ unsigned long long fp_skip_count;
};
int llapi_ostlist(char *path, struct find_param *param);
}
run_test 56eg "lfs find -xattr"
+test_56eh() {
+ local dir=$DIR/d$(basetest $testnum)g.$TESTSUITE
+
+ setup_56_special $dir $NUMFILES $NUMDIRS
+
+ local cmd="$LFS find $dir"
+ local total=$($cmd | wc -l)
+ local n=1
+
+ local nums
+
+ echo "Running tests on $dir, with $total total results."
+
+ while (( $n < 100 )); do
+ nums=$($LFS find --skip=$((100 - $n)) $dir | wc -l)
+ (( $nums <= $(($total * ($n + 5) / 100)) &&
+ $nums >= $(($total * ($n - 5) / 100)) )) ||
+ error "--skip=$((100 - $n)): expected $(($total * $n / 100)) results with 5% error margin, got $nums"
+ (( n++ ))
+ done
+}
+run_test 56eh "check lfs find --skip"
+
test_57a() {
[ $PARALLEL == "yes" ] && skip "skip parallel run"
# note test will not do anything if MDS is not local
" [[!] --ost|-O <uuid|index,...>] [[!] --perm [/-]mode]\n"
" [[!] --pool <pool>] [--print|-P] [--print0|-0] [--printf <format>]\n"
" [[!] --projid <projid>] [[!] --size|-s [+-]N[bkMGTPE]]\n"
- " [[!] --stripe-count|-c [+-]<stripes>]\n"
+ " [--skip|-k PERCENT] [[!] --stripe-count|-c [+-]<stripes>]\n"
" [[!] --stripe-index|-i <index,...>]\n"
" [[!] --stripe-size|-S [+-]N[kMGT]] [[!] --type|-t <filetype>]\n"
" [[!] --uid|-u|--user|-U <uid>|<uname>]\n"
{ .val = 'i', .name = "stripe-index", .has_arg = required_argument },
{ .val = 'i', .name = "stripe_index", .has_arg = required_argument },
/* getstripe { .val = 'I', .name = "comp-id", .has_arg = required_argument }*/
+ { .val = 'k', .name = "skip", .has_arg = required_argument },
{ .val = 'l', .name = "lazy", .has_arg = no_argument },
{ .val = 'L', .name = "layout", .has_arg = required_argument },
{ .val = LFS_LINKS_OPT,
/* when getopt_long_only() hits '!' it returns 1, puts "!" in optarg */
while ((c = getopt_long_only(argc, argv,
- "-0A:b:B:c:C:D:E:g:G:hH:i:lL:m:M:n:N:O:Ppqrs:S:t:T:u:U:z:",
+ "-0A:b:B:c:C:D:E:g:G:hH:i:k:lL:m:M:n:N:O:Ppqrs:S:t:T:u:U:z:",
long_opts, &optidx)) >= 0) {
xtime = NULL;
xsign = NULL;
param.fp_check_hash_flag = 1;
param.fp_exclude_hash_type = !!neg_opt;
break;
+ case 'k':
+ param.fp_skip_percent = strtoul(optarg, &endptr, 10);
+ if (param.fp_skip_percent < 0 ||
+ param.fp_skip_percent >= 100 ||
+ (*endptr != '\0' && *endptr != '%')) {
+ ret = -1;
+ fprintf(stderr,
+ "error: invalid skip percentage '%s'\n",
+ optarg);
+ goto err;
+ }
+ break;
case 'l':
param.fp_lazy = 1;
break;
return 1;
}
+static bool find_skip_file(struct find_param *param)
+{
+ if (param->fp_skip_count * 100 <
+ param->fp_skip_percent * param->fp_skip_total++) {
+ param->fp_skip_count++;
+ return true;
+ }
+ return false;
+}
+
static bool find_check_lmm_info(struct find_param *param)
{
return param->fp_check_pool || param->fp_check_stripe_count ||
}
print:
+ if (param->fp_skip_percent && find_skip_file(param))
+ goto decided;
+
if (param->fp_format_printf_str)
printf_format_string(param, path, projid, d);
else