add I/O error uevent for block devices
Subsystems (3)
PATCH 1/1 add I/O error uevent for block devices
For HAL we want to get notified about I/O errors of block devices. This is especially useful for devices we are unable to poll and therefore can't know if something goes wrong here.
===== fs/buffer.c 1.270 vs edited =====
fs/buffer.c +3 -1
@@ -105,6 +105,7 @@ static void buffer_io_error(struct buffeprintk (KERN_ERR "Buffer I/O error on device %s, logical block %Lu\n" ,bdevname (bh->b_bdev, b), (unsigned long long )bh->b_blocknr); +kobject_uevent (&bh->b_bdev->bd_disk->kobj,KOBJ_IO_ERROR ,NULL ); }/*
@@ -550,7 +551,8 @@ static void end_buffer_async_read(structset_buffer_uptodate (bh); }else {clear_buffer_uptodate (bh); -buffer_io_error (bh); +if (printk_ratelimit ()) +buffer_io_error (bh);SetPageError (page); }
===== include/linux/kobject_uevent.h 1.6 vs edited =====
include/linux/kobject_uevent.h +1 -0
@@ -29,6 +29,7 @@ enum kobject_action {KOBJ_UMOUNT = (__force kobject_action_t )0x05 ,/* umount event for block devices */ KOBJ_OFFLINE = (__force kobject_action_t )0x06 ,/* offline event for hotplug devices */ KOBJ_ONLINE = (__force kobject_action_t )0x07 ,/* online event for hotplug devices */ + KOBJ_IO_ERROR = (__force kobject_action_t) 0x08, /* I/O error for devices */ };
===== lib/kobject_uevent.c 1.18 vs edited =====
lib/kobject_uevent.c +2 -0
@@ -44,6 +44,8 @@ static char *action_to_string(enum kobjereturn "offline" ;case KOBJ_ONLINE :return "online" ; +case KOBJ_IO_ERROR : +return "io_error" ;default :return NULL ; }
Quoted 8 lines · Kay Sievers
For HAL we want to get notified about I/O errors of block devices.
This is especially useful for devices we are unable to poll and therefore can't know if something goes wrong here.Signed-off-by David Zeuthen <[email protected]>Signed-off-by Kay Sievers <[email protected]>
Quoted 9 lines
=====
fs/buffer.c1.270 vs edited =====
---1.270/fs/buffer.c2005-01-21 06:02:13 +01:00
+++edited/fs/buffer.c2005-02-17 22:56:05 +01:00
@@ -105,6 +105,7 @@ static void buffer_io_error(struct buffe
printk(KERN_ERR "Buffer I/O error on device %s, logical block %Lu\n",
bdevname(bh->b_bdev, b),
(unsigned long long)bh->b_blocknr);
+kobject_uevent(&bh->b_bdev->bd_disk->kobj, KOBJ_IO_ERROR, NULL);
}
- buffer_io_error() is called from interrupt context, and kobject_uevent() does multiple GFP_KERNEL allocations. You'll need to use kobject_uevent_atomic().
- the prink_ratelimit() fix in end_buffer_async_read() should be a separate patch, really. I'll fix that up.
- there are numerous other places where an I/O error can be detected:
grep the tree for b_end_io and bio_end_io.
Quoted 9 lines · Andrew Morton
Quoted 4 lines · Kay Sievers
For HAL we want to get notified about I/O errors of block devices.
This is especially useful for devices we are unable to poll and therefore can't know if something goes wrong here.-
buffer_io_error()is called from interrupt context, andkobject_uevent()does multipleGFP_KERNELallocations. You'll need to usekobject_uevent_atomic().
Fixed.
Quoted 2 lines
- the
prink_ratelimit()fix inend_buffer_async_read()should be a separate patch, really. I'll fix that up.
Removed that part.
Quoted 2 lines
- there are numerous other places where an I/O error can be detected:
grep the tree forb_end_ioandbio_end_io.
You mean the mmap and direct-io stuff?
Thanks,
Kay
-----
For HAL we want to get notified about I/O errors of block devices. This is especially useful for devices we are unable to poll and therefore can't know if something goes wrong here.
===== fs/buffer.c 1.270 vs edited =====
fs/buffer.c +1 -0
@@ -105,6 +105,7 @@ static void buffer_io_error(struct buffeprintk (KERN_ERR "Buffer I/O error on device %s, logical block %Lu\n" ,bdevname (bh->b_bdev, b), (unsigned long long )bh->b_blocknr); +kobject_uevent_atomic (&bh->b_bdev->bd_disk->kobj,KOBJ_IO_ERROR ,NULL ); }/*
===== include/linux/kobject_uevent.h 1.6 vs edited =====
include/linux/kobject_uevent.h +1 -0
@@ -29,6 +29,7 @@ enum kobject_action {KOBJ_UMOUNT = (__force kobject_action_t )0x05 ,/* umount event for block devices */ KOBJ_OFFLINE = (__force kobject_action_t )0x06 ,/* offline event for hotplug devices */ KOBJ_ONLINE = (__force kobject_action_t )0x07 ,/* online event for hotplug devices */ + KOBJ_IO_ERROR = (__force kobject_action_t) 0x08, /* I/O error for devices */ };
===== lib/kobject_uevent.c 1.18 vs edited =====
lib/kobject_uevent.c +2 -0
@@ -44,6 +44,8 @@ static char *action_to_string(enum kobjereturn "offline" ;case KOBJ_ONLINE :return "online" ; +case KOBJ_IO_ERROR : +return "io_error" ;default :return NULL ; }
Quoted 5 lines · Kay Sievers
Quoted 3 lines
- there are numerous other places where an I/O error can be detected:
grep the tree forb_end_ioandbio_end_io.You mean the mmap and direct-io stuff?
direct-io, certainly. Also reiserfs, xfs, ntfs, ext3, jfs and possibly md have their own I/O completion handlers.
Quoted 9 lines · Andrew Morton
Quoted 5 lines · Kay Sievers
Quoted 3 lines
- there are numerous other places where an I/O error can be detected:
grep the tree forb_end_ioandbio_end_io.You mean the mmap and direct-io stuff?
direct-io, certainly. Also reiserfs, xfs, ntfs, ext3, jfs and possibly md have their own I/O completion handlers.
Hmm, ok. Any idea how to propagate errors like this in a saner way? Some of these places don't even log errors and spreading uevents all over the place doesn't sounds like the best idea.
Thanks,
Kay
Quoted 7 lines · Kay Sievers
Quoted 5 lines · Andrew Morton
Quoted 4 lines · Kay Sievers
Quoted 3 lines
- there are numerous other places where an I/O error can be detected:
grep the tree forb_end_ioandbio_end_io.
Quoted 9 lines
Quoted 4 lines
Quoted 1 line
You mean the mmap and direct-io stuff?
direct-io, certainly. Also reiserfs, xfs, ntfs, ext3, jfs and possibly md have their own I/O completion handlers.
Hmm, ok. Any idea how to propagate errors like this in a saner way? Some of these places don't even log errors and spreading uevents all over the place doesn't sounds like the best idea.
I guess you should add some new generic function handle_block_io_error(bdev, rw, sector) in ll_rw_blk.c and do whatever you need to do inside that. Move the ratelimited printk there, too.