~registry/lvm2/master

« back to all changes in this revision

Viewing changes to daemons/lvmetad/lvmetad-core.c

  • Committer: Zdenek Kabelac
  • Date: 2012-12-17 12:49:19 UTC
  • Revision ID: git-v1:69099e7ef57eb2d39da836a5466196ec05123ffb
Revert "lvmetad: simplify pvid memory allocation."

This reverts commit ed23da95b63308e11f8d680b189686a5d2d380d0.

Hash table device_to_pvid  seems to contain references to
already deleted pvids and so revert to the older
behaviour using allocated memory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
        dm_hash_destroy(s->vgid_to_metadata);
68
68
        dm_hash_destroy(s->vgid_to_vgname);
69
69
        dm_hash_destroy(s->vgname_to_vgid);
 
70
 
 
71
        n = dm_hash_get_first(s->device_to_pvid);
 
72
        while (n) {
 
73
                dm_free(dm_hash_get_data(s->device_to_pvid, n));
 
74
                n = dm_hash_get_next(s->device_to_pvid, n);
 
75
        }
 
76
 
70
77
        dm_hash_destroy(s->device_to_pvid);
71
78
        dm_hash_destroy(s->pvid_to_vgid);
72
79
}
765
772
        const char *pvid = daemon_request_str(r, "uuid", NULL);
766
773
        int64_t device = daemon_request_int(r, "device", 0);
767
774
        struct dm_config_tree *pvmeta;
 
775
        char *pvid_old;
768
776
 
769
777
        DEBUGLOG(s, "pv_gone: %s / %" PRIu64, pvid, device);
770
778
 
779
787
        DEBUGLOG(s, "pv_gone (updated): %s / %" PRIu64, pvid, device);
780
788
 
781
789
        pvmeta = dm_hash_lookup(s->pvid_to_pvmeta, pvid);
 
790
        pvid_old = dm_hash_lookup_binary(s->device_to_pvid, &device, sizeof(device));
782
791
        dm_hash_remove_binary(s->device_to_pvid, &device, sizeof(device));
783
792
        dm_hash_remove(s->pvid_to_pvmeta, pvid);
784
793
        vg_remove_if_missing(s, dm_hash_lookup(s->pvid_to_vgid, pvid));
785
794
        unlock_pvid_to_pvmeta(s);
786
795
 
 
796
        if (pvid_old)
 
797
                dm_free(pvid_old);
 
798
 
787
799
        if (pvmeta) {
788
800
                dm_config_destroy(pvmeta);
789
801
                return daemon_reply_simple("OK", NULL);
818
830
        struct dm_config_node *pvmeta = dm_config_find_node(r.cft->root, "pvmeta");
819
831
        uint64_t device;
820
832
        struct dm_config_tree *cft, *pvmeta_old_dev = NULL, *pvmeta_old_pvid = NULL;
821
 
        const char *old;
822
 
        const char *pvid_dup;
 
833
        char *old;
 
834
        char *pvid_dup;
823
835
        int complete = 0, orphan = 0;
824
836
        int64_t seqno = -1, seqno_old = -1;
825
837
 
841
853
 
842
854
        DEBUGLOG(s, "pv_found %s, vgid = %s, device = %" PRIu64 ", old = %s", pvid, vgid, device, old);
843
855
 
 
856
        dm_free(old);
 
857
 
844
858
        if (!(cft = dm_config_create()) ||
845
859
            !(cft->root = dm_config_clone_node(cft, pvmeta, 0))) {
846
860
                unlock_pvid_to_pvmeta(s);
849
863
                return reply_fail("out of memory");
850
864
        }
851
865
 
852
 
        if (!(pvid_dup = dm_pool_strdup(dm_config_memory(cft), pvid))) {
 
866
        if (!(pvid_dup = dm_strdup(pvid))) {
853
867
                unlock_pvid_to_pvmeta(s);
854
868
                dm_config_destroy(cft);
855
869
                return reply_fail("out of memory");
860
874
                unlock_pvid_to_pvmeta(s);
861
875
                dm_hash_remove(s->pvid_to_pvmeta, pvid);
862
876
                dm_config_destroy(cft);
 
877
                dm_free(pvid_dup);
863
878
                return reply_fail("out of memory");
864
879
        }
865
880
        if (pvmeta_old_pvid)