From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756419AbdJJLJd (ORCPT ); Tue, 10 Oct 2017 07:09:33 -0400 Received: from terminus.zytor.com ([65.50.211.136]:43329 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756321AbdJJLJa (ORCPT ); Tue, 10 Oct 2017 07:09:30 -0400 Date: Tue, 10 Oct 2017 04:05:55 -0700 From: tip-bot for Kirill Tkhai Message-ID: Cc: mingo@kernel.org, hpa@zytor.com, peterz@infradead.org, tglx@linutronix.de, torvalds@linux-foundation.org, ktkhai@virtuozzo.com, linux-kernel@vger.kernel.org Reply-To: linux-kernel@vger.kernel.org, ktkhai@virtuozzo.com, torvalds@linux-foundation.org, tglx@linutronix.de, peterz@infradead.org, mingo@kernel.org, hpa@zytor.com In-Reply-To: <150670120820.23930.5455667921545937220.stgit@localhost.localdomain> References: <150670120820.23930.5455667921545937220.stgit@localhost.localdomain> To: linux-tip-commits@vger.kernel.org Subject: [tip:locking/core] locking/rwsem, fs: Use killable down_read() in iterate_dir() Git-Commit-ID: 0dc208b5d5feedc795cbf124539decd182c8e99e X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0dc208b5d5feedc795cbf124539decd182c8e99e Gitweb: https://git.kernel.org/tip/0dc208b5d5feedc795cbf124539decd182c8e99e Author: Kirill Tkhai AuthorDate: Fri, 29 Sep 2017 19:06:48 +0300 Committer: Ingo Molnar 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 Signed-off-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: arnd@arndb.de Cc: avagin@virtuozzo.com Cc: davem@davemloft.net Cc: fenghua.yu@intel.com Cc: gorcunov@virtuozzo.com Cc: heiko.carstens@de.ibm.com Cc: hpa@zytor.com Cc: ink@jurassic.park.msu.ru Cc: mattst88@gmail.com Cc: rientjes@google.com Cc: rth@twiddle.net Cc: schwidefsky@de.ibm.com Cc: tony.luck@intel.com Cc: viro@zeniv.linux.org.uk Link: http://lkml.kernel.org/r/150670120820.23930.5455667921545937220.stgit@localhost.localdomain Signed-off-by: Ingo Molnar --- 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)) {