From 1bf4e2d962d0d7937bb24799aaa636edc6497fa4 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Fri, 26 Aug 2005 06:08:28 +0000 Subject: Passes all tests, nearly ready for release. Signed-off-by: Neil Brown --- super0.c | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) (limited to 'super0.c') diff --git a/super0.c b/super0.c index 496e3bb..ffa5cf7 100644 --- a/super0.c +++ b/super0.c @@ -472,7 +472,7 @@ static int store_super0(struct supertype *st, int fd, void *sbv) return 0; } -static int write_init_super0(struct supertype *st, void *sbv, mdu_disk_info_t *dinfo, char *devname, int reserve) +static int write_init_super0(struct supertype *st, void *sbv, mdu_disk_info_t *dinfo, char *devname) { mdp_super_t *sb = sbv; int fd = open(devname, O_RDWR|O_EXCL); @@ -490,27 +490,8 @@ static int write_init_super0(struct supertype *st, void *sbv, mdu_disk_info_t *d sb->sb_csum = calc_sb0_csum(sb); rv = store_super0(st, fd, sb); - if (sb->state & (1< 0) { - n = towrite; - if (n > sizeof(buf)) - n = sizeof(buf); - n = write(fd, buf, n); - if (n > 0) - towrite -= n; - else - break; - } - fsync(fd); - if (towrite) - rv = -2; - } + if (rv == 0 && (sb->state & (1<ss->write_bitmap(st, fd, sbv); close(fd); if (rv) @@ -664,15 +645,14 @@ static struct supertype *match_metadata_desc0(char *arg) return NULL; } -static __u64 avail_size0(struct supertype *st, __u64 devsize, int reserve) +static __u64 avail_size0(struct supertype *st, __u64 devsize) { if (devsize < MD_RESERVED_SECTORS*2) return 0ULL; - if (reserve > 64*2) return 0ULL; return MD_NEW_SIZE_SECTORS(devsize); } -static int add_internal_bitmap0(struct supertype *st, void *sbv, int chunk, int delay, int write_behind, unsigned long long size) +static int add_internal_bitmap0(struct supertype *st, void *sbv, int chunk, int delay, int write_behind, int *sizep, int may_change) { /* * The bitmap comes immediately after the superblock and must be 60K in size @@ -680,8 +660,8 @@ static int add_internal_bitmap0(struct supertype *st, void *sbv, int chunk, int * * size is in K, chunk is in bytes !!! */ - - unsigned long long bits = size; + unsigned long long size = *sizep; + unsigned long long bits; unsigned long long max_bits = 60*1024*8; unsigned long long min_chunk; mdp_super_t *sb = sbv; @@ -689,6 +669,7 @@ static int add_internal_bitmap0(struct supertype *st, void *sbv, int chunk, int min_chunk = 4096; /* sub-page chunks don't work yet.. */ + bits = (size * 1024)/ min_chunk +1; while (bits > max_bits) { min_chunk *= 2; bits = (bits+1)/2; @@ -706,7 +687,7 @@ static int add_internal_bitmap0(struct supertype *st, void *sbv, int chunk, int uuid_from_super0((int*)bms->uuid, sb); bms->chunksize = __cpu_to_le32(chunk); bms->daemon_sleep = __cpu_to_le32(delay); - bms->sync_size = __cpu_to_le64(size); + bms->sync_size = __cpu_to_le64(size<<1); bms->write_behind = __cpu_to_le32(write_behind); -- cgit