From nobody Sat Feb 7 17:55:11 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1452BC77B7A for ; Tue, 16 May 2023 15:24:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233664AbjEPPYN (ORCPT ); Tue, 16 May 2023 11:24:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233929AbjEPPYK (ORCPT ); Tue, 16 May 2023 11:24:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3339A7A92 for ; Tue, 16 May 2023 08:24:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A957A631EA for ; Tue, 16 May 2023 15:24:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DD6B8C433D2; Tue, 16 May 2023 15:24:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684250647; bh=dlpta+O6AiRXSqeDkk4SbGJ4ZUr5sNITboxH95GYYEw=; h=From:To:Cc:Subject:Date:From; b=kJEA5hI+Wdi20yIxk1fqICrPWnarW0/Ac8m1J/cW04ZVawLaeNW3Ng6SjJdr8anfd vnUvCtmhQEFdVdJERDv2ztM79XEg45STq0Agc0zjl5gxL9yTGyqhhjH5G0nmi71NFC 6/BjUdfKMRn4QUPcAl+mzEyMkgecPDEfxACm5clJ8aosHHQ45MvijrIgwOhrOoIxKC jFZAzL63bAnIUWJilQJ4vYfC+uM56FZpmooQzZO8ptTEPivZH1ufuQyrzbzH5YDCK9 jXUl60Z9ThHS98E50LkUWDAPhVoUBtLRKz9Vokgzh/AbvmOGTr7KtpXI+3ILq6ADYg n1hR65mihswjw== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH] f2fs: fix to set noatime and immutable flag for quota file Date: Tue, 16 May 2023 23:23:46 +0800 Message-Id: <20230516152346.190199-1-chao@kernel.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" We should set noatime bit for quota files, since no one cares about atime of quota file, and we should set immutalbe bit as well, due to nobody should write to the file through exported interfaces. Meanwhile this patch use inode_lock to avoid race condition during inode->i_flags, f2fs_inode->i_flags update. Signed-off-by: Chao Yu --- fs/f2fs/super.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 9f15b03037db..5d3ac196f0d5 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -2713,6 +2713,7 @@ static int f2fs_quota_enable(struct super_block *sb, = int type, int format_id, { struct inode *qf_inode; unsigned long qf_inum; + unsigned int qf_flag =3D F2FS_NOATIME_FL | F2FS_IMMUTABLE_FL; int err; =20 BUG_ON(!f2fs_sb_has_quota_ino(F2FS_SB(sb))); @@ -2728,7 +2729,15 @@ static int f2fs_quota_enable(struct super_block *sb,= int type, int format_id, } =20 /* Don't account quota for quota files to avoid recursion */ + inode_lock(qf_inode); qf_inode->i_flags |=3D S_NOQUOTA; + + if (!(F2FS_I(qf_inode)->i_flags & qf_flag)) { + F2FS_I(qf_inode)->i_flags |=3D qf_flag; + f2fs_set_inode_flags(qf_inode); + } + inode_unlock(qf_inode); + err =3D dquot_load_quota_inode(qf_inode, type, format_id, flags); iput(qf_inode); return err; --=20 2.25.1