From nobody Tue Apr 7 19:54:48 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 43C1EC433FE for ; Tue, 4 Oct 2022 01:11:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229577AbiJDBL5 (ORCPT ); Mon, 3 Oct 2022 21:11:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229501AbiJDBLz (ORCPT ); Mon, 3 Oct 2022 21:11:55 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 375FA3687A for ; Mon, 3 Oct 2022 18:11:54 -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 D0D3061223 for ; Tue, 4 Oct 2022 01:11:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 20ED0C433D6; Tue, 4 Oct 2022 01:11:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664845913; bh=zIdhzzCwavjd8ySaYJwHVS3f7SIxtSOXSEFFjestnug=; h=From:To:Cc:Subject:Date:From; b=pDm586T/SRXTreuRpTGzWSJKLKP/2zfHk1ETvIVq+1PxhqUzjzIGht13VoPxqFzY5 VRdd6EQrunesGarpcCI605WLaOE6ftf9X/qA/yirvlk30dgKeD8FKfLP3o3EU9QgsR Q7ReouEXP/Qn8bedkZmie2d4ngN99nIsFPR+s6/Y8qLLy38+qzIpWUea/kNitoBPMz 8A7fb+sRBdx8ZF+i9+cN8ALx7eMTH1IFo2G6kR0BSBQJdrOGLzPsqMyfQfKUQ/s9Yp quUARN9UHZEKWZAc6IvMiD0u2Yq4cIq5KVDzoLPyipD04tH86FMzqYNg3ZFweG2dpT o515rhKBhTPSA== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu Subject: [PATCH v3] f2fs: account swapfile inodes Date: Tue, 4 Oct 2022 09:11:33 +0800 Message-Id: <20221004011133.963048-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" From: Chao Yu In order to check count of opened swapfile inodes. Signed-off-by: Chao Yu --- v3: - fix to assign correct variable in f2fs_build_stats() fs/f2fs/data.c | 2 ++ fs/f2fs/debug.c | 4 ++++ fs/f2fs/f2fs.h | 9 ++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 0869fbbb5516..66f34cd559c6 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3970,6 +3970,7 @@ static int f2fs_swap_activate(struct swap_info_struct= *sis, struct file *file, if (ret < 0) return ret; =20 + stat_inc_swapfile_inode(inode); set_inode_flag(inode, FI_PIN_FILE); f2fs_update_time(F2FS_I_SB(inode), REQ_TIME); return ret; @@ -3979,6 +3980,7 @@ static void f2fs_swap_deactivate(struct file *file) { struct inode *inode =3D file_inode(file); =20 + stat_dec_swapfile_inode(inode); clear_inode_flag(inode, FI_PIN_FILE); } #else diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c index c01471573977..53eeb196b7d9 100644 --- a/fs/f2fs/debug.c +++ b/fs/f2fs/debug.c @@ -135,6 +135,7 @@ static void update_general_status(struct f2fs_sb_info *= sbi) si->inline_inode =3D atomic_read(&sbi->inline_inode); si->inline_dir =3D atomic_read(&sbi->inline_dir); si->compr_inode =3D atomic_read(&sbi->compr_inode); + si->swapfile_inode =3D atomic_read(&sbi->swapfile_inode); si->compr_blocks =3D atomic64_read(&sbi->compr_blocks); si->append =3D sbi->im[APPEND_INO].ino_num; si->update =3D sbi->im[UPDATE_INO].ino_num; @@ -385,6 +386,8 @@ static int stat_show(struct seq_file *s, void *v) si->inline_dir); seq_printf(s, " - Compressed Inode: %u, Blocks: %llu\n", si->compr_inode, si->compr_blocks); + seq_printf(s, " - Swapfile Inode: %u\n", + si->swapfile_inode); seq_printf(s, " - Orphan/Append/Update Inode: %u, %u, %u\n", si->orphans, si->append, si->update); seq_printf(s, "\nMain area: %d segs, %d secs %d zones\n", @@ -607,6 +610,7 @@ int f2fs_build_stats(struct f2fs_sb_info *sbi) atomic_set(&sbi->inline_dir, 0); atomic_set(&sbi->compr_inode, 0); atomic64_set(&sbi->compr_blocks, 0); + atomic_set(&sbi->swapfile_inode, 0); atomic_set(&sbi->inplace_count, 0); for (i =3D META_CP; i < META_MAX; i++) atomic_set(&sbi->meta_count[i], 0); diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 088c3d1574b8..408d8034ed74 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1765,6 +1765,7 @@ struct f2fs_sb_info { atomic_t inline_dir; /* # of inline_dentry inodes */ atomic_t compr_inode; /* # of compressed inodes */ atomic64_t compr_blocks; /* # of compressed blocks */ + atomic_t swapfile_inode; /* # of swapfile inodes */ atomic_t max_aw_cnt; /* max # of atomic writes */ unsigned int io_skip_bggc; /* skip background gc for in-flight IO */ unsigned int other_skip_bggc; /* skip background gc for other reasons */ @@ -3863,7 +3864,7 @@ struct f2fs_stat_info { int nr_issued_ckpt, nr_total_ckpt, nr_queued_ckpt; unsigned int cur_ckpt_time, peak_ckpt_time; int inline_xattr, inline_inode, inline_dir, append, update, orphans; - int compr_inode; + int compr_inode, swapfile_inode; unsigned long long compr_blocks; int aw_cnt, max_aw_cnt; unsigned int valid_count, valid_node_count, valid_inode_count, discard_bl= ks; @@ -3952,6 +3953,10 @@ static inline struct f2fs_stat_info *F2FS_STAT(struc= t f2fs_sb_info *sbi) (atomic64_add(blocks, &F2FS_I_SB(inode)->compr_blocks)) #define stat_sub_compr_blocks(inode, blocks) \ (atomic64_sub(blocks, &F2FS_I_SB(inode)->compr_blocks)) +#define stat_inc_swapfile_inode(inode) \ + (atomic_inc(&F2FS_I_SB(inode)->swapfile_inode)) +#define stat_dec_swapfile_inode(inode) \ + (atomic_dec(&F2FS_I_SB(inode)->swapfile_inode)) #define stat_inc_meta_count(sbi, blkaddr) \ do { \ if (blkaddr < SIT_I(sbi)->sit_base_addr) \ @@ -4036,6 +4041,8 @@ void f2fs_update_sit_info(struct f2fs_sb_info *sbi); #define stat_dec_compr_inode(inode) do { } while (0) #define stat_add_compr_blocks(inode, blocks) do { } while (0) #define stat_sub_compr_blocks(inode, blocks) do { } while (0) +#define stat_inc_swapfile_inode(inode) do { } while (0) +#define stat_dec_swapfile_inode(inode) do { } while (0) #define stat_update_max_atomic_write(inode) do { } while (0) #define stat_inc_meta_count(sbi, blkaddr) do { } while (0) #define stat_inc_seg_type(sbi, curseg) do { } while (0) --=20 2.25.1