On 10/16/2015 06:30 PM, Gabriel Krisman Bertazi wrote:
> Add a new '-vc <policy>' option to raid-create to allow setting Sync
> Write Cache policy for vsets during raid creation.  For performance
> reasons, if user doesn't specify any policy and adapter supports it, it
> will default to Writeback.
> 
> New syntax allowed:
> 
> $ iprconfig -c raid-create sg1 -z -c writeback
> $ iprconfig -c raid-create sg1 -r 10 -c writethrough
> 
> Signed-off-by: Gabriel Krisman Bertazi <kris...@linux.vnet.ibm.com>
> ---
>  iprconfig.8 |  6 ++++--
>  iprconfig.c | 34 ++++++++++++++++++++++++++++++++--
>  2 files changed, 36 insertions(+), 4 deletions(-)
> 
> diff --git a/iprconfig.8 b/iprconfig.8
> index 682ec69..65bb1e3 100644
> --- a/iprconfig.8
> +++ b/iprconfig.8
> @@ -474,12 +474,14 @@ specified array will be displayed.
>  .br
>  Show the current write cache policy for [device].
>  .TP
> -.B raid-create [-r raid_level] [-s stripe_size_in_kb] [-l label] 
> [--skip-format] [devices...]
> +.B raid-create [-r raid_level] [-s stripe_size_in_kb] [-l label] 
> [--skip-format] [-vc cache_policy] [devices...]

I think I'd prefer to keep the options to be a single character. Can you change 
-vc to just be -c?

>  Create a RAID array. RAID level can be any supported RAID level for the given
>  adapter, such as 0, 10, 5, 6. Currently supported stripe sizes in kb 
>  include 16, 64, and 256. If raid_level is not specified, it will default to
>  RAID 5. If stripe size is not specified, it will default to the recommended
> -stripe size for the selected RAID level. Devices are specified with their 
> full
> +stripe size for the selected RAID level.  Available cache policies are the
> +same that can be passed to set-write-cache-policy command.  If none is
> +specified, write back is assumed.  Devices are specified with their full
>  name, either the /dev/sd name or the /dev/sg name is acceptable. On some RAID
>  adapters, a label can also be specified. Example array
>  creation:
> diff --git a/iprconfig.c b/iprconfig.c
> index b811bfd..8240bf7 100644
> --- a/iprconfig.c
> +++ b/iprconfig.c
> @@ -59,6 +59,7 @@ struct array_cmd_data {
>       u16 stripe_size;
>       int qdepth;
>       u32 do_cmd;
> +     int vset_cache;
>       struct ipr_ioa *ioa;
>       struct ipr_dev *dev;
>       struct ipr_array_query_data *qac;
> @@ -4013,11 +4014,14 @@ int raid_start_complete()
>                                                       } else
>                                                               retry = 0;
>                                                       if 
> (ipr_get_dev_attr(dev, &attr)) {
> -                                                             syslog(LOG_ERR, 
> _("Unable to read queue_depth"));
> +                                                             syslog(LOG_ERR,
> +                                                                    
> _("Unable to read attributes when creating arrays"));
>                                                       } else {
>                                                               
> attr.queue_depth = cur_raid_cmd->qdepth;
> +                                                             
> attr.write_cache_policy = cur_raid_cmd->vset_cache;
>                                                               if 
> (ipr_set_dev_attr(dev, &attr, 1))
> -                                                                     
> syslog(LOG_ERR, _("Unable to set queue_depth"));
> +                                                                     
> syslog(LOG_ERR,
> +                                                                            
> _("Unable to set attributes when creating arrays"));
>                                                       }
>                                               } else
>                                                       break;
> @@ -13646,6 +13650,7 @@ static int raid_create(char **args, int num_args)
>       char *raid_level = IPR_DEFAULT_RAID_LVL;
>       char label[8];
>       int stripe_size, qdepth, zeroed_devs, skip_format;
> +     int next_vcache, vcache = -1;
>       struct ipr_dev *dev;
>       struct sysfs_dev *sdev;
>       struct ipr_ioa *ioa = NULL;
> @@ -13657,6 +13662,7 @@ static int raid_create(char **args, int num_args)
>       next_stripe_size = 0;
>       next_qdepth = 0;
>       next_label = 0;
> +     next_vcache = 0;
>       stripe_size = 0;
>       qdepth = 0;
>       zeroed_devs = 0;
> @@ -13673,6 +13679,8 @@ static int raid_create(char **args, int num_args)
>                       next_qdepth = 1;
>               else if (strcmp(args[i], "-l") == 0)
>                       next_label = 1;
> +             else if (strcmp(args[i], "-vc") == 0)
> +                      next_vcache = 1;
>               else if (strcmp(args[i], "--skip-format") == 0)
>                       skip_format = 1;
>               else if (next_raid_level) {
> @@ -13684,6 +13692,17 @@ static int raid_create(char **args, int num_args)
>               } else if (next_qdepth) {
>                       next_qdepth = 0;
>                       qdepth = strtoul(args[i], NULL, 10);
> +             } else if (next_vcache) {
> +                     next_vcache = 0;
> +                     if (strcmp(args[i], "writethrough") == 0)
> +                         vcache = IPR_DEV_CACHE_WRITE_THROUGH;
> +                     else if (strcmp(args[i], "writeback") == 0)
> +                             vcache = IPR_DEV_CACHE_WRITE_BACK;
> +                     else {
> +                             syslog(LOG_ERR,
> +                                    _("Invalid value passed to -c."));
> +                             return -EINVAL;
> +                     }
>               } else if (next_label) {
>                       next_label = 0;
>                       if (strlen(args[i]) > (sizeof(label) - 1)) {
> @@ -13768,6 +13787,16 @@ IOA write cache.  Use --force to force creation.\n");
>                       qdepth = num_devs * 4;
>       }
> 
> +     if (vcache == IPR_DEV_CACHE_WRITE_BACK && !ioa->vset_write_cache)
> +             syslog(LOG_ERR,
> +                    _("vset cache not enabled for this IOA.\n"));

Suggest rewording to "Cannot set requested caching mode, using default"

> +     else if(ioa->vset_write_cache && vcache < 0) {
> +             /* For performance reasons Writeback is the default
> +               Vset Cache policy. Users can override this setting
> +               by passing option '-c writethrough' to raid create */
> +             vcache = IPR_DEV_CACHE_WRITE_BACK;
> +     }
> +
>       if (dev_init_head) {
>               rc = send_dev_inits(NULL);
>               free_devs_to_init();
> @@ -13808,6 +13837,7 @@ IOA write cache.  Use --force to force creation.\n");
>       add_raid_cmd_tail(ioa, &ioa->ioa, array_id);
>       raid_cmd_tail->qdepth = qdepth;
>       raid_cmd_tail->do_cmd = 1;
> +     raid_cmd_tail->vset_cache = vcache;
> 
>       rc = ipr_start_array_protection(ioa, stripe_size, cap->prot_level);
> 


-- 
Brian King
Power Linux I/O
IBM Linux Technology Center


------------------------------------------------------------------------------
_______________________________________________
Iprdd-devel mailing list
Iprdd-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iprdd-devel

Reply via email to