From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751611AbdJMKCI (ORCPT ); Fri, 13 Oct 2017 06:02:08 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8030 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757790AbdJMKCG (ORCPT ); Fri, 13 Oct 2017 06:02:06 -0400 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH 3/5] f2fs: allow readdir() to be interrupted Date: Fri, 13 Oct 2017 18:01:34 +0800 Message-ID: <20171013100136.35212-3-yuchao0@huawei.com> X-Mailer: git-send-email 2.13.1.388.g69e6b9b4f4a9 In-Reply-To: <20171013100136.35212-1-yuchao0@huawei.com> References: <20171013100136.35212-1-yuchao0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.120.216.130] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0201.59E08F10.0031,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 7fdec9f440b5eb514ed3d1f56ff84566 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 #include +#include #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