Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp330503lqi; Wed, 6 Mar 2024 20:19:36 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXVAMQu+jc8pxK2fIpAs89yFeWzNqAYQTRtzENK7wf19NZAbbmIkyQfwYVlG7sV5k8OGLiQzarJCqLcCu9w0290nlF3J3lg/0vijx/big== X-Google-Smtp-Source: AGHT+IG/f5C+jfHa93C1Btp1N2qsYKyRRww70351qhKxbNkVPoGBaDtVPA9UpCPFlAAslulzNxhv X-Received: by 2002:a05:6a20:2e26:b0:1a1:4b57:4e9b with SMTP id be38-20020a056a202e2600b001a14b574e9bmr5350587pzb.60.1709785176013; Wed, 06 Mar 2024 20:19:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709785176; cv=pass; d=google.com; s=arc-20160816; b=Yf/KSo/n3L83/6R7rq8VM/Hndy/83HVxVOW6rwJyUlCGs2/RuD+NFECXL10D/3OUni iXVpwWCfxxqZVV5W+7jLF0rTnYjtpfdvrpbucJKsiHLuBO5tq1YAfD9r4W0pOD0a+qPy LYCvRq/G1TISb3ztkUZXAe44Zz/tpkPz4QSalJ2ooSi4exmow/4KiAaEj8ejo1Ne6DQY nrDsguWGywv07UZ4cGkYEI1JEyArO0lbOq0NVuRIV2jVE4x8c5qJArBl+8PW8tLYYFcQ Vbx2mBHMbJoMN0j4EEIXLgqdZ78FFlMIW1P5CyeAKOxDd4ABKhaqtmavER7KzkepKYs4 MEZQ== 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:subject :user-agent:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:date:message-id:dkim-signature; bh=/JXmXA43vVqGhsDtEFhDqf2Cvh59uxiblaNOZ07Oi4I=; fh=HFOsk/G+9xbFmyCjmKbcJnLGeCWb9J1sgREBrY6r+b0=; b=MTc2eZ7oEK4iZTq4Ni0XsLluVvSYSftQQE6EzOHATK5Z7nll8EWCtyY/59GZAfVSkt APLUbvU4iPFJpXa8COcys7KK03ceAUlbMoZTVjIzw3q2wsZvty+ME4MFggqoVQFBGL1C jSHHG9ePoIKNN7Ev7dNB+e3/+qvLD30qRqets8SX47lG/BmwMte1IaRP7RCehlZqc3lm zBh3b6hK4tk6JTbLMaNMQ+Jn8vRk7v8S5T+I0dikNBxijLwQMbU3ZplNbng/xhMp06WW +usmbGgSVw7E2xK3J0xYnwR7+H1RX16FNqJrmz/UicgJ4WYn/ntCBhlNfMaXnm+z2x97 yZ/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=vqJck7GO; 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-94956-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94956-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 sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id ce22-20020a17090aff1600b00299bceb07e2si884279pjb.11.2024.03.06.20.19.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 20:19:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-94956-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=vqJck7GO; 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-94956-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-94956-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id BA8DBB2221A for ; Thu, 7 Mar 2024 04:19:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CA461BDC4; Thu, 7 Mar 2024 04:19:03 +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="vqJck7GO" Received: from out30-133.freemail.mail.aliyun.com (out30-133.freemail.mail.aliyun.com [115.124.30.133]) (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 BBC741BC40 for ; Thu, 7 Mar 2024 04:18:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709785141; cv=none; b=HtDEWQ4c+U1Q43OCNAmvyCod7XCwR5AQyd5IbAKrfpw4ygDQmWlGrMALk+52uFjLQzwGT1uTPRAus+61wczmuPGb89TfYZBR5ljPG5jR9bFVkBbN+/cXmutHL1ggb3gp7QGyimGKnEiaapuCKvGySgBOFVxJnpYZkHXDi9ywthE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709785141; c=relaxed/simple; bh=x2ntiD9Wl2H+gX3Wqu3ABX5fwwVger6QrHwwL2dakV8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=d0qYx7I6+ehIgAQCzeE1ADeAk0/0fQC6EooMc7ETRhOsMizKytle221oPW5ROrblephOm10o4E5RAb94dHmmBFy0V/7NbFU4NoWHuXg8qsik6Kdd8j8c9jVYeAGsnpvDMpZGDuW84Scc1+gFQ+0o40tRdyfxho1ZDN+8Z/u5LbA= 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=vqJck7GO; arc=none smtp.client-ip=115.124.30.133 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=1709785134; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=/JXmXA43vVqGhsDtEFhDqf2Cvh59uxiblaNOZ07Oi4I=; b=vqJck7GOABFmM4D1qXRj29hbrQ2iDo79rRXz99QK7A0ovyd6m99ap3F5IPAhhE5UGiTwjWrFmsw5VSofXbLMhqT81kIJiS7mFTi1it9uoj2OayFetiq48TEN+IMz84j/ysAjOWde7cTgqhMYtzu4CKGGMxn7ZgTwgynhBmgQdjw= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R131e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046056;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=13;SR=0;TI=SMTPD_---0W1zMWuU_1709785132; Received: from 30.97.48.224(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0W1zMWuU_1709785132) by smtp.aliyun-inc.com; Thu, 07 Mar 2024 12:18:53 +0800 Message-ID: <38934cc4-58da-47b4-a120-00a2f3a56836@linux.alibaba.com> Date: Thu, 7 Mar 2024 12:18: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 To: Jingbo Xu , 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, Al Viro , Christian Brauner References: <20240307024459.883044-1-libaokun1@huawei.com> <7e262242-d90d-4f61-a217-f156219eaa4d@linux.alibaba.com> From: Gao Xiang In-Reply-To: <7e262242-d90d-4f61-a217-f156219eaa4d@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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's much appreciated to get more inputs of this, thanks a lot! Thanks, Gao Xiang >