From: Chao Yu <yuchao0@huawei.com>
To: jaegeuk@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH 3/5] f2fs: allow readdir() to be interrupted
Date: Fri, 13 Oct 2017 18:01:34 +0800 [thread overview]
Message-ID: <20171013100136.35212-3-yuchao0@huawei.com> (raw)
In-Reply-To: <20171013100136.35212-1-yuchao0@huawei.com>
This patch follows ext4 to allow readdir() in large empty directory to
be interrupted. Referenced commit of ext4: 1f60fbe72749 ("ext4: allow
readdir()'s of large empty directories to be interrupted").
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/dir.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c
index 148927f5bc93..1ebd206a4085 100644
--- a/fs/f2fs/dir.c
+++ b/fs/f2fs/dir.c
@@ -10,6 +10,7 @@
*/
#include <linux/fs.h>
#include <linux/f2fs_fs.h>
+#include <linux/sched/signal.h>
#include "f2fs.h"
#include "node.h"
#include "acl.h"
@@ -875,6 +876,14 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
min(npages - n, (pgoff_t)MAX_DIR_RA_PAGES));
for (; n < npages; n++) {
+
+ /* allow readdir() to be interrupted */
+ if (fatal_signal_pending(current)) {
+ err = -ERESTARTSYS;
+ goto out_free;
+ }
+ cond_resched();
+
dentry_page = get_lock_data_page(inode, n, false);
if (IS_ERR(dentry_page)) {
err = PTR_ERR(dentry_page);
--
2.13.1.388.g69e6b9b4f4a9
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
next prev parent reply other threads:[~2017-10-13 10:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-13 10:01 [PATCH 1/5] f2fs: trace f2fs_lookup Chao Yu
2017-10-13 10:01 ` [PATCH 2/5] f2fs: trace f2fs_readdir Chao Yu
2017-10-13 10:01 ` Chao Yu [this message]
2017-10-13 10:01 ` [PATCH 4/5] f2fs: relocate readahead codes in readdir() Chao Yu
2017-10-13 10:01 ` [PATCH 5/5] f2fs: update ctx->pos correctly when hitting hole in directory Chao Yu
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=20171013100136.35212-3-yuchao0@huawei.com \
--to=yuchao0@huawei.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).