~registry/lvm2/master

« back to all changes in this revision

Viewing changes to lib/cache/lvmetad.c

  • Committer: Alasdair G Kergon
  • Date: 2013-01-04 23:45:22 UTC
  • Revision ID: git-v1:41e7f45258555bf28871a8243487a12751932842
lvmetad: rename device vars and move _token_update

Move _token_update() to avoid the need for _lvmetad_send prototype.

Use 'dev' consistently for a struct device * variable.
Use 'devno' for a dev_t.

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
        _lvmetad_socket = sock;
119
119
}
120
120
 
121
 
static daemon_reply _lvmetad_send(const char *id, ...);
122
 
 
123
 
static int _token_update(void)
124
 
{
125
 
        daemon_reply repl = _lvmetad_send("token_update", NULL);
126
 
 
127
 
        if (repl.error || strcmp(daemon_reply_str(repl, "response", ""), "OK")) {
128
 
                daemon_reply_destroy(repl);
129
 
                return 0;
130
 
        }
131
 
 
132
 
        daemon_reply_destroy(repl);
133
 
        return 1;
134
 
}
135
 
 
136
 
 
137
121
static daemon_reply _lvmetad_send(const char *id, ...)
138
122
{
139
123
        va_list ap;
167
151
        return repl;
168
152
}
169
153
 
 
154
static int _token_update(void)
 
155
{
 
156
        daemon_reply repl = _lvmetad_send("token_update", NULL);
 
157
 
 
158
        if (repl.error || strcmp(daemon_reply_str(repl, "response", ""), "OK")) {
 
159
                daemon_reply_destroy(repl);
 
160
                return 0;
 
161
        }
 
162
 
 
163
        daemon_reply_destroy(repl);
 
164
        return 1;
 
165
}
 
166
 
170
167
/*
171
168
 * Helper; evaluate the reply from lvmetad, check for errors, print diagnostics
172
169
 * and return a summary success/failure exit code.
222
219
static struct lvmcache_info *_pv_populate_lvmcache(
223
220
        struct cmd_context *cmd, struct dm_config_node *cn, dev_t fallback)
224
221
{
225
 
        struct device *device;
 
222
        struct device *dev;
226
223
        struct id pvid, vgid;
227
224
        char mda_id[32];
228
225
        char da_id[32];
246
243
                return NULL;
247
244
        }
248
245
 
249
 
        device = dev_cache_get_by_devt(devt, cmd->filter);
250
 
        if (!device && fallback)
251
 
                device = dev_cache_get_by_devt(fallback, cmd->filter);
 
246
        dev = dev_cache_get_by_devt(devt, cmd->filter);
 
247
        if (!dev && fallback)
 
248
                dev = dev_cache_get_by_devt(fallback, cmd->filter);
252
249
 
253
 
        if (!device) {
 
250
        if (!dev) {
254
251
                log_error("No device found for PV %s.", pvid_txt);
255
252
                return NULL;
256
253
        }
269
266
        if (!vgname)
270
267
                vgname = fmt->orphan_vg_name;
271
268
 
272
 
        if (!(info = lvmcache_add(fmt->labeller, (const char *)&pvid, device,
 
269
        if (!(info = lvmcache_add(fmt->labeller, (const char *)&pvid, dev,
273
270
                                  vgname, (const char *)&vgid, 0)))
274
271
                return_NULL;
275
272
 
680
677
        return 1;
681
678
}
682
679
 
683
 
int lvmetad_pv_found(const struct id *pvid, struct device *device, const struct format_type *fmt,
 
680
int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct format_type *fmt,
684
681
                     uint64_t label_sector, struct volume_group *vg, activation_handler handler)
685
682
{
686
683
        char uuid[64];
708
705
        }
709
706
 
710
707
        if (!config_make_nodes(pvmeta, pvmeta->root, NULL,
711
 
                               "device = %"PRId64, (int64_t) device->dev,
 
708
                               "device = %"PRId64, (int64_t) dev->dev,
712
709
                               "dev_size = %"PRId64, (int64_t) (info ? lvmcache_device_size(info) : 0),
713
710
                               "format = %s", fmt->name,
714
711
                               "label_sector = %"PRId64, (int64_t) label_sector,
768
765
        return result;
769
766
}
770
767
 
771
 
int lvmetad_pv_gone(dev_t device, const char *pv_name, activation_handler handler)
 
768
int lvmetad_pv_gone(dev_t devno, const char *pv_name, activation_handler handler)
772
769
{
773
770
        daemon_reply reply;
774
771
        int result;
784
781
         *        the whole stack from top to bottom (not yet upstream).
785
782
         */
786
783
 
787
 
        reply = _lvmetad_send("pv_gone", "device = %" PRId64, (int64_t) device, NULL);
 
784
        reply = _lvmetad_send("pv_gone", "device = %" PRId64, (int64_t) devno, NULL);
788
785
 
789
786
        result = _lvmetad_handle_reply(reply, "drop PV", pv_name, &found);
790
787
        /* We don't care whether or not the daemon had the PV cached. */