From: Ye Bin <yebin@huaweicloud.com>
To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org
Cc: jack@suse.cz
Subject: [PATCH 1/3] ext4: register 'orphan_list' procfs
Date: Fri, 3 Apr 2026 16:25:05 +0800 [thread overview]
Message-ID: <20260403082507.1882703-2-yebin@huaweicloud.com> (raw)
In-Reply-To: <20260403082507.1882703-1-yebin@huaweicloud.com>
From: Ye Bin <yebin10@huawei.com>
This patch register '/proc/fs/ext4/XXX/orphan_list' procfs for show inode
orphan list about EXT4 file system.
In actual production environments, there may be inconsistencies in df/du,
sometimes due to kernel occupation, making it difficult to find such files,
and it is also difficult to operate in the current network environment. So
add "orphan_list" procfs to quickly query files that have been deleted but
are occupied.
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
fs/ext4/ext4.h | 1 +
fs/ext4/orphan.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++
fs/ext4/sysfs.c | 2 ++
3 files changed, 73 insertions(+)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 876597f8331d..fa38a8380fed 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3873,6 +3873,7 @@ extern void ext4_stop_mmpd(struct ext4_sb_info *sbi);
extern const struct fsverity_operations ext4_verityops;
/* orphan.c */
+extern const struct proc_ops ext4_orphan_proc_ops;
extern int ext4_orphan_add(handle_t *, struct inode *);
extern int ext4_orphan_del(handle_t *, struct inode *);
extern void ext4_orphan_cleanup(struct super_block *sb,
diff --git a/fs/ext4/orphan.c b/fs/ext4/orphan.c
index 64ea47624233..1d231aeaf282 100644
--- a/fs/ext4/orphan.c
+++ b/fs/ext4/orphan.c
@@ -4,6 +4,8 @@
#include <linux/fs.h>
#include <linux/quotaops.h>
#include <linux/buffer_head.h>
+#include <linux/proc_fs.h>
+#include <linux/seq_file.h>
#include "ext4.h"
#include "ext4_jbd2.h"
@@ -657,3 +659,71 @@ int ext4_orphan_file_empty(struct super_block *sb)
return 0;
return 1;
}
+
+struct ext4_proc_orphan {
+ struct ext4_inode_info cursor;
+};
+
+static void *ext4_orphan_seq_start(struct seq_file *seq, loff_t *pos)
+{
+ return NULL;
+}
+
+static void *ext4_orphan_seq_next(struct seq_file *seq, void *v, loff_t *pos)
+{
+ return NULL;
+}
+
+static int ext4_orphan_seq_show(struct seq_file *seq, void *v)
+{
+ return 0;
+}
+
+static void ext4_orphan_seq_stop(struct seq_file *seq, void *v)
+{
+}
+
+const struct seq_operations ext4_orphan_seq_ops = {
+ .start = ext4_orphan_seq_start,
+ .next = ext4_orphan_seq_next,
+ .stop = ext4_orphan_seq_stop,
+ .show = ext4_orphan_seq_show,
+};
+
+static int ext4_seq_orphan_open(struct inode *inode, struct file *file)
+{
+ int rc;
+ struct seq_file *m;
+ struct ext4_proc_orphan *private;
+
+ rc = seq_open_private(file, &ext4_orphan_seq_ops,
+ sizeof(struct ext4_proc_orphan));
+ if (!rc) {
+ m = file->private_data;
+ private = m->private;
+ INIT_LIST_HEAD(&private->cursor.i_orphan);
+ private->cursor.vfs_inode.i_ino = 0;
+ }
+
+ return rc;
+}
+
+static int ext4_seq_orphan_release(struct inode *inode, struct file *file)
+{
+ struct seq_file *seq = file->private_data;
+ struct ext4_proc_orphan *s = seq->private;
+ struct ext4_sb_info *sbi = EXT4_SB(pde_data(inode));
+
+ mutex_lock(&sbi->s_orphan_lock);
+ list_del(&s->cursor.i_orphan);
+ mutex_unlock(&sbi->s_orphan_lock);
+
+ return seq_release_private(inode, file);
+}
+
+const struct proc_ops ext4_orphan_proc_ops = {
+ .proc_open = ext4_seq_orphan_open,
+ .proc_read = seq_read,
+ .proc_lseek = seq_lseek,
+ .proc_release = ext4_seq_orphan_release,
+};
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index b87d7bdab06a..324eb6b5900e 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -634,6 +634,8 @@ int ext4_register_sysfs(struct super_block *sb)
ext4_seq_mb_stats_show, sb);
proc_create_seq_data("mb_structs_summary", 0444, sbi->s_proc,
&ext4_mb_seq_structs_summary_ops, sb);
+ proc_create_data("orphan_list", 0444, sbi->s_proc,
+ &ext4_orphan_proc_ops, sb);
}
return 0;
}
--
2.34.1
next prev parent reply other threads:[~2026-04-03 8:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-03 8:25 [PATCH 0/3] show orphan file inode detail info Ye Bin
2026-04-03 8:25 ` Ye Bin [this message]
2026-04-03 12:55 ` [PATCH 1/3] ext4: register 'orphan_list' procfs Theodore Tso
2026-04-03 8:25 ` [PATCH 2/3] ext4: show inode orphan list detail information Ye Bin
2026-04-03 16:22 ` Andreas Dilger
2026-04-03 8:25 ` [PATCH 3/3] ext4: show orphan file inode detail info Ye Bin
2026-04-03 13:03 ` [PATCH 0/3] " Theodore Tso
2026-04-07 10:29 ` Jan Kara
2026-04-07 20:28 ` Theodore Tso
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260403082507.1882703-2-yebin@huaweicloud.com \
--to=yebin@huaweicloud.com \
--cc=adilger.kernel@dilger.ca \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox