All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] erofs: allow readdir() to be interrupted
@ 2025-07-10  7:36 Chao Yu
  2025-07-10  7:36 ` [PATCH 2/2] erofs: support to readahead dirent blocks in erofs_readdir() Chao Yu
  2025-07-10  7:41 ` [PATCH 1/2] erofs: allow readdir() to be interrupted Gao Xiang
  0 siblings, 2 replies; 8+ messages in thread
From: Chao Yu @ 2025-07-10  7:36 UTC (permalink / raw)
  To: xiang
  Cc: linux-erofs, linux-kernel, Yue Hu, Jeffle Xu, Sandeep Dhavale,
	Hongbo Li, Chao Yu

In a quick slow device, readdir() may loop for long time in large
directory, let's give a chance to allow it to be interrupted by
userspace.

Signed-off-by: Chao Yu <chao@kernel.org>
---
 fs/erofs/dir.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fs/erofs/dir.c b/fs/erofs/dir.c
index 2fae209d0274..cff61c5a172b 100644
--- a/fs/erofs/dir.c
+++ b/fs/erofs/dir.c
@@ -58,6 +58,13 @@ static int erofs_readdir(struct file *f, struct dir_context *ctx)
 		struct erofs_dirent *de;
 		unsigned int nameoff, maxsize;
 
+		/* allow readdir() to be interrupted */
+		if (fatal_signal_pending(current)) {
+			err = -ERESTARTSYS;
+			break;
+		}
+		cond_resched();
+
 		de = erofs_bread(&buf, dbstart, true);
 		if (IS_ERR(de)) {
 			erofs_err(sb, "failed to readdir of logical block %llu of nid %llu",
-- 
2.49.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-07-10 13:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-10  7:36 [PATCH 1/2] erofs: allow readdir() to be interrupted Chao Yu
2025-07-10  7:36 ` [PATCH 2/2] erofs: support to readahead dirent blocks in erofs_readdir() Chao Yu
2025-07-10  7:46   ` Gao Xiang
2025-07-10  7:59     ` Chao Yu
2025-07-10  8:04       ` Gao Xiang
2025-07-10 13:15         ` Chao Yu
2025-07-10  7:41 ` [PATCH 1/2] erofs: allow readdir() to be interrupted Gao Xiang
2025-07-10  7:57   ` Chao Yu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.