* [PATCH v2] md/bitmap: clear BITMAP_WRITE_ERROR bit before writing it to sb
@ 2017-11-06 2:11 Hou Tao
2017-11-13 2:18 ` Hou Tao
0 siblings, 1 reply; 3+ messages in thread
From: Hou Tao @ 2017-11-06 2:11 UTC (permalink / raw)
To: linux-raid; +Cc: shli, neilb
For a RAID1 device using a file-based bitmap, if a bitmap write error
occurs but the later writes succeed, it's possible both BITMAP_STALE
and BITMAP_WRITE_ERROR bits will be written to the bitmap super block,
the BITMAP_STALE bit will be handled properly and be cleared, but the
BITMAP_WRITE_ERROR bit in sb->flags will make bitmap_create() to fail.
So clear it to protect against the write failure-and-then-recovery case.
Signed-off-by: Hou Tao <houtao1@huawei.com>
---
v2:
* clear the BITMAP_WRITE_ERROR bit before writing sb, not after
reading sb
v1:
* http://www.spinics.net/lists/raid/msg59590.html
---
drivers/md/bitmap.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index d212163..30e503d 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -459,7 +459,11 @@ void bitmap_update_sb(struct bitmap *bitmap)
/* rocking back to read-only */
bitmap->events_cleared = bitmap->mddev->events;
sb->events_cleared = cpu_to_le64(bitmap->events_cleared);
- sb->state = cpu_to_le32(bitmap->flags);
+ /*
+ * clear BITMAP_WRITE_ERROR bit to protect against the case that
+ * a bitmap write error occurred but the later writes succeeded.
+ */
+ sb->state = cpu_to_le32(bitmap->flags & ~BIT(BITMAP_WRITE_ERROR));
/* Just in case these have been changed via sysfs: */
sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ);
sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind);
--
2.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] md/bitmap: clear BITMAP_WRITE_ERROR bit before writing it to sb
2017-11-06 2:11 [PATCH v2] md/bitmap: clear BITMAP_WRITE_ERROR bit before writing it to sb Hou Tao
@ 2017-11-13 2:18 ` Hou Tao
2017-11-13 3:57 ` Shaohua Li
0 siblings, 1 reply; 3+ messages in thread
From: Hou Tao @ 2017-11-13 2:18 UTC (permalink / raw)
To: linux-raid; +Cc: shli, neilb
Hi,
Any comments ?
On 2017/11/6 10:11, Hou Tao wrote:
> For a RAID1 device using a file-based bitmap, if a bitmap write error
> occurs but the later writes succeed, it's possible both BITMAP_STALE
> and BITMAP_WRITE_ERROR bits will be written to the bitmap super block,
> the BITMAP_STALE bit will be handled properly and be cleared, but the
> BITMAP_WRITE_ERROR bit in sb->flags will make bitmap_create() to fail.
>
> So clear it to protect against the write failure-and-then-recovery case.
>
> Signed-off-by: Hou Tao <houtao1@huawei.com>
>
> ---
> v2:
> * clear the BITMAP_WRITE_ERROR bit before writing sb, not after
> reading sb
> v1:
> * http://www.spinics.net/lists/raid/msg59590.html
> ---
> drivers/md/bitmap.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
> index d212163..30e503d 100644
> --- a/drivers/md/bitmap.c
> +++ b/drivers/md/bitmap.c
> @@ -459,7 +459,11 @@ void bitmap_update_sb(struct bitmap *bitmap)
> /* rocking back to read-only */
> bitmap->events_cleared = bitmap->mddev->events;
> sb->events_cleared = cpu_to_le64(bitmap->events_cleared);
> - sb->state = cpu_to_le32(bitmap->flags);
> + /*
> + * clear BITMAP_WRITE_ERROR bit to protect against the case that
> + * a bitmap write error occurred but the later writes succeeded.
> + */
> + sb->state = cpu_to_le32(bitmap->flags & ~BIT(BITMAP_WRITE_ERROR));
> /* Just in case these have been changed via sysfs: */
> sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ);
> sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] md/bitmap: clear BITMAP_WRITE_ERROR bit before writing it to sb
2017-11-13 2:18 ` Hou Tao
@ 2017-11-13 3:57 ` Shaohua Li
0 siblings, 0 replies; 3+ messages in thread
From: Shaohua Li @ 2017-11-13 3:57 UTC (permalink / raw)
To: Hou Tao; +Cc: linux-raid, neilb
On Mon, Nov 13, 2017 at 10:18:14AM +0800, Hou Tao wrote:
> Hi,
>
> Any comments ?
already queued.
> On 2017/11/6 10:11, Hou Tao wrote:
> > For a RAID1 device using a file-based bitmap, if a bitmap write error
> > occurs but the later writes succeed, it's possible both BITMAP_STALE
> > and BITMAP_WRITE_ERROR bits will be written to the bitmap super block,
> > the BITMAP_STALE bit will be handled properly and be cleared, but the
> > BITMAP_WRITE_ERROR bit in sb->flags will make bitmap_create() to fail.
> >
> > So clear it to protect against the write failure-and-then-recovery case.
> >
> > Signed-off-by: Hou Tao <houtao1@huawei.com>
> >
> > ---
> > v2:
> > * clear the BITMAP_WRITE_ERROR bit before writing sb, not after
> > reading sb
> > v1:
> > * http://www.spinics.net/lists/raid/msg59590.html
> > ---
> > drivers/md/bitmap.c | 6 +++++-
> > 1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
> > index d212163..30e503d 100644
> > --- a/drivers/md/bitmap.c
> > +++ b/drivers/md/bitmap.c
> > @@ -459,7 +459,11 @@ void bitmap_update_sb(struct bitmap *bitmap)
> > /* rocking back to read-only */
> > bitmap->events_cleared = bitmap->mddev->events;
> > sb->events_cleared = cpu_to_le64(bitmap->events_cleared);
> > - sb->state = cpu_to_le32(bitmap->flags);
> > + /*
> > + * clear BITMAP_WRITE_ERROR bit to protect against the case that
> > + * a bitmap write error occurred but the later writes succeeded.
> > + */
> > + sb->state = cpu_to_le32(bitmap->flags & ~BIT(BITMAP_WRITE_ERROR));
> > /* Just in case these have been changed via sysfs: */
> > sb->daemon_sleep = cpu_to_le32(bitmap->mddev->bitmap_info.daemon_sleep/HZ);
> > sb->write_behind = cpu_to_le32(bitmap->mddev->bitmap_info.max_write_behind);
> >
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-raid" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-13 3:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-06 2:11 [PATCH v2] md/bitmap: clear BITMAP_WRITE_ERROR bit before writing it to sb Hou Tao
2017-11-13 2:18 ` Hou Tao
2017-11-13 3:57 ` Shaohua Li
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).