#endif
#include <libcfs/libcfs.h>
-#include <libcfs/libcfsutil.h>
+#include <libcfs/util/ioctl.h>
+#include <libcfs/util/parser.h>
#include <lustre/lustreapi.h>
#include <lustre_ver.h>
static int lfs_swap_layouts(int argc, char **argv);
static int lfs_mv(int argc, char **argv);
-#define SETSTRIPE_USAGE(_cmd, _tgt) \
- "usage: "_cmd" [--stripe-count|-c <stripe_count>]\n"\
- " [--stripe-index|-i <start_ost_idx>]\n"\
- " [--stripe-size|-S <stripe_size>]\n"\
- " [--pool|-p <pool_name>]\n"\
- " [--block|-b] "_tgt"\n"\
- " [--ost-list|-o <ost_indices>]\n"\
- "\tstripe_size: Number of bytes on each OST (0 filesystem default)\n"\
- "\t Can be specified with k, m or g (in KB, MB and GB\n"\
- "\t respectively)\n"\
- "\tstart_ost_idx: OST index of first stripe (-1 default)\n"\
- "\tstripe_count: Number of OSTs to stripe over (0 default, -1 all)\n"\
- "\tpool_name: Name of OST pool to use (default none)\n"\
- "\tblock: Block file access during data migration\n"\
+/* Setstripe and migrate share mostly the same parameters */
+#define SSM_CMD_COMMON(cmd) \
+ "usage: "cmd" [--stripe-count|-c <stripe_count>]\n" \
+ " [--stripe-index|-i <start_ost_idx>]\n" \
+ " [--stripe-size|-S <stripe_size>]\n" \
+ " [--pool|-p <pool_name>]\n" \
+ " [--ost-list|-o <ost_indices>]\n"
+
+#define SSM_HELP_COMMON \
+ "\tstripe_size: Number of bytes on each OST (0 filesystem default)\n" \
+ "\t Can be specified with k, m or g (in KB, MB and GB\n" \
+ "\t respectively)\n" \
+ "\tstart_ost_idx: OST index of first stripe (-1 default)\n" \
+ "\tstripe_count: Number of OSTs to stripe over (0 default, -1 all)\n" \
+ "\tpool_name: Name of OST pool to use (default none)\n" \
"\tost_indices: List of OST indices, can be repeated multiple times\n"\
- "\t Indices be specified in a format of:\n"\
- "\t -o <ost_1>,<ost_i>-<ost_j>,<ost_n>\n"\
- "\t Or:\n"\
- "\t -o <ost_1> -o <ost_i>-<ost_j> -o <ost_n>\n"\
- "\t If --pool is set with --ost-list, then the OSTs\n"\
+ "\t Indices be specified in a format of:\n" \
+ "\t -o <ost_1>,<ost_i>-<ost_j>,<ost_n>\n" \
+ "\t Or:\n" \
+ "\t -o <ost_1> -o <ost_i>-<ost_j> -o <ost_n>\n" \
+ "\t If --pool is set with --ost-list, then the OSTs\n" \
"\t must be the members of the pool."
-/* all avaialable commands */
+#define SETSTRIPE_USAGE \
+ SSM_CMD_COMMON("setstripe") \
+ " <directory|filename>\n" \
+ SSM_HELP_COMMON
+
+#define MIGRATE_USAGE \
+ SSM_CMD_COMMON("migrate ") \
+ " [--block|-b]\n" \
+ " <filename>\n" \
+ SSM_HELP_COMMON \
+ "\n" \
+ "\tblock: Block file access during data migration\n" \
+
+/* all available commands */
command_t cmdlist[] = {
{"setstripe", lfs_setstripe, 0,
"Create a new file with a specific striping pattern or\n"
"delete the default striping pattern from an existing directory\n"
"usage: setstripe -d <directory> (to delete default striping)\n"\
" or\n"
- SETSTRIPE_USAGE("setstripe", "<directory|filename>")},
+ SETSTRIPE_USAGE},
{"getstripe", lfs_getstripe, 0,
"To list the striping info for a given file or files in a\n"
"directory or recursively for all files in a directory tree.\n"
{"swap_layouts", lfs_swap_layouts, 0, "Swap layouts between 2 files.\n"
"usage: swap_layouts <path1> <path2>"},
{"migrate", lfs_setstripe, 0, "migrate file from one OST layout to "
- "another (may be not safe with concurent writes).\n"
- SETSTRIPE_USAGE("migrate ", "<filename>")},
+ "another (may be not safe with concurrent writes).\n"
+ MIGRATE_USAGE},
{"mv", lfs_mv, 0,
"To move directories between MDTs.\n"
"usage: mv <directory|filename> [--mdt-index|-M] <mdt_index> "
}
rc = llapi_file_get_stripe(name, lum);
- /* failure can come from may case and some may be not real error
+ /* failure can happen for many reasons and some may be not real errors
* (eg: no stripe)
- * in case of a real error, a later call will failed with a better
+ * in case of a real error, a later call will fail with better
* error management */
if (rc < 0)
bufsz = 1024*1024;
gid = random();
while (gid == 0);
if (migration_flags & MIGRATION_BLOCKS) {
- /* take group lock to limit concurent access
+ /* take group lock to limit concurrent access
* this will be no more needed when exclusive access will
* be implemented (see LU-2919) */
/* group lock is taken after data version read because it
while ((rc = getline(&line, &len, fp)) != -1) {
struct hsm_user_item *hui;
- /* If allocated buffer was too small, gets something
- * bigger */
+ /* If allocated buffer was too small, get something
+ * larger */
if (nbfile_alloc <= hur->hur_request.hr_itemcount) {
ssize_t size;
nbfile_alloc = nbfile_alloc * 2 + 1;