Commit 5e601b35 authored by Neil Brown's avatar Neil Brown Committed by Trond Myklebust

[PATCH] MD - Move persistent from superblock to mddev

Move persistent from superblock to mddev

Tidyup calc_dev_sboffset and calc_dev_size on the way
parent 9f3b0380
...@@ -297,24 +297,20 @@ char * partition_name(kdev_t dev) ...@@ -297,24 +297,20 @@ char * partition_name(kdev_t dev)
return dname->name; return dname->name;
} }
static unsigned int calc_dev_sboffset(mdk_rdev_t *rdev, mddev_t *mddev, static unsigned int calc_dev_sboffset(struct block_device *bdev)
int persistent)
{ {
unsigned int size = rdev->bdev->bd_inode->i_size >> BLOCK_SIZE_BITS; unsigned int size = bdev->bd_inode->i_size >> BLOCK_SIZE_BITS;
if (persistent) return MD_NEW_SIZE_BLOCKS(size);
size = MD_NEW_SIZE_BLOCKS(size);
return size;
} }
static unsigned int calc_dev_size(mdk_rdev_t *rdev, mddev_t *mddev, int persistent) static unsigned int calc_dev_size(struct block_device *bdev, mddev_t *mddev)
{ {
unsigned int size; unsigned int size;
size = calc_dev_sboffset(rdev, mddev, persistent); if (mddev->persistent)
if (!mddev->sb) { size = calc_dev_sboffset(bdev);
MD_BUG(); else
return size; size = bdev->bd_inode->i_size >> BLOCK_SIZE_BITS;
}
if (mddev->sb->chunk_size) if (mddev->sb->chunk_size)
size &= ~(mddev->sb->chunk_size/1024 - 1); size &= ~(mddev->sb->chunk_size/1024 - 1);
return size; return size;
...@@ -450,7 +446,7 @@ static int read_disk_sb(mdk_rdev_t * rdev) ...@@ -450,7 +446,7 @@ static int read_disk_sb(mdk_rdev_t * rdev)
* *
* It also happens to be a multiple of 4Kb. * It also happens to be a multiple of 4Kb.
*/ */
sb_offset = calc_dev_sboffset(rdev, rdev->mddev, 1); sb_offset = calc_dev_sboffset(rdev->bdev);
rdev->sb_offset = sb_offset; rdev->sb_offset = sb_offset;
if (!sync_page_io(rdev->bdev, sb_offset<<1, MD_SB_BYTES, rdev->sb_page, READ)) if (!sync_page_io(rdev->bdev, sb_offset<<1, MD_SB_BYTES, rdev->sb_page, READ))
...@@ -814,7 +810,7 @@ static int write_disk_sb(mdk_rdev_t * rdev) ...@@ -814,7 +810,7 @@ static int write_disk_sb(mdk_rdev_t * rdev)
return 1; return 1;
} }
sb_offset = calc_dev_sboffset(rdev, rdev->mddev, 1); sb_offset = calc_dev_sboffset(rdev->bdev);
if (rdev->sb_offset != sb_offset) { if (rdev->sb_offset != sb_offset) {
printk(KERN_INFO "%s's sb offset has changed from %ld to %ld, skipping\n", printk(KERN_INFO "%s's sb offset has changed from %ld to %ld, skipping\n",
partition_name(dev), rdev->sb_offset, sb_offset); partition_name(dev), rdev->sb_offset, sb_offset);
...@@ -825,7 +821,7 @@ static int write_disk_sb(mdk_rdev_t * rdev) ...@@ -825,7 +821,7 @@ static int write_disk_sb(mdk_rdev_t * rdev)
* its size has changed to zero silently, and the MD code does * its size has changed to zero silently, and the MD code does
* not yet know that it's faulty. * not yet know that it's faulty.
*/ */
size = calc_dev_size(rdev, rdev->mddev, 1); size = calc_dev_size(rdev->bdev, rdev->mddev);
if (size != rdev->size) { if (size != rdev->size) {
printk(KERN_INFO "%s's size has changed from %ld to %ld since import, skipping\n", printk(KERN_INFO "%s's size has changed from %ld to %ld since import, skipping\n",
partition_name(dev), rdev->size, size); partition_name(dev), rdev->size, size);
...@@ -863,6 +859,7 @@ static int sync_sbs(mddev_t * mddev) ...@@ -863,6 +859,7 @@ static int sync_sbs(mddev_t * mddev)
int active=0, working=0,failed=0,spare=0,nr_disks=0; int active=0, working=0,failed=0,spare=0,nr_disks=0;
sb = mddev->sb; sb = mddev->sb;
sb->not_persistent = !mddev->persistent;
sb->disks[0].state = (1<<MD_DISK_REMOVED); sb->disks[0].state = (1<<MD_DISK_REMOVED);
ITERATE_RDEV(mddev,rdev,tmp) { ITERATE_RDEV(mddev,rdev,tmp) {
...@@ -942,7 +939,7 @@ static void md_update_sb(mddev_t * mddev) ...@@ -942,7 +939,7 @@ static void md_update_sb(mddev_t * mddev)
* do not write anything to disk if using * do not write anything to disk if using
* nonpersistent superblocks * nonpersistent superblocks
*/ */
if (mddev->sb->not_persistent) if (!mddev->persistent)
return; return;
printk(KERN_INFO "md: updating md%d RAID superblock on device\n", printk(KERN_INFO "md: updating md%d RAID superblock on device\n",
...@@ -1153,6 +1150,7 @@ static int analyze_sbs(mddev_t * mddev) ...@@ -1153,6 +1150,7 @@ static int analyze_sbs(mddev_t * mddev)
} }
memcpy (sb, freshest->sb, sizeof(*sb)); memcpy (sb, freshest->sb, sizeof(*sb));
mddev->persistent = ! sb->not_persistent;
/* /*
* at this point we have picked the 'best' superblock * at this point we have picked the 'best' superblock
* from all available superblocks. * from all available superblocks.
...@@ -1230,7 +1228,7 @@ static int analyze_sbs(mddev_t * mddev) ...@@ -1230,7 +1228,7 @@ static int analyze_sbs(mddev_t * mddev)
static int device_size_calculation(mddev_t * mddev) static int device_size_calculation(mddev_t * mddev)
{ {
int data_disks = 0, persistent; int data_disks = 0;
unsigned int readahead; unsigned int readahead;
mdp_super_t *sb = mddev->sb; mdp_super_t *sb = mddev->sb;
struct list_head *tmp; struct list_head *tmp;
...@@ -1241,7 +1239,7 @@ static int device_size_calculation(mddev_t * mddev) ...@@ -1241,7 +1239,7 @@ static int device_size_calculation(mddev_t * mddev)
* (we have to do this after having validated chunk_size, * (we have to do this after having validated chunk_size,
* because device size has to be modulo chunk_size) * because device size has to be modulo chunk_size)
*/ */
persistent = !mddev->sb->not_persistent;
ITERATE_RDEV(mddev,rdev,tmp) { ITERATE_RDEV(mddev,rdev,tmp) {
if (rdev->faulty) if (rdev->faulty)
continue; continue;
...@@ -1249,7 +1247,7 @@ static int device_size_calculation(mddev_t * mddev) ...@@ -1249,7 +1247,7 @@ static int device_size_calculation(mddev_t * mddev)
MD_BUG(); MD_BUG();
continue; continue;
} }
rdev->size = calc_dev_size(rdev, mddev, persistent); rdev->size = calc_dev_size(rdev->bdev, mddev);
if (rdev->size < sb->chunk_size / 1024) { if (rdev->size < sb->chunk_size / 1024) {
printk(KERN_WARNING printk(KERN_WARNING
"md: Dev %s smaller than chunk_size: %ldk < %dk\n", "md: Dev %s smaller than chunk_size: %ldk < %dk\n",
...@@ -1849,7 +1847,7 @@ static int get_array_info(mddev_t * mddev, void * arg) ...@@ -1849,7 +1847,7 @@ static int get_array_info(mddev_t * mddev, void * arg)
SET_FROM_SB(nr_disks); SET_FROM_SB(nr_disks);
SET_FROM_SB(raid_disks); SET_FROM_SB(raid_disks);
SET_FROM_SB(md_minor); SET_FROM_SB(md_minor);
SET_FROM_SB(not_persistent); info.not_persistent= !mddev->persistent;
SET_FROM_SB(utime); SET_FROM_SB(utime);
SET_FROM_SB(state); SET_FROM_SB(state);
...@@ -1911,7 +1909,7 @@ static int get_disk_info(mddev_t * mddev, void * arg) ...@@ -1911,7 +1909,7 @@ static int get_disk_info(mddev_t * mddev, void * arg)
static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
{ {
int size, persistent; int size;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
kdev_t dev; kdev_t dev;
dev = mk_kdev(info->major,info->minor); dev = mk_kdev(info->major,info->minor);
...@@ -1958,12 +1956,11 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info) ...@@ -1958,12 +1956,11 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
bind_rdev_to_array(rdev, mddev); bind_rdev_to_array(rdev, mddev);
persistent = !mddev->sb->not_persistent; if (!mddev->persistent)
if (!persistent)
printk(KERN_INFO "md: nonpersistent superblock ...\n"); printk(KERN_INFO "md: nonpersistent superblock ...\n");
size = calc_dev_size(rdev, mddev, persistent); size = calc_dev_size(rdev->bdev, mddev);
rdev->sb_offset = calc_dev_sboffset(rdev, mddev, persistent); rdev->sb_offset = calc_dev_sboffset(rdev->bdev);
if (!mddev->sb->size || (mddev->sb->size > size)) if (!mddev->sb->size || (mddev->sb->size > size))
mddev->sb->size = size; mddev->sb->size = size;
...@@ -2053,7 +2050,7 @@ static int hot_remove_disk(mddev_t * mddev, kdev_t dev) ...@@ -2053,7 +2050,7 @@ static int hot_remove_disk(mddev_t * mddev, kdev_t dev)
static int hot_add_disk(mddev_t * mddev, kdev_t dev) static int hot_add_disk(mddev_t * mddev, kdev_t dev)
{ {
int i, err, persistent; int i, err;
unsigned int size; unsigned int size;
mdk_rdev_t *rdev; mdk_rdev_t *rdev;
...@@ -2074,8 +2071,8 @@ static int hot_add_disk(mddev_t * mddev, kdev_t dev) ...@@ -2074,8 +2071,8 @@ static int hot_add_disk(mddev_t * mddev, kdev_t dev)
printk(KERN_WARNING "md: error, md_import_device() returned %ld\n", PTR_ERR(rdev)); printk(KERN_WARNING "md: error, md_import_device() returned %ld\n", PTR_ERR(rdev));
return -EINVAL; return -EINVAL;
} }
persistent = !mddev->sb->not_persistent;
size = calc_dev_size(rdev, mddev, persistent); size = calc_dev_size(rdev->bdev, mddev);
if (size < mddev->sb->size) { if (size < mddev->sb->size) {
printk(KERN_WARNING "md%d: disk size %d blocks < array size %d\n", printk(KERN_WARNING "md%d: disk size %d blocks < array size %d\n",
...@@ -2098,7 +2095,7 @@ static int hot_add_disk(mddev_t * mddev, kdev_t dev) ...@@ -2098,7 +2095,7 @@ static int hot_add_disk(mddev_t * mddev, kdev_t dev)
* noticed in interrupt contexts ... * noticed in interrupt contexts ...
*/ */
rdev->size = size; rdev->size = size;
rdev->sb_offset = calc_dev_sboffset(rdev, mddev, persistent); rdev->sb_offset = calc_dev_sboffset(rdev->bdev);
for (i = mddev->sb->raid_disks; i < MD_SB_DISKS; i++) for (i = mddev->sb->raid_disks; i < MD_SB_DISKS; i++)
if (find_rdev_nr(mddev,i)==NULL) if (find_rdev_nr(mddev,i)==NULL)
...@@ -2155,7 +2152,7 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info) ...@@ -2155,7 +2152,7 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
SET_SB(nr_disks); SET_SB(nr_disks);
SET_SB(raid_disks); SET_SB(raid_disks);
SET_SB(md_minor); SET_SB(md_minor);
SET_SB(not_persistent); mddev->persistent = ! info->not_persistent;
SET_SB(state); SET_SB(state);
...@@ -3329,7 +3326,7 @@ static struct { ...@@ -3329,7 +3326,7 @@ static struct {
* invoked program now). Added ability to initialise all * invoked program now). Added ability to initialise all
* the MD devices (by specifying multiple "md=" lines) * the MD devices (by specifying multiple "md=" lines)
* instead of just one. -- KTK * instead of just one. -- KTK
* 18May2000: Added support for persistant-superblock arrays: * 18May2000: Added support for persistent-superblock arrays:
* md=n,0,factor,fault,device-list uses RAID0 for device n * md=n,0,factor,fault,device-list uses RAID0 for device n
* md=n,-1,factor,fault,device-list uses LINEAR for device n * md=n,-1,factor,fault,device-list uses LINEAR for device n
* md=n,device-list reads a RAID superblock from the devices * md=n,device-list reads a RAID superblock from the devices
......
...@@ -175,6 +175,8 @@ struct mddev_s ...@@ -175,6 +175,8 @@ struct mddev_s
int sb_dirty; int sb_dirty;
int ro; int ro;
int persistent;
struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */ struct mdk_thread_s *sync_thread; /* doing resync or reconstruct */
unsigned long curr_resync; /* blocks scheduled */ unsigned long curr_resync; /* blocks scheduled */
unsigned long resync_mark; /* a recent timestamp */ unsigned long resync_mark; /* a recent timestamp */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment