X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Futils%2Fmount_lustre.c;h=7671da38acdaa645e0d674590079bba3a41e9c16;hb=9f38647a7b24a834ecbb35e36e42f76d907adecf;hp=ecc532e3473b97d97b7e99e6551ff0172825c371;hpb=98060d83459ba10409f295898f0ec917f938b4d3;p=fs%2Flustre-release.git diff --git a/lustre/utils/mount_lustre.c b/lustre/utils/mount_lustre.c index ecc532e..7671da3 100644 --- a/lustre/utils/mount_lustre.c +++ b/lustre/utils/mount_lustre.c @@ -53,6 +53,7 @@ #include #include #include +#include #if LUSTRE_VERSION_CODE > OBD_OCD_VERSION(2, 10, 51, 0) /* * LU-1783 @@ -63,7 +64,7 @@ * set of flag #defines we should stop including linux/fs.h */ #warn remove kernel include -#else +#elif !defined(MS_RDONLY) #include #endif @@ -320,11 +321,17 @@ static int clear_update_ondisk(char *source, struct lustre_disk_data *ldd) char default_mountopts[512] = ""; struct mkfs_opts mkop; int ret; + int ret2; memset(&mkop, 0, sizeof(mkop)); mkop.mo_ldd = *ldd; mkop.mo_ldd.ldd_flags &= ~LDD_F_UPDATE; - strcpy(mkop.mo_device, source); + if (strlen(source) > sizeof(mkop.mo_device)-1) { + fatal(); + fprintf(stderr, "Device name too long: %s\n", source); + return -E2BIG; + } + strncpy(mkop.mo_device, source, sizeof(mkop.mo_device)); ret = osd_prepare_lustre(&mkop, default_mountopts, sizeof(default_mountopts), @@ -361,7 +368,10 @@ static int clear_update_ondisk(char *source, struct lustre_disk_data *ldd) fprintf(stderr, "failed to write local files: %s\n", strerror(ret)); } - loop_cleanup(&mkop); + + ret2 = loop_cleanup(&mkop); + if (ret == 0) + ret = ret2; return ret; } @@ -388,7 +398,8 @@ static int parse_ldd(char *source, struct mount_opts *mop, char *options) return rc; } - if (ldd->ldd_flags & LDD_F_NEED_INDEX) { + if ((IS_MDT(ldd) || IS_OST(ldd)) && + (ldd->ldd_flags & LDD_F_NEED_INDEX)) { fprintf(stderr, "%s: %s has no index assigned " "(probably formatted with old mkfs)\n", progname, source); @@ -684,7 +695,18 @@ int main(int argc, char *const argv[]) for (i = 0, rc = -EAGAIN; i <= mop.mo_retry && rc != 0; i++) { rc = mount(mop.mo_source, mop.mo_target, "lustre", flags, (void *)options); - if (rc) { + if (rc == 0) { + /* change label from : to + * - to indicate the device has + * been registered. only if the label is + * supposed to be changed and target service + * is supposed to start */ + if (mop.mo_ldd.ldd_flags & + (LDD_F_VIRGIN | LDD_F_WRITECONF)) { + if (mop.mo_nosvc == 0) + (void)osd_label_lustre(&mop); + } + } else { if (verbose) { fprintf(stderr, "%s: mount %s at %s " "failed: %s retries left: " @@ -770,16 +792,7 @@ int main(int argc, char *const argv[]) } else if (!mop.mo_nomtab) { rc = update_mtab_entry(mop.mo_usource, mop.mo_target, "lustre", mop.mo_orig_options, 0,0,0); - - /* change label from : to - - * to indicate the device has been registered. - * only if the label is supposed to be changed and - * target service is supposed to start */ - if (mop.mo_ldd.ldd_flags & (LDD_F_VIRGIN | LDD_F_WRITECONF)) { - if (mop.mo_nosvc == 0 ) - (void) osd_label_lustre(&mop); - } - } + } free(options); /* mo_usource should be freed, but we can rely on the kernel */