master - thin: add discard support for thin pool
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ebbf7d8e68f37c1a1e448a07676cca0a6e7f1430 Commit: ebbf7d8e68f37c1a1e448a07676cca0a6e7f1430 Parent: 260e8f24768d7a6e7c6a8018b5c2b08e7a35e35c Author: Zdenek Kabelac <[email protected]> AuthorDate: Thu Jun 28 14:47:34 2012 +0200 Committer: Zdenek Kabelac <[email protected]> CommitterDate: Wed Jul 18 14:36:57 2012 +0200
thin: add discard support for thin pool
Add arg support for discard.
Add discard ignore, nopassdown, passdown (=default) support. Flags could be set per pool.
lvcreate [--discard {ignore|no_passdown|passdown}] vg/thinlv
--- WHATS_NEW | 1 + lib/metadata/metadata-exported.h | 9 +++++++ lib/metadata/thin_manip.c | 35 ++++++++++++++++++++++++++++++ lib/thin/thin.c | 44 ++++++++++++++++++++++++++++++++++++++ man/lvcreate.8.in | 6 +++++ tools/args.h | 1 + tools/commands.h | 6 ++++- tools/lvmcmdline.c | 13 +++++++++++ tools/tools.h | 1 + 9 files changed, 115 insertions(+), 1 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.97 - =============================== + Add support for controlling discard behavior of thin pool. Detect features for new 1.1 thin pool target. Count percentage of completeness upwards when merging a snapshot volume. Skip activation when using vg/lvchange --sysinit -a ay and lvmetad is active.
lib/metadata/metadata-exported.h +9 -0
@@ -166,6 +166,12 @@ typedef enum { DONT_PROMPT_OVERRIDE = 2 /* Skip prompt + override a second condition */ } force_t; +typedef enum { +THIN_DISCARD_PASSDOWN , +THIN_DISCARD_NO_PASSDOWN , +THIN_DISCARD_IGNORE , +}thin_discard_t ; +struct cmd_context ;struct format_handler ;struct labeller ;
@@ -347,6 +353,7 @@ struct lv_segment {uint64_t transaction_id;/* For thin_pool, thin */ uint64_t low_water_mark;/* For thin_pool */ unsigned zero_new_blocks;/* For thin_pool */ +thin_discard_t discard;/* For thin_pool */ struct dm_list thin_messages;/* For thin_pool */ struct logical_volume *pool_lv;/* For thin */ uint32_t device_id;/* For thin, 24bit */
@@ -558,6 +565,8 @@ uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size, uint32_t extent_size);int update_pool_lv (struct logical_volume *lv,int activate); +int get_pool_discard (const char *str,thin_discard_t *discard); +const char *get_pool_discard_name (thin_discard_t discard);/* * Activation options
lib/metadata/thin_manip.c +35 -0
@@ -428,3 +428,38 @@ int update_pool_lv(struct logical_volume *lv, int activate)return 1 ; } + +int get_pool_discard (const char *str,thin_discard_t *discard) +{ +if (!strcasecmp (str,"passdown" )) + *discard =THIN_DISCARD_PASSDOWN ; +/* Allow some variation in thin parameter */ +else if (!strcasecmp (str,"nopassdown" ) || + !strcasecmp (str,"no-passdown" ) || + !strcasecmp (str,"no_passdown" )) + *discard =THIN_DISCARD_NO_PASSDOWN ; +else if (!strcasecmp (str,"ignore" )) + *discard =THIN_DISCARD_IGNORE ; +else { +log_error ("Thin pool discard type %s is unknown." , str); +return 0 ; + } + +return 1 ; +} + +const char *get_pool_discard_name (thin_discard_t discard) +{ +switch (discard) { +case THIN_DISCARD_PASSDOWN : +return "passdown" ; +case THIN_DISCARD_NO_PASSDOWN : +return "nopassdown" ; +case THIN_DISCARD_IGNORE : +return "ignore" ; + } + +log_error (INTERNAL_ERROR "Uknown discard type." ); + +return NULL ; +}
lib/thin/thin.c +44 -0
85 lines not on this page · raw message
man/lvcreate.8.in +6 -0
@@ -54,6 +54,8 @@ lvcreate \- create a logical volume in an existing volume group .RB [ \-T | \-\-thin .RB [ \-c | \-\-chunksize .IR ChunkSize ] +.RB [ \-\-discard +.RI { ignore | nopassdown | passdown }] .RB [ \-\-poolmetadatasize .IR MetadataSize [ bBsSkKmMgG ]]] .RB [ \-\-thinpool
@@ -138,6 +140,10 @@ Sets or resets the contiguous allocation policy for logical volumes. Default is no contiguous allocation based on a next free principle. .TP +.BR \-\-discard " {" \fIignore | \fInopassdown | \fIpassdown } +Set discard behavior. +Default is \fIpassdown\fP. +.TP .BR \-i ", " \-\-stripes " " \fIStripes Gives the number of stripes. This is equal to the number of physical volumes to scatter
tools/args.h +1 -0
@@ -72,6 +72,7 @@ arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0) arg(noudevsync_ARG, '\0', "noudevsync", NULL, 0) arg(poll_ARG, '\0', "poll", yes_no_arg, 0) arg(poolmetadatasize_ARG, '\0', "poolmetadatasize", size_mb_arg, 0) +arg(discard_ARG, '\0', "discard", discard_arg, 0) arg(stripes_long_ARG, '\0', "stripes", int_arg, 0) arg(sysinit_ARG, '\0', "sysinit", NULL, 0)arg (thinpool_ARG,'\0' ,"thinpool" , string_arg,0 )
tools/commands.h +5 -1
@@ -177,6 +177,10 @@ xx(lvcreate,"\t[-p|--permission {r|rw}]\n" "\t[-r|--readahead ReadAheadSectors|auto|none]\n" "\t[-R|--regionsize MirrorLogRegionSize]\n" +"\t[-T|--thin [-c|--chunksize ChunkSize]\n" +"\t [--discard {ignore|nopassdown|passdown}]\n" +"\t [--poolmetadatasize MetadataSize[bBsSkKmMgG]]]\n" +"\t[--thinpool ThinPoolLogicalVolume{Name|Path}]\n" "\t[-t|--test]\n" "\t[--type VolumeType]\n" "\t[-v|--verbose]\n"
@@ -215,7 +219,7 @@ xx(lvcreate,"\t[PhysicalVolumePath...]\n\n" , addtag_ARG, alloc_ARG, autobackup_ARG, activate_ARG, available_ARG, - chunksize_ARG, contiguous_ARG, corelog_ARG, extents_ARG, + chunksize_ARG, contiguous_ARG, corelog_ARG, extents_ARG, discard_ARG, ignoremonitoring_ARG, major_ARG, minor_ARG, mirrorlog_ARG, mirrors_ARG, monitor_ARG, name_ARG, nosync_ARG, noudevsync_ARG, permission_ARG, persistent_ARG, readahead_ARG, regionsize_ARG, size_ARG, snapshot_ARG,
tools/lvmcmdline.c +13 -0
@@ -216,6 +216,19 @@ int activation_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_vreturn 1 ; } +int discard_arg (struct cmd_context *cmd __attribute__((unused)),struct arg_values *av) +{ +thin_discard_t discard; + +if (!get_pool_discard (av->value, &discard)) + return_0; + + av->i_value = discard; + av->ui_value = discard; + +return 1 ; +} +int metadatatype_arg (struct cmd_context *cmd,struct arg_values *av) {return get_format_by_name (cmd, av->value) ?1 :0 ;
tools/tools.h +1 -0
@@ -139,6 +139,7 @@ void usage(const char *name);/* the argument verify/normalise functions */ int yes_no_arg (struct cmd_context *cmd,struct arg_values *av);int activation_arg (struct cmd_context *cmd,struct arg_values *av); +int discard_arg (struct cmd_context *cmd,struct arg_values *av);int size_kb_arg (struct cmd_context *cmd,struct arg_values *av);int size_mb_arg (struct cmd_context *cmd,struct arg_values *av);int int_arg (struct cmd_context *cmd,struct arg_values *av);