~ubuntu-branches/debian/sid/lvm2/sid

« back to all changes in this revision

Viewing changes to tools/vgreduce.c

  • Committer: Package Import Robot
  • Author(s): Bastian Blank
  • Date: 2013-03-03 12:33:47 UTC
  • mfrom: (1.1.15)
  • Revision ID: package-import@ubuntu.com-20130303123347-smfwei6dodkdth55
Tags: 2.02.98-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 */
15
15
 
16
16
#include "tools.h"
17
 
#include "lv_alloc.h"
18
17
 
19
18
static int _remove_pv(struct volume_group *vg, struct pv_list *pvl, int silent)
20
19
{
125
124
        int r = ECMD_FAILED;
126
125
        const char *name = pv_dev_name(pv);
127
126
 
 
127
        if (!vg) {
 
128
                log_error(INTERNAL_ERROR "VG is NULL.");
 
129
                return ECMD_FAILED;
 
130
        }
 
131
 
128
132
        if (pv_pe_alloc_count(pv)) {
129
133
                log_error("Physical volume \"%s\" still in use", name);
130
134
                return ECMD_FAILED;
189
193
 
190
194
        backup(vg);
191
195
 
192
 
        log_print("Removed \"%s\" from volume group \"%s\"", name, vg->name);
 
196
        log_print_unless_silent("Removed \"%s\" from volume group \"%s\"", name, vg->name);
193
197
        r = ECMD_PROCESSED;
194
198
bad:
195
199
        if (pvl)
206
210
        int fixed = 1;
207
211
        int repairing = arg_count(cmd, removemissing_ARG);
208
212
        int saved_ignore_suspended_devices = ignore_suspended_devices();
 
213
        int locked = 0;
209
214
 
210
215
        if (!argc && !repairing) {
211
216
                log_error("Please give volume group name and "
260
265
            && !arg_count(cmd, removemissing_ARG))
261
266
                goto_out;
262
267
 
 
268
        locked = !vg_read_error(vg);
 
269
 
263
270
        if (repairing) {
264
271
                if (!vg_read_error(vg) && !vg_missing_pv_count(vg)) {
265
272
                        log_error("Volume group \"%s\" is already consistent",
275
282
                                        READ_ALLOW_INCONSISTENT
276
283
                                        | READ_ALLOW_EXPORTED);
277
284
 
 
285
                locked |= !vg_read_error(vg);
278
286
                if (vg_read_error(vg) && vg_read_error(vg) != FAILED_READ_ONLY
279
287
                    && vg_read_error(vg) != FAILED_INCONSISTENT)
280
288
                        goto_out;
296
304
                backup(vg);
297
305
 
298
306
                if (fixed) {
299
 
                        log_print("Wrote out consistent volume group %s",
300
 
                                  vg_name);
 
307
                        log_print_unless_silent("Wrote out consistent volume group %s",
 
308
                                                vg_name);
301
309
                        ret = ECMD_PROCESSED;
302
310
                } else
303
311
                        ret = ECMD_FAILED;
314
322
        }
315
323
out:
316
324
        init_ignore_suspended_devices(saved_ignore_suspended_devices);
317
 
        unlock_and_release_vg(cmd, vg, vg_name);
 
325
        if (locked)
 
326
                unlock_vg(cmd, vg_name);
 
327
 
 
328
        release_vg(vg);
318
329
 
319
330
        return ret;
320
331