diff options
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r-- | fs/ext4/super.c | 125 |
1 files changed, 77 insertions, 48 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 40131b777af6..fb15c9c0be74 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
@@ -828,12 +828,22 @@ static struct inode *ext4_alloc_inode(struct super_block *sb) | |||
828 | ei->cur_aio_dio = NULL; | 828 | ei->cur_aio_dio = NULL; |
829 | ei->i_sync_tid = 0; | 829 | ei->i_sync_tid = 0; |
830 | ei->i_datasync_tid = 0; | 830 | ei->i_datasync_tid = 0; |
831 | atomic_set(&ei->i_ioend_count, 0); | ||
831 | 832 | ||
832 | return &ei->vfs_inode; | 833 | return &ei->vfs_inode; |
833 | } | 834 | } |
834 | 835 | ||
836 | static int ext4_drop_inode(struct inode *inode) | ||
837 | { | ||
838 | int drop = generic_drop_inode(inode); | ||
839 | |||
840 | trace_ext4_drop_inode(inode, drop); | ||
841 | return drop; | ||
842 | } | ||
843 | |||
835 | static void ext4_destroy_inode(struct inode *inode) | 844 | static void ext4_destroy_inode(struct inode *inode) |
836 | { | 845 | { |
846 | ext4_ioend_wait(inode); | ||
837 | if (!list_empty(&(EXT4_I(inode)->i_orphan))) { | 847 | if (!list_empty(&(EXT4_I(inode)->i_orphan))) { |
838 | ext4_msg(inode->i_sb, KERN_ERR, | 848 | ext4_msg(inode->i_sb, KERN_ERR, |
839 | "Inode %lu (%p): orphan list check failed!", | 849 | "Inode %lu (%p): orphan list check failed!", |
@@ -1016,6 +1026,8 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs) | |||
1016 | !(def_mount_opts & EXT4_DEFM_NODELALLOC)) | 1026 | !(def_mount_opts & EXT4_DEFM_NODELALLOC)) |
1017 | seq_puts(seq, ",nodelalloc"); | 1027 | seq_puts(seq, ",nodelalloc"); |
1018 | 1028 | ||
1029 | if (test_opt(sb, MBLK_IO_SUBMIT)) | ||
1030 | seq_puts(seq, ",mblk_io_submit"); | ||
1019 | if (sbi->s_stripe) | 1031 | if (sbi->s_stripe) |
1020 | seq_printf(seq, ",stripe=%lu", sbi->s_stripe); | 1032 | seq_printf(seq, ",stripe=%lu", sbi->s_stripe); |
1021 | /* | 1033 | /* |
@@ -1173,6 +1185,7 @@ static const struct super_operations ext4_sops = { | |||
1173 | .destroy_inode = ext4_destroy_inode, | 1185 | .destroy_inode = ext4_destroy_inode, |
1174 | .write_inode = ext4_write_inode, | 1186 | .write_inode = ext4_write_inode, |
1175 | .dirty_inode = ext4_dirty_inode, | 1187 | .dirty_inode = ext4_dirty_inode, |
1188 | .drop_inode = ext4_drop_inode, | ||
1176 | .evict_inode = ext4_evict_inode, | 1189 | .evict_inode = ext4_evict_inode, |
1177 | .put_super = ext4_put_super, | 1190 | .put_super = ext4_put_super, |
1178 | .sync_fs = ext4_sync_fs, | 1191 | .sync_fs = ext4_sync_fs, |
@@ -1186,7 +1199,6 @@ static const struct super_operations ext4_sops = { | |||
1186 | .quota_write = ext4_quota_write, | 1199 | .quota_write = ext4_quota_write, |
1187 | #endif | 1200 | #endif |
1188 | .bdev_try_to_free_page = bdev_try_to_free_page, | 1201 | .bdev_try_to_free_page = bdev_try_to_free_page, |
1189 | .trim_fs = ext4_trim_fs | ||
1190 | }; | 1202 | }; |
1191 | 1203 | ||
1192 | static const struct super_operations ext4_nojournal_sops = { | 1204 | static const struct super_operations ext4_nojournal_sops = { |
@@ -1194,6 +1206,7 @@ static const struct super_operations ext4_nojournal_sops = { | |||
1194 | .destroy_inode = ext4_destroy_inode, | 1206 | .destroy_inode = ext4_destroy_inode, |
1195 | .write_inode = ext4_write_inode, | 1207 | .write_inode = ext4_write_inode, |
1196 | .dirty_inode = ext4_dirty_inode, | 1208 | .dirty_inode = ext4_dirty_inode, |
1209 | .drop_inode = ext4_drop_inode, | ||
1197 | .evict_inode = ext4_evict_inode, | 1210 | .evict_inode = ext4_evict_inode, |
1198 | .write_super = ext4_write_super, | 1211 | .write_super = ext4_write_super, |
1199 | .put_super = ext4_put_super, | 1212 | .put_super = ext4_put_super, |
@@ -1228,8 +1241,8 @@ enum { | |||
1228 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota, | 1241 | Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota, |
1229 | Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, | 1242 | Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err, |
1230 | Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version, | 1243 | Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version, |
1231 | Opt_stripe, Opt_delalloc, Opt_nodelalloc, | 1244 | Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_mblk_io_submit, |
1232 | Opt_block_validity, Opt_noblock_validity, | 1245 | Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity, |
1233 | Opt_inode_readahead_blks, Opt_journal_ioprio, | 1246 | Opt_inode_readahead_blks, Opt_journal_ioprio, |
1234 | Opt_dioread_nolock, Opt_dioread_lock, | 1247 | Opt_dioread_nolock, Opt_dioread_lock, |
1235 | Opt_discard, Opt_nodiscard, | 1248 | Opt_discard, Opt_nodiscard, |
@@ -1293,6 +1306,8 @@ static const match_table_t tokens = { | |||
1293 | {Opt_resize, "resize"}, | 1306 | {Opt_resize, "resize"}, |
1294 | {Opt_delalloc, "delalloc"}, | 1307 | {Opt_delalloc, "delalloc"}, |
1295 | {Opt_nodelalloc, "nodelalloc"}, | 1308 | {Opt_nodelalloc, "nodelalloc"}, |
1309 | {Opt_mblk_io_submit, "mblk_io_submit"}, | ||
1310 | {Opt_nomblk_io_submit, "nomblk_io_submit"}, | ||
1296 | {Opt_block_validity, "block_validity"}, | 1311 | {Opt_block_validity, "block_validity"}, |
1297 | {Opt_noblock_validity, "noblock_validity"}, | 1312 | {Opt_noblock_validity, "noblock_validity"}, |
1298 | {Opt_inode_readahead_blks, "inode_readahead_blks=%u"}, | 1313 | {Opt_inode_readahead_blks, "inode_readahead_blks=%u"}, |
@@ -1714,6 +1729,12 @@ set_qf_format: | |||
1714 | case Opt_nodelalloc: | 1729 | case Opt_nodelalloc: |
1715 | clear_opt(sbi->s_mount_opt, DELALLOC); | 1730 | clear_opt(sbi->s_mount_opt, DELALLOC); |
1716 | break; | 1731 | break; |
1732 | case Opt_mblk_io_submit: | ||
1733 | set_opt(sbi->s_mount_opt, MBLK_IO_SUBMIT); | ||
1734 | break; | ||
1735 | case Opt_nomblk_io_submit: | ||
1736 | clear_opt(sbi->s_mount_opt, MBLK_IO_SUBMIT); | ||
1737 | break; | ||
1717 | case Opt_stripe: | 1738 | case Opt_stripe: |
1718 | if (match_int(&args[0], &option)) | 1739 | if (match_int(&args[0], &option)) |
1719 | return 0; | 1740 | return 0; |
@@ -2699,7 +2720,6 @@ static int ext4_lazyinit_thread(void *arg) | |||
2699 | struct ext4_li_request *elr; | 2720 | struct ext4_li_request *elr; |
2700 | unsigned long next_wakeup; | 2721 | unsigned long next_wakeup; |
2701 | DEFINE_WAIT(wait); | 2722 | DEFINE_WAIT(wait); |
2702 | int ret; | ||
2703 | 2723 | ||
2704 | BUG_ON(NULL == eli); | 2724 | BUG_ON(NULL == eli); |
2705 | 2725 | ||
@@ -2723,13 +2743,12 @@ cont_thread: | |||
2723 | elr = list_entry(pos, struct ext4_li_request, | 2743 | elr = list_entry(pos, struct ext4_li_request, |
2724 | lr_request); | 2744 | lr_request); |
2725 | 2745 | ||
2726 | if (time_after_eq(jiffies, elr->lr_next_sched)) | 2746 | if (time_after_eq(jiffies, elr->lr_next_sched)) { |
2727 | ret = ext4_run_li_request(elr); | 2747 | if (ext4_run_li_request(elr) != 0) { |
2728 | 2748 | /* error, remove the lazy_init job */ | |
2729 | if (ret) { | 2749 | ext4_remove_li_request(elr); |
2730 | ret = 0; | 2750 | continue; |
2731 | ext4_remove_li_request(elr); | 2751 | } |
2732 | continue; | ||
2733 | } | 2752 | } |
2734 | 2753 | ||
2735 | if (time_before(elr->lr_next_sched, next_wakeup)) | 2754 | if (time_before(elr->lr_next_sched, next_wakeup)) |
@@ -2740,7 +2759,8 @@ cont_thread: | |||
2740 | if (freezing(current)) | 2759 | if (freezing(current)) |
2741 | refrigerator(); | 2760 | refrigerator(); |
2742 | 2761 | ||
2743 | if (time_after_eq(jiffies, next_wakeup)) { | 2762 | if ((time_after_eq(jiffies, next_wakeup)) || |
2763 | (MAX_JIFFY_OFFSET == next_wakeup)) { | ||
2744 | cond_resched(); | 2764 | cond_resched(); |
2745 | continue; | 2765 | continue; |
2746 | } | 2766 | } |
@@ -2788,9 +2808,6 @@ static void ext4_clear_request_list(void) | |||
2788 | struct ext4_li_request *elr; | 2808 | struct ext4_li_request *elr; |
2789 | 2809 | ||
2790 | mutex_lock(&ext4_li_info->li_list_mtx); | 2810 | mutex_lock(&ext4_li_info->li_list_mtx); |
2791 | if (list_empty(&ext4_li_info->li_request_list)) | ||
2792 | return; | ||
2793 | |||
2794 | list_for_each_safe(pos, n, &ext4_li_info->li_request_list) { | 2811 | list_for_each_safe(pos, n, &ext4_li_info->li_request_list) { |
2795 | elr = list_entry(pos, struct ext4_li_request, | 2812 | elr = list_entry(pos, struct ext4_li_request, |
2796 | lr_request); | 2813 | lr_request); |
@@ -3257,13 +3274,14 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3257 | * Test whether we have more sectors than will fit in sector_t, | 3274 | * Test whether we have more sectors than will fit in sector_t, |
3258 | * and whether the max offset is addressable by the page cache. | 3275 | * and whether the max offset is addressable by the page cache. |
3259 | */ | 3276 | */ |
3260 | ret = generic_check_addressable(sb->s_blocksize_bits, | 3277 | err = generic_check_addressable(sb->s_blocksize_bits, |
3261 | ext4_blocks_count(es)); | 3278 | ext4_blocks_count(es)); |
3262 | if (ret) { | 3279 | if (err) { |
3263 | ext4_msg(sb, KERN_ERR, "filesystem" | 3280 | ext4_msg(sb, KERN_ERR, "filesystem" |
3264 | " too large to mount safely on this system"); | 3281 | " too large to mount safely on this system"); |
3265 | if (sizeof(sector_t) < 8) | 3282 | if (sizeof(sector_t) < 8) |
3266 | ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled"); | 3283 | ext4_msg(sb, KERN_WARNING, "CONFIG_LBDAF not enabled"); |
3284 | ret = err; | ||
3267 | goto failed_mount; | 3285 | goto failed_mount; |
3268 | } | 3286 | } |
3269 | 3287 | ||
@@ -3348,6 +3366,24 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3348 | get_random_bytes(&sbi->s_next_generation, sizeof(u32)); | 3366 | get_random_bytes(&sbi->s_next_generation, sizeof(u32)); |
3349 | spin_lock_init(&sbi->s_next_gen_lock); | 3367 | spin_lock_init(&sbi->s_next_gen_lock); |
3350 | 3368 | ||
3369 | err = percpu_counter_init(&sbi->s_freeblocks_counter, | ||
3370 | ext4_count_free_blocks(sb)); | ||
3371 | if (!err) { | ||
3372 | err = percpu_counter_init(&sbi->s_freeinodes_counter, | ||
3373 | ext4_count_free_inodes(sb)); | ||
3374 | } | ||
3375 | if (!err) { | ||
3376 | err = percpu_counter_init(&sbi->s_dirs_counter, | ||
3377 | ext4_count_dirs(sb)); | ||
3378 | } | ||
3379 | if (!err) { | ||
3380 | err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); | ||
3381 | } | ||
3382 | if (err) { | ||
3383 | ext4_msg(sb, KERN_ERR, "insufficient memory"); | ||
3384 | goto failed_mount3; | ||
3385 | } | ||
3386 | |||
3351 | sbi->s_stripe = ext4_get_stripe_size(sbi); | 3387 | sbi->s_stripe = ext4_get_stripe_size(sbi); |
3352 | sbi->s_max_writeback_mb_bump = 128; | 3388 | sbi->s_max_writeback_mb_bump = 128; |
3353 | 3389 | ||
@@ -3446,22 +3482,19 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
3446 | } | 3482 | } |
3447 | set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); | 3483 | set_task_ioprio(sbi->s_journal->j_task, journal_ioprio); |
3448 | 3484 | ||
3449 | no_journal: | 3485 | /* |
3450 | err = percpu_counter_init(&sbi->s_freeblocks_counter, | 3486 | * The journal may have updated the bg summary counts, so we |
3451 | ext4_count_free_blocks(sb)); | 3487 | * need to update the global counters. |
3452 | if (!err) | 3488 | */ |
3453 | err = percpu_counter_init(&sbi->s_freeinodes_counter, | 3489 | percpu_counter_set(&sbi->s_freeblocks_counter, |
3454 | ext4_count_free_inodes(sb)); | 3490 | ext4_count_free_blocks(sb)); |
3455 | if (!err) | 3491 | percpu_counter_set(&sbi->s_freeinodes_counter, |
3456 | err = percpu_counter_init(&sbi->s_dirs_counter, | 3492 | ext4_count_free_inodes(sb)); |
3457 | ext4_count_dirs(sb)); | 3493 | percpu_counter_set(&sbi->s_dirs_counter, |
3458 | if (!err) | 3494 | ext4_count_dirs(sb)); |
3459 | err = percpu_counter_init(&sbi->s_dirtyblocks_counter, 0); | 3495 | percpu_counter_set(&sbi->s_dirtyblocks_counter, 0); |
3460 | if (err) { | ||
3461 | ext4_msg(sb, KERN_ERR, "insufficient memory"); | ||
3462 | goto failed_mount_wq; | ||
3463 | } | ||
3464 | 3496 | ||
3497 | no_journal: | ||
3465 | EXT4_SB(sb)->dio_unwritten_wq = create_workqueue("ext4-dio-unwritten"); | 3498 | EXT4_SB(sb)->dio_unwritten_wq = create_workqueue("ext4-dio-unwritten"); |
3466 | if (!EXT4_SB(sb)->dio_unwritten_wq) { | 3499 | if (!EXT4_SB(sb)->dio_unwritten_wq) { |
3467 | printk(KERN_ERR "EXT4-fs: failed to create DIO workqueue\n"); | 3500 | printk(KERN_ERR "EXT4-fs: failed to create DIO workqueue\n"); |
@@ -3611,10 +3644,6 @@ failed_mount_wq: | |||
3611 | jbd2_journal_destroy(sbi->s_journal); | 3644 | jbd2_journal_destroy(sbi->s_journal); |
3612 | sbi->s_journal = NULL; | 3645 | sbi->s_journal = NULL; |
3613 | } | 3646 | } |
3614 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | ||
3615 | percpu_counter_destroy(&sbi->s_freeinodes_counter); | ||
3616 | percpu_counter_destroy(&sbi->s_dirs_counter); | ||
3617 | percpu_counter_destroy(&sbi->s_dirtyblocks_counter); | ||
3618 | failed_mount3: | 3647 | failed_mount3: |
3619 | if (sbi->s_flex_groups) { | 3648 | if (sbi->s_flex_groups) { |
3620 | if (is_vmalloc_addr(sbi->s_flex_groups)) | 3649 | if (is_vmalloc_addr(sbi->s_flex_groups)) |
@@ -3622,6 +3651,10 @@ failed_mount3: | |||
3622 | else | 3651 | else |
3623 | kfree(sbi->s_flex_groups); | 3652 | kfree(sbi->s_flex_groups); |
3624 | } | 3653 | } |
3654 | percpu_counter_destroy(&sbi->s_freeblocks_counter); | ||
3655 | percpu_counter_destroy(&sbi->s_freeinodes_counter); | ||
3656 | percpu_counter_destroy(&sbi->s_dirs_counter); | ||
3657 | percpu_counter_destroy(&sbi->s_dirtyblocks_counter); | ||
3625 | failed_mount2: | 3658 | failed_mount2: |
3626 | for (i = 0; i < db_count; i++) | 3659 | for (i = 0; i < db_count; i++) |
3627 | brelse(sbi->s_group_desc[i]); | 3660 | brelse(sbi->s_group_desc[i]); |
@@ -3949,13 +3982,11 @@ static int ext4_commit_super(struct super_block *sb, int sync) | |||
3949 | else | 3982 | else |
3950 | es->s_kbytes_written = | 3983 | es->s_kbytes_written = |
3951 | cpu_to_le64(EXT4_SB(sb)->s_kbytes_written); | 3984 | cpu_to_le64(EXT4_SB(sb)->s_kbytes_written); |
3952 | if (percpu_counter_initialized(&EXT4_SB(sb)->s_freeblocks_counter)) | 3985 | ext4_free_blocks_count_set(es, percpu_counter_sum_positive( |
3953 | ext4_free_blocks_count_set(es, percpu_counter_sum_positive( | 3986 | &EXT4_SB(sb)->s_freeblocks_counter)); |
3954 | &EXT4_SB(sb)->s_freeblocks_counter)); | 3987 | es->s_free_inodes_count = |
3955 | if (percpu_counter_initialized(&EXT4_SB(sb)->s_freeinodes_counter)) | 3988 | cpu_to_le32(percpu_counter_sum_positive( |
3956 | es->s_free_inodes_count = | 3989 | &EXT4_SB(sb)->s_freeinodes_counter)); |
3957 | cpu_to_le32(percpu_counter_sum_positive( | ||
3958 | &EXT4_SB(sb)->s_freeinodes_counter)); | ||
3959 | sb->s_dirt = 0; | 3990 | sb->s_dirt = 0; |
3960 | BUFFER_TRACE(sbh, "marking dirty"); | 3991 | BUFFER_TRACE(sbh, "marking dirty"); |
3961 | mark_buffer_dirty(sbh); | 3992 | mark_buffer_dirty(sbh); |
@@ -4556,12 +4587,10 @@ static int ext4_quota_on(struct super_block *sb, int type, int format_id, | |||
4556 | 4587 | ||
4557 | static int ext4_quota_off(struct super_block *sb, int type) | 4588 | static int ext4_quota_off(struct super_block *sb, int type) |
4558 | { | 4589 | { |
4559 | /* Force all delayed allocation blocks to be allocated */ | 4590 | /* Force all delayed allocation blocks to be allocated. |
4560 | if (test_opt(sb, DELALLOC)) { | 4591 | * Caller already holds s_umount sem */ |
4561 | down_read(&sb->s_umount); | 4592 | if (test_opt(sb, DELALLOC)) |
4562 | sync_filesystem(sb); | 4593 | sync_filesystem(sb); |
4563 | up_read(&sb->s_umount); | ||
4564 | } | ||
4565 | 4594 | ||
4566 | return dquot_quota_off(sb, type); | 4595 | return dquot_quota_off(sb, type); |
4567 | } | 4596 | } |