Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2898602lqo; Mon, 20 May 2024 23:51:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXfDav8Ea8AjTNhtxxUsjgvL78fjysvoMkpcM1Q5gP9dN5LAg26wwqbaByHLNHejPp6tVBHYHOIXAZJciDKXh9+EECw0E3bOk0dZOGflg== X-Google-Smtp-Source: AGHT+IHN7Fg37ibS/LT29sfqC46YrcWUKmP1oWEDK4wgc34SM9TYPJsEdX0a0R1qsXUQRBiLHv6J X-Received: by 2002:a05:620a:4086:b0:790:b205:b7b9 with SMTP id af79cd13be357-79470f0c008mr1379687585a.27.1716274290826; Mon, 20 May 2024 23:51:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716274290; cv=pass; d=google.com; s=arc-20160816; b=q6O/uZTZnztSh9winLkD7jmLG6+gl3XlPtiRBMLNllXl3OsmY5m/JMhECHVnlebhlW vVf2a/9MIWr/daBV+ARrw1iKt8pAt9URlm4IFGJDzongUSyJkz4A8l2SAVW7P5RbJbeN 254CEYkEDTLjHfH1RPYdIRdFQDtbRHIj2nHSJFDGy3jYoIEcbjTLvbSQzfuRW5lKBoiI jt7mhDqVAJ6rtsDfE8kpvrRsaTZIvcAb1rmmsec9h/8ZsdzEa47siUs0VW7q1fb8zsLr c4jodm3xmv3uL8gbEtLPmN60bBatwuWD/74tVwTfoGq/Q2H5ofm808kHEMg/cXha5+nR Rzdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=YlJ85IoVGRgtAyGr1x5qdaIWxHz4yG8tHOeTj8CXgJM=; fh=ZoaKWawxKzRV8+1aMXax3G3uo6OriPLjuHWg3NTzKac=; b=XBiuCvw9FadPx2EuX98+rJ6alY1p9W5vq1Ub+q09ZYJb7CJJMRKGcCMBD/0d6ksxsF TN0Yp9J8ViRnUshxC96C6SvHCKpWoQNHuQZBtcF+xCyXdy3/w06zUbLGtK4Pn/jz1v60 VRUjZxbeNMTZodHShNbYqbqxSzyz3jnW+iZQyBdH6ioGwNRWBaGc/Baiwgn86mDmHF/y fhVi0odhEYa4t9Xho2ABIeT9U8uM4sKG294XlJ6tMEW0LGJKUsWCAmXd0M0RKL5PpAqb O2ae8W5GLMR2kUPuDnOT4/9SRYhn0gvtF6u05mlK7dRRl4e0bB/ibcwiUaAZRRuu5yeW cxpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=EeSe0PQD; 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-184532-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184532-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. [147.75.199.223]) by mx.google.com with ESMTPS id af79cd13be357-792bf29a30fsi143473485a.214.2024.05.20.23.51.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 23:51:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184532-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=EeSe0PQD; 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-184532-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184532-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 8F72A1C21397 for ; Tue, 21 May 2024 06:51:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6DBDD4AEF0; Tue, 21 May 2024 06:51:16 +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="EeSe0PQD" Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) (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 5C02D4F5E6; Tue, 21 May 2024 06:51:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716274275; cv=none; b=EnyWI4qP+xWTN2AZcncNjjF/+LeEe7HzM8lf1RpERoIbzhz3ZrYIYzwJFslBDOLhmkcQTIt3ygVkVP/poE2gxOkSlmQkKwHjDdtxCKGYz7tL6TWkp3ZcXNAfeu42QIgTXfKl1ZNaETrRFhBWiNAIANDCQ+0W/7ZOrwW6yC8Auf4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716274275; c=relaxed/simple; bh=Hu63G6HieVsu3NRYaVKJ+LFwFCggNTekdAjaGlRHP1M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hiM/60SzIsauR5Nz1DvwitHdTcWFcEfdk9FIgGP0WyIUOZNYehEi+Et186+d+h2Xx8RdOVV9GvoyqDFC8DhmbkPXqOTk7uLKNHLVYZBSNeVHxfLGma1sYs70ZQWEFFGphoAObQ2793s8rivrTmRoRtNgDdAuw6+gDkG0imxbo4o= 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=EeSe0PQD; arc=none smtp.client-ip=115.124.30.130 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=1716274271; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=YlJ85IoVGRgtAyGr1x5qdaIWxHz4yG8tHOeTj8CXgJM=; b=EeSe0PQDCAXSUshW/dK1WNGG42gnGfp4CnDK4+g8+ZNSnVRmOAxQB5XHnPX1E41/7ZOis4BRPBll58b3ggV4oag1rYe9Q2lWf0zWQ+oSYq9DxaaTDHDg+02YHgSpi6W9BxPjlFOb/D2Bfq+DyS248s5x0wbtW6LwpOrkpSpJVsc= 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=maildocker-contentspam033037067109;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=9;SR=0;TI=SMTPD_---0W6wi3PC_1716274267; Received: from x31i01179.sqa.na131.tbsite.net(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0W6wi3PC_1716274267) by smtp.aliyun-inc.com; Tue, 21 May 2024 14:51:10 +0800 From: Gao Xiang To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: linux-erofs@lists.ozlabs.org, Baokun Li , LKML , Christian Brauner , Jingbo Xu , Gao Xiang , Chao Yu Subject: [PATCH 6.6.y 2/2] erofs: reliably distinguish block based and fscache mode Date: Tue, 21 May 2024 14:50:53 +0800 Message-Id: <20240521065053.4192636-2-hsiangkao@linux.alibaba.com> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240521065053.4192636-1-hsiangkao@linux.alibaba.com> References: <20240521065053.4192636-1-hsiangkao@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Christian Brauner commit 7af2ae1b1531feab5d38ec9c8f472dc6cceb4606 upstream. When erofs_kill_sb() is called in block dev based mode, s_bdev may not have been initialised yet, and if CONFIG_EROFS_FS_ONDEMAND is enabled, it will be mistaken for fscache mode, and then attempt to free an anon_dev that has never been allocated, triggering the following warning: ============================================ ida_free called for id=0 which is not allocated. WARNING: CPU: 14 PID: 926 at lib/idr.c:525 ida_free+0x134/0x140 Modules linked in: CPU: 14 PID: 926 Comm: mount Not tainted 6.9.0-rc3-dirty #630 RIP: 0010:ida_free+0x134/0x140 Call Trace: erofs_kill_sb+0x81/0x90 deactivate_locked_super+0x35/0x80 get_tree_bdev+0x136/0x1e0 vfs_get_tree+0x2c/0xf0 do_new_mount+0x190/0x2f0 [...] ============================================ Now when erofs_kill_sb() is called, erofs_sb_info must have been initialised, so use sbi->fsid to distinguish between the two modes. Signed-off-by: Christian Brauner Signed-off-by: Baokun Li Reviewed-by: Jingbo Xu Reviewed-by: Gao Xiang Reviewed-by: Chao Yu Link: https://lore.kernel.org/r/20240419123611.947084-3-libaokun1@huawei.com Signed-off-by: Gao Xiang --- fs/erofs/super.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/erofs/super.c b/fs/erofs/super.c index ea9bb0ad2a7c..113414e6f35b 100644 --- a/fs/erofs/super.c +++ b/fs/erofs/super.c @@ -786,17 +786,13 @@ static int erofs_init_fs_context(struct fs_context *fc) static void erofs_kill_sb(struct super_block *sb) { - struct erofs_sb_info *sbi; + struct erofs_sb_info *sbi = EROFS_SB(sb); - if (erofs_is_fscache_mode(sb)) + if (IS_ENABLED(CONFIG_EROFS_FS_ONDEMAND) && sbi->fsid) kill_anon_super(sb); else kill_block_super(sb); - sbi = EROFS_SB(sb); - if (!sbi) - return; - erofs_free_dev_context(sbi->devs); fs_put_dax(sbi->dax_dev, NULL); erofs_fscache_unregister_fs(sb); -- 2.39.3