dm raid: ensure superblock's size matches device's logical block size
authorHeinz Mauelshagen <heinzm@redhat.com>
Fri, 17 Oct 2014 11:38:50 +0000 (13:38 +0200)
committerZefan Li <lizefan@huawei.com>
Mon, 2 Feb 2015 09:05:17 +0000 (17:05 +0800)
commitc0f73f51c40b93af864a1c0093fb1a05f24762c3
tree8ebff1ccc09553d5fe5e07eb94d24ac130a27026
parent792a118bb47f8e34ca0794032a533df214fbb1fe
dm raid: ensure superblock's size matches device's logical block size

commit 40d43c4b4cac4c2647bf07110d7b07d35f399a84 upstream.

The dm-raid superblock (struct dm_raid_superblock) is padded to 512
bytes and that size is being used to read it in from the metadata
device into one preallocated page.

Reading or writing this on a 512-byte sector device works fine but on
a 4096-byte sector device this fails.

Set the dm-raid superblock's size to the logical block size of the
metadata device, because IO at that size is guaranteed too work.  Also
add a size check to avoid silent partial metadata loss in case the
superblock should ever grow past the logical block size or PAGE_SIZE.

[includes pointer math fix from Dan Carpenter]
Reported-by: "Liuhua Wang" <lwang@suse.com>
Signed-off-by: Heinz Mauelshagen <heinzm@redhat.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Zefan Li <lizefan@huawei.com>
drivers/md/dm-raid.c