From mboxrd@z Thu Jan 1 00:00:00 1970 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.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (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 30A04CA0EE4 for ; Wed, 13 Aug 2025 16:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: Reply-To:From:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:In-Reply-To:MIME-Version:References: Message-ID:To:Date:Sender:Cc:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=554f3oAqW3aKlEYvFubdimZSWSJv1tq0J+USYwRR8hU=; b=g4+CK5YyBXYAMycmMnPhZ/n6ZU 0HP0+I3KORgDHqGfN3/FY0rh2O5wg2ZXedtgDNemyylZv0gyKEJD1wQrK2vWQgLQ2/QgwxgG3cir0 i6WYQhNMN09GtKe+Tb6Xjq4sBVnHl66ATHPH6aORIKTEAyZE6f0Q8Xw2LlnqI1mKvYpY=; Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1umEGv-0002R9-Uo; Wed, 13 Aug 2025 16:24:18 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1umEGu-0002R3-Uy for linux-f2fs-devel@lists.sourceforge.net; Wed, 13 Aug 2025 16:24:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=odI/ZduvcMCgze9lTEkoETpC23n4CWSKhhTLj5bNby8=; b=g9pecS59txUVpTETgtTXl+GKr5 8yAPPtgsTMgTgqwEELIPdBMQ7VXpgSfPNE8fWl6gjiDbzRBB/SLE7pJBgmfX9H6QVprvxAy1ktTYE wLaVRK/Wl1cTM7gj1M4NkQOVC84Mxp2qgEtxWe6bc4I/RHxSTijiUA+wEjuEJJa+aI9Y=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To: From:Date:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=odI/ZduvcMCgze9lTEkoETpC23n4CWSKhhTLj5bNby8=; b=J0V06pH5wOWNo/8DZoA/644YJH R4DjRLahoju/GHAtj0PddoL+9szRAgcK4UtGnZiafKZ4i2aiSu3viOefhGtmG3ERC4FYZlN6gTEON GT3Nn77gXgFsC5vFv88umKW2q7PkzmJ1WvJo/A6QfWl8oqoWl55Qp3+PeVvl+F2PMrzA=; Received: from sea.source.kernel.org ([172.234.252.31]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1umEGv-0000cf-70 for linux-f2fs-devel@lists.sourceforge.net; Wed, 13 Aug 2025 16:24:17 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id D742344CBA for ; Wed, 13 Aug 2025 16:24:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A164EC4CEEB; Wed, 13 Aug 2025 16:24:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755102251; bh=l5GRYhSLt0ih++tPVUvR1mN9QUxqlTdpEpa75uKM1Y4=; h=Date:From:To:Subject:References:In-Reply-To:From; b=Kw9w+dRRq6VoWhAXksu+GX1ie0z3xKSiZRNGsDPDdFN/jYzYt+9SQzTBQ1RFiQBrD pz7YW4oMNh44joMaqC/sPLucJ8umJ2cqQtyZRFkYTDh7MChUlsDVtPuRFKcwkoyAx3 ndRvHNjwnArvFg7fLee4TyHxvZLQ1hicEJhmK87z4EYx6wTGfBA/+hWq160kgptYMN +8DRJ3MogBcJbDTUojqml1fBH+UWlD8BhImpS/sdn2fjqjqHIO5/Rhd+3/jr/tbkob w69Tl1F7HR+h1mM0Iuj8RQiZ8jV9iBlhnFbT1ZEveY5yz1wtSoUjWvQZ2n80K1SdwA H/m5jxkNtjcgw== Date: Wed, 13 Aug 2025 16:24:09 +0000 To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Message-ID: References: <20250812235814.960924-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250812235814.960924-1-jaegeuk@kernel.org> X-Headers-End: 1umEGv-0000cf-70 Subject: Re: [f2fs-dev] [PATCH v2] f2fs: show the list of donation files X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Jaegeuk Kim via Linux-f2fs-devel Reply-To: Jaegeuk Kim Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net This patch introduces a proc entry to show the currently enrolled donation files. - "File path" indicates a file. - "Status" a. "Donated" means the file is registed in the donation list by fadvise(offset, length, POSIX_FADV_NOREUSE) b. "Evicted" means the donated pages were reclaimed. - "Offset (kb)" and "Length (kb) show the registered donation range. - "Cached pages (kb)" shows the amount of cached pages in the inode page cache. For example, Donation List # of files : 2 File path Status Offset (kb) Length (kb) Cached pages (kb) --- /local/tmp/test2 Donated 0 1048576 2097152 /local/tmp/test Evicted 0 1048576 1048576 Signed-off-by: Jaegeuk Kim --- v2: use inode_lock|unlock_shared fs/f2fs/sysfs.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 1ffaf9e74ce9..9f90d1878ec6 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -1769,6 +1769,68 @@ static int __maybe_unused disk_map_seq_show(struct seq_file *seq, return 0; } +static int __maybe_unused donation_list_seq_show(struct seq_file *seq, + void *offset) +{ + struct super_block *sb = seq->private; + struct f2fs_sb_info *sbi = F2FS_SB(sb); + struct inode *inode; + struct f2fs_inode_info *fi; + struct dentry *dentry; + char *buf, *path; + int i; + + buf = f2fs_getname(sbi); + if (!buf) + return 0; + + seq_printf(seq, "Donation List\n"); + seq_printf(seq, " # of files : %u\n", sbi->donate_files); + seq_printf(seq, " %-50s %10s %15s %15s %20s\n", + "File path", "Status", "Offset (kb)", + "Length (kb)", "Cached pages (kb)"); + seq_printf(seq, "---\n"); + + for (i = 0; i < sbi->donate_files; i++) { + spin_lock(&sbi->inode_lock[DONATE_INODE]); + if (list_empty(&sbi->inode_list[DONATE_INODE])) { + spin_unlock(&sbi->inode_lock[DONATE_INODE]); + break; + } + fi = list_first_entry(&sbi->inode_list[DONATE_INODE], + struct f2fs_inode_info, gdonate_list); + list_move_tail(&fi->gdonate_list, &sbi->inode_list[DONATE_INODE]); + inode = igrab(&fi->vfs_inode); + spin_unlock(&sbi->inode_lock[DONATE_INODE]); + + if (!inode) + continue; + + inode_lock_shared(inode); + + dentry = d_find_alias(inode); + if (!dentry) { + path = NULL; + } else { + path = dentry_path_raw(dentry, buf, PATH_MAX); + if (IS_ERR(path)) + goto next; + } + seq_printf(seq, " %-50s %10s %15lu %15lu %20lu\n", + path ? path : "", + is_inode_flag_set(inode, FI_DONATE_FINISHED) ? + "Evicted" : "Donated", + fi->donate_start << (PAGE_SHIFT - 10), + (fi->donate_end + 1) << (PAGE_SHIFT - 10), + inode->i_mapping->nrpages << (PAGE_SHIFT - 10)); +next: + inode_unlock_shared(inode); + iput(inode); + } + f2fs_putname(buf); + return 0; +} + #ifdef CONFIG_F2FS_FAULT_INJECTION static int __maybe_unused inject_stats_seq_show(struct seq_file *seq, void *offset) @@ -1878,6 +1940,8 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi) discard_plist_seq_show, sb); proc_create_single_data("disk_map", 0444, sbi->s_proc, disk_map_seq_show, sb); + proc_create_single_data("donation_list", 0444, sbi->s_proc, + donation_list_seq_show, sb); #ifdef CONFIG_F2FS_FAULT_INJECTION proc_create_single_data("inject_stats", 0444, sbi->s_proc, inject_stats_seq_show, sb); -- 2.51.0.rc1.163.g2494970778-goog _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel