fix mirror device creation with lvcreate failed
Subsystems (2)
PATCH 1/1 fix mirror device creation with lvcreate failed
On some devices, when create mirror device with lvcreate, it fails.
device-mapper: reload ioctl on failed: Invalid argument Failed to activate new LV.
We can use read size 4096 since md always use 4096.
--- drivers/md/dm-raid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-raid.c +1 -1
@@ -860,7 +860,7 @@ static int super_load(struct md_rdev *rdev, struct md_rdev *refdev) rdev->sb_start =0 ; rdev->sb_size =sizeof (*sb); - ret =read_disk_sb (rdev, rdev->sb_size); + ret =read_disk_sb (rdev,4096 );if (ret)return ret;
Signature · 1 line
1.9.0
Alasdair G Kergon
maintainerQuoted 1 line · Liuhua Wang
On some devices,
Which devices? What is the necessary condition to trigger the problem?
Quoted 3 lines
when create mirror device with lvcreate, it fails.
device-mapper: reload ioctl on failed: Invalid argument Failed to activate new LV.
What exactly causes this error?
- Do you get a kernel error message too?
Quoted 1 line
We can use read size 4096 since md always use 4096.
How is that connected to problem?
Why does it fix it?
drivers/md/dm-raid.c static int super_load(struct md_rdev *rdev, struct md_rdev *refdev) · line 861
Quoted 4 lines
+++
b/drivers/md/dm-raid.cdrivers/md/dm-raid.c +0
-0@@ -860,7 +860,7 @@ static int super_load(struct md_rdev *rdev, struct md_rdev *refdev) rdev->sb_start =0 ; rdev->sb_size =sizeof (*sb);
What should sb_size really be?
drivers/md/dm-raid.c static int super_load(struct md_rdev *rdev, struct md_rdev *refdev) · line 863
Quoted 2 lines
drivers/md/dm-raid.c +1
-1- ret =read_disk_sb (rdev, rdev->sb_size); + ret =read_disk_sb (rdev,4096 );
Why aren't they both MD_SB_BYTES?
(Strictly, does sb_size need recalculating after the read?)
Alasdair
Alasdair G Kergon
maintainerQuoted 3 lines · Alasdair G Kergon
Quoted 1 line
rdev->sb_size=sizeof(*sb);What should
sb_sizereally be?drivers/md/dm-raid.c static int super_load(struct md_rdev *rdev, struct md_rdev *refdev) · line 863
Quoted 1 line
drivers/md/dm-raid.c +0
-1- ret =read_disk_sb (rdev, rdev->sb_size);
Or are the sizes in the existing code correct (the dm sb is always 512 bytes?), with the problem coming from something in sync_page_io()?
(4k sector device? large page size? incorrectly uninitialised field?)
Alasdair
Alasdair G Kergon
maintainerQuoted 1 line · Alasdair G Kergon
Quoted 1 line
drivers/md/dm-raid.c static int super_load(struct md_rdev *rdev, struct md_rdev *refdev) · line 863
Quoted 1 line
drivers/md/dm-raid.c +0
-1- ret =read_disk_sb (rdev, rdev->sb_size);
And if that needed changing to 4096, why does this similar instance elsewhere one not also need changing?
static void attempt_restore_of_faulty_devices(struct raid_set *rs)
{
...
sync_page_io(r, 0, r->sb_size, r->sb_page, READ, 1)) {Alasdair
Quoted 6 lines · On Wed, 17 Sep 2014 00:40:08 +0100 Alasdair G Kergon <[email protected]> wrote:
Quoted 1 line · Alasdair G Kergon
Quoted 1 line
Review
Quoted 1 line
(quoted diff) +0
-1- ret = read_disk_sb(rdev, rdev->sb_size);And if that needed changing to 4096, why does this similar instance elsewhere one not also need changing?
Quoted 7 lines
static void attempt_restore_of_faulty_devices(struct raid_set *rs) { ... sync_page_io(r, 0, r->sb_size, r->sb_page, READ, 1)) {Alasdair
That suggests we should probably "fix" the problem in sync_page_io().
e.g.
drivers/md/md.c +3 -0
@@ -777,6 +777,9 @@ int sync_page_io(struct md_rdev *rdev, sector_t sector, int size, bio->bi_bdev = (metadata_op && rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev; + size =roundup (size,bdev_logical_block_size (bio->bi_bdev)); +if (size >PAGE_SIZE ) +return -EINVAL ;if (metadata_op) bio->bi_iter.bi_sector = sector + rdev->sb_start; else if (rdev->mddev->reshape_position != MaxSector &&
I'll queue that up and maybe tag it for -stable.
Thanks,
NeilBrown
Hi, Alasdair
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 9/17/2014 at 07:21 AM, in message
<[email protected]>, Alasdair G Kergon
Quoted 5 lines · <[email protected]> wrote:
Quoted 1 line · Liuhua Wang
On some devices,
Which devices? What is the necessary condition to trigger the problem?
When using dasd device formated with bocksize of 4096bytes. the problem occurs, while formated with blocksie of 512bytes, no problem.
Quoted 6 lines
Quoted 3 lines
when create mirror device with lvcreate, it fails.
device-mapper: reload ioctl on failed: Invalid argument Failed to activate new LV.What exactly causes this error?
- Do you get a kernel error message too?
There are error messages:
---------------------
[22798.077877] end_request: I/O error, dev dasdd, sector 2240 [22798.077902] device-mapper: raid: Failed to read superblock of device at position 1 [23087.875420] type=1006 audit(1404313201.346:28): pid=1596 uid=0 old auid=4294967295 new auid=0 old ses=4294967295 new ses=27 res=1 [23127.707296] dasd-eckd.d2bf98: 0.0.141d: ERP 0000000036ab1e40 has run out of retries and failed
----------------------
Quoted 5 lines
Quoted 1 line
We can use read size 4096 since md always use 4096.
How is that connected to problem?
Why does it fix it?
Quoted 7 lines
Review static int super_load(struct md_rdev *rdev, struct
Quoted 2 lines
+++
b/drivers/md/dm-raid.c(quoted diff) +0
-0@@ -860,7 +860,7 @@ static int super_load(struct md_rdev *rdev, struct
md_rdev*refdev)drivers/md/dm-raid.c static int super_load(struct md_rdev *rdev, struct md_rdev *refdev) · line 861
Quoted 2 lines
drivers/md/dm-raid.c +0
-0rdev->sb_start =0 ; rdev->sb_size =sizeof (*sb);What should
sb_sizereally be?
512bytes
Quoted 9 lines
drivers/md/dm-raid.c static int super_load(struct md_rdev *rdev, struct md_rdev *refdev) · line 863
Quoted 3 lines
drivers/md/dm-raid.c +1
-1- ret =read_disk_sb (rdev, rdev->sb_size); + ret =read_disk_sb (rdev,4096 );Why aren't they both
MD_SB_BYTES?
(Strictly, doessb_sizeneed recalculating after the read?)Alasdair
Best regards,
Liuhua
Alasdair G Kergon
maintainerQuoted 7 lines · Liuhua Wang
There are error messages:
---------------------[22798.077877] end_request: I/O error, dev dasdd, sector 2240 [22798.077902] device-mapper: raid: Failed to read superblock of device at position 1 [23087.875420] type=1006 audit(1404313201.346:28): pid=1596 uid=0 old auid=4294967295 new auid=0 old ses=4294967295 new ses=27 res=1 [23127.707296] dasd-eckd.d2bf98: 0.0.141d: ERP 0000000036ab1e40 has run out of retries and failed----------------------
OK, so it sounds like Neil's patch will be enough to fix this. Can you test that and confirm it solves the problem?
Alasdair
Hi, Alasdair
Hi, Neil
Quoted 1 line
Quoted 1 line
Quoted 1 line
On 9/17/2014 at 07:41 PM, in message
<[email protected]>, Alasdair G Kergon
Quoted 6 lines · <[email protected]> wrote:
Quoted 4 lines · Liuhua Wang
There are error messages:
---------------------[22798.077877] end_request: I/O error, dev dasdd, sector 2240 [22798.077902] device-mapper: raid: Failed to read superblock of device atposition 1
Quoted 9 lines
Quoted 1 line
[23087.875420] type=1006 audit(1404313201.346:28): pid=1596 uid=0 oldauid=4294967295 new auid=0 old ses=4294967295 new ses=27 res=1
Quoted 1 line
[23127.707296] dasd-eckd.d2bf98: 0.0.141d: ERP 0000000036ab1e40 has run outof retries and failed
Quoted 1 line
----------------------
OK, so it sounds like Neil's patch will be enough to fix this. Can you test that and confirm it solves the problem?
I tested Neil's patch, lvcreate succeed, the lv created can display, be written successfully, but only there still are error messages:
--------------------------------
2014-09-18T06:39:52.653239+02:00 s390vsl158 kernel: device-mapper: raid: Superblocks created for new array 2014-09-18T06:39:52.663361+02:00 s390vsl158 kernel: md/raid1:mdX: not clean -- starting background reconstruction 2014-09-18T06:39:52.663366+02:00 s390vsl158 kernel: md/raid1:mdX: active with 2 out of 2 mirrors 2014-09-18T06:39:52.663366+02:00 s390vsl158 kernel: Choosing daemon_sleep default (5 sec) 2014-09-18T06:39:52.663367+02:00 s390vsl158 kernel: created bitmap (1 pages) for device mdX 2014-09-18T06:39:52.663368+02:00 s390vsl158 kernel: end_request: I/O error, dev dasdb, sector 19202144 2014-09-18T06:39:52.663369+02:00 s390vsl158 kernel: md: super_written gets error=-5, uptodate=0 2014-09-18T06:39:52.663369+02:00 s390vsl158 kernel: md/raid1:mdX: Disk failure on dm-3, disabling device.
-------------------------
So I add also roundup to md_super_write() as following, then the above error messages disappears.
--------------------------
drivers/md/md.c +6 -0
@@ -754,6 +754,8 @@ void md_super_write(struct mddev *mddev, struct md_rdev *rdev,struct bio *bio =bio_alloc_mddev (GFP_NOIO ,1 , mddev); bio->bi_bdev = rdev->meta_bdev ? rdev->meta_bdev : rdev->bdev; + size =roundup (size,bdev_logical_block_size (bio->bi_bdev)); + bio->bi_iter.bi_sector = sector;bio_add_page (bio, page, size,0 ); bio->bi_private = rdev;
@@ -784,6 +786,10 @@ int sync_page_io(struct md_rdev *rdev, sector_t sector, int size, bio->bi_bdev = (metadata_op && rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev; + size =roundup (size,bdev_logical_block_size (bio->bi_bdev)); +if (size >PAGE_SIZE ) +return -EINVAL ; +if (metadata_op) bio->bi_iter.bi_sector = sector + rdev->sb_start; else if (rdev->mddev->reshape_position != MaxSector &&
Signature · 8 lines
-------------------------- I also used this patch and tested with a loop device of blocksize 512, there is no problem. Best regards, Liuhua
Quoted 43 lines · On Thu, 18 Sep 2014 00:56:33 -0600 "Liuhua Wang" <[email protected]> wrote:
Hi, Alasdair
Hi, NeilQuoted 1 line
Quoted 1 line
Quoted 1 line
On 9/17/2014 at 07:41 PM, in message
<[email protected]>, Alasdair G Kergon
Quoted 6 lines · <[email protected]> wrote:
Quoted 4 lines · Liuhua Wang
There are error messages:
---------------------[22798.077877] end_request: I/O error, dev dasdd, sector 2240 [22798.077902] device-mapper: raid: Failed to read superblock of device atposition 1
Quoted 9 lines
Quoted 1 line
[23087.875420] type=1006 audit(1404313201.346:28): pid=1596 uid=0 oldauid=4294967295 new auid=0 old ses=4294967295 new ses=27 res=1
Quoted 1 line
[23127.707296] dasd-eckd.d2bf98: 0.0.141d: ERP 0000000036ab1e40 has run outof retries and failed
Quoted 1 line
----------------------
OK, so it sounds like Neil's patch will be enough to fix this. Can you test that and confirm it solves the problem?
I tested Neil's patch, lvcreate succeed, the lv created can display, be written successfully, but only there still are error messages:
--------------------------------2014-09-18T06:39:52.653239+02:00 s390vsl158 kernel: device-mapper: raid: Superblocks created for new array 2014-09-18T06:39:52.663361+02:00 s390vsl158 kernel: md/raid1:mdX: not clean -- starting background reconstruction 2014-09-18T06:39:52.663366+02:00 s390vsl158 kernel: md/raid1:mdX: active with 2 out of 2 mirrors 2014-09-18T06:39:52.663366+02:00 s390vsl158 kernel: Choosing daemon_sleep default (5 sec) 2014-09-18T06:39:52.663367+02:00 s390vsl158 kernel: created bitmap (1 pages) for device mdX 2014-09-18T06:39:52.663368+02:00 s390vsl158 kernel: end_request: I/O error, dev dasdb, sector 19202144 2014-09-18T06:39:52.663369+02:00 s390vsl158 kernel: md: super_written gets error=-5, uptodate=0 2014-09-18T06:39:52.663369+02:00 s390vsl158 kernel: md/raid1:mdX: Disk failure on dm-3, disabling device.-------------------------
So I add also roundup to
md_super_write()as following, then the above error messages disappears.
--------------------------drivers/md/md.c +0
-0
drivers/md/md.c void md_super_write(struct mddev *mddev, struct md_rdev *rdev, · line 761
Quoted 8 lines
drivers/md/md.c +2
-0@@ -754,6 +754,8 @@ void md_super_write(struct mddev *mddev, struct md_rdev *rdev,struct bio *bio =bio_alloc_mddev (GFP_NOIO ,1 , mddev); bio->bi_bdev = rdev->meta_bdev ? rdev->meta_bdev : rdev->bdev; + size =roundup (size,bdev_logical_block_size (bio->bi_bdev)); + bio->bi_iter.bi_sector = sector;bio_add_page (bio, page, size,0 ); bio->bi_private = rdev;
I'm not really comfortable with this change.
It is always safe to read more than requested. Writing more than requested is quite different.
I think I would rather that rdev->sb_size were rounded up by the code that sets it. That would make it clear to anyone reading the code that a full block was always written.
Jon: how does lvm allocate space for the dm-raid metadata? Does it always allocate some minimum? Is the allocation aware of underlying block size? Is it reasonable to round up rdev->sb_size in load_super() ??
Thanks,
NeilBrown
Quoted 11 lines
drivers/md/md.c +4
-0@@ -784,6 +786,10 @@ int sync_page_io(struct md_rdev *rdev, sector_t sector, int size, bio->bi_bdev = (metadata_op && rdev->meta_bdev) ? rdev->meta_bdev : rdev->bdev; + size =roundup (size,bdev_logical_block_size (bio->bi_bdev)); +if (size >PAGE_SIZE ) +return -EINVAL ; +if (metadata_op) bio->bi_iter.bi_sector = sector + rdev->sb_start; else if (rdev->mddev->reshape_position != MaxSector &&