Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp1675146imw; Tue, 5 Jul 2022 13:32:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vllzCH1XHkLb4tMS6nilkGKgJW2l/Ef3fsftU6Pxojlm0ROOPs6cDcplHlecDVMf/2Q/GB X-Received: by 2002:a17:90b:4d05:b0:1e0:b53:f4a3 with SMTP id mw5-20020a17090b4d0500b001e00b53f4a3mr45560474pjb.3.1657053121992; Tue, 05 Jul 2022 13:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657053121; cv=none; d=google.com; s=arc-20160816; b=0AjOKgbne1eWwcrOZ+LvgHsLx2BTx6Hl3EE53KO4Dq+AXXgjCjxbcxH1RNJbWkkUfO bg7P8+CbMNUUVzwtgu22vwUhM5KIuf7OxoGtu/F1xLkp/BYRdqjxS7BBodyX8K1mvQe6 FOtkUZBBhU2vZbrUZtijXYspjAVwiG/wY2kyyz3HuEgoNRnvxvE+5wQFzFJY/KH4wDJf kIvFROoQl15hHil6TugSognDRpUSj1cOsicEuUltZl/E12kN5CgKELZxZ4jbpOdlor2u 4n8FBc+hgRqv+6+yxXjm+D0vnhqKM+Fk1+4fpjUXGIR9K7w0KrPxbwFqAdADM9eDHeTJ 7qoA== 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=K09u3BTeWpo+6I64to3zCKlnogCRvue0V/mHY0f5E/Q=; b=LP7z3yS3WbxTJww9T9pzmuSpXF0Amsy2ReGu7PiqKoqNuMvBBXk6NFc7cpE7nqu2V+ Vr4lU0Gm9Y3xgGUDRqqnQJC//tBDxYe0TUmYfgz1T95wwllP9JaUWTYlVBs0mikPG/+E +k8n4bgjUkgW/Z2PVqk7ZN1Kaj2iukvYpmZBjYZaj5fl4XtLlJTy26tvycYb+tHh54xb 6KOxamMJG4fjYRAffiLOFp9AB+kU4TWOmRK+pYPY17LPTTXpXdZDcQ6WJEX4NyZRSZhR z5TGE/1hXMGtNNOJhvxdJ0G8FhOa4KVcQTJj3NQ338GoNl/3aEHRSxe5faU33uIeQ4d8 0xxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=l57h2cRb; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a056a00150700b00525369ece8fsi49097214pfu.89.2022.07.05.13.31.49; Tue, 05 Jul 2022 13:32:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=l57h2cRb; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229653AbiGEUaC (ORCPT + 99 others); Tue, 5 Jul 2022 16:30:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231239AbiGEUaA (ORCPT ); Tue, 5 Jul 2022 16:30:00 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7122C1ADBD; Tue, 5 Jul 2022 13:29:59 -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=K09u3BTeWpo+6I64to3zCKlnogCRvue0V/mHY0f5E/Q=; b=l57h2cRbrO6Lg1HhRVycuIT/Kf oy/j+j8TitmuTC9psjEhtXWHbAfC0zhXA46E6lUE3+COlb+F/dlExPfMrkI+iEwxNOzH/PXaKzszt I8nI0tl9b7eupBxd8uyiEbAdRB9LngWJ/nQ/nh8VThmiBMZbcZfMsiOxh4vLc1iQQcJ6nHUPfnVMf O/TwACOda5fGjMAYrn3femvZ2m5QEUo8l8ql+CmN0lv3F8/qRGunKw7kJO9vXg0MR43HhesiLw7r2 peV5uw0+N0m9szbczf4Vzl/LsFL11NP7g4Q328lScBhez1i+PvLAWCUSY/Iisol+pOuSTiHfxcXmr D62QgbZA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1o8pB8-000tQG-CR; Tue, 05 Jul 2022 20:29:50 +0000 Date: Tue, 5 Jul 2022 21:29:50 +0100 From: Matthew Wilcox To: Filipe Manana Cc: dai.ngo@oracle.com, linux-btrfs , gniebler@suse.com, "linux-nfs@vger.kernel.org" Subject: Re: bug in btrfs during low memory testing. Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Tue, Jul 05, 2022 at 09:26:47PM +0100, Filipe Manana wrote: > In this case we can actually call xa_insert() without holding that > spinlock, it's safe against other concurrent calls to > btrfs_get_or_create_delayed_node(), btrfs_get_delayed_node(), > btrfs_kill_delayed_inode_items(), etc. > > However, looking at xa_insert() we have: > > xa_lock(xa); > err = __xa_insert(xa, index, entry, gfp); > xa_unlock(xa); > > And xa_lock() is defined as: > > #define xa_lock(xa) spin_lock(&(xa)->xa_lock) > > So we'll always be under a spinlock even if we change btrfs to not > take the root->inode_lock spinlock. > > This seems more like a general problem outside btrfs' control. > So CC'ing Willy to double check. No, the XArray knows about its own spinlock. It'll drop it if it needs to allocate memory and the GFP flags indicate that the caller can sleep. It doesn't know about your spinlock, so it can't do the same thing for you ;-)