ovl: use ovl_inode_lock in ovl_llseek()
authorAmir Goldstein <amir73il@gmail.com>
Sat, 21 Dec 2019 09:42:29 +0000 (11:42 +0200)
committerMiklos Szeredi <mszeredi@redhat.com>
Wed, 22 Jan 2020 19:11:41 +0000 (20:11 +0100)
commitb1f9d3858f724ed45b279b689fb5b400d91352e3
treefaabb4d4dd5af7b3ea8448d1db1ed1019965fc5a
parent1bd0a3aea4357e1dce8b3f0f889fd3fe756353e6
ovl: use ovl_inode_lock in ovl_llseek()

In ovl_llseek() we use the overlay inode rwsem to protect against
concurrent modifications to real file f_pos, because we copy the overlay
file f_pos to/from the real file f_pos.

This caused a lockdep warning of locking order violation when the
ovl_llseek() operation was called on a lower nested overlay layer while the
upper layer fs sb_writers is held (with patch improving copy-up efficiency
for big sparse file).

Use the internal ovl_inode_lock() instead of the overlay inode rwsem in
those cases. It is meant to be used for protecting against concurrent
changes to overlay inode internal state changes.

The locking order rules are documented to explain this case.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
fs/overlayfs/file.c
fs/overlayfs/inode.c