diff options
author | David Teigland <teigland@redhat.com> | 2022-06-14 15:20:21 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2022-08-11 13:54:44 -0500 |
commit | 744c27fcba9a4387b0fa10fc4e4374735f193ede (patch) | |
tree | 680dffebec74e47c06ec7715199d43a29d0eae32 /lib/device/filesystem.h | |
parent | 845d4d26c528e4cb28ee74d1a40c1566cc81fc53 (diff) | |
download | lvm2-dev-dct-lvresize-6.tar.gz |
lvresize: add new options and defaults for fs handlingdev-dct-lvresize-6
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.
Possible --fs values:
checksize
Only used when reducing the size, does nothing when exending.
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_remount | resize
Resize the fs if needed. Mounts or unmounts the fs as
required (avoids mounting/unmounting when possible.)
Attempts to restore the original mount state when finished.
resize_keepmount
Resize the fs if needed, only if it can be done without
changing the current mount state. Fail the command without
resizing the fs or LV if an fs resize requires mounting or
unmounting.
resize_unmount
Resize the fs if needed, only while unmounted. Unmount the
fs if needed. Fail the command without resizing the fs
or LV if an fs resize is needed that requires the the fs
to be mounted.
resize_fsadm
Use the old method of calling fsadm to do handle the fs
(deprecated).
ignore
Resize the LV without checking for or handling a file system.
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.
Diffstat (limited to 'lib/device/filesystem.h')
-rw-r--r-- | lib/device/filesystem.h | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/lib/device/filesystem.h b/lib/device/filesystem.h new file mode 100644 index 000000000..1e83469cb --- /dev/null +++ b/lib/device/filesystem.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2022 Red Hat, Inc. All rights reserved. + * + * 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 + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef _FILESYSTEM_H +#define _FILESYSTEM_H + +#define FSTYPE_MAX 16 + +struct fs_info { + char fstype[FSTYPE_MAX]; + char mount_dir[PATH_MAX]; + char fs_dev_path[PATH_MAX]; /* usually lv dev, can be crypt dev */ + unsigned int block_size_bytes; /* 512 or 4k */ + uint64_t fs_last_byte; /* last byte on the device used by the fs */ + uint32_t crypt_offset_bytes; /* offset in bytes of crypt data on LV */ + dev_t crypt_devt; /* dm-crypt device between the LV and FS */ + + unsigned nofs:1; + unsigned unmounted:1; + unsigned mounted:1; + unsigned temp_mount_dir:1; + /* for resizing */ + unsigned needs_reduce:1; + unsigned needs_extend:1; + unsigned needs_fsck:1; + unsigned needs_unmount:1; + unsigned needs_mount:1; + unsigned needs_crypt:1; +}; + +int fs_get_info(struct cmd_context *cmd, struct logical_volume *lv, + struct fs_info *fsi, int include_mount); +int fs_fsck_command(struct cmd_context *cmd, struct logical_volume *lv, struct fs_info *fsi); +int fs_reduce_command(struct cmd_context *cmd, struct logical_volume *lv, struct fs_info *fsi, + uint64_t newsize_bytes); +int fs_extend_command(struct cmd_context *cmd, struct logical_volume *lv, struct fs_info *fsi); +int fs_mount_command(struct cmd_context *cmd, struct logical_volume *lv, struct fs_info *fsi, + int reuse_mount_dir); +int fs_unmount_command(struct cmd_context *cmd, struct logical_volume *lv, struct fs_info *fsi); + +int crypt_resize_command(struct cmd_context *cmd, dev_t crypt_devt, uint64_t newsize_bytes); + +#endif |