From patchwork Tue May 16 15:23:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 94755 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp515112vqo; Tue, 16 May 2023 08:30:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ49uFT6vn0ihuxf5r3CYjLs9Xo6UHeyTciw9Q5HfLe7dgAMzA8jz+BUWhDvKsGsTQS6FfAY X-Received: by 2002:a05:6a00:9aa:b0:646:b3f6:945c with SMTP id u42-20020a056a0009aa00b00646b3f6945cmr37284918pfg.4.1684251044396; Tue, 16 May 2023 08:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684251044; cv=none; d=google.com; s=arc-20160816; b=f2QT6uAZ9X42tnAKqTU/+ct49jL/7uPi1DvuLtyt+foO/Mk6KSxedgnRfMRfIo9wLw y3V6Hn+9F4NNiN3xk63IC4q+wYITbe8DbPwqg/udXmzmuxrMMoRHPkrYXBKHqAhlSMlD sKovNNgnX108FMJc5D9enPghHSPwQpIMNkqMxApOpCPQ/AAMarJYl958BLEJIW6A1vW4 QSCKfBxtezCPLOOdiNYPZDWQXAY08liHaBTr7xvD9tpMdH1ju7H1O0sJb1ypX/5XAPjl b1l/U8WCVTI/xgdz7BNRllrZyDvzldmM4dNG+3JiHVqcH0bABnH0KKI2+QSm+ZRQ4dFe s/Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=s2s/ccMC4Z2K6TRahFRfnzlFlPl6sOgfOEPGE0q3ZR4=; b=AA+1GZnFs3lk3zrVAexsfQ4xahX3Svu0zRHjctp+ON8Oi78e6TWgwF8Gxycrd2x3MY BtlpxRbafsewmOxe/eePTc6CvP2Ldr9Km3NDyIfvHMdOvpA/zjAsf3/p1fcQOur80c40 HV+hJGo2kMp4KaYZvl3RdEM8b8grCUBWdODXfYJlW7SJPFEu90FhFjj3wzPUD6tPpNuK ApVl8HHDyAJKNqQPIGU+mWOTJV4WCojXUHdaFWAJ0/uiGMM0YOiyFd+vg8SmG1XZpPct azfAWxLoYBPMafaEVsFsvYzjfSL153KFf9E8EsaXT0mVyCGhuTAz7IB9AeDgd7peutU/ A5fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kJEA5hI+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g7-20020aa796a7000000b0064895928e06si16007426pfk.334.2023.05.16.08.30.27; Tue, 16 May 2023 08:30:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kJEA5hI+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233808AbjEPPYN (ORCPT + 99 others); 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 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766065223373400483?= X-GMAIL-MSGID: =?utf-8?q?1766065223373400483?= 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 = F2FS_NOATIME_FL | F2FS_IMMUTABLE_FL; int err; 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, } /* Don't account quota for quota files to avoid recursion */ + inode_lock(qf_inode); qf_inode->i_flags |= S_NOQUOTA; + + if (!(F2FS_I(qf_inode)->i_flags & qf_flag)) { + F2FS_I(qf_inode)->i_flags |= qf_flag; + f2fs_set_inode_flags(qf_inode); + } + inode_unlock(qf_inode); + err = dquot_load_quota_inode(qf_inode, type, format_id, flags); iput(qf_inode); return err;