quota: Use s_umount protection for quota operations
authorJan Kara <jack@suse.cz>
Wed, 23 Nov 2016 12:35:14 +0000 (13:35 +0100)
committerJan Kara <jack@suse.cz>
Thu, 24 Nov 2016 14:27:16 +0000 (15:27 +0100)
commit9d1ccbe70e0b14545caad12dc73adb3605447df0
tree9a8b6122cf02f099996bf5137bbec4d9e4e8799d
parent7d6cd73d33b62021111a469b6a454ec357be295f
quota: Use s_umount protection for quota operations

Writeback quota is protected by s_umount semaphore held for reading
because every writeback must be protected by that lock (grabbed either
by the generic writeback code or by quotactl handler). Getting next
available ID in quota file, querying quota state, setting quota
information, getting quota format are all quotactl operations protected
by s_umount semaphore held for reading grabbed in quotactl handler.

This also fixes lockdep splat about possible deadlock during filesystem
freezing where sync_filesystem() is called with page-faults already
blocked but sync_filesystem() calls into dquot_writeback_dquots() which
grabs dqonoff_mutex which ranks above i_mutex (vfs_load_quota_inode()
grabs i_mutex under dqonoff_mutex) which clearly ranks below page fault
freeze protection (e.g. via mmap_sem dependencies). The reported problem
is not a real deadlock possibility since during quota on we check
whether filesystem freezing is not in progress but still it is good to
have this fixed.

Reported-by: Ted Tso <tytso@mit.edu>
Reported-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/quota/dquot.c
fs/quota/quota.c