From c5639bef63a241d8d5a00e5243d7f304d7563c46 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Mon, 4 Oct 2010 17:26:53 +0900 Subject: jbd: Move debug message into #ifdef area Move call to jbd_debug() into #ifdef CONFIG_JBD_DEBUG block because 'dropped' is declared there. The code could be compiled without this change anyway, simply because jbd_debug() expands to nothing if !CONFIG_JBD_DEBUG but IMHO it doesn't look good in general. Signed-off-by: Namhyung Kim Signed-off-by: Jan Kara --- fs/jbd/recovery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/jbd') diff --git a/fs/jbd/recovery.c b/fs/jbd/recovery.c index 81051dafebf5..5b43e96788e6 100644 --- a/fs/jbd/recovery.c +++ b/fs/jbd/recovery.c @@ -296,10 +296,10 @@ int journal_skip_recovery(journal_t *journal) #ifdef CONFIG_JBD_DEBUG int dropped = info.end_transaction - be32_to_cpu(journal->j_superblock->s_sequence); -#endif jbd_debug(1, "JBD: ignoring %d transaction%s from the journal.\n", dropped, (dropped == 1) ? "" : "s"); +#endif journal->j_transaction_sequence = ++info.end_transaction; } -- cgit v1.2.3 From f81e3d4564a06c5a070337ba527d11865acecb67 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Mon, 4 Oct 2010 19:12:13 +0900 Subject: jbd: Use printk_ratelimited() in journal_alloc_journal_head() Use printk_ratelimited() instead of doing it manually. Signed-off-by: Namhyung Kim Signed-off-by: Jan Kara --- fs/jbd/journal.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'fs/jbd') diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index 2c4b1f109da9..d7a86935553a 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -1719,7 +1720,6 @@ static void journal_destroy_journal_head_cache(void) static struct journal_head *journal_alloc_journal_head(void) { struct journal_head *ret; - static unsigned long last_warning; #ifdef CONFIG_JBD_DEBUG atomic_inc(&nr_journal_heads); @@ -1727,11 +1727,9 @@ static struct journal_head *journal_alloc_journal_head(void) ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS); if (ret == NULL) { jbd_debug(1, "out of memory for journal_head\n"); - if (time_after(jiffies, last_warning + 5*HZ)) { - printk(KERN_NOTICE "ENOMEM in %s, retrying.\n", - __func__); - last_warning = jiffies; - } + printk_ratelimited(KERN_NOTICE "ENOMEM in %s, retrying.\n", + __func__); + while (ret == NULL) { yield(); ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS); -- cgit v1.2.3 From 2b23976908d9f8406f8b10b86c83b2cee302bc7d Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Tue, 5 Oct 2010 00:13:59 +0900 Subject: jbd: Remove unnecessary goto statement Remove goto statement which jumps to very next line. Also remove target label because it is no longer used anywhere. Signed-off-by: Namhyung Kim Signed-off-by: Jan Kara --- fs/jbd/transaction.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'fs/jbd') diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c index 5ae71e75a491..981449ca8f18 100644 --- a/fs/jbd/transaction.c +++ b/fs/jbd/transaction.c @@ -293,9 +293,7 @@ handle_t *journal_start(journal_t *journal, int nblocks) jbd_free_handle(handle); current->journal_info = NULL; handle = ERR_PTR(err); - goto out; } -out: return handle; } -- cgit v1.2.3 From 8117f98c058dbe463eaba2b51b84d19bd5d78804 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Tue, 5 Oct 2010 01:03:40 +0900 Subject: jbd: Use offset_in_page() instead of manual calculation Signed-off-by: Namhyung Kim Signed-off-by: Jan Kara --- fs/jbd/transaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/jbd') diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c index 981449ca8f18..c9bb7a73f8fd 100644 --- a/fs/jbd/transaction.c +++ b/fs/jbd/transaction.c @@ -711,7 +711,7 @@ done: J_EXPECT_JH(jh, buffer_uptodate(jh2bh(jh)), "Possible IO failure.\n"); page = jh2bh(jh)->b_page; - offset = ((unsigned long) jh2bh(jh)->b_data) & ~PAGE_MASK; + offset = offset_in_page(jh2bh(jh)->b_data); source = kmap_atomic(page, KM_USER0); memcpy(jh->b_frozen_data, source+offset, jh2bh(jh)->b_size); kunmap_atomic(source, KM_USER0); -- cgit v1.2.3 From dff6825e9fde93891e60751e01480337a991235e Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Mon, 4 Oct 2010 12:35:05 -0700 Subject: ext3/jbd: Avoid WARN() messages when failing to write the superblock This fixes a WARN backtrace in mark_buffer_dirty() that occurs during unmount when the underlying block device is removed. This bug has been seen on System Z when removing all paths from a multipath-backed ext3 mount; on System P when injecting enough PCI EEH errors to make the SCSI controller go offline; and similar warnings have been seen (and patched) with ext2/ext4. The super block update from a previous operation has marked the buffer as in error, and the flag has to be cleared before doing the update. Similar changes have been made to ext4 by commit 914258bf2cb22bf4336a1b1d90c551b4b11ca5aa. Signed-off-by: Darrick J. Wong Signed-off-by: Jan Kara --- fs/ext3/super.c | 24 +++++++++++++++++++++++- fs/jbd/journal.c | 30 ++++++++++++++++++++++++++++-- 2 files changed, 51 insertions(+), 3 deletions(-) (limited to 'fs/jbd') diff --git a/fs/ext3/super.c b/fs/ext3/super.c index 5dbf4dba03c4..3ef272488ac9 100644 --- a/fs/ext3/super.c +++ b/fs/ext3/super.c @@ -2361,6 +2361,21 @@ static int ext3_commit_super(struct super_block *sb, if (!sbh) return error; + + if (buffer_write_io_error(sbh)) { + /* + * Oh, dear. A previous attempt to write the + * superblock failed. This could happen because the + * USB device was yanked out. Or it could happen to + * be a transient write error and maybe the block will + * be remapped. Nothing we can do but to retry the + * write and hope for the best. + */ + ext3_msg(sb, KERN_ERR, "previous I/O error to " + "superblock detected"); + clear_buffer_write_io_error(sbh); + set_buffer_uptodate(sbh); + } /* * If the file system is mounted read-only, don't update the * superblock write time. This avoids updating the superblock @@ -2377,8 +2392,15 @@ static int ext3_commit_super(struct super_block *sb, es->s_free_inodes_count = cpu_to_le32(ext3_count_free_inodes(sb)); BUFFER_TRACE(sbh, "marking dirty"); mark_buffer_dirty(sbh); - if (sync) + if (sync) { error = sync_dirty_buffer(sbh); + if (buffer_write_io_error(sbh)) { + ext3_msg(sb, KERN_ERR, "I/O error while writing " + "superblock"); + clear_buffer_write_io_error(sbh); + set_buffer_uptodate(sbh); + } + } return error; } diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index d7a86935553a..e56117651826 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c @@ -85,6 +85,7 @@ EXPORT_SYMBOL(journal_force_commit); static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *); static void __journal_abort_soft (journal_t *journal, int errno); +static const char *journal_dev_name(journal_t *journal, char *buffer); /* * Helper function used to manage commit timeouts @@ -1011,6 +1012,23 @@ void journal_update_superblock(journal_t *journal, int wait) goto out; } + if (buffer_write_io_error(bh)) { + char b[BDEVNAME_SIZE]; + /* + * Oh, dear. A previous attempt to write the journal + * superblock failed. This could happen because the + * USB device was yanked out. Or it could happen to + * be a transient write error and maybe the block will + * be remapped. Nothing we can do but to retry the + * write and hope for the best. + */ + printk(KERN_ERR "JBD: previous I/O error detected " + "for journal superblock update for %s.\n", + journal_dev_name(journal, b)); + clear_buffer_write_io_error(bh); + set_buffer_uptodate(bh); + } + spin_lock(&journal->j_state_lock); jbd_debug(1,"JBD: updating superblock (start %u, seq %d, errno %d)\n", journal->j_tail, journal->j_tail_sequence, journal->j_errno); @@ -1022,9 +1040,17 @@ void journal_update_superblock(journal_t *journal, int wait) BUFFER_TRACE(bh, "marking dirty"); mark_buffer_dirty(bh); - if (wait) + if (wait) { sync_dirty_buffer(bh); - else + if (buffer_write_io_error(bh)) { + char b[BDEVNAME_SIZE]; + printk(KERN_ERR "JBD: I/O error detected " + "when updating journal superblock for %s.\n", + journal_dev_name(journal, b)); + clear_buffer_write_io_error(bh); + set_buffer_uptodate(bh); + } + } else write_dirty_buffer(bh, WRITE); out: -- cgit v1.2.3 From a910eefa511f9d1118effc13fba6773163502c4f Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Fri, 8 Oct 2010 20:05:06 +0900 Subject: jbd: Convert bitops to buffer fns Convert set/clear_bit(BH_JWrite, ...) to set/clear_buffer_jwrite() for consistency. Signed-off-by: Namhyung Kim Signed-off-by: Jan Kara --- fs/jbd/commit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'fs/jbd') diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c index 95d8c11c929e..c8428323167f 100644 --- a/fs/jbd/commit.c +++ b/fs/jbd/commit.c @@ -617,7 +617,7 @@ void journal_commit_transaction(journal_t *journal) (this will requeue both the metadata buffer and the temporary IO buffer). new_bh goes on BJ_IO*/ - set_bit(BH_JWrite, &jh2bh(jh)->b_state); + set_buffer_jwrite(jh2bh(jh)); /* * akpm: journal_write_metadata_buffer() sets * new_bh->b_transaction to commit_transaction. @@ -627,7 +627,7 @@ void journal_commit_transaction(journal_t *journal) JBUFFER_TRACE(jh, "ph3: write metadata"); flags = journal_write_metadata_buffer(commit_transaction, jh, &new_jh, blocknr); - set_bit(BH_JWrite, &jh2bh(new_jh)->b_state); + set_buffer_jwrite(jh2bh(new_jh)); wbuf[bufs++] = jh2bh(new_jh); /* Record the new block's tag in the current descriptor @@ -737,7 +737,7 @@ wait_for_iobuf: shadowed buffer */ jh = commit_transaction->t_shadow_list->b_tprev; bh = jh2bh(jh); - clear_bit(BH_JWrite, &bh->b_state); + clear_buffer_jwrite(bh); J_ASSERT_BH(bh, buffer_jbddirty(bh)); /* The metadata is now released for reuse, but we need -- cgit v1.2.3 From 2a0e33889b3f5e3c270dd1b746f4c0a75efa4790 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Wed, 13 Oct 2010 17:17:18 +0900 Subject: jbd: Check return value of __getblk() Fail journal creation if __getblk() returns NULL. unlikely() is added because it is called in a loop and we've been OK without the check until now. Signed-off-by: Namhyung Kim Signed-off-by: Jan Kara --- fs/jbd/journal.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'fs/jbd') diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index e56117651826..ac1840415a65 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c @@ -952,6 +952,8 @@ int journal_create(journal_t *journal) if (err) return err; bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize); + if (unlikely(!bh)) + return -ENOMEM; lock_buffer(bh); memset (bh->b_data, 0, journal->j_blocksize); BUFFER_TRACE(bh, "marking dirty"); -- cgit v1.2.3 From b8ea49fa9baff99523aa51e680e76e8ccb5f25f3 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Wed, 13 Oct 2010 23:14:07 +0900 Subject: jbd: Fix debug message in do_get_write_access() 'buffer_head' should be 'journal_head'. Signed-off-by: Namhyung Kim Signed-off-by: Jan Kara --- fs/jbd/transaction.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/jbd') diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c index c9bb7a73f8fd..846a3f314111 100644 --- a/fs/jbd/transaction.c +++ b/fs/jbd/transaction.c @@ -526,7 +526,7 @@ do_get_write_access(handle_t *handle, struct journal_head *jh, transaction = handle->h_transaction; journal = transaction->t_journal; - jbd_debug(5, "buffer_head %p, force_copy %d\n", jh, force_copy); + jbd_debug(5, "journal_head %p, force_copy %d\n", jh, force_copy); JBUFFER_TRACE(jh, "entry"); repeat: -- cgit v1.2.3 From e4d5e3a497e159be7c2dbe4c61cfb185d60cfde2 Mon Sep 17 00:00:00 2001 From: Namhyung Kim Date: Sat, 16 Oct 2010 17:11:02 +0900 Subject: jbd: Convert atomic_inc() to get_bh() Convert atomic_inc(&bh->b_count) to get_bh(bh) for consistency. Signed-off-by: Namhyung Kim Signed-off-by: Jan Kara --- fs/jbd/checkpoint.c | 4 ++-- fs/jbd/commit.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'fs/jbd') diff --git a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c index 05a38b9c4c0e..e4b87bc1fa56 100644 --- a/fs/jbd/checkpoint.c +++ b/fs/jbd/checkpoint.c @@ -221,7 +221,7 @@ restart: goto restart; } if (buffer_locked(bh)) { - atomic_inc(&bh->b_count); + get_bh(bh); spin_unlock(&journal->j_list_lock); jbd_unlock_bh_state(bh); wait_on_buffer(bh); @@ -283,7 +283,7 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh, int ret = 0; if (buffer_locked(bh)) { - atomic_inc(&bh->b_count); + get_bh(bh); spin_unlock(&journal->j_list_lock); jbd_unlock_bh_state(bh); wait_on_buffer(bh); diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c index c8428323167f..a89c4630b1ed 100644 --- a/fs/jbd/commit.c +++ b/fs/jbd/commit.c @@ -611,7 +611,7 @@ void journal_commit_transaction(journal_t *journal) /* Bump b_count to prevent truncate from stumbling over the shadowed buffer! @@@ This can go if we ever get rid of the BJ_IO/BJ_Shadow pairing of buffers. */ - atomic_inc(&jh2bh(jh)->b_count); + get_bh(jh2bh(jh)); /* Make a temporary IO buffer with which to write it out (this will requeue both the metadata buffer and the -- cgit v1.2.3 From bcf3d0bcff9c2ab5794d9a2c5f0ebc9ce63cc63f Mon Sep 17 00:00:00 2001 From: Andrea Gelmini Date: Sat, 16 Oct 2010 15:19:14 +0200 Subject: jbd/2: fixed typos "wakup" Signed-off-by: Andrea Gelmini Signed-off-by: Jan Kara --- fs/jbd/journal.c | 2 +- fs/jbd2/journal.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'fs/jbd') diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index ac1840415a65..da1b5e4ffce1 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c @@ -441,7 +441,7 @@ int __log_start_commit(journal_t *journal, tid_t target) */ if (!tid_geq(journal->j_commit_request, target)) { /* - * We want a new commit: OK, mark the request and wakup the + * We want a new commit: OK, mark the request and wakeup the * commit thread. We do _not_ do the commit ourselves. */ diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 0e8014ea6b94..2b9a342551b9 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -478,7 +478,7 @@ int __jbd2_log_start_commit(journal_t *journal, tid_t target) */ if (!tid_geq(journal->j_commit_request, target)) { /* - * We want a new commit: OK, mark the request and wakup the + * We want a new commit: OK, mark the request and wakeup the * commit thread. We do _not_ do the commit ourselves. */ -- cgit v1.2.3