Skip to content

Commit f1a49c1

Browse files
author
Jaegeuk Kim
committed
f2fs: show the list of donation files
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, # of files : 2 File path Status Donation offset (kb) Donation size (kb) File cached size (kb) --- /local/test2 Donated 0 1048576 2097152 /local/test Evicted 0 1048576 1048576 Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent ff11d87 commit f1a49c1

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

fs/f2fs/sysfs.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,68 @@ static int __maybe_unused disk_map_seq_show(struct seq_file *seq,
17691769
return 0;
17701770
}
17711771

1772+
static int __maybe_unused donation_list_seq_show(struct seq_file *seq,
1773+
void *offset)
1774+
{
1775+
struct super_block *sb = seq->private;
1776+
struct f2fs_sb_info *sbi = F2FS_SB(sb);
1777+
struct inode *inode;
1778+
struct f2fs_inode_info *fi;
1779+
struct dentry *dentry;
1780+
char *buf, *path;
1781+
int i;
1782+
1783+
buf = f2fs_getname(sbi);
1784+
if (!buf)
1785+
return 0;
1786+
1787+
seq_printf(seq, "Donation List\n");
1788+
seq_printf(seq, " # of files : %u\n", sbi->donate_files);
1789+
seq_printf(seq, " %-50s %10s %20s %20s %22s\n",
1790+
"File path", "Status", "Donation offset (kb)",
1791+
"Donation size (kb)", "File cached size (kb)");
1792+
seq_printf(seq, "---\n");
1793+
1794+
for (i = 0; i < sbi->donate_files; i++) {
1795+
spin_lock(&sbi->inode_lock[DONATE_INODE]);
1796+
if (list_empty(&sbi->inode_list[DONATE_INODE])) {
1797+
spin_unlock(&sbi->inode_lock[DONATE_INODE]);
1798+
break;
1799+
}
1800+
fi = list_first_entry(&sbi->inode_list[DONATE_INODE],
1801+
struct f2fs_inode_info, gdonate_list);
1802+
list_move_tail(&fi->gdonate_list, &sbi->inode_list[DONATE_INODE]);
1803+
inode = igrab(&fi->vfs_inode);
1804+
spin_unlock(&sbi->inode_lock[DONATE_INODE]);
1805+
1806+
if (!inode)
1807+
continue;
1808+
1809+
inode_lock_shared(inode);
1810+
1811+
dentry = d_find_alias(inode);
1812+
if (!dentry) {
1813+
path = NULL;
1814+
} else {
1815+
path = dentry_path_raw(dentry, buf, PATH_MAX);
1816+
if (IS_ERR(path))
1817+
goto next;
1818+
}
1819+
seq_printf(seq, " %-50s %10s %20llu %20llu %22llu\n",
1820+
path ? path : "<unlinked>",
1821+
is_inode_flag_set(inode, FI_DONATE_FINISHED) ?
1822+
"Evicted" : "Donated",
1823+
(loff_t)fi->donate_start << (PAGE_SHIFT - 10),
1824+
(loff_t)(fi->donate_end + 1) << (PAGE_SHIFT - 10),
1825+
(loff_t)inode->i_mapping->nrpages << (PAGE_SHIFT - 10));
1826+
next:
1827+
inode_unlock_shared(inode);
1828+
iput(inode);
1829+
}
1830+
f2fs_putname(buf);
1831+
return 0;
1832+
}
1833+
17721834
#ifdef CONFIG_F2FS_FAULT_INJECTION
17731835
static int __maybe_unused inject_stats_seq_show(struct seq_file *seq,
17741836
void *offset)
@@ -1878,6 +1940,8 @@ int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
18781940
discard_plist_seq_show, sb);
18791941
proc_create_single_data("disk_map", 0444, sbi->s_proc,
18801942
disk_map_seq_show, sb);
1943+
proc_create_single_data("donation_list", 0444, sbi->s_proc,
1944+
donation_list_seq_show, sb);
18811945
#ifdef CONFIG_F2FS_FAULT_INJECTION
18821946
proc_create_single_data("inject_stats", 0444, sbi->s_proc,
18831947
inject_stats_seq_show, sb);

0 commit comments

Comments
 (0)