* [PATCH 0/2] md: More block -> sector conversions.
@ 2009-01-26 15:14 Andre Noll
2009-01-26 15:14 ` [PATCH 1/2] md: Make mddev->size sector-based Andre Noll
` (3 more replies)
0 siblings, 4 replies; 10+ messages in thread
From: Andre Noll @ 2009-01-26 15:14 UTC (permalink / raw)
To: Neil Brown; +Cc: LinuxRaid, Andre Noll
These two patches against Neil's for-next tree make the internal
representaions of mddev->size and rdev->size sector-based.
checkpatch.pl is happy with both patches, and the patched kernel
passes all tests of the mdadm test suite on my i386 UP box.
Please review.
BTW: This completes the block -> sector conversion of the md code base
because all remaining block-based quantities are either user-visible
(via sysfs) or describe on-disk formats (version 0.90 superblocks)
and hence can not be changed without breaking user space.
Andre
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/2] md: Make mddev->size sector-based.
2009-01-26 15:14 [PATCH 0/2] md: More block -> sector conversions Andre Noll
@ 2009-01-26 15:14 ` Andre Noll
2009-01-26 15:14 ` [PATCH 2/2] md: Represent raid device size in sectors Andre Noll
` (2 subsequent siblings)
3 siblings, 0 replies; 10+ messages in thread
From: Andre Noll @ 2009-01-26 15:14 UTC (permalink / raw)
To: Neil Brown; +Cc: LinuxRaid, Andre Noll
This patch renames the "size" field of struct mddev_s to "dev_sectors"
and stores the number of 512-byte sectors instead of the number of
1K-blocks in it.
All users of that field, including raid levels 1,4-6,10, are adjusted
accordingly. This simplifies the code a bit because it allows to get
rid of a couple of divisions/multiplications by two.
In order to make checkpatch happy, some minor coding style issues
have also been addressed. In particular, size_store() now uses
strict_strtoull() instead of simple_strtoull().
Signed-off-by: Andre Noll <maan@systemlinux.org>
---
drivers/md/bitmap.c | 2 +-
drivers/md/faulty.c | 2 +-
drivers/md/md.c | 97 ++++++++++++++++++++++++--------------------
drivers/md/multipath.c | 2 +-
drivers/md/raid1.c | 10 ++--
drivers/md/raid10.c | 6 +-
drivers/md/raid5.c | 24 ++++++------
include/linux/raid/md_k.h | 3 +-
8 files changed, 78 insertions(+), 68 deletions(-)
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 7199437..56a941a 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -297,7 +297,7 @@ static int write_sb_page(struct bitmap *bitmap, struct page *page, int wait)
+ size/512 > 0)
/* bitmap runs in to metadata */
goto bad_alignment;
- if (rdev->data_offset + mddev->size*2
+ if (rdev->data_offset + mddev->dev_sectors
> rdev->sb_start + bitmap->offset)
/* data runs in to bitmap */
goto bad_alignment;
diff --git a/drivers/md/faulty.c b/drivers/md/faulty.c
index 86d9adf..b3b0437 100644
--- a/drivers/md/faulty.c
+++ b/drivers/md/faulty.c
@@ -298,7 +298,7 @@ static int run(mddev_t *mddev)
list_for_each_entry(rdev, &mddev->disks, same_set)
conf->rdev = rdev;
- mddev->array_sectors = mddev->size * 2;
+ mddev->array_sectors = mddev->dev_sectors;
mddev->private = conf;
reconfig(mddev, mddev->layout, -1);
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 41e2509..4e04804 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -817,7 +817,7 @@ static int super_90_validate(mddev_t *mddev, mdk_rdev_t *rdev)
mddev->clevel[0] = 0;
mddev->layout = sb->layout;
mddev->raid_disks = sb->raid_disks;
- mddev->size = sb->size;
+ mddev->dev_sectors = sb->size * 2;
mddev->events = ev1;
mddev->bitmap_offset = 0;
mddev->default_bitmap_offset = MD_SB_BYTES >> 9;
@@ -931,7 +931,7 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
sb->ctime = mddev->ctime;
sb->level = mddev->level;
- sb->size = mddev->size;
+ sb->size = mddev->dev_sectors / 2;
sb->raid_disks = mddev->raid_disks;
sb->md_minor = mddev->md_minor;
sb->not_persistent = 0;
@@ -1029,7 +1029,7 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
static unsigned long long
super_90_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
{
- if (num_sectors && num_sectors < rdev->mddev->size * 2)
+ if (num_sectors && num_sectors < rdev->mddev->dev_sectors)
return 0; /* component must fit device */
if (rdev->mddev->bitmap_offset)
return 0; /* can't move bitmap */
@@ -1221,7 +1221,7 @@ static int super_1_validate(mddev_t *mddev, mdk_rdev_t *rdev)
mddev->clevel[0] = 0;
mddev->layout = le32_to_cpu(sb->layout);
mddev->raid_disks = le32_to_cpu(sb->raid_disks);
- mddev->size = le64_to_cpu(sb->size)/2;
+ mddev->dev_sectors = le64_to_cpu(sb->size);
mddev->events = ev1;
mddev->bitmap_offset = 0;
mddev->default_bitmap_offset = 1024 >> 9;
@@ -1317,7 +1317,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
sb->raid_disks = cpu_to_le32(mddev->raid_disks);
- sb->size = cpu_to_le64(mddev->size<<1);
+ sb->size = cpu_to_le64(mddev->dev_sectors);
if (mddev->bitmap && mddev->bitmap_file == NULL) {
sb->bitmap_offset = cpu_to_le32((__u32)mddev->bitmap_offset);
@@ -1370,7 +1370,7 @@ super_1_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
{
struct mdp_superblock_1 *sb;
sector_t max_sectors;
- if (num_sectors && num_sectors < rdev->mddev->size * 2)
+ if (num_sectors && num_sectors < rdev->mddev->dev_sectors)
return 0; /* component must fit device */
if (rdev->sb_start < rdev->data_offset) {
/* minor versions 1 and 2; superblock before data */
@@ -1454,8 +1454,9 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
if (find_rdev(mddev, rdev->bdev->bd_dev))
return -EEXIST;
- /* make sure rdev->size exceeds mddev->size */
- if (rdev->size && (mddev->size == 0 || rdev->size < mddev->size)) {
+ /* make sure rdev->size exceeds mddev->dev_sectors / 2 */
+ if (rdev->size && (mddev->dev_sectors == 0 ||
+ rdev->size < mddev->dev_sectors / 2)) {
if (mddev->pers) {
/* Cannot change size, so fail
* If mddev->level <= 0, then we don't care
@@ -1464,7 +1465,7 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
if (mddev->level > 0)
return -ENOSPC;
} else
- mddev->size = rdev->size;
+ mddev->dev_sectors = rdev->size * 2;
}
/* Verify rdev->desc_nr is unique.
@@ -2200,7 +2201,7 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
size -= rdev->data_offset/2;
}
}
- if (size < my_mddev->size)
+ if (size < my_mddev->dev_sectors / 2)
return -EINVAL; /* component must fit device */
rdev->size = size;
@@ -2757,7 +2758,7 @@ array_state_show(mddev_t *mddev, char *page)
else {
if (list_empty(&mddev->disks) &&
mddev->raid_disks == 0 &&
- mddev->size == 0)
+ mddev->dev_sectors == 0)
st = clear;
else
st = inactive;
@@ -2964,7 +2965,8 @@ __ATTR(bitmap_set_bits, S_IWUSR, null_show, bitmap_store);
static ssize_t
size_show(mddev_t *mddev, char *page)
{
- return sprintf(page, "%llu\n", (unsigned long long)mddev->size);
+ return sprintf(page, "%llu\n",
+ (unsigned long long)mddev->dev_sectors / 2);
}
static int update_size(mddev_t *mddev, sector_t num_sectors);
@@ -2976,20 +2978,19 @@ size_store(mddev_t *mddev, const char *buf, size_t len)
* not increase it (except from 0).
* If array is active, we can try an on-line resize
*/
- char *e;
- int err = 0;
- unsigned long long size = simple_strtoull(buf, &e, 10);
- if (!*buf || *buf == '\n' ||
- (*e && *e != '\n'))
- return -EINVAL;
+ unsigned long long sectors;
+ int err = strict_strtoull(buf, 10, §ors);
+ if (err < 0)
+ return err;
+ sectors *= 2;
if (mddev->pers) {
- err = update_size(mddev, size * 2);
+ err = update_size(mddev, sectors);
md_update_sb(mddev, 1);
} else {
- if (mddev->size == 0 ||
- mddev->size > size)
- mddev->size = size;
+ if (mddev->dev_sectors == 0 ||
+ mddev->dev_sectors > sectors)
+ mddev->dev_sectors = sectors;
else
err = -ENOSPC;
}
@@ -3254,15 +3255,15 @@ static struct md_sysfs_entry md_sync_speed = __ATTR_RO(sync_speed);
static ssize_t
sync_completed_show(mddev_t *mddev, char *page)
{
- unsigned long max_blocks, resync;
+ unsigned long max_sectors, resync;
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
- max_blocks = mddev->resync_max_sectors;
+ max_sectors = mddev->resync_max_sectors;
else
- max_blocks = mddev->size << 1;
+ max_sectors = mddev->dev_sectors;
resync = (mddev->curr_resync - atomic_read(&mddev->recovery_active));
- return sprintf(page, "%lu / %lu\n", resync, max_blocks);
+ return sprintf(page, "%lu / %lu\n", resync, max_sectors);
}
static struct md_sysfs_entry md_sync_completed = __ATTR_RO(sync_completed);
@@ -3737,11 +3738,11 @@ static int do_md_run(mddev_t * mddev)
/* perform some consistency tests on the device.
* We don't want the data to overlap the metadata,
- * Internal Bitmap issues has handled elsewhere.
+ * Internal Bitmap issues have been handled elsewhere.
*/
if (rdev->data_offset < rdev->sb_start) {
- if (mddev->size &&
- rdev->data_offset + mddev->size*2
+ if (mddev->dev_sectors &&
+ rdev->data_offset + mddev->dev_sectors
> rdev->sb_start) {
printk("md: %s: data overlaps metadata\n",
mdname(mddev));
@@ -3819,7 +3820,9 @@ static int do_md_run(mddev_t * mddev)
}
mddev->recovery = 0;
- mddev->resync_max_sectors = mddev->size << 1; /* may be over-ridden by personality */
+ /* may be over-ridden by personality */
+ mddev->resync_max_sectors = mddev->dev_sectors;
+
mddev->barriers_work = 1;
mddev->ok_start_degraded = start_dirty_degraded;
@@ -4075,7 +4078,7 @@ static int do_md_stop(mddev_t * mddev, int mode, int is_open)
export_array(mddev);
mddev->array_sectors = 0;
- mddev->size = 0;
+ mddev->dev_sectors = 0;
mddev->raid_disks = 0;
mddev->recovery_cp = 0;
mddev->resync_min = 0;
@@ -4280,8 +4283,8 @@ static int get_array_info(mddev_t * mddev, void __user * arg)
info.patch_version = MD_PATCHLEVEL_VERSION;
info.ctime = mddev->ctime;
info.level = mddev->level;
- info.size = mddev->size;
- if (info.size != mddev->size) /* overflow */
+ info.size = mddev->dev_sectors / 2;
+ if (info.size != mddev->dev_sectors / 2) /* overflow */
info.size = -1;
info.nr_disks = nr;
info.raid_disks = mddev->raid_disks;
@@ -4739,7 +4742,7 @@ static int set_array_info(mddev_t * mddev, mdu_array_info_t *info)
mddev->level = info->level;
mddev->clevel[0] = 0;
- mddev->size = info->size;
+ mddev->dev_sectors = 2 * (sector_t)info->size;
mddev->raid_disks = info->raid_disks;
/* don't set md_minor, it is determined by which /dev/md* was
* openned
@@ -4877,12 +4880,18 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
)
return -EINVAL;
/* Check there is only one change */
- if (info->size >= 0 && mddev->size != info->size) cnt++;
- if (mddev->raid_disks != info->raid_disks) cnt++;
- if (mddev->layout != info->layout) cnt++;
- if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT)) cnt++;
- if (cnt == 0) return 0;
- if (cnt > 1) return -EINVAL;
+ if (info->size >= 0 && mddev->dev_sectors / 2 != info->size)
+ cnt++;
+ if (mddev->raid_disks != info->raid_disks)
+ cnt++;
+ if (mddev->layout != info->layout)
+ cnt++;
+ if ((state ^ info->state) & (1<<MD_SB_BITMAP_PRESENT))
+ cnt++;
+ if (cnt == 0)
+ return 0;
+ if (cnt > 1)
+ return -EINVAL;
if (mddev->layout != info->layout) {
/* Change layout
@@ -4894,7 +4903,7 @@ static int update_array_info(mddev_t *mddev, mdu_array_info_t *info)
else
return mddev->pers->reconfig(mddev, info->layout, -1);
}
- if (info->size >= 0 && mddev->size != info->size)
+ if (info->size >= 0 && mddev->dev_sectors / 2 != info->size)
rv = update_size(mddev, (sector_t)info->size * 2);
if (mddev->raid_disks != info->raid_disks)
@@ -5394,7 +5403,7 @@ static void status_resync(struct seq_file *seq, mddev_t * mddev)
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
max_blocks = mddev->resync_max_sectors >> 1;
else
- max_blocks = mddev->size;
+ max_blocks = mddev->dev_sectors / 2;
/*
* Should not happen.
@@ -5970,10 +5979,10 @@ void md_do_sync(mddev_t *mddev)
j = mddev->recovery_cp;
} else if (test_bit(MD_RECOVERY_RESHAPE, &mddev->recovery))
- max_sectors = mddev->size << 1;
+ max_sectors = mddev->dev_sectors;
else {
/* recovery follows the physical size of devices */
- max_sectors = mddev->size << 1;
+ max_sectors = mddev->dev_sectors;
j = MaxSector;
list_for_each_entry(rdev, &mddev->disks, same_set)
if (rdev->raid_disk >= 0 &&
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index f6d08f2..a21084b 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -498,7 +498,7 @@ static int multipath_run (mddev_t *mddev)
/*
* Ok, everything is just fine now
*/
- mddev->array_sectors = mddev->size * 2;
+ mddev->array_sectors = mddev->dev_sectors;
mddev->queue->unplug_fn = multipath_unplug;
mddev->queue->backing_dev_info.congested_fn = multipath_congested;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 7b4f5f7..7b73bc9 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1721,7 +1721,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
return 0;
}
- max_sector = mddev->size << 1;
+ max_sector = mddev->dev_sectors;
if (sector_nr >= max_sector) {
/* If we aborted, we need to abort the
* sync on the 'current' bitmap chunk (there will
@@ -2046,7 +2046,7 @@ static int run(mddev_t *mddev)
/*
* Ok, everything is just fine now
*/
- mddev->array_sectors = mddev->size * 2;
+ mddev->array_sectors = mddev->dev_sectors;
mddev->queue->unplug_fn = raid1_unplug;
mddev->queue->backing_dev_info.congested_fn = raid1_congested;
@@ -2111,12 +2111,12 @@ static int raid1_resize(mddev_t *mddev, sector_t sectors)
mddev->array_sectors = sectors;
set_capacity(mddev->gendisk, mddev->array_sectors);
mddev->changed = 1;
- if (mddev->array_sectors / 2 > mddev->size &&
+ if (mddev->array_sectors > mddev->dev_sectors &&
mddev->recovery_cp == MaxSector) {
- mddev->recovery_cp = mddev->size << 1;
+ mddev->recovery_cp = mddev->dev_sectors;
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
}
- mddev->size = mddev->array_sectors / 2;
+ mddev->dev_sectors = mddev->array_sectors;
mddev->resync_max_sectors = sectors;
return 0;
}
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 6736d6d..0484c7e 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1694,7 +1694,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
return 0;
skipped:
- max_sector = mddev->size << 1;
+ max_sector = mddev->dev_sectors;
if (test_bit(MD_RECOVERY_SYNC, &mddev->recovery))
max_sector = mddev->resync_max_sectors;
if (sector_nr >= max_sector) {
@@ -2075,7 +2075,7 @@ static int run(mddev_t *mddev)
conf->far_offset = fo;
conf->chunk_mask = (sector_t)(mddev->chunk_size>>9)-1;
conf->chunk_shift = ffz(~mddev->chunk_size) - 9;
- size = mddev->size >> (conf->chunk_shift-1);
+ size = mddev->dev_sectors >> conf->chunk_shift;
sector_div(size, fc);
size = size * conf->raid_disks;
sector_div(size, nc);
@@ -2088,7 +2088,7 @@ static int run(mddev_t *mddev)
*/
stride += conf->raid_disks - 1;
sector_div(stride, conf->raid_disks);
- mddev->size = stride << (conf->chunk_shift-1);
+ mddev->dev_sectors = stride << conf->chunk_shift;
if (fo)
stride = 1;
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index a5ba080..99c5261 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3626,8 +3626,8 @@ static sector_t reshape_request(mddev_t *mddev, sector_t sector_nr, int *skipped
*(new_data_disks) -1,
raid_disks, data_disks,
&dd_idx, &pd_idx, conf);
- if (last_sector >= (mddev->size<<1))
- last_sector = (mddev->size<<1)-1;
+ if (last_sector >= mddev->dev_sectors)
+ last_sector = mddev->dev_sectors - 1;
while (first_sector <= last_sector) {
pd_idx = stripe_to_pdidx(first_sector, conf,
conf->previous_raid_disks);
@@ -3667,7 +3667,7 @@ static inline sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *ski
struct stripe_head *sh;
int pd_idx;
int raid_disks = conf->raid_disks;
- sector_t max_sector = mddev->size << 1;
+ sector_t max_sector = mddev->dev_sectors;
int sync_blocks;
int still_degraded = 0;
int i;
@@ -3705,7 +3705,7 @@ static inline sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *ski
*/
if (mddev->degraded >= conf->max_degraded &&
test_bit(MD_RECOVERY_SYNC, &mddev->recovery)) {
- sector_t rv = (mddev->size << 1) - sector_nr;
+ sector_t rv = mddev->dev_sectors - sector_nr;
*skipped = 1;
return rv;
}
@@ -4143,8 +4143,8 @@ static int run(mddev_t *mddev)
conf->expand_progress = mddev->reshape_position;
/* device size must be a multiple of chunk size */
- mddev->size &= ~(mddev->chunk_size/1024 -1);
- mddev->resync_max_sectors = mddev->size << 1;
+ mddev->dev_sectors &= ~(mddev->chunk_size / 512 - 1);
+ mddev->resync_max_sectors = mddev->dev_sectors;
if (conf->level == 6 && conf->raid_disks < 4) {
printk(KERN_ERR "raid6: not enough configured devices for %s (%d, minimum 4)\n",
@@ -4251,8 +4251,8 @@ static int run(mddev_t *mddev)
mddev->queue->backing_dev_info.congested_data = mddev;
mddev->queue->backing_dev_info.congested_fn = raid5_congested;
- mddev->array_sectors = 2 * mddev->size * (conf->previous_raid_disks -
- conf->max_degraded);
+ mddev->array_sectors = mddev->dev_sectors *
+ (conf->previous_raid_disks - conf->max_degraded);
blk_queue_merge_bvec(mddev->queue, raid5_mergeable_bvec);
@@ -4479,11 +4479,11 @@ static int raid5_resize(mddev_t *mddev, sector_t sectors)
- conf->max_degraded);
set_capacity(mddev->gendisk, mddev->array_sectors);
mddev->changed = 1;
- if (sectors/2 > mddev->size && mddev->recovery_cp == MaxSector) {
- mddev->recovery_cp = mddev->size << 1;
+ if (sectors > mddev->dev_sectors && mddev->recovery_cp == MaxSector) {
+ mddev->recovery_cp = mddev->dev_sectors;
set_bit(MD_RECOVERY_NEEDED, &mddev->recovery);
}
- mddev->size = sectors /2;
+ mddev->dev_sectors = sectors;
mddev->resync_max_sectors = sectors;
return 0;
}
@@ -4612,7 +4612,7 @@ static void end_reshape(raid5_conf_t *conf)
struct block_device *bdev;
if (!test_bit(MD_RECOVERY_INTR, &conf->mddev->recovery)) {
- conf->mddev->array_sectors = 2 * conf->mddev->size *
+ conf->mddev->array_sectors = conf->mddev->dev_sectors *
(conf->raid_disks - conf->max_degraded);
set_capacity(conf->mddev->gendisk, conf->mddev->array_sectors);
conf->mddev->changed = 1;
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
index 9743e4d..ed2f24b 100644
--- a/include/linux/raid/md_k.h
+++ b/include/linux/raid/md_k.h
@@ -155,7 +155,8 @@ struct mddev_s
char clevel[16];
int raid_disks;
int max_disks;
- sector_t size; /* used size of component devices */
+ sector_t dev_sectors; /* used size of
+ * component devices */
sector_t array_sectors; /* exported array size */
__u64 events;
--
1.5.3.8
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/2] md: Represent raid device size in sectors.
2009-01-26 15:14 [PATCH 0/2] md: More block -> sector conversions Andre Noll
2009-01-26 15:14 ` [PATCH 1/2] md: Make mddev->size sector-based Andre Noll
@ 2009-01-26 15:14 ` Andre Noll
2009-01-26 15:31 ` [PATCH 0/2] md: More block -> sector conversions Peter Rabbitson
2009-01-27 6:39 ` [PATCH 0/2] md: More block -> sector conversions Neil Brown
3 siblings, 0 replies; 10+ messages in thread
From: Andre Noll @ 2009-01-26 15:14 UTC (permalink / raw)
To: Neil Brown; +Cc: LinuxRaid, Andre Noll
This patch renames the "size" field of struct mdk_rdev_s to
"num_sectors" and changes this field to store sectors instead of
blocks.
All users of this field, linear.c, raid0.c and md.c, are fixed up
accordingly which gets rid of many multiplications and divisions.
Signed-off-by: Andre Noll <maan@systemlinux.org>
---
drivers/md/linear.c | 4 +-
drivers/md/md.c | 96 ++++++++++++++++++++++----------------------
drivers/md/raid0.c | 41 +++++++++----------
include/linux/raid/md_k.h | 2 +-
4 files changed, 71 insertions(+), 72 deletions(-)
diff --git a/drivers/md/linear.c b/drivers/md/linear.c
index 09658b2..83110f8 100644
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@ -135,8 +135,8 @@ static linear_conf_t *linear_conf(mddev_t *mddev, int raid_disks)
mddev->queue->max_sectors > (PAGE_SIZE>>9))
blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
- disk->num_sectors = rdev->size * 2;
- conf->array_sectors += rdev->size * 2;
+ disk->num_sectors = rdev->sectors;
+ conf->array_sectors += rdev->sectors;
cnt++;
}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 4e04804..359c842 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -414,7 +414,7 @@ static void free_disk_sb(mdk_rdev_t * rdev)
rdev->sb_loaded = 0;
rdev->sb_page = NULL;
rdev->sb_start = 0;
- rdev->size = 0;
+ rdev->sectors = 0;
}
}
@@ -780,9 +780,9 @@ static int super_90_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version
else
ret = 0;
}
- rdev->size = calc_num_sectors(rdev, sb->chunk_size) / 2;
+ rdev->sectors = calc_num_sectors(rdev, sb->chunk_size);
- if (rdev->size < sb->size && sb->level > 1)
+ if (rdev->sectors < sb->size * 2 && sb->level > 1)
/* "this cannot possibly happen" ... */
ret = -EINVAL;
@@ -1185,16 +1185,17 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
ret = 0;
}
if (minor_version)
- rdev->size = ((rdev->bdev->bd_inode->i_size>>9) - le64_to_cpu(sb->data_offset)) / 2;
+ rdev->sectors = (rdev->bdev->bd_inode->i_size >> 9) -
+ le64_to_cpu(sb->data_offset);
else
- rdev->size = rdev->sb_start / 2;
- if (rdev->size < le64_to_cpu(sb->data_size)/2)
+ rdev->sectors = rdev->sb_start;
+ if (rdev->sectors < le64_to_cpu(sb->data_size))
return -EINVAL;
- rdev->size = le64_to_cpu(sb->data_size)/2;
+ rdev->sectors = le64_to_cpu(sb->data_size);
if (le32_to_cpu(sb->chunksize))
- rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1);
+ rdev->sectors &= ~((sector_t)le32_to_cpu(sb->chunksize) - 1);
- if (le64_to_cpu(sb->size) > rdev->size*2)
+ if (le64_to_cpu(sb->size) > rdev->sectors)
return -EINVAL;
return ret;
}
@@ -1386,7 +1387,7 @@ super_1_rdev_size_change(mdk_rdev_t *rdev, sector_t num_sectors)
sector_t sb_start;
sb_start = (rdev->bdev->bd_inode->i_size >> 9) - 8*2;
sb_start &= ~(sector_t)(4*2 - 1);
- max_sectors = rdev->size * 2 + sb_start - rdev->sb_start;
+ max_sectors = rdev->sectors + sb_start - rdev->sb_start;
if (!num_sectors || num_sectors > max_sectors)
num_sectors = max_sectors;
rdev->sb_start = sb_start;
@@ -1454,9 +1455,9 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
if (find_rdev(mddev, rdev->bdev->bd_dev))
return -EEXIST;
- /* make sure rdev->size exceeds mddev->dev_sectors / 2 */
- if (rdev->size && (mddev->dev_sectors == 0 ||
- rdev->size < mddev->dev_sectors / 2)) {
+ /* make sure rdev->sectors exceeds mddev->dev_sectors */
+ if (rdev->sectors && (mddev->dev_sectors == 0 ||
+ rdev->sectors < mddev->dev_sectors)) {
if (mddev->pers) {
/* Cannot change size, so fail
* If mddev->level <= 0, then we don't care
@@ -1465,7 +1466,7 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
if (mddev->level > 0)
return -ENOSPC;
} else
- mddev->dev_sectors = rdev->size * 2;
+ mddev->dev_sectors = rdev->sectors;
}
/* Verify rdev->desc_nr is unique.
@@ -1714,8 +1715,8 @@ static void print_sb_1(struct mdp_superblock_1 *sb)
static void print_rdev(mdk_rdev_t *rdev, int major_version)
{
char b[BDEVNAME_SIZE];
- printk(KERN_INFO "md: rdev %s, SZ:%08llu F:%d S:%d DN:%u\n",
- bdevname(rdev->bdev,b), (unsigned long long)rdev->size,
+ printk(KERN_INFO "md: rdev %s, Sect:%08llu F:%d S:%d DN:%u\n",
+ bdevname(rdev->bdev, b), (unsigned long long)rdev->sectors,
test_bit(Faulty, &rdev->flags), test_bit(In_sync, &rdev->flags),
rdev->desc_nr);
if (rdev->sb_loaded) {
@@ -2154,7 +2155,7 @@ offset_store(mdk_rdev_t *rdev, const char *buf, size_t len)
return -EINVAL;
if (rdev->mddev->pers && rdev->raid_disk >= 0)
return -EBUSY;
- if (rdev->size && rdev->mddev->external)
+ if (rdev->sectors && rdev->mddev->external)
/* Must set offset before size, so overlap checks
* can be sane */
return -EBUSY;
@@ -2168,7 +2169,7 @@ __ATTR(offset, S_IRUGO|S_IWUSR, offset_show, offset_store);
static ssize_t
rdev_size_show(mdk_rdev_t *rdev, char *page)
{
- return sprintf(page, "%llu\n", (unsigned long long)rdev->size);
+ return sprintf(page, "%llu\n", (unsigned long long)rdev->sectors / 2);
}
static int overlaps(sector_t s1, sector_t l1, sector_t s2, sector_t l2)
@@ -2184,31 +2185,31 @@ static int overlaps(sector_t s1, sector_t l1, sector_t s2, sector_t l2)
static ssize_t
rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
{
- unsigned long long size;
- unsigned long long oldsize = rdev->size;
mddev_t *my_mddev = rdev->mddev;
+ sector_t oldsectors = rdev->sectors;
+ unsigned long long sectors;
- if (strict_strtoull(buf, 10, &size) < 0)
+ if (strict_strtoull(buf, 10, §ors) < 0)
return -EINVAL;
+ sectors *= 2;
if (my_mddev->pers && rdev->raid_disk >= 0) {
if (my_mddev->persistent) {
- size = super_types[my_mddev->major_version].
- rdev_size_change(rdev, size * 2);
- if (!size)
+ sectors = super_types[my_mddev->major_version].
+ rdev_size_change(rdev, sectors);
+ if (!sectors)
return -EBUSY;
- } else if (!size) {
- size = (rdev->bdev->bd_inode->i_size >> 10);
- size -= rdev->data_offset/2;
- }
+ } else if (!sectors)
+ sectors = (rdev->bdev->bd_inode->i_size >> 9) -
+ rdev->data_offset;
}
- if (size < my_mddev->dev_sectors / 2)
+ if (sectors < my_mddev->dev_sectors)
return -EINVAL; /* component must fit device */
- rdev->size = size;
- if (size > oldsize && my_mddev->external) {
+ rdev->sectors = sectors;
+ if (sectors > oldsectors && my_mddev->external) {
/* need to check that all other rdevs with the same ->bdev
* do not overlap. We need to unlock the mddev to avoid
- * a deadlock. We have already changed rdev->size, and if
+ * a deadlock. We have already changed rdev->sectors, and if
* we have to change it back, we will have the lock again.
*/
mddev_t *mddev;
@@ -2224,9 +2225,9 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
if (test_bit(AllReserved, &rdev2->flags) ||
(rdev->bdev == rdev2->bdev &&
rdev != rdev2 &&
- overlaps(rdev->data_offset, rdev->size * 2,
+ overlaps(rdev->data_offset, rdev->sectors,
rdev2->data_offset,
- rdev2->size * 2))) {
+ rdev2->sectors))) {
overlap = 1;
break;
}
@@ -2240,11 +2241,11 @@ rdev_size_store(mdk_rdev_t *rdev, const char *buf, size_t len)
if (overlap) {
/* Someone else could have slipped in a size
* change here, but doing so is just silly.
- * We put oldsize back because we *know* it is
+ * We put oldsectors back because we *know* it is
* safe, and trust userspace not to race with
* itself
*/
- rdev->size = oldsize;
+ rdev->sectors = oldsectors;
return -EBUSY;
}
}
@@ -3708,13 +3709,13 @@ static int do_md_run(mddev_t * mddev)
list_for_each_entry(rdev, &mddev->disks, same_set) {
if (test_bit(Faulty, &rdev->flags))
continue;
- if (rdev->size < chunk_size / 1024) {
+ if (rdev->sectors < chunk_size / 512) {
printk(KERN_WARNING
"md: Dev %s smaller than chunk_size:"
- " %lluk < %dk\n",
+ " %llu < %d\n",
bdevname(rdev->bdev,b),
- (unsigned long long)rdev->size,
- chunk_size / 1024);
+ (unsigned long long)rdev->sectors,
+ chunk_size / 512);
return -EINVAL;
}
}
@@ -4526,7 +4527,7 @@ static int add_new_disk(mddev_t * mddev, mdu_disk_info_t *info)
rdev->sb_start = rdev->bdev->bd_inode->i_size / 512;
} else
rdev->sb_start = calc_dev_sboffset(rdev->bdev);
- rdev->size = calc_num_sectors(rdev, mddev->chunk_size) / 2;
+ rdev->sectors = calc_num_sectors(rdev, mddev->chunk_size);
err = bind_rdev_to_array(rdev, mddev);
if (err) {
@@ -4596,7 +4597,7 @@ static int hot_add_disk(mddev_t * mddev, dev_t dev)
else
rdev->sb_start = rdev->bdev->bd_inode->i_size / 512;
- rdev->size = calc_num_sectors(rdev, mddev->chunk_size) / 2;
+ rdev->sectors = calc_num_sectors(rdev, mddev->chunk_size);
if (test_bit(Faulty, &rdev->flags)) {
printk(KERN_WARNING
@@ -4807,8 +4808,7 @@ static int update_size(mddev_t *mddev, sector_t num_sectors)
*/
return -EBUSY;
list_for_each_entry(rdev, &mddev->disks, same_set) {
- sector_t avail;
- avail = rdev->size * 2;
+ sector_t avail = rdev->sectors;
if (fit && (num_sectors == 0 || num_sectors > avail))
num_sectors = avail;
@@ -5536,7 +5536,7 @@ struct mdstat_info {
static int md_seq_show(struct seq_file *seq, void *v)
{
mddev_t *mddev = v;
- sector_t size;
+ sector_t sectors;
mdk_rdev_t *rdev;
struct mdstat_info *mi = seq->private;
struct bitmap *bitmap;
@@ -5572,7 +5572,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
seq_printf(seq, " %s", mddev->pers->name);
}
- size = 0;
+ sectors = 0;
list_for_each_entry(rdev, &mddev->disks, same_set) {
char b[BDEVNAME_SIZE];
seq_printf(seq, " %s[%d]",
@@ -5584,7 +5584,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
continue;
} else if (rdev->raid_disk < 0)
seq_printf(seq, "(S)"); /* spare */
- size += rdev->size;
+ sectors += rdev->sectors;
}
if (!list_empty(&mddev->disks)) {
@@ -5594,7 +5594,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
mddev->array_sectors / 2);
else
seq_printf(seq, "\n %llu blocks",
- (unsigned long long)size);
+ (unsigned long long)sectors / 2);
}
if (mddev->persistent) {
if (mddev->major_version != 0 ||
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c
index c605ba8..a5037de 100644
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@ -73,16 +73,15 @@ static int create_strip_zones (mddev_t *mddev)
list_for_each_entry(rdev2, &mddev->disks, same_set) {
printk(KERN_INFO "raid0: comparing %s(%llu)",
bdevname(rdev1->bdev,b),
- (unsigned long long)rdev1->size);
+ (unsigned long long)rdev1->sectors);
printk(KERN_INFO " with %s(%llu)\n",
bdevname(rdev2->bdev,b),
- (unsigned long long)rdev2->size);
+ (unsigned long long)rdev2->sectors);
if (rdev2 == rdev1) {
printk(KERN_INFO "raid0: END\n");
break;
}
- if (rdev2->size == rdev1->size)
- {
+ if (rdev2->sectors == rdev1->sectors) {
/*
* Not unique, don't count it as a new
* group
@@ -145,7 +144,7 @@ static int create_strip_zones (mddev_t *mddev)
mddev->queue->max_sectors > (PAGE_SIZE>>9))
blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
- if (!smallest || (rdev1->size <smallest->size))
+ if (!smallest || (rdev1->sectors < smallest->sectors))
smallest = rdev1;
cnt++;
}
@@ -155,10 +154,10 @@ static int create_strip_zones (mddev_t *mddev)
goto abort;
}
zone->nb_dev = cnt;
- zone->sectors = smallest->size * cnt * 2;
+ zone->sectors = smallest->sectors * cnt;
zone->zone_start = 0;
- current_start = smallest->size * 2;
+ current_start = smallest->sectors;
curr_zone_start = zone->sectors;
/* now do the other zones */
@@ -177,29 +176,29 @@ static int create_strip_zones (mddev_t *mddev)
rdev = conf->strip_zone[0].dev[j];
printk(KERN_INFO "raid0: checking %s ...",
bdevname(rdev->bdev, b));
- if (rdev->size > current_start / 2) {
- printk(KERN_INFO " contained as device %d\n",
- c);
- zone->dev[c] = rdev;
- c++;
- if (!smallest || (rdev->size <smallest->size)) {
- smallest = rdev;
- printk(KERN_INFO " (%llu) is smallest!.\n",
- (unsigned long long)rdev->size);
- }
- } else
+ if (rdev->sectors <= current_start) {
printk(KERN_INFO " nope.\n");
+ continue;
+ }
+ printk(KERN_INFO " contained as device %d\n", c);
+ zone->dev[c] = rdev;
+ c++;
+ if (!smallest || rdev->sectors < smallest->sectors) {
+ smallest = rdev;
+ printk(KERN_INFO " (%llu) is smallest!.\n",
+ (unsigned long long)rdev->sectors);
+ }
}
zone->nb_dev = c;
- zone->sectors = (smallest->size * 2 - current_start) * c;
+ zone->sectors = (smallest->sectors - current_start) * c;
printk(KERN_INFO "raid0: zone->nb_dev: %d, sectors: %llu\n",
zone->nb_dev, (unsigned long long)zone->sectors);
zone->zone_start = curr_zone_start;
curr_zone_start += zone->sectors;
- current_start = smallest->size * 2;
+ current_start = smallest->sectors;
printk(KERN_INFO "raid0: current zone start: %llu\n",
(unsigned long long)current_start);
}
@@ -293,7 +292,7 @@ static int raid0_run (mddev_t *mddev)
/* calculate array device size */
mddev->array_sectors = 0;
list_for_each_entry(rdev, &mddev->disks, same_set)
- mddev->array_sectors += rdev->size * 2;
+ mddev->array_sectors += rdev->sectors;
printk(KERN_INFO "raid0 : md_size is %llu sectors.\n",
(unsigned long long)mddev->array_sectors);
diff --git a/include/linux/raid/md_k.h b/include/linux/raid/md_k.h
index ed2f24b..e0defd6 100644
--- a/include/linux/raid/md_k.h
+++ b/include/linux/raid/md_k.h
@@ -49,7 +49,7 @@ struct mdk_rdev_s
{
struct list_head same_set; /* RAID devices within the same set */
- sector_t size; /* Device size (in blocks) */
+ sector_t sectors; /* Device size (in 512bytes sectors) */
mddev_t *mddev; /* RAID array if running */
long last_events; /* IO event timestamp */
--
1.5.3.8
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] md: More block -> sector conversions.
2009-01-26 15:14 [PATCH 0/2] md: More block -> sector conversions Andre Noll
2009-01-26 15:14 ` [PATCH 1/2] md: Make mddev->size sector-based Andre Noll
2009-01-26 15:14 ` [PATCH 2/2] md: Represent raid device size in sectors Andre Noll
@ 2009-01-26 15:31 ` Peter Rabbitson
2009-01-26 16:08 ` Andre Noll
2009-01-27 6:39 ` [PATCH 0/2] md: More block -> sector conversions Neil Brown
3 siblings, 1 reply; 10+ messages in thread
From: Peter Rabbitson @ 2009-01-26 15:31 UTC (permalink / raw)
To: Andre Noll; +Cc: LinuxRaid
Andre Noll wrote:
> These two patches against Neil's for-next tree make the internal
> representaions of mddev->size and rdev->size sector-based.
> checkpatch.pl is happy with both patches, and the patched kernel
> passes all tests of the mdadm test suite on my i386 UP box.
>
> Please review.
>
> BTW: This completes the block -> sector conversion of the md code base
> because all remaining block-based quantities are either user-visible
> (via sysfs) or describe on-disk formats (version 0.90 superblocks)
> and hence can not be changed without breaking user space.
>
> Andre
>
Hi Andre,
Is it possible that the following issue is related to your earlier
patches: http://marc.info/?l=linux-raid&m=123202024116493&w=2
Thanks
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] md: More block -> sector conversions.
2009-01-26 15:31 ` [PATCH 0/2] md: More block -> sector conversions Peter Rabbitson
@ 2009-01-26 16:08 ` Andre Noll
2009-01-26 17:26 ` Peter Rabbitson
0 siblings, 1 reply; 10+ messages in thread
From: Andre Noll @ 2009-01-26 16:08 UTC (permalink / raw)
To: Peter Rabbitson; +Cc: LinuxRaid
[-- Attachment #1: Type: text/plain, Size: 792 bytes --]
On 16:31, Peter Rabbitson wrote:
> Is it possible that the following issue is related to your earlier
> patches: http://marc.info/?l=linux-raid&m=123202024116493&w=2
I don't think this is possible because you are using Linux 2.6.24.7
which does not contain any of the block -> sector conversion changes.
Moreover, those changes should be invisible to userspace. In
particular, mdadm does not need to know whether the kernel uses blocks
or sectors for its internal representations. In fact, no changes to
mdadm were made wrt. the block -> sector conversions.
Can you reproduce the incorrect output for the used device size
with the recent master branch of the mdadm git tree?
Thanks
Andre
--
The only person who always got his work done by Friday was Robinson Crusoe
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] md: More block -> sector conversions.
2009-01-26 16:08 ` Andre Noll
@ 2009-01-26 17:26 ` Peter Rabbitson
2009-01-26 18:33 ` Andre Noll
0 siblings, 1 reply; 10+ messages in thread
From: Peter Rabbitson @ 2009-01-26 17:26 UTC (permalink / raw)
To: Andre Noll; +Cc: LinuxRaid
Andre Noll wrote:
> On 16:31, Peter Rabbitson wrote:
>
>> Is it possible that the following issue is related to your earlier
>> patches: http://marc.info/?l=linux-raid&m=123202024116493&w=2
>
> I don't think this is possible because you are using Linux 2.6.24.7
> which does not contain any of the block -> sector conversion changes.
>
> Moreover, those changes should be invisible to userspace. In
> particular, mdadm does not need to know whether the kernel uses blocks
> or sectors for its internal representations. In fact, no changes to
> mdadm were made wrt. the block -> sector conversions.
>
> Can you reproduce the incorrect output for the used device size
> with the recent master branch of the mdadm git tree?
>
Hi Andre,
Yes I can:
root@Thesaurus:/home/rabbit/src/git/mdadm# ./mdadm --version
mdadm - v2.6.8 - 28th November 2008
root@Thesaurus:/home/rabbit/src/git/mdadm# ./mdadm -E /dev/sda1
/dev/sda1:
Magic : a92b4efc
Version : 1.1
Feature Map : 0x0
Array UUID : 6b11b1ba:78985745:b320fc1a:1db68bcf
Name : Thesaurus:Crypta (local to host Thesaurus)
Creation Time : Sat Mar 8 16:33:41 2008
Raid Level : raid5
Raid Devices : 4
Avail Dev Size : 578130828 (275.67 GiB 296.00 GB)
Array Size : 1730162688 (825.01 GiB 885.84 GB)
Used Dev Size : 576720896 (275.00 GiB 295.28 GB)
Data Offset : 264 sectors
Super Offset : 0 sectors
State : active
Device UUID : 85e0e62b:56129e5f:b0d82e78:2ace7d37
Update Time : Mon Jan 26 18:24:19 2009
Checksum : 61b214ff - correct
Events : 772406
Layout : left-symmetric
Chunk Size : 2048K
Array Slot : 5 (failed, failed, 2, 3, 0, 1)
Array State : uUuu 2 failed
root@Thesaurus:/home/rabbit/src/git/mdadm# ./mdadm -D /dev/md5
/dev/md5:
Version : 1.01
Creation Time : Sat Mar 8 16:33:41 2008
Raid Level : raid5
Array Size : 865081344 (825.01 GiB 885.84 GB)
Used Dev Size : 576720896 (550.00 GiB 590.56 GB)
Raid Devices : 4
Total Devices : 4
Preferred Minor : 5
Persistence : Superblock is persistent
Update Time : Mon Jan 26 18:24:34 2009
State : clean
Active Devices : 4
Working Devices : 4
Failed Devices : 0
Spare Devices : 0
Layout : left-symmetric
Chunk Size : 2048K
Name : Thesaurus:Crypta (local to host Thesaurus)
UUID : 6b11b1ba:78985745:b320fc1a:1db68bcf
Events : 772406
Number Major Minor RaidDevice State
4 8 67 0 active sync /dev/sde3
5 8 1 1 active sync /dev/sda1
2 8 19 2 active sync /dev/sdb3
3 8 35 3 active sync /dev/sdc3
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] md: More block -> sector conversions.
2009-01-26 17:26 ` Peter Rabbitson
@ 2009-01-26 18:33 ` Andre Noll
2009-01-27 7:52 ` [PATCH] mdadm: Fix the used device size in mdadm -D output Andre Noll
0 siblings, 1 reply; 10+ messages in thread
From: Andre Noll @ 2009-01-26 18:33 UTC (permalink / raw)
To: Peter Rabbitson; +Cc: LinuxRaid
[-- Attachment #1: Type: text/plain, Size: 1393 bytes --]
On 18:26, Peter Rabbitson wrote:
> > Can you reproduce the incorrect output for the used device size
> > with the recent master branch of the mdadm git tree?
> >
>
> Hi Andre,
>
> Yes I can:
[snip]
> Used Dev Size : 576720896 (550.00 GiB 590.56 GB)
This is twice as much as it should be due to a bug in mdadm which bites
only for version1 superblocks. The patch below should fix it. However,
this might not be the most elegant solution because the real bug
is IMHO that get_component_size() multiplies the value from sysfs
(which is always in 1K units) by two, so it returns 2K units which
looks a bit weird.
Since there are more callers of get_component_size() I have to take
a deeper look to come up with a more reasonable patch.
Have fun
Andre
diff --git a/Detail.c b/Detail.c
index 3cee66f..cef1abb 100644
--- a/Detail.c
+++ b/Detail.c
@@ -195,7 +195,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
if (array.level >= 1) {
if (array.major_version != 0 &&
(larray_size >= 0xFFFFFFFFULL|| array.size == 0)) {
- unsigned long long dsize = get_component_size(fd);
+ unsigned long long dsize = get_component_size(fd) / 2; /* KB */
if (dsize > 0)
printf(" Used Dev Size : %llu%s\n",
dsize,
--
The only person who always got his work done by Friday was Robinson Crusoe
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 0/2] md: More block -> sector conversions.
2009-01-26 15:14 [PATCH 0/2] md: More block -> sector conversions Andre Noll
` (2 preceding siblings ...)
2009-01-26 15:31 ` [PATCH 0/2] md: More block -> sector conversions Peter Rabbitson
@ 2009-01-27 6:39 ` Neil Brown
3 siblings, 0 replies; 10+ messages in thread
From: Neil Brown @ 2009-01-27 6:39 UTC (permalink / raw)
To: Andre Noll; +Cc: LinuxRaid
On Monday January 26, maan@systemlinux.org wrote:
> These two patches against Neil's for-next tree make the internal
> representaions of mddev->size and rdev->size sector-based.
> checkpatch.pl is happy with both patches, and the patched kernel
> passes all tests of the mdadm test suite on my i386 UP box.
>
> Please review.
>
> BTW: This completes the block -> sector conversion of the md code base
> because all remaining block-based quantities are either user-visible
> (via sysfs) or describe on-disk formats (version 0.90 superblocks)
> and hence can not be changed without breaking user space.
>
Thanks Andre.
These look fine.
The only problem I could find was that in the first patch, the change
log says "num_sectors" and the code says "sectors" :-)
I'll queue these for the next release.
Thanks,
NeilBrown
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mdadm: Fix the used device size in mdadm -D output.
2009-01-26 18:33 ` Andre Noll
@ 2009-01-27 7:52 ` Andre Noll
2009-02-01 23:04 ` Neil Brown
0 siblings, 1 reply; 10+ messages in thread
From: Andre Noll @ 2009-01-27 7:52 UTC (permalink / raw)
To: Peter Rabbitson; +Cc: LinuxRaid
[-- Attachment #1: Type: text/plain, Size: 1873 bytes --]
On 19:33, Andre Noll wrote:
> This is twice as much as it should be due to a bug in mdadm which bites
> only for version1 superblocks. The patch below should fix it. However,
> this might not be the most elegant solution because the real bug
> is IMHO that get_component_size() multiplies the value from sysfs
> (which is always in 1K units) by two, so it returns 2K units which
> looks a bit weird.
This was of course a braino: Multiplying a value in 1K units by two
yields 512byte units rather than 2K units, which is exactly what the
comment to get_component_size() says ;)
That being said, I think my patch is correct and dividing the result
by two in Detail() seems the best way to deal with the situation.
So here's the patch again, this time with proper log message.
Andre
commit 2e9fd78bd09bf332ac86f2d288a0e7c3c1c3df4f
Author: Andre Noll <maan@systemlinux.org>
Date: Tue Jan 27 08:49:15 2009 +0100
Fix the used device size in mdadm -D output.
As get_component_size() returns the number of used sectors of a
device while mdadm is supposed to print this size in kilobytes,
we have to divide the return value of get_component_size() by two.
Signed-off-by: Andre Noll <maan@systemlinux.org>
diff --git a/Detail.c b/Detail.c
index 3cee66f..cef1abb 100644
--- a/Detail.c
+++ b/Detail.c
@@ -195,7 +195,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
if (array.level >= 1) {
if (array.major_version != 0 &&
(larray_size >= 0xFFFFFFFFULL|| array.size == 0)) {
- unsigned long long dsize = get_component_size(fd);
+ unsigned long long dsize = get_component_size(fd) / 2; /* KB */
if (dsize > 0)
printf(" Used Dev Size : %llu%s\n",
dsize,
--
The only person who always got his work done by Friday was Robinson Crusoe
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] mdadm: Fix the used device size in mdadm -D output.
2009-01-27 7:52 ` [PATCH] mdadm: Fix the used device size in mdadm -D output Andre Noll
@ 2009-02-01 23:04 ` Neil Brown
0 siblings, 0 replies; 10+ messages in thread
From: Neil Brown @ 2009-02-01 23:04 UTC (permalink / raw)
To: Andre Noll; +Cc: Peter Rabbitson, LinuxRaid
On Tuesday January 27, maan@systemlinux.org wrote:
> On 19:33, Andre Noll wrote:
> > This is twice as much as it should be due to a bug in mdadm which bites
> > only for version1 superblocks. The patch below should fix it. However,
> > this might not be the most elegant solution because the real bug
> > is IMHO that get_component_size() multiplies the value from sysfs
> > (which is always in 1K units) by two, so it returns 2K units which
> > looks a bit weird.
>
> This was of course a braino: Multiplying a value in 1K units by two
> yields 512byte units rather than 2K units, which is exactly what the
> comment to get_component_size() says ;)
>
> That being said, I think my patch is correct and dividing the result
> by two in Detail() seems the best way to deal with the situation.
> So here's the patch again, this time with proper log message.
Thanks Andre.
Your patch is good... but I really like to use "sectors" as often as
possible.
So I've changed it to leave 'dsize' as sectors, but device it by 2, or
shift by 9, as appropriate.
Thanks,
NeilBrown
>
> Andre
>
> commit 2e9fd78bd09bf332ac86f2d288a0e7c3c1c3df4f
> Author: Andre Noll <maan@systemlinux.org>
> Date: Tue Jan 27 08:49:15 2009 +0100
>
> Fix the used device size in mdadm -D output.
>
> As get_component_size() returns the number of used sectors of a
> device while mdadm is supposed to print this size in kilobytes,
> we have to divide the return value of get_component_size() by two.
>
> Signed-off-by: Andre Noll <maan@systemlinux.org>
>
> diff --git a/Detail.c b/Detail.c
> index 3cee66f..cef1abb 100644
> --- a/Detail.c
> +++ b/Detail.c
> @@ -195,7 +195,7 @@ int Detail(char *dev, int brief, int export, int test, char *homehost)
> if (array.level >= 1) {
> if (array.major_version != 0 &&
> (larray_size >= 0xFFFFFFFFULL|| array.size == 0)) {
> - unsigned long long dsize = get_component_size(fd);
> + unsigned long long dsize = get_component_size(fd) / 2; /* KB */
> if (dsize > 0)
> printf(" Used Dev Size : %llu%s\n",
> dsize,
> --
> The only person who always got his work done by Friday was Robinson Crusoe
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-02-01 23:04 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-26 15:14 [PATCH 0/2] md: More block -> sector conversions Andre Noll
2009-01-26 15:14 ` [PATCH 1/2] md: Make mddev->size sector-based Andre Noll
2009-01-26 15:14 ` [PATCH 2/2] md: Represent raid device size in sectors Andre Noll
2009-01-26 15:31 ` [PATCH 0/2] md: More block -> sector conversions Peter Rabbitson
2009-01-26 16:08 ` Andre Noll
2009-01-26 17:26 ` Peter Rabbitson
2009-01-26 18:33 ` Andre Noll
2009-01-27 7:52 ` [PATCH] mdadm: Fix the used device size in mdadm -D output Andre Noll
2009-02-01 23:04 ` Neil Brown
2009-01-27 6:39 ` [PATCH 0/2] md: More block -> sector conversions Neil Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).