]>
sourceware.org Git - lvm2.git/blob - tools/vgimport.c
d94b113144a5a76270bce48f1bbd8ad46b44a50c
2 * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
3 * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved.
5 * This file is part of LVM2.
7 * This copyrighted material is made available to anyone wishing to use,
8 * modify, copy, or redistribute it subject to the terms and conditions
9 * of the GNU Lesser General Public License v.2.1.
11 * You should have received a copy of the GNU Lesser General Public License
12 * along with this program; if not, write to the Free Software Foundation,
13 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 #include "lib/label/hints.h"
19 static int _vgimport_single(struct cmd_context
*cmd
,
21 struct volume_group
*vg
,
22 struct processing_handle
*handle
__attribute__((unused
)))
25 struct physical_volume
*pv
;
27 if (!vg_is_exported(vg
)) {
28 log_error("Volume group \"%s\" is not exported", vg_name
);
32 if (vg_status(vg
) & PARTIAL_VG
) {
33 log_error("Volume group \"%s\" is partially missing", vg_name
);
37 vg
->status
&= ~EXPORTED_VG
;
39 if (!vg_is_shared(vg
))
40 vg
->system_id
= cmd
->system_id
? dm_pool_strdup(vg
->vgmem
, cmd
->system_id
) : NULL
;
42 dm_list_iterate_items(pvl
, &vg
->pvs
) {
44 pv
->status
&= ~EXPORTED_VG
;
47 if (!vg_write(vg
) || !vg_commit(vg
))
50 log_print_unless_silent("Volume group \"%s\" successfully imported", vg
->name
);
53 * This is not necessary for any normal, known cases, but it could be
54 * associated with some unconventional method of sharing disks. Hints
55 * should be disabled when sharing disks, but this might help.
57 invalidate_hints(cmd
);
59 return ECMD_PROCESSED
;
65 int vgimport(struct cmd_context
*cmd
, int argc
, char **argv
)
67 if (!argc
&& !arg_is_set(cmd
, all_ARG
) && !arg_is_set(cmd
, select_ARG
)) {
68 log_error("Please supply volume groups or -S for selection or use -a for all.");
69 return EINVALID_CMD_LINE
;
72 if (arg_is_set(cmd
, all_ARG
) && (argc
|| arg_is_set(cmd
, select_ARG
))) {
73 log_error("No arguments permitted when using -a for all.");
74 return EINVALID_CMD_LINE
;
77 if (arg_is_set(cmd
, force_ARG
)) {
79 * The volume group cannot be repaired unless it is first
80 * imported. If we don't allow the user a way to import the
81 * VG while it is 'partial', then we will have created a
82 * circular dependency.
84 * The reason we don't just simply set 'handles_missing_pvs'
85 * by default is that we want to guard against the case
86 * where the user simply forgot to move one or more disks in
87 * the VG before running 'vgimport'.
89 log_warn("WARNING: Volume groups with missing PVs will be imported with --force.");
90 cmd
->handles_missing_pvs
= 1;
93 return process_each_vg(cmd
, argc
, argv
, NULL
, NULL
, READ_FOR_UPDATE
,
94 0, NULL
, &_vgimport_single
);
This page took 0.046646 seconds and 6 git commands to generate.