On 04/27/2018 12:25 PM, Dan Williams wrote:
On Fri, Apr 27, 2018 at 11:18 AM, Dave Jiang
<dave.jiang(a)intel.com> wrote:
> util_filter_walk() does the looping through of busses and regions. Removing
> duplicate code in namespace ops and provide filter functions so we can
> utilize util_filter_walk() and share common code.
>
> Signed-off-by: Dave Jiang <dave.jiang(a)intel.com>
> ---
> ndctl/namespace.c | 164 ++++++++++++++++++++++++++++++-----------------------
> test/btt-check.sh | 2 -
> util/filter.c | 5 +-
> util/filter.h | 8 +++
> 4 files changed, 105 insertions(+), 74 deletions(-)
>
> diff --git a/ndctl/namespace.c b/ndctl/namespace.c
> index e61f500c..404d6761 100644
> --- a/ndctl/namespace.c
> +++ b/ndctl/namespace.c
> @@ -983,14 +983,92 @@ static int namespace_reconfig(struct ndctl_region *region,
> int namespace_check(struct ndctl_namespace *ndns, bool verbose, bool force,
> bool repair, bool logfix);
>
> +static bool filter_bus(struct ndctl_bus *bus, struct util_filter_ctx *ctx)
> +{
> + return true;
> +}
> +
> +static bool filter_region(struct ndctl_region *region,
> + struct util_filter_ctx *ctx)
> +{
> + struct nsaction_filter_arg *nfa = ctx->nsaction;
> + int rc = 0;
> + bool out = true;
> +
> + if (nfa->action == ACTION_CREATE && !nfa->namespace) {
> + if (nfa->rc == 1)
> + return false;
> +
> + rc = namespace_create(region);
> + if (rc != -EAGAIN) {
> + if (rc == 0)
> + rc = 1;
> + /* don't proceed in the filter loop */
> + out = false;
> + }
> + nfa->rc = rc;
> + }
> +
> + return out;
> +}
> +
> +static void filter_namespace(struct ndctl_namespace *ndns,
> + struct util_filter_ctx *ctx)
> +{
> + struct ndctl_region *region = ndctl_namespace_get_region(ndns);
> + struct nsaction_filter_arg *nfa = ctx->nsaction;
> + const char *ndns_name;
> + int rc;
> +
> + /* we have an error, don't do anything else */
> + if (nfa->rc < 0)
> + return;
Why do we need to stop here? This seems like a behavior regression.
For example:
ndctl disable-namespace all
Should continue to disable subsequent namespaces even if a previous
namespace attempt fails.
Yes I misread the original flow. I need to replace that with:
if (!nfa->namespace)
return;