Commit-ID: 0dc208b5d5feedc795cbf124539decd182c8e99e Gitweb: https://git.kernel.org/tip/0dc208b5d5feedc795cbf124539decd182c8e99e Author: Kirill Tkhai <ktk...@virtuozzo.com> AuthorDate: Fri, 29 Sep 2017 19:06:48 +0300 Committer: Ingo Molnar <mi...@kernel.org> CommitDate: Tue, 10 Oct 2017 11:50:16 +0200
locking/rwsem, fs: Use killable down_read() in iterate_dir() There was mutex_lock_interruptible() initially, and it was changed to rwsem, but there were not killable rwsem primitives that time. >From commit 9902af79c01a: "The main issue is the lack of down_write_killable(), so the places like readdir.c switched to plain inode_lock(); once killable variants of rwsem primitives appear, that'll be dealt with" Use down_read_killable() same as down_write_killable() in !shared case, as concurrent inode_lock() may take much time, that may be wanted to be interrupted by user. Signed-off-by: Kirill Tkhai <ktk...@virtuozzo.com> Signed-off-by: Peter Zijlstra (Intel) <pet...@infradead.org> Cc: Linus Torvalds <torva...@linux-foundation.org> Cc: Peter Zijlstra <pet...@infradead.org> Cc: Thomas Gleixner <t...@linutronix.de> Cc: a...@arndb.de Cc: ava...@virtuozzo.com Cc: da...@davemloft.net Cc: fenghua...@intel.com Cc: gorcu...@virtuozzo.com Cc: heiko.carst...@de.ibm.com Cc: h...@zytor.com Cc: i...@jurassic.park.msu.ru Cc: matts...@gmail.com Cc: rient...@google.com Cc: r...@twiddle.net Cc: schwidef...@de.ibm.com Cc: tony.l...@intel.com Cc: v...@zeniv.linux.org.uk Link: http://lkml.kernel.org/r/150670120820.23930.5455667921545937220.stgit@localhost.localdomain Signed-off-by: Ingo Molnar <mi...@kernel.org> --- fs/readdir.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fs/readdir.c b/fs/readdir.c index 8965954..7c584bb 100644 --- a/fs/readdir.c +++ b/fs/readdir.c @@ -36,13 +36,12 @@ int iterate_dir(struct file *file, struct dir_context *ctx) if (res) goto out; - if (shared) { - inode_lock_shared(inode); - } else { + if (shared) + res = down_read_killable(&inode->i_rwsem); + else res = down_write_killable(&inode->i_rwsem); - if (res) - goto out; - } + if (res) + goto out; res = -ENOENT; if (!IS_DEADDIR(inode)) {