aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-05-03 12:56:25 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-05-03 12:56:25 -0400
commit14a9e5c09d13aa36b88ea54b8b6134b60ff2a410 (patch)
tree4c8c477d4e459bd3429b83a81e3db531ffe32969
parent8546dc1d4b671480961c3eaf4c0c102ae6848340 (diff)
parentfb1c2d8294a60184a151ff12182446d7b930ed95 (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
-rw-r--r--fs/ext3/inode.c3
-rw-r--r--fs/jbd/journal.c19
-rw-r--r--fs/jbd/transaction.c1
-rw-r--r--include/linux/jbd.h2
4 files changed, 17 insertions, 8 deletions
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c
index d512c4bc4ad7..d706dbfa6220 100644
--- a/fs/ext3/inode.c
+++ b/fs/ext3/inode.c
@@ -218,7 +218,8 @@ void ext3_evict_inode (struct inode *inode)
218 */ 218 */
219 if (inode->i_nlink && ext3_should_journal_data(inode) && 219 if (inode->i_nlink && ext3_should_journal_data(inode) &&
220 EXT3_SB(inode->i_sb)->s_journal && 220 EXT3_SB(inode->i_sb)->s_journal &&
221 (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode))) { 221 (S_ISLNK(inode->i_mode) || S_ISREG(inode->i_mode)) &&
222 inode->i_ino != EXT3_JOURNAL_INO) {
222 tid_t commit_tid = atomic_read(&ei->i_datasync_tid); 223 tid_t commit_tid = atomic_read(&ei->i_datasync_tid);
223 journal_t *journal = EXT3_SB(inode->i_sb)->s_journal; 224 journal_t *journal = EXT3_SB(inode->i_sb)->s_journal;
224 225
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 }
586out_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
1915repeat: 1926repeat:
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)) {
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 071d6905f0dd..e3e255c0a509 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -245,7 +245,6 @@ static handle_t *new_handle(int nblocks)
245 handle_t *handle = jbd_alloc_handle(GFP_NOFS); 245 handle_t *handle = jbd_alloc_handle(GFP_NOFS);
246 if (!handle) 246 if (!handle)
247 return NULL; 247 return NULL;
248 memset(handle, 0, sizeof(*handle));
249 handle->h_buffer_credits = nblocks; 248 handle->h_buffer_credits = nblocks;
250 handle->h_ref = 1; 249 handle->h_ref = 1;
251 250
diff --git a/include/linux/jbd.h b/include/linux/jbd.h
index c8f32975f0e4..7e0b622503c4 100644
--- a/include/linux/jbd.h
+++ b/include/linux/jbd.h
@@ -887,7 +887,7 @@ extern struct kmem_cache *jbd_handle_cache;
887 887
888static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags) 888static inline handle_t *jbd_alloc_handle(gfp_t gfp_flags)
889{ 889{
890 return kmem_cache_alloc(jbd_handle_cache, gfp_flags); 890 return kmem_cache_zalloc(jbd_handle_cache, gfp_flags);
891} 891}
892 892
893static inline void jbd_free_handle(handle_t *handle) 893static inline void jbd_free_handle(handle_t *handle)