Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C658CCFC286 for ; Tue, 15 Oct 2024 10:34:43 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4XSVpV0JC5z3bvJ for ; Tue, 15 Oct 2024 21:34:42 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=115.124.30.101 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1728988480; cv=none; b=IVj+xERrMEqD+YlbrZbFSToNX5gw99Yhu0nnVpPkUC0byNm3IJF5GJJl5Abavt9GejUYCyNf6v+3l8TiF8mDTfTsTCjnFa4+Q181anHoSbB7PpOxcsO8u76rioXNb0w0Us9XJZr9Q/0Kd6o3E2Gh154ItukQF7B2AV01RJ/o7eB4LCsc3Pfg6bDEaC8zfBnynlb49Z2jkfCFiW/i0yQNCXtaQfkVDaiKAJnEra2AfglvEqt8RI6a5NgfgJKSJwARYJRIU7iTakuE7no8AYGib085n3QTkgTjcesIZ/73FIWy8s34caUAba6A0La68L9Vah143/+cU4eEN9nLtbYeBQ== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1728988480; c=relaxed/relaxed; bh=rY+7tRwbhEa9NRr1LWtSOufpGMP2qFins0pVb8gCf08=; h=Content-Type:Message-ID:Date:MIME-Version:Subject:To:Cc: References:From:In-Reply-To; b=HFKrZE/YDKP71lyF19YeYzj4yA0YTeozVGcXj5L0ofFaXldRgr3y2FuU63JOyhEMuTCHoV3YnF0OCVRQhYJz1hl3yCOY3NfBdG5oejyjPcRtk59UCJMugdKlrx5cXoCgYAYoRTP7ev/Jfo4qm+rDFCn0pbpWfQY4KhZtmnKAq6mNY1e7ZMxrHMh5st/vP/z06PXfe31o74qJd4lE0PONrqpa3NXdN1WB9TcRyUAH8X9EsMrZxWM4yGlLQxsa9QFf20US21bxAVWS7e53Sf4cZIRtH1RkuKauQxqsOA7gstHE5Wc0f39+tWH7uFgdogUo62Fa+5rzjhjHzwvbbpNZoA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=bZBo6/jH; dkim-atps=neutral; spf=pass (client-ip=115.124.30.101; helo=out30-101.freemail.mail.aliyun.com; envelope-from=hongzhen@linux.alibaba.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=bZBo6/jH; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.alibaba.com (client-ip=115.124.30.101; helo=out30-101.freemail.mail.aliyun.com; envelope-from=hongzhen@linux.alibaba.com; receiver=lists.ozlabs.org) Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4XSVpK5MR5z3bkf for ; Tue, 15 Oct 2024 21:34:29 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1728988464; h=Content-Type:Message-ID:Date:MIME-Version:Subject:To:From; bh=rY+7tRwbhEa9NRr1LWtSOufpGMP2qFins0pVb8gCf08=; b=bZBo6/jHRaocaoS5tB1Su5Vq7nk1iqSOcg5wdGbUlEYK/Jq3KngFs/v/Vvae4YkU0n7seg1yUIpxJpo1LFATpXXOhoJpbSMrHvJ4RezbVHj44AHqPBRevbsyP3I213cf+D+Ll0fP7LKkfez+xMRtWPzG3Xxo4VMnD+71Jqz2DSQ= Received: from 30.221.131.163(mailfrom:hongzhen@linux.alibaba.com fp:SMTPD_---0WHDRFEq_1728988463 cluster:ay36) by smtp.aliyun-inc.com; Tue, 15 Oct 2024 18:34:24 +0800 Content-Type: multipart/alternative; boundary="------------2vpXlp0bPm3k17s4EV0KpwP6" Message-ID: <0445fd69-8236-4e09-b2b4-0ac57882229e@linux.alibaba.com> Date: Tue, 15 Oct 2024 18:34:23 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] erofs: fix blksize < PAGE_SIZE for file-backed mounts To: Gao Xiang , linux-erofs@lists.ozlabs.org References: <20241015070750.3489603-1-hongzhen@linux.alibaba.com> From: Hongzhen Luo In-Reply-To: X-BeenThere: linux-erofs@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development of Linux EROFS file system List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org Errors-To: linux-erofs-bounces+linux-erofs=archiver.kernel.org@lists.ozlabs.org Sender: "Linux-erofs" This is a multi-part message in MIME format. --------------2vpXlp0bPm3k17s4EV0KpwP6 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024/10/15 15:52, Gao Xiang wrote: > > > On 2024/10/15 15:07, Hongzhen Luo wrote: >> Adjust sb->s_blocksize{,_bits} directly for file-backed >> mounts when the fs block size is smaller than PAGE_SIZE. >> >> Previously, EROFS used sb_set_blocksize(), which caused >> a panic if bdev-backed mounts is not used. >> >> Fixes: fb176750266a ("erofs: add file-backed mount support") >> Signed-off-by: Hongzhen Luo >> --- >> v3: Fix trivial typos. >> v2: >> https://lore.kernel.org/linux-erofs/20241015064007.3449582-1-hongzhen@linux.alibaba.com/ >> v1: >> https://lore.kernel.org/linux-erofs/20241015033601.3206952-1-hongzhen@linux.alibaba.com/ >> --- >>   fs/erofs/super.c | 6 +++++- >>   1 file changed, 5 insertions(+), 1 deletion(-) >> >> diff --git a/fs/erofs/super.c b/fs/erofs/super.c >> index 320d586c3896..ca45dfb17d7c 100644 >> --- a/fs/erofs/super.c >> +++ b/fs/erofs/super.c >> @@ -631,7 +631,11 @@ static int erofs_fc_fill_super(struct >> super_block *sb, struct fs_context *fc) >>               errorfc(fc, "unsupported blksize for fscache mode"); >>               return -EINVAL; >>           } >> -        if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) { >> + >> +        if (erofs_is_fileio_mode(sbi)) { >> +            sb->s_blocksize = (1 << sbi->blkszbits); > > Why needing parentheses here? > > Thanks, > Gao Xiang I will resend a version without the parentheses soon. --- Thanks, Hongzhen > >> +            sb->s_blocksize_bits = sbi->blkszbits; >> +        } else if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) { >>               errorfc(fc, "failed to set erofs blksize"); >>               return -EINVAL; >>           } --------------2vpXlp0bPm3k17s4EV0KpwP6 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 2024/10/15 15:52, Gao Xiang wrote:


On 2024/10/15 15:07, Hongzhen Luo wrote:
Adjust sb->s_blocksize{,_bits} directly for file-backed
mounts when the fs block size is smaller than PAGE_SIZE.

Previously, EROFS used sb_set_blocksize(), which caused
a panic if bdev-backed mounts is not used.

Fixes: fb176750266a ("erofs: add file-backed mount support")
Signed-off-by: Hongzhen Luo <hongzhen@linux.alibaba.com>
---
v3: Fix trivial typos.
v2: https://lore.kernel.org/linux-erofs/20241015064007.3449582-1-hongzhen@linux.alibaba.com/
v1: https://lore.kernel.org/linux-erofs/20241015033601.3206952-1-hongzhen@linux.alibaba.com/
---
  fs/erofs/super.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/erofs/super.c b/fs/erofs/super.c
index 320d586c3896..ca45dfb17d7c 100644
--- a/fs/erofs/super.c
+++ b/fs/erofs/super.c
@@ -631,7 +631,11 @@ static int erofs_fc_fill_super(struct super_block *sb, struct fs_context *fc)
              errorfc(fc, "unsupported blksize for fscache mode");
              return -EINVAL;
          }
-        if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
+
+        if (erofs_is_fileio_mode(sbi)) {
+            sb->s_blocksize = (1 << sbi->blkszbits);

Why needing parentheses here?

Thanks,
Gao Xiang

I will resend a version without the parentheses soon.

---

Thanks,

Hongzhen


+            sb->s_blocksize_bits = sbi->blkszbits;
+        } else if (!sb_set_blocksize(sb, 1 << sbi->blkszbits)) {
              errorfc(fc, "failed to set erofs blksize");
              return -EINVAL;
          }
--------------2vpXlp0bPm3k17s4EV0KpwP6--