From: Shaohua Li <shli@kernel.org>
To: Hou Tao <houtao1@huawei.com>
Cc: linux-raid@vger.kernel.org, neilb@suse.com
Subject: Re: [PATCH] md/bitmap: clear BITMAP_WRITE_ERROR bit after reading it from sb
Date: Fri, 13 Oct 2017 12:21:27 -0700 [thread overview]
Message-ID: <20171013192127.5a4oznnkljfpv7ca@kernel.org> (raw)
In-Reply-To: <1507890991-27425-1-git-send-email-houtao1@huawei.com>
On Fri, Oct 13, 2017 at 06:36:31PM +0800, Hou Tao wrote:
> For a RAID1 device using a file-based bitmap, if a bitmap write error
> occurs and the later writes succeed, it's possible both BITMAP_STALE
> and BITMAP_WRITE_ERROR bit will be written to the bitmap super block,
> and the BITMAP_WRITE_ERROR bit in sb->flags will make bitmap_create()
> to fail.
Why don't clear the bit in the 'latter succeeded write'?
> So clear it to protect against the write failure-success case.
>
> Signed-off-by: Hou Tao <houtao1@huawei.com>
> ---
> drivers/md/bitmap.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
> index d212163..97c423a 100644
> --- a/drivers/md/bitmap.c
> +++ b/drivers/md/bitmap.c
> @@ -688,8 +688,13 @@ static int bitmap_read_sb(struct bitmap *bitmap)
> }
> }
>
> - /* assign fields using values from superblock */
> - bitmap->flags |= le32_to_cpu(sb->state);
> + /*
> + * assign fields using values from superblock
> + * clear BITMAP_WRITE_ERROR bit to protect against the case that
> + * a bitmap write error had occurred and the later writes had
> + * succeeded.
> + */
> + bitmap->flags |= (le32_to_cpu(sb->state) & ~BIT(BITMAP_WRITE_ERROR));
> if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN)
> set_bit(BITMAP_HOSTENDIAN, &bitmap->flags);
> bitmap->events_cleared = le64_to_cpu(sb->events_cleared);
> --
> 2.5.0
>
next prev parent reply other threads:[~2017-10-13 19:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-13 10:36 [PATCH] md/bitmap: clear BITMAP_WRITE_ERROR bit after reading it from sb Hou Tao
2017-10-13 19:21 ` Shaohua Li [this message]
2017-10-16 3:22 ` Hou Tao
2017-10-30 6:13 ` Hou Tao
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=20171013192127.5a4oznnkljfpv7ca@kernel.org \
--to=shli@kernel.org \
--cc=houtao1@huawei.com \
--cc=linux-raid@vger.kernel.org \
--cc=neilb@suse.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).