Brian King <brk...@linux.vnet.ibm.com> writes: > 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.
Hi, Thanks for your review. I applied your suggestions in the v2 below. If you need a system with sync cache to test this, let me know. Thanks! -- >8 -- 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 | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- iprlib.c | 3 ++- 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/iprconfig.c b/iprconfig.c index fadf562..83e5ca5 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,19 @@ 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; + } else { + 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 +3665,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 +3694,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 +3723,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 +3840,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 +3883,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 ------------------------------------------------------------------------------ _______________________________________________ Iprdd-devel mailing list Iprdd-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/iprdd-devel