{"id":758,"url":"http://patchwork.ozlabs.org/api/1.0/patches/758/?format=json","project":{"id":8,"url":"http://patchwork.ozlabs.org/api/1.0/projects/8/?format=json","name":"Linux ext4 filesystem development","link_name":"linux-ext4","list_id":"linux-ext4.vger.kernel.org","list_email":"linux-ext4@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<1221946547-9873-1-git-send-email-tytso@mit.edu>","date":"2008-09-20T21:35:47","name":"ext3/jbd: Avoid WARN() messages when failing to write to the superblock","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"d1f21ffe45094f645d55e89be7da821363f420da","submitter":{"id":350,"url":"http://patchwork.ozlabs.org/api/1.0/people/350/?format=json","name":"Theodore Tso","email":"tytso@mit.edu"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-ext4/patch/1221946547-9873-1-git-send-email-tytso@mit.edu/mbox/","series":[],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/758/checks/","tags":{},"headers":{"Return-Path":"<linux-ext4-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Received":["from vger.kernel.org (vger.kernel.org [209.132.176.167])\n\tby ozlabs.org (Postfix) with ESMTP id B8EADDDE1E\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSun, 21 Sep 2008 09:10:34 +1000 (EST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751470AbYITXKc (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tSat, 20 Sep 2008 19:10:32 -0400","(majordomo@vger.kernel.org) by vger.kernel.org id S1751519AbYITXKc\n\t(ORCPT <rfc822;linux-ext4-outgoing>);\n\tSat, 20 Sep 2008 19:10:32 -0400","from www.church-of-our-saviour.org ([69.25.196.31]:51246 \"EHLO\n\tthunker.thunk.org\" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org\n\twith ESMTP id S1751470AbYITXKa (ORCPT\n\t<rfc822; linux-ext4@vger.kernel.org>); Sat, 20 Sep 2008 19:10:30 -0400","from root (helo=closure.thunk.org)\n\tby thunker.thunk.org with local-esmtp   (Exim 4.50 #1 (Debian))\n\tid 1KhBau-0006p5-D7; Sat, 20 Sep 2008 19:10:28 -0400","from tytso by closure.thunk.org with local (Exim 4.69)\n\t(envelope-from <tytso@mit.edu>)\n\tid 1KhA7H-0002Zd-Dn; Sat, 20 Sep 2008 17:35:47 -0400"],"From":"Theodore Ts'o <tytso@mit.edu>","To":"akpm@linux-foundation.org","Cc":"Linux Kernel Developers List <linux-kernel@vger.kernel.org>,\n\tExt4 Developers List <linux-ext4@vger.kernel.org>,\n\tTheodore Ts'o <tytso@mit.edu>","Subject":"[PATCH] ext3/jbd: Avoid WARN() messages when failing to write to\n\tthe superblock","Date":"Sat, 20 Sep 2008 17:35:47 -0400","Message-Id":"<1221946547-9873-1-git-send-email-tytso@mit.edu>","X-Mailer":"git-send-email 1.5.6.1.205.ge2c7.dirty","X-SA-Exim-Connect-IP":"<locally generated>","X-SA-Exim-Mail-From":"tytso@mit.edu","X-SA-Exim-Scanned":"No (on thunker.thunk.org); SAEximRunCond expanded to false","Sender":"linux-ext4-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<linux-ext4.vger.kernel.org>","X-Mailing-List":"linux-ext4@vger.kernel.org"},"content":"This fixes some very common warnings reported by kerneloops.org\n\nSigned-off-by: \"Theodore Ts'o\" <tytso@mit.edu>\n---\n fs/ext3/super.c  |   23 ++++++++++++++++++++++-\n fs/jbd/journal.c |   29 +++++++++++++++++++++++++++--\n 2 files changed, 49 insertions(+), 3 deletions(-)","diff":"diff --git a/fs/ext3/super.c b/fs/ext3/super.c\nindex f38a5af..b3f8eb8 100644\n--- a/fs/ext3/super.c\n+++ b/fs/ext3/super.c\n@@ -2259,13 +2259,34 @@ static void ext3_commit_super (struct super_block * sb,\n \n \tif (!sbh)\n \t\treturn;\n+\tif (buffer_write_io_error(sbh)) {\n+\t\t/*\n+\t\t * Oh, dear.  A previous attempt to write the\n+\t\t * superblock failed.  This could happen because the\n+\t\t * USB device was yanked out.  Or it could happen to\n+\t\t * be a transient write error and maybe the block will\n+\t\t * be remapped.  Nothing we can do but to retry the\n+\t\t * write and hope for the best.\n+\t\t */\n+\t\tprintk(KERN_ERR \"ext3: previous I/O error to \"\n+\t\t       \"superblock detected for %s.\\n\", sb->s_id);\n+\t\tclear_buffer_write_io_error(sbh);\n+\t\tset_buffer_uptodate(sbh);\n+\t}\n \tes->s_wtime = cpu_to_le32(get_seconds());\n \tes->s_free_blocks_count = cpu_to_le32(ext3_count_free_blocks(sb));\n \tes->s_free_inodes_count = cpu_to_le32(ext3_count_free_inodes(sb));\n \tBUFFER_TRACE(sbh, \"marking dirty\");\n \tmark_buffer_dirty(sbh);\n-\tif (sync)\n+\tif (sync) {\n \t\tsync_dirty_buffer(sbh);\n+\t\tif (buffer_write_io_error(sbh)) {\n+\t\t\tprintk(KERN_ERR \"ext3: I/O error while writing \"\n+\t\t\t       \"superblock for %s.\\n\", sb->s_id);\n+\t\t\tclear_buffer_write_io_error(sbh);\n+\t\t\tset_buffer_uptodate(sbh);\n+\t\t}\n+\t}\n }\n \n \ndiff --git a/fs/jbd/journal.c b/fs/jbd/journal.c\nindex aa7143a..8214175 100644\n--- a/fs/jbd/journal.c\n+++ b/fs/jbd/journal.c\n@@ -83,6 +83,7 @@ EXPORT_SYMBOL(journal_force_commit);\n \n static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *);\n static void __journal_abort_soft (journal_t *journal, int errno);\n+static const char *journal_dev_name(journal_t *journal, char *buffer);\n \n /*\n  * Helper function used to manage commit timeouts\n@@ -931,6 +932,7 @@ void journal_update_superblock(journal_t *journal, int wait)\n {\n \tjournal_superblock_t *sb = journal->j_superblock;\n \tstruct buffer_head *bh = journal->j_sb_buffer;\n+\tchar b[BDEVNAME_SIZE];\n \n \t/*\n \t * As a special case, if the on-disk copy is already marked as needing\n@@ -948,6 +950,22 @@ void journal_update_superblock(journal_t *journal, int wait)\n \t\tgoto out;\n \t}\n \n+\tif (buffer_write_io_error(bh)) {\n+\t\t/*\n+\t\t * Oh, dear.  A previous attempt to write the journal\n+\t\t * superblock failed.  This could happen because the\n+\t\t * USB device was yanked out.  Or it could happen to\n+\t\t * be a transient write error and maybe the block will\n+\t\t * be remapped.  Nothing we can do but to retry the\n+\t\t * write and hope for the best.\n+\t\t */\n+\t\tprintk(KERN_ERR \"JBD: previous I/O error detected \"\n+\t\t       \"for journal superblock update for %s.\\n\",\n+\t\t       journal_dev_name(journal, b));\n+\t\tclear_buffer_write_io_error(bh);\n+\t\tset_buffer_uptodate(bh);\n+\t}\n+\n \tspin_lock(&journal->j_state_lock);\n \tjbd_debug(1,\"JBD: updating superblock (start %ld, seq %d, errno %d)\\n\",\n \t\t  journal->j_tail, journal->j_tail_sequence, journal->j_errno);\n@@ -959,9 +977,16 @@ void journal_update_superblock(journal_t *journal, int wait)\n \n \tBUFFER_TRACE(bh, \"marking dirty\");\n \tmark_buffer_dirty(bh);\n-\tif (wait)\n+\tif (wait) {\n \t\tsync_dirty_buffer(bh);\n-\telse\n+\t\tif (buffer_write_io_error(bh)) {\n+\t\t\tprintk(KERN_ERR \"JBD: I/O error detected \"\n+\t\t\t       \"when updating journal superblock for %s.\\n\",\n+\t\t\t       journal_dev_name(journal, b));\n+\t\t\tclear_buffer_write_io_error(bh);\n+\t\t\tset_buffer_uptodate(bh);\n+\t\t}\n+\t} else\n \t\tll_rw_block(SWRITE, 1, &bh);\n \n out:\n","prefixes":[]}