]> sourceware.org Git - lvm2.git/commitdiff
Change the code throughout for recent changes in format_instance handling.
authorPeter Rajnoha <prajnoha@redhat.com>
Mon, 21 Feb 2011 12:07:03 +0000 (12:07 +0000)
committerPeter Rajnoha <prajnoha@redhat.com>
Mon, 21 Feb 2011 12:07:03 +0000 (12:07 +0000)
lib/cache/lvmcache.c
lib/format_text/archive.c
lib/format_text/archiver.c
lib/format_text/format-text.c
lib/metadata/metadata.c

index 3f5f417139db54ea21e2ce94bffc0350db8493eb..0a8693c6c328ce72e1a6dfc3d12573554fd48fa8 100644 (file)
@@ -629,6 +629,7 @@ struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted)
        struct lvmcache_vginfo *vginfo;
        struct volume_group *vg;
        struct format_instance *fid;
+       struct format_instance_ctx fic;
 
        if (!vgid || !(vginfo = vginfo_from_vgid(vgid)) || !vginfo->vgmetadata)
                return NULL;
@@ -652,9 +653,10 @@ struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted)
            (!precommitted && vginfo->precommitted && !critical_section()))
                return NULL;
 
-       if (!(fid = vginfo->fmt->ops->create_instance(vginfo->fmt,
-                                                     vginfo->vgname,
-                                                     vgid, NULL)))
+       fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
+       fic.context.vg_ref.vg_name = vginfo->vgname;
+       fic.context.vg_ref.vg_id = vgid;
+       if (!(fid = vginfo->fmt->ops->create_instance(vginfo->fmt, &fic)))
                return_NULL;
 
        /* Build config tree from vgmetadata, if not yet cached */
index 43425dc30eb99c462ef75c18ea9ad46922ce2a42..4ba6d072d21573eef1d692b949438eb551b637a2 100644 (file)
@@ -300,16 +300,16 @@ static void _display_archive(struct cmd_context *cmd, struct archive_file *af)
 {
        struct volume_group *vg = NULL;
        struct format_instance *tf;
+       struct format_instance_ctx fic;
        time_t when;
        char *desc;
-       void *context;
 
        log_print(" ");
        log_print("File:\t\t%s", af->path);
 
-       if (!(context = create_text_context(cmd, af->path, NULL)) ||
-           !(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, NULL,
-                                                        NULL, context))) {
+       fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_PRIVATE_MDAS;
+       if (!(fic.context.private = create_text_context(cmd, af->path, NULL)) ||
+           !(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, &fic))) {
                log_error("Couldn't create text instance object.");
                return;
        }
index 2d47ff5e887a8f7f6a03ad27fabe0e9c3803739c..84119652640f34681f3eb2540487ceec6ab61703 100644 (file)
@@ -270,13 +270,12 @@ struct volume_group *backup_read_vg(struct cmd_context *cmd,
 {
        struct volume_group *vg = NULL;
        struct format_instance *tf;
+       struct format_instance_ctx fic;
        struct metadata_area *mda;
-       void *context;
 
-       if (!(context = create_text_context(cmd, file,
-                                           cmd->cmd_line)) ||
-           !(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, NULL,
-                                                        NULL, context))) {
+       fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_PRIVATE_MDAS;
+       if (!(fic.context.private = create_text_context(cmd, file, cmd->cmd_line)) ||
+           !(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, &fic))) {
                log_error("Couldn't create text format object.");
                return NULL;
        }
@@ -297,6 +296,8 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
        struct pv_list *pvl;
        struct physical_volume *pv;
        struct lvmcache_info *info;
+       struct format_instance *fid;
+       struct format_instance_ctx fic;
 
        /*
         * FIXME: Check that the PVs referenced in the backup are
@@ -304,8 +305,10 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
         */
 
        /* Attempt to write out using currently active format */
-       if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, vg->name,
-                                                      NULL, NULL))) {
+       fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
+       fic.context.vg_ref.vg_name = vg->name;
+       fic.context.vg_ref.vg_id = NULL;
+       if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, &fic))) {
                log_error("Failed to allocate format instance");
                return 0;
        }
@@ -386,17 +389,17 @@ int backup_to_file(const char *file, const char *desc, struct volume_group *vg)
 {
        int r = 0;
        struct format_instance *tf;
+       struct format_instance_ctx fic;
        struct metadata_area *mda;
-       void *context;
        struct cmd_context *cmd;
 
        cmd = vg->cmd;
 
        log_verbose("Creating volume group backup \"%s\" (seqno %u).", file, vg->seqno);
 
-       if (!(context = create_text_context(cmd, file, desc)) ||
-           !(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, NULL,
-                                                        NULL, context))) {
+       fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_PRIVATE_MDAS;
+       if (!(fic.context.private = create_text_context(cmd, file, desc)) ||
+           !(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, &fic))) {
                log_error("Couldn't create backup object.");
                return 0;
        }
index 88f9bad786dba150299127e92a4b03a383c65cf1..a3d7dbc83ee06da163d6b497a96e79161a60b851 100644 (file)
@@ -1056,6 +1056,7 @@ static int _scan_file(const struct format_type *fmt, const char *vgname)
        DIR *d;
        struct volume_group *vg;
        struct format_instance *fid;
+       struct format_instance_ctx fic;
        char path[PATH_MAX];
        char *scanned_vgname;
 
@@ -1086,8 +1087,10 @@ static int _scan_file(const struct format_type *fmt, const char *vgname)
                                }
 
                                /* FIXME stat file to see if it's changed */
-                               fid = _text_create_text_instance(fmt, NULL, NULL,
-                                                           NULL);
+                               /* FIXME: Check this fid is OK! */
+                               fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_PRIVATE_MDAS;
+                               fic.context.private = NULL;
+                               fid = _text_create_text_instance(fmt, &fic);
                                if ((vg = _vg_read_file_name(fid, scanned_vgname,
                                                             path))) {
                                        /* FIXME Store creation host in vg */
index 37d7f489545ec9196a118fb1eee448b774d3118e..06969974815fabd80156ed3b03acaf09b00b6626 100644 (file)
@@ -906,6 +906,7 @@ int vg_has_unknown_segments(const struct volume_group *vg)
 struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name)
 {
        struct volume_group *vg;
+       struct format_instance_ctx fic;
        int consistent = 0;
        struct dm_pool *mem;
        uint32_t rc;
@@ -979,8 +980,10 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name)
        /* initialize removed_pvs list */
        dm_list_init(&vg->removed_pvs);
 
-       if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, vg_name,
-                                                      NULL, NULL))) {
+       fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
+       fic.context.vg_ref.vg_name = vg_name;
+       fic.context.vg_ref.vg_id = NULL;
+       if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, &fic))) {
                log_error("Failed to create format instance");
                goto bad;
        }
@@ -2604,6 +2607,7 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
                                             int warnings,
                                             const char *orphan_vgname)
 {
+       struct format_instance_ctx fic;
        struct lvmcache_vginfo *vginfo;
        struct lvmcache_info *info;
        struct pv_list *pvl;
@@ -2635,9 +2639,10 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd,
        }
 
        /* create format instance with appropriate metadata area */
-       if (!(vg->fid = vginfo->fmt->ops->create_instance(vginfo->fmt,
-                                                         orphan_vgname, NULL,
-                                                         NULL))) {
+       fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_AUX_MDAS;
+       fic.context.vg_ref.vg_name = orphan_vgname;
+       fic.context.vg_ref.vg_id = NULL;
+       if (!(vg->fid = vginfo->fmt->ops->create_instance(vginfo->fmt, &fic))) {
                log_error("Failed to create format instance");
                goto bad;
        }
@@ -2742,6 +2747,7 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
                                     int *consistent, unsigned precommitted)
 {
        struct format_instance *fid;
+       struct format_instance_ctx fic;
        const struct format_type *fmt;
        struct volume_group *vg, *correct_vg = NULL;
        struct metadata_area *mda;
@@ -2814,7 +2820,10 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
                use_precommitted = 0;
 
        /* create format instance with appropriate metadata area */
-       if (!(fid = fmt->ops->create_instance(fmt, vgname, vgid, NULL))) {
+       fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
+       fic.context.vg_ref.vg_name = vgname;
+       fic.context.vg_ref.vg_id = vgid;
+       if (!(fid = fmt->ops->create_instance(fmt, &fic))) {
                log_error("Failed to create format instance");
                return NULL;
        }
@@ -2969,7 +2978,10 @@ static struct volume_group *_vg_read(struct cmd_context *cmd,
                        use_precommitted = 0;
 
                /* create format instance with appropriate metadata area */
-               if (!(fid = fmt->ops->create_instance(fmt, vgname, vgid, NULL))) {
+               fic.type = FMT_INSTANCE_VG | FMT_INSTANCE_MDAS | FMT_INSTANCE_AUX_MDAS;
+               fic.context.vg_ref.vg_name = vgname;
+               fic.context.vg_ref.vg_id = vgid;
+               if (!(fid = fmt->ops->create_instance(fmt, &fic))) {
                        log_error("Failed to create format instance");
                        return NULL;
                }
This page took 0.043189 seconds and 5 git commands to generate.