Skip to content

Commit

Permalink
locking/rwsem, fs: Use killable down_read() in iterate_dir()
Browse files Browse the repository at this point in the history
There was mutex_lock_interruptible() initially, and it was changed
to rwsem, but there were not killable rwsem primitives that time.
>From commit 9902af7:

    "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 <ktkhai@virtuozzo.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
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 <mingo@kernel.org>
  • Loading branch information
Kirill Tkhai authored and Ingo Molnar committed Oct 10, 2017
1 parent 76f8507 commit 0dc208b
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions fs/readdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 0dc208b

Please sign in to comment.