]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
NFS: swap IO handling is slightly different for O_DIRECT IO
authorNeilBrown <neilb@suse.de>
Sun, 6 Mar 2022 23:41:44 +0000 (10:41 +1100)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 13:19:51 +0000 (15:19 +0200)
commitec9d5b7c2e22b13fb017177dab3e4f70451c1022
tree2cb61b89b49dbb4a8685ffae87c8047fa114264e
parent60e4886a33fb7e0fb7cda4767557e36211996e67
NFS: swap IO handling is slightly different for O_DIRECT IO

BugLink: https://bugs.launchpad.net/bugs/1971497
[ Upstream commit 64158668ac8b31626a8ce48db4cad08496eb8340 ]

1/ Taking the i_rwsem for swap IO triggers lockdep warnings regarding
   possible deadlocks with "fs_reclaim".  These deadlocks could, I believe,
   eventuate if a buffered read on the swapfile was attempted.

   We don't need coherence with the page cache for a swap file, and
   buffered writes are forbidden anyway.  There is no other need for
   i_rwsem during direct IO.  So never take it for swap_rw()

2/ generic_write_checks() explicitly forbids writes to swap, and
   performs checks that are not needed for swap.  So bypass it
   for swap_rw().

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
fs/nfs/direct.c
fs/nfs/file.c
include/linux/nfs_fs.h