From: Andreas Dilger Date: Fri, 10 Apr 2020 10:48:51 +0000 (-0600) Subject: LU-13314 utils: fix lfs find time calculation margin X-Git-Tag: 2.13.56~69 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=7e0208da21f9358d96feebce5124f8587778c318 LU-13314 utils: fix lfs find time calculation margin Allow a larger margin when checking files that are years old. Re-enable sanity test_56ob. Signed-off-by: Andreas Dilger Change-Id: Id74e4b737ebb3a2b721d3e3b6d79dffe703ebbe5 Reviewed-on: https://review.whamcloud.com/39433 Tested-by: jenkins Reviewed-by: Jian Yu Reviewed-by: Yingjin Qian Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/doc/lfs-find.1 b/lustre/doc/lfs-find.1 index ab4271b..063f6d9 100644 --- a/lustre/doc/lfs-find.1 +++ b/lustre/doc/lfs-find.1 @@ -54,9 +54,9 @@ OST and MDT location, and composite layout attributes. .BR --atime | -A File was last accessed \fIn\fR*24 hours ago (if no units are given), or \fIn\fR*\fBs\fReconds, \fBm\fRinutes, \fBh\fRours, \fBd\fRays, -\fBw\fReeks, or \fBy\fRears ago within a margin of error of 24h, -or smaller if a unit is specified. Multiple units can be specified, -for example \fB8h20m\fR is equivalent to \fB500m\fR. If multipe units +\fBw\fReeks, or \fBy\fRears ago within a margin of error of 24h +if no unit is specified. Multiple units can be specified, +for example \fB8h20m\fR is equivalent to \fB500m\fR. If multiple units are specified, the margin of error is based on the smallest unit used, so .B -atime 3d has a margin of error of one day, while @@ -155,6 +155,10 @@ File or directory inode is located on the specified MDT(s). DNE striped directory uses the given filename hashing function, one of: .RS 1.2i .TP +.B crush +The CRUSH consistent hash function, added in Lustre 2.14, minimizes +entry migration if the directory stripe count changes during migration. +.TP .B fnv_1a_64 The Fowler\-Noll\-Vo hash function, which is a simple and efficient hash. .TP @@ -202,7 +206,7 @@ standard .BR glob (7) file name regular expressions and wildcards. .TP -.BR -newer [ XY "] " \fIreference +.BR --newer [ XY "] " \fIreference Succeeds if timestamp \fIX\fR of the file being considered is newer than timestamp \fIY\fR of the file .IR reference . @@ -384,5 +388,5 @@ command is part of the Lustre filesystem. .BR lfs-getdirstripe (1), .BR lfs-migrate (1), .BR lfs_migrate (1), -.BR lustre (7) +.BR lustre (7), .BR xargs (1) diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index 0fd2034..d168bd3 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -41,8 +41,8 @@ init_logging ALWAYS_EXCEPT="$SANITY_EXCEPT " # bug number for skipped test: LU-9693 LU-6493 LU-9693 ALWAYS_EXCEPT+=" 42a 42b 42c " -# bug number: LU-8411 LU-9054 LU-13314 -ALWAYS_EXCEPT+=" 407 312 56ob" +# bug number: LU-8411 LU-9054 +ALWAYS_EXCEPT+=" 407 312" if $SHARED_KEY; then # bug number: LU-9795 LU-9795 LU-9795 LU-9795 @@ -5919,7 +5919,7 @@ test_56ob() { cmd="$LFS find $dir -ctime +1s -type f" nums=$($cmd | wc -l) (( $nums == $count * 2 + 1)) || - error "'$cmd' wrong: found $nums, expected $((expected*2+1))" + error "'$cmd' wrong: found $nums, expected $((count * 2 + 1))" } run_test 56ob "check lfs find -atime -mtime -ctime with units" diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index ed31744..64d5f88 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -4137,20 +4137,21 @@ static int lfs_poollist(int argc, char **argv) return llapi_poollist(argv[1]); } +#define FP_DEFAULT_TIME_MARGIN (24 * 60 * 60) static time_t set_time(struct find_param *param, time_t *time, time_t *set, char *str) { long long t = 0; - int res = 0; + int sign = 0; char *endptr = "AD"; char *timebuf; if (str[0] == '+') - res = 1; + sign = 1; else if (str[0] == '-') - res = -1; + sign = -1; - if (res) + if (sign) str++; for (timebuf = str; *endptr && *(endptr + 1); timebuf = endptr + 1) { @@ -4162,9 +4163,12 @@ static time_t set_time(struct find_param *param, time_t *time, time_t *set, unit *= 52; /* 52 weeks + 1 day below */ case 'w': /* fallthrough */ unit *= 7; + if (param->fp_time_margin == FP_DEFAULT_TIME_MARGIN) + param->fp_time_margin *= (1 + unit / 52); + unit += (*endptr == 'y'); /* +1 day for 365 days/year */ case '\0': /* days are default unit if none used */ case 'd': /* fallthrough */ - unit = (unit + (*endptr == 'y')) * 24; + unit *= 24; case 'h': /* fallthrough */ unit *= 60; case 'm': /* fallthrough */ @@ -4186,7 +4190,7 @@ static time_t set_time(struct find_param *param, time_t *time, time_t *set, t += val * unit; } if (*time < t) { - if (res != 0) + if (sign != 0) str--; fprintf(stderr, "%s find: bad time '%s': too large\n", progname, str); @@ -4195,7 +4199,7 @@ static time_t set_time(struct find_param *param, time_t *time, time_t *set, *set = *time - t; - return res; + return sign; } static int str2quotaid(__u32 *id, const char *arg) @@ -4298,7 +4302,7 @@ static int lfs_find(int argc, char **argv) struct find_param param = { .fp_max_depth = -1, .fp_quiet = 1, - .fp_time_margin = 24 * 60 * 60, + .fp_time_margin = FP_DEFAULT_TIME_MARGIN, }; struct option long_opts[] = { { .val = 'A', .name = "atime", .has_arg = required_argument },