Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp1283844pxf; Fri, 2 Apr 2021 06:28:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1qymvB/wtLybjBv/CqZQNIanQBQDPIU+qKjZKZn5CHkN/qn7nYEAS/aAc4Rr/KohxHlEq X-Received: by 2002:a02:aa92:: with SMTP id u18mr12895934jai.119.1617370100325; Fri, 02 Apr 2021 06:28:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617370100; cv=none; d=google.com; s=arc-20160816; b=dStlAO6lJvNbbAyNL7QPBOENe02GpwgmuJgYsADQHGu2GChKoZrGBUf44rKzBMOaRy fr7TKJZtXDtA70kkBP5GHqSC7ACgH6nG36uW06fNjLDyN1Ulogklmtvg7cWQI2Q1Va56 DO8NPl+2NRgtshBha0fLJ9DgNqgZfcStKJDBbfUxRCBPCdUwRhmfO33nQTkctIkRQ8+s ldqjuuurce8LQfWzLfHeOU+uv0mIhj53ITKf30kDA+GLSWMN9oMB/lsiCPobARi+AqCj LcA0+XWI1ZvOdy32foVOMZAaNiezg7moE4XQ42zkM1F+Gwf3+kPn96iocX+HNPH94dwS 0mgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=Quv+d5ruToqASsYHkDYyM+RNKRKLkPKY2MzE/OEcBCc=; b=wNq906WefYnqRGBE0TchBbtqZN2mVvoqAoNcHZIff2xQpq3Fz7x6KYZrnsDdPTgoJD lSevUz3UVJRjdvp6vlGV+jEKRxH1A4NOBzqpUrZvFUj+8nWXuvmT9AXI6+Xso7Fr4CKf M+jMB4wTBlC7G0vXKXEQKLoHEv2ALJikUSgTPigaYwpYK07rf3HmLnQzKpmPaWIHSC2p cmD9mVVLT0lMJvrQyaCIntfqFRVi7E87KwRL3vi+8stSoXXp76bUcHnH1REXhzs6e0qd K15oasobSztfwBZZYV7ixaOFoK826Q3cKbNcQGer5JpwxbLaRW+SXESENs4wn8TPeXXt Yq/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=Hn4p16U0; 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 z8si7379760jat.80.2021.04.02.06.28.06; Fri, 02 Apr 2021 06:28: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=pass header.i=@infradead.org header.s=casper.20170209 header.b=Hn4p16U0; 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 S235477AbhDBN1o (ORCPT + 99 others); Fri, 2 Apr 2021 09:27:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229932AbhDBN1n (ORCPT ); Fri, 2 Apr 2021 09:27:43 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE78EC0613E6; Fri, 2 Apr 2021 06:27:42 -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=Quv+d5ruToqASsYHkDYyM+RNKRKLkPKY2MzE/OEcBCc=; b=Hn4p16U0Xxhq5upbBRvlz8n2ox zWm3vcPITR6WIgIRjEtrgfbpywR54mfRiOw1cS0cS9diYxrum7asLMiUvNEtR/bUQa9suts9rquNt 6h5DAKJQR8mxrMOT6YRTTRA2o9i73/i4wO3P43uXwZ/0kXaIRnEjeWSgQwXrfi/N/LUHpJalqporl HfQAdmqsnJh/m1SlQtGsDDjmv81jNN5D6vhUhWLtxaZyNq1MxY3XN5tDgMXYqNBQBTO9ljSjUqaFY pP5P053z76nhNadrx0wLL6GPQXV/dEzbk9NmQ68ylZ8oFQW2QYwjZRVpLURl9rRZnVeP4iXMTBLn+ cRrcvYcA==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lSJpM-007gLj-Br; Fri, 02 Apr 2021 13:27:14 +0000 Date: Fri, 2 Apr 2021 14:27:08 +0100 From: Matthew Wilcox To: Hugh Dickins Cc: Andrew Morton , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-nvdimm@lists.01.org, linux-kernel@vger.kernel.org Subject: Re: BUG_ON(!mapping_empty(&inode->i_data)) Message-ID: <20210402132708.GM351017@casper.infradead.org> References: <20210331024913.GS351017@casper.infradead.org> <20210401170615.GH351017@casper.infradead.org> <20210402031305.GK351017@casper.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210402031305.GK351017@casper.infradead.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Apr 02, 2021 at 04:13:05AM +0100, Matthew Wilcox wrote: > + for (;;) { > + xas_load(xas); > + if (!xas_is_node(xas)) > + break; > + xas_delete_node(xas); > + xas->xa_index -= XA_CHUNK_SIZE; > + if (xas->xa_index < index) > + break; That's a bug. index can be 0, so the condition would never be true. It should be: if (xas->xa_index <= (index | XA_CHUNK_MASK)) break; xas->xa_index -= XA_CHUNK_SIZE; The test doesn't notice this bug because the tree is otherwise empty, and the !xas_is_node(xas) condition is hit first. The next test will notice this.