From: Neil Brown <neilb@suse.de>
To: Mario 'BitKoenig' Holbe <Mario.Holbe@TU-Ilmenau.DE>
Cc: linux-raid@vger.kernel.org
Subject: Re: Incorrect in-kernel bitmap on raid10
Date: Fri, 1 May 2009 12:11:43 +1000 [thread overview]
Message-ID: <18938.23135.726382.733302@notabene.brown> (raw)
In-Reply-To: message from Mario 'BitKoenig' Holbe on Tuesday April 28
On Tuesday April 28, Mario.Holbe@TU-Ilmenau.DE wrote:
> Mario 'BitKoenig' Holbe <Mario.Holbe@TU-Ilmenau.DE> wrote:
> > Neil Brown <neilb@suse.de> wrote:
> >> Could you let me know if that following patch helps?
> > Hmmm, it looks like the patch doesn't fully fix it.
> > root@darkside:~# echo 0-268275 > /sys/block/md7/md/bitmap_set_bits
> > However, in-kernel it should also allocate all pages, but it does not:
>
> *push*
Thanks for persisting.
>
> I forgot to clarify the (new) issue:
> While now the amount of pages needed in-kernel is calculated correctly,
> only the half of them seems to be actually used, even if all bits are
> set.
>
This is not necessarily a bug. If the attempt to allocate a page
fails, we can persevere but using fewer counters with much larger
granularity. So we might not alway allocate all the pages that are
required.
However I don't think that is the case here. There some other places
where are are overflowing on a shift. One of those (in
bitmap_dirty_bits) can cause the problem you see.
This patch should fix it. Please confirm.
NeilBrown
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 1fb91ed..fcbf439 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1016,8 +1016,11 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
kunmap_atomic(paddr, KM_USER0);
if (b) {
/* if the disk bit is set, set the memory bit */
- bitmap_set_memory_bits(bitmap, i << CHUNK_BLOCK_SHIFT(bitmap),
- ((i+1) << (CHUNK_BLOCK_SHIFT(bitmap)) >= start)
+ int needed = ((sector_t)(i+1) << (CHUNK_BLOCK_SHIFT(bitmap))
+ >= start);
+ bitmap_set_memory_bits(bitmap,
+ (sector_t)i << CHUNK_BLOCK_SHIFT(bitmap),
+ needed);
);
bit_cnt++;
set_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
@@ -1154,8 +1157,9 @@ void bitmap_daemon_work(struct bitmap *bitmap)
spin_lock_irqsave(&bitmap->lock, flags);
clear_page_attr(bitmap, page, BITMAP_PAGE_CLEAN);
}
- bmc = bitmap_get_counter(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap),
- &blocks, 0);
+ bmc = bitmap_get_counter(bitmap,
+ (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap),
+ &blocks, 0);
if (bmc) {
/*
if (j < 100) printk("bitmap: j=%lu, *bmc = 0x%x\n", j, *bmc);
@@ -1169,7 +1173,8 @@ void bitmap_daemon_work(struct bitmap *bitmap)
} else if (*bmc == 1) {
/* we can clear the bit */
*bmc = 0;
- bitmap_count_page(bitmap, j << CHUNK_BLOCK_SHIFT(bitmap),
+ bitmap_count_page(bitmap,
+ (sector_t)j << CHUNK_BLOCK_SHIFT(bitmap),
-1);
/* clear the bit */
@@ -1514,7 +1519,7 @@ void bitmap_dirty_bits(struct bitmap *bitmap, unsigned long s, unsigned long e)
unsigned long chunk;
for (chunk = s; chunk <= e; chunk++) {
- sector_t sec = chunk << CHUNK_BLOCK_SHIFT(bitmap);
+ sector_t sec = (sector_t)chunk << CHUNK_BLOCK_SHIFT(bitmap);
bitmap_set_memory_bits(bitmap, sec, 1);
bitmap_file_set_bit(bitmap, sec);
}
next prev parent reply other threads:[~2009-05-01 2:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-18 18:15 Incorrect in-kernel bitmap on raid10 Mario 'BitKoenig' Holbe
2009-04-19 6:24 ` Neil Brown
2009-04-19 22:55 ` Mario 'BitKoenig' Holbe
2009-04-19 23:27 ` Neil Brown
2009-04-20 0:13 ` Race condition in write_sb_page? (was: Re: Incorrect in-kernel bitmap on raid10) Mario 'BitKoenig' Holbe
2009-04-20 1:57 ` NeilBrown
2009-04-20 8:03 ` Race condition in write_sb_page? Mario 'BitKoenig' Holbe
2009-04-22 18:45 ` Incorrect in-kernel bitmap on raid10 Mario 'BitKoenig' Holbe
2009-04-28 14:05 ` Mario 'BitKoenig' Holbe
2009-05-01 2:11 ` Neil Brown [this message]
2009-05-01 17:55 ` Mario 'BitKoenig' Holbe
2009-05-01 21:36 ` NeilBrown
2009-05-02 19:52 ` Mario 'BitKoenig' Holbe
2009-05-02 22:41 ` NeilBrown
2009-05-03 13:22 ` Mario 'BitKoenig' Holbe
2009-05-07 20:25 ` Mario 'BitKoenig' Holbe
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=18938.23135.726382.733302@notabene.brown \
--to=neilb@suse.de \
--cc=Mario.Holbe@TU-Ilmenau.DE \
--cc=linux-raid@vger.kernel.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.