Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4440053yba; Mon, 29 Apr 2019 21:03:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqwfUd7acCgTEnoJGNFLfV8MB/RoDgMe2NGNHX++thRHs1nCgurf+MnHGMxYalwZ7LWGLg0e X-Received: by 2002:a63:2c06:: with SMTP id s6mr64010532pgs.245.1556596992311; Mon, 29 Apr 2019 21:03:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556596992; cv=none; d=google.com; s=arc-20160816; b=JX+IR6vQj92YgAx2IEvbMt4DyYmmHHVPKacg2dpm6NBENa7KjZ3ulk3vU5EeINIvWt SgJHCJy7A878PJ93fnY8zsXtjpdMSp9ul1X6PpXAbYWeFGz4F4udgox6Tv7JAofJO6Ov iDL8dU0+yRUly31mA3kyEDF1f2QSc08VgKCMNibi/wSLG3eVA5TPsQX6skA99anKO7n1 Ft76za0BFpeiq0rOjUA+0tO1itQtXDHVkBZHyL9dKf5sP6T/ICATTpfjy38swaXS5qvM T8PLos3rInOVJdDhEOol3mslUfYw9VAD8r8VgVOyWL3iMyIOO2Y72Au3bQERs3kxq85b Tauw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ltDh4BkKvcXbbAeNA1Hv7LRFTxdoEvXNx8i0Qhmwv4I=; b=ycQggHiBTiWvKoB8bqJOUWh1lQzJw2iW25iY2Ph1QU/rb4iIVKUqju7F4BfM1CCt+i GdvR0gF9rNxfhMXBXQOePSaadnWjRvF42LiAeb3VuH0Ek2kWbDbr3y/4WJZOj/30rtB4 ZgpcFnibJoPkYRm8gh0jVcmpKCVdNf+0Ace6QREzwm/UwrCfdcd8UYJKRyKOj6hogWcb CalWuhKR05cEAVaV1cwRt2py/baiFjWWAKOsCT4nJ29OLxW/d5QoZZPZcAOSfPGU/0FI oktGks/+HQjPxKb0+haew1bRTThD7HD4ZVRrO5Jam6ihOuPXrIIX+Kd1nGZ/lD5I93sO MA0g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si35334073pgq.216.2019.04.29.21.02.56; Mon, 29 Apr 2019 21:03:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725973AbfD3EAq (ORCPT + 99 others); Tue, 30 Apr 2019 00:00:46 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:38260 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725268AbfD3EAp (ORCPT ); Tue, 30 Apr 2019 00:00:45 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hLJwh-00071y-Ft; Tue, 30 Apr 2019 04:00:43 +0000 Date: Tue, 30 Apr 2019 05:00:43 +0100 From: Al Viro To: Linus Torvalds Cc: linux-fsdevel , Linux List Kernel Mailing Subject: Re: [RFC][PATCHSET] sorting out RCU-delayed stuff in ->destroy_inode() Message-ID: <20190430040043.GH23075@ZenIV.linux.org.uk> References: <20190416174900.GT2217@ZenIV.linux.org.uk> <20190430030914.GF23075@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Apr 29, 2019 at 08:37:29PM -0700, Linus Torvalds wrote: > On Mon, Apr 29, 2019, 20:09 Al Viro wrote: > > > > > ... except that this callback can (and always could) get executed after > > freeing struct super_block. > > > > Ugh. > > That food looks nasty. Shouldn't the super block freeing wait for the > filesystem to be all done instead? Do a rcu synchronization or something? > > Adding that pointer looks really wrong to me. I'd much rather delay the sb > freeing. Is there some reason that can't be done that I'm missing? Where would you put that synchronize_rcu()? Doing that before ->put_super() is too early - inode references might be dropped in there. OTOH, doing that after that point means that while struct super_block itself will be there, any number of data structures hanging from it might be not. So we are still very limited in what we can do inside ->free_inode() instance *and* we get bunch of synchronize_rcu() for no good reason. Note that for normal lockless accesses (lockless ->d_revalidate(), ->d_hash(), etc.) we are just fine with having struct super_block freeing RCU-delayed (along with any data structures we might need) - the superblock had been seen at some point after we'd taken rcu_read_lock(), so its freeing won't happen until we drop it. So we don't need synchronize_rcu() for that. Here the problem is that we are dealing with another RCU callback; synchronize_rcu() would be needed for it, but it will only protect that intermediate dereference of ->i_sb; any rcu-delayed stuff scheduled from inside ->put_super() would not be ordered wrt ->free_inode(). And if we are doing that just for the sake of that one dereference, we might as well do it before scheduling i_callback(). PS: we *are* guaranteed that module will still be there (unregister_filesystem() does synchronize_rcu() and rcu_barrier() is done before kmem_cache_destroy() in assorted exit_foo_fs()).