"\t--start|-s: Start index of file names\n"
"\t--end|-e: End index of file names\n"
"\t--basename|-b:Base name for file naming format\n"
+ "\t--noadvise|-N:No ahead advise hint IOCTL\n"
"\t--batch_max|-B: max batch count for ahead operations\n"
"\t--directory|-d: under this directory do ahead operations\n",
progname);
return filename;
}
+static int ll_batch_io_by_name(const char *dirpath, const char *fname,
+ enum lu_access_flags flags, __u64 start,
+ __u64 end)
+{
+ int rc = 0;
+ int i;
+
+ for (i = start; i < end; i++) {
+ char *filename;
+ struct stat st;
+
+ filename = get_file_name(dirpath, fname, i);
+ if (flags & ACCESS_FL_STAT) {
+ rc = stat(filename, &st);
+ if (rc < 0) {
+ rc = -errno;
+ fprintf(stderr,
+ "%s: stat(%s) failed: rc = %d\n",
+ progname, filename, errno);
+ break;
+ }
+ }
+ }
+
+ return rc;
+}
+
static int ll_ahead_by_name_index(const char *dirpath, const char *fname,
enum lu_access_flags flags, __u64 start,
__u64 end, __u32 batch_max)
{
struct llapi_lu_ladvise2 ladvise;
- struct stat st;
int dir_fd;
int rc;
- int i;
dir_fd = open(dirpath, O_DIRECTORY | O_RDONLY);
if (dir_fd < 0) {
return rc;
}
- for (i = start; i < end; i++) {
- char *filename;
-
- filename = get_file_name(dirpath, fname, i);
- rc = stat(filename, &st);
- if (rc < 0) {
- rc = -errno;
- fprintf(stderr, "%s: stat(%s) failed: rc = %d\n",
- progname, filename, errno);
- break;
- }
- }
-
+ rc = ll_batch_io_by_name(dirpath, fname, flags, start, end);
close(dir_fd);
return rc;
}
{ .val = 'b', .name = "basename", .has_arg = required_argument },
{ .val = 'd', .name = "directory", .has_arg = required_argument },
{ .val = 'B', .name = "batch_max", .has_arg = required_argument },
+ { .val = 'N', .name = "noadvise", .has_arg = no_argument },
{ .val = 'h', .name = "help", .has_arg = no_argument },
{ .name = NULL } };
enum lu_access_flags flags = ACCESS_FL_NONE;
char *fname = NULL;
__u64 start_index = 0;
__u64 end_index = 0;
+ bool has_advise = true;
char *end;
int rc = 0;
int c;
progname = basename(argv[0]);
- while ((c = getopt_long(argc, argv, "c:s:e:b:d:B:h",
+ while ((c = getopt_long(argc, argv, "c:s:e:b:d:B:Nh",
long_opts, NULL)) != -1) {
switch (c) {
case 'c':
return -EINVAL;
}
break;
+ case 'N':
+ has_advise = false;
+ break;
case 'b':
fname = optarg;
break;
return -EINVAL;
}
- rc = ll_ahead_by_name_index(dirpath, fname, flags, start_index,
- end_index, batch_max);
+ if (has_advise)
+ rc = ll_ahead_by_name_index(dirpath, fname, flags,
+ start_index, end_index,
+ batch_max);
+ else
+ rc = ll_batch_io_by_name(dirpath, fname, flags,
+ start_index, end_index);
} else {
rc = -EOPNOTSUPP;
fprintf(stderr, "%s: unsupported ahead type %d\n",
}
run_test 123h "Verify statahead work with the fname pattern via du"
-test_123i() {
+test_123i_base() {
+ local fmt=$1
+ local iocmd=$2
local dir=$DIR/$tdir
- local cmd="createmany -m $dir/$tfile.%06d 1000"
+ local cmd="createmany -m $fmt"
- stack_trap "unlinkmany $dir/$tfile.%06d 1000"
+ echo "Command:"
+ echo "- $cmd"
+ echo "- $iocmd"
+ stack_trap "unlinkmany $fmt"
mkdir -p $dir || error "failed to mkdir $dir"
eval $cmd
$LCTL set_param llite.*.statahead_stats=clear
$LCTL set_param mdc.*.batch_stats=0
- local max
- local batch_max
- local enabled
-
- max=$($LCTL get_param -n llite.*.statahead_max | head -n 1)
- batch_max=$($LCTL get_param -n llite.*.statahead_batch_max | head -n 1)
- enabled=$($LCTL get_param -n llite.*.enable_statahead_fname | head -n 1)
- stack_trap "$LCTL set_param llite.*.statahead_max=$max"
- stack_trap "$LCTL set_param llite.*.statahead_batch_max=$batch_max"
- stack_trap "$LCTL set_param llite.*.enable_statahead_fname=$enabled"
-
- $LCTL set_param llite.*.statahead_max=1024
- $LCTL set_param llite.*.statahead_batch_max=32
- $LCTL set_param llite.*.enable_statahead_fname=1
echo "statahead_stats (Pre):"
lctl get_param -n llite.*.statahead_stats
- ls $dir/* > /dev/null
+ eval $iocmd || error "$iocmd failed"
echo "statahead_stats (Post):"
$LCTL get_param -n llite.*.statahead_stats
$LCTL get_param -n mdc.*.batch_stats
count=$($LCTL get_param -n llite.*.statahead_stats |
awk '/hit.total:/ {print $2}')
# Hit ratio should be >= 75%
- (( $count > 75 )) || error "hit total is too low: $count"
+ (( $count > 750 )) || error "hit total is too low: $count"
+}
+
+test_123i() {
+ local dir=$DIR/$tdir
+ local cnt=1000
+ local max
+ local batch_max
+ local enabled
+ local min
+
+ max=$($LCTL get_param -n llite.*.statahead_max | head -n 1)
+ batch_max=$($LCTL get_param -n llite.*.statahead_batch_max | head -n 1)
+ min=$($LCTL get_param -n llite.*.statahead_min | head -n 1)
+ enabled=$($LCTL get_param -n llite.*.enable_statahead_fname | head -n 1)
+ stack_trap "$LCTL set_param llite.*.statahead_max=$max"
+ stack_trap "$LCTL set_param llite.*.statahead_batch_max=$batch_max"
+ stack_trap "$LCTL set_param llite.*.statahead_min=$min"
+ stack_trap "$LCTL set_param llite.*.enable_statahead_fname=$enabled"
+ $LCTL set_param llite.*.statahead_max=1024
+ $LCTL set_param llite.*.statahead_batch_max=32
+ $LCTL set_param llite.*.statahead_min=64
+ $LCTL set_param llite.*.enable_statahead_fname=1
+
+ test_123i_base "$dir/$tfile.%06d $cnt" "ls $dir/* > /dev/null"
+ test_123i_base "$dir/$tfile $cnt" \
+ "aheadmany -c stat -N -s 0 -e $cnt -b $tfile -d $dir"
}
-run_test 123i "Verify statahead work with the fname pattern via ls dir/*"
+run_test 123i "Verify statahead work with the fname indexing pattern"
test_124a() {
[ $PARALLEL == "yes" ] && skip "skip parallel run"