Add a new RAID parameter to allow configuration of vset cache through the ncurses interface, in the raid creation screen.
Changes from last iteration: - Safe guard references to input_field[4] to prevent accesses to it when sync cache is not available. Signed-off-by: Gabriel Krisman Bertazi <kris...@linux.vnet.ibm.com> --- iprconfig.c | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- iprlib.c | 3 ++- 2 files changed, 61 insertions(+), 4 deletions(-) diff --git a/iprconfig.c b/iprconfig.c index fadf562..75899d5 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[] = {"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); @@ -3638,7 +3641,22 @@ int configure_raid_parameters(i_container *i_con) 0, /* number of offscreen rows */ 0); /* number of working buffers */ - input_fields[4] = NULL; + + if (ioa->vset_write_cache) { + /* 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 */ + cache_prot = IPR_DEV_CACHE_WRITE_BACK; + + set_field_just(input_fields[4], JUSTIFY_LEFT); + field_opts_off(input_fields[4], O_EDIT); + } else { + input_fields [4] = NULL; + } + + input_fields[5] = NULL; raid_index = raid_index_default; cap_entry = prot_level_list[raid_index].array_cap_entry; @@ -3677,6 +3695,8 @@ 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); + if (ioa->vset_write_cache) + mvprintw(11, 0, "Array Write Cache Policy . . . . . . . . :"); mvaddstr(max_y - 4, 0, _("Press Enter to Continue")); mvaddstr(max_y - 2, 0, EXIT_KEY_LABEL CANCEL_KEY_LABEL); @@ -3704,6 +3724,13 @@ 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]; + + if (ioa->vset_write_cache) + 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 +3841,33 @@ int configure_raid_parameters(i_container *i_con) else qdepth = new_qdepth; continue; + } else if (cur_field_index == 4 && ioa->vset_write_cache) { + 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 +3884,8 @@ 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; + if (ioa->vset_write_cache) + cur_raid_cmd->vset_cache = cache_prot; goto leave; } else if (ch == KEY_RIGHT) form_driver(form, REQ_NEXT_CHAR); diff --git a/iprlib.c b/iprlib.c index c5dfd8b..a899e1b 100644 --- a/iprlib.c +++ b/iprlib.c @@ -7529,7 +7529,8 @@ int ipr_set_dev_attr(struct ipr_dev *dev, struct ipr_disk_attr *attr, int save) } } - if (attr->write_cache_policy != old_attr.write_cache_policy) { + if (attr->write_cache_policy != old_attr.write_cache_policy + || !attr->write_cache_policy) { ipr_set_dev_wcache_policy(dev, attr->write_cache_policy); if (save) { sprintf(temp, "%d", attr->write_cache_policy); -- 2.1.0 ------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140 _______________________________________________ Iprdd-devel mailing list Iprdd-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iprdd-devel