diff options
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 397 |
1 files changed, 245 insertions, 152 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 6ed9aa91f27d..e14d22c170d5 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -68,7 +68,21 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf); | |||
68 | static int ext4_unfreeze(struct super_block *sb); | 68 | static int ext4_unfreeze(struct super_block *sb); |
69 | static void ext4_write_super(struct super_block *sb); | 69 | static void ext4_write_super(struct super_block *sb); |
70 | static int ext4_freeze(struct super_block *sb); | 70 | static int ext4_freeze(struct super_block *sb); |
71 | static int ext4_get_sb(struct file_system_type *fs_type, int flags, | ||
72 | const char *dev_name, void *data, struct vfsmount *mnt); | ||
71 | 73 | ||
74 | #if !defined(CONFIG_EXT3_FS) && !defined(CONFIG_EXT3_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT23) | ||
75 | static struct file_system_type ext3_fs_type = { | ||
76 | .owner = THIS_MODULE, | ||
77 | .name = "ext3", | ||
78 | .get_sb = ext4_get_sb, | ||
79 | .kill_sb = kill_block_super, | ||
80 | .fs_flags = FS_REQUIRES_DEV, | ||
81 | }; | ||
82 | #define IS_EXT3_SB(sb) ((sb)->s_bdev->bd_holder == &ext3_fs_type) | ||
83 | #else | ||
84 | #define IS_EXT3_SB(sb) (0) | ||
85 | #endif | ||
72 | 86 | ||
73 | ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, | 87 | ext4_fsblk_t ext4_block_bitmap(struct super_block *sb, |
74 | struct ext4_group_desc *bg) | 88 | struct ext4_group_desc *bg) |
@@ -302,7 +316,7 @@ void ext4_journal_abort_handle(const char *caller, const char *err_fn, | |||
302 | * write out the superblock safely. | 316 | * write out the superblock safely. |
303 | * | 317 | * |
304 | * We'll just use the jbd2_journal_abort() error code to record an error in | 318 | * We'll just use the jbd2_journal_abort() error code to record an error in |
305 | * the journal instead. On recovery, the journal will compain about | 319 | * the journal instead. On recovery, the journal will complain about |
306 | * that error until we've noted it down and cleared it. | 320 | * that error until we've noted it down and cleared it. |
307 | */ | 321 | */ |
308 | 322 | ||
@@ -333,7 +347,7 @@ static void ext4_handle_error(struct super_block *sb) | |||
333 | sb->s_id); | 347 | sb->s_id); |
334 | } | 348 | } |
335 | 349 | ||
336 | void ext4_error(struct super_block *sb, const char *function, | 350 | void __ext4_error(struct super_block *sb, const char *function, |
337 | const char *fmt, ...) | 351 | const char *fmt, ...) |
338 | { | 352 | { |
339 | va_list args; | 353 | va_list args; |
@@ -347,6 +361,42 @@ void ext4_error(struct super_block *sb, const char *function, | |||
347 | ext4_handle_error(sb); | 361 | ext4_handle_error(sb); |
348 | } | 362 | } |
349 | 363 | ||
364 | void ext4_error_inode(const char *function, struct inode *inode, | ||
365 | const char *fmt, ...) | ||
366 | { | ||
367 | va_list args; | ||
368 | |||
369 | va_start(args, fmt); | ||
370 | printk(KERN_CRIT "EXT4-fs error (device %s): %s: inode #%lu: (comm %s) ", | ||
371 | inode->i_sb->s_id, function, inode->i_ino, current->comm); | ||
372 | vprintk(fmt, args); | ||
373 | printk("\n"); | ||
374 | va_end(args); | ||
375 | |||
376 | ext4_handle_error(inode->i_sb); | ||
377 | } | ||
378 | |||
379 | void ext4_error_file(const char *function, struct file *file, | ||
380 | const char *fmt, ...) | ||
381 | { | ||
382 | va_list args; | ||
383 | struct inode *inode = file->f_dentry->d_inode; | ||
384 | char pathname[80], *path; | ||
385 | |||
386 | va_start(args, fmt); | ||
387 | path = d_path(&(file->f_path), pathname, sizeof(pathname)); | ||
388 | if (!path) | ||
389 | path = "(unknown)"; | ||
390 | printk(KERN_CRIT | ||
391 | "EXT4-fs error (device %s): %s: inode #%lu (comm %s path %s): ", | ||
392 | inode->i_sb->s_id, function, inode->i_ino, current->comm, path); | ||
393 | vprintk(fmt, args); | ||
394 | printk("\n"); | ||
395 | va_end(args); | ||
396 | |||
397 | ext4_handle_error(inode->i_sb); | ||
398 | } | ||
399 | |||
350 | static const char *ext4_decode_error(struct super_block *sb, int errno, | 400 | static const char *ext4_decode_error(struct super_block *sb, int errno, |
351 | char nbuf[16]) | 401 | char nbuf[16]) |
352 | { | 402 | { |
@@ -450,7 +500,7 @@ void ext4_msg (struct super_block * sb, const char *prefix, | |||
450 | va_end(args); | 500 | va_end(args); |
451 | } | 501 | } |
452 | 502 | ||
453 | void ext4_warning(struct super_block *sb, const char *function, | 503 | void __ext4_warning(struct super_block *sb, const char *function, |
454 | const char *fmt, ...) | 504 | const char *fmt, ...) |
455 | { | 505 | { |
456 | va_list args; | 506 | va_list args; |
@@ -507,7 +557,7 @@ void ext4_update_dynamic_rev(struct super_block *sb) | |||
507 | if (le32_to_cpu(es->s_rev_level) > EXT4_GOOD_OLD_REV) | 557 | if (le32_to_cpu(es->s_rev_level) > EXT4_GOOD_OLD_REV) |
508 | return; | 558 | return; |
509 | 559 | ||
510 | ext4_warning(sb, __func__, | 560 | ext4_warning(sb, |
511 | "updating to rev %d because of new feature flag, " | 561 | "updating to rev %d because of new feature flag, " |
512 | "running e2fsck is recommended", | 562 | "running e2fsck is recommended", |
513 | EXT4_DYNAMIC_REV); | 563 | EXT4_DYNAMIC_REV); |
@@ -702,12 +752,14 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) | |||
702 | ei->i_reserved_data_blocks = 0; | 752 | ei->i_reserved_data_blocks = 0; |
703 | ei->i_reserved_meta_blocks = 0; | 753 | ei->i_reserved_meta_blocks = 0; |
704 | ei->i_allocated_meta_blocks = 0; | 754 | ei->i_allocated_meta_blocks = 0; |
755 | ei->i_da_metadata_calc_len = 0; | ||
705 | ei->i_delalloc_reserved_flag = 0; | 756 | ei->i_delalloc_reserved_flag = 0; |
706 | spin_lock_init(&(ei->i_block_reservation_lock)); | 757 | spin_lock_init(&(ei->i_block_reservation_lock)); |
707 | #ifdef CONFIG_QUOTA | 758 | #ifdef CONFIG_QUOTA |
708 | ei->i_reserved_quota = 0; | 759 | ei->i_reserved_quota = 0; |
709 | #endif | 760 | #endif |
710 | INIT_LIST_HEAD(&ei->i_aio_dio_complete_list); | 761 | INIT_LIST_HEAD(&ei->i_completed_io_list); |
762 | spin_lock_init(&ei->i_completed_io_lock); | ||
711 | ei->cur_aio_dio = NULL; | 763 | ei->cur_aio_dio = NULL; |
712 | ei->i_sync_tid = 0; | 764 | ei->i_sync_tid = 0; |
713 | ei->i_datasync_tid = 0; | 765 | ei->i_datasync_tid = 0; |
@@ -760,6 +812,7 @@ static void destroy_inodecache(void) | |||
760 | 812 | ||
761 | static void ext4_clear_inode(struct inode *inode) | 813 | static void ext4_clear_inode(struct inode *inode) |
762 | { | 814 | { |
815 | dquot_drop(inode); | ||
763 | ext4_discard_preallocations(inode); | 816 | ext4_discard_preallocations(inode); |
764 | if (EXT4_JOURNAL(inode)) | 817 | if (EXT4_JOURNAL(inode)) |
765 | jbd2_journal_release_jbd_inode(EXT4_SB(inode->i_sb)->s_journal, | 818 | jbd2_journal_release_jbd_inode(EXT4_SB(inode->i_sb)->s_journal, |
@@ -795,10 +848,10 @@ static inline void ext4_show_quota_options(struct seq_file *seq, | |||
795 | if (sbi->s_qf_names[GRPQUOTA]) | 848 | if (sbi->s_qf_names[GRPQUOTA]) |
796 | seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]); | 849 | seq_printf(seq, ",grpjquota=%s", sbi->s_qf_names[GRPQUOTA]); |
797 | 850 | ||
798 | if (sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA) | 851 | if (test_opt(sb, USRQUOTA)) |
799 | seq_puts(seq, ",usrquota"); | 852 | seq_puts(seq, ",usrquota"); |
800 | 853 | ||
801 | if (sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA) | 854 | if (test_opt(sb, GRPQUOTA)) |
802 | seq_puts(seq, ",grpquota"); | 855 | seq_puts(seq, ",grpquota"); |
803 | #endif | 856 | #endif |
804 | } | 857 | } |
@@ -925,6 +978,9 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
925 | if (test_opt(sb, NOLOAD)) | 978 | if (test_opt(sb, NOLOAD)) |
926 | seq_puts(seq, ",norecovery"); | 979 | seq_puts(seq, ",norecovery"); |
927 | 980 | ||
981 | if (test_opt(sb, DIOREAD_NOLOCK)) | ||
982 | seq_puts(seq, ",dioread_nolock"); | ||
983 | |||
928 | ext4_show_quota_options(seq, sb); | 984 | ext4_show_quota_options(seq, sb); |
929 | 985 | ||
930 | return 0; | 986 | return 0; |
@@ -1011,19 +1067,9 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type, | |||
1011 | const char *data, size_t len, loff_t off); | 1067 | const char *data, size_t len, loff_t off); |
1012 | 1068 | ||
1013 | static const struct dquot_operations ext4_quota_operations = { | 1069 | static const struct dquot_operations ext4_quota_operations = { |
1014 | .initialize = dquot_initialize, | ||
1015 | .drop = dquot_drop, | ||
1016 | .alloc_space = dquot_alloc_space, | ||
1017 | .reserve_space = dquot_reserve_space, | ||
1018 | .claim_space = dquot_claim_space, | ||
1019 | .release_rsv = dquot_release_reserved_space, | ||
1020 | #ifdef CONFIG_QUOTA | 1070 | #ifdef CONFIG_QUOTA |
1021 | .get_reserved_space = ext4_get_reserved_space, | 1071 | .get_reserved_space = ext4_get_reserved_space, |
1022 | #endif | 1072 | #endif |
1023 | .alloc_inode = dquot_alloc_inode, | ||
1024 | .free_space = dquot_free_space, | ||
1025 | .free_inode = dquot_free_inode, | ||
1026 | .transfer = dquot_transfer, | ||
1027 | .write_dquot = ext4_write_dquot, | 1073 | .write_dquot = ext4_write_dquot, |
1028 | .acquire_dquot = ext4_acquire_dquot, | 1074 | .acquire_dquot = ext4_acquire_dquot, |
1029 | .release_dquot = ext4_release_dquot, | 1075 | .release_dquot = ext4_release_dquot, |
@@ -1108,6 +1154,7 @@ enum { | |||
1108 | Opt_stripe, Opt_delalloc, Opt_nodelalloc, | 1154 | Opt_stripe, Opt_delalloc, Opt_nodelalloc, |
1109 | Opt_block_validity, Opt_noblock_validity, | 1155 | Opt_block_validity, Opt_noblock_validity, |
1110 | Opt_inode_readahead_blks, Opt_journal_ioprio, | 1156 | Opt_inode_readahead_blks, Opt_journal_ioprio, |
1157 | Opt_dioread_nolock, Opt_dioread_lock, | ||
1111 | Opt_discard, Opt_nodiscard, | 1158 | Opt_discard, Opt_nodiscard, |
1112 | }; | 1159 | }; |
1113 | 1160 | ||
@@ -1175,6 +1222,8 @@ static const match_table_t tokens = { | |||
1175 | {Opt_auto_da_alloc, "auto_da_alloc=%u"}, | 1222 | {Opt_auto_da_alloc, "auto_da_alloc=%u"}, |
1176 | {Opt_auto_da_alloc, "auto_da_alloc"}, | 1223 | {Opt_auto_da_alloc, "auto_da_alloc"}, |
1177 | {Opt_noauto_da_alloc, "noauto_da_alloc"}, | 1224 | {Opt_noauto_da_alloc, "noauto_da_alloc"}, |
1225 | {Opt_dioread_nolock, "dioread_nolock"}, | ||
1226 | {Opt_dioread_lock, "dioread_lock"}, | ||
1178 | {Opt_discard, "discard"}, | 1227 | {Opt_discard, "discard"}, |
1179 | {Opt_nodiscard, "nodiscard"}, | 1228 | {Opt_nodiscard, "nodiscard"}, |
1180 | {Opt_err, NULL}, | 1229 | {Opt_err, NULL}, |
@@ -1204,6 +1253,66 @@ static ext4_fsblk_t get_sb_block(void **data) | |||
1204 | } | 1253 | } |
1205 | 1254 | ||
1206 | #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3)) | 1255 | #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3)) |
1256 | static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n" | ||
1257 | "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n"; | ||
1258 | |||
1259 | #ifdef CONFIG_QUOTA | ||
1260 | static int set_qf_name(struct super_block *sb, int qtype, substring_t *args) | ||
1261 | { | ||
1262 | struct ext4_sb_info *sbi = EXT4_SB(sb); | ||
1263 | char *qname; | ||
1264 | |||
1265 | if (sb_any_quota_loaded(sb) && | ||
1266 | !sbi->s_qf_names[qtype]) { | ||
1267 | ext4_msg(sb, KERN_ERR, | ||
1268 | "Cannot change journaled " | ||
1269 | "quota options when quota turned on"); | ||
1270 | return 0; | ||
1271 | } | ||
1272 | qname = match_strdup(args); | ||
1273 | if (!qname) { | ||
1274 | ext4_msg(sb, KERN_ERR, | ||
1275 | "Not enough memory for storing quotafile name"); | ||
1276 | return 0; | ||
1277 | } | ||
1278 | if (sbi->s_qf_names[qtype] && | ||
1279 | strcmp(sbi->s_qf_names[qtype], qname)) { | ||
1280 | ext4_msg(sb, KERN_ERR, | ||
1281 | "%s quota file already specified", QTYPE2NAME(qtype)); | ||
1282 | kfree(qname); | ||
1283 | return 0; | ||
1284 | } | ||
1285 | sbi->s_qf_names[qtype] = qname; | ||
1286 | if (strchr(sbi->s_qf_names[qtype], '/')) { | ||
1287 | ext4_msg(sb, KERN_ERR, | ||
1288 | "quotafile must be on filesystem root"); | ||
1289 | kfree(sbi->s_qf_names[qtype]); | ||
1290 | sbi->s_qf_names[qtype] = NULL; | ||
1291 | return 0; | ||
1292 | } | ||
1293 | set_opt(sbi->s_mount_opt, QUOTA); | ||
1294 | return 1; | ||
1295 | } | ||
1296 | |||
1297 | static int clear_qf_name(struct super_block *sb, int qtype) | ||
1298 | { | ||
1299 | |||
1300 | struct ext4_sb_info *sbi = EXT4_SB(sb); | ||
1301 | |||
1302 | if (sb_any_quota_loaded(sb) && | ||
1303 | sbi->s_qf_names[qtype]) { | ||
1304 | ext4_msg(sb, KERN_ERR, "Cannot change journaled quota options" | ||
1305 | " when quota turned on"); | ||
1306 | return 0; | ||
1307 | } | ||
1308 | /* | ||
1309 | * The space will be released later when all options are confirmed | ||
1310 | * to be correct | ||
1311 | */ | ||
1312 | sbi->s_qf_names[qtype] = NULL; | ||
1313 | return 1; | ||
1314 | } | ||
1315 | #endif | ||
1207 | 1316 | ||
1208 | static int parse_options(char *options, struct super_block *sb, | 1317 | static int parse_options(char *options, struct super_block *sb, |
1209 | unsigned long *journal_devnum, | 1318 | unsigned long *journal_devnum, |
@@ -1216,8 +1325,7 @@ static int parse_options(char *options, struct super_block *sb, | |||
1216 | int data_opt = 0; | 1325 | int data_opt = 0; |
1217 | int option; | 1326 | int option; |
1218 | #ifdef CONFIG_QUOTA | 1327 | #ifdef CONFIG_QUOTA |
1219 | int qtype, qfmt; | 1328 | int qfmt; |
1220 | char *qname; | ||
1221 | #endif | 1329 | #endif |
1222 | 1330 | ||
1223 | if (!options) | 1331 | if (!options) |
@@ -1228,19 +1336,31 @@ static int parse_options(char *options, struct super_block *sb, | |||
1228 | if (!*p) | 1336 | if (!*p) |
1229 | continue; | 1337 | continue; |
1230 | 1338 | ||
1339 | /* | ||
1340 | * Initialize args struct so we know whether arg was | ||
1341 | * found; some options take optional arguments. | ||
1342 | */ | ||
1343 | args[0].to = args[0].from = 0; | ||
1231 | token = match_token(p, tokens, args); | 1344 | token = match_token(p, tokens, args); |
1232 | switch (token) { | 1345 | switch (token) { |
1233 | case Opt_bsd_df: | 1346 | case Opt_bsd_df: |
1347 | ext4_msg(sb, KERN_WARNING, deprecated_msg, p, "2.6.38"); | ||
1234 | clear_opt(sbi->s_mount_opt, MINIX_DF); | 1348 | clear_opt(sbi->s_mount_opt, MINIX_DF); |
1235 | break; | 1349 | break; |
1236 | case Opt_minix_df: | 1350 | case Opt_minix_df: |
1351 | ext4_msg(sb, KERN_WARNING, deprecated_msg, p, "2.6.38"); | ||
1237 | set_opt(sbi->s_mount_opt, MINIX_DF); | 1352 | set_opt(sbi->s_mount_opt, MINIX_DF); |
1353 | |||
1238 | break; | 1354 | break; |
1239 | case Opt_grpid: | 1355 | case Opt_grpid: |
1356 | ext4_msg(sb, KERN_WARNING, deprecated_msg, p, "2.6.38"); | ||
1240 | set_opt(sbi->s_mount_opt, GRPID); | 1357 | set_opt(sbi->s_mount_opt, GRPID); |
1358 | |||
1241 | break; | 1359 | break; |
1242 | case Opt_nogrpid: | 1360 | case Opt_nogrpid: |
1361 | ext4_msg(sb, KERN_WARNING, deprecated_msg, p, "2.6.38"); | ||
1243 | clear_opt(sbi->s_mount_opt, GRPID); | 1362 | clear_opt(sbi->s_mount_opt, GRPID); |
1363 | |||
1244 | break; | 1364 | break; |
1245 | case Opt_resuid: | 1365 | case Opt_resuid: |
1246 | if (match_int(&args[0], &option)) | 1366 | if (match_int(&args[0], &option)) |
@@ -1377,14 +1497,13 @@ static int parse_options(char *options, struct super_block *sb, | |||
1377 | data_opt = EXT4_MOUNT_WRITEBACK_DATA; | 1497 | data_opt = EXT4_MOUNT_WRITEBACK_DATA; |
1378 | datacheck: | 1498 | datacheck: |
1379 | if (is_remount) { | 1499 | if (is_remount) { |
1380 | if ((sbi->s_mount_opt & EXT4_MOUNT_DATA_FLAGS) | 1500 | if (test_opt(sb, DATA_FLAGS) != data_opt) { |
1381 | != data_opt) { | ||
1382 | ext4_msg(sb, KERN_ERR, | 1501 | ext4_msg(sb, KERN_ERR, |
1383 | "Cannot change data mode on remount"); | 1502 | "Cannot change data mode on remount"); |
1384 | return 0; | 1503 | return 0; |
1385 | } | 1504 | } |
1386 | } else { | 1505 | } else { |
1387 | sbi->s_mount_opt &= ~EXT4_MOUNT_DATA_FLAGS; | 1506 | clear_opt(sbi->s_mount_opt, DATA_FLAGS); |
1388 | sbi->s_mount_opt |= data_opt; | 1507 | sbi->s_mount_opt |= data_opt; |
1389 | } | 1508 | } |
1390 | break; | 1509 | break; |
@@ -1396,63 +1515,22 @@ static int parse_options(char *options, struct super_block *sb, | |||
1396 | break; | 1515 | break; |
1397 | #ifdef CONFIG_QUOTA | 1516 | #ifdef CONFIG_QUOTA |
1398 | case Opt_usrjquota: | 1517 | case Opt_usrjquota: |
1399 | qtype = USRQUOTA; | 1518 | if (!set_qf_name(sb, USRQUOTA, &args[0])) |
1400 | goto set_qf_name; | ||
1401 | case Opt_grpjquota: | ||
1402 | qtype = GRPQUOTA; | ||
1403 | set_qf_name: | ||
1404 | if (sb_any_quota_loaded(sb) && | ||
1405 | !sbi->s_qf_names[qtype]) { | ||
1406 | ext4_msg(sb, KERN_ERR, | ||
1407 | "Cannot change journaled " | ||
1408 | "quota options when quota turned on"); | ||
1409 | return 0; | 1519 | return 0; |
1410 | } | 1520 | break; |
1411 | qname = match_strdup(&args[0]); | 1521 | case Opt_grpjquota: |
1412 | if (!qname) { | 1522 | if (!set_qf_name(sb, GRPQUOTA, &args[0])) |
1413 | ext4_msg(sb, KERN_ERR, | ||
1414 | "Not enough memory for " | ||
1415 | "storing quotafile name"); | ||
1416 | return 0; | ||
1417 | } | ||
1418 | if (sbi->s_qf_names[qtype] && | ||
1419 | strcmp(sbi->s_qf_names[qtype], qname)) { | ||
1420 | ext4_msg(sb, KERN_ERR, | ||
1421 | "%s quota file already " | ||
1422 | "specified", QTYPE2NAME(qtype)); | ||
1423 | kfree(qname); | ||
1424 | return 0; | ||
1425 | } | ||
1426 | sbi->s_qf_names[qtype] = qname; | ||
1427 | if (strchr(sbi->s_qf_names[qtype], '/')) { | ||
1428 | ext4_msg(sb, KERN_ERR, | ||
1429 | "quotafile must be on " | ||
1430 | "filesystem root"); | ||
1431 | kfree(sbi->s_qf_names[qtype]); | ||
1432 | sbi->s_qf_names[qtype] = NULL; | ||
1433 | return 0; | 1523 | return 0; |
1434 | } | ||
1435 | set_opt(sbi->s_mount_opt, QUOTA); | ||
1436 | break; | 1524 | break; |
1437 | case Opt_offusrjquota: | 1525 | case Opt_offusrjquota: |
1438 | qtype = USRQUOTA; | 1526 | if (!clear_qf_name(sb, USRQUOTA)) |
1439 | goto clear_qf_name; | 1527 | return 0; |
1528 | break; | ||
1440 | case Opt_offgrpjquota: | 1529 | case Opt_offgrpjquota: |
1441 | qtype = GRPQUOTA; | 1530 | if (!clear_qf_name(sb, GRPQUOTA)) |
1442 | clear_qf_name: | ||
1443 | if (sb_any_quota_loaded(sb) && | ||
1444 | sbi->s_qf_names[qtype]) { | ||
1445 | ext4_msg(sb, KERN_ERR, "Cannot change " | ||
1446 | "journaled quota options when " | ||
1447 | "quota turned on"); | ||
1448 | return 0; | 1531 | return 0; |
1449 | } | ||
1450 | /* | ||
1451 | * The space will be released later when all options | ||
1452 | * are confirmed to be correct | ||
1453 | */ | ||
1454 | sbi->s_qf_names[qtype] = NULL; | ||
1455 | break; | 1532 | break; |
1533 | |||
1456 | case Opt_jqfmt_vfsold: | 1534 | case Opt_jqfmt_vfsold: |
1457 | qfmt = QFMT_VFS_OLD; | 1535 | qfmt = QFMT_VFS_OLD; |
1458 | goto set_qf_format; | 1536 | goto set_qf_format; |
@@ -1517,10 +1595,11 @@ set_qf_format: | |||
1517 | clear_opt(sbi->s_mount_opt, BARRIER); | 1595 | clear_opt(sbi->s_mount_opt, BARRIER); |
1518 | break; | 1596 | break; |
1519 | case Opt_barrier: | 1597 | case Opt_barrier: |
1520 | if (match_int(&args[0], &option)) { | 1598 | if (args[0].from) { |
1521 | set_opt(sbi->s_mount_opt, BARRIER); | 1599 | if (match_int(&args[0], &option)) |
1522 | break; | 1600 | return 0; |
1523 | } | 1601 | } else |
1602 | option = 1; /* No argument, default to 1 */ | ||
1524 | if (option) | 1603 | if (option) |
1525 | set_opt(sbi->s_mount_opt, BARRIER); | 1604 | set_opt(sbi->s_mount_opt, BARRIER); |
1526 | else | 1605 | else |
@@ -1593,10 +1672,11 @@ set_qf_format: | |||
1593 | set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC); | 1672 | set_opt(sbi->s_mount_opt,NO_AUTO_DA_ALLOC); |
1594 | break; | 1673 | break; |
1595 | case Opt_auto_da_alloc: | 1674 | case Opt_auto_da_alloc: |
1596 | if (match_int(&args[0], &option)) { | 1675 | if (args[0].from) { |
1597 | clear_opt(sbi->s_mount_opt, NO_AUTO_DA_ALLOC); | 1676 | if (match_int(&args[0], &option)) |
1598 | break; | 1677 | return 0; |
1599 | } | 1678 | } else |
1679 | option = 1; /* No argument, default to 1 */ | ||
1600 | if (option) | 1680 | if (option) |
1601 | clear_opt(sbi->s_mount_opt, NO_AUTO_DA_ALLOC); | 1681 | clear_opt(sbi->s_mount_opt, NO_AUTO_DA_ALLOC); |
1602 | else | 1682 | else |
@@ -1608,6 +1688,12 @@ set_qf_format: | |||
1608 | case Opt_nodiscard: | 1688 | case Opt_nodiscard: |
1609 | clear_opt(sbi->s_mount_opt, DISCARD); | 1689 | clear_opt(sbi->s_mount_opt, DISCARD); |
1610 | break; | 1690 | break; |
1691 | case Opt_dioread_nolock: | ||
1692 | set_opt(sbi->s_mount_opt, DIOREAD_NOLOCK); | ||
1693 | break; | ||
1694 | case Opt_dioread_lock: | ||
1695 | clear_opt(sbi->s_mount_opt, DIOREAD_NOLOCK); | ||
1696 | break; | ||
1611 | default: | 1697 | default: |
1612 | ext4_msg(sb, KERN_ERR, | 1698 | ext4_msg(sb, KERN_ERR, |
1613 | "Unrecognized mount option \"%s\" " | 1699 | "Unrecognized mount option \"%s\" " |
@@ -1617,18 +1703,13 @@ set_qf_format: | |||
1617 | } | 1703 | } |
1618 | #ifdef CONFIG_QUOTA | 1704 | #ifdef CONFIG_QUOTA |
1619 | if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { | 1705 | if (sbi->s_qf_names[USRQUOTA] || sbi->s_qf_names[GRPQUOTA]) { |
1620 | if ((sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA) && | 1706 | if (test_opt(sb, USRQUOTA) && sbi->s_qf_names[USRQUOTA]) |
1621 | sbi->s_qf_names[USRQUOTA]) | ||
1622 | clear_opt(sbi->s_mount_opt, USRQUOTA); | 1707 | clear_opt(sbi->s_mount_opt, USRQUOTA); |
1623 | 1708 | ||
1624 | if ((sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA) && | 1709 | if (test_opt(sb, GRPQUOTA) && sbi->s_qf_names[GRPQUOTA]) |
1625 | sbi->s_qf_names[GRPQUOTA]) | ||
1626 | clear_opt(sbi->s_mount_opt, GRPQUOTA); | 1710 | clear_opt(sbi->s_mount_opt, GRPQUOTA); |
1627 | 1711 | ||
1628 | if ((sbi->s_qf_names[USRQUOTA] && | 1712 | if (test_opt(sb, GRPQUOTA) || test_opt(sb, USRQUOTA)) { |
1629 | (sbi->s_mount_opt & EXT4_MOUNT_GRPQUOTA)) || | ||
1630 | (sbi->s_qf_names[GRPQUOTA] && | ||
1631 | (sbi->s_mount_opt & EXT4_MOUNT_USRQUOTA))) { | ||
1632 | ext4_msg(sb, KERN_ERR, "old and new quota " | 1713 | ext4_msg(sb, KERN_ERR, "old and new quota " |
1633 | "format mixing"); | 1714 | "format mixing"); |
1634 | return 0; | 1715 | return 0; |
@@ -1938,7 +2019,7 @@ static void ext4_orphan_cleanup(struct super_block *sb, | |||
1938 | } | 2019 | } |
1939 | 2020 | ||
1940 | list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); | 2021 | list_add(&EXT4_I(inode)->i_orphan, &EXT4_SB(sb)->s_orphan); |
1941 | vfs_dq_init(inode); | 2022 | dquot_initialize(inode); |
1942 | if (inode->i_nlink) { | 2023 | if (inode->i_nlink) { |
1943 | ext4_msg(sb, KERN_DEBUG, | 2024 | ext4_msg(sb, KERN_DEBUG, |
1944 | "%s: truncating inode %lu to %lld bytes", | 2025 | "%s: truncating inode %lu to %lld bytes", |
@@ -2174,9 +2255,9 @@ static ssize_t lifetime_write_kbytes_show(struct ext4_attr *a, | |||
2174 | struct super_block *sb = sbi->s_buddy_cache->i_sb; | 2255 | struct super_block *sb = sbi->s_buddy_cache->i_sb; |
2175 | 2256 | ||
2176 | return snprintf(buf, PAGE_SIZE, "%llu\n", | 2257 | return snprintf(buf, PAGE_SIZE, "%llu\n", |
2177 | sbi->s_kbytes_written + | 2258 | (unsigned long long)(sbi->s_kbytes_written + |
2178 | ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) - | 2259 | ((part_stat_read(sb->s_bdev->bd_part, sectors[1]) - |
2179 | EXT4_SB(sb)->s_sectors_written_start) >> 1)); | 2260 | EXT4_SB(sb)->s_sectors_written_start) >> 1))); |
2180 | } | 2261 | } |
2181 | 2262 | ||
2182 | static ssize_t inode_readahead_blks_store(struct ext4_attr *a, | 2263 | static ssize_t inode_readahead_blks_store(struct ext4_attr *a, |
@@ -2291,7 +2372,7 @@ static void ext4_sb_release(struct kobject *kobj) | |||
2291 | } | 2372 | } |
2292 | 2373 | ||
2293 | 2374 | ||
2294 | static struct sysfs_ops ext4_attr_ops = { | 2375 | static const struct sysfs_ops ext4_attr_ops = { |
2295 | .show = ext4_attr_show, | 2376 | .show = ext4_attr_show, |
2296 | .store = ext4_attr_store, | 2377 | .store = ext4_attr_store, |
2297 | }; | 2378 | }; |
@@ -2431,8 +2512,11 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2431 | def_mount_opts = le32_to_cpu(es->s_default_mount_opts); | 2512 | def_mount_opts = le32_to_cpu(es->s_default_mount_opts); |
2432 | if (def_mount_opts & EXT4_DEFM_DEBUG) | 2513 | if (def_mount_opts & EXT4_DEFM_DEBUG) |
2433 | set_opt(sbi->s_mount_opt, DEBUG); | 2514 | set_opt(sbi->s_mount_opt, DEBUG); |
2434 | if (def_mount_opts & EXT4_DEFM_BSDGROUPS) | 2515 | if (def_mount_opts & EXT4_DEFM_BSDGROUPS) { |
2516 | ext4_msg(sb, KERN_WARNING, deprecated_msg, "bsdgroups", | ||
2517 | "2.6.38"); | ||
2435 | set_opt(sbi->s_mount_opt, GRPID); | 2518 | set_opt(sbi->s_mount_opt, GRPID); |
2519 | } | ||
2436 | if (def_mount_opts & EXT4_DEFM_UID16) | 2520 | if (def_mount_opts & EXT4_DEFM_UID16) |
2437 | set_opt(sbi->s_mount_opt, NO_UID32); | 2521 | set_opt(sbi->s_mount_opt, NO_UID32); |
2438 | #ifdef CONFIG_EXT4_FS_XATTR | 2522 | #ifdef CONFIG_EXT4_FS_XATTR |
@@ -2444,11 +2528,11 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2444 | set_opt(sbi->s_mount_opt, POSIX_ACL); | 2528 | set_opt(sbi->s_mount_opt, POSIX_ACL); |
2445 | #endif | 2529 | #endif |
2446 | if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA) | 2530 | if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_DATA) |
2447 | sbi->s_mount_opt |= EXT4_MOUNT_JOURNAL_DATA; | 2531 | set_opt(sbi->s_mount_opt, JOURNAL_DATA); |
2448 | else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED) | 2532 | else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_ORDERED) |
2449 | sbi->s_mount_opt |= EXT4_MOUNT_ORDERED_DATA; | 2533 | set_opt(sbi->s_mount_opt, ORDERED_DATA); |
2450 | else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_WBACK) | 2534 | else if ((def_mount_opts & EXT4_DEFM_JMODE) == EXT4_DEFM_JMODE_WBACK) |
2451 | sbi->s_mount_opt |= EXT4_MOUNT_WRITEBACK_DATA; | 2535 | set_opt(sbi->s_mount_opt, WRITEBACK_DATA); |
2452 | 2536 | ||
2453 | if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_PANIC) | 2537 | if (le16_to_cpu(sbi->s_es->s_errors) == EXT4_ERRORS_PANIC) |
2454 | set_opt(sbi->s_mount_opt, ERRORS_PANIC); | 2538 | set_opt(sbi->s_mount_opt, ERRORS_PANIC); |
@@ -2469,14 +2553,15 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2469 | * enable delayed allocation by default | 2553 | * enable delayed allocation by default |
2470 | * Use -o nodelalloc to turn it off | 2554 | * Use -o nodelalloc to turn it off |
2471 | */ | 2555 | */ |
2472 | set_opt(sbi->s_mount_opt, DELALLOC); | 2556 | if (!IS_EXT3_SB(sb)) |
2557 | set_opt(sbi->s_mount_opt, DELALLOC); | ||
2473 | 2558 | ||
2474 | if (!parse_options((char *) data, sb, &journal_devnum, | 2559 | if (!parse_options((char *) data, sb, &journal_devnum, |
2475 | &journal_ioprio, NULL, 0)) | 2560 | &journal_ioprio, NULL, 0)) |
2476 | goto failed_mount; | 2561 | goto failed_mount; |
2477 | 2562 | ||
2478 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | | 2563 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | |
2479 | ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); | 2564 | (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0); |
2480 | 2565 | ||
2481 | if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV && | 2566 | if (le32_to_cpu(es->s_rev_level) == EXT4_GOOD_OLD_REV && |
2482 | (EXT4_HAS_COMPAT_FEATURE(sb, ~0U) || | 2567 | (EXT4_HAS_COMPAT_FEATURE(sb, ~0U) || |
@@ -2765,7 +2850,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2765 | EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { | 2850 | EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) { |
2766 | ext4_msg(sb, KERN_ERR, "required journal recovery " | 2851 | ext4_msg(sb, KERN_ERR, "required journal recovery " |
2767 | "suppressed and not mounted read-only"); | 2852 | "suppressed and not mounted read-only"); |
2768 | goto failed_mount4; | 2853 | goto failed_mount_wq; |
2769 | } else { | 2854 | } else { |
2770 | clear_opt(sbi->s_mount_opt, DATA_FLAGS); | 2855 | clear_opt(sbi->s_mount_opt, DATA_FLAGS); |
2771 | set_opt(sbi->s_mount_opt, WRITEBACK_DATA); | 2856 | set_opt(sbi->s_mount_opt, WRITEBACK_DATA); |
@@ -2778,7 +2863,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2778 | !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, | 2863 | !jbd2_journal_set_features(EXT4_SB(sb)->s_journal, 0, 0, |
2779 | JBD2_FEATURE_INCOMPAT_64BIT)) { | 2864 | JBD2_FEATURE_INCOMPAT_64BIT)) { |
2780 | ext4_msg(sb, KERN_ERR, "Failed to set 64-bit journal feature"); | 2865 | ext4_msg(sb, KERN_ERR, "Failed to set 64-bit journal feature"); |
2781 | goto failed_mount4; | 2866 | goto failed_mount_wq; |
2782 | } | 2867 | } |
2783 | 2868 | ||
2784 | if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { | 2869 | if (test_opt(sb, JOURNAL_ASYNC_COMMIT)) { |
@@ -2817,7 +2902,7 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2817 | (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) { | 2902 | (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) { |
2818 | ext4_msg(sb, KERN_ERR, "Journal does not support " | 2903 | ext4_msg(sb, KERN_ERR, "Journal does not support " |
2819 | "requested data journaling mode"); | 2904 | "requested data journaling mode"); |
2820 | goto failed_mount4; | 2905 | goto failed_mount_wq; |
2821 | } | 2906 | } |
2822 | default: | 2907 | default: |
2823 | break; | 2908 | break; |
@@ -2825,13 +2910,17 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
2825 | set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); | 2910 | set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); |
2826 | 2911 | ||
2827 | no_journal: | 2912 | no_journal: |
2828 | |||
2829 | if (test_opt(sb, NOBH)) { | 2913 | if (test_opt(sb, NOBH)) { |
2830 | if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { | 2914 | if (!(test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_WRITEBACK_DATA)) { |
2831 | ext4_msg(sb, KERN_WARNING, "Ignoring nobh option - " | 2915 | ext4_msg(sb, KERN_WARNING, "Ignoring nobh option - " |
2832 | "its supported only with writeback mode"); | 2916 | "its supported only with writeback mode"); |
2833 | clear_opt(sbi->s_mount_opt, NOBH); | 2917 | clear_opt(sbi->s_mount_opt, NOBH); |
2834 | } | 2918 | } |
2919 | if (test_opt(sb, DIOREAD_NOLOCK)) { | ||
2920 | ext4_msg(sb, KERN_WARNING, "dioread_nolock option is " | ||
2921 | "not supported with nobh mode"); | ||
2922 | goto failed_mount_wq; | ||
2923 | } | ||
2835 | } | 2924 | } |
2836 | EXT4_SB(sb)->dio_unwritten_wq = create_workqueue("ext4-dio-unwritten"); | 2925 | EXT4_SB(sb)->dio_unwritten_wq = create_workqueue("ext4-dio-unwritten"); |
2837 | if (!EXT4_SB(sb)->dio_unwritten_wq) { | 2926 | if (!EXT4_SB(sb)->dio_unwritten_wq) { |
@@ -2896,6 +2985,18 @@ no_journal: | |||
2896 | "requested data journaling mode"); | 2985 | "requested data journaling mode"); |
2897 | clear_opt(sbi->s_mount_opt, DELALLOC); | 2986 | clear_opt(sbi->s_mount_opt, DELALLOC); |
2898 | } | 2987 | } |
2988 | if (test_opt(sb, DIOREAD_NOLOCK)) { | ||
2989 | if (test_opt(sb, DATA_FLAGS) == EXT4_MOUNT_JOURNAL_DATA) { | ||
2990 | ext4_msg(sb, KERN_WARNING, "Ignoring dioread_nolock " | ||
2991 | "option - requested data journaling mode"); | ||
2992 | clear_opt(sbi->s_mount_opt, DIOREAD_NOLOCK); | ||
2993 | } | ||
2994 | if (sb->s_blocksize < PAGE_SIZE) { | ||
2995 | ext4_msg(sb, KERN_WARNING, "Ignoring dioread_nolock " | ||
2996 | "option - block size is too small"); | ||
2997 | clear_opt(sbi->s_mount_opt, DIOREAD_NOLOCK); | ||
2998 | } | ||
2999 | } | ||
2899 | 3000 | ||
2900 | err = ext4_setup_system_zone(sb); | 3001 | err = ext4_setup_system_zone(sb); |
2901 | if (err) { | 3002 | if (err) { |
@@ -3359,10 +3460,9 @@ static void ext4_clear_journal_err(struct super_block *sb, | |||
3359 | char nbuf[16]; | 3460 | char nbuf[16]; |
3360 | 3461 | ||
3361 | errstr = ext4_decode_error(sb, j_errno, nbuf); | 3462 | errstr = ext4_decode_error(sb, j_errno, nbuf); |
3362 | ext4_warning(sb, __func__, "Filesystem error recorded " | 3463 | ext4_warning(sb, "Filesystem error recorded " |
3363 | "from previous mount: %s", errstr); | 3464 | "from previous mount: %s", errstr); |
3364 | ext4_warning(sb, __func__, "Marking fs in need of " | 3465 | ext4_warning(sb, "Marking fs in need of filesystem check."); |
3365 | "filesystem check."); | ||
3366 | 3466 | ||
3367 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; | 3467 | EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; |
3368 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); | 3468 | es->s_state |= cpu_to_le16(EXT4_ERROR_FS); |
@@ -3513,7 +3613,7 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) | |||
3513 | ext4_abort(sb, __func__, "Abort forced by user"); | 3613 | ext4_abort(sb, __func__, "Abort forced by user"); |
3514 | 3614 | ||
3515 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | | 3615 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | |
3516 | ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); | 3616 | (test_opt(sb, POSIX_ACL) ? MS_POSIXACL : 0); |
3517 | 3617 | ||
3518 | es = sbi->s_es; | 3618 | es = sbi->s_es; |
3519 | 3619 | ||
@@ -3707,7 +3807,7 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf) | |||
3707 | * Process 1 Process 2 | 3807 | * Process 1 Process 2 |
3708 | * ext4_create() quota_sync() | 3808 | * ext4_create() quota_sync() |
3709 | * jbd2_journal_start() write_dquot() | 3809 | * jbd2_journal_start() write_dquot() |
3710 | * vfs_dq_init() down(dqio_mutex) | 3810 | * dquot_initialize() down(dqio_mutex) |
3711 | * down(dqio_mutex) jbd2_journal_start() | 3811 | * down(dqio_mutex) jbd2_journal_start() |
3712 | * | 3812 | * |
3713 | */ | 3813 | */ |
@@ -3916,9 +4016,7 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type, | |||
3916 | ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb); | 4016 | ext4_lblk_t blk = off >> EXT4_BLOCK_SIZE_BITS(sb); |
3917 | int err = 0; | 4017 | int err = 0; |
3918 | int offset = off & (sb->s_blocksize - 1); | 4018 | int offset = off & (sb->s_blocksize - 1); |
3919 | int tocopy; | ||
3920 | int journal_quota = EXT4_SB(sb)->s_qf_names[type] != NULL; | 4019 | int journal_quota = EXT4_SB(sb)->s_qf_names[type] != NULL; |
3921 | size_t towrite = len; | ||
3922 | struct buffer_head *bh; | 4020 | struct buffer_head *bh; |
3923 | handle_t *handle = journal_current_handle(); | 4021 | handle_t *handle = journal_current_handle(); |
3924 | 4022 | ||
@@ -3928,52 +4026,53 @@ static ssize_t ext4_quota_write(struct super_block *sb, int type, | |||
3928 | (unsigned long long)off, (unsigned long long)len); | 4026 | (unsigned long long)off, (unsigned long long)len); |
3929 | return -EIO; | 4027 | return -EIO; |
3930 | } | 4028 | } |
4029 | /* | ||
4030 | * Since we account only one data block in transaction credits, | ||
4031 | * then it is impossible to cross a block boundary. | ||
4032 | */ | ||
4033 | if (sb->s_blocksize - offset < len) { | ||
4034 | ext4_msg(sb, KERN_WARNING, "Quota write (off=%llu, len=%llu)" | ||
4035 | " cancelled because not block aligned", | ||
4036 | (unsigned long long)off, (unsigned long long)len); | ||
4037 | return -EIO; | ||
4038 | } | ||
4039 | |||
3931 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); | 4040 | mutex_lock_nested(&inode->i_mutex, I_MUTEX_QUOTA); |
3932 | while (towrite > 0) { | 4041 | bh = ext4_bread(handle, inode, blk, 1, &err); |
3933 | tocopy = sb->s_blocksize - offset < towrite ? | 4042 | if (!bh) |
3934 | sb->s_blocksize - offset : towrite; | 4043 | goto out; |
3935 | bh = ext4_bread(handle, inode, blk, 1, &err); | 4044 | if (journal_quota) { |
3936 | if (!bh) | 4045 | err = ext4_journal_get_write_access(handle, bh); |
4046 | if (err) { | ||
4047 | brelse(bh); | ||
3937 | goto out; | 4048 | goto out; |
3938 | if (journal_quota) { | ||
3939 | err = ext4_journal_get_write_access(handle, bh); | ||
3940 | if (err) { | ||
3941 | brelse(bh); | ||
3942 | goto out; | ||
3943 | } | ||
3944 | } | ||
3945 | lock_buffer(bh); | ||
3946 | memcpy(bh->b_data+offset, data, tocopy); | ||
3947 | flush_dcache_page(bh->b_page); | ||
3948 | unlock_buffer(bh); | ||
3949 | if (journal_quota) | ||
3950 | err = ext4_handle_dirty_metadata(handle, NULL, bh); | ||
3951 | else { | ||
3952 | /* Always do at least ordered writes for quotas */ | ||
3953 | err = ext4_jbd2_file_inode(handle, inode); | ||
3954 | mark_buffer_dirty(bh); | ||
3955 | } | 4049 | } |
3956 | brelse(bh); | ||
3957 | if (err) | ||
3958 | goto out; | ||
3959 | offset = 0; | ||
3960 | towrite -= tocopy; | ||
3961 | data += tocopy; | ||
3962 | blk++; | ||
3963 | } | 4050 | } |
4051 | lock_buffer(bh); | ||
4052 | memcpy(bh->b_data+offset, data, len); | ||
4053 | flush_dcache_page(bh->b_page); | ||
4054 | unlock_buffer(bh); | ||
4055 | if (journal_quota) | ||
4056 | err = ext4_handle_dirty_metadata(handle, NULL, bh); | ||
4057 | else { | ||
4058 | /* Always do at least ordered writes for quotas */ | ||
4059 | err = ext4_jbd2_file_inode(handle, inode); | ||
4060 | mark_buffer_dirty(bh); | ||
4061 | } | ||
4062 | brelse(bh); | ||
3964 | out: | 4063 | out: |
3965 | if (len == towrite) { | 4064 | if (err) { |
3966 | mutex_unlock(&inode->i_mutex); | 4065 | mutex_unlock(&inode->i_mutex); |
3967 | return err; | 4066 | return err; |
3968 | } | 4067 | } |
3969 | if (inode->i_size < off+len-towrite) { | 4068 | if (inode->i_size < off + len) { |
3970 | i_size_write(inode, off+len-towrite); | 4069 | i_size_write(inode, off + len); |
3971 | EXT4_I(inode)->i_disksize = inode->i_size; | 4070 | EXT4_I(inode)->i_disksize = inode->i_size; |
3972 | } | 4071 | } |
3973 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; | 4072 | inode->i_mtime = inode->i_ctime = CURRENT_TIME; |
3974 | ext4_mark_inode_dirty(handle, inode); | 4073 | ext4_mark_inode_dirty(handle, inode); |
3975 | mutex_unlock(&inode->i_mutex); | 4074 | mutex_unlock(&inode->i_mutex); |
3976 | return len - towrite; | 4075 | return len; |
3977 | } | 4076 | } |
3978 | 4077 | ||
3979 | #endif | 4078 | #endif |
@@ -3984,7 +4083,7 @@ static int ext4_get_sb(struct file_system_type *fs_type, int flags, | |||
3984 | return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt); | 4083 | return get_sb_bdev(fs_type, flags, dev_name, data, ext4_fill_super,mnt); |
3985 | } | 4084 | } |
3986 | 4085 | ||
3987 | #if !defined(CONTIG_EXT2_FS) && !defined(CONFIG_EXT2_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT23) | 4086 | #if !defined(CONFIG_EXT2_FS) && !defined(CONFIG_EXT2_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT23) |
3988 | static struct file_system_type ext2_fs_type = { | 4087 | static struct file_system_type ext2_fs_type = { |
3989 | .owner = THIS_MODULE, | 4088 | .owner = THIS_MODULE, |
3990 | .name = "ext2", | 4089 | .name = "ext2", |
@@ -4005,20 +4104,13 @@ static inline void unregister_as_ext2(void) | |||
4005 | { | 4104 | { |
4006 | unregister_filesystem(&ext2_fs_type); | 4105 | unregister_filesystem(&ext2_fs_type); |
4007 | } | 4106 | } |
4107 | MODULE_ALIAS("ext2"); | ||
4008 | #else | 4108 | #else |
4009 | static inline void register_as_ext2(void) { } | 4109 | static inline void register_as_ext2(void) { } |
4010 | static inline void unregister_as_ext2(void) { } | 4110 | static inline void unregister_as_ext2(void) { } |
4011 | #endif | 4111 | #endif |
4012 | 4112 | ||
4013 | #if !defined(CONTIG_EXT3_FS) && !defined(CONFIG_EXT3_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT23) | 4113 | #if !defined(CONFIG_EXT3_FS) && !defined(CONFIG_EXT3_FS_MODULE) && defined(CONFIG_EXT4_USE_FOR_EXT23) |
4014 | static struct file_system_type ext3_fs_type = { | ||
4015 | .owner = THIS_MODULE, | ||
4016 | .name = "ext3", | ||
4017 | .get_sb = ext4_get_sb, | ||
4018 | .kill_sb = kill_block_super, | ||
4019 | .fs_flags = FS_REQUIRES_DEV, | ||
4020 | }; | ||
4021 | |||
4022 | static inline void register_as_ext3(void) | 4114 | static inline void register_as_ext3(void) |
4023 | { | 4115 | { |
4024 | int err = register_filesystem(&ext3_fs_type); | 4116 | int err = register_filesystem(&ext3_fs_type); |
@@ -4031,6 +4123,7 @@ static inline void unregister_as_ext3(void) | |||
4031 | { | 4123 | { |
4032 | unregister_filesystem(&ext3_fs_type); | 4124 | unregister_filesystem(&ext3_fs_type); |
4033 | } | 4125 | } |
4126 | MODULE_ALIAS("ext3"); | ||
4034 | #else | 4127 | #else |
4035 | static inline void register_as_ext3(void) { } | 4128 | static inline void register_as_ext3(void) { } |
4036 | static inline void unregister_as_ext3(void) { } | 4129 | static inline void unregister_as_ext3(void) { } |