super.c (d905163c5b23f6d8511971e06081a1b525e8a0bd) | super.c (90c699a9ee4be165966d40f1837909ccb8890a68) |
---|---|
1/* 2 * linux/fs/ext4/super.c 3 * 4 * Copyright (C) 1992, 1993, 1994, 1995 5 * Remy Card (card@masi.ibp.fr) 6 * Laboratoire MASI - Institut Blaise Pascal 7 * Universite Pierre et Marie Curie (Paris VI) 8 * --- 23 unchanged lines hidden (view full) --- 32#include <linux/vfs.h> 33#include <linux/random.h> 34#include <linux/mount.h> 35#include <linux/namei.h> 36#include <linux/quotaops.h> 37#include <linux/seq_file.h> 38#include <linux/proc_fs.h> 39#include <linux/ctype.h> | 1/* 2 * linux/fs/ext4/super.c 3 * 4 * Copyright (C) 1992, 1993, 1994, 1995 5 * Remy Card (card@masi.ibp.fr) 6 * Laboratoire MASI - Institut Blaise Pascal 7 * Universite Pierre et Marie Curie (Paris VI) 8 * --- 23 unchanged lines hidden (view full) --- 32#include <linux/vfs.h> 33#include <linux/random.h> 34#include <linux/mount.h> 35#include <linux/namei.h> 36#include <linux/quotaops.h> 37#include <linux/seq_file.h> 38#include <linux/proc_fs.h> 39#include <linux/ctype.h> |
40#include <linux/marker.h> |
|
40#include <linux/log2.h> 41#include <linux/crc16.h> 42#include <asm/uaccess.h> 43 44#include "ext4.h" 45#include "ext4_jbd2.h" 46#include "xattr.h" 47#include "acl.h" 48 | 41#include <linux/log2.h> 42#include <linux/crc16.h> 43#include <asm/uaccess.h> 44 45#include "ext4.h" 46#include "ext4_jbd2.h" 47#include "xattr.h" 48#include "acl.h" 49 |
49#define CREATE_TRACE_POINTS 50#include <trace/events/ext4.h> 51 | |
52static int default_mb_history_length = 1000; 53 54module_param_named(default_mb_history_length, default_mb_history_length, 55 int, 0644); 56MODULE_PARM_DESC(default_mb_history_length, 57 "Default number of entries saved for mb_history"); 58 59struct proc_dir_entry *ext4_proc_root; --- 238 unchanged lines hidden (view full) --- 298 es->s_state |= cpu_to_le16(EXT4_ERROR_FS); 299 300 if (sb->s_flags & MS_RDONLY) 301 return; 302 303 if (!test_opt(sb, ERRORS_CONT)) { 304 journal_t *journal = EXT4_SB(sb)->s_journal; 305 | 50static int default_mb_history_length = 1000; 51 52module_param_named(default_mb_history_length, default_mb_history_length, 53 int, 0644); 54MODULE_PARM_DESC(default_mb_history_length, 55 "Default number of entries saved for mb_history"); 56 57struct proc_dir_entry *ext4_proc_root; --- 238 unchanged lines hidden (view full) --- 296 es->s_state |= cpu_to_le16(EXT4_ERROR_FS); 297 298 if (sb->s_flags & MS_RDONLY) 299 return; 300 301 if (!test_opt(sb, ERRORS_CONT)) { 302 journal_t *journal = EXT4_SB(sb)->s_journal; 303 |
306 EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED; | 304 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; |
307 if (journal) 308 jbd2_journal_abort(journal, -EIO); 309 } 310 if (test_opt(sb, ERRORS_RO)) { 311 ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); 312 sb->s_flags |= MS_RDONLY; 313 } 314 ext4_commit_super(sb, 1); --- 96 unchanged lines hidden (view full) --- 411 panic("EXT4-fs panic from previous error\n"); 412 413 if (sb->s_flags & MS_RDONLY) 414 return; 415 416 ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); 417 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; 418 sb->s_flags |= MS_RDONLY; | 305 if (journal) 306 jbd2_journal_abort(journal, -EIO); 307 } 308 if (test_opt(sb, ERRORS_RO)) { 309 ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); 310 sb->s_flags |= MS_RDONLY; 311 } 312 ext4_commit_super(sb, 1); --- 96 unchanged lines hidden (view full) --- 409 panic("EXT4-fs panic from previous error\n"); 410 411 if (sb->s_flags & MS_RDONLY) 412 return; 413 414 ext4_msg(sb, KERN_CRIT, "Remounting filesystem read-only"); 415 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; 416 sb->s_flags |= MS_RDONLY; |
419 EXT4_SB(sb)->s_mount_flags |= EXT4_MF_FS_ABORTED; | 417 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; |
420 if (EXT4_SB(sb)->s_journal) 421 jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); 422} 423 424void ext4_msg (struct super_block * sb, const char *prefix, 425 const char *fmt, ...) 426{ 427 va_list args; --- 1043 unchanged lines hidden (view full) --- 1471 case Opt_jqfmt_vfsv0: 1472 ext4_msg(sb, KERN_ERR, 1473 "journaled quota options not supported"); 1474 break; 1475 case Opt_noquota: 1476 break; 1477#endif 1478 case Opt_abort: | 418 if (EXT4_SB(sb)->s_journal) 419 jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO); 420} 421 422void ext4_msg (struct super_block * sb, const char *prefix, 423 const char *fmt, ...) 424{ 425 va_list args; --- 1043 unchanged lines hidden (view full) --- 1469 case Opt_jqfmt_vfsv0: 1470 ext4_msg(sb, KERN_ERR, 1471 "journaled quota options not supported"); 1472 break; 1473 case Opt_noquota: 1474 break; 1475#endif 1476 case Opt_abort: |
1479 sbi->s_mount_flags |= EXT4_MF_FS_ABORTED; | 1477 set_opt(sbi->s_mount_opt, ABORT); |
1480 break; 1481 case Opt_nobarrier: 1482 clear_opt(sbi->s_mount_opt, BARRIER); 1483 break; 1484 case Opt_barrier: 1485 if (match_int(&args[0], &option)) { 1486 set_opt(sbi->s_mount_opt, BARRIER); 1487 break; --- 162 unchanged lines hidden (view full) --- 1650 es->s_mtime = cpu_to_le32(get_seconds()); 1651 ext4_update_dynamic_rev(sb); 1652 if (sbi->s_journal) 1653 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 1654 1655 ext4_commit_super(sb, 1); 1656 if (test_opt(sb, DEBUG)) 1657 printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, " | 1478 break; 1479 case Opt_nobarrier: 1480 clear_opt(sbi->s_mount_opt, BARRIER); 1481 break; 1482 case Opt_barrier: 1483 if (match_int(&args[0], &option)) { 1484 set_opt(sbi->s_mount_opt, BARRIER); 1485 break; --- 162 unchanged lines hidden (view full) --- 1648 es->s_mtime = cpu_to_le32(get_seconds()); 1649 ext4_update_dynamic_rev(sb); 1650 if (sbi->s_journal) 1651 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 1652 1653 ext4_commit_super(sb, 1); 1654 if (test_opt(sb, DEBUG)) 1655 printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, " |
1658 "bpg=%lu, ipg=%lu, mo=%04x]\n", | 1656 "bpg=%lu, ipg=%lu, mo=%04lx]\n", |
1659 sb->s_blocksize, 1660 sbi->s_groups_count, 1661 EXT4_BLOCKS_PER_GROUP(sb), 1662 EXT4_INODES_PER_GROUP(sb), 1663 sbi->s_mount_opt); 1664 1665 if (EXT4_SB(sb)->s_journal) { 1666 ext4_msg(sb, KERN_INFO, "%s journal on %s", --- 287 unchanged lines hidden (view full) --- 1954static loff_t ext4_max_size(int blkbits, int has_huge_files) 1955{ 1956 loff_t res; 1957 loff_t upper_limit = MAX_LFS_FILESIZE; 1958 1959 /* small i_blocks in vfs inode? */ 1960 if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { 1961 /* | 1657 sb->s_blocksize, 1658 sbi->s_groups_count, 1659 EXT4_BLOCKS_PER_GROUP(sb), 1660 EXT4_INODES_PER_GROUP(sb), 1661 sbi->s_mount_opt); 1662 1663 if (EXT4_SB(sb)->s_journal) { 1664 ext4_msg(sb, KERN_INFO, "%s journal on %s", --- 287 unchanged lines hidden (view full) --- 1952static loff_t ext4_max_size(int blkbits, int has_huge_files) 1953{ 1954 loff_t res; 1955 loff_t upper_limit = MAX_LFS_FILESIZE; 1956 1957 /* small i_blocks in vfs inode? */ 1958 if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { 1959 /* |
1962 * CONFIG_LBD is not enabled implies the inode | 1960 * CONFIG_LBDAF is not enabled implies the inode |
1963 * i_block represent total blocks in 512 bytes 1964 * 32 == size of vfs inode i_blocks * 8 1965 */ 1966 upper_limit = (1LL << 32) - 1; 1967 1968 /* total blocks in file system block size */ 1969 upper_limit >>= (blkbits - 9); 1970 upper_limit <<= blkbits; --- 26 unchanged lines hidden (view full) --- 1997 * including data and all indirect blocks, does not exceed (2^48 - 1). 1998 * 1999 * __u32 i_blocks_lo and _u16 i_blocks_high represent the total 2000 * number of 512-byte sectors of the file. 2001 */ 2002 2003 if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { 2004 /* | 1961 * i_block represent total blocks in 512 bytes 1962 * 32 == size of vfs inode i_blocks * 8 1963 */ 1964 upper_limit = (1LL << 32) - 1; 1965 1966 /* total blocks in file system block size */ 1967 upper_limit >>= (blkbits - 9); 1968 upper_limit <<= blkbits; --- 26 unchanged lines hidden (view full) --- 1995 * including data and all indirect blocks, does not exceed (2^48 - 1). 1996 * 1997 * __u32 i_blocks_lo and _u16 i_blocks_high represent the total 1998 * number of 512-byte sectors of the file. 1999 */ 2000 2001 if (!has_huge_files || sizeof(blkcnt_t) < sizeof(u64)) { 2002 /* |
2005 * !has_huge_files or CONFIG_LBD not enabled implies that | 2003 * !has_huge_files or CONFIG_LBDAF not enabled implies that |
2006 * the inode i_block field represents total file blocks in 2007 * 2^32 512-byte sectors == size of vfs inode i_blocks * 8 2008 */ 2009 upper_limit = (1LL << 32) - 1; 2010 2011 /* total blocks in file system block size */ 2012 upper_limit >>= (bits - 9); 2013 --- 187 unchanged lines hidden (view full) --- 2201 EXT4_ATTR_OFFSET(name, 0644, sbi_ui_show, sbi_ui_store, elname) 2202#define ATTR_LIST(name) &ext4_attr_##name.attr 2203 2204EXT4_RO_ATTR(delayed_allocation_blocks); 2205EXT4_RO_ATTR(session_write_kbytes); 2206EXT4_RO_ATTR(lifetime_write_kbytes); 2207EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, sbi_ui_show, 2208 inode_readahead_blks_store, s_inode_readahead_blks); | 2004 * the inode i_block field represents total file blocks in 2005 * 2^32 512-byte sectors == size of vfs inode i_blocks * 8 2006 */ 2007 upper_limit = (1LL << 32) - 1; 2008 2009 /* total blocks in file system block size */ 2010 upper_limit >>= (bits - 9); 2011 --- 187 unchanged lines hidden (view full) --- 2199 EXT4_ATTR_OFFSET(name, 0644, sbi_ui_show, sbi_ui_store, elname) 2200#define ATTR_LIST(name) &ext4_attr_##name.attr 2201 2202EXT4_RO_ATTR(delayed_allocation_blocks); 2203EXT4_RO_ATTR(session_write_kbytes); 2204EXT4_RO_ATTR(lifetime_write_kbytes); 2205EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, sbi_ui_show, 2206 inode_readahead_blks_store, s_inode_readahead_blks); |
2209EXT4_RW_ATTR_SBI_UI(inode_goal, s_inode_goal); | |
2210EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats); 2211EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan); 2212EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan); 2213EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs); 2214EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request); 2215EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc); 2216 2217static struct attribute *ext4_attrs[] = { 2218 ATTR_LIST(delayed_allocation_blocks), 2219 ATTR_LIST(session_write_kbytes), 2220 ATTR_LIST(lifetime_write_kbytes), 2221 ATTR_LIST(inode_readahead_blks), | 2207EXT4_RW_ATTR_SBI_UI(mb_stats, s_mb_stats); 2208EXT4_RW_ATTR_SBI_UI(mb_max_to_scan, s_mb_max_to_scan); 2209EXT4_RW_ATTR_SBI_UI(mb_min_to_scan, s_mb_min_to_scan); 2210EXT4_RW_ATTR_SBI_UI(mb_order2_req, s_mb_order2_reqs); 2211EXT4_RW_ATTR_SBI_UI(mb_stream_req, s_mb_stream_request); 2212EXT4_RW_ATTR_SBI_UI(mb_group_prealloc, s_mb_group_prealloc); 2213 2214static struct attribute *ext4_attrs[] = { 2215 ATTR_LIST(delayed_allocation_blocks), 2216 ATTR_LIST(session_write_kbytes), 2217 ATTR_LIST(lifetime_write_kbytes), 2218 ATTR_LIST(inode_readahead_blks), |
2222 ATTR_LIST(inode_goal), | |
2223 ATTR_LIST(mb_stats), 2224 ATTR_LIST(mb_max_to_scan), 2225 ATTR_LIST(mb_min_to_scan), 2226 ATTR_LIST(mb_order2_req), 2227 ATTR_LIST(mb_stream_req), 2228 ATTR_LIST(mb_group_prealloc), 2229 NULL, 2230}; --- 204 unchanged lines hidden (view full) --- 2435 ~EXT4_FEATURE_RO_COMPAT_SUPP)); 2436 goto failed_mount; 2437 } 2438 has_huge_files = EXT4_HAS_RO_COMPAT_FEATURE(sb, 2439 EXT4_FEATURE_RO_COMPAT_HUGE_FILE); 2440 if (has_huge_files) { 2441 /* 2442 * Large file size enabled file system can only be | 2219 ATTR_LIST(mb_stats), 2220 ATTR_LIST(mb_max_to_scan), 2221 ATTR_LIST(mb_min_to_scan), 2222 ATTR_LIST(mb_order2_req), 2223 ATTR_LIST(mb_stream_req), 2224 ATTR_LIST(mb_group_prealloc), 2225 NULL, 2226}; --- 204 unchanged lines hidden (view full) --- 2431 ~EXT4_FEATURE_RO_COMPAT_SUPP)); 2432 goto failed_mount; 2433 } 2434 has_huge_files = EXT4_HAS_RO_COMPAT_FEATURE(sb, 2435 EXT4_FEATURE_RO_COMPAT_HUGE_FILE); 2436 if (has_huge_files) { 2437 /* 2438 * Large file size enabled file system can only be |
2443 * mount if kernel is build with CONFIG_LBD | 2439 * mount if kernel is build with CONFIG_LBDAF |
2444 */ 2445 if (sizeof(root->i_blocks) < sizeof(u64) && 2446 !(sb->s_flags & MS_RDONLY)) { 2447 ext4_msg(sb, KERN_ERR, "Filesystem with huge " 2448 "files cannot be mounted read-write " | 2440 */ 2441 if (sizeof(root->i_blocks) < sizeof(u64) && 2442 !(sb->s_flags & MS_RDONLY)) { 2443 ext4_msg(sb, KERN_ERR, "Filesystem with huge " 2444 "files cannot be mounted read-write " |
2449 "without CONFIG_LBD"); | 2445 "without CONFIG_LBDAF"); |
2450 goto failed_mount; 2451 } 2452 } 2453 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); 2454 2455 if (blocksize < EXT4_MIN_BLOCK_SIZE || 2456 blocksize > EXT4_MAX_BLOCK_SIZE) { 2457 ext4_msg(sb, KERN_ERR, --- 107 unchanged lines hidden (view full) --- 2565 goto failed_mount; 2566 } 2567 2568 if (ext4_blocks_count(es) > 2569 (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { 2570 ext4_msg(sb, KERN_ERR, "filesystem" 2571 " too large to mount safely"); 2572 if (sizeof(sector_t) < 8) | 2446 goto failed_mount; 2447 } 2448 } 2449 blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); 2450 2451 if (blocksize < EXT4_MIN_BLOCK_SIZE || 2452 blocksize > EXT4_MAX_BLOCK_SIZE) { 2453 ext4_msg(sb, KERN_ERR, --- 107 unchanged lines hidden (view full) --- 2561 goto failed_mount; 2562 } 2563 2564 if (ext4_blocks_count(es) > 2565 (sector_t)(~0ULL) >> (sb->s_blocksize_bits - 9)) { 2566 ext4_msg(sb, KERN_ERR, "filesystem" 2567 " too large to mount safely"); 2568 if (sizeof(sector_t) < 8) |
2573 ext4_msg(sb, KERN_WARNING, "CONFIG_LBD not enabled"); | 2569 ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled"); |
2574 goto failed_mount; 2575 } 2576 2577 if (EXT4_BLOCKS_PER_GROUP(sb) == 0) 2578 goto cantfind_ext4; 2579 2580 /* check blocks count against device size */ 2581 blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; --- 763 unchanged lines hidden (view full) --- 3345 unlock_super(sb); 3346} 3347 3348static int ext4_sync_fs(struct super_block *sb, int wait) 3349{ 3350 int ret = 0; 3351 tid_t target; 3352 | 2570 goto failed_mount; 2571 } 2572 2573 if (EXT4_BLOCKS_PER_GROUP(sb) == 0) 2574 goto cantfind_ext4; 2575 2576 /* check blocks count against device size */ 2577 blocks_count = sb->s_bdev->bd_inode->i_size >> sb->s_blocksize_bits; --- 763 unchanged lines hidden (view full) --- 3341 unlock_super(sb); 3342} 3343 3344static int ext4_sync_fs(struct super_block *sb, int wait) 3345{ 3346 int ret = 0; 3347 tid_t target; 3348 |
3353 trace_ext4_sync_fs(sb, wait); | 3349 trace_mark(ext4_sync_fs, "dev %s wait %d", sb->s_id, wait); |
3354 if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, &target)) { 3355 if (wait) 3356 jbd2_log_wait_commit(EXT4_SB(sb)->s_journal, target); 3357 } 3358 return ret; 3359} 3360 3361/* --- 87 unchanged lines hidden (view full) --- 3449 * Allow the "check" option to be passed as a remount option. 3450 */ 3451 if (!parse_options(data, sb, NULL, &journal_ioprio, 3452 &n_blocks_count, 1)) { 3453 err = -EINVAL; 3454 goto restore_opts; 3455 } 3456 | 3350 if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, &target)) { 3351 if (wait) 3352 jbd2_log_wait_commit(EXT4_SB(sb)->s_journal, target); 3353 } 3354 return ret; 3355} 3356 3357/* --- 87 unchanged lines hidden (view full) --- 3445 * Allow the "check" option to be passed as a remount option. 3446 */ 3447 if (!parse_options(data, sb, NULL, &journal_ioprio, 3448 &n_blocks_count, 1)) { 3449 err = -EINVAL; 3450 goto restore_opts; 3451 } 3452 |
3457 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) | 3453 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT) |
3458 ext4_abort(sb, __func__, "Abort forced by user"); 3459 3460 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | 3461 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); 3462 3463 es = sbi->s_es; 3464 3465 if (sbi->s_journal) { 3466 ext4_init_journal_params(sb, sbi->s_journal); 3467 set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); 3468 } 3469 3470 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) || 3471 n_blocks_count > ext4_blocks_count(es)) { | 3454 ext4_abort(sb, __func__, "Abort forced by user"); 3455 3456 sb->s_flags = (sb->s_flags & ~MS_POSIXACL) | 3457 ((sbi->s_mount_opt & EXT4_MOUNT_POSIX_ACL) ? MS_POSIXACL : 0); 3458 3459 es = sbi->s_es; 3460 3461 if (sbi->s_journal) { 3462 ext4_init_journal_params(sb, sbi->s_journal); 3463 set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); 3464 } 3465 3466 if ((*flags & MS_RDONLY) != (sb->s_flags & MS_RDONLY) || 3467 n_blocks_count > ext4_blocks_count(es)) { |
3472 if (sbi->s_mount_flags & EXT4_MF_FS_ABORTED) { | 3468 if (sbi->s_mount_opt & EXT4_MOUNT_ABORT) { |
3473 err = -EROFS; 3474 goto restore_opts; 3475 } 3476 3477 if (*flags & MS_RDONLY) { 3478 /* 3479 * First of all, the unconditional stuff we have to do 3480 * to disable replay of the journal when we next remount --- 554 unchanged lines hidden --- | 3469 err = -EROFS; 3470 goto restore_opts; 3471 } 3472 3473 if (*flags & MS_RDONLY) { 3474 /* 3475 * First of all, the unconditional stuff we have to do 3476 * to disable replay of the journal when we next remount --- 554 unchanged lines hidden --- |