}
run_test 87 "check if MDT inode can hold EAs with N stripes properly"
+test_88() {
+ [ "$(facet_fstype mds1)" == "zfs" ] &&
+ skip "LU-6662: no implementation for ZFS" && return
+
+ load_modules
+
+ add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
+ --reformat $(mdsdevname 1) || error "add mds1 failed"
+
+ do_facet mds1 "$TUNEFS $(mdsdevname 1) |
+ grep -e \".*opts:.*errors=remount-ro.*\"" ||
+ error "default mount options is missing"
+
+ add mds1 $(mkfs_opts mds1 $(mdsdevname 1)) \
+ --mountfsoptions="user_xattr,errors=panic" \
+ --reformat $(mdsdevname 1) || error "add mds1 failed"
+
+ do_facet mds1 "$TUNEFS $(mdsdevname 1) |
+ grep -e \".*opts:.*errors=panic.*\"" ||
+ error "user can't override default mount options"
+}
+run_test 88 "check the default mount options can be overridden"
+
# $1 test directory
# $2 (optional) value of max_mod_rpcs_in_flight to set
check_max_mod_rpcs_in_flight() {
struct mkfs_opts mop;
struct lustre_disk_data *ldd;
char *mountopts = NULL;
- char always_mountopts[512] = "";
- char default_mountopts[512] = "";
+ char wanted_mountopts[512] = "";
unsigned mount_type;
int ret = 0;
int ret2 = 0;
/* These are the permanent mount options (always included) */
ret = osd_prepare_lustre(&mop,
- default_mountopts, sizeof(default_mountopts),
- always_mountopts, sizeof(always_mountopts));
+ wanted_mountopts, sizeof(wanted_mountopts));
if (ret) {
fatal();
fprintf(stderr, "unable to prepare backend (%d)\n", ret);
goto out;
}
- if (mountopts) {
- trim_mountfsoptions(mountopts);
- (void)check_mountfsoptions(mountopts, default_mountopts, 1);
- if (check_mountfsoptions(mountopts, always_mountopts, 0)) {
- ret = EINVAL;
- goto out;
- }
- sprintf(ldd->ldd_mount_opts, "%s", mountopts);
- } else {
+ if (mountopts) {
+ trim_mountfsoptions(mountopts);
+ if (check_mountfsoptions(mountopts, wanted_mountopts)) {
+ ret = EINVAL;
+ goto out;
+ }
+ snprintf(ldd->ldd_mount_opts, sizeof(ldd->ldd_mount_opts),
+ "%s", mountopts);
+ } else {
#ifdef TUNEFS
- if (ldd->ldd_mount_opts[0] == 0)
- /* use the defaults unless old opts exist */
+ if (ldd->ldd_mount_opts[0] == 0)
+ /* use the defaults unless old opts exist */
#endif
- {
- sprintf(ldd->ldd_mount_opts, "%s%s",
- always_mountopts, default_mountopts);
- trim_mountfsoptions(ldd->ldd_mount_opts);
- }
- }
+ {
+ snprintf(ldd->ldd_mount_opts,
+ sizeof(ldd->ldd_mount_opts),
+ "%s", wanted_mountopts);
+ trim_mountfsoptions(ldd->ldd_mount_opts);
+ }
+ }
+
+ ret = osd_fix_mountopts(&mop, ldd->ldd_mount_opts,
+ sizeof(ldd->ldd_mount_opts));
+ if (ret) {
+ fatal();
+ fprintf(stderr, "unable to fix mountfsoptions (%d)\n", ret);
+ goto out;
+ }
server_make_name(ldd->ldd_flags, ldd->ldd_svindex,
ldd->ldd_fsname, ldd->ldd_svname);
static int clear_update_ondisk(char *source, struct lustre_disk_data *ldd)
{
- char always_mountopts[512] = "";
- char default_mountopts[512] = "";
+ char wanted_mountopts[512] = "";
struct mkfs_opts mkop;
int ret;
int ret2;
strncpy(mkop.mo_device, source, sizeof(mkop.mo_device));
ret = osd_prepare_lustre(&mkop,
- default_mountopts, sizeof(default_mountopts),
- always_mountopts, sizeof(always_mountopts));
+ wanted_mountopts, sizeof(wanted_mountopts));
if (ret) {
fatal();
fprintf(stderr, "Can't prepare device %s: %s\n",
* present in mountopts. The justwarn boolean toggles between error and
* warning message. Return an error count.
*/
-int check_mountfsoptions(char *mountopts, char *wanted_mountopts,
- int justwarn)
+int check_mountfsoptions(char *mountopts, char *wanted_mountopts)
{
char *ml, *mlp, *item, *ctx = NULL;
int errors = 0;
mlp = ml;
while ((item = strtok_r(mlp, ",", &ctx))) {
if (!in_mntlist(item, mountopts)) {
- fprintf(stderr, "%s: %s mount option `%s' is missing\n",
- progname, justwarn ? "Warning: default"
- : "Error: mandatory", item);
+ fprintf(stderr, "%s: Error: mandatory mount option"
+ " '%s' is missing\n", progname, item);
errors++;
}
mlp = NULL;
free(ops);
return NULL;
}
+
+ /* optional methods */
+ DLSYM(name, ops, fix_mountopts);
+
return ops;
}
}
int osd_prepare_lustre(struct mkfs_opts *mop,
- char *default_mountopts, int default_len,
- char *always_mountopts, int always_len)
+ char *wanted_mountopts, size_t len)
{
struct lustre_disk_data *ldd = &mop->mo_ldd;
int ret;
if (backfs_mount_type_okay(ldd->ldd_mount_type))
ret = backfs_ops[ldd->ldd_mount_type]->prepare_lustre(mop,
- default_mountopts, default_len,
- always_mountopts, always_len);
+ wanted_mountopts, len);
else
ret = EINVAL;
return ret;
}
+int osd_fix_mountopts(struct mkfs_opts *mop, char *mountopts, size_t len)
+{
+ struct lustre_disk_data *ldd = &mop->mo_ldd;
+
+ if (!backfs_mount_type_okay(ldd->ldd_mount_type))
+ return EINVAL;
+
+ if (backfs_ops[ldd->ldd_mount_type]->fix_mountopts == NULL)
+ return 0;
+
+ return backfs_ops[ldd->ldd_mount_type]->fix_mountopts(mop, mountopts,
+ len);
+}
+
int osd_tune_lustre(char *dev, struct mount_opts *mop)
{
struct lustre_disk_data *ldd = &mop->mo_ldd;
int check_mtab_entry(char *spec1, char *spec2, char *mntpt, char *type);
int update_mtab_entry(char *spec, char *mtpt, char *type, char *opts,
int flags, int freq, int pass);
-int check_mountfsoptions(char *mountopts, char *wanted_mountopts, int justwarn);
+int check_mountfsoptions(char *mountopts, char *wanted_mountopts);
void trim_mountfsoptions(char *s);
__u64 get_device_size(char* device);
int osd_is_lustre(char *dev, unsigned *mount_type);
int osd_make_lustre(struct mkfs_opts *mop);
int osd_prepare_lustre(struct mkfs_opts *mop,
- char *default_mountopts, int default_len,
- char *always_mountopts, int always_len);
+ char *wanted_mountopts, size_t len);
+int osd_fix_mountopts(struct mkfs_opts *mop, char *mountopts, size_t len);
int osd_tune_lustre(char *dev, struct mount_opts *mop);
int osd_label_lustre(struct mount_opts *mop);
int osd_enable_quota(struct mkfs_opts *mop);
int (*is_lustre)(char *dev, enum ldd_mount_type *mount_type);
int (*make_lustre)(struct mkfs_opts *mop);
int (*prepare_lustre)(struct mkfs_opts *mop,
- char *default_mountopts, int default_len,
- char *always_mountopts, int always_len);
+ char *wanted_mountopts, size_t len);
+ int (*fix_mountopts)(struct mkfs_opts *mop,
+ char *mountopts, size_t len);
int (*tune_lustre)(char *dev, struct mount_opts *mop);
int (*label_lustre)(struct mount_opts *mop);
int (*enable_quota)(struct mkfs_opts *mop);
}
int ldiskfs_prepare_lustre(struct mkfs_opts *mop,
- char *default_mountopts, int default_len,
- char *always_mountopts, int always_len)
+ char *wanted_mountopts, size_t len)
{
struct lustre_disk_data *ldd = &mop->mo_ldd;
int ret;
mop->mo_flags |= MO_IS_LOOP;
}
- strscat(default_mountopts, ",errors=remount-ro", default_len);
if (IS_MDT(ldd) || IS_MGS(ldd))
- strscat(always_mountopts, ",user_xattr", always_len);
+ strscat(wanted_mountopts, ",user_xattr", len);
+
+ return 0;
+}
+
+int ldiskfs_fix_mountopts(struct mkfs_opts *mop, char *mountopts, size_t len)
+{
+ if (strstr(mountopts, "errors=") == NULL)
+ strscat(mountopts, ",errors=remount-ro", len);
return 0;
}
}
int zfs_prepare_lustre(struct mkfs_opts *mop,
- char *default_mountopts, int default_len,
- char *always_mountopts, int always_len)
+ char *wanted_mountopts, size_t len)
{
if (osd_check_zfs_setup() == 0)
return EINVAL;