Skip to contentSkip to conversation

md/bitmap:If bmap() failed,free buffers must check bitmap->pending_writes == 0.

PATCH In review majianpeng 2 participants 2 messages May 18, 2012 – May 21, 2012 MD RAID

lore
Share & tools
lore

majianpeng

author
#0 lore raw

PATCH 1/1 md/bitmap:If bmap() failed,free buffers must check bitmap->pending_writes == 0.

---
 drivers/md/bitmap.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/md/bitmap.c +2 -0
index 17e2b47..74540d7 100644
@@ -376,6 +376,8 @@ static struct page *read_page(struct file *file, unsigned long index,
 			bh->b_blocknr = bmap(inode, block);
 			if (bh->b_blocknr == 0) {
 				/* Cannot use this file! */
+				wait_event(bitmap->write_wait,
+					atomic_read(&bitmap->pending_writes) == 0);
 				free_buffers(page);
 				page = ERR_PTR(-EINVAL);
 				goto out;
Signature · 6 lines
1.7.5.4

 				
--------------
majianpeng
2012-05-18
#1 lore raw
Quoted 10 lines · On Fri, 18 May 2012 19:38:34 +0800 "majianpeng" <[email protected]> wrote:
---
 drivers/md/bitmap.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/md/bitmap.c +0 -0
index 17e2b47..74540d7 100644

drivers/md/bitmap.c static struct page *read_page(struct file *file, unsigned long index, · line 383

Quoted 8 lines
drivers/md/bitmap.c +2 -0
@@ -376,6 +376,8 @@ static struct page *read_page(struct file *file, unsigned long index,
 			bh->b_blocknr = bmap(inode, block);
 			if (bh->b_blocknr == 0) {
 				/* Cannot use this file! */
+				wait_event(bitmap->write_wait,
+					atomic_read(&bitmap->pending_writes) == 0);
 				free_buffers(page);
 				page = ERR_PTR(-EINVAL);
 				goto out;

Hi,
thanks for the patch.

However it doesn't apply against the current code in linux-next. Some changes have been made which might make this fix unnecessary as the page is not freed until later.
Could you check the latest code and see if the problem still exists?

Thanks,
NeilBrown