2002-02-25 15:02:33 +03:00
/*
2004-03-30 23:35:44 +04:00
* Copyright ( C ) 2002 - 2004 Sistina Software , Inc . All rights reserved .
2012-01-12 05:51:56 +04:00
* Copyright ( C ) 2004 - 2012 Red Hat , Inc . All rights reserved .
2002-02-25 15:02:33 +03:00
*
2004-03-30 23:35:44 +04:00
* This file is part of LVM2 .
*
* 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 .
2004-03-30 23:35:44 +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
2002-02-25 15:02:33 +03:00
*/
# ifndef _LVM_DEV_MANAGER_H
# define _LVM_DEV_MANAGER_H
2018-05-14 12:30:20 +03:00
# include "lib/metadata/metadata-exported.h"
2009-10-01 04:35:29 +04:00
2004-05-05 01:25:57 +04:00
struct logical_volume ;
2011-06-17 18:14:19 +04:00
struct lv_activate_opts ;
2005-10-25 23:08:21 +04:00
struct volume_group ;
2004-05-05 01:25:57 +04:00
struct cmd_context ;
2002-02-25 15:02:33 +03:00
struct dev_manager ;
2003-03-24 21:08:53 +03:00
struct dm_info ;
2005-10-25 23:08:21 +04:00
struct device ;
2014-11-04 17:00:32 +03:00
struct lv_seg_status ;
2002-02-25 15:02:33 +03:00
2018-03-08 12:27:04 +03:00
int read_only_lv ( const struct logical_volume * lv , const struct lv_activate_opts * laopts , const char * layer ) ;
2012-01-12 05:51:56 +04:00
lvresize: add new options and defaults for fs handling
The new option "--fs String" for lvresize/lvreduce/lvextend
controls the handling of file systems before/after resizing
the LV. --resizefs is the same as --fs resize.
The new option "--fsmode String" can be used to control
mounting and unmounting of the fs during resizing.
Possible --fs values:
checksize
Only applies to reducing size; does nothing for extend.
Check the fs size and reduce the LV if the fs is not using
the affected space, i.e. the fs does not need to be shrunk.
Fail the command without reducing the fs or LV if the fs is
using the affected space.
resize
Resize the fs using the fs-specific resize command.
This may include mounting, unmounting, or running fsck.
See --fsmode to control mounting behavior, and --nofsck to
disable fsck.
resize_fsadm
Use the old method of calling fsadm to handle the fs
(deprecated.) Warning: this option does not prevent lvreduce
from destroying file systems that are unmounted (or mounted
if prompts are skipped.)
ignore
Resize the LV without checking for or handling a file system.
Warning: using ignore when reducing the LV size may destroy the
file system.
Possible --fsmode values:
manage
Mount or unmount the fs as needed to resize the fs,
and attempt to restore the original mount state at the end.
nochange
Do not mount or unmount the fs. If mounting or unmounting
is required to resize the fs, then do not resize the fs or
the LV and fail the command.
offline
Unmount the fs if it is mounted, and resize the fs while it
is unmounted. If mounting is required to resize the fs,
then do not resize the fs or the LV and fail the command.
Notes on lvreduce:
When no --fs or --resizefs option is specified:
. lvextend default behavior is fs ignore.
. lvreduce default behavior is fs checksize
(includes activating the LV.)
With the exception of --fs resize_fsadm|ignore, lvreduce requires
the recent libblkid fields FSLASTBLOCK and FSBLOCKSIZE.
FSLASTBLOCK*FSBLOCKSIZE is the last byte used by the fs on the LV,
which determines if reducing the fs is necessary.
2022-06-14 23:20:21 +03:00
int get_crypt_table_offset ( dev_t crypt_devt , uint32_t * offset_bytes ) ;
2002-02-25 15:02:33 +03:00
/*
* Constructor and destructor .
*/
2004-05-05 01:25:57 +04:00
struct dev_manager * dev_manager_create ( struct cmd_context * cmd ,
2011-06-11 04:03:06 +04:00
const char * vg_name ,
unsigned track_pvmove_deps ) ;
2002-02-25 15:02:33 +03:00
void dev_manager_destroy ( struct dev_manager * dm ) ;
2006-05-16 20:48:31 +04:00
void dev_manager_release ( void ) ;
2003-07-05 02:34:56 +04:00
void dev_manager_exit ( void ) ;
2002-02-25 15:02:33 +03:00
/*
* The device handler is responsible for creating all the layered
* dm devices , and ensuring that all constraints are maintained
* ( eg , an origin is created before its snapshot , but is not
* unsuspended until the snapshot is also created . )
*/
2016-04-08 18:27:12 +03:00
int dev_manager_info ( struct cmd_context * cmd , const struct logical_volume * lv ,
2010-08-17 20:25:32 +04:00
const char * layer ,
2019-10-31 13:45:28 +03:00
int with_open_count , int with_read_ahead , int with_name_check ,
2014-11-04 17:00:32 +03:00
struct dm_info * dminfo , uint32_t * read_ahead ,
struct lv_seg_status * seg_status ) ;
2016-04-08 18:27:12 +03:00
2002-05-22 18:03:45 +04:00
int dev_manager_snapshot_percent ( struct dev_manager * dm ,
2006-04-06 18:06:27 +04:00
const struct logical_volume * lv ,
2014-06-09 14:08:27 +04:00
dm_percent_t * percent ) ;
2003-04-30 19:26:25 +04:00
int dev_manager_mirror_percent ( struct dev_manager * dm ,
2010-01-16 01:58:25 +03:00
const struct logical_volume * lv , int wait ,
2014-06-09 14:08:27 +04:00
dm_percent_t * percent , uint32_t * event_nr ) ;
2013-02-01 21:31:47 +04:00
int dev_manager_raid_status ( struct dev_manager * dm ,
const struct logical_volume * lv ,
2021-03-17 11:50:09 +03:00
struct lv_status_raid * * status , int * exists ) ;
2013-04-12 00:33:59 +04:00
int dev_manager_raid_message ( struct dev_manager * dm ,
const struct logical_volume * lv ,
const char * msg ) ;
2018-08-27 22:53:09 +03:00
int dev_manager_writecache_message ( struct dev_manager * dm ,
const struct logical_volume * lv ,
const char * msg ) ;
2014-01-28 22:24:51 +04:00
int dev_manager_cache_status ( struct dev_manager * dm ,
const struct logical_volume * lv ,
2021-03-17 13:20:23 +03:00
struct lv_status_cache * * status , int * exists ) ;
2020-09-27 02:11:47 +03:00
int dev_manager_thin_status ( struct dev_manager * dm ,
const struct logical_volume * lv , int flush ,
2021-03-17 13:20:23 +03:00
struct lv_status_thin * * status , int * exists ) ;
2013-12-04 16:57:27 +04:00
int dev_manager_thin_device_id ( struct dev_manager * dm ,
const struct logical_volume * lv ,
2021-03-17 13:20:23 +03:00
uint32_t * device_id , int * exist ) ;
2020-09-27 02:11:47 +03:00
int dev_manager_thin_pool_status ( struct dev_manager * dm ,
const struct logical_volume * lv , int flush ,
2021-03-17 13:20:23 +03:00
struct lv_status_thin_pool * * status , int * exists ) ;
2018-06-29 12:15:54 +03:00
int dev_manager_vdo_pool_status ( struct dev_manager * dm ,
2021-03-17 13:20:23 +03:00
const struct logical_volume * lv , int flush ,
struct lv_status_vdo * * status , int * exists ) ;
2023-01-15 23:24:28 +03:00
int dev_manager_vdo_pool_size_config ( struct dev_manager * dm ,
const struct logical_volume * lv ,
struct vdo_pool_size_config * cfg ) ;
2014-09-22 17:50:07 +04:00
int dev_manager_suspend ( struct dev_manager * dm , const struct logical_volume * lv ,
2011-06-17 18:14:19 +04:00
struct lv_activate_opts * laopts , int lockfs , int flush_required ) ;
2014-09-22 17:50:07 +04:00
int dev_manager_activate ( struct dev_manager * dm , const struct logical_volume * lv ,
2011-06-17 18:14:19 +04:00
struct lv_activate_opts * laopts ) ;
2014-09-22 17:50:07 +04:00
int dev_manager_preload ( struct dev_manager * dm , const struct logical_volume * lv ,
2011-06-17 18:14:19 +04:00
struct lv_activate_opts * laopts , int * flush_required ) ;
2014-09-22 17:50:07 +04:00
int dev_manager_deactivate ( struct dev_manager * dm , const struct logical_volume * lv ) ;
int dev_manager_transient ( struct dev_manager * dm , const struct logical_volume * lv ) __attribute__ ( ( nonnull ( 1 , 2 ) ) ) ;
2002-02-25 15:02:33 +03:00
2010-02-24 23:00:56 +03:00
int dev_manager_mknodes ( const struct logical_volume * lv ) ;
2003-11-12 22:16:48 +03:00
2002-02-25 15:02:33 +03:00
/*
* Put the desired changes into effect .
*/
int dev_manager_execute ( struct dev_manager * dm ) ;
2006-05-11 21:58:58 +04:00
int dev_manager_device_uses_vg ( struct device * dev ,
2005-10-25 23:08:21 +04:00
struct volume_group * vg ) ;
2018-08-17 23:45:52 +03:00
int dev_manager_remove_dm_major_minor ( uint32_t major , uint32_t minor ) ;
2019-03-13 14:59:59 +03:00
int dev_manager_check_prefix_dm_major_minor ( uint32_t major , uint32_t minor , const char * prefix ) ;
2024-06-28 21:35:12 +03:00
int dev_manager_get_dm_active_devices ( const char * prefix , struct dm_list * * devs ,
unsigned * devs_features ) ;
2019-03-13 14:59:59 +03:00
2002-02-25 15:02:33 +03:00
# endif