} 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 <fsname>:<index> to <fsname>-<index>
+ * to indicate the device has been registered. */
+ if (mop.mo_ldd.ldd_flags & LDD_F_VIRGIN)
+ (void) osd_label_lustre(&mop);
}
free(options);
return ret;
}
+int osd_label_lustre(struct mount_opts *mop)
+{
+ struct lustre_disk_data *ldd = &mop->mo_ldd;
+ int ret;
+
+ switch (ldd->ldd_mount_type) {
+ case LDD_MT_LDISKFS:
+ case LDD_MT_LDISKFS2:
+ ret = ldiskfs_label_lustre(mop);
+ break;
+#ifdef HAVE_ZFS_OSD
+ case LDD_MT_ZFS:
+ ret = zfs_label_lustre(mop);
+ break;
+#endif /* HAVE_ZFS_OSD */
+ default:
+ fatal();
+ fprintf(stderr, "unknown fs type %d '%s'\n",
+ ldd->ldd_mount_type, MT_STR(ldd));
+ ret = EINVAL;
+ break;
+ }
+
+ return ret;
+}
+
int osd_init(void)
{
int ret = 0;
char *default_mountopts, int default_len,
char *always_mountopts, int always_len);
int osd_tune_lustre(char *dev, struct mount_opts *mop);
+int osd_label_lustre(struct mount_opts *mop);
int osd_init(void);
void osd_fini(void);
char *default_mountopts, int default_len,
char *always_mountopts, int always_len);
int ldiskfs_tune_lustre(char *dev, struct mount_opts *mop);
+int ldiskfs_label_lustre(struct mount_opts *mop);
int ldiskfs_init(void);
void ldiskfs_fini(void);
char *default_mountopts, int default_len,
char *always_mountopts, int always_len);
int zfs_tune_lustre(char *dev, struct mount_opts *mop);
+int zfs_label_lustre(struct mount_opts *mop);
int zfs_init(void);
void zfs_fini(void);
#endif
return set_blockdev_tunables(dev, mop, 1);
}
+int ldiskfs_label_lustre(struct mount_opts *mop)
+{
+ char label_cmd[PATH_MAX];
+ int rc;
+
+ snprintf(label_cmd, sizeof(label_cmd), E2LABEL" %s %s",
+ mop->mo_source, mop->mo_ldd.ldd_svname);
+ rc = run_command(label_cmd, sizeof(label_cmd));
+
+ return rc;
+}
+
/* return canonicalized absolute pathname, even if the target file does not
* exist, unlike realpath */
static char *absolute_path(char *devname)
return 0;
}
+int zfs_label_lustre(struct mount_opts *mop)
+{
+ zfs_handle_t *zhp;
+ int ret;
+
+ if (osd_check_zfs_setup() == 0)
+ return EINVAL;
+
+ zhp = zfs_open(g_zfs, mop->mo_source, ZFS_TYPE_FILESYSTEM);
+ if (zhp == NULL)
+ return EINVAL;
+
+ ret = zfs_set_prop_str(zhp, LDD_SVNAME_PROP, mop->mo_ldd.ldd_svname);
+ zfs_close(zhp);
+
+ return ret;
+}
+
int zfs_init(void)
{
int ret = 0;