Whamcloud - gitweb
LU-17263 utils: 'lfs find -size' to use 512-byte units 94/52994/6
authorAndreas Dilger <adilger@whamcloud.com>
Sun, 5 Nov 2023 05:44:02 +0000 (23:44 -0600)
committerOleg Drokin <green@whamcloud.com>
Wed, 20 Dec 2023 01:56:24 +0000 (01:56 +0000)
Change the 'lfs find -size' argument to 512-byte blocks by default if
no unit is given.  This better matches find(1) and avoids confusion
when converting "find" arguments to "lfs find".  Accept the 'c' suffix
like find(1) to specify a number of characters (bytes).

Most users/scripts will specify a unit, so it is expected not to cause
significant upset with this change.

Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I3124e667acc06928f41a3d3006e1d9b4a43ebbe5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52994
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Anjus George <georgea@ornl.gov>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/doc/lfs-find.1
lustre/tests/sanity.sh
lustre/utils/lfs.c

index d9f8726..bfd7f3d 100644 (file)
@@ -422,7 +422,8 @@ instantiated component.
 File has specified numeric project ID.
 .TP
 .BR --size | -s
-File size is \fIn\fR bytes, or \fBK\fRibi-, \fBM\fRebi-,
+File size is \fIn\fR 512-byte blocks (if no unit is given), or
+\fIn\fR \fBc\fRhars (bytes), \fBK\fRibi-, \fBM\fRebi-,
 \fBG\fRibi-, \fBT\fRebi-, \fBP\fRebi-, or \fBE\fRbi-bytes if a
 suffix is given.
 .TP
index d99d0b6..3dd3351 100755 (executable)
@@ -7112,21 +7112,21 @@ test_56r() {
        echo "test" > $dir/$tfile
        echo "test2" > $dir/$tfile.2 && sync
        expected=1
-       cmd="$LFS find -size 5 -type f -lazy $dir"
+       cmd="$LFS find -size 5c -type f -lazy $dir"
        nums=$($cmd | wc -l)
        [ $nums -eq $expected ] ||
                error "'$cmd' wrong: found $nums, expected $expected"
-       cmd="$LFS find -size 5 -type f $dir"
+       cmd="$LFS find -size 5c -type f $dir"
        nums=$($cmd | wc -l)
        [ $nums -eq $expected ] ||
                error "'$cmd' wrong: found $nums, expected $expected"
 
        expected=1
-       cmd="$LFS find -size +5 -type f -lazy $dir"
+       cmd="$LFS find -size +5c -type f -lazy $dir"
        nums=$($cmd | wc -l)
        [ $nums -eq $expected ] ||
                error "'$cmd' wrong: found $nums, expected $expected"
-       cmd="$LFS find -size +5 -type f $dir"
+       cmd="$LFS find -size +5c -type f $dir"
        nums=$($cmd | wc -l)
        [ $nums -eq $expected ] ||
                error "'$cmd' wrong: found $nums, expected $expected"
@@ -7142,21 +7142,21 @@ test_56r() {
                error "'$cmd' wrong: found $nums, expected $expected"
 
        expected=2
-       cmd="$LFS find ! -size -5 -type f -lazy $dir"
+       cmd="$LFS find ! -size -5c -type f -lazy $dir"
        nums=$($cmd | wc -l)
        [ $nums -eq $expected ] ||
                error "'$cmd' wrong: found $nums, expected $expected"
-       cmd="$LFS find ! -size -5 -type f $dir"
+       cmd="$LFS find ! -size -5c -type f $dir"
        nums=$($cmd | wc -l)
        [ $nums -eq $expected ] ||
                error "'$cmd' wrong: found $nums, expected $expected"
 
        expected=12
-       cmd="$LFS find -size -5 -type f -lazy $dir"
+       cmd="$LFS find -size -5c -type f -lazy $dir"
        nums=$($cmd | wc -l)
        [ $nums -eq $expected ] ||
                error "'$cmd' wrong: found $nums, expected $expected"
-       cmd="$LFS find -size -5 -type f $dir"
+       cmd="$LFS find -size -5c -type f $dir"
        nums=$($cmd | wc -l)
        [ $nums -eq $expected ] ||
                error "'$cmd' wrong: found $nums, expected $expected"
@@ -7218,17 +7218,17 @@ test_56ra() {
        cancel_lru_locks $OSC
        cat $dir/$tfile $dir/$tfile.2 > /dev/null
 
-       test_56ra_sub  1  0 "$LFS find -size 5 -type f -lazy $dir"
-       test_56ra_sub  1 14 "$LFS find -size 5 -type f $dir"
-       test_56ra_sub  1  0 "$LFS find -size +5 -type f -lazy $dir"
-       test_56ra_sub  1 14 "$LFS find -size +5 -type f $dir"
+       test_56ra_sub  1  0 "$LFS find -size 5c -type f -lazy $dir"
+       test_56ra_sub  1 14 "$LFS find -size 5c -type f $dir"
+       test_56ra_sub  1  0 "$LFS find -size +5c -type f -lazy $dir"
+       test_56ra_sub  1 14 "$LFS find -size +5c -type f $dir"
 
        test_56ra_sub  2  0 "$LFS find -size +0 -type f -lazy $dir"
        test_56ra_sub  2 14 "$LFS find -size +0 -type f $dir"
-       test_56ra_sub  2  0 "$LFS find ! -size -5 -type f -lazy $dir"
-       test_56ra_sub  2 14 "$LFS find ! -size -5 -type f $dir"
-       test_56ra_sub 12  0 "$LFS find -size -5 -type f -lazy $dir"
-       test_56ra_sub 12 14 "$LFS find -size -5 -type f $dir"
+       test_56ra_sub  2  0 "$LFS find ! -size -5c -type f -lazy $dir"
+       test_56ra_sub  2 14 "$LFS find ! -size -5c -type f $dir"
+       test_56ra_sub 12  0 "$LFS find -size -5c -type f -lazy $dir"
+       test_56ra_sub 12 14 "$LFS find -size -5c -type f $dir"
 }
 run_test 56ra "check lfs find -size -lazy works for data on OSTs"
 
index c81df64..c212c5e 100644 (file)
@@ -5880,6 +5880,7 @@ err_free:
                                optarg++;
                        }
 
+                       param.fp_size_units = 512;
                        ret = llapi_parse_size(optarg, &param.fp_size,
                                               &param.fp_size_units, 0);
                        if (ret) {