-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.gnu.org/licenses/gpl-2.0.html
- *
- * GPL HEADER END
- */
+// SPDX-License-Identifier: GPL-2.0
+
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
* Use is subject to license terms.
*
* Copyright (c) 2011, Intel Corporation.
+ *
*/
+
/*
* This file is part of Lustre, http://www.lustre.org/
*
* lustre/utils/llverfs.c
*
- * Filesystem Verification Tool.
- * This program tests the correct operation of large filesystems and
- * the underlying block storage device(s).
- * This tool have two working modes
- * 1. full mode
- * 2. partial mode
+ * Filesystem Verification Tool: this program tests the correct operation of
+ * large filesystems and the underlying block storage device(s). For more
+ * information, see the llverfs.8 man page.
*
- * In full mode, the program creates a subdirectory in the test
- * filesystem, writes n(files_in_dir, default=32) large(4GB) files to
- * the directory with the test pattern at the start of each 4kb block.
- * The test pattern contains timestamp, relative file offset and per
- * file unique identifier(inode number). This continues until the
- * whole filesystem is full and then the tool verifies that the data
- * in all of the test files is correct.
- *
- * In partial mode, the tool creates test directories with the
- * EXT3_TOPDIR_FL flag set (if supported) to spread the directory data
- * around the block device instead of localizing it in a single place.
- * The number of directories equals to the number of block groups in the
- * filesystem (e.g. 65536 directories for 8TB ext3/ext4 filesystem) and
- * then writes a single 1MB file in each directory. The tool then verifies
- * that the data in each file is correct.
*/
#ifndef _GNU_SOURCE
static unsigned long num_files; /* Total number of files for read/write */
static loff_t file_size = 4*ONE_GB; /* Size of each file */
static unsigned files_in_dir = 32; /* number of files in each directioy */
-static unsigned num_dirs = 30000; /* total number of directories */
+static unsigned int num_dirs; /* total number of directories */
const int dirmode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH;
static int isatty_flag;
static int perms = S_IRWXU | S_IRGRP | S_IROTH;
{ .val = 'h', .name = "help", .has_arg = no_argument },
{ .val = 'l', .name = "long", .has_arg = no_argument },
{ .val = 'l', .name = "full", .has_arg = no_argument },
+ { .val = 'n', .name = "num_dirs", .has_arg = required_argument },
{ .val = 'o', .name = "offset", .has_arg = required_argument },
{ .val = 'p', .name = "partial", .has_arg = required_argument },
{ .val = 'q', .name = "quiet", .has_arg = required_argument },
"\t-v, --verbose\n"
"\t-p, --partial, for partial check (1MB files)\n"
"\t-l, --long, --full check (4GB file with 4k blocks)\n"
+ "\t-n, --num_dirs, number of directories to create\n"
"\t-c, --chunksize, IO chunk size in MB (default=1)\n"
"\t-s, --filesize, file size in MB (default=4096)\n"
"\t-h, --help, display this help and exit\n");
int c;
progname = strrchr(argv[0], '/') ? strrchr(argv[0], '/') + 1 : argv[0];
- while ((c = getopt_long(argc, argv, "c:hlo:pqrs:t:vw",
+ while ((c = getopt_long(argc, argv, "c:hln:o:pqrs:t:vw",
long_opts, NULL)) != -1) {
switch (c) {
case 'c':
case 'l':
full = 1;
break;
+ case 'n':
+ num_dirs = strtoul(optarg, NULL, 0);
+ break;
case 'o': /* offset */
dir_num = strtoul(optarg, NULL, 0);
break;
printf("Timestamp: %lu\n", (unsigned long )time_st);
isatty_flag = isatty(STDOUT_FILENO);
- if (!full) {
+ if (!full && !num_dirs) {
#ifdef HAVE_EXT2FS_EXT2FS_H
struct mntent *tempmnt;
FILE *fp = NULL;
#else
goto guess;
#endif
- if (0) { /* ugh */
- struct statfs64 statbuf;
+ }
+ if (!num_dirs) {
+ struct statfs64 statbuf;
guess:
- /*
- * Most extN filesystems are formatted with 128MB/group
- * (32k bitmap = 4KB blocksize * 8 bits/block) * 4KB,
- * so this is a relatively safe default (somewhat more
- * or less doesn't make a huge difference for testing).
- *
- * We want to create one directory per group, together
- * with the "TOPDIR" feature, so that the directories
- * are spread across the whole block device.
- */
- if (statfs64(testdir, &statbuf) == 0) {
- num_dirs = 1 + (long long)statbuf.f_blocks *
- statbuf.f_bsize / (128ULL * ONE_MB);
- if (verbose)
- printf("dirs: %u, fs blocks: %llu\n",
- num_dirs,
- (long long)statbuf.f_blocks);
- } else {
- fprintf(stderr, "%s: unable to stat '%s': %s\n",
- progname, testdir, strerror(errno));
- if (verbose)
- printf("dirs: %u\n", num_dirs);
- }
+ /*
+ * Most extN filesystems are formatted with 128MB/group
+ * (32k bitmap = 4KB blocksize * 8 bits/block) * 4KB,
+ * so this is a relatively safe default (somewhat more
+ * or less doesn't make a huge difference for testing).
+ *
+ * We want to create one directory per group, together
+ * with the "TOPDIR" feature, so that the directories
+ * are spread across the whole block device.
+ */
+ if (statfs64(testdir, &statbuf) == 0) {
+ num_dirs = 1 + (long long)statbuf.f_blocks *
+ statbuf.f_bsize /
+ (full ? files_in_dir * file_size : 128*ONE_MB);
+ if (verbose)
+ printf("dirs: %u, fs blocks: %llu\n",
+ num_dirs, (long long)statbuf.f_blocks);
+ } else {
+ fprintf(stderr, "%s: unable to stat '%s': %s\n",
+ progname, testdir, strerror(errno));
+ if (!num_dirs)
+ num_dirs = 30000;
+ if (verbose)
+ printf("dirs: %u\n", num_dirs);
}
}
chunk_buf = (char *)calloc(chunksize, 1);