Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1438487lqp; Mon, 15 Apr 2024 06:44:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXomOPHpMPyUdWjtXrp1+w961ZziFGFMNnArQlDKVgUX927oIXOfvQgqWwnhQjKPGaFTfj65vvAc4n5QDauaiwRHnpolnPRqW6TeusmIQ== X-Google-Smtp-Source: AGHT+IFF8OKrQchB9SynQKwaZLNTsTx3qniaQa+zIAsOTqIhFSH6C++73WD7nchRv/wZ+7Q8rgsB X-Received: by 2002:a17:907:970f:b0:a52:3451:8a18 with SMTP id jg15-20020a170907970f00b00a5234518a18mr8413803ejc.29.1713188650491; Mon, 15 Apr 2024 06:44:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713188650; cv=pass; d=google.com; s=arc-20160816; b=NF8khhDm6xqe3YAucCS1gzfET6+31GtQccBZVDXYDlM1rZxV74CiUa4WcQYZcdELup 8xkrWf6Md1VjfUnoD2xdpsT5fVbwJ1+43xZw9Ya8ZWIcpEDQQ9u/EjB0LG+PDZDm+3Qg GnoYfzuCEtxBY5iGo5VOhDqoO9WHMdn2Xmn89Po+3suzuGXZbu7B7jIR0s/CbMbrd9V+ geq9g64/t/W1focMIiJkN5hSa2rAMN3ux0cosDWH8lBOe/ER+4uRZ+X/jsZJ2Odg6FrL 0f6yeO+GPBC4r8b7UPUVzJArUzPgkiQ5KCpi8yNVNehNGmxlv+5Qt6dlRN0cKzSdzQiI 8mvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1vfBwEp4Nw9eO/7Un83FQ3qrQ0i+r6qchq+80ghhK2U=; fh=U5uKsBw6keAki1gus2i20hKDUo00VqdtQg+HQsvnLz8=; b=Q/xtT6x9N21zypf9Bll0gWocJR8JXk2AjxjJlQYp0CytItqvJUBY4C758rtI5j4AmK HzAABvUmMCnO5M1Tl15P3VWcWew9YVz6pwIwtbFxmftHrHJdLfnZNBn1QVq4DheXyxRz ZRvsqIU9/i+sBlnG2ykBAjqHlHW8AAA645cAvrfKfPgMk/rHogiEH1ulvZ3xVnDJiRUT 3zhEmN816sogGJeJLutND0CGoadABJ0VLMGLzjwlReG9rQXxrBOM4R0cCvqlAH83w2jG 5dhm+jWGapwlTpRPbx+3SSzdLmRTus6spXXsypPneJp8nwF+FkYyoc5E1F+cSfp8BJpX UGIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="c1Gx9/7H"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145277-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145277-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ht15-20020a170907608f00b00a523632043asi3612666ejc.486.2024.04.15.06.44.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Apr 2024 06:44:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-145277-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="c1Gx9/7H"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-145277-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-145277-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 926731F235F4 for ; Mon, 15 Apr 2024 13:42:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46FEE7353F; Mon, 15 Apr 2024 13:38:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="c1Gx9/7H" 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 70EBA71759 for ; Mon, 15 Apr 2024 13:38:15 +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=1713188295; cv=none; b=QDVNFob7jdExFC5f0EAO7qDtqMGRD0fG0/5kfeDt7iN+Ql8VIAxsgtvKGpzfDLAmB3GjFLntr6u3b+geCQd+i3yk8eZlIzY8JiD4hRc4p0lwK6TouIPCIjH3rMxT6/mwXz+Z9xoJusd0H8GNx9yZ8Dykzk2rJt5dYQ5MECFFig8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713188295; c=relaxed/simple; bh=D5lnOS4BaZn4Qhbk5HBYMUjuMcVsr7Tg9EDh+w5m3oQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=th6y++VyeUqJLpfSi4UQ1yz25eJfV0T9Ka+T5Dyb0Ji122oOWsHLfjYfBrN5HnXhC5oYLkeEqaARof9DfaJxmh0iMfiORV9hkabRP0y11YkFqgEk6NeN98INMXtokFj3XLDrUwD2+4iiyMuQMD0cNiUcCF+NeNwUgWTSqNS42Mw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=c1Gx9/7H; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 643B1C2BD10; Mon, 15 Apr 2024 13:38:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1713188295; bh=D5lnOS4BaZn4Qhbk5HBYMUjuMcVsr7Tg9EDh+w5m3oQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c1Gx9/7HrR7qcEPgR+1Gf7UVgaJwyZJ3Vt3Jt92x6Ap36pWHyJQPiko8+8rfYwOHB 6lf//ROsKkm+Vv2WeATEHf0gQyzXcpvNZ5NAM5UMBNA3QuQFbByK+hIdRuJJhTJE/t QTur5cx7RJRyPOPcJEUNgKN+AMiG9x0kGkU9L8OkhAU4EdvrC+eqtCoRITVtbqYJW7 K7dwUoT3Pf5zwYxG71dJOS8ejhMMoSuYkh0obmKVGXta/80keaAWvRI5CbXLl6kIor cA3ib1p9RDty4OhcjwV1yjVLmnh1ZMaipYA3PUCeLy7Xo6BNW0I0PNFsRngLao8MXH cBkT9G504KWdw== Date: Mon, 15 Apr 2024 15:38:07 +0200 From: Christian Brauner To: Baokun Li Cc: linux-erofs@lists.ozlabs.org, xiang@kernel.org, chao@kernel.org, huyue2@coolpad.com, jefflexu@linux.alibaba.com, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, yangerkun@huawei.com, houtao1@huawei.com Subject: Re: [PATCH] erofs: set SB_NODEV sb_flags when mounting with fsid Message-ID: <20240415-betagten-querlatte-feb727ed56c1@brauner> References: <20240415121746.1207242-1-libaokun1@huawei.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 In-Reply-To: <20240415121746.1207242-1-libaokun1@huawei.com> On Mon, Apr 15, 2024 at 08:17:46PM +0800, Baokun Li wrote: > 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 > [...] > ============================================ > > To avoid this problem, add SB_NODEV to fc->sb_flags after successfully > parsing the fsid, and then the superblock inherits this flag when it is > allocated, so that the sb_flags can be used to distinguish whether it is > in block dev based mode when calling erofs_kill_sb(). > > Signed-off-by: Baokun Li > --- > fs/erofs/super.c | 7 +++---- > 1 file changed, 3 insertions(+), 4 deletions(-) > > diff --git a/fs/erofs/super.c b/fs/erofs/super.c > index b21bd8f78dc1..7539ce7d64bc 100644 > --- a/fs/erofs/super.c > +++ b/fs/erofs/super.c > @@ -520,6 +520,7 @@ static int erofs_fc_parse_param(struct fs_context *fc, > ctx->fsid = kstrdup(param->string, GFP_KERNEL); > if (!ctx->fsid) > return -ENOMEM; > + fc->sb_flags |= SB_NODEV; Hm, I wouldn't do it this way. That's an abuse of that flag imho. Record the information in the erofs_fs_context if you need to.