char mo_loopdev[128]; /* in case a loop dev is needed */
__u64 mo_device_sz; /* in KB */
int mo_stripe_count;
- int mo_flags;
+ int mo_flags;
int mo_mgs_failnodes;
};
break;
sprintf(cmd, "losetup %s > /dev/null 2>&1", l_device);
ret = system(cmd);
-
+
/* losetup gets 1 (ret=256) for non-set-up device */
if (ret) {
/* Set up a loopback device to our file */
__u32 lsize = 0;
/* size in blocks */
ret = ioctl(fd, BLKGETSIZE, (void*)&lsize);
- size = (__u64)lsize * 512;
+ size = (__u64)lsize * 512;
}
#endif
close(fd);
if (strstr(debugfs_cmd, "unsupported feature")) {
fprintf(stderr, "In all likelihood, the "
"'unsupported feature' is 'extents', which "
- "older debugfs does not understand.\n"
+ "older debugfs does not understand.\n"
"Use e2fsprogs-1.38-cfs1 or later, available "
"from ftp://ftp.lustre.org/pub/lustre/other/"
"e2fsprogs/\n");
}
fwrite(&mop->mo_ldd, sizeof(mop->mo_ldd), 1, filep);
fclose(filep);
-
+
/* COMPAT_146 */
#ifdef TUNEFS
/* Check for upgrade */
- if ((mop->mo_ldd.ldd_flags & (LDD_F_UPGRADE14 | LDD_F_SV_TYPE_MGS))
+ if ((mop->mo_ldd.ldd_flags & (LDD_F_UPGRADE14 | LDD_F_SV_TYPE_MGS))
== (LDD_F_UPGRADE14 | LDD_F_SV_TYPE_MGS)) {
char cmd[128];
char *term;
vprint("Copying old logs\n");
-
+
/* Copy the old client log to fsname-client */
- sprintf(filepnm, "%s/%s/%s-client",
+ sprintf(filepnm, "%s/%s/%s-client",
mntpt, MOUNT_CONFIGS_DIR, mop->mo_ldd.ldd_fsname);
sprintf(cmd, "cp %s/%s/client %s", mntpt, MDT_LOGS_DIR,
filepnm);
"find the client log for fs %s and "
"copy it manually into %s/%s-client, "
"then umount.\n",
- mop->mo_device,
+ mop->mo_device,
mop->mo_ldd.ldd_fsname, MOUNT_CONFIGS_DIR,
mop->mo_ldd.ldd_fsname);
goto out_umnt;
}
/* We need to use the old mdt log because otherwise mdt won't
- have complete lov if old clients connect before all
+ have complete lov if old clients connect before all
servers upgrade. */
/* Copy the old mdt log to fsname-MDT0000 (get old
name from mdt_UUID) */
if (term) {
*term = '\0';
sprintf(cmd, "cp %s/%s/%s %s/%s/%s",
- mntpt, MDT_LOGS_DIR, filepnm,
+ mntpt, MDT_LOGS_DIR, filepnm,
mntpt, MOUNT_CONFIGS_DIR,
mop->mo_ldd.ldd_svname);
ret = run_command(cmd);
"find the MDT log for fs %s and "
"copy it manually into %s/%s, "
"then umount.\n",
- mop->mo_device,
+ mop->mo_device,
mop->mo_ldd.ldd_fsname, MOUNT_CONFIGS_DIR,
mop->mo_ldd.ldd_svname);
goto out_umnt;
out_umnt:
- umount(mntpt);
+ umount(mntpt);
out_rmdir:
rmdir(mntpt);
return ret;
fprintf(stderr, "%s: Short read (%d of %d)\n",
progname, ret, sizeof(lsd));
ret = -ferror(filep);
- if (ret)
+ if (ret)
goto out_close;
}
vprint("Feature compat=%x, incompat=%x\n",
/* We must co-locate so mgs can see old logs.
If user doesn't want this, they can copy the old
logs manually and re-tunefs. */
- mop->mo_ldd.ldd_flags =
+ mop->mo_ldd.ldd_flags =
LDD_F_SV_TYPE_MDT | LDD_F_SV_TYPE_MGS;
mop->mo_ldd.ldd_svindex = lsd.lsd_mdt_index;
} else {
/* If there's a LOGS dir, it's an MDT */
if ((ret = access(filepnm, F_OK)) == 0) {
mop->mo_ldd.ldd_flags =
- LDD_F_SV_TYPE_MDT |
+ LDD_F_SV_TYPE_MDT |
LDD_F_SV_TYPE_MGS;
- /* Old MDT's are always index 0
+ /* Old MDT's are always index 0
(pre CMD) */
mop->mo_ldd.ldd_svindex = 0;
} else {
}
}
}
-
+
ret = 0;
- memcpy(mop->mo_ldd.ldd_uuid, lsd.lsd_uuid,
+ memcpy(mop->mo_ldd.ldd_uuid, lsd.lsd_uuid,
sizeof(mop->mo_ldd.ldd_uuid));
mop->mo_ldd.ldd_flags |= LDD_F_UPGRADE14;
}
/* end COMPAT_146 */
-out_close:
+out_close:
fclose(filep);
out_rmdir:
mop->mo_ldd.ldd_flags = LDD_F_NEED_INDEX | LDD_F_UPDATE | LDD_F_VIRGIN;
mop->mo_mgs_failnodes = 0;
strcpy(mop->mo_ldd.ldd_fsname, "lustre");
- if (get_os_version() == 24)
+ if (get_os_version() == 24)
mop->mo_ldd.ldd_mount_type = LDD_MT_EXT3;
- else
+ else
mop->mo_ldd.ldd_mount_type = LDD_MT_LDISKFS;
-
+
mop->mo_ldd.ldd_svindex = INDEX_UNASSIGNED;
mop->mo_stripe_count = 1;
}
int start = strlen(buf);
int keylen = 0;
- if (key)
+ if (key)
keylen = strlen(key);
if (start + 1 + keylen + strlen(val) >= end) {
fprintf(stderr, "%s: params are too long-\n%s %s%s\n",
char *converted, *s2 = 0, *c;
int left = MAXNIDSTR;
lnet_nid_t nid;
-
+
converted = malloc(left);
if (converted == NULL) {
return NULL;
while ((left > 0) && ((s2 = strsep(&s1, ",: \0")))) {
nid = libcfs_str2nid(s2);
if (nid == LNET_NID_ANY) {
- if (*s2 == '/')
+ if (*s2 == '/')
/* end of nids */
break;
- fprintf(stderr, "%s: Can't parse NID '%s'\n",
+ fprintf(stderr, "%s: Can't parse NID '%s'\n",
progname, s2);
free(converted);
return NULL;
}
- if (strncmp(libcfs_nid2str(nid), "127.0.0.1",
+ if (strncmp(libcfs_nid2str(nid), "127.0.0.1",
strlen("127.0.0.1")) == 0) {
fprintf(stderr, "%s: The NID '%s' resolves to the "
"loopback address '%s'. Lustre requires a "
- "non-loopback address.\n",
+ "non-loopback address.\n",
progname, s2, libcfs_nid2str(nid));
free(converted);
return NULL;
char opt;
int rc, longidx;
- while ((opt = getopt_long(argc, argv, optstring, long_opt, &longidx)) !=
+ while ((opt = getopt_long(argc, argv, optstring, long_opt, &longidx)) !=
EOF) {
switch (opt) {
case 'b': {
printf("Configdev not implemented\n");
return 1;
case 'd':
- mop->mo_device_sz = atol(optarg);
+ mop->mo_device_sz = atol(optarg);
break;
case 'e':
mop->mo_ldd.ldd_params[0] = '\0';
break;
case 'f': {
char *nids = convert_hostnames(optarg);
- if (!nids)
+ if (!nids)
return 1;
- rc = add_param(mop->mo_ldd.ldd_params, PARAM_FAILNODE,
- nids);
+ rc = add_param(mop->mo_ldd.ldd_params, PARAM_FAILNODE,
+ nids);
free(nids);
- if (rc)
+ if (rc)
return rc;
/* Must update the mgs logs */
mop->mo_ldd.ldd_flags |= LDD_F_UPDATE;
usage(stdout);
return 1;
case 'i':
- if (!(mop->mo_ldd.ldd_flags &
+ if (!(mop->mo_ldd.ldd_flags &
(LDD_F_UPGRADE14 | LDD_F_VIRGIN |
LDD_F_WRITECONF))) {
fprintf(stderr, "%s: cannot change the index of"
}
break;
case 'k':
- strncpy(mop->mo_mkfsopts, optarg,
+ strncpy(mop->mo_mkfsopts, optarg,
sizeof(mop->mo_mkfsopts) - 1);
break;
case 'L':
- if (!(mop->mo_ldd.ldd_flags &
+ if (!(mop->mo_ldd.ldd_flags &
(LDD_F_UPGRADE14 | LDD_F_VIRGIN |
LDD_F_WRITECONF))) {
fprintf(stderr, "%s: cannot change the name of"
"<= 8 chars\n", progname);
return 1;
}
- if (optarg[0] != 0)
- strncpy(mop->mo_ldd.ldd_fsname, optarg,
+ if (optarg[0] != 0)
+ strncpy(mop->mo_ldd.ldd_fsname, optarg,
sizeof(mop->mo_ldd.ldd_fsname) - 1);
break;
case 'm': {
char *nids = convert_hostnames(optarg);
- if (!nids)
+ if (!nids)
return 1;
- rc = add_param(mop->mo_ldd.ldd_params, PARAM_MGSNODE,
- nids);
+ rc = add_param(mop->mo_ldd.ldd_params, PARAM_MGSNODE,
+ nids);
free(nids);
- if (rc)
+ if (rc)
return rc;
mop->mo_mgs_failnodes++;
break;
break;
case 'p':
rc = add_param(mop->mo_ldd.ldd_params, NULL, optarg);
- if (rc)
+ if (rc)
return rc;
/* Must update the mgs logs */
mop->mo_ldd.ldd_flags |= LDD_F_UPDATE;
struct stat st;
source = mop->mo_device;
- if (mop->mo_flags & MO_IS_LOOP) {
+ if (mop->mo_flags & MO_IS_LOOP) {
source = mop->mo_loopdev;
}
}
snprintf(filepnm, sizeof(filepnm) - 1, "%s/%s", mntpt, "root");
- ret = iam_creat(filepnm, FMT_LVAR,
- SET_DEFAULT, SET_DEFAULT, 16, SET_DEFAULT);
+ ret = iam_creat(filepnm, FMT_LVAR, L_BLOCK_SIZE, 4, 16, 4);
if (ret) {
goto out_umount;
}
snprintf(filepnm, sizeof(filepnm) - 1, "%s/%s", mntpt, "fld");
ret = iam_creat(filepnm, FMT_LFIX,
- SET_DEFAULT, 8, 8, SET_DEFAULT);
+ L_BLOCK_SIZE, 8, 8, 4);
if (ret) {
goto out_umount;
}
snprintf(filepnm, sizeof(filepnm) - 1, "%s/%s", mntpt, "oi");
- ret = iam_creat(filepnm, FMT_LFIX,
- SET_DEFAULT, 16, 16, SET_DEFAULT);
+ ret = iam_creat(filepnm, FMT_LFIX, L_BLOCK_SIZE, 16, 16, 4);
if (ret) {
goto out_umount;
}
//printf("pad %d\n", offsetof(struct lustre_disk_data, ldd_padding));
assert(offsetof(struct lustre_disk_data, ldd_padding) == 200);
-
+
if ((progname = strrchr(argv[0], '/')) != NULL)
progname++;
else
/* Are we using a loop device? */
ret = is_block(mop.mo_device);
- if (ret < 0)
+ if (ret < 0)
goto out;
- if (ret == 0)
+ if (ret == 0)
mop.mo_flags |= MO_IS_LOOP;
#ifdef TUNEFS
/* For tunefs, we must read in the old values before parsing any
new ones. */
-
+
/* Check whether the disk has already been formatted by mkfs.lustre */
ret = is_lustre_target(&mop);
if (ret == 0) {
if (strstr(mop.mo_ldd.ldd_params, PARAM_MGSNODE))
mop.mo_mgs_failnodes++;
- if (verbose > 0)
+ if (verbose > 0)
print_ldd("Read previous values", &(mop.mo_ldd));
#endif
ret = parse_opts(argc, argv, &mop, &mountopts);
- if (ret)
+ if (ret)
goto out;
ldd = &mop.mo_ldd;
-
+
if (!(IS_MDT(ldd) || IS_OST(ldd) || IS_MGS(ldd))) {
fatal();
fprintf(stderr, "must set target type: MDT,OST,MGS\n");
goto out;
}
- /* These are the permanent mount options (always included) */
+ /* These are the permanent mount options (always included) */
switch (ldd->ldd_mount_type) {
case LDD_MT_EXT3:
case LDD_MT_LDISKFS: {
if ((get_os_version() == 24) && IS_OST(ldd))
strcat(always_mountopts, ",asyncdel");
/* NB: Files created while extents are enabled cannot be read
- if mounted with a kernel that doesn't include the CFS
+ if mounted with a kernel that doesn't include the CFS
patches! */
- if (IS_OST(ldd) &&
+ if (IS_OST(ldd) &&
ldd->ldd_mount_type == LDD_MT_LDISKFS) {
strcat(default_mountopts, ",extents,mballoc");
}
ret = EINVAL;
goto out;
}
- }
+ }
if (mountopts) {
/* If user specifies mount opts, don't use defaults,
but always use always_mountopts */
- sprintf(ldd->ldd_mount_opts, "%s,%s",
+ sprintf(ldd->ldd_mount_opts, "%s,%s",
always_mountopts, mountopts);
} else {
#ifdef TUNEFS
- if (ldd->ldd_mount_opts[0] == 0)
+ if (ldd->ldd_mount_opts[0] == 0)
/* use the defaults unless old opts exist */
#endif
{
- sprintf(ldd->ldd_mount_opts, "%s%s",
+ sprintf(ldd->ldd_mount_opts, "%s%s",
always_mountopts, default_mountopts);
}
}
/* Create the loopback file */
if (mop.mo_flags & MO_IS_LOOP) {
ret = access(mop.mo_device, F_OK);
- if (ret)
+ if (ret)
ret = errno;
#ifndef TUNEFS /* mkfs.lustre */
/* Reformat the loopback file */
if (ret || (mop.mo_flags & MO_FORCEFORMAT))
ret = loop_format(&mop);
#endif
- if (ret == 0)
+ if (ret == 0)
ret = loop_setup(&mop);
if (ret) {
fatal();
ret = is_lustre_target(&mop);
if (ret) {
fatal();
- fprintf(stderr, "Device %s was previously formatted "
+ fprintf(stderr, "Device %s was previously formatted "
"for lustre. Use --reformat to reformat it, "
"or tunefs.lustre to modify.\n",
mop.mo_device);
}
out:
- loop_cleanup(&mop);
+ loop_cleanup(&mop);
return ret;
}