All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Wang Long <w@laoqinren.net>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v1] xarray: update document for error space returned by xarray normal API
Date: Mon, 20 Jul 2020 13:03:10 +0100	[thread overview]
Message-ID: <20200720120310.GV12769@casper.infradead.org> (raw)
In-Reply-To: <1595218658-53727-1-git-send-email-w@laoqinren.net>

On Mon, Jul 20, 2020 at 12:17:38PM +0800, Wang Long wrote:
> In the current xarray code, the negative value -1 and -4095 represented
> as an error.
> 
> xa_is_err(xa_mk_internal(-4095)) and xa_is_err(xa_mk_internal(-1))
> are all return true.
> 
> This patch update the document.

There are actually three distinct problems here, but none of them are
fixed by this patch.

The first is that there's no test-suite coverage for this.
The second is that xa_is_err() is checking against -MAX_ERRNO instead of
-1023.
The third is that the documentation isn't clear enough because the line
you're correcting is accurate.

I don't think any of these three problems is terribly urgent to fix.
The second is most important because it could lead to confusion between
an xa_node that happens to be allocated at the top of memory and an
error return, but I don't think there is ever a situation where we end
up checking a node entry for being an error entry.  I may be wrong.

The solution to the first problem probably looks like this:

+++ b/lib/test_xarray.c
@@ -81,6 +81,11 @@ static void *xa_store_order(struct xarray *xa, unsigned long index,
 
 static noinline void check_xa_err(struct xarray *xa)
 {
+       XA_BUG_ON(xa, xa_is_err(xa_mk_internal(0)));
+       XA_BUG_ON(xa, !xa_is_err(xa_mk_internal(-1)));
+       XA_BUG_ON(xa, !xa_is_err(xa_mk_internal(-1023)));
+       XA_BUG_ON(xa, xa_is_err(xa_mk_internal(-1024)));
+
        XA_BUG_ON(xa, xa_err(xa_store_index(xa, 0, GFP_NOWAIT)) != 0);
        XA_BUG_ON(xa, xa_err(xa_erase(xa, 0)) != 0);
 #ifndef __KERNEL__


> Signed-off-by: Wang Long <w@laoqinren.net>
> ---
>  include/linux/xarray.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/xarray.h b/include/linux/xarray.h
> index b4d70e7..0588fb9 100644
> --- a/include/linux/xarray.h
> +++ b/include/linux/xarray.h
> @@ -36,7 +36,7 @@
>   * 257: Zero entry
>   *
>   * Errors are also represented as internal entries, but use the negative
> - * space (-4094 to -2).  They're never stored in the slots array; only
> + * space (-4095 to -1).  They're never stored in the slots array; only
>   * returned by the normal API.
>   */
>  
> -- 
> 1.8.3.1
> 
> 
> 
> 

      reply	other threads:[~2020-07-20 12:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20  4:17 [PATCH v1] xarray: update document for error space returned by xarray normal API Wang Long
2020-07-20 12:03 ` Matthew Wilcox [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200720120310.GV12769@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=w@laoqinren.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.