On Tue, 27 Aug 2013 17:50:41 +0800 Shaohua Li <shli@xxxxxxxxxx> wrote: > -static struct stripe_head *__get_priority_stripe(struct r5conf *conf) > +static struct stripe_head *__get_priority_stripe(struct r5conf *conf, int group) > { > - struct stripe_head *sh; > + struct stripe_head *sh = NULL, *tmp; > + struct list_head *handle_list = NULL; > + > + if (conf->worker_cnt_per_group == 0) { > + handle_list = &conf->handle_list; > + if (list_empty(handle_list)) > + handle_list = NULL; > + } else if (group != ANY_GROUP) { > + handle_list = &conf->worker_groups[group].handle_list; > + if (list_empty(handle_list)) > + handle_list = NULL; > + } else { > + int i; > + for (i = 0; i < conf->group_cnt; i++) { > + handle_list = &conf->worker_groups[i].handle_list; > + if (!list_empty(handle_list)) > + break; > + } > + if (i == conf->group_cnt) > + handle_list = NULL; > + } Sorry, I meant to mention this last time... The setting of handle_list to NULL seems unnecessary. It is sufficient to test if it is empty. The only interesting case is the last 'else' above. That is only reached if worker_cnt_per_group != 0 so handle_list will get set to some list_head. If all list_heads are empty, handle_list will be set to the last list_head so a list_empty(handle_list) test is perfectly safe. Also with the current code: > > pr_debug("%s: handle: %s hold: %s full_writes: %d bypass_count: %d\n", > __func__, > - list_empty(&conf->handle_list) ? "empty" : "busy", > + list_empty(handle_list) ? "empty" : "busy", ^^^^^^^^^^^^^^^^^^^^^^^ This will crash. Could you fix that up please? Thanks. NeilBrown
Attachment:
signature.asc
Description: PGP signature