Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp432575lqi; Thu, 7 Mar 2024 01:19:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU4fft9fuhnC0W1GlddlbpSip22TEKbgsCwKx40h3gTN+aI5B6stAxVqR2aEE2mcf4U4aBaZMJfqe7peAZj1M8QYul812xy2/bqdn3rEw== X-Google-Smtp-Source: AGHT+IFMoKsN++XzLGIJLQl+gZWaNA7vML+MbotlobETLZo9NocaHOnHRhadbBXEWTiXe18L+0sD X-Received: by 2002:a9d:684b:0:b0:6e5:704:63fc with SMTP id c11-20020a9d684b000000b006e5070463fcmr2246359oto.34.1709803174986; Thu, 07 Mar 2024 01:19:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709803174; cv=pass; d=google.com; s=arc-20160816; b=QxtyIeGHGVpKr+W0gd8GnoiGKK5Pvn5voRjDdT38TeG0JZ5DJxLUkb/fFhvqbuttOY IM6i8KPIsNkUpVsHd/rwS+ppJNubto1p7MA6Jial6nSkcK5DC1oKTghqus/duXvjnWKA KZ568vqxNryOGQU+2/Q0OMAACEVqyr72a7KpMCyNYB88iQzqVAk6XDDLtzmhszsSmqr/ BlFU9Gkb7Y6dQ4LkkArgnmzaeI8GykRkw9c63fqq33JsNMF/p2Sk8RNHmf3fwnYAwUiA BbB1rk8NpBQIqC9vE5VjtxuMARWckXjpBCMJ0Yh2sQdKANaqe7sUJxet/G0SFNvlsHcK Vu5g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=2m77T6+HNnQQ5U+XxXf7Va0X5mB/JBk9+jACA8Q5jNA=; fh=3mxl2Na4Sx6VRB87/FaxUs1zSc6BO2tXhhz9QIshGRg=; b=FutaU8ZCIufzwabRI2kv2289vjuBrvl2yW+TKA1g1qnJ/fOTpBFtFs12swH1cIqbvt OskKmSDMcsObiqOHV7944kKxvF3lZUD0vdcjHansn1VEXEX7ec//Te4rLgk0zso7Q25H B6CU7Vq4Oyhxdb81kIBmF6ECW0axZSbRPg/4n4PovB4UIpk+ZeC1LKy28iwQ3nWyVgdk abU/Xm5smwW7n21xLDFIa6Ng6s3j5Ksy/t24XIJV9I2zibGX7BAA247oCxAv1Gbn8UvH 8ZNz06Zys/E/FdS/eM59BTXQLy74ZfEGlpNQqE40yEmFrOQ5oRdgq2qPyFckgYxP0dI6 wj5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qOf2mOnh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-95196-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95196-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id h8-20020a635748000000b005e2b1e879d6si13415741pgm.370.2024.03.07.01.19.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 01:19:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95196-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qOf2mOnh; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-95196-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95196-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 180D8282194 for ; Thu, 7 Mar 2024 09:17:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 69D30839EA; Thu, 7 Mar 2024 09:17:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qOf2mOnh" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 873CB745FE for ; Thu, 7 Mar 2024 09:17:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709803039; cv=none; b=fLsiHR4kVSyMm6kkUrgFyIRTjSH3m2qUs8fmzjJ2LCAOfnSd7L26mFI+jUhFgrfBRONWHBxSVjZT/cJ7/XBdyiDhTRFy4ke7/5/rrgRo6jn4BKbBb4FmgsyjCKD63/93xRHk4zG125Qz5YutuIYvOwIFi9p7QJgkN171MoDZAjo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709803039; c=relaxed/simple; bh=+bGKQg2gdBxm1YSwaAYyFYRWm9IZnY03uaFZhMfjE40=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ppUvjMDLz+2uW8H0P3iiRxIlRv5B0iKRSfoc00cg/2GCuedNIAdpfXi0rGM8UcWNKN8AD4uoQy/LZerA33wynkjukYdu/OXvWQnyJohbsyy1s/hEIuIOMw5IPMzZhiqway8Zbyw8R8dEQG/Wc/y2rxO18D4VwCSAQr1Rm7zwPrY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qOf2mOnh; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C408CC433C7; Thu, 7 Mar 2024 09:17:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709803039; bh=+bGKQg2gdBxm1YSwaAYyFYRWm9IZnY03uaFZhMfjE40=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qOf2mOnhYvFMR3Gr6UCsDFgVUTfl4wkxaG4IFdwzxK+nZKyaUnPuNjb4EYHcBbIJA +BVyjXtwwzHgrfRRkh85dvtYTxSKXdpNl3tRz6mIIcxxZwEmHgxlZq6bMgPYd9/9w1 ysvl5fTNZWK3jOXGgNYLQvvc3+v57zl2ZMvw25uSqckg+IDfUClhPhAVA52R4kH2zp 2PP3veU2WuzWLMUsKTfCuzZDY3clWbg1os4RDEk5v6xEUGEShh1KwyG4ajqrbjS95U b5Vo8BrnyysKHo/crizgwVrVihJ68oE9pFSzGHdrsMme2BPphTy3A0++tAGAIPx2m0 6oxbE7mroTBZQ== Date: Thu, 7 Mar 2024 10:17:13 +0100 From: Christian Brauner To: Gao Xiang Cc: Jingbo Xu , Baokun Li , linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com, linux-kernel@vger.kernel.org, yangerkun@huawei.com, houtao1@huawei.com, yukuai3@huawei.com, chengzhihao1@huawei.com, Al Viro Subject: Re: [PATCH] erofs: fix lockdep false positives on initializing erofs_pseudo_mnt Message-ID: <20240307-segmentieren-sitzkissen-5086f5e1f99f@brauner> References: <20240307024459.883044-1-libaokun1@huawei.com> <7e262242-d90d-4f61-a217-f156219eaa4d@linux.alibaba.com> <38934cc4-58da-47b4-a120-00a2f3a56836@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <38934cc4-58da-47b4-a120-00a2f3a56836@linux.alibaba.com> On Thu, Mar 07, 2024 at 12:18:52PM +0800, Gao Xiang wrote: > Hi, > > (try to +Cc Christian and Al here...) > > On 2024/3/7 11:41, Jingbo Xu wrote: > > Hi Baokun, > > > > Thanks for catching this! > > > > > > On 3/7/24 10:52 AM, Gao Xiang wrote: > > > Hi Baokun, > > > > > > On 2024/3/7 10:44, Baokun Li wrote: > > > > Lockdep reported the following issue when mounting erofs with a > > > > domain_id: > > > > > > > > ============================================ > > > > WARNING: possible recursive locking detected > > > > 6.8.0-rc7-xfstests #521 Not tainted > > > > -------------------------------------------- > > > > mount/396 is trying to acquire lock: > > > > ffff907a8aaaa0e0 (&type->s_umount_key#50/1){+.+.}-{3:3}, > > > >                         at: alloc_super+0xe3/0x3d0 > > > > > > > > but task is already holding lock: > > > > ffff907a8aaa90e0 (&type->s_umount_key#50/1){+.+.}-{3:3}, > > > >                         at: alloc_super+0xe3/0x3d0 > > > > > > > > other info that might help us debug this: > > > >   Possible unsafe locking scenario: > > > > > > > >         CPU0 > > > >         ---- > > > >    lock(&type->s_umount_key#50/1); > > > >    lock(&type->s_umount_key#50/1); > > > > > > > >   *** DEADLOCK *** > > > > > > > >   May be due to missing lock nesting notation > > > > > > > > 2 locks held by mount/396: > > > >   #0: ffff907a8aaa90e0 (&type->s_umount_key#50/1){+.+.}-{3:3}, > > > >             at: alloc_super+0xe3/0x3d0 > > > >   #1: ffffffffc00e6f28 (erofs_domain_list_lock){+.+.}-{3:3}, > > > >             at: erofs_fscache_register_fs+0x3d/0x270 [erofs] > > > > > > > > stack backtrace: > > > > CPU: 1 PID: 396 Comm: mount Not tainted 6.8.0-rc7-xfstests #521 > > > > Call Trace: > > > >   > > > >   dump_stack_lvl+0x64/0xb0 > > > >   validate_chain+0x5c4/0xa00 > > > >   __lock_acquire+0x6a9/0xd50 > > > >   lock_acquire+0xcd/0x2b0 > > > >   down_write_nested+0x45/0xd0 > > > >   alloc_super+0xe3/0x3d0 > > > >   sget_fc+0x62/0x2f0 > > > >   vfs_get_super+0x21/0x90 > > > >   vfs_get_tree+0x2c/0xf0 > > > >   fc_mount+0x12/0x40 > > > >   vfs_kern_mount.part.0+0x75/0x90 > > > >   kern_mount+0x24/0x40 > > > >   erofs_fscache_register_fs+0x1ef/0x270 [erofs] > > > >   erofs_fc_fill_super+0x213/0x380 [erofs] > > > > > > > > This is because the file_system_type of both erofs and the pseudo-mount > > > > point of domain_id is erofs_fs_type, so two successive calls to > > > > alloc_super() are considered to be using the same lock and trigger the > > > > warning above. > > > > > > > > Therefore add a nodev file_system_type named erofs_anon_fs_type to > > > > silence this complaint. In addition, to reduce code coupling, refactor > > > > out the erofs_anon_init_fs_context() and erofs_kill_pseudo_sb() functions > > > > and move the erofs_pseudo_mnt related code to fscache.c. > > > > > > > > Signed-off-by: Baokun Li > > > > > > IMHO, in the beginning, I'd like to avoid introducing another fs type > > > for erofs to share (meta)data between filesystems since it will cause > > > churn, could we use some alternative way to resolve this? > > > > Yeah as Gao Xiang said, this is initially intended to avoid introducing > > anothoer file_system_type, say erofs_anon_fs_type. > > > > What we need is actually a method of allocating anonymous inode as a > > sentinel identifying each blob. There is indeed a global mount, i.e. > > anon_inode_mnt, for allocating anonymous inode/file specifically. At > > the time the share domain feature is introduced, there's only one > > anonymous inode, i.e. anon_inode_inode, and all the allocated anonymous > > files are bound to this single anon_inode_inode. Thus we decided to > > implement a erofs internal pseudo mount for this usage. > > > > But I noticed that we can now allocate unique anonymous inodes from > > anon_inode_mnt since commit e7e832c ("fs: add LSM-supporting anon-inode > > interface"), though the new interface is initially for LSM usage. > > Yes, as summary, EROFS now maintains a bunch of anon inodes among > all different filesystem instances, so that like > > blob sharing or > page cache sharing across filesystems can be done. > > In brief, I think the following patch is a good idea but it > hasn't been landed until now: > https://lore.kernel.org/r/20210309155348.974875-3-hch@lst.de > > Other than that, is it a good idea to introduce another fs type > (like erofs_anon_fs_type) for such usage? It depends. If you're allocating a lot of inodes then having a separate filesystem type for erofs makes sense. If it's just a few then it probably doesn't matter. If you need custom inode operations for these anonymous inodes then it also makes sense to have a separate filesystem type.