diff options
author | Alasdair Kergon <agk@redhat.com> | 2007-11-09 16:51:54 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2007-11-09 16:51:54 +0000 |
commit | b4068515e8f94e0d9839878b85fb5d2df31a2cc8 (patch) | |
tree | b9ee8e11bcde5c12bb237d8fad27429b07bf2760 /tools | |
parent | 19c865437a8c661045e61389dd6953047e2b9c82 (diff) | |
download | lvm2-b4068515e8f94e0d9839878b85fb5d2df31a2cc8.tar.gz lvm2-b4068515e8f94e0d9839878b85fb5d2df31a2cc8.tar.xz lvm2-b4068515e8f94e0d9839878b85fb5d2df31a2cc8.zip |
Enhance the management of readahead settings.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/args.h | 2 | ||||
-rw-r--r-- | tools/commands.h | 6 | ||||
-rw-r--r-- | tools/lvchange.c | 8 | ||||
-rw-r--r-- | tools/lvcreate.c | 7 | ||||
-rw-r--r-- | tools/lvmcmdline.c | 21 | ||||
-rw-r--r-- | tools/tools.h | 2 |
6 files changed, 37 insertions, 9 deletions
diff --git a/tools/args.h b/tools/args.h index 061dab1e..5a0309c5 100644 --- a/tools/args.h +++ b/tools/args.h @@ -107,7 +107,7 @@ arg(permission_ARG, 'p', "permission", permission_arg, 0) arg(maxphysicalvolumes_ARG, 'p', "maxphysicalvolumes", int_arg, 0) arg(partial_ARG, 'P', "partial", NULL, 0) arg(physicalvolume_ARG, 'P', "physicalvolume", NULL, 0) -arg(readahead_ARG, 'r', "readahead", int_arg, 0) +arg(readahead_ARG, 'r', "readahead", readahead_arg, 0) arg(resizefs_ARG, 'r', "resizefs", NULL, 0) arg(reset_ARG, 'R', "reset", NULL, 0) arg(regionsize_ARG, 'R', "regionsize", size_mb_arg, 0) diff --git a/tools/commands.h b/tools/commands.h index cebb3060..46b4e046 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -71,7 +71,7 @@ xx(lvchange, "\t[-M|--persistent y|n] [--major major] [--minor minor]\n" "\t[-P|--partial] " "\n" "\t[-p|--permission r|rw]\n" - "\t[-r|--readahead ReadAheadSectors]\n" + "\t[-r|--readahead ReadAheadSectors|auto|none]\n" "\t[--refresh]\n" "\t[--resync]\n" "\t[-t|--test]\n" @@ -126,7 +126,7 @@ xx(lvcreate, "\t[-m|--mirrors Mirrors [--nosync] [{--mirrorlog {disk|core}|--corelog}]]\n" "\t[-n|--name LogicalVolumeName]\n" "\t[-p|--permission {r|rw}]\n" - "\t[-r|--readahead ReadAheadSectors]\n" + "\t[-r|--readahead ReadAheadSectors|auto|none]\n" "\t[-R|--regionsize MirrorLogRegionSize]\n" "\t[-t|--test]\n" "\t[--type VolumeType]\n" @@ -149,7 +149,7 @@ xx(lvcreate, "\t[-M|--persistent {y|n}] [--major major] [--minor minor]\n" "\t[-n|--name LogicalVolumeName]\n" "\t[-p|--permission {r|rw}]\n" - "\t[-r|--readahead ReadAheadSectors]\n" + "\t[-r|--readahead ReadAheadSectors|auto|none]\n" "\t[-t|--test]\n" "\t[-v|--verbose]\n" "\t[--version]\n" diff --git a/tools/lvchange.c b/tools/lvchange.c index d2f473a1..152cd2d4 100644 --- a/tools/lvchange.c +++ b/tools/lvchange.c @@ -375,12 +375,12 @@ static int lvchange_readahead(struct cmd_context *cmd, read_ahead = arg_uint_value(cmd, readahead_ARG, 0); -/******* FIXME Ranges? - if (read_ahead < LVM_MIN_READ_AHEAD || read_ahead > LVM_MAX_READ_AHEAD) { - log_error("read ahead sector argument is invalid"); + if (read_ahead != DM_READ_AHEAD_AUTO && + (lv->vg->fid->fmt->features & FMT_RESTRICTED_READAHEAD) && + (read_ahead < 2 || read_ahead > 120)) { + log_error("Metadata only supports readahead values between 2 and 120."); return 0; } -********/ if (lv->read_ahead == read_ahead) { log_error("Read ahead is already %u for \"%s\"", diff --git a/tools/lvcreate.c b/tools/lvcreate.c index 46573b92..184d039f 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -548,6 +548,13 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp) return 0; } + if (lp->read_ahead != DM_READ_AHEAD_AUTO && + (vg->fid->fmt->features & FMT_RESTRICTED_READAHEAD) && + (lp->read_ahead < 2 || lp->read_ahead > 120)) { + log_error("Metadata only supports readahead values between 2 and 120."); + return 0; + } + /* * Create the pv list. */ diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 94575f38..ca77e242 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -372,6 +372,27 @@ int segtype_arg(struct cmd_context *cmd, struct arg *a) return 1; } +/* + * Positive integer, zero or "auto". + */ +int readahead_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a) +{ + if (int_arg(cmd, a)) + return 1; + + if (!strcasecmp(a->value, "auto")) { + a->ui_value = DM_READ_AHEAD_AUTO; + return 1; + } + + if (!strcasecmp(a->value, "none")) { + a->ui_value = DM_READ_AHEAD_NONE; + return 1; + } + + return 0; +} + static void __alloc(int size) { if (!(_cmdline.commands = dm_realloc(_cmdline.commands, sizeof(*_cmdline.commands) * size))) { diff --git a/tools/tools.h b/tools/tools.h index 436cc9c5..fdd6a81d 100644 --- a/tools/tools.h +++ b/tools/tools.h @@ -147,7 +147,7 @@ int metadatatype_arg(struct cmd_context *cmd, struct arg *a); int units_arg(struct cmd_context *cmd, struct arg *a); int segtype_arg(struct cmd_context *cmd, struct arg *a); int alloc_arg(struct cmd_context *cmd, struct arg *a); - +int readahead_arg(struct cmd_context *cmd, struct arg *a); /* we use the enums to access the switches */ unsigned int arg_count(const struct cmd_context *cmd, int a); |