"usage: lov_modify_tgts add|del <lov-name> <uuid> <index> <gen>"},
{"lov_getconfig", jt_obd_lov_getconfig, 0,
"read lov configuration from an mds device\n"
- "usage: lov_getconfig /mount/path"},
+ "usage: lov_getconfig <mountpoint>"},
{"record", jt_cfg_record, 0, "record commands that follow in log\n"
"usage: record cfg-uuid-name"},
{"endrecord", jt_cfg_endrecord, 0, "stop recording\n"
long st_size;
int st_offset, st_count;
char *end;
- int page_size;
if (argc != 5 && argc != 3)
return CMD_HELP;
argv[0], argv[2]);
return CMD_HELP;
}
- /* 64 KB is the largest common page size I'm aware of (on ia64), but
- * check the local page size just in case. */
- page_size = 65536;
- if (getpagesize() > page_size) {
- fprintf(stderr, "WARNING: your page size (%d) is larger than "
- "expected.\n", getpagesize());
- page_size = getpagesize();
- }
- if (st_size % page_size) {
- fprintf(stderr, "FATAL: stripe_size must be an even multiple "
- "of %d bytes.\n", page_size);
- return CMD_HELP;
- }
// get the stripe offset
st_offset = strtoul(argv[3], &end, 0);
static void err_msg(char *fmt, ...)
{
va_list args;
- int tmp_errno = errno;
+ int tmp_errno = abs(errno);
va_start(args, fmt);
vfprintf(stderr, fmt, args);
struct lov_user_md lum = { 0 };
int fd, rc = 0;
int isdir = 0;
-
- /* Initialize IOCTL striping pattern structure */
- lum.lmm_magic = LOV_USER_MAGIC;
- lum.lmm_pattern = stripe_pattern;
- lum.lmm_stripe_size = stripe_size;
- lum.lmm_stripe_count = stripe_count;
- lum.lmm_stripe_offset = stripe_offset;
+ int page_size;
fd = open(name, O_CREAT | O_RDWR | O_LOV_DELAY_CREATE, 0644);
if (errno == EISDIR) {
return rc;
}
+ /* 64 KB is the largest common page size I'm aware of (on ia64), but
+ * check the local page size just in case. */
+ page_size = 65536;
+ if (getpagesize() > page_size) {
+ page_size = getpagesize();
+ fprintf(stderr, "WARNING: your page size (%d) is larger than "
+ "expected.\n", page_size);
+ }
+ if ((stripe_size < 0 || stripe_size % 65536) &&
+ !(isdir && stripe_size == -1)) {
+ rc = -EINVAL;
+ err_msg("error: stripe_size must be an even "
+ "multiple of %d bytes.\n", page_size);
+ goto out;
+ }
+ if (stripe_offset < -1 || stripe_offset > 65534) {
+ errno = rc = -EINVAL;
+ err_msg("error: bad stripe offset %d\n", stripe_offset);
+ goto out;
+ }
+ if (stripe_count < -1 || stripe_count > 65534) {
+ errno = rc = -EINVAL;
+ err_msg("error: bad stripe count %d\n", stripe_count);
+ goto out;
+ }
+ if (stripe_count > 0 && (__u64)stripe_size * stripe_count > ~0UL) {
+ errno = rc = -EINVAL;
+ err_msg("error: stripe_size %ld * stripe_count %d "
+ "exceeds %lu bytes.\n", ~0UL);
+ goto out;
+ }
+
+ /* Initialize IOCTL striping pattern structure */
+ lum.lmm_magic = LOV_USER_MAGIC;
+ lum.lmm_pattern = stripe_pattern;
+ lum.lmm_stripe_size = stripe_size;
+ lum.lmm_stripe_count = stripe_count;
+ lum.lmm_stripe_offset = stripe_offset;
+
/* setting stripe pattern 0 -1 0 to a dir means to delete it */
if (isdir) {
if (stripe_size == 0 && stripe_count == 0 &&
lum.lmm_stripe_size = -1;
} else {
if (stripe_size == -1) {
+ errno = rc = -EPERM;
err_msg("deleting file stripe info is not allowed\n");
- rc = -EPERM;
goto out;
}
}
/* if it's a directory */
if (*fname == '\0') {
- if (header && (obdstripe == 1)) {
- printf("default lmm_stripe_count: %u\n"
- "default lmm_stripe_size: %u\n"
- "default lmm_stripe_offset: %u\n",
- lum->lmm_stripe_count, lum->lmm_stripe_size,
- (int)lum->lmm_stripe_offset);
+ if (obdstripe == 1) {
+ printf("default stripe_count: %d stripe_size: %u "
+ "stripe_offset: %d\n",
+ lum->lmm_stripe_count == (__u16)-1 ? -1 :
+ lum->lmm_stripe_count,
+ lum->lmm_stripe_size,
+ lum->lmm_stripe_offset == (__u16)-1 ? -1 :
+ lum->lmm_stripe_offset);
}
return;
}