Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp318176lqi; Wed, 6 Mar 2024 19:42:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWr/mpqrNNpNMi0bGycQKV/qD2GnckBwlP7+3dyyhwPK5LfxKZIAUswH5S9yLswZgqgZIqiO/IXYf0w8MLqMyOQlZ7FtK8Wt2dehkK1dA== X-Google-Smtp-Source: AGHT+IEnhtxmuU1Xq8nJRqW/z/Z+cvxOiKjo1WWPklVfIfC6f7oNZqxBc82ZcanwiQ+GeCEEZTsX X-Received: by 2002:ac8:5d8a:0:b0:42e:eba3:5ef3 with SMTP id d10-20020ac85d8a000000b0042eeba35ef3mr7617553qtx.59.1709782927751; Wed, 06 Mar 2024 19:42:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709782927; cv=pass; d=google.com; s=arc-20160816; b=ha4w0WAvyREqlqBJlSjGVpoaRaEo/kWecIT2fQ8Yu6rpjeyygVaLQGQY36tN3LfAXE KyCZnMXAsD8bnYsBX/wjC5hm2c42hasV7ahmZYm0Zc0AyFpLpiCiUmnCcyVA+buwKR4u 1jT0IiPqqvOljTK02f3Bm+A6VcihULxrJao9Rk80NE7Ekj1nmB0XiHAgxHTfOKs9Vkcp c5Qup21M0rJMi/bLA5NjjsrIj1gCwakxcCdQ+XP7ERi4S+7uJ3+B4WLPuDbEqNyIkszO TTruuM0qPyYWy21zxadmy7kKtqdky1Me7Z692c1Nye8aYEI/TdiX0gx0r1fLo9WCGIQf Zz0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=q4PBY43ikf/oTLhUi+LnbpgksNhIyzwTQbdt2BgU8vs=; fh=tpA7YpP70E79egOgOdZh9YfkbUnQ9pVVD+GJ4iLxTgc=; b=YxiQpPNFHP7tG3Cn2uhLfE5H0dKQTCwq2V6o6U86T9Q+skthWe/gUfiZV84SAlEfSg WQPt/BS4V8fk1XMHpGSfNsWzF34+hlRi0LlMVSwjOMes6/327swa+I/ZJeCPFlRAYLAT eFcJ00XSrLUDQb5oQRBEnihgM4bJjFtqaVxR1KXrcixbW9lEM9gw5ZG0GDdQnJLuUN8n KRit3bknCPoRbhM2uEEHPYsqNPO6quB84EUqFbQAJOop3Aq2iCp5ga+8GQzvP0GCCVte KmzLK8hha21V5fKH5i9rxl6ZhtJA5iINqUeu70UaRATwondHuRkvQn/qt+8kOeNC+DX8 8E4g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=cnH0gaQ1; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-94940-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94940-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id wh4-20020a05620a56c400b007884205251fsi2080325qkn.640.2024.03.06.19.42.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 19:42:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94940-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=cnH0gaQ1; arc=pass (i=1 spf=pass spfdomain=linux.alibaba.com dkim=pass dkdomain=linux.alibaba.com dmarc=pass fromdomain=linux.alibaba.com); spf=pass (google.com: domain of linux-kernel+bounces-94940-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94940-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.alibaba.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 53F341C217EF for ; Thu, 7 Mar 2024 03:42:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E61A101CA; Thu, 7 Mar 2024 03:42:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="cnH0gaQ1" Received: from out30-113.freemail.mail.aliyun.com (out30-113.freemail.mail.aliyun.com [115.124.30.113]) (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 2C23A522A for ; Thu, 7 Mar 2024 03:41:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.113 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709782921; cv=none; b=O7+fXN10jihJMZSRuGmCBL+2ONO+mHC/p2z2U1w8xxjnjD23UjOkJ8FFX4k2EtYZ895hRChUd5KI5FazKKw597yBG1L/gx/ZiwmAEgB5fSBnmKmJO0IZj8k3Uwv5OiNG0QXJ/DGwEXsq5c4i45v9j8DiTWMl9JNmcCgxxbJhaWI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709782921; c=relaxed/simple; bh=uJ2iXSj75dq6W7miQZ7u/xspgpwQuAlIO6Bxb6G08y8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=nTENr347+W49dpq9sMMSew9vT6NofLjEm7JzTgpF/Qi9tdIYyfm4EWEmLB7ju5yGA2JNmTti5hCFQ9NG4k/LXCIy7Kjf48h7rT9gy1cCnFC2V41JvTcBUWJEk3Q1BKE2kEuipVafwD2blSx49ZL8gOMuOxIIwrOA4FKV5Do77ac= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=cnH0gaQ1; arc=none smtp.client-ip=115.124.30.113 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1709782915; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=q4PBY43ikf/oTLhUi+LnbpgksNhIyzwTQbdt2BgU8vs=; b=cnH0gaQ1S4kVFiBPwQZUF9xi7stUPQIYcZooLiANo+3MuGRl/SblegAd/JAN9GYrj4m/b5e1M5bfzcaB9JYTN5/8XA5LxqGHpE1cde47Tj9BI0ni1+EK7rIze/JV5KBl1Dli+S4XzoLbJqzgyZtAytIjYUL6naWHECRoDhznXtE= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R121e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0W1zLd.n_1709782913; Received: from 30.221.148.124(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0W1zLd.n_1709782913) by smtp.aliyun-inc.com; Thu, 07 Mar 2024 11:41:55 +0800 Message-ID: <7e262242-d90d-4f61-a217-f156219eaa4d@linux.alibaba.com> Date: Thu, 7 Mar 2024 11:41:52 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] erofs: fix lockdep false positives on initializing erofs_pseudo_mnt Content-Language: en-US To: Gao Xiang , Baokun Li , linux-erofs@lists.ozlabs.org Cc: 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 References: <20240307024459.883044-1-libaokun1@huawei.com> From: Jingbo Xu In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. -- Thanks, Jingbo