Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1695744ybh; Mon, 20 Jul 2020 05:07:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJweD0xFayolQjDLHDdNJtXSE9r/5Qu5UW3+C1+Nb8ajLpz+NpBYQKC/CA8kXDq+LmfI+X8a X-Received: by 2002:a05:6402:164f:: with SMTP id s15mr21213315edx.239.1595246840395; Mon, 20 Jul 2020 05:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595246840; cv=none; d=google.com; s=arc-20160816; b=q3HNo2MvEeNmbttPaqWxoFZDfkc4+IIiqmKpHYK3ZySiUCWN2MMnmM82zYoJHbh+Ko K+0+tEDGbj3T6yPsgYCqPDv4XlKlRaIkSrmUEDNByk4S5LLvFGJuipHyaBaZ6ORiqEV5 OcZUWHb0+JlWFmlFZfyaBdrr8CRkkBBXKHG1Hg5bs5CPeP8k8IWvwEiwFqjdZ/r+nVMN mAviykksO2TcB2o5bcMz08N9p4RHH1BbwQektRy3ct3RFxGv5iD+USxfwPOCO0CgWw8E 1fFfh3jl4q+fvwcHpCvIM0ciSZ+4voOIpUggI8GspFaOBepyJNddub3aRYropUtWThfH z9iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=r6dsj8pxTqtn3NLeQXECCjoNOIjatp7b7gHsR16dalE=; b=B4oLKZV1Rq7zbJM+zGQWVzvd/b2v3n54NsjuCwHH5mVJ7R4kx+j/z/HdoXYAeWUDrn SfGQtQ/BPpIzv97nOLmXT1hb/Z9HvunVfC4s3TszpYjU9IuFz+1scl+PXtmZYnnG+0HK XEs+nHdpKy6SUg+nZZlRv3Sx8PYrvfZdCNX+hlQVVeDnFh/IZiHwdTBajqwH+OLDL5o8 Mvf3YB9bsy9+eXgbHX5z7pefI5eX6gUXAbNbXaeR80xvtqbQSSRgG5bv/ezW/WSIUWIA hiICfcOqcAqHg0cObKSWq/eulmSlrkxhazoqu+2Ln7YHh9t4CYTHtfhH9ew2X0uHMjZx XYFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=G99G9fsl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k21si10521670eds.345.2020.07.20.05.06.57; Mon, 20 Jul 2020 05:07:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=G99G9fsl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728803AbgGTMDV (ORCPT + 99 others); Mon, 20 Jul 2020 08:03:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728572AbgGTMDU (ORCPT ); Mon, 20 Jul 2020 08:03:20 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5661BC061794; Mon, 20 Jul 2020 05:03:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=r6dsj8pxTqtn3NLeQXECCjoNOIjatp7b7gHsR16dalE=; b=G99G9fsltR8hD/EK9QDcnBEEz2 FQqtw0X4kXGCmPR/TyA6+POEoGYjCkwY3qg4zkV3LQxWPuj2J3tHRtw8RG31CXwcFesePGPczjqVE HbLM9v8+iPBDhpNMKGDPYYzvG62Fwwva/zH1F73qlENXRTOrGIb2LkC6qdC+s0l8pxbJdlFri0hN/ 52GP4VhKwqWIa0btJFBOdGMkIYyYdIo+RQq2FYBh5907sDhk7iPeP6ImcQ6PpdqcfiV4LUR7Sq2yD vITnkccfjhiSEmnbEq27DdbpfKMsrREHZx2bpFeigQxYVriBjbcUF9zJ+aB+hTwNw8+5rbE0GqOWT 4o+bKLxA==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1jxUVi-00029K-E0; Mon, 20 Jul 2020 12:03:10 +0000 Date: Mon, 20 Jul 2020 13:03:10 +0100 From: Matthew Wilcox To: Wang Long 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 Message-ID: <20200720120310.GV12769@casper.infradead.org> References: <1595218658-53727-1-git-send-email-w@laoqinren.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1595218658-53727-1-git-send-email-w@laoqinren.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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 > > > >