if (vers >= 9000) {
mdu_array_info_t array;
array.level = level;
- array.size = size;
+ array.size = size == MAX_SIZE ? 0 : size;
array.nr_disks = raiddisks;
array.raid_disks = raiddisks;
array.md_minor = 0;
goto abort;
}
if (get_dev_size(fd, NULL, &dsize) &&
- (size == 0 || dsize < size))
+ (size == 0 || size == MAX_SIZE || dsize < size))
size = dsize;
close(fd);
if (vers >= 9000) {
pr_err("unknown level %d\n", level);
return 1;
}
-
+ if (size == MAX_SIZE)
+ /* use '0' to mean 'max' now... */
+ size = 0;
if (size && chunk && chunk != UnSet)
size &= ~(unsigned long long)(chunk - 1);
newsize = size * 2;
int verbose, int restart, int freeze_reshape);
int Grow_reshape(char *devname, int fd, int verbose, char *backup_file,
- long long size,
+ unsigned long long size,
int level, char *layout_str, int chunksize, int raid_disks,
struct mddev_dev *devlist,
int assume_clean, int force)
return 1;
}
- if (size >= 0 &&
+ if (size > 0 &&
(chunksize || level!= UnSet || layout_str || raid_disks)) {
pr_err("cannot change component size at the same time "
"as other changes.\n"
}
/* ========= set size =============== */
- if (size >= 0 && (size == 0 || size != array.size)) {
- long long orig_size = get_component_size(fd)/2;
- long long min_csize;
+ if (size > 0 && (size == MAX_DISKS || size != (unsigned)array.size)) {
+ unsigned long long orig_size = get_component_size(fd)/2;
+ unsigned long long min_csize;
struct mdinfo *mdi;
int raid0_takeover = 0;
if (orig_size == 0)
- orig_size = array.size;
+ orig_size = (unsigned) array.size;
if (reshape_super(st, size, UnSet, UnSet, 0, 0, UnSet, NULL,
devname, APPLY_METADATA_CHANGES, verbose > 0)) {
min_csize = 0;
rv = 0;
for (mdi = sra->devs; mdi; mdi = mdi->next) {
- if (sysfs_set_num(sra, mdi, "size", size) < 0) {
+ if (sysfs_set_num(sra, mdi, "size",
+ size == MAX_SIZE ? 0 : size) < 0) {
/* Probably kernel refusing to let us
* reduce the size - not an error.
*/
if (csize >= 2ULL*1024*1024*1024)
csize = 2ULL*1024*1024*1024;
if ((min_csize == 0 || (min_csize
- > (long long)csize)))
+ > csize)))
min_csize = csize;
}
}
rv = 1;
goto size_change_error;
}
- if (min_csize && size == 0) {
+ if (min_csize && size == MAX_SIZE) {
/* Don't let the kernel choose a size - it will get
* it wrong
*/
st->update_tail = &st->updates;
}
- array.size = size;
- if (array.size != size) {
+ array.size = size == MAX_SIZE ? 0 : size;
+ if ((unsigned)array.size != size) {
/* got truncated to 32bit, write to
* component_size instead
*/
int i;
int chunk = 0;
- long long size = -1;
+ unsigned long long size = 0;
long long array_size = -1;
int level = UnSet;
int layout = UnSet;
case O(GROW,'z'):
case O(CREATE,'z'):
case O(BUILD,'z'): /* size */
- if (size >= 0) {
+ if (size > 0) {
pr_err("size may only be specified once. "
"Second value is %s.\n", optarg);
exit(2);
}
if (strcmp(optarg, "max")==0)
- size = 0;
+ size = MAX_SIZE;
else {
size = parse_size(optarg);
if (size < 8) {
break;
}
- rv = Create(ss, devlist->devname, chunk, level, layout, size<0 ? 0 : size,
+ rv = Create(ss, devlist->devname, chunk, level, layout, size,
raiddisks, sparedisks, ident.name,
ident.uuid_set ? ident.uuid : NULL,
devs_found-1, devlist->next,
}
if (devs_found > 1 && raiddisks == 0) {
/* must be '-a'. */
- if (size >= 0 || chunk || layout_str != NULL || bitmap_file) {
+ if (size > 0 || chunk || layout_str != NULL || bitmap_file) {
pr_err("--add cannot be used with "
"other geometry changes in --grow mode\n");
rv = 1;
break;
}
} else if (bitmap_file) {
- if (size >= 0 || raiddisks || chunk ||
+ if (size > 0 || raiddisks || chunk ||
layout_str != NULL || devs_found > 1) {
pr_err("--bitmap changes cannot be "
"used with other geometry changes "
rv = Grow_continue_command(devlist->devname,
mdfd, c.backup_file,
c.verbose);
- else if (size >= 0 || raiddisks != 0 || layout_str != NULL
+ else if (size > 0 || raiddisks != 0 || layout_str != NULL
|| chunk != 0 || level != UnSet) {
rv = Grow_reshape(devlist->devname, mdfd, c.verbose, c.backup_file,
size, level, layout_str, chunk, raiddisks,
#define APPLY_METADATA_CHANGES 1
#define ROLLBACK_METADATA_CHANGES 0
- int (*reshape_super)(struct supertype *st, long long size, int level,
+ int (*reshape_super)(struct supertype *st,
+ unsigned long long size, int level,
int layout, int chunksize, int raid_disks,
int delta_disks, char *backup, char *dev,
int direction,
extern int Grow_Add_device(char *devname, int fd, char *newdev);
extern int Grow_addbitmap(char *devname, int fd, char *file, int chunk, int delay, int write_behind, int force);
extern int Grow_reshape(char *devname, int fd, int quiet, char *backup_file,
- long long size,
+ unsigned long long size,
int level, char *layout_str, int chunksize, int raid_disks,
struct mddev_dev *devlist,
int assume_clean, int force);
*/
#define MAX_DISKS 4096
+/* Sometimes the 'size' value passed needs to mean "Maximum".
+ * In those cases with use MAX_SIZE
+ */
+#define MAX_SIZE 1
extern int __offroot;
struct geo_params {
int dev_id;
char *dev_name;
- long long size;
+ unsigned long long size;
int level;
int layout;
int chunksize;
"st->devnum = (%i)\n",
st->devnum);
- if (geo->size != -1 ||
+ if (geo->size > 0 ||
geo->level != UnSet ||
geo->layout != UnSet ||
geo->chunksize != 0 ||
int data_disks;
struct imsm_dev *dev;
struct intel_super *super;
- long long current_size;
+ unsigned long long current_size;
unsigned long long free_size;
- long long max_size;
+ unsigned long long max_size;
int rv;
getinfo_super_imsm_volume(st, &info, NULL);
geo->size * 2);
}
- if ((current_size != geo->size) && (geo->size >= 0)) {
+ if ((current_size != geo->size) && (geo->size > 0)) {
if (change != -1) {
pr_err("Error. Size change should be the only "
"one at a time.\n");
chunk * 1024,
max_size);
}
- if (geo->size == 0) {
+ if (geo->size == MAX_SIZE) {
/* requested size change to the maximum available size
*/
if (max_size == 0) {
return 0;
}
-static int imsm_reshape_super(struct supertype *st, long long size, int level,
+static int imsm_reshape_super(struct supertype *st, unsigned long long size,
+ int level,
int layout, int chunksize, int raid_disks,
int delta_disks, char *backup, char *dev,
int direction, int verbose)