md bug fixes and minor improvements
Hi Linus,
please pull the following bugfixes for drivers/md.
Thanks,
NeilBrown
The following changes since commit 6e86841d05f371b5b9b86ce76c02aaee83352298:
Linus Torvalds (1):
Linux 2.6.27-rc1
are available in the git repository at:
git://neil.brown.name/md/ for-linus
Arthur Jones (1):
md: raid10: wake up frozen array
Dan Williams (5):
md: move async_tx_issue_pending_all outside spin_lock_irq
md: fix merge error
md: delay notification of 'active_idle' to the recovery thread
md: do not progress the resync process if the stripe was blocked
md: do not count blocked devices as spares
drivers/md/md.c | 8 ++++++-- drivers/md/raid10.c | 3 +++ drivers/md/raid5.c | 29 ++++++++++++++++++----------- include/linux/raid/md_k.h | 1 + 4 files changed, 28 insertions(+), 13 deletions(-)
Quoted 3 lines · Neil Brown
Hi Linus,
please pull the following bugfixes fordrivers/md.
Hmm. This doesn't seem to include any fix for the reported unlocked blk_plug() from MD?
See the emails from Rafael on the kernel mailing list for details (WARNING: at /home/rafael/src/linux-next/include/linux/blkdev.h:447), but it boils down to
WARNING: at /home/rafael/src/linux-2.6/include/linux/blkdev.h:447 blk_plug_device+0x9b/0xb0() Pid: 2268, comm: kjournald Not tainted 2.6.27-rc1-git #211 Call Trace: [<ffffffff8023af5f>] warn_on_slowpath+0x5f/0x80 [<ffffffff8034fc7b>] blk_plug_device+0x9b/0xb0 [<ffffffff8044d5bf>] bitmap_startwrite+0xbf/0x1b0
where it really looks like "bitmap_startwrite()" just calls blk_plug_device() without holding the queue lock. The rule for that function is documented to be:
* This is called with interrupts off and no requests on the queue and
* with the queue lock held.
Hmm?
Now, admittedly, the blk interfaces here are a bit inconsistent: I think blk_unplug() is supposed to be called _without_ the lock, so it's a bit odd that blk_plug_device() is supposed to b called with it held, but somebody should double-check me on that one.
I guess Jens is gone too..
Linus
Quoted 29 lines · Linus Torvalds
Quoted 3 lines · Neil Brown
Hi Linus,
please pull the following bugfixes fordrivers/md.Hmm. This doesn't seem to include any fix for the reported unlocked
blk_plug()from MD?See the emails from Rafael on the kernel mailing list for details (WARNING: at
/home/rafael/src/linux-next/include/linux/blkdev.h:447), but it boils down toWARNING: at /home/rafael/src/linux-2.6/include/linux/blkdev.h:447 blk_plug_device+0x9b/0xb0() Pid: 2268, comm: kjournald Not tainted 2.6.27-rc1-git #211 Call Trace: [<ffffffff8023af5f>] warn_on_slowpath+0x5f/0x80 [<ffffffff8034fc7b>] blk_plug_device+0x9b/0xb0 [<ffffffff8044d5bf>] bitmap_startwrite+0xbf/0x1b0where it really looks like "
bitmap_startwrite()" just callsblk_plug_device()without holding the queue lock. The rule for that function is documented to be:* This is called with interrupts off and no requests on the queue and
* with the queue lock held.
Quoted 6 lines
Hmm?
Now, admittedly, the blk interfaces here are a bit inconsistent: I think
blk_unplug()is supposed to be called _without_ the lock, so it's a bit odd thatblk_plug_device()is supposed to b called with it held, but somebody should double-check me on that one.
It is a bit asymmetrical, largely due to the fact that the ->unplug_fn() itself grabs the lock. The below patch should fix it, since Neil has added a proper queue lock to the md queues. If someone can confirm that this fixes it, I'll queue up a patch with proper descriptions.
Quoted 1 line
I guess Jens is gone too..
I'm back, just been busy this week :-)
drivers/md/bitmap.c +2 -0
@@ -1234,7 +1234,9 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectcase 0 :bitmap_file_set_bit (bitmap, offset);bitmap_count_page (bitmap,offset,1 ); +spin_lock_irq (&bitmap->mddev->queue->queue_lock);blk_plug_device (bitmap->mddev->queue); +spin_unlock_irq (&bitmap->mddev->queue->queue_lock);/* fall through */ case 1 : *bmc =2 ;
Signature · 1 line
Jens Axboe
Quoted 15 lines · Jens Axboe
It is a bit asymmetrical, largely due to the fact that the ->unplug_fn() itself grabs the lock. The below patch should fix it, since Neil has added a proper queue lock to the md queues. If someone can confirm that this fixes it, I'll queue up a patch with proper descriptions.
Quoted 1 line
I guess Jens is gone too..
I'm back, just been busy this week :-)
drivers/md/bitmap.c +0
-0
drivers/md/bitmap.c int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect · line 1242
Quoted 9 lines
drivers/md/bitmap.c +2
-0@@ -1234,7 +1234,9 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectcase 0 :bitmap_file_set_bit (bitmap, offset);bitmap_count_page (bitmap,offset,1 ); +spin_lock_irq (&bitmap->mddev->queue->queue_lock);blk_plug_device (bitmap->mddev->queue); +spin_unlock_irq (&bitmap->mddev->queue->queue_lock);/* fall through */ case 1 : *bmc =2 ;
We also need to protect the blk_plug_device call a few lines down (and an obvious compile fix).
drivers/md/bitmap.c +4 -0
@@ -1224,7 +1224,9 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectprepare_to_wait (&bitmap->overflow_wait, &__wait,TASK_UNINTERRUPTIBLE );spin_unlock_irq (&bitmap->lock); +spin_lock_irq (bitmap->mddev->queue->queue_lock);blk_unplug (bitmap->mddev->queue); +spin_unlock_irq (bitmap->mddev->queue->queue_lock);schedule ();finish_wait (&bitmap->overflow_wait, &__wait);continue ;
@@ -1234,7 +1236,9 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectcase 0 :bitmap_file_set_bit (bitmap, offset);bitmap_count_page (bitmap,offset,1 ); +spin_lock_irq (bitmap->mddev->queue->queue_lock);blk_plug_device (bitmap->mddev->queue); +spin_unlock_irq (bitmap->mddev->queue->queue_lock);/* fall through */ case 1 : *bmc =2 ;
Quoted 21 lines · Dan Williams
Quoted 19 lines · Jens Axboe
It is a bit asymmetrical, largely due to the fact that the ->unplug_fn() itself grabs the lock. The below patch should fix it, since Neil has added a proper queue lock to the md queues. If someone can confirm that this fixes it, I'll queue up a patch with proper descriptions.
Quoted 1 line
I guess Jens is gone too..
I'm back, just been busy this week :-)
drivers/md/bitmap.c +1
-0@@ -1234,7 +1234,9 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectcase 0 :bitmap_file_set_bit (bitmap, offset);bitmap_count_page (bitmap,offset,1 ); +spin_lock_irq (&bitmap->mddev->queue->queue_lock);blk_plug_device (bitmap->mddev->queue);
Quoted 8 lines
drivers/md/bitmap.c int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect · line 1244
Quoted 5 lines
drivers/md/bitmap.c +1
-0+spin_unlock_irq (&bitmap->mddev->queue->queue_lock);/* fall through */ case 1 : *bmc =2 ;We also need to protect the
blk_plug_devicecall a few lines down (and an obvious compile fix).
Old source I guess, just one blk_plug_device() in the copy I have here. Just checked latest git, still just one blk_plug_device(), are you diffing against -mm or something like that? Or linux-next?
And queue_lock is of course a pointer, I didn't even compile the thing... Thanks for the updated variant!
Signature · 1 line
Jens Axboe
drivers/md/bitmap.c int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect · line 1239
Quoted 3 lines · Jens Axboe
drivers/md/bitmap.c +2
-0+spin_lock_irq (&bitmap->mddev->queue->queue_lock);blk_plug_device (bitmap->mddev->queue); +spin_unlock_irq (&bitmap->mddev->queue->queue_lock);
Can we please not have a chain of three dereferences in a row like that? That's an almost certain sign that we should either have a helper function or just a variable, and do it as
queue = bitmap->mddev->queue; spin_lock_irq(&queue->queue_lock); blk_plug_device(queue); spin_unlock_irq(&queue->queue_lock);
Hmm? Perhaps the helper function is cleaner, ie
static inline blk_plug_device_unlocked(struct request_queue * queue)
{..instead. That, of course, would have to use spin_lock_irqsave().
Linus
Quoted 31 lines · Jens Axboe
Quoted 21 lines · Dan Williams
Quoted 19 lines · Jens Axboe
It is a bit asymmetrical, largely due to the fact that the ->unplug_fn() itself grabs the lock. The below patch should fix it, since Neil has added a proper queue lock to the md queues. If someone can confirm that this fixes it, I'll queue up a patch with proper descriptions.
Quoted 1 line
I guess Jens is gone too..
I'm back, just been busy this week :-)
drivers/md/bitmap.c +1
-0@@ -1234,7 +1234,9 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectcase 0 :bitmap_file_set_bit (bitmap, offset);bitmap_count_page (bitmap,offset,1 ); +spin_lock_irq (&bitmap->mddev->queue->queue_lock);blk_plug_device (bitmap->mddev->queue);Quoted 8 lines
drivers/md/bitmap.c int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect · line 1244
Quoted 5 lines
drivers/md/bitmap.c +1
-0+spin_unlock_irq (&bitmap->mddev->queue->queue_lock);/* fall through */ case 1 : *bmc =2 ;We also need to protect the
blk_plug_devicecall a few lines down (and an obvious compile fix).
Quoted 3 lines
Old source I guess, just one
blk_plug_device()in the copy I have here. Just checked latest git, still just oneblk_plug_device(), are you diffing against -mm or something like that? Or linux-next?
No, my mistake... I crossed my eyes and misread your patch as protecting blk_unplug() a few lines up, sorry.
Quoted 3 lines
And
queue_lockis of course a pointer, I didn't even compile the thing... Thanks for the updated variant!
I have verified that:
mdadm --create /dev/md0 /dev/sd[bc] -n 2 -l 1 --bitmap=internal dd if=/dev/zero of=/dev/md0 bs=1024k count=1
...no longer triggers the warning with your fix.
Regards,
Dan
Quoted 17 lines · Linus Torvalds
drivers/md/bitmap.c int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect · line 1239
Quoted 3 lines · Jens Axboe
drivers/md/bitmap.c +2
-0+spin_lock_irq (&bitmap->mddev->queue->queue_lock);blk_plug_device (bitmap->mddev->queue); +spin_unlock_irq (&bitmap->mddev->queue->queue_lock);Can we please not have a chain of three dereferences in a row like that? That's an almost certain sign that we should either have a helper function or just a variable, and do it as
queue = bitmap->mddev->queue; spin_lock_irq(&queue->queue_lock); blk_plug_device(queue); spin_unlock_irq(&queue->queue_lock);
Quoted 6 lines
Hmm? Perhaps the helper function is cleaner, ie
static inline blk_plug_device_unlocked(struct request_queue * queue) {..instead. That, of course, would have to use
spin_lock_irqsave().
I rather like that. I've got a few simpler things to push, I'll queue it up with that and send you a pull request later today.
Signature · 1 line
Jens Axboe
Quoted 33 lines · Dan Williams
Quoted 31 lines · Jens Axboe
Quoted 29 lines · Dan Williams
Quoted 15 lines · Jens Axboe
It is a bit asymmetrical, largely due to the fact that the ->unplug_fn() itself grabs the lock. The below patch should fix it, since Neil has added a proper queue lock to the md queues. If someone can confirm that this fixes it, I'll queue up a patch with proper descriptions.
Quoted 1 line
I guess Jens is gone too..
I'm back, just been busy this week :-)
drivers/md/bitmap.c +0
-0drivers/md/bitmap.c int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sect · line 1242
Quoted 9 lines
drivers/md/bitmap.c +2
-0@@ -1234,7 +1234,9 @@ int bitmap_startwrite(struct bitmap *bitmap, sector_t offset, unsigned long sectcase 0 :bitmap_file_set_bit (bitmap, offset);bitmap_count_page (bitmap,offset,1 ); +spin_lock_irq (&bitmap->mddev->queue->queue_lock);blk_plug_device (bitmap->mddev->queue); +spin_unlock_irq (&bitmap->mddev->queue->queue_lock);/* fall through */ case 1 : *bmc =2 ;We also need to protect the
blk_plug_devicecall a few lines down (and an obvious compile fix).
Quoted 6 lines
Quoted 3 lines
Old source I guess, just one
blk_plug_device()in the copy I have here. Just checked latest git, still just oneblk_plug_device(), are you diffing against -mm or something like that? Or linux-next?No, my mistake... I crossed my eyes and misread your patch as protecting
blk_unplug()a few lines up, sorry.
Ah, didn't read that closely in your patch, that would get you into trouble :-)
Quoted 9 lines
Quoted 2 lines
And
queue_lockis of course a pointer, I didn't even compile the thing... Thanks for the updated variant!I have verified that:
mdadm --create /dev/md0 /dev/sd[bc] -n 2 -l 1 --bitmap=internal dd if=/dev/zero of=/dev/md0 bs=1024k count=1...no longer triggers the warning with your fix.
Goodie, thanks!
Signature · 1 line
Jens Axboe