All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
To: <linux-fsdevel@vger.kernel.org>
Cc: <willy@infradead.org>, <jlayton@redhat.com>
Subject: [PATCH] inode: always initialize mapping->wb_err
Date: Sat, 26 May 2018 10:42:54 +0800	[thread overview]
Message-ID: <20180526024254.21114-1-lufq.fnst@cn.fujitsu.com> (raw)

Creating a file reuses the inode object by kmem_cache_alloc without
initializing maping->wb_err. If it contains an unseen writeback error,
fsync will report an error on the file, even if no error has ever occurred
after the file was created.

Before commit b4678df184b3 ("errseq: Always report a writeback error
once"), any errors that occur before the file descriptor is opened will be
ignored, causing the issue not to be found. Afterward, any unseen writeback
error will be reported once, including, of course, the uninitialized
maping->wb_err, which exposes this problem.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
---
 fs/inode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/inode.c b/fs/inode.c
index 13ceb98c3bd3..bf02dc9d1837 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -182,6 +182,7 @@ int inode_init_always(struct super_block *sb, struct inode *inode)
 	mapping_set_gfp_mask(mapping, GFP_HIGHUSER_MOVABLE);
 	mapping->private_data = NULL;
 	mapping->writeback_index = 0;
+	mapping->wb_err = 0;
 	inode->i_private = NULL;
 	inode->i_mapping = mapping;
 	INIT_HLIST_HEAD(&inode->i_dentry);	/* buggered by rcu freeing */
-- 
2.17.0

             reply	other threads:[~2018-05-26  2:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-26  2:42 Lu Fengqi [this message]
2018-05-26 11:42 ` [PATCH] inode: always initialize mapping->wb_err Jeff Layton
2018-05-26 12:29   ` Lu Fengqi
2018-05-29 17:49     ` Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180526024254.21114-1-lufq.fnst@cn.fujitsu.com \
    --to=lufq.fnst@cn.fujitsu.com \
    --cc=jlayton@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.