From 0e6004268370082b3af89e73c356f4ada5ca31c2 Mon Sep 17 00:00:00 2001 From: NeilBrown Date: Thu, 18 Sep 2008 15:04:47 +1000 Subject: [PATCH] Compile fixes, particularly moving more stuff under MDASSEMBLE Now 'make everything' works again. --- Assemble.c | 2 +- Create.c | 2 +- Manage.c | 5 ++++- super-ddf.c | 18 ++++++++++++------ super-intel.c | 31 +++++++++++++++++++++++-------- super0.c | 9 +++++++-- super1.c | 8 ++++++-- util.c | 8 +++----- 8 files changed, 57 insertions(+), 26 deletions(-) diff --git a/Assemble.c b/Assemble.c index 7efa2b8c..34d046d6 100644 --- a/Assemble.c +++ b/Assemble.c @@ -847,7 +847,7 @@ int Assemble(struct supertype *st, char *mddev, int mdfd, int rv; #ifndef MDASSEMBLE - struct mdinfo *sra; + struct mdinfo *sra = NULL; if (st->ss->external) { char ver[100]; strcat(strcpy(ver, "external:"), info.text_version); diff --git a/Create.c b/Create.c index c9c64b84..48d811f2 100644 --- a/Create.c +++ b/Create.c @@ -72,7 +72,7 @@ int Create(struct supertype *st, char *mddev, int mdfd, int rv; int bitmap_fd; int have_container = 0; - int container_fd; + int container_fd = -1; int need_mdmon = 0; unsigned long long bitmapsize; struct mdinfo *sra; diff --git a/Manage.c b/Manage.c index 5853515d..a6e10725 100644 --- a/Manage.c +++ b/Manage.c @@ -45,12 +45,15 @@ int Manage_ro(char *devname, int fd, int readonly) * */ mdu_array_info_t array; +#ifndef MDASSEMBLE struct mdinfo *mdi; +#endif if (md_get_version(fd) < 9000) { fprintf(stderr, Name ": need md driver version 0.90.0 or later\n"); return 1; } +#ifndef MDASSEMBLE /* If this is an externally-manage array, we need to modify the * metadata_version so that mdmon doesn't undo our change. */ @@ -92,7 +95,7 @@ int Manage_ro(char *devname, int fd, int readonly) } return 0; } - +#endif if (ioctl(fd, GET_ARRAY_INFO, &array)) { fprintf(stderr, Name ": %s does not appear to be active.\n", devname); diff --git a/super-ddf.c b/super-ddf.c index d7efa9f8..f7bdd2a0 100644 --- a/super-ddf.c +++ b/super-ddf.c @@ -1149,6 +1149,7 @@ static int match_home_ddf(struct supertype *st, char *homehost) ddf->controller.vendor_data[len] == 0); } +#ifndef MDASSEMBLE static struct vd_config *find_vdcr(struct ddf_super *ddf, int inst) { struct vcl *v; @@ -1158,6 +1159,7 @@ static struct vd_config *find_vdcr(struct ddf_super *ddf, int inst) return &v->conf; return NULL; } +#endif static int find_phys(struct ddf_super *ddf, __u32 phys_refnum) { @@ -1715,6 +1717,7 @@ static int rlq_to_layout(int rlq, int prl, int raiddisks) return -1; } +#ifndef MDASSEMBLE struct extent { unsigned long long start, size; }; @@ -1765,6 +1768,7 @@ FIXME ignore DDF_Legacy devices? rv[n].size = 0; return rv; } +#endif static int init_super_ddf_bvd(struct supertype *st, mdu_array_info_t *info, @@ -1877,6 +1881,7 @@ static int init_super_ddf_bvd(struct supertype *st, return 1; } +#ifndef MDASSEMBLE static void add_to_super_ddf_bvd(struct supertype *st, mdu_disk_info_t *dk, int fd, char *devname) { @@ -2071,8 +2076,6 @@ static void add_to_super_ddf(struct supertype *st, * container. */ -#ifndef MDASSEMBLE - static unsigned char null_conf[4096+512]; static int __write_init_super_ddf(struct supertype *st, int do_close) @@ -2557,7 +2560,7 @@ static int load_super_ddf_all(struct supertype *st, int fd, } return 0; } -#endif +#endif /* MDASSEMBLE */ static struct mdinfo *container_content_ddf(struct supertype *st) { @@ -2605,7 +2608,7 @@ static struct mdinfo *container_content_ddf(struct supertype *st) this->resync_start = ~0ULL; } memcpy(this->name, ddf->virt->entries[i].name, 32); - this->name[33]=0; + this->name[32]=0; memset(this->uuid, 0, sizeof(this->uuid)); this->component_size = __be64_to_cpu(vc->conf.blocks); @@ -2694,6 +2697,7 @@ static int compare_super_ddf(struct supertype *st, struct supertype *tst) return 0; } +#ifndef MDASSEMBLE /* * A new array 'a' has been started which claims to be instance 'inst' * within container 'c'. @@ -3243,6 +3247,7 @@ static struct mdinfo *ddf_activate_spare(struct active_array *a, *updates = mu; return rv; } +#endif /* MDASSEMBLE */ struct superswitch super_ddf = { #ifndef MDASSEMBLE @@ -3252,6 +3257,7 @@ struct superswitch super_ddf = { .brief_detail_super = brief_detail_super_ddf, .validate_geometry = validate_geometry_ddf, .write_init_super = write_init_super_ddf, + .add_to_super = add_to_super_ddf, #endif .match_home = match_home_ddf, .uuid_from_super= uuid_from_super_ddf, @@ -3267,11 +3273,11 @@ struct superswitch super_ddf = { .store_super = store_zero_ddf, .free_super = free_super_ddf, .match_metadata_desc = match_metadata_desc_ddf, - .add_to_super = add_to_super_ddf, .container_content = container_content_ddf, .external = 1, +#ifndef MDASSEMBLE /* for mdmon */ .open_new = ddf_open_new, .set_array_state= ddf_set_array_state, @@ -3280,5 +3286,5 @@ struct superswitch super_ddf = { .process_update = ddf_process_update, .prepare_update = ddf_prepare_update, .activate_spare = ddf_activate_spare, - +#endif }; diff --git a/super-intel.c b/super-intel.c index dc302b1d..bbc07302 100644 --- a/super-intel.c +++ b/super-intel.c @@ -238,10 +238,12 @@ static struct supertype *match_metadata_desc_imsm(char *arg) return st; } +#ifndef MDASSEMBLE static __u8 *get_imsm_version(struct imsm_super *mpb) { return &mpb->sig[MPB_SIG_LEN]; } +#endif /* retrieve a disk directly from the anchor when the anchor is known to be * up-to-date, currently only at load time @@ -253,6 +255,7 @@ static struct imsm_disk *__get_imsm_disk(struct imsm_super *mpb, __u8 index) return &mpb->disk[index]; } +#ifndef MDASSEMBLE /* retrieve a disk from the parsed metadata */ static struct imsm_disk *get_imsm_disk(struct intel_super *super, __u8 index) { @@ -264,6 +267,7 @@ static struct imsm_disk *get_imsm_disk(struct intel_super *super, __u8 index) return NULL; } +#endif /* generate a checksum directly from the anchor when the anchor is known to be * up-to-date, currently only at load or write_super after coalescing @@ -383,6 +387,7 @@ static int get_imsm_raid_level(struct imsm_map *map) return map->raid_level; } +#ifndef MDASSEMBLE static int cmp_extent(const void *av, const void *bv) { const struct extent *a = av; @@ -439,7 +444,6 @@ static struct extent *get_extents(struct intel_super *super, struct dl *dl) return rv; } -#ifndef MDASSEMBLE static void print_imsm_dev(struct imsm_dev *dev, int index) { __u64 sz; @@ -993,6 +997,7 @@ static void imsm_copy_dev(struct imsm_dev *dest, struct imsm_dev *src) memcpy(dest, src, sizeof_imsm_dev(src, 0)); } +#ifndef MDASSEMBLE /* When migrating map0 contains the 'destination' state while map1 * contains the current state. When not migrating map0 contains the * current state. This routine assumes that map[0].map_state is set to @@ -1019,6 +1024,7 @@ static void migrate(struct imsm_dev *dev, __u8 to_state, int rebuild_resync) memcpy(dest, src, sizeof_imsm_map(src)); src->map_state = to_state; } +#endif static int parse_raid_devices(struct intel_super *super) { @@ -1566,6 +1572,7 @@ static int init_super_imsm(struct supertype *st, mdu_array_info_t *info, return 1; } +#ifndef MDASSEMBLE static void add_to_super_imsm_volume(struct supertype *st, mdu_disk_info_t *dk, int fd, char *devname) { @@ -1765,6 +1772,7 @@ static int write_super_imsm(struct intel_super *super, int doclose) return 0; } + static int create_array(struct supertype *st) { size_t len; @@ -1838,6 +1846,7 @@ static int write_init_super_imsm(struct supertype *st) } else return write_super_imsm(st->sb, 1); } +#endif static int store_zero_imsm(struct supertype *st, int fd) { @@ -1859,6 +1868,12 @@ static int store_zero_imsm(struct supertype *st, int fd) return 0; } +static int imsm_bbm_log_size(struct imsm_super *mpb) +{ + return __le32_to_cpu(mpb->bbm_log_size); +} + +#ifndef MDASSEMBLE static int validate_geometry_imsm_container(struct supertype *st, int level, int layout, int raiddisks, int chunk, unsigned long long size, char *dev, @@ -2000,11 +2015,6 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level, return 1; } -int imsm_bbm_log_size(struct imsm_super *mpb) -{ - return __le32_to_cpu(mpb->bbm_log_size); -} - static int validate_geometry_imsm(struct supertype *st, int level, int layout, int raiddisks, int chunk, unsigned long long size, char *dev, unsigned long long *freesize, @@ -2092,6 +2102,7 @@ static int validate_geometry_imsm(struct supertype *st, int level, int layout, return 1; } +#endif /* MDASSEMBLE */ static struct mdinfo *container_content_imsm(struct supertype *st) { @@ -2196,6 +2207,7 @@ static struct mdinfo *container_content_imsm(struct supertype *st) } +#ifndef MDASSEMBLE static int imsm_open_new(struct supertype *c, struct active_array *a, char *inst) { @@ -3061,6 +3073,7 @@ static void imsm_delete(struct intel_super *super, struct dl **dlp, int index) __free_imsm_disk(dl); } } +#endif /* MDASSEMBLE */ struct superswitch super_imsm = { #ifndef MDASSEMBLE @@ -3069,6 +3082,8 @@ struct superswitch super_imsm = { .detail_super = detail_super_imsm, .brief_detail_super = brief_detail_super_imsm, .write_init_super = write_init_super_imsm, + .validate_geometry = validate_geometry_imsm, + .add_to_super = add_to_super_imsm, #endif .match_home = match_home_imsm, .uuid_from_super= uuid_from_super_imsm, @@ -3081,15 +3096,14 @@ struct superswitch super_imsm = { .load_super = load_super_imsm, .init_super = init_super_imsm, - .add_to_super = add_to_super_imsm, .store_super = store_zero_imsm, .free_super = free_super_imsm, .match_metadata_desc = match_metadata_desc_imsm, .container_content = container_content_imsm, - .validate_geometry = validate_geometry_imsm, .external = 1, +#ifndef MDASSEMBLE /* for mdmon */ .open_new = imsm_open_new, .load_super = load_super_imsm, @@ -3099,4 +3113,5 @@ struct superswitch super_imsm = { .activate_spare = imsm_activate_spare, .process_update = imsm_process_update, .prepare_update = imsm_prepare_update, +#endif /* MDASSEMBLE */ }; diff --git a/super0.c b/super0.c index ed44affe..99aa3d88 100644 --- a/super0.c +++ b/super0.c @@ -634,6 +634,8 @@ struct devinfo { mdu_disk_info_t disk; struct devinfo *next; }; + +#ifndef MDASSEMBLE /* Add a device to the superblock being created */ static void add_to_super0(struct supertype *st, mdu_disk_info_t *dinfo, int fd, char *devname) @@ -661,6 +663,7 @@ static void add_to_super0(struct supertype *st, mdu_disk_info_t *dinfo, di->next = NULL; *dip = di; } +#endif static int store_super0(struct supertype *st, int fd) { @@ -1036,6 +1039,7 @@ static void free_super0(struct supertype *st) st->sb = NULL; } +#ifndef MDASSEMBLE static int validate_geometry0(struct supertype *st, int level, int layout, int raiddisks, int chunk, unsigned long long size, @@ -1075,6 +1079,7 @@ static int validate_geometry0(struct supertype *st, int level, *freesize = MD_NEW_SIZE_SECTORS(ldsize >> 9); return 1; } +#endif /* MDASSEMBLE */ struct superswitch super0 = { #ifndef MDASSEMBLE @@ -1085,13 +1090,14 @@ struct superswitch super0 = { .brief_detail_super = brief_detail_super0, .export_detail_super = export_detail_super0, .write_init_super = write_init_super0, + .validate_geometry = validate_geometry0, + .add_to_super = add_to_super0, #endif .match_home = match_home0, .uuid_from_super = uuid_from_super0, .getinfo_super = getinfo_super0, .update_super = update_super0, .init_super = init_super0, - .add_to_super = add_to_super0, .store_super = store_super0, .compare_super = compare_super0, .load_super = load_super0, @@ -1101,5 +1107,4 @@ struct superswitch super0 = { .locate_bitmap = locate_bitmap0, .write_bitmap = write_bitmap0, .free_super = free_super0, - .validate_geometry = validate_geometry0, }; diff --git a/super1.c b/super1.c index 176579d4..2e3ef530 100644 --- a/super1.c +++ b/super1.c @@ -777,6 +777,7 @@ struct devinfo { mdu_disk_info_t disk; struct devinfo *next; }; +#ifndef MDASSEMBLE /* Add a device to the superblock being created */ static void add_to_super1(struct supertype *st, mdu_disk_info_t *dk, int fd, char *devname) @@ -805,6 +806,7 @@ static void add_to_super1(struct supertype *st, mdu_disk_info_t *dk, di->next = NULL; *dip = di; } +#endif static void locate_bitmap1(struct supertype *st, int fd); @@ -1463,6 +1465,7 @@ static void free_super1(struct supertype *st) st->sb = NULL; } +#ifndef MDASSEMBLE static int validate_geometry1(struct supertype *st, int level, int layout, int raiddisks, int chunk, unsigned long long size, @@ -1494,6 +1497,7 @@ static int validate_geometry1(struct supertype *st, int level, *freesize = avail_size1(st, ldsize >> 9); return 1; } +#endif /* MDASSEMBLE */ struct superswitch super1 = { #ifndef MDASSEMBLE @@ -1504,13 +1508,14 @@ struct superswitch super1 = { .brief_detail_super = brief_detail_super1, .export_detail_super = export_detail_super1, .write_init_super = write_init_super1, + .validate_geometry = validate_geometry1, + .add_to_super = add_to_super1, #endif .match_home = match_home1, .uuid_from_super = uuid_from_super1, .getinfo_super = getinfo_super1, .update_super = update_super1, .init_super = init_super1, - .add_to_super = add_to_super1, .store_super = store_super1, .compare_super = compare_super1, .load_super = load_super1, @@ -1520,7 +1525,6 @@ struct superswitch super1 = { .locate_bitmap = locate_bitmap1, .write_bitmap = write_bitmap1, .free_super = free_super1, - .validate_geometry = validate_geometry1, #if __BYTE_ORDER == BIG_ENDIAN .swapuuid = 0, #else diff --git a/util.c b/util.c index 7fe835a4..181a0a3c 100644 --- a/util.c +++ b/util.c @@ -633,7 +633,6 @@ unsigned long long calc_array_size(int level, int raid_disks, int layout, return data_disks * devsize; } -#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) int get_mdp_major(void) { static int mdp_major = -1; @@ -662,8 +661,7 @@ static int mdp_major = -1; return mdp_major; } - - +#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO) char *get_md_name(int dev) { /* find /dev/md%d or /dev/md/%d or make a device /dev/.tmp.md%d */ @@ -1145,7 +1143,7 @@ int env_no_mdmon(void) return 0; } - +#ifndef MDASSEMBLE int flush_metadata_updates(struct supertype *st) { int sfd; @@ -1186,7 +1184,7 @@ void append_metadata_update(struct supertype *st, void *buf, int len) *st->update_tail = mu; st->update_tail = &mu->next; } - +#endif /* MDASSEMBLE */ #ifdef __TINYC__ /* tinyc doesn't optimize this check in ioctl.h out ... */ -- 2.39.2