master - dmsetup: Support remove --deferred.
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=42e07d2bceaad21f197de5dde9ead69742425159 Commit: 42e07d2bceaad21f197de5dde9ead69742425159 Parent: ec41bd1920be119538cd9c98a8fc3d38e184803f Author: Alasdair G Kergon <[email protected]> AuthorDate: Sat Aug 16 00:34:48 2014 +0100 Committer: Alasdair G Kergon <[email protected]> CommitterDate: Sat Aug 16 00:34:48 2014 +0100
dmsetup: Support remove --deferred.
This patch adds a new flag --deferred to dmsetup remove. If this flag is specified and the device is open, it is scheduled to be deleted on close.
struct dm_info is extended.
The existing dm_task_get_info() is converted into a wrapper around the new version dm_task_get_info_with_deferred_remove() so existing binaries can still use the old smaller structure.
Recompiled code will pick up the new larger structure.
From: Mikulas Patocka <[email protected]>
--- WHATS_NEW_DM | 1 + libdm/.exported_symbols | 1 + libdm/ioctl/libdm-iface.c | 44 +++++++++++++++++++++++++++++++++++++++- libdm/ioctl/libdm-targets.h | 1 + libdm/libdevmapper.h | 5 ++++ man/dmsetup.8.in | 47 ++++++++++++++++++++++-------------------- tools/dmsetup.c | 14 ++++++++++-- 7 files changed, 87 insertions(+), 26 deletions(-)
WHATS_NEW_DM +1 -0
@@ -1,5 +1,6 @@ Version 1.02.89 - ================================= + Support --deferred with dmsetup remove to defer removal of open devices. Update dm-ioctl.h to include DM_DEFERRED_REMOVE flag. Add support for selection to match string list subset, recognize { } operator. Fix string list selection with '[value]' to not match list that's superset.
libdm/.exported_symbols +1 -0
@@ -1,2 +1,3 @@ dm_log dm_log_with_errno +dm_task_get_info
libdm/ioctl/libdm-iface.c +43 -1
83 lines not on this page · raw message
libdm/ioctl/libdm-targets.h +1 -0
@@ -65,6 +65,7 @@ struct dm_task {int new_uuid;int secure_data;int retry_remove; +int deferred_remove;int enable_checks;int expected_errno;
libdm/libdevmapper.h +5 -0
@@ -149,6 +149,8 @@ struct dm_info {int read_only;/* 0:read-write; 1:read-only */ int32_t target_count; + +int deferred_remove; };struct dm_deps {
@@ -172,6 +174,8 @@ struct dm_versions {int dm_get_library_version (char *version,size_t size);int dm_task_get_driver_version (struct dm_task *dmt,char *version,size_t size); + +#define dm_task_get_info dm_task_get_info_with_deferred_removeint dm_task_get_info (struct dm_task *dmt,struct dm_info *dmi);/*
@@ -222,6 +226,7 @@ int dm_task_query_inactive_table(struct dm_task *dmt);int dm_task_suppress_identical_reload (struct dm_task *dmt);int dm_task_secure_data (struct dm_task *dmt);int dm_task_retry_remove (struct dm_task *dmt); +int dm_task_deferred_remove (struct dm_task *dmt);/* * Enable checks for common mistakes such as issuing ioctls in an unsafe order.
man/dmsetup.8.in +25 -22
69 lines not on this page · raw message
tools/dmsetup.c +11 -3
@@ -120,6 +120,7 @@ enum {ADD_NODE_ON_RESUME_ARG ,CHECKS_ARG ,COLS_ARG , +DEFERRED_ARG ,SELECT_ARG ,EXEC_ARG , FORCE_ARG,
@@ -468,9 +469,10 @@ static void _display_info_long(struct dm_task *dmt, struct dm_info *info)printf ("Name: %s\n" ,dm_task_get_name (dmt)); -printf ("State: %s%s\n" , +printf ("State: %s%s%s\n" , info->suspended ?"SUSPENDED" :"ACTIVE" , - info->read_only ?" (READ-ONLY)" :"" ); + info->read_only ?" (READ-ONLY)" :"" , + info->deferred_remove ?" (DEFERRED REMOVE)" :"" );/* FIXME Old value is being printed when it's being changed. */ if (dm_task_get_read_ahead (dmt, &read_ahead))
@@ -1321,6 +1323,9 @@ static int _simple(int task, const char *name, uint32_t event_nr, int display)if (_switches[RETRY_ARG ] && task ==DM_DEVICE_REMOVE )dm_task_retry_remove (dmt); +if (_switches[DEFERRED_ARG ] && (task ==DM_DEVICE_REMOVE || task ==DM_DEVICE_REMOVE_ALL )) +dm_task_deferred_remove (dmt); + r =dm_task_run (dmt); out:
@@ -3071,7 +3076,7 @@ static struct command _commands[] = {"\t [-u|uuid <uuid>] [{--addnodeonresume|--addnodeoncreate}]\n" "\t [--notable | --table <table> | <table_file>]" , 1, 2,0, _create}, - {"remove", "[-f|--force] <device>", 0, -1, 1, _remove}, + {"remove", "[-f|--force] [--deferred] <device>", 0, -1, 1, _remove}, {"remove_all", "[-f|--force]", 0, 0, 0, _remove_all}, {"suspend", "[--noflush] <device>", 0, -1, 1, _suspend}, {"resume", "<device> [{--addnodeonresume|--addnodeoncreate}]", 0, -1, 1, _resume},
@@ -3521,6 +3526,7 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir) {"readonly", 0, &ind, READ_ONLY}, {"checks", 0, &ind, CHECKS_ARG}, {"columns", 0, &ind, COLS_ARG}, + {"deferred", 0, &ind, DEFERRED_ARG}, {"select", 1, &ind, SELECT_ARG}, {"exec", 1, &ind, EXEC_ARG}, {"force", 0, &ind, FORCE_ARG},
@@ -3694,6 +3700,8 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)/* FIXME Accept modes as per chmod */ _int_args[MODE_ARG ] = (int )strtol (optarg,NULL ,8 ); } +if (ind ==DEFERRED_ARG ) + _switches[DEFERRED_ARG ]++;if (ind ==EXEC_ARG ) { _switches[EXEC_ARG ]++; _command = optarg;