From 66a8e90fd944dad6cf592b134e23f04b650ff915 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 26 Mar 2004 21:24:03 +0000 Subject: [PATCH] lvchange --refresh --- tools/args.h | 1 + tools/commands.h | 3 ++- tools/lvchange.c | 21 ++++++++++++++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/tools/args.h b/tools/args.h index c6d0d2621..16375e4c9 100644 --- a/tools/args.h +++ b/tools/args.h @@ -29,6 +29,7 @@ arg(removemissing_ARG, '\0', "removemissing", NULL) arg(abort_ARG, '\0', "abort", NULL) arg(addtag_ARG, '\0', "addtag", tag_arg) arg(deltag_ARG, '\0', "deltag", tag_arg) +arg(refresh_ARG, '\0', "refresh", NULL) arg(mknodes_ARG, '\0', "mknodes", NULL) arg(minor_ARG, '\0', "minor", minor_arg) diff --git a/tools/commands.h b/tools/commands.h index 93bd110dd..62d74a625 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -67,6 +67,7 @@ xx(lvchange, "\t[-P|--partial] " "\n" "\t[-p|--permission r|rw]\n" "\t[-r|--readahead ReadAheadSectors]\n" + "\t[--refresh]\n" "\t[-t|--test]\n" "\t[-v|--verbose]\n" "\t[--version]" "\n" @@ -74,7 +75,7 @@ xx(lvchange, autobackup_ARG, available_ARG, contiguous_ARG, force_ARG, ignorelockingfailure_ARG, major_ARG, minor_ARG, partial_ARG, permission_ARG, - persistent_ARG, readahead_ARG, addtag_ARG, deltag_ARG, + persistent_ARG, readahead_ARG, refresh_ARG, addtag_ARG, deltag_ARG, test_ARG) xx(lvcreate, diff --git a/tools/lvchange.c b/tools/lvchange.c index 75cfa2195..3ee88e762 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -105,6 +105,16 @@ static int lvchange_availability(struct cmd_context *cmd, return 1; } +static int lvchange_refresh(struct cmd_context *cmd, struct logical_volume *lv) +{ + log_verbose("Refreshing logical volume \"%s\" (if active)", lv->name); + if (!lock_vol(cmd, lv->lvid.s, LCK_LV_SUSPEND | LCK_LV_HOLD) || + !unlock_vol(cmd, lv->lvid.s)) + return 0; + + return 1; +} + static int lvchange_contiguous(struct cmd_context *cmd, struct logical_volume *lv) { @@ -428,6 +438,10 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv, if (!lvchange_availability(cmd, lv)) return ECMD_FAILED; + if (arg_count(cmd, refresh_ARG)) + if (!lvchange_refresh(cmd, lv)) + return ECMD_FAILED; + return ECMD_PROCESSED; } @@ -437,16 +451,17 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv) && !arg_count(cmd, permission_ARG) && !arg_count(cmd, readahead_ARG) && !arg_count(cmd, minor_ARG) && !arg_count(cmd, major_ARG) && !arg_count(cmd, persistent_ARG) && !arg_count(cmd, addtag_ARG) - && !arg_count(cmd, deltag_ARG)) { + && !arg_count(cmd, deltag_ARG) && !arg_count(cmd, refresh_ARG)) { log_error("One or more of -a, -C, -j, -m, -M, -p, -r, " - "--addtag or --deltag required"); + "--refresh, --addtag or --deltag required"); return EINVALID_CMD_LINE; } if (arg_count(cmd, ignorelockingfailure_ARG) && (arg_count(cmd, contiguous_ARG) || arg_count(cmd, permission_ARG) || arg_count(cmd, readahead_ARG) || arg_count(cmd, persistent_ARG) || - arg_count(cmd, addtag_ARG) || arg_count(cmd, deltag_ARG))) { + arg_count(cmd, addtag_ARG) || arg_count(cmd, deltag_ARG) || + arg_count(cmd, refresh_ARG))) { log_error("Only -a permitted with --ignorelockingfailure"); return EINVALID_CMD_LINE; }