Received: by 2002:ab2:6203:0:b0:1f5:f2ab:c469 with SMTP id o3csp2205754lqt; Mon, 22 Apr 2024 04:53:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUENGng5yUcfjPu/JSJssfLY6i5J7XONBhaX5aJNDQMX94BtbcxATyqPAj/2EJUPWT0m6rR6f/R3UA+v2+yJXYrKvRBuGojziQkBfDsoA== X-Google-Smtp-Source: AGHT+IFKA5XrbKd9rYqDQ/UblaQTzYvNiLAJXOLdNYGxgqh/OrmLaxtm2fF+EeEA826AT+QsnabF X-Received: by 2002:a05:6a21:2d09:b0:1ac:4fca:23c2 with SMTP id tw9-20020a056a212d0900b001ac4fca23c2mr9386496pzb.8.1713786790134; Mon, 22 Apr 2024 04:53:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713786790; cv=pass; d=google.com; s=arc-20160816; b=RA2IeE75jroBKZiiulybU94kD+LsMzj1SlWN+9f1Lh1UNLSDvdfELOu0P93WfzFIrg nlrTAUNX+TdMcXswOlcG8+GR/42E4O9AFFR8Or5vntoLRfd/i6CbRtVtXMXu709zeM1/ 1el+x2+bZXWIjHUmzWJQuN1f9T9uJOVixgnNpev4/7k1u7KVlPSFUcvDzMVZpPHAoq65 7iGxk2g113f55JDbOZdGtspmD23e7hS5aGJ0f97+0shSt9mntE2/ejjJ8loHRMmRDryy yzQ+ZgROIwWw3CI2R2PWoly/Q/Z062yfIkevVrMpCdWB+GQjqPHBaEbRLkP+3zQewjF9 PwPQ== 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:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=sU0mTOrtGv3n30RiUAYhMQ3aqcRYrKnvJek+VBQiJqE=; fh=h4xgT+VjSOkXTJ1n8g9Vx/kXxmSZ6NLbRFy7FQaC8WY=; b=DS0ZWLqP7Xh4P/Lu2l8Dijisr3WM1/NRKAr6jsIPLvYTVT4h1iS0+/n1NbfiBFqG0v 6fapP73DCCEnO0q3iwc/vKkfIChePw42r7JxjVEgRv8WAxjuRC9Un8p9+zLOPLmf9tSr G+UpzJvKz4GS/CUMKeFuGpYY2NbH3Ldsc7EpBDwsJIzEeiTkYLEYkT23NcVmgVWRDLRF U80qy/3n7knY7au8VomeQ0ks+QMP34ph2TrO42ydOtBaOlF9A3gzb5PAnyF10ZPuzxVf UpJ0psm2pnD46Wfd3Z8PlPlxuHABg965lv3JTFsBXpjnm91GXwja+z/dlwOg88zAKCZr CVIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=GwDUQYNP; 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-153313-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153313-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 sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id p23-20020a631e57000000b005feb30ea489si2252673pgm.795.2024.04.22.04.53.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Apr 2024 04:53:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-153313-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.alibaba.com header.s=default header.b=GwDUQYNP; 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-153313-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-153313-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6140E284E4C for ; Mon, 22 Apr 2024 11:52:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 527C1146A8F; Mon, 22 Apr 2024 11:52:37 +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="GwDUQYNP" Received: from out30-111.freemail.mail.aliyun.com (out30-111.freemail.mail.aliyun.com [115.124.30.111]) (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 44E9C146A67 for ; Mon, 22 Apr 2024 11:52:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.111 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713786756; cv=none; b=uyiDqewjV1aozISov0fI9Kt4eVeNA1MUFY+8N1L/qJtPu+93FUmG9247pQDk7WQFri0sjHhNqkq/55spg+0yu5R16ZVi0aUif9yqUUNr1tlZlIy7cOJfvby6jeEDu0LTZ4XK2kcYpKk5UGgTjw9YQgj3GxfXN4K0OR0kOYd0jjk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713786756; c=relaxed/simple; bh=+f7rJs2cnBfRZEufrT0ZyBBpUIa6VOul1OeZmuWU9EU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=kagqgJXDcdHSwJtegE/jIjhIcrx8Z9znpXqYfB2rRPjRsVu5m5Mi5SJyTD28J5k/AHCWPffQWyZQK9JlClkwqWk9RIfmOMzRdRegGFbDaEytgP4c8hJuV2J/O8ObBG+HAMubGIhXNqToE8XWMatoe0bIb7fFxQ09i87430Z0qEc= 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=GwDUQYNP; arc=none smtp.client-ip=115.124.30.111 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=1713786749; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=sU0mTOrtGv3n30RiUAYhMQ3aqcRYrKnvJek+VBQiJqE=; b=GwDUQYNPKH6deu07HgJRODEqDEpgZs18SD8F20jzOkwtLZ3yMOsNuWL2bUt9l/p6V5FoSYdRgGdPOtiC/K69t2jDj492iHQlKYkRLHZB5E7l9zWAPRIOqocDr3vGdCrtxJupACQJGJBZ8oIJl/kL9ESj9+S/ZZlkFvqxry5IiYc= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R261e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045168;MF=jefflexu@linux.alibaba.com;NM=1;PH=DS;RN=10;SR=0;TI=SMTPD_---0W52wujw_1713786747; Received: from 30.221.150.42(mailfrom:jefflexu@linux.alibaba.com fp:SMTPD_---0W52wujw_1713786747) by smtp.aliyun-inc.com; Mon, 22 Apr 2024 19:52:28 +0800 Message-ID: Date: Mon, 22 Apr 2024 19:52:27 +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 -next v3 2/2] erofs: reliably distinguish block based and fscache mode To: Baokun Li , linux-erofs@lists.ozlabs.org Cc: xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com, viro@zeniv.linux.org.uk, brauner@kernel.org, linux-kernel@vger.kernel.org, yangerkun@huawei.com, houtao1@huawei.com References: <20240419123611.947084-1-libaokun1@huawei.com> <20240419123611.947084-3-libaokun1@huawei.com> Content-Language: en-US From: Jingbo Xu In-Reply-To: <20240419123611.947084-3-libaokun1@huawei.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 4/19/24 8:36 PM, Baokun Li wrote: > From: Christian Brauner > > 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 > --- > 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 21faa49bc970..30b49b2eee53 100644 > --- a/fs/erofs/super.c > +++ b/fs/erofs/super.c > @@ -789,17 +789,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); -- Thanks, Jingbo