On 12/08/2015 09:18 AM, Gabriel Krisman Bertazi wrote: > Add a new RAID parameter to allow configuration of vset cache through > the ncurses interface, in the raid creation screen. > > Signed-off-by: Gabriel Krisman Bertazi <kris...@linux.vnet.ibm.com> > --- > iprconfig.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- > 1 file changed, 52 insertions(+), 3 deletions(-) > > diff --git a/iprconfig.c b/iprconfig.c > index fb95bbd..a67a205 100644 > --- a/iprconfig.c > +++ b/iprconfig.c > @@ -3524,7 +3524,7 @@ int display_input(int field_start_row, int *userptr) > **/ > int configure_raid_parameters(i_container *i_con) > { > - FIELD *input_fields[5]; > + FIELD *input_fields[6]; > FIELD *cur_field; > FORM *form; > ITEM **raid_item = NULL; > @@ -3542,7 +3542,9 @@ int configure_raid_parameters(i_container *i_con) > { > char line[16]; > } *raid_menu_str = NULL, *stripe_menu_str = NULL; > - char raid_str[16], stripe_str[16], qdepth_str[4]; > + char *cache_pols[] = {"writethrough", "writeback"};
Can we change what we display to the end user on the screen to be: char *cache_pols[] = {"Write Through", "Write Back"}; > + ITEM *cache_prot_item[ARRAY_SIZE(cache_pols) + 1]; > + char raid_str[16], stripe_str[16], qdepth_str[4], *cache_prot_str; > int ch, start_row; > int cur_field_index; > int selected_count = 0, ssd_num = 0, hdd_num = 0; > @@ -3552,6 +3554,7 @@ int configure_raid_parameters(i_container *i_con) > int *retptr; > int max_x,max_y,start_y,start_x; > int qdepth, new_qdepth; > + int cache_prot; > > getmaxyx(stdscr,max_y,max_x); > getbegyx(stdscr,start_y,start_x); > @@ -3614,6 +3617,11 @@ int configure_raid_parameters(i_container *i_con) > if (raid_index_default == -1) > raid_index_default = 0; > > + if (ioa->vset_write_cache) > + cache_prot = IPR_DEV_CACHE_WRITE_BACK; > + else > + cache_prot = IPR_DEV_CACHE_WRITE_THROUGH; > + > /* Title */ > input_fields[0] = new_field(1, max_x - start_x, /* new field size */ > 0, 0, /* upper left corner */ > @@ -3637,8 +3645,13 @@ int configure_raid_parameters(i_container *i_con) > 10, 44, /* */ > 0, /* number of offscreen rows */ > 0); /* number of working buffers */ > + /* Sync Cache protection */ > + input_fields[4] = new_field(1, 13, /* new field size */ > + 11, 44, /* */ > + 0, /* number of offscreen rows */ > + 0); /* number of working buffers */ > > - input_fields[4] = NULL; > + input_fields[5] = NULL; > > raid_index = raid_index_default; > cap_entry = prot_level_list[raid_index].array_cap_entry; > @@ -3650,11 +3663,13 @@ int configure_raid_parameters(i_container *i_con) > > set_field_just(input_fields[0], JUSTIFY_CENTER); > set_field_just(input_fields[3], JUSTIFY_LEFT); > + set_field_just(input_fields[4], JUSTIFY_LEFT); > > field_opts_off(input_fields[0], O_ACTIVE); > field_opts_off(input_fields[1], O_EDIT); > field_opts_off(input_fields[2], O_EDIT); > field_opts_off(input_fields[3], O_EDIT); > + field_opts_off(input_fields[4], O_EDIT); > > set_field_buffer(input_fields[0], /* field to alter */ > 0, /* number of buffer to alter */ > @@ -3677,6 +3692,7 @@ int configure_raid_parameters(i_container *i_con) > mvaddstr(8, 0, "Protection Level . . . . . . . . . . . . :"); > mvaddstr(9, 0, "Stripe Size . . . . . . . . . . . . . . :"); > mvprintw(10, 0, "Queue Depth (default = %3d). . . . . . . :", qdepth); > + mvprintw(11, 0, "Cache Protection . . . . . . . . . . . . :"); I think this parameter might be confusing for anyone with a battery or supercap backed cache. Let's be consistent with what was done in the disk config screen and only display the attribute when vset_write_cache = 1. Additionally, let's name the field to be more consistent with the field on the disk configuration screen. I'd suggest we call it "Array Write Cache Policy" here. > mvaddstr(max_y - 4, 0, _("Press Enter to Continue")); > mvaddstr(max_y - 2, 0, EXIT_KEY_LABEL CANCEL_KEY_LABEL); > > @@ -3704,6 +3720,11 @@ int configure_raid_parameters(i_container *i_con) > 0, /* number of buffer to > alter */ > qdepth_str); /* string value to set */ > > + cache_prot_str = cache_pols[cache_prot]; > + set_field_buffer(input_fields[4], /* field to alter */ > + 0, /* number of buffer to > alter */ > + cache_prot_str); /* string value to set */ > + > refresh(); > ch = getch(); > > @@ -3814,6 +3835,33 @@ int configure_raid_parameters(i_container *i_con) > else > qdepth = new_qdepth; > continue; > + } else if (cur_field_index == 4) { > + userptr = realloc(userptr, > + (sizeof(int) * > + (ARRAY_SIZE(cache_pols) + > 1))); > + > + for (index = 0; index < ARRAY_SIZE(cache_pols); > + index++) { > + cache_prot_item[index] = > + new_item(cache_pols[index], ""); > + userptr[index] = index; > + set_item_userptr(cache_prot_item[index], > + (char > *)&userptr[index]); > + } > + cache_prot_item[index] = (ITEM *) NULL; > + > + start_row = 8; > + rc = display_menu(cache_prot_item, start_row, > + index, &retptr); > + if (rc == RC_SUCCESS) { > + cache_prot = *retptr; > + } > + for (index = 0; index < ARRAY_SIZE(cache_pols); > + index++) > + free_item(cache_prot_item[index]); > + if (rc == EXIT_FLAG) > + goto leave; > + continue; > } else > continue; > > @@ -3830,6 +3878,7 @@ int configure_raid_parameters(i_container *i_con) > cur_raid_cmd->prot_level = cap_entry->prot_level; > cur_raid_cmd->stripe_size = stripe_sz; > cur_raid_cmd->qdepth = qdepth; > + cur_raid_cmd->vset_cache = cache_prot; > goto leave; > } else if (ch == KEY_RIGHT) > form_driver(form, REQ_NEXT_CHAR); > -- 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