diff options
| -rw-r--r-- | fs/ext4/balloc.c | 4 | ||||
| -rw-r--r-- | fs/ext4/ext4.h | 1 | ||||
| -rw-r--r-- | fs/ext4/ext4_jbd2.h | 10 | ||||
| -rw-r--r-- | fs/ext4/mballoc.c | 12 |
4 files changed, 23 insertions, 4 deletions
diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c index 3020fd70c392..0b8105b3293d 100644 --- a/fs/ext4/balloc.c +++ b/fs/ext4/balloc.c | |||
| @@ -610,7 +610,9 @@ int ext4_should_retry_alloc(struct super_block *sb, int *retries) | |||
| 610 | 610 | ||
| 611 | jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id); | 611 | jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id); |
| 612 | 612 | ||
| 613 | jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal); | 613 | smp_mb(); |
| 614 | if (EXT4_SB(sb)->s_mb_free_pending) | ||
| 615 | jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal); | ||
| 614 | return 1; | 616 | return 1; |
| 615 | } | 617 | } |
| 616 | 618 | ||
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index b84aa1ca480a..96c73e6fec6e 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
| @@ -1430,6 +1430,7 @@ struct ext4_sb_info { | |||
| 1430 | unsigned short *s_mb_offsets; | 1430 | unsigned short *s_mb_offsets; |
| 1431 | unsigned int *s_mb_maxs; | 1431 | unsigned int *s_mb_maxs; |
| 1432 | unsigned int s_group_info_size; | 1432 | unsigned int s_group_info_size; |
| 1433 | unsigned int s_mb_free_pending; | ||
| 1433 | 1434 | ||
| 1434 | /* tunables */ | 1435 | /* tunables */ |
| 1435 | unsigned long s_stripe; | 1436 | unsigned long s_stripe; |
diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h index 09c1ef38cbe6..b1d52c14098e 100644 --- a/fs/ext4/ext4_jbd2.h +++ b/fs/ext4/ext4_jbd2.h | |||
| @@ -175,6 +175,13 @@ struct ext4_journal_cb_entry { | |||
| 175 | * There is no guaranteed calling order of multiple registered callbacks on | 175 | * There is no guaranteed calling order of multiple registered callbacks on |
| 176 | * the same transaction. | 176 | * the same transaction. |
| 177 | */ | 177 | */ |
| 178 | static inline void _ext4_journal_callback_add(handle_t *handle, | ||
| 179 | struct ext4_journal_cb_entry *jce) | ||
| 180 | { | ||
| 181 | /* Add the jce to transaction's private list */ | ||
| 182 | list_add_tail(&jce->jce_list, &handle->h_transaction->t_private_list); | ||
| 183 | } | ||
| 184 | |||
| 178 | static inline void ext4_journal_callback_add(handle_t *handle, | 185 | static inline void ext4_journal_callback_add(handle_t *handle, |
| 179 | void (*func)(struct super_block *sb, | 186 | void (*func)(struct super_block *sb, |
| 180 | struct ext4_journal_cb_entry *jce, | 187 | struct ext4_journal_cb_entry *jce, |
| @@ -187,10 +194,11 @@ static inline void ext4_journal_callback_add(handle_t *handle, | |||
| 187 | /* Add the jce to transaction's private list */ | 194 | /* Add the jce to transaction's private list */ |
| 188 | jce->jce_func = func; | 195 | jce->jce_func = func; |
| 189 | spin_lock(&sbi->s_md_lock); | 196 | spin_lock(&sbi->s_md_lock); |
| 190 | list_add_tail(&jce->jce_list, &handle->h_transaction->t_private_list); | 197 | _ext4_journal_callback_add(handle, jce); |
| 191 | spin_unlock(&sbi->s_md_lock); | 198 | spin_unlock(&sbi->s_md_lock); |
| 192 | } | 199 | } |
| 193 | 200 | ||
| 201 | |||
| 194 | /** | 202 | /** |
| 195 | * ext4_journal_callback_del: delete a registered callback | 203 | * ext4_journal_callback_del: delete a registered callback |
| 196 | * @handle: active journal transaction handle on which callback was registered | 204 | * @handle: active journal transaction handle on which callback was registered |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index c1ab3ec30423..77249e1f5c3a 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
| @@ -2627,6 +2627,7 @@ int ext4_mb_init(struct super_block *sb) | |||
| 2627 | 2627 | ||
| 2628 | spin_lock_init(&sbi->s_md_lock); | 2628 | spin_lock_init(&sbi->s_md_lock); |
| 2629 | spin_lock_init(&sbi->s_bal_lock); | 2629 | spin_lock_init(&sbi->s_bal_lock); |
| 2630 | sbi->s_mb_free_pending = 0; | ||
| 2630 | 2631 | ||
| 2631 | sbi->s_mb_max_to_scan = MB_DEFAULT_MAX_TO_SCAN; | 2632 | sbi->s_mb_max_to_scan = MB_DEFAULT_MAX_TO_SCAN; |
| 2632 | sbi->s_mb_min_to_scan = MB_DEFAULT_MIN_TO_SCAN; | 2633 | sbi->s_mb_min_to_scan = MB_DEFAULT_MIN_TO_SCAN; |
| @@ -2814,6 +2815,9 @@ static void ext4_free_data_callback(struct super_block *sb, | |||
| 2814 | /* we expect to find existing buddy because it's pinned */ | 2815 | /* we expect to find existing buddy because it's pinned */ |
| 2815 | BUG_ON(err != 0); | 2816 | BUG_ON(err != 0); |
| 2816 | 2817 | ||
| 2818 | spin_lock(&EXT4_SB(sb)->s_md_lock); | ||
| 2819 | EXT4_SB(sb)->s_mb_free_pending -= entry->efd_count; | ||
| 2820 | spin_unlock(&EXT4_SB(sb)->s_md_lock); | ||
| 2817 | 2821 | ||
| 2818 | db = e4b.bd_info; | 2822 | db = e4b.bd_info; |
| 2819 | /* there are blocks to put in buddy to make them really free */ | 2823 | /* there are blocks to put in buddy to make them really free */ |
| @@ -4583,6 +4587,7 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b, | |||
| 4583 | { | 4587 | { |
| 4584 | ext4_group_t group = e4b->bd_group; | 4588 | ext4_group_t group = e4b->bd_group; |
| 4585 | ext4_grpblk_t cluster; | 4589 | ext4_grpblk_t cluster; |
| 4590 | ext4_grpblk_t clusters = new_entry->efd_count; | ||
| 4586 | struct ext4_free_data *entry; | 4591 | struct ext4_free_data *entry; |
| 4587 | struct ext4_group_info *db = e4b->bd_info; | 4592 | struct ext4_group_info *db = e4b->bd_info; |
| 4588 | struct super_block *sb = e4b->bd_sb; | 4593 | struct super_block *sb = e4b->bd_sb; |
| @@ -4649,8 +4654,11 @@ ext4_mb_free_metadata(handle_t *handle, struct ext4_buddy *e4b, | |||
| 4649 | } | 4654 | } |
| 4650 | } | 4655 | } |
| 4651 | /* Add the extent to transaction's private list */ | 4656 | /* Add the extent to transaction's private list */ |
| 4652 | ext4_journal_callback_add(handle, ext4_free_data_callback, | 4657 | new_entry->efd_jce.jce_func = ext4_free_data_callback; |
| 4653 | &new_entry->efd_jce); | 4658 | spin_lock(&sbi->s_md_lock); |
| 4659 | _ext4_journal_callback_add(handle, &new_entry->efd_jce); | ||
| 4660 | sbi->s_mb_free_pending += clusters; | ||
| 4661 | spin_unlock(&sbi->s_md_lock); | ||
| 4654 | return 0; | 4662 | return 0; |
| 4655 | } | 4663 | } |
| 4656 | 4664 | ||
