From: Ye Bin <yebin@huaweicloud.com>
To: viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz,
linux-fsdevel@vger.kernel.org, axboe@kernel.dk,
linux-block@vger.kernel.org, agruenba@redhat.com,
gfs2@lists.linux.dev, amir73il@gmail.com, mic@digikod.net,
gnoack@google.com, paul@paul-moore.com, jmorris@namei.org,
serge@hallyn.com, linux-security-module@vger.kernel.org
Cc: yebin10@huawei.com, zhangxiaoxu5@huawei.com
Subject: [PATCH 01/11] fs: introduce I_CURSOR flag for inode
Date: Mon, 18 Nov 2024 19:44:58 +0800 [thread overview]
Message-ID: <20241118114508.1405494-2-yebin@huaweicloud.com> (raw)
In-Reply-To: <20241118114508.1405494-1-yebin@huaweicloud.com>
From: Ye Bin <yebin10@huawei.com>
This patch introduce I_CURSOR flag for inode and introduce
sb_for_each_inodes_safe/sb_for_each_inodes/sb_for_each_inodes_continue_safe
API for foreach super_block->s_inodes.
Signed-off-by: Ye Bin <yebin10@huawei.com>
---
include/linux/fs.h | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 0a152c31d1bf..cf2734e0b2cd 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2473,6 +2473,7 @@ static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src,
#define I_DONTCACHE (1 << 15)
#define I_SYNC_QUEUED (1 << 16)
#define I_PINNING_NETFS_WB (1 << 17)
+#define I_CURSOR (1 << 18)
#define I_DIRTY_INODE (I_DIRTY_SYNC | I_DIRTY_DATASYNC)
#define I_DIRTY (I_DIRTY_INODE | I_DIRTY_PAGES)
@@ -3809,4 +3810,48 @@ static inline bool vfs_empty_path(int dfd, const char __user *path)
int generic_atomic_write_valid(struct kiocb *iocb, struct iov_iter *iter);
+static inline bool inode_is_cursor(struct inode *inode)
+{
+ return inode->i_state & I_CURSOR;
+}
+
+static inline struct inode *next_sb_inode(struct inode *pos,
+ struct list_head *head)
+{
+ struct inode *inode;
+ struct list_head *start;
+
+ if (!pos)
+ return NULL;
+
+ start = &pos->i_sb_list;
+
+ list_for_each_continue(start, head) {
+ inode = list_entry(start, typeof(*inode), i_sb_list);
+ if (likely(!inode_is_cursor(inode)))
+ return inode;
+ }
+
+ return NULL;
+}
+
+#define sb_for_each_inodes_safe(pos, n, head) \
+ for (pos = list_entry(head, typeof(*pos), i_sb_list), \
+ pos = next_sb_inode(pos, head), \
+ n = next_sb_inode(pos, head); \
+ pos != NULL; \
+ pos = n, n = next_sb_inode(n, head))
+
+#define sb_for_each_inodes(pos, head) \
+ for (pos = list_entry(head, typeof(*pos), i_sb_list), \
+ pos = next_sb_inode(pos, head); \
+ pos != NULL; \
+ pos = next_sb_inode(pos, head))
+
+#define sb_for_each_inodes_continue_safe(pos, n, head) \
+ for (pos = next_sb_inode(pos, head), \
+ n = next_sb_inode(pos, head); \
+ pos != NULL; \
+ pos = n, n = next_sb_inode(n, head))
+
#endif /* _LINUX_FS_H */
--
2.34.1
next prev parent reply other threads:[~2024-11-18 11:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-18 11:44 [PATCH 00/11] fix hungtask due to repeated traversal of inodes list Ye Bin
2024-11-18 11:44 ` Ye Bin [this message]
2024-11-18 11:44 ` [PATCH 02/11] block: use sb_for_each_inodes API Ye Bin
2024-11-18 11:45 ` [PATCH 03/11] fs: " Ye Bin
2024-11-18 11:45 ` [PATCH 04/11] gfs2: " Ye Bin
2024-11-18 11:45 ` [PATCH 05/11] fs: use sb_for_each_inodes_safe API Ye Bin
2024-11-18 11:45 ` [PATCH 06/11] fsnotify: use sb_for_each_inodes API Ye Bin
2024-11-18 11:45 ` [PATCH 07/11] quota: " Ye Bin
2024-11-18 11:45 ` [PATCH 08/11] fs/super.c: " Ye Bin
2024-11-18 11:45 ` [PATCH 09/11] landlock: " Ye Bin
2024-11-18 11:45 ` [PATCH 10/11] fs: fix hungtask due to repeated traversal of inodes list Ye Bin
2024-12-04 11:17 ` Christian Brauner
2024-12-04 14:16 ` Jan Kara
2024-11-18 11:45 ` [PATCH 11/11] fs: fix potential soft lockup when 'sb->s_inodes' has large number of inodes Ye Bin
2024-12-04 7:04 ` [PATCH 00/11] fix hungtask due to repeated traversal of inodes list yebin (H)
2024-12-04 11:04 ` Mateusz Guzik
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=20241118114508.1405494-2-yebin@huaweicloud.com \
--to=yebin@huaweicloud.com \
--cc=agruenba@redhat.com \
--cc=amir73il@gmail.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=gfs2@lists.linux.dev \
--cc=gnoack@google.com \
--cc=jack@suse.cz \
--cc=jmorris@namei.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mic@digikod.net \
--cc=paul@paul-moore.com \
--cc=serge@hallyn.com \
--cc=viro@zeniv.linux.org.uk \
--cc=yebin10@huawei.com \
--cc=zhangxiaoxu5@huawei.com \
/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