From nobody Fri Apr 10 00:56:56 2026 Received: from SHSQR01.spreadtrum.com (mx1.unisoc.com [222.66.158.135]) (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 ED86626A0C7 for ; Thu, 5 Mar 2026 03:22:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=222.66.158.135 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772680940; cv=none; b=pfgnvTdstl6v3ErZTmaplLidyObvZj2AF65LN6rUsAxnhVXk2lQvCqDMbK4UmURyshsPdYYBzFCbwoWBYwuNV177wk+0pU0jb0cRNllVoqbPwPBTLmfFveveVp070kX0wcPazkng3q5aNevEOQVgaPEo85ckKSaGBizAN1Yqyrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772680940; c=relaxed/simple; bh=ifrGWOJhsE5f6tKM34+q3JYcLMQBOPG4mhCcEq183vA=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=b+FeyIS1W9O8/eX4zNijSpPN1Rurz/2Hb7cT7VFx7wRycxWY+t11cXJU7OM4Vdtw5Y8e5U4Y28k2Z+E4mAoBWbN5z0xLCWixAFb3emNKJUeNP8lncppESMyWWpcRYrYuJUJSHxoeN0IvJqzuhZknDiwYYjyEpcO4G5Ft7L3itOY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=unisoc.com; spf=pass smtp.mailfrom=unisoc.com; dkim=pass (2048-bit key) header.d=unisoc.com header.i=@unisoc.com header.b=NFlbgOfP; arc=none smtp.client-ip=222.66.158.135 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=unisoc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=unisoc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=unisoc.com header.i=@unisoc.com header.b="NFlbgOfP" Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 6253LAXE052432; Thu, 5 Mar 2026 11:21:10 +0800 (+08) (envelope-from Zhiguo.Niu@unisoc.com) Received: from SHDLP.spreadtrum.com (BJMBX02.spreadtrum.com [10.0.64.8]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4fRFCW14HXz2P9BsF; Thu, 5 Mar 2026 11:20:07 +0800 (CST) Received: from bj08434pcu.spreadtrum.com (10.0.73.87) by BJMBX02.spreadtrum.com (10.0.64.8) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Thu, 5 Mar 2026 11:21:07 +0800 From: Zhiguo Niu To: , CC: , , , , , Subject: [PATCH v2] f2fs: fix to preserve previous reserve_{blocks,node} value when remount Date: Thu, 5 Mar 2026 11:22:46 +0800 Message-ID: <1772680966-29939-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 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" X-ClientProxiedBy: SHCAS03.spreadtrum.com (10.0.1.207) To BJMBX02.spreadtrum.com (10.0.64.8) Content-Transfer-Encoding: quoted-printable X-MAIL: SHSQR01.spreadtrum.com 6253LAXE052432 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unisoc.com; s=default; t=1772680888; bh=400WQIFn++ZKQ1Ry/cxj5etcTJY4nE54JPnrb8u/8tQ=; h=From:To:CC:Subject:Date; b=NFlbgOfPW3LtTqZgH4BkLce1wtxWvyTajnjvE5Lo1aCIffd0iyXM2jCttySVdpOK+ vLY75gLKCugjmz5rT1J2tXMhb4hDPwJZQ06BTPJVYyTJUWpeunUdq6nDM/4rsWhhUj 3/HVT1dHLgYK4/DlPGdhu0gpQh8Xvq+NE7aXqEmHfxOl9KHeYW61JeWBP/bXLZt1PW SLMUX3IndrmvwEnuW8DMzZQ496tXKJhwO/kHqXZwI9QXlaCljbDoZjy7gEQZTYpWdc Nmjp4xX7PQ4ZWLJjiCf6yxFSA7SfhGayCxohXs6Jm1Isb2FwNYT/eNyF8Iko8i4dKM xvTrO/jzyht8w== The following steps will change previous value of reserve_{blocks,node}, this dones not match the original intention. 1.mount -t f2fs -o reserve_root=3D8192 imgfile test_mount/ F2FS-fs (loop56): Mounted with checkpoint version =3D 1b69f8c7 mount info: /dev/block/loop56 on /data/test_mount type f2fs (xxx,reserve_root=3D8192,re= serve_node=3D0,resuid=3D0,resgid=3D0,xxx) 2.mount -t f2fs -o remount,reserve_root=3D4096 /data/test_mount F2FS-fs (loop56): Preserve previous reserve_root=3D8192 check mount info: reserve_root change to 4096 /dev/block/loop56 on /data/test_mount type f2fs (xxx,reserve_root=3D4096,re= serve_node=3D0,resuid=3D0,resgid=3D0,xxx) Prior to commit d18535132523 ("f2fs: separate the options parsing and optio= ns checking"), the value of reserve_{blocks,node} was only set during the first mount, alo= ng with the corresponding mount option F2FS_MOUNT_RESERVE_{ROOT,NODE} . If the moun= t option F2FS_MOUNT_RESERVE_{ROOT,NODE} was found to have been set during the mount/= remount, the previously value of reserve_{blocks,node} would also be preserved, as s= hown in the code below. if (test_opt(sbi, RESERVE_ROOT)) { f2fs_info(sbi, "Preserve previous reserve_root=3D%u", F2FS_OPTION(sbi).root_reserved_blocks); } else { F2FS_OPTION(sbi).root_reserved_blocks =3D arg; set_opt(sbi, RESERVE_ROOT); } But commit d18535132523 ("f2fs: separate the options parsing and options ch= ecking") only preserved the previous mount option; it did not preserve the previous = value of reserve_{blocks,node}. Since value of reserve_{blocks,node} value is assign= ed or not depends on ctx->spec_mask, ctx->spec_mask should be alos handled in f2fs_check_opt_consistency. This patch will clear the corresponding ctx->spec_mask bits in f2fs_check_o= pt_consistency to preserve the previously values of reserve_{blocks,node} if it already ha= ve a value. Fixes: d18535132523 ("f2fs: separate the options parsing and options checki= ng") Signed-off-by: Zhiguo Niu Reviewed-by: Chao Yu --- v2: add more detail info in commit msg suggested by Chao --- fs/f2fs/super.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 8774c60..39f8e88 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1515,6 +1515,7 @@ static int f2fs_check_opt_consistency(struct fs_conte= xt *fc, F2FS_OPTION(sbi).root_reserved_blocks); ctx_clear_opt(ctx, F2FS_MOUNT_RESERVE_ROOT); ctx->opt_mask &=3D ~BIT(F2FS_MOUNT_RESERVE_ROOT); + ctx->spec_mask &=3D ~F2FS_SPEC_reserve_root; } if (test_opt(sbi, RESERVE_NODE) && (ctx->opt_mask & BIT(F2FS_MOUNT_RESERVE_NODE)) && @@ -1523,6 +1524,7 @@ static int f2fs_check_opt_consistency(struct fs_conte= xt *fc, F2FS_OPTION(sbi).root_reserved_nodes); ctx_clear_opt(ctx, F2FS_MOUNT_RESERVE_NODE); ctx->opt_mask &=3D ~BIT(F2FS_MOUNT_RESERVE_NODE); + ctx->spec_mask &=3D ~F2FS_SPEC_reserve_node; } err =3D f2fs_check_test_dummy_encryption(fc, sb); -- 1.9.1 ________________________________ This email (including its attachments) is intended only for the person or = entity to which it is addressed and may contain information that is privile= ged, confidential or otherwise protected from disclosure. Unauthorized use,= dissemination, distribution or copying of this email or the information he= rein or taking any action in reliance on the contents of this email or the = information herein, by anyone other than the intended recipient, or an empl= oyee or agent responsible for delivering the message to the intended recipi= ent, is strictly prohibited. If you are not the intended recipient, please = do not read, copy, use or disclose any part of this e-mail to others. Pleas= e notify the sender immediately and permanently delete this e-mail and any = attachments if you received it in error. Internet communications cannot be = guaranteed to be timely, secure, error-free or virus-free. The sender does = not accept liability for any errors or omissions. =E6=9C=AC=E9=82=AE=E4=BB=B6=E5=8F=8A=E5=85=B6=E9=99=84=E4=BB=B6=E5=85=B7=E6= =9C=89=E4=BF=9D=E5=AF=86=E6=80=A7=E8=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