.SH SYNOPSIS
.B lfs find \fR<\fIdirectory\fR|\fIfilename \fR...>
[[\fB!\fR] \fB--atime\fR|\fB-A\fR [\fB-+\fR]\fIn\fR]
-[[\fB!\fR] \fB--ctime\fR|\fB-C\fR [\fB+-\fR]\fIn\fR]
+[[\fB!\fR] \fB--blocks\fR|\fB-b\fR [\fB+-\fR]\fIn\fR]
+ [[\fB!\fR] \fB--ctime\fR|\fB-C\fR [\fB+-\fR]\fIn\fR]
[[\fB!\fR] \fB--component-count|\fB--comp-count\fR [\fB+-\fR]\fIn\fR]
[[\fB!\fR] \fB--component-end|\fB--comp-end\fR|\fB-E\fR [\fB+-\fR]\fIn\fR[\fBKMGTPE\fR]]
[[\fB!\fR] \fB--component-flags|\fB--comp-flags\fR <[^]\fIflag\fB,\fR...>]
.BR --atime | -A
File was last accessed \fIn\fR*24 hours ago.
.TP
+.BR --blocks | -b
+Blocks allocated by the file is \fIn\fR kibibytes (if no units are given),
+\fIn\fR 512-byte \fBb\fRlocks, or \fBK\fRibi-, \fBM\fRebi-, \fBG\fRibi-,
+\fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-bytes if that suffix is given.
+.TP
.BR --ctime | -C
File's status was last changed \fIn\fR*24 hours ago.
.TP
fp_comp_end_sign:2,
fp_comp_count_sign:2,
fp_mirror_count_sign:2,
- fp_mdt_count_sign:2;
+ fp_mdt_count_sign:2,
+ fp_blocks_sign:2;
unsigned long long fp_size;
unsigned long long fp_size_units;
fp_exclude_mdt_count:1,
fp_check_hash_type:1,
fp_exclude_hash_type:1,
- fp_yaml:1; /* output layout in YAML */
+ fp_yaml:1, /* output layout in YAML */
+ fp_check_blocks:1,
+ fp_exclude_blocks:1;
int fp_verbose;
int fp_quiet;
unsigned long long fp_comp_end_units;
unsigned long long fp_mdt_count;
unsigned fp_projid;
+ unsigned long long fp_blocks;
+ unsigned long long fp_blocks_units;
/* In-process parameters. */
unsigned long fp_got_uuids:1,
$LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
createmany -o $dir/striped_dir/${tfile}- 1024
- local dirs=$(lfs find --size +8k $dir/)
+ local dirs=$($LFS find --size +8k $dir/)
[ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
}
run_test 56aa "lfs find --size under striped dir"
+test_56ab() { # LU-10705
+ test_mkdir $DIR/$tdir
+ dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
+ dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
+ dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
+ # Flush writes to ensure valid blocks. Need to be more thorough for
+ # ZFS, since blocks are not allocated/returned to client immediately.
+ sync_all_data
+ wait_zfs_commit ost1 2
+ cancel_lru_locks osc
+ ls -ls $DIR/$tdir
+
+ local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
+
+ [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
+
+ files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
+ [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
+
+ rm -f $DIR/$tdir/$tfile.[123]
+}
+run_test 56ab "lfs find --blocks"
+
test_56ba() {
# Create composite files with one component
local dir=$DIR/$tdir
"find files matching given attributes recursively in directory tree.\n"
"usage: find <directory|filename> ...\n"
" [[!] --atime|-A [+-]N] [[!] --ctime|-C [+-]N]\n"
- " [[!] --mtime|-M [+-]N] [--maxdepth|-D N]\n"
+ " [[!] --mtime|-M [+-]N] [--maxdepth|-D N] [[!] --blocks|-b N]\n"
" [[!] --mdt-index|--mdt|-m <uuid|index,...>]\n"
" [[!] --name|-n <pattern>] [[!] --ost|-O <uuid|index,...>]\n"
" [--print|-P] [--print0|-0] [[!] --size|-s [+-]N[bkMGTPE]]\n"
};
struct option long_opts[] = {
{ .val = 'A', .name = "atime", .has_arg = required_argument },
+ { .val = 'b', .name = "blocks", .has_arg = required_argument },
{ .val = LFS_COMP_COUNT_OPT,
.name = "comp-count", .has_arg = required_argument },
{ .val = LFS_COMP_COUNT_OPT,
/* when getopt_long_only() hits '!' it returns 1, puts "!" in optarg */
while ((c = getopt_long_only(argc, argv,
- "-0A:c:C:D:E:g:G:H:i:L:m:M:n:N:O:Ppqrs:S:t:T:u:U:v",
+ "-0A:b:c:C:D:E:g:G:H:i:L:m:M:n:N:O:Ppqrs:S:t:T:u:U:v",
long_opts, NULL)) >= 0) {
xtime = NULL;
xsign = NULL;
if (rc)
*xsign = rc;
break;
+ case 'b':
+ if (optarg[0] == '+') {
+ param.fp_blocks_sign = -1;
+ optarg++;
+ } else if (optarg[0] == '-') {
+ param.fp_blocks_sign = 1;
+ optarg++;
+ }
+
+ param.fp_blocks_units = 1024;
+ ret = llapi_parse_size(optarg, ¶m.fp_blocks,
+ ¶m.fp_blocks_units, 0);
+ if (ret) {
+ fprintf(stderr, "error: bad blocks '%s'\n",
+ optarg);
+ goto err;
+ }
+ param.fp_check_blocks = 1;
+ param.fp_exclude_blocks = !!neg_opt;
+ break;
case LFS_COMP_COUNT_OPT:
if (optarg[0] == '+') {
param.fp_comp_count_sign = -1;
{
struct option long_opts[] = {
/* find { .val = 'A', .name = "atime", .has_arg = required_argument }*/
+/* find { .val = 'b', .name = "blocks", .has_arg = required_argument }*/
{ .val = LFS_COMP_COUNT_OPT,
.name = "comp-count", .has_arg = no_argument },
{ .val = LFS_COMP_COUNT_OPT,
if (param->fp_obd_uuid || param->fp_mdt_uuid ||
param->fp_check_uid || param->fp_check_gid ||
param->fp_atime || param->fp_mtime || param->fp_ctime ||
- param->fp_check_size || find_check_lmm_info(param) ||
+ param->fp_check_size || param->fp_check_blocks ||
+ find_check_lmm_info(param) ||
param->fp_check_mdt_count || param->fp_check_hash_type)
decision = 0;
The regular stat is almost of the same speed as some new
'glimpse-size-ioctl'. */
- if (param->fp_check_size && S_ISREG(st->st_mode) && stripe_count)
- decision = 0;
-
- if (param->fp_check_size && S_ISDIR(st->st_mode))
+ if ((param->fp_check_size || param->fp_check_blocks) &&
+ ((S_ISREG(st->st_mode) && stripe_count) || S_ISDIR(st->st_mode)))
decision = 0;
if (!decision) {
goto decided;
}
- if (param->fp_check_size)
+ if (param->fp_check_size) {
decision = find_value_cmp(st->st_size, param->fp_size,
param->fp_size_sign,
param->fp_exclude_size,
param->fp_size_units, 0);
+ if (decision == -1)
+ goto decided;
+ }
- if (decision != -1) {
- llapi_printf(LLAPI_MSG_NORMAL, "%s", path);
- if (param->fp_zero_end)
- llapi_printf(LLAPI_MSG_NORMAL, "%c", '\0');
- else
- llapi_printf(LLAPI_MSG_NORMAL, "\n");
+ if (param->fp_check_blocks) { /* convert st_blocks to bytes */
+ decision = find_value_cmp(st->st_blocks * 512, param->fp_blocks,
+ param->fp_blocks_sign,
+ param->fp_exclude_blocks,
+ param->fp_blocks_units, 0);
+ if (decision == -1)
+ goto decided;
}
+ llapi_printf(LLAPI_MSG_NORMAL, "%s", path);
+ if (param->fp_zero_end)
+ llapi_printf(LLAPI_MSG_NORMAL, "%c", '\0');
+ else
+ llapi_printf(LLAPI_MSG_NORMAL, "\n");
+
decided:
ret = 0;
/* Do not get down anymore? */