diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-03 12:56:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-03 12:56:25 -0400 |
commit | 14a9e5c09d13aa36b88ea54b8b6134b60ff2a410 (patch) | |
tree | 4c8c477d4e459bd3429b83a81e3db531ffe32969 /fs/jbd/journal.c | |
parent | 8546dc1d4b671480961c3eaf4c0c102ae6848340 (diff) | |
parent | fb1c2d8294a60184a151ff12182446d7b930ed95 (diff) |
Merge branch 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs
Pull ext3/jbd fixes from Jan Kara:
"A couple of ext3/jbd fixes"
* 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
jbd: use kmem_cache_zalloc for allocating journal head
jbd: use kmem_cache_zalloc instead of kmem_cache_alloc/memset
jbd: don't wait (forever) for stale tid caused by wraparound
ext3: fix data=journal fast mount/umount hang
Diffstat (limited to 'fs/jbd/journal.c')
-rw-r--r-- | fs/jbd/journal.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index 865c4308acb6..6510d6355729 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c | |||
@@ -562,6 +562,16 @@ int log_wait_commit(journal_t *journal, tid_t tid) | |||
562 | spin_unlock(&journal->j_state_lock); | 562 | spin_unlock(&journal->j_state_lock); |
563 | #endif | 563 | #endif |
564 | spin_lock(&journal->j_state_lock); | 564 | spin_lock(&journal->j_state_lock); |
565 | /* | ||
566 | * Not running or committing trans? Must be already committed. This | ||
567 | * saves us from waiting for a *long* time when tid overflows. | ||
568 | */ | ||
569 | if (!((journal->j_running_transaction && | ||
570 | journal->j_running_transaction->t_tid == tid) || | ||
571 | (journal->j_committing_transaction && | ||
572 | journal->j_committing_transaction->t_tid == tid))) | ||
573 | goto out_unlock; | ||
574 | |||
565 | if (!tid_geq(journal->j_commit_waited, tid)) | 575 | if (!tid_geq(journal->j_commit_waited, tid)) |
566 | journal->j_commit_waited = tid; | 576 | journal->j_commit_waited = tid; |
567 | while (tid_gt(tid, journal->j_commit_sequence)) { | 577 | while (tid_gt(tid, journal->j_commit_sequence)) { |
@@ -573,6 +583,7 @@ int log_wait_commit(journal_t *journal, tid_t tid) | |||
573 | !tid_gt(tid, journal->j_commit_sequence)); | 583 | !tid_gt(tid, journal->j_commit_sequence)); |
574 | spin_lock(&journal->j_state_lock); | 584 | spin_lock(&journal->j_state_lock); |
575 | } | 585 | } |
586 | out_unlock: | ||
576 | spin_unlock(&journal->j_state_lock); | 587 | spin_unlock(&journal->j_state_lock); |
577 | 588 | ||
578 | if (unlikely(is_journal_aborted(journal))) { | 589 | if (unlikely(is_journal_aborted(journal))) { |
@@ -1843,7 +1854,7 @@ static struct journal_head *journal_alloc_journal_head(void) | |||
1843 | #ifdef CONFIG_JBD_DEBUG | 1854 | #ifdef CONFIG_JBD_DEBUG |
1844 | atomic_inc(&nr_journal_heads); | 1855 | atomic_inc(&nr_journal_heads); |
1845 | #endif | 1856 | #endif |
1846 | ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS); | 1857 | ret = kmem_cache_zalloc(journal_head_cache, GFP_NOFS); |
1847 | if (ret == NULL) { | 1858 | if (ret == NULL) { |
1848 | jbd_debug(1, "out of memory for journal_head\n"); | 1859 | jbd_debug(1, "out of memory for journal_head\n"); |
1849 | printk_ratelimited(KERN_NOTICE "ENOMEM in %s, retrying.\n", | 1860 | printk_ratelimited(KERN_NOTICE "ENOMEM in %s, retrying.\n", |
@@ -1851,7 +1862,7 @@ static struct journal_head *journal_alloc_journal_head(void) | |||
1851 | 1862 | ||
1852 | while (ret == NULL) { | 1863 | while (ret == NULL) { |
1853 | yield(); | 1864 | yield(); |
1854 | ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS); | 1865 | ret = kmem_cache_zalloc(journal_head_cache, GFP_NOFS); |
1855 | } | 1866 | } |
1856 | } | 1867 | } |
1857 | return ret; | 1868 | return ret; |
@@ -1913,10 +1924,8 @@ struct journal_head *journal_add_journal_head(struct buffer_head *bh) | |||
1913 | struct journal_head *new_jh = NULL; | 1924 | struct journal_head *new_jh = NULL; |
1914 | 1925 | ||
1915 | repeat: | 1926 | repeat: |
1916 | if (!buffer_jbd(bh)) { | 1927 | if (!buffer_jbd(bh)) |
1917 | new_jh = journal_alloc_journal_head(); | 1928 | new_jh = journal_alloc_journal_head(); |
1918 | memset(new_jh, 0, sizeof(*new_jh)); | ||
1919 | } | ||
1920 | 1929 | ||
1921 | jbd_lock_bh_journal_head(bh); | 1930 | jbd_lock_bh_journal_head(bh); |
1922 | if (buffer_jbd(bh)) { | 1931 | if (buffer_jbd(bh)) { |