2001-10-02 21:09:05 +04:00
/*
2004-03-30 23:35:44 +04:00
* Copyright ( C ) 2001 - 2004 Sistina Software , Inc . All rights reserved .
2012-03-03 22:32:53 +04:00
* Copyright ( C ) 2004 - 2012 Red Hat , Inc . All rights reserved .
2001-10-02 21:09:05 +04:00
*
2004-03-30 23:35:44 +04:00
* This file is part of LVM2 .
2001-10-02 21:09:05 +04:00
*
2004-03-30 23:35:44 +04:00
* This copyrighted material is made available to anyone wishing to use ,
* modify , copy , or redistribute it subject to the terms and conditions
2007-08-21 00:55:30 +04:00
* of the GNU Lesser General Public License v .2 .1 .
2001-10-02 21:09:05 +04:00
*
2007-08-21 00:55:30 +04:00
* You should have received a copy of the GNU Lesser General Public License
2004-03-30 23:35:44 +04:00
* along with this program ; if not , write to the Free Software Foundation ,
2016-01-21 13:49:46 +03:00
* Inc . , 51 Franklin Street , Fifth Floor , Boston , MA 02110 - 1301 USA
2001-10-02 21:09:05 +04:00
*/
# include "tools.h"
2012-02-23 17:11:07 +04:00
# include "lvmetad.h"
# include "lvmcache.h"
2015-10-19 21:58:43 +03:00
struct pvscan_params {
int new_pvs_found ;
int pvs_found ;
uint64_t size_total ;
uint64_t size_new ;
unsigned pv_max_name_len ;
unsigned vg_max_name_len ;
unsigned pv_tmp_namelen ;
char * pv_tmp_name ;
} ;
static int _pvscan_display_single ( struct cmd_context * cmd ,
struct physical_volume * pv ,
struct pvscan_params * params )
2002-11-18 17:04:08 +03:00
{
2014-03-19 03:17:36 +04:00
/* XXXXXX-XXXX-XXXX-XXXX-XXXX-XXXX-XXXXXX */
char uuid [ 40 ] __attribute__ ( ( aligned ( 8 ) ) ) ;
2015-10-19 21:58:43 +03:00
const unsigned suffix_len = sizeof ( uuid ) + 10 ;
unsigned pv_len ;
2014-03-19 03:17:36 +04:00
const char * pvdevname = pv_dev_name ( pv ) ;
2002-11-18 17:04:08 +03:00
/* short listing? */
if ( arg_count ( cmd , short_ARG ) > 0 ) {
2014-03-19 03:19:01 +04:00
log_print_unless_silent ( " %s " , pvdevname ) ;
2015-10-19 21:58:43 +03:00
return ECMD_PROCESSED ;
2002-11-18 17:04:08 +03:00
}
2015-10-19 21:58:43 +03:00
if ( ! params - > pv_max_name_len ) {
lvmcache_get_max_name_lengths ( cmd , & params - > pv_max_name_len , & params - > vg_max_name_len ) ;
2002-11-18 17:04:08 +03:00
2015-10-19 21:58:43 +03:00
params - > pv_max_name_len + = 2 ;
params - > vg_max_name_len + = 2 ;
params - > pv_tmp_namelen = params - > pv_max_name_len + suffix_len ;
2002-11-18 17:04:08 +03:00
2015-10-19 21:58:43 +03:00
if ( ! ( params - > pv_tmp_name = dm_pool_alloc ( cmd - > mem , params - > pv_tmp_namelen ) ) )
return ECMD_FAILED ;
2002-11-18 17:04:08 +03:00
}
2015-10-19 21:58:43 +03:00
pv_len = params - > pv_max_name_len ;
memset ( params - > pv_tmp_name , 0 , params - > pv_tmp_namelen ) ;
2002-11-18 17:04:08 +03:00
if ( arg_count ( cmd , uuid_ARG ) ) {
if ( ! id_write_format ( & pv - > id , uuid , sizeof ( uuid ) ) ) {
stack ;
2015-10-19 21:58:43 +03:00
return ECMD_FAILED ;
2002-11-18 17:04:08 +03:00
}
2015-10-19 21:58:43 +03:00
if ( dm_snprintf ( params - > pv_tmp_name , params - > pv_tmp_namelen , " %-*s with UUID %s " ,
params - > pv_max_name_len - 2 , pvdevname , uuid ) < 0 ) {
2014-03-19 03:17:36 +04:00
log_error ( " Invalid PV name with uuid. " ) ;
2015-10-19 21:58:43 +03:00
return ECMD_FAILED ;
2014-03-19 03:17:36 +04:00
}
2015-10-19 21:58:43 +03:00
pvdevname = params - > pv_tmp_name ;
pv_len + = suffix_len ;
2002-11-18 17:04:08 +03:00
}
2014-03-19 03:17:36 +04:00
if ( is_orphan ( pv ) )
config: add silent mode
Accept -q as the short form of --quiet.
Suppress non-essential standard output if -q is given twice.
Treat log/silent in lvm.conf as equivalent to -qq.
Review all log_print messages and change some to
log_print_unless_silent.
When silent, the following commands still produce output:
dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay,
pvs, version, vgcfgrestore -l, vgdisplay, vgs.
[Needs checking.]
Non-essential messages are shifted from log level 4 to log level 5
for syslog and lvm2_log_fn purposes.
2012-08-25 23:35:48 +04:00
log_print_unless_silent ( " PV %-*s %-*s %s [%s] " ,
2014-03-19 03:17:36 +04:00
pv_len , pvdevname ,
2015-10-19 21:58:43 +03:00
params - > vg_max_name_len , " " ,
config: add silent mode
Accept -q as the short form of --quiet.
Suppress non-essential standard output if -q is given twice.
Treat log/silent in lvm.conf as equivalent to -qq.
Review all log_print messages and change some to
log_print_unless_silent.
When silent, the following commands still produce output:
dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay,
pvs, version, vgcfgrestore -l, vgdisplay, vgs.
[Needs checking.]
Non-essential messages are shifted from log level 4 to log level 5
for syslog and lvm2_log_fn purposes.
2012-08-25 23:35:48 +04:00
pv - > fmt ? pv - > fmt - > name : " " ,
display_size ( cmd , pv_size ( pv ) ) ) ;
2014-03-19 03:17:36 +04:00
else if ( pv_status ( pv ) & EXPORTED_VG )
log_print_unless_silent ( " PV %-*s is in exported VG %s [%s / %s free] " ,
pv_len , pvdevname , pv_vg_name ( pv ) ,
display_size ( cmd , ( uint64_t ) pv_pe_count ( pv ) * pv_pe_size ( pv ) ) ,
display_size ( cmd , ( uint64_t ) ( pv_pe_count ( pv ) - pv_pe_alloc_count ( pv ) ) * pv_pe_size ( pv ) ) ) ;
else
log_print_unless_silent ( " PV %-*s VG %-*s %s [%s / %s free] " ,
pv_len , pvdevname ,
2015-10-19 21:58:43 +03:00
params - > vg_max_name_len , pv_vg_name ( pv ) ,
2014-03-19 03:17:36 +04:00
pv - > fmt ? pv - > fmt - > name : " " ,
config: add silent mode
Accept -q as the short form of --quiet.
Suppress non-essential standard output if -q is given twice.
Treat log/silent in lvm.conf as equivalent to -qq.
Review all log_print messages and change some to
log_print_unless_silent.
When silent, the following commands still produce output:
dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay,
pvs, version, vgcfgrestore -l, vgdisplay, vgs.
[Needs checking.]
Non-essential messages are shifted from log level 4 to log level 5
for syslog and lvm2_log_fn purposes.
2012-08-25 23:35:48 +04:00
display_size ( cmd , ( uint64_t ) pv_pe_count ( pv ) * pv_pe_size ( pv ) ) ,
display_size ( cmd , ( uint64_t ) ( pv_pe_count ( pv ) - pv_pe_alloc_count ( pv ) ) * pv_pe_size ( pv ) ) ) ;
2015-10-19 21:58:43 +03:00
return ECMD_PROCESSED ;
}
static int _pvscan_single ( struct cmd_context * cmd , struct volume_group * vg ,
struct physical_volume * pv , struct processing_handle * handle )
{
struct pvscan_params * params = ( struct pvscan_params * ) handle - > custom_handle ;
if ( ( arg_count ( cmd , exported_ARG ) & & ! ( pv_status ( pv ) & EXPORTED_VG ) ) | |
( arg_count ( cmd , novolumegroup_ARG ) & & ( ! is_orphan ( pv ) ) ) ) {
return ECMD_PROCESSED ;
}
params - > pvs_found + + ;
if ( is_orphan ( pv ) ) {
params - > new_pvs_found + + ;
params - > size_new + = pv_size ( pv ) ;
params - > size_total + = pv_size ( pv ) ;
} else {
params - > size_total + = ( uint64_t ) pv_pe_count ( pv ) * pv_pe_size ( pv ) ;
}
_pvscan_display_single ( cmd , pv , params ) ;
return ECMD_PROCESSED ;
2002-11-18 17:04:08 +03:00
}
2013-11-12 13:55:34 +04:00
# define REFRESH_BEFORE_AUTOACTIVATION_RETRIES 5
# define REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY 100000
2012-12-12 15:51:28 +04:00
static int _auto_activation_handler ( struct cmd_context * cmd ,
2014-03-14 15:07:41 +04:00
const char * vgname , const char * vgid ,
2014-03-14 13:44:14 +04:00
int partial , int changed ,
2012-08-21 17:49:23 +04:00
activation_change_t activate )
2012-06-27 17:35:11 +04:00
{
2013-11-12 13:55:34 +04:00
unsigned int refresh_retries = REFRESH_BEFORE_AUTOACTIVATION_RETRIES ;
int refresh_done = 0 ;
2012-12-12 15:51:28 +04:00
struct volume_group * vg ;
struct id vgid_raw ;
2013-09-03 18:45:18 +04:00
int r = 0 ;
2012-12-12 15:51:28 +04:00
2012-06-27 17:35:11 +04:00
/* TODO: add support for partial and clustered VGs */
2012-12-12 15:51:28 +04:00
if ( partial )
2012-06-27 17:35:11 +04:00
return 1 ;
2013-04-29 14:34:50 +04:00
if ( ! id_read_format ( & vgid_raw , vgid ) )
return_0 ;
2013-09-03 18:45:18 +04:00
/* NB. This is safe because we know lvmetad is running and we won't hit disk. */
2015-03-05 23:00:44 +03:00
vg = vg_read ( cmd , vgname , ( const char * ) & vgid_raw , 0 , 0 ) ;
2014-03-14 15:07:41 +04:00
if ( vg_read_error ( vg ) ) {
log_error ( " Failed to read Volume Group \" %s \" (%s) during autoactivation. " , vgname , vgid ) ;
release_vg ( vg ) ;
return 0 ;
}
2012-12-12 15:51:28 +04:00
if ( vg_is_clustered ( vg ) ) {
2013-09-03 18:45:18 +04:00
r = 1 ; goto out ;
}
2013-11-12 13:55:34 +04:00
/* FIXME: There's a tiny race when suspending the device which is part
* of the refresh because when suspend ioctl is performed , the dm
* kernel driver executes ( do_suspend and dm_suspend kernel fn ) :
*
* step 1 : a check whether the dev is already suspended and
* if yes it returns success immediately as there ' s
* nothing to do
* step 2 : it grabs the suspend lock
* step 3 : another check whether the dev is already suspended
* and if found suspended , it exits with - EINVAL now
*
* The race can occur in between step 1 and step 2. To prevent premature
* autoactivation failure , we ' re using a simple retry logic here before
* we fail completely . For a complete solution , we need to fix the
* locking so there ' s no possibility for suspend calls to interleave
* each other to cause this kind of race .
*
* Remove this workaround with " refresh_retries " once we have proper locking in !
*/
2014-03-14 13:44:14 +04:00
if ( changed ) {
while ( refresh_retries - - ) {
if ( vg_refresh_visible ( vg - > cmd , vg ) ) {
refresh_done = 1 ;
break ;
}
usleep ( REFRESH_BEFORE_AUTOACTIVATION_RETRY_USLEEP_DELAY ) ;
2013-11-12 13:55:34 +04:00
}
2014-03-14 13:44:14 +04:00
if ( ! refresh_done )
log_warn ( " %s: refresh before autoactivation failed. " , vg - > name ) ;
}
2012-12-12 15:51:28 +04:00
2012-06-27 17:35:11 +04:00
if ( ! vgchange_activate ( vg - > cmd , vg , activate ) ) {
log_error ( " %s: autoactivation failed. " , vg - > name ) ;
2013-09-03 18:45:18 +04:00
goto out ;
2012-06-27 17:35:11 +04:00
}
2016-01-07 17:17:08 +03:00
/*
* After sucessfull activation we need to initialise polling
* for all activated LVs in a VG . Possible enhancement would
* be adding - - poll y | n cmdline option for pvscan and call
* init_background_polling routine in autoactivation handler .
*/
if ( ! ( vgchange_background_polling ( vg - > cmd , vg ) ) )
goto_out ;
2013-09-03 18:45:18 +04:00
r = 1 ;
out :
2014-03-14 15:07:41 +04:00
unlock_and_release_vg ( cmd , vg , vgname ) ;
2013-09-03 18:45:18 +04:00
return r ;
2012-06-27 17:35:11 +04:00
}
2013-10-22 15:52:18 +04:00
static int _clear_dev_from_lvmetad_cache ( dev_t devno , int32_t major , int32_t minor ,
activation_handler handler )
{
2014-06-16 14:38:14 +04:00
char buf [ 24 ] ;
2013-10-22 15:52:18 +04:00
2015-07-06 17:09:17 +03:00
( void ) dm_snprintf ( buf , sizeof ( buf ) , FMTi32 " : " FMTi32 , major , minor ) ;
2014-06-16 14:38:14 +04:00
if ( ! lvmetad_pv_gone ( devno , buf , handler ) )
return_0 ;
2013-10-22 15:52:18 +04:00
log_print_unless_silent ( " Device %s not found. "
2014-06-16 14:38:14 +04:00
" Cleared from lvmetad cache. " , buf ) ;
2013-10-22 15:52:18 +04:00
return 1 ;
}
2012-03-03 22:32:53 +04:00
static int _pvscan_lvmetad ( struct cmd_context * cmd , int argc , char * * argv )
{
int ret = ECMD_PROCESSED ;
struct device * dev ;
const char * pv_name ;
2012-03-06 06:30:49 +04:00
int32_t major = - 1 ;
int32_t minor = - 1 ;
int devno_args = 0 ;
struct arg_value_group_list * current_group ;
2012-03-03 22:32:53 +04:00
dev_t devno ;
2012-06-27 16:59:34 +04:00
activation_handler handler = NULL ;
2012-03-06 06:30:49 +04:00
2015-02-26 00:41:15 +03:00
cmd - > include_foreign_vgs = 1 ;
2012-11-09 18:56:57 +04:00
/*
* Return here immediately if lvmetad is not used .
* Also return if locking_type = 3 ( clustered ) as we
* dont ' t support cluster + lvmetad yet .
*
* This is to avoid taking the global lock uselessly
* and to prevent hangs in clustered environment .
*/
/* TODO: Remove this once lvmetad + cluster supported! */
2014-04-18 05:13:46 +04:00
if ( ! lvmetad_used ( ) ) {
log_verbose ( " Ignoring pvscan --cache command because lvmetad is not in use. " ) ;
2012-11-09 18:56:57 +04:00
return ret ;
}
2012-06-27 17:35:11 +04:00
if ( arg_count ( cmd , activate_ARG ) ) {
if ( arg_uint_value ( cmd , activate_ARG , CHANGE_AAY ) ! = CHANGE_AAY ) {
log_error ( " Only --activate ay allowed with pvscan. " ) ;
return 0 ;
}
handler = _auto_activation_handler ;
}
2012-03-06 06:30:49 +04:00
if ( arg_count ( cmd , major_ARG ) + arg_count ( cmd , minor_ARG ) )
devno_args = 1 ;
2012-03-03 22:32:53 +04:00
2012-03-06 06:30:49 +04:00
if ( devno_args & & ( ! arg_count ( cmd , major_ARG ) | | ! arg_count ( cmd , minor_ARG ) ) ) {
log_error ( " Both --major and --minor required to identify devices. " ) ;
return EINVALID_CMD_LINE ;
}
2013-03-18 00:29:58 +04:00
if ( ! lock_vol ( cmd , VG_GLOBAL , LCK_VG_READ , NULL ) ) {
2012-03-02 20:58:41 +04:00
log_error ( " Unable to obtain global lock. " ) ;
return ECMD_FAILED ;
}
2012-03-06 06:30:49 +04:00
/* Scan everything? */
if ( ! argc & & ! devno_args ) {
2012-09-10 00:05:59 +04:00
if ( ! lvmetad_pvscan_all_devs ( cmd , handler ) )
2012-03-03 22:32:53 +04:00
ret = ECMD_FAILED ;
goto out ;
}
2012-03-02 20:58:41 +04:00
log_verbose ( " Using physical volume(s) on command line " ) ;
2012-03-03 22:32:53 +04:00
2012-03-06 06:30:49 +04:00
/* Process any command line PVs first. */
2012-03-02 20:58:41 +04:00
while ( argc - - ) {
2012-03-03 22:32:53 +04:00
pv_name = * argv + + ;
2013-10-22 15:52:18 +04:00
if ( pv_name [ 0 ] = = ' / ' ) {
/* device path */
if ( ! ( dev = dev_cache_get ( pv_name , cmd - > lvmetad_filter ) ) ) {
2015-01-12 15:50:11 +03:00
if ( ( dev = dev_cache_get ( pv_name , NULL ) ) ) {
if ( ! _clear_dev_from_lvmetad_cache ( dev - > dev , MAJOR ( dev - > dev ) , MINOR ( dev - > dev ) , handler ) ) {
stack ;
ret = ECMD_FAILED ;
break ;
}
} else {
log_error ( " Physical Volume %s not found. " , pv_name ) ;
ret = ECMD_FAILED ;
break ;
}
2013-10-22 15:52:18 +04:00
continue ;
}
}
else {
/* device major:minor */
if ( sscanf ( pv_name , " %d:%d " , & major , & minor ) ! = 2 ) {
log_error ( " Failed to parse major:minor from %s " , pv_name ) ;
ret = ECMD_FAILED ;
continue ;
}
2015-05-07 12:03:48 +03:00
devno = MKDEV ( ( dev_t ) major , ( dev_t ) minor ) ;
2013-10-22 15:52:18 +04:00
if ( ! ( dev = dev_cache_get_by_devt ( devno , cmd - > lvmetad_filter ) ) ) {
if ( ! ( _clear_dev_from_lvmetad_cache ( devno , major , minor , handler ) ) ) {
stack ;
ret = ECMD_FAILED ;
break ;
}
continue ;
}
2012-03-06 06:30:49 +04:00
}
2013-07-01 18:30:12 +04:00
if ( sigint_caught ( ) ) {
2012-03-06 06:30:49 +04:00
ret = ECMD_FAILED ;
2013-07-01 18:30:12 +04:00
stack ;
2012-03-06 06:30:49 +04:00
break ;
}
2015-03-10 21:56:25 +03:00
if ( ! lvmetad_pvscan_single ( cmd , dev , handler , 0 ) ) {
2013-07-01 18:30:12 +04:00
ret = ECMD_FAILED ;
stack ;
2012-03-06 06:30:49 +04:00
break ;
2013-07-01 18:30:12 +04:00
}
2012-03-06 06:30:49 +04:00
}
if ( ! devno_args )
goto out ;
/* Process any grouped --major --minor args */
dm_list_iterate_items ( current_group , & cmd - > arg_value_groups ) {
major = grouped_arg_int_value ( current_group - > arg_values , major_ARG , major ) ;
minor = grouped_arg_int_value ( current_group - > arg_values , minor_ARG , minor ) ;
if ( major < 0 | | minor < 0 )
continue ;
2015-05-07 12:03:48 +03:00
devno = MKDEV ( ( dev_t ) major , ( dev_t ) minor ) ;
2012-03-06 06:30:49 +04:00
2013-07-22 17:03:56 +04:00
if ( ! ( dev = dev_cache_get_by_devt ( devno , cmd - > lvmetad_filter ) ) ) {
2013-10-22 15:52:18 +04:00
if ( ! ( _clear_dev_from_lvmetad_cache ( devno , major , minor , handler ) ) ) {
2012-03-06 06:30:49 +04:00
stack ;
2012-03-03 22:32:53 +04:00
ret = ECMD_FAILED ;
break ;
}
continue ;
}
2013-07-01 18:30:12 +04:00
if ( sigint_caught ( ) ) {
ret = ECMD_FAILED ;
stack ;
break ;
}
2015-03-10 21:56:25 +03:00
if ( ! lvmetad_pvscan_single ( cmd , dev , handler , 0 ) ) {
2012-03-02 20:58:41 +04:00
ret = ECMD_FAILED ;
2013-07-01 18:30:12 +04:00
stack ;
2012-03-02 20:58:41 +04:00
break ;
}
2012-03-03 22:32:53 +04:00
2012-03-02 20:58:41 +04:00
}
2012-03-03 22:32:53 +04:00
out :
2015-06-30 20:54:38 +03:00
if ( ! sync_local_dev_names ( cmd ) )
stack ;
2012-03-02 20:58:41 +04:00
unlock_vg ( cmd , VG_GLOBAL ) ;
return ret ;
}
2012-02-23 17:11:07 +04:00
int pvscan ( struct cmd_context * cmd , int argc , char * * argv )
2001-10-02 21:09:05 +04:00
{
2015-10-19 21:58:43 +03:00
struct pvscan_params params = { 0 } ;
struct processing_handle * handle = NULL ;
int ret ;
2001-10-02 21:09:05 +04:00
2014-09-29 22:43:11 +04:00
if ( arg_count ( cmd , cache_long_ARG ) )
2012-03-02 20:58:41 +04:00
return _pvscan_lvmetad ( cmd , argc , argv ) ;
2012-02-23 17:11:07 +04:00
2014-03-31 01:32:53 +04:00
if ( argc ) {
log_error ( " Too many parameters on command line. " ) ;
return EINVALID_CMD_LINE ;
}
2012-06-27 17:35:11 +04:00
if ( arg_count ( cmd , activate_ARG ) ) {
log_error ( " --activate is only valid with --cache. " ) ;
return EINVALID_CMD_LINE ;
}
2014-03-31 13:43:28 +04:00
if ( arg_count ( cmd , major_ARG ) | | arg_count ( cmd , minor_ARG ) ) {
2012-03-06 06:30:49 +04:00
log_error ( " --major and --minor are only valid with --cache. " ) ;
return EINVALID_CMD_LINE ;
}
2002-02-12 00:00:35 +03:00
if ( arg_count ( cmd , novolumegroup_ARG ) & & arg_count ( cmd , exported_ARG ) ) {
2001-10-16 22:07:54 +04:00
log_error ( " Options -e and -n are incompatible " ) ;
2001-10-05 02:53:37 +04:00
return EINVALID_CMD_LINE ;
2001-10-02 21:09:05 +04:00
}
2012-03-03 21:03:20 +04:00
if ( arg_count ( cmd , exported_ARG ) | | arg_count ( cmd , novolumegroup_ARG ) )
2007-06-28 21:33:44 +04:00
log_warn ( " WARNING: only considering physical volumes %s " ,
2002-02-12 00:00:35 +03:00
arg_count ( cmd , exported_ARG ) ?
2001-10-02 21:09:05 +04:00
" of exported volume group(s) " : " in no volume group " ) ;
2013-03-18 00:29:58 +04:00
if ( ! lock_vol ( cmd , VG_GLOBAL , LCK_VG_WRITE , NULL ) ) {
2007-08-23 19:02:26 +04:00
log_error ( " Unable to obtain global lock. " ) ;
return ECMD_FAILED ;
}
2015-03-05 23:00:44 +03:00
/* Needed for a current listing of the global VG namespace. */
if ( ! lockd_gl ( cmd , " sh " , 0 ) )
return_ECMD_FAILED ;
2001-10-02 21:09:05 +04:00
2015-10-19 21:58:43 +03:00
if ( ! ( handle = init_processing_handle ( cmd ) ) ) {
log_error ( " Failed to initialize processing handle. " ) ;
ret = ECMD_FAILED ;
goto out ;
2001-10-02 21:09:05 +04:00
}
2015-10-19 21:58:43 +03:00
handle - > custom_handle = & params ;
2001-10-02 21:09:05 +04:00
2016-02-16 23:15:24 +03:00
ret = process_each_pv ( cmd , argc , argv , NULL , 0 , 0 , handle , _pvscan_single ) ;
2001-10-02 21:09:05 +04:00
2015-10-19 21:58:43 +03:00
if ( ! params . pvs_found )
config: add silent mode
Accept -q as the short form of --quiet.
Suppress non-essential standard output if -q is given twice.
Treat log/silent in lvm.conf as equivalent to -qq.
Review all log_print messages and change some to
log_print_unless_silent.
When silent, the following commands still produce output:
dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay,
pvs, version, vgcfgrestore -l, vgdisplay, vgs.
[Needs checking.]
Non-essential messages are shifted from log level 4 to log level 5
for syslog and lvm2_log_fn purposes.
2012-08-25 23:35:48 +04:00
log_print_unless_silent ( " No matching physical volumes found " ) ;
2014-03-19 03:19:01 +04:00
else
log_print_unless_silent ( " Total: %d [%s] / in use: %d [%s] / in no VG: %d [%s] " ,
2015-10-19 21:58:43 +03:00
params . pvs_found ,
display_size ( cmd , params . size_total ) ,
params . pvs_found - params . new_pvs_found ,
display_size ( cmd , ( params . size_total - params . size_new ) ) ,
params . new_pvs_found , display_size ( cmd , params . size_new ) ) ;
2001-10-02 21:09:05 +04:00
2015-10-19 21:58:43 +03:00
out :
2007-08-23 19:02:26 +04:00
unlock_vg ( cmd , VG_GLOBAL ) ;
2015-10-19 21:58:43 +03:00
return ret ;
2001-10-02 21:09:05 +04:00
}