Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

ocfs2: convert to the new mount API

Convert ocfs2 to the new mount API.

Link: https://lkml.kernel.org/r/20241028144443.609151-3-sandeen@redhat.com
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Tested-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Acked-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Tested-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Jun Piao <piaojun@huawei.com>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Mark Fasheh <mark@fasheh.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Eric Sandeen and committed by
Andrew Morton
9be53fe6 94e0c289

+275 -330
+10 -10
fs/ocfs2/ocfs2_trace.h
··· 1658 1658 ); 1659 1659 1660 1660 TRACE_EVENT(ocfs2_fill_super, 1661 - TP_PROTO(void *sb, void *data, int silent), 1662 - TP_ARGS(sb, data, silent), 1661 + TP_PROTO(void *sb, void *fc, int silent), 1662 + TP_ARGS(sb, fc, silent), 1663 1663 TP_STRUCT__entry( 1664 1664 __field(void *, sb) 1665 - __field(void *, data) 1665 + __field(void *, fc) 1666 1666 __field(int, silent) 1667 1667 ), 1668 1668 TP_fast_assign( 1669 1669 __entry->sb = sb; 1670 - __entry->data = data; 1670 + __entry->fc = fc; 1671 1671 __entry->silent = silent; 1672 1672 ), 1673 1673 TP_printk("%p %p %d", __entry->sb, 1674 - __entry->data, __entry->silent) 1674 + __entry->fc, __entry->silent) 1675 1675 ); 1676 1676 1677 1677 TRACE_EVENT(ocfs2_parse_options, 1678 - TP_PROTO(int is_remount, char *options), 1679 - TP_ARGS(is_remount, options), 1678 + TP_PROTO(int is_remount, const char *option), 1679 + TP_ARGS(is_remount, option), 1680 1680 TP_STRUCT__entry( 1681 1681 __field(int, is_remount) 1682 - __string(options, options) 1682 + __string(option, option) 1683 1683 ), 1684 1684 TP_fast_assign( 1685 1685 __entry->is_remount = is_remount; 1686 - __assign_str(options); 1686 + __assign_str(option); 1687 1687 ), 1688 - TP_printk("%d %s", __entry->is_remount, __get_str(options)) 1688 + TP_printk("%d %s", __entry->is_remount, __get_str(option)) 1689 1689 ); 1690 1690 1691 1691 DEFINE_OCFS2_POINTER_EVENT(ocfs2_put_super);
+265 -320
fs/ocfs2/super.c
··· 19 19 #include <linux/blkdev.h> 20 20 #include <linux/socket.h> 21 21 #include <linux/inet.h> 22 - #include <linux/parser.h> 22 + #include <linux/fs_parser.h> 23 + #include <linux/fs_context.h> 23 24 #include <linux/crc32.h> 24 25 #include <linux/debugfs.h> 25 - #include <linux/mount.h> 26 26 #include <linux/seq_file.h> 27 27 #include <linux/quotaops.h> 28 28 #include <linux/signal.h> ··· 80 80 unsigned int resv_level; 81 81 int dir_resv_level; 82 82 char cluster_stack[OCFS2_STACK_LABEL_LEN + 1]; 83 + bool user_stack; 83 84 }; 84 85 85 - static int ocfs2_parse_options(struct super_block *sb, char *options, 86 - struct mount_options *mopt, 87 - int is_remount); 86 + static int ocfs2_parse_param(struct fs_context *fc, struct fs_parameter *param); 88 87 static int ocfs2_check_set_options(struct super_block *sb, 89 88 struct mount_options *options); 90 89 static int ocfs2_show_options(struct seq_file *s, struct dentry *root); 91 90 static void ocfs2_put_super(struct super_block *sb); 92 91 static int ocfs2_mount_volume(struct super_block *sb); 93 - static int ocfs2_remount(struct super_block *sb, int *flags, char *data); 94 92 static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err); 95 93 static int ocfs2_initialize_mem_caches(void); 96 94 static void ocfs2_free_mem_caches(void); ··· 133 135 .evict_inode = ocfs2_evict_inode, 134 136 .sync_fs = ocfs2_sync_fs, 135 137 .put_super = ocfs2_put_super, 136 - .remount_fs = ocfs2_remount, 137 138 .show_options = ocfs2_show_options, 138 139 .quota_read = ocfs2_quota_read, 139 140 .quota_write = ocfs2_quota_write, ··· 141 144 142 145 enum { 143 146 Opt_barrier, 144 - Opt_err_panic, 145 - Opt_err_ro, 147 + Opt_errors, 146 148 Opt_intr, 147 - Opt_nointr, 148 - Opt_hb_none, 149 - Opt_hb_local, 150 - Opt_hb_global, 151 - Opt_data_ordered, 152 - Opt_data_writeback, 149 + Opt_heartbeat, 150 + Opt_data, 153 151 Opt_atime_quantum, 154 152 Opt_slot, 155 153 Opt_commit, ··· 152 160 Opt_localflocks, 153 161 Opt_stack, 154 162 Opt_user_xattr, 155 - Opt_nouser_xattr, 156 163 Opt_inode64, 157 164 Opt_acl, 158 - Opt_noacl, 159 165 Opt_usrquota, 160 166 Opt_grpquota, 161 - Opt_coherency_buffered, 162 - Opt_coherency_full, 167 + Opt_coherency, 163 168 Opt_resv_level, 164 169 Opt_dir_resv_level, 165 170 Opt_journal_async_commit, 166 - Opt_err_cont, 167 - Opt_err, 168 171 }; 169 172 170 - static const match_table_t tokens = { 171 - {Opt_barrier, "barrier=%u"}, 172 - {Opt_err_panic, "errors=panic"}, 173 - {Opt_err_ro, "errors=remount-ro"}, 174 - {Opt_intr, "intr"}, 175 - {Opt_nointr, "nointr"}, 176 - {Opt_hb_none, OCFS2_HB_NONE}, 177 - {Opt_hb_local, OCFS2_HB_LOCAL}, 178 - {Opt_hb_global, OCFS2_HB_GLOBAL}, 179 - {Opt_data_ordered, "data=ordered"}, 180 - {Opt_data_writeback, "data=writeback"}, 181 - {Opt_atime_quantum, "atime_quantum=%u"}, 182 - {Opt_slot, "preferred_slot=%u"}, 183 - {Opt_commit, "commit=%u"}, 184 - {Opt_localalloc, "localalloc=%d"}, 185 - {Opt_localflocks, "localflocks"}, 186 - {Opt_stack, "cluster_stack=%s"}, 187 - {Opt_user_xattr, "user_xattr"}, 188 - {Opt_nouser_xattr, "nouser_xattr"}, 189 - {Opt_inode64, "inode64"}, 190 - {Opt_acl, "acl"}, 191 - {Opt_noacl, "noacl"}, 192 - {Opt_usrquota, "usrquota"}, 193 - {Opt_grpquota, "grpquota"}, 194 - {Opt_coherency_buffered, "coherency=buffered"}, 195 - {Opt_coherency_full, "coherency=full"}, 196 - {Opt_resv_level, "resv_level=%u"}, 197 - {Opt_dir_resv_level, "dir_resv_level=%u"}, 198 - {Opt_journal_async_commit, "journal_async_commit"}, 199 - {Opt_err_cont, "errors=continue"}, 200 - {Opt_err, NULL} 173 + static const struct constant_table ocfs2_param_errors[] = { 174 + {"panic", OCFS2_MOUNT_ERRORS_PANIC}, 175 + {"remount-ro", OCFS2_MOUNT_ERRORS_ROFS}, 176 + {"continue", OCFS2_MOUNT_ERRORS_CONT}, 177 + {} 178 + }; 179 + 180 + static const struct constant_table ocfs2_param_heartbeat[] = { 181 + {"local", OCFS2_MOUNT_HB_LOCAL}, 182 + {"none", OCFS2_MOUNT_HB_NONE}, 183 + {"global", OCFS2_MOUNT_HB_GLOBAL}, 184 + {} 185 + }; 186 + 187 + static const struct constant_table ocfs2_param_data[] = { 188 + {"writeback", OCFS2_MOUNT_DATA_WRITEBACK}, 189 + {"ordered", 0}, 190 + {} 191 + }; 192 + 193 + static const struct constant_table ocfs2_param_coherency[] = { 194 + {"buffered", OCFS2_MOUNT_COHERENCY_BUFFERED}, 195 + {"full", 0}, 196 + {} 197 + }; 198 + 199 + static const struct fs_parameter_spec ocfs2_param_spec[] = { 200 + fsparam_u32 ("barrier", Opt_barrier), 201 + fsparam_enum ("errors", Opt_errors, ocfs2_param_errors), 202 + fsparam_flag_no ("intr", Opt_intr), 203 + fsparam_enum ("heartbeat", Opt_heartbeat, ocfs2_param_heartbeat), 204 + fsparam_enum ("data", Opt_data, ocfs2_param_data), 205 + fsparam_u32 ("atime_quantum", Opt_atime_quantum), 206 + fsparam_u32 ("preferred_slot", Opt_slot), 207 + fsparam_u32 ("commit", Opt_commit), 208 + fsparam_s32 ("localalloc", Opt_localalloc), 209 + fsparam_flag ("localflocks", Opt_localflocks), 210 + fsparam_string ("cluster_stack", Opt_stack), 211 + fsparam_flag_no ("user_xattr", Opt_user_xattr), 212 + fsparam_flag ("inode64", Opt_inode64), 213 + fsparam_flag_no ("acl", Opt_acl), 214 + fsparam_flag ("usrquota", Opt_usrquota), 215 + fsparam_flag ("grpquota", Opt_grpquota), 216 + fsparam_enum ("coherency", Opt_coherency, ocfs2_param_coherency), 217 + fsparam_u32 ("resv_level", Opt_resv_level), 218 + fsparam_u32 ("dir_resv_level", Opt_dir_resv_level), 219 + fsparam_flag ("journal_async_commit", Opt_journal_async_commit), 220 + {} 201 221 }; 202 222 203 223 #ifdef CONFIG_DEBUG_FS ··· 604 600 return (((unsigned long long)bytes) << bitshift) - trim; 605 601 } 606 602 607 - static int ocfs2_remount(struct super_block *sb, int *flags, char *data) 603 + static int ocfs2_reconfigure(struct fs_context *fc) 608 604 { 609 605 int incompat_features; 610 606 int ret = 0; 611 - struct mount_options parsed_options; 607 + struct mount_options *parsed_options = fc->fs_private; 608 + struct super_block *sb = fc->root->d_sb; 612 609 struct ocfs2_super *osb = OCFS2_SB(sb); 613 610 u32 tmp; 614 611 615 612 sync_filesystem(sb); 616 613 617 - if (!ocfs2_parse_options(sb, data, &parsed_options, 1) || 618 - !ocfs2_check_set_options(sb, &parsed_options)) { 614 + if (!ocfs2_check_set_options(sb, parsed_options)) { 619 615 ret = -EINVAL; 620 616 goto out; 621 617 } 622 618 623 619 tmp = OCFS2_MOUNT_HB_LOCAL | OCFS2_MOUNT_HB_GLOBAL | 624 620 OCFS2_MOUNT_HB_NONE; 625 - if ((osb->s_mount_opt & tmp) != (parsed_options.mount_opt & tmp)) { 621 + if ((osb->s_mount_opt & tmp) != (parsed_options->mount_opt & tmp)) { 626 622 ret = -EINVAL; 627 623 mlog(ML_ERROR, "Cannot change heartbeat mode on remount\n"); 628 624 goto out; 629 625 } 630 626 631 627 if ((osb->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK) != 632 - (parsed_options.mount_opt & OCFS2_MOUNT_DATA_WRITEBACK)) { 628 + (parsed_options->mount_opt & OCFS2_MOUNT_DATA_WRITEBACK)) { 633 629 ret = -EINVAL; 634 630 mlog(ML_ERROR, "Cannot change data mode on remount\n"); 635 631 goto out; ··· 638 634 /* Probably don't want this on remount; it might 639 635 * mess with other nodes */ 640 636 if (!(osb->s_mount_opt & OCFS2_MOUNT_INODE64) && 641 - (parsed_options.mount_opt & OCFS2_MOUNT_INODE64)) { 637 + (parsed_options->mount_opt & OCFS2_MOUNT_INODE64)) { 642 638 ret = -EINVAL; 643 639 mlog(ML_ERROR, "Cannot enable inode64 on remount\n"); 644 640 goto out; 645 641 } 646 642 647 643 /* We're going to/from readonly mode. */ 648 - if ((bool)(*flags & SB_RDONLY) != sb_rdonly(sb)) { 644 + if ((bool)(fc->sb_flags & SB_RDONLY) != sb_rdonly(sb)) { 649 645 /* Disable quota accounting before remounting RO */ 650 - if (*flags & SB_RDONLY) { 646 + if (fc->sb_flags & SB_RDONLY) { 651 647 ret = ocfs2_susp_quotas(osb, 0); 652 648 if (ret < 0) 653 649 goto out; ··· 661 657 goto unlock_osb; 662 658 } 663 659 664 - if (*flags & SB_RDONLY) { 660 + if (fc->sb_flags & SB_RDONLY) { 665 661 sb->s_flags |= SB_RDONLY; 666 662 osb->osb_flags |= OCFS2_OSB_SOFT_RO; 667 663 } else { ··· 682 678 sb->s_flags &= ~SB_RDONLY; 683 679 osb->osb_flags &= ~OCFS2_OSB_SOFT_RO; 684 680 } 685 - trace_ocfs2_remount(sb->s_flags, osb->osb_flags, *flags); 681 + trace_ocfs2_remount(sb->s_flags, osb->osb_flags, fc->sb_flags); 686 682 unlock_osb: 687 683 spin_unlock(&osb->osb_lock); 688 684 /* Enable quota accounting after remounting RW */ 689 - if (!ret && !(*flags & SB_RDONLY)) { 685 + if (!ret && !(fc->sb_flags & SB_RDONLY)) { 690 686 if (sb_any_quota_suspended(sb)) 691 687 ret = ocfs2_susp_quotas(osb, 1); 692 688 else ··· 705 701 if (!ret) { 706 702 /* Only save off the new mount options in case of a successful 707 703 * remount. */ 708 - osb->s_mount_opt = parsed_options.mount_opt; 709 - osb->s_atime_quantum = parsed_options.atime_quantum; 710 - osb->preferred_slot = parsed_options.slot; 711 - if (parsed_options.commit_interval) 712 - osb->osb_commit_interval = parsed_options.commit_interval; 704 + osb->s_mount_opt = parsed_options->mount_opt; 705 + osb->s_atime_quantum = parsed_options->atime_quantum; 706 + osb->preferred_slot = parsed_options->slot; 707 + if (parsed_options->commit_interval) 708 + osb->osb_commit_interval = parsed_options->commit_interval; 713 709 714 710 if (!ocfs2_is_hard_readonly(osb)) 715 711 ocfs2_set_journal_params(osb); ··· 970 966 } 971 967 } 972 968 973 - static int ocfs2_fill_super(struct super_block *sb, void *data, int silent) 969 + static int ocfs2_fill_super(struct super_block *sb, struct fs_context *fc) 974 970 { 975 971 struct dentry *root; 976 972 int status, sector_size; 977 - struct mount_options parsed_options; 973 + struct mount_options *parsed_options = fc->fs_private; 978 974 struct inode *inode = NULL; 979 975 struct ocfs2_super *osb = NULL; 980 976 struct buffer_head *bh = NULL; 981 977 char nodestr[12]; 982 978 struct ocfs2_blockcheck_stats stats; 983 979 984 - trace_ocfs2_fill_super(sb, data, silent); 985 - 986 - if (!ocfs2_parse_options(sb, data, &parsed_options, 0)) { 987 - status = -EINVAL; 988 - goto out; 989 - } 980 + trace_ocfs2_fill_super(sb, fc, fc->sb_flags & SB_SILENT); 990 981 991 982 /* probe for superblock */ 992 983 status = ocfs2_sb_probe(sb, &bh, &sector_size, &stats); ··· 998 999 999 1000 osb = OCFS2_SB(sb); 1000 1001 1001 - if (!ocfs2_check_set_options(sb, &parsed_options)) { 1002 + if (!ocfs2_check_set_options(sb, parsed_options)) { 1002 1003 status = -EINVAL; 1003 1004 goto out_super; 1004 1005 } 1005 - osb->s_mount_opt = parsed_options.mount_opt; 1006 - osb->s_atime_quantum = parsed_options.atime_quantum; 1007 - osb->preferred_slot = parsed_options.slot; 1008 - osb->osb_commit_interval = parsed_options.commit_interval; 1006 + osb->s_mount_opt = parsed_options->mount_opt; 1007 + osb->s_atime_quantum = parsed_options->atime_quantum; 1008 + osb->preferred_slot = parsed_options->slot; 1009 + osb->osb_commit_interval = parsed_options->commit_interval; 1009 1010 1010 - ocfs2_la_set_sizes(osb, parsed_options.localalloc_opt); 1011 - osb->osb_resv_level = parsed_options.resv_level; 1012 - osb->osb_dir_resv_level = parsed_options.resv_level; 1013 - if (parsed_options.dir_resv_level == -1) 1014 - osb->osb_dir_resv_level = parsed_options.resv_level; 1011 + ocfs2_la_set_sizes(osb, parsed_options->localalloc_opt); 1012 + osb->osb_resv_level = parsed_options->resv_level; 1013 + osb->osb_dir_resv_level = parsed_options->resv_level; 1014 + if (parsed_options->dir_resv_level == -1) 1015 + osb->osb_dir_resv_level = parsed_options->resv_level; 1015 1016 else 1016 - osb->osb_dir_resv_level = parsed_options.dir_resv_level; 1017 + osb->osb_dir_resv_level = parsed_options->dir_resv_level; 1017 1018 1018 - status = ocfs2_verify_userspace_stack(osb, &parsed_options); 1019 + status = ocfs2_verify_userspace_stack(osb, parsed_options); 1019 1020 if (status) 1020 1021 goto out_super; 1021 1022 ··· 1179 1180 return status; 1180 1181 } 1181 1182 1182 - static struct dentry *ocfs2_mount(struct file_system_type *fs_type, 1183 - int flags, 1184 - const char *dev_name, 1185 - void *data) 1183 + static int ocfs2_get_tree(struct fs_context *fc) 1186 1184 { 1187 - return mount_bdev(fs_type, flags, dev_name, data, ocfs2_fill_super); 1185 + return get_tree_bdev(fc, ocfs2_fill_super); 1186 + } 1187 + 1188 + static void ocfs2_free_fc(struct fs_context *fc) 1189 + { 1190 + kfree(fc->fs_private); 1191 + } 1192 + 1193 + static const struct fs_context_operations ocfs2_context_ops = { 1194 + .parse_param = ocfs2_parse_param, 1195 + .get_tree = ocfs2_get_tree, 1196 + .reconfigure = ocfs2_reconfigure, 1197 + .free = ocfs2_free_fc, 1198 + }; 1199 + 1200 + static int ocfs2_init_fs_context(struct fs_context *fc) 1201 + { 1202 + struct mount_options *mopt; 1203 + 1204 + mopt = kzalloc(sizeof(struct mount_options), GFP_KERNEL); 1205 + if (!mopt) 1206 + return -EINVAL; 1207 + 1208 + mopt->commit_interval = 0; 1209 + mopt->mount_opt = OCFS2_MOUNT_NOINTR; 1210 + mopt->atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; 1211 + mopt->slot = OCFS2_INVALID_SLOT; 1212 + mopt->localalloc_opt = -1; 1213 + mopt->cluster_stack[0] = '\0'; 1214 + mopt->resv_level = OCFS2_DEFAULT_RESV_LEVEL; 1215 + mopt->dir_resv_level = -1; 1216 + 1217 + fc->fs_private = mopt; 1218 + fc->ops = &ocfs2_context_ops; 1219 + 1220 + return 0; 1188 1221 } 1189 1222 1190 1223 static struct file_system_type ocfs2_fs_type = { 1191 1224 .owner = THIS_MODULE, 1192 1225 .name = "ocfs2", 1193 - .mount = ocfs2_mount, 1194 1226 .kill_sb = kill_block_super, 1195 1227 .fs_flags = FS_REQUIRES_DEV|FS_RENAME_DOES_D_MOVE, 1196 - .next = NULL 1228 + .next = NULL, 1229 + .init_fs_context = ocfs2_init_fs_context, 1230 + .parameters = ocfs2_param_spec, 1197 1231 }; 1198 1232 MODULE_ALIAS_FS("ocfs2"); 1199 1233 1200 1234 static int ocfs2_check_set_options(struct super_block *sb, 1201 1235 struct mount_options *options) 1202 1236 { 1237 + if (options->user_stack == 0) { 1238 + u32 tmp; 1239 + 1240 + /* Ensure only one heartbeat mode */ 1241 + tmp = options->mount_opt & (OCFS2_MOUNT_HB_LOCAL | 1242 + OCFS2_MOUNT_HB_GLOBAL | 1243 + OCFS2_MOUNT_HB_NONE); 1244 + if (hweight32(tmp) != 1) { 1245 + mlog(ML_ERROR, "Invalid heartbeat mount options\n"); 1246 + return 0; 1247 + } 1248 + } 1203 1249 if (options->mount_opt & OCFS2_MOUNT_USRQUOTA && 1204 1250 !OCFS2_HAS_RO_COMPAT_FEATURE(sb, 1205 1251 OCFS2_FEATURE_RO_COMPAT_USRQUOTA)) { ··· 1276 1232 return 1; 1277 1233 } 1278 1234 1279 - static int ocfs2_parse_options(struct super_block *sb, 1280 - char *options, 1281 - struct mount_options *mopt, 1282 - int is_remount) 1235 + static int ocfs2_parse_param(struct fs_context *fc, struct fs_parameter *param) 1283 1236 { 1284 - int status, user_stack = 0; 1285 - char *p; 1286 - u32 tmp; 1287 - int token, option; 1288 - substring_t args[MAX_OPT_ARGS]; 1237 + struct fs_parse_result result; 1238 + int opt; 1239 + struct mount_options *mopt = fc->fs_private; 1240 + bool is_remount = (fc->purpose & FS_CONTEXT_FOR_RECONFIGURE); 1289 1241 1290 - trace_ocfs2_parse_options(is_remount, options ? options : "(none)"); 1242 + trace_ocfs2_parse_options(is_remount, param->key); 1291 1243 1292 - mopt->commit_interval = 0; 1293 - mopt->mount_opt = OCFS2_MOUNT_NOINTR; 1294 - mopt->atime_quantum = OCFS2_DEFAULT_ATIME_QUANTUM; 1295 - mopt->slot = OCFS2_INVALID_SLOT; 1296 - mopt->localalloc_opt = -1; 1297 - mopt->cluster_stack[0] = '\0'; 1298 - mopt->resv_level = OCFS2_DEFAULT_RESV_LEVEL; 1299 - mopt->dir_resv_level = -1; 1244 + opt = fs_parse(fc, ocfs2_param_spec, param, &result); 1245 + if (opt < 0) 1246 + return opt; 1300 1247 1301 - if (!options) { 1302 - status = 1; 1303 - goto bail; 1304 - } 1305 - 1306 - while ((p = strsep(&options, ",")) != NULL) { 1307 - if (!*p) 1308 - continue; 1309 - 1310 - token = match_token(p, tokens, args); 1311 - switch (token) { 1312 - case Opt_hb_local: 1313 - mopt->mount_opt |= OCFS2_MOUNT_HB_LOCAL; 1314 - break; 1315 - case Opt_hb_none: 1316 - mopt->mount_opt |= OCFS2_MOUNT_HB_NONE; 1317 - break; 1318 - case Opt_hb_global: 1319 - mopt->mount_opt |= OCFS2_MOUNT_HB_GLOBAL; 1320 - break; 1321 - case Opt_barrier: 1322 - if (match_int(&args[0], &option)) { 1323 - status = 0; 1324 - goto bail; 1325 - } 1326 - if (option) 1327 - mopt->mount_opt |= OCFS2_MOUNT_BARRIER; 1328 - else 1329 - mopt->mount_opt &= ~OCFS2_MOUNT_BARRIER; 1330 - break; 1331 - case Opt_intr: 1332 - mopt->mount_opt &= ~OCFS2_MOUNT_NOINTR; 1333 - break; 1334 - case Opt_nointr: 1248 + switch (opt) { 1249 + case Opt_heartbeat: 1250 + mopt->mount_opt |= result.uint_32; 1251 + break; 1252 + case Opt_barrier: 1253 + if (result.uint_32) 1254 + mopt->mount_opt |= OCFS2_MOUNT_BARRIER; 1255 + else 1256 + mopt->mount_opt &= ~OCFS2_MOUNT_BARRIER; 1257 + break; 1258 + case Opt_intr: 1259 + if (result.negated) 1335 1260 mopt->mount_opt |= OCFS2_MOUNT_NOINTR; 1336 - break; 1337 - case Opt_err_panic: 1338 - mopt->mount_opt &= ~OCFS2_MOUNT_ERRORS_CONT; 1339 - mopt->mount_opt &= ~OCFS2_MOUNT_ERRORS_ROFS; 1340 - mopt->mount_opt |= OCFS2_MOUNT_ERRORS_PANIC; 1341 - break; 1342 - case Opt_err_ro: 1343 - mopt->mount_opt &= ~OCFS2_MOUNT_ERRORS_CONT; 1344 - mopt->mount_opt &= ~OCFS2_MOUNT_ERRORS_PANIC; 1345 - mopt->mount_opt |= OCFS2_MOUNT_ERRORS_ROFS; 1346 - break; 1347 - case Opt_err_cont: 1348 - mopt->mount_opt &= ~OCFS2_MOUNT_ERRORS_ROFS; 1349 - mopt->mount_opt &= ~OCFS2_MOUNT_ERRORS_PANIC; 1350 - mopt->mount_opt |= OCFS2_MOUNT_ERRORS_CONT; 1351 - break; 1352 - case Opt_data_ordered: 1353 - mopt->mount_opt &= ~OCFS2_MOUNT_DATA_WRITEBACK; 1354 - break; 1355 - case Opt_data_writeback: 1356 - mopt->mount_opt |= OCFS2_MOUNT_DATA_WRITEBACK; 1357 - break; 1358 - case Opt_user_xattr: 1359 - mopt->mount_opt &= ~OCFS2_MOUNT_NOUSERXATTR; 1360 - break; 1361 - case Opt_nouser_xattr: 1261 + else 1262 + mopt->mount_opt &= ~OCFS2_MOUNT_NOINTR; 1263 + break; 1264 + case Opt_errors: 1265 + mopt->mount_opt &= ~(OCFS2_MOUNT_ERRORS_CONT | 1266 + OCFS2_MOUNT_ERRORS_ROFS | 1267 + OCFS2_MOUNT_ERRORS_PANIC); 1268 + mopt->mount_opt |= result.uint_32; 1269 + break; 1270 + case Opt_data: 1271 + mopt->mount_opt &= ~OCFS2_MOUNT_DATA_WRITEBACK; 1272 + mopt->mount_opt |= result.uint_32; 1273 + break; 1274 + case Opt_user_xattr: 1275 + if (result.negated) 1362 1276 mopt->mount_opt |= OCFS2_MOUNT_NOUSERXATTR; 1363 - break; 1364 - case Opt_atime_quantum: 1365 - if (match_int(&args[0], &option)) { 1366 - status = 0; 1367 - goto bail; 1368 - } 1369 - if (option >= 0) 1370 - mopt->atime_quantum = option; 1371 - break; 1372 - case Opt_slot: 1373 - if (match_int(&args[0], &option)) { 1374 - status = 0; 1375 - goto bail; 1376 - } 1377 - if (option) 1378 - mopt->slot = (u16)option; 1379 - break; 1380 - case Opt_commit: 1381 - if (match_int(&args[0], &option)) { 1382 - status = 0; 1383 - goto bail; 1384 - } 1385 - if (option < 0) 1386 - return 0; 1387 - if (option == 0) 1388 - option = JBD2_DEFAULT_MAX_COMMIT_AGE; 1389 - mopt->commit_interval = HZ * option; 1390 - break; 1391 - case Opt_localalloc: 1392 - if (match_int(&args[0], &option)) { 1393 - status = 0; 1394 - goto bail; 1395 - } 1396 - if (option >= 0) 1397 - mopt->localalloc_opt = option; 1398 - break; 1399 - case Opt_localflocks: 1400 - /* 1401 - * Changing this during remount could race 1402 - * flock() requests, or "unbalance" existing 1403 - * ones (e.g., a lock is taken in one mode but 1404 - * dropped in the other). If users care enough 1405 - * to flip locking modes during remount, we 1406 - * could add a "local" flag to individual 1407 - * flock structures for proper tracking of 1408 - * state. 1409 - */ 1410 - if (!is_remount) 1411 - mopt->mount_opt |= OCFS2_MOUNT_LOCALFLOCKS; 1412 - break; 1413 - case Opt_stack: 1414 - /* Check both that the option we were passed 1415 - * is of the right length and that it is a proper 1416 - * string of the right length. 1417 - */ 1418 - if (((args[0].to - args[0].from) != 1419 - OCFS2_STACK_LABEL_LEN) || 1420 - (strnlen(args[0].from, 1421 - OCFS2_STACK_LABEL_LEN) != 1422 - OCFS2_STACK_LABEL_LEN)) { 1423 - mlog(ML_ERROR, 1424 - "Invalid cluster_stack option\n"); 1425 - status = 0; 1426 - goto bail; 1427 - } 1428 - memcpy(mopt->cluster_stack, args[0].from, 1429 - OCFS2_STACK_LABEL_LEN); 1430 - mopt->cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0'; 1431 - /* 1432 - * Open code the memcmp here as we don't have 1433 - * an osb to pass to 1434 - * ocfs2_userspace_stack(). 1435 - */ 1436 - if (memcmp(mopt->cluster_stack, 1437 - OCFS2_CLASSIC_CLUSTER_STACK, 1438 - OCFS2_STACK_LABEL_LEN)) 1439 - user_stack = 1; 1440 - break; 1441 - case Opt_inode64: 1442 - mopt->mount_opt |= OCFS2_MOUNT_INODE64; 1443 - break; 1444 - case Opt_usrquota: 1445 - mopt->mount_opt |= OCFS2_MOUNT_USRQUOTA; 1446 - break; 1447 - case Opt_grpquota: 1448 - mopt->mount_opt |= OCFS2_MOUNT_GRPQUOTA; 1449 - break; 1450 - case Opt_coherency_buffered: 1451 - mopt->mount_opt |= OCFS2_MOUNT_COHERENCY_BUFFERED; 1452 - break; 1453 - case Opt_coherency_full: 1454 - mopt->mount_opt &= ~OCFS2_MOUNT_COHERENCY_BUFFERED; 1455 - break; 1456 - case Opt_acl: 1457 - mopt->mount_opt |= OCFS2_MOUNT_POSIX_ACL; 1458 - mopt->mount_opt &= ~OCFS2_MOUNT_NO_POSIX_ACL; 1459 - break; 1460 - case Opt_noacl: 1277 + else 1278 + mopt->mount_opt &= ~OCFS2_MOUNT_NOUSERXATTR; 1279 + break; 1280 + case Opt_atime_quantum: 1281 + mopt->atime_quantum = result.uint_32; 1282 + break; 1283 + case Opt_slot: 1284 + if (result.uint_32) 1285 + mopt->slot = (u16)result.uint_32; 1286 + break; 1287 + case Opt_commit: 1288 + if (result.uint_32 == 0) 1289 + mopt->commit_interval = HZ * JBD2_DEFAULT_MAX_COMMIT_AGE; 1290 + else 1291 + mopt->commit_interval = HZ * result.uint_32; 1292 + break; 1293 + case Opt_localalloc: 1294 + if (result.int_32 >= 0) 1295 + mopt->localalloc_opt = result.int_32; 1296 + break; 1297 + case Opt_localflocks: 1298 + /* 1299 + * Changing this during remount could race flock() requests, or 1300 + * "unbalance" existing ones (e.g., a lock is taken in one mode 1301 + * but dropped in the other). If users care enough to flip 1302 + * locking modes during remount, we could add a "local" flag to 1303 + * individual flock structures for proper tracking of state. 1304 + */ 1305 + if (!is_remount) 1306 + mopt->mount_opt |= OCFS2_MOUNT_LOCALFLOCKS; 1307 + break; 1308 + case Opt_stack: 1309 + /* Check both that the option we were passed is of the right 1310 + * length and that it is a proper string of the right length. 1311 + */ 1312 + if (strlen(param->string) != OCFS2_STACK_LABEL_LEN) { 1313 + mlog(ML_ERROR, "Invalid cluster_stack option\n"); 1314 + return -EINVAL; 1315 + } 1316 + memcpy(mopt->cluster_stack, param->string, OCFS2_STACK_LABEL_LEN); 1317 + mopt->cluster_stack[OCFS2_STACK_LABEL_LEN] = '\0'; 1318 + /* 1319 + * Open code the memcmp here as we don't have an osb to pass 1320 + * to ocfs2_userspace_stack(). 1321 + */ 1322 + if (memcmp(mopt->cluster_stack, 1323 + OCFS2_CLASSIC_CLUSTER_STACK, 1324 + OCFS2_STACK_LABEL_LEN)) 1325 + mopt->user_stack = 1; 1326 + break; 1327 + case Opt_inode64: 1328 + mopt->mount_opt |= OCFS2_MOUNT_INODE64; 1329 + break; 1330 + case Opt_usrquota: 1331 + mopt->mount_opt |= OCFS2_MOUNT_USRQUOTA; 1332 + break; 1333 + case Opt_grpquota: 1334 + mopt->mount_opt |= OCFS2_MOUNT_GRPQUOTA; 1335 + break; 1336 + case Opt_coherency: 1337 + mopt->mount_opt &= ~OCFS2_MOUNT_COHERENCY_BUFFERED; 1338 + mopt->mount_opt |= result.uint_32; 1339 + break; 1340 + case Opt_acl: 1341 + if (result.negated) { 1461 1342 mopt->mount_opt |= OCFS2_MOUNT_NO_POSIX_ACL; 1462 1343 mopt->mount_opt &= ~OCFS2_MOUNT_POSIX_ACL; 1463 - break; 1464 - case Opt_resv_level: 1465 - if (is_remount) 1466 - break; 1467 - if (match_int(&args[0], &option)) { 1468 - status = 0; 1469 - goto bail; 1470 - } 1471 - if (option >= OCFS2_MIN_RESV_LEVEL && 1472 - option < OCFS2_MAX_RESV_LEVEL) 1473 - mopt->resv_level = option; 1474 - break; 1475 - case Opt_dir_resv_level: 1476 - if (is_remount) 1477 - break; 1478 - if (match_int(&args[0], &option)) { 1479 - status = 0; 1480 - goto bail; 1481 - } 1482 - if (option >= OCFS2_MIN_RESV_LEVEL && 1483 - option < OCFS2_MAX_RESV_LEVEL) 1484 - mopt->dir_resv_level = option; 1485 - break; 1486 - case Opt_journal_async_commit: 1487 - mopt->mount_opt |= OCFS2_MOUNT_JOURNAL_ASYNC_COMMIT; 1488 - break; 1489 - default: 1490 - mlog(ML_ERROR, 1491 - "Unrecognized mount option \"%s\" " 1492 - "or missing value\n", p); 1493 - status = 0; 1494 - goto bail; 1344 + } else { 1345 + mopt->mount_opt |= OCFS2_MOUNT_POSIX_ACL; 1346 + mopt->mount_opt &= ~OCFS2_MOUNT_NO_POSIX_ACL; 1495 1347 } 1348 + break; 1349 + case Opt_resv_level: 1350 + if (is_remount) 1351 + break; 1352 + if (result.uint_32 >= OCFS2_MIN_RESV_LEVEL && 1353 + result.uint_32 < OCFS2_MAX_RESV_LEVEL) 1354 + mopt->resv_level = result.uint_32; 1355 + break; 1356 + case Opt_dir_resv_level: 1357 + if (is_remount) 1358 + break; 1359 + if (result.uint_32 >= OCFS2_MIN_RESV_LEVEL && 1360 + result.uint_32 < OCFS2_MAX_RESV_LEVEL) 1361 + mopt->dir_resv_level = result.uint_32; 1362 + break; 1363 + case Opt_journal_async_commit: 1364 + mopt->mount_opt |= OCFS2_MOUNT_JOURNAL_ASYNC_COMMIT; 1365 + break; 1366 + default: 1367 + return -EINVAL; 1496 1368 } 1497 1369 1498 - if (user_stack == 0) { 1499 - /* Ensure only one heartbeat mode */ 1500 - tmp = mopt->mount_opt & (OCFS2_MOUNT_HB_LOCAL | 1501 - OCFS2_MOUNT_HB_GLOBAL | 1502 - OCFS2_MOUNT_HB_NONE); 1503 - if (hweight32(tmp) != 1) { 1504 - mlog(ML_ERROR, "Invalid heartbeat mount options\n"); 1505 - status = 0; 1506 - goto bail; 1507 - } 1508 - } 1509 - 1510 - status = 1; 1511 - 1512 - bail: 1513 - return status; 1370 + return 0; 1514 1371 } 1515 1372 1516 1373 static int ocfs2_show_options(struct seq_file *s, struct dentry *root)