1 ext4: allow readdir()'s of large empty directories to be interrupted
3 If a directory has a large number of empty blocks, iterating over all
4 of them can take a long time, leading to scheduler warnings and users
5 getting irritated when they can't kill a process in the middle of one
6 of these long-running readdir operations. Fix this by adding checks to
7 ext4_readdir() and ext4_htree_fill_tree().
9 Reported-by: Benjamin LaHaise <bcrl@kvack.org>
10 Google-Bug-Id: 27880676
11 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 fs/ext4/dir.c | 5 +++++
14 fs/ext4/namei.c | 5 +++++
15 2 files changed, 10 insertions(+)
17 diff --git a/fs/ext4/dir.c b/fs/ext4/dir.c
18 index 33f5e2a..ebfcb89 100644
21 @@ -150,6 +150,11 @@ static int ext4_readdir(struct file *file, struct dir_context *ctx)
22 while (ctx->pos < inode->i_size) {
23 struct ext4_map_blocks map;
25 + if (fatal_signal_pending(current)) {
30 map.m_lblk = ctx->pos >> EXT4_BLOCK_SIZE_BITS(sb);
32 err = ext4_map_blocks(NULL, inode, &map, 0);
33 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
34 index 48e4b89..db98f89f 100644
37 @@ -1107,6 +1107,11 @@ int ext4_htree_fill_tree(struct file *dir_file, __u32 start_hash,
41 + if (signal_pending(current)) {
46 block = dx_get_block(frame->at);
47 ret = htree_dirblock_to_tree(dir_file, dir, block, &hinfo,
48 start_hash, start_minor_hash);