diff options
author | Jan Kara <jack@suse.cz> | 2016-11-23 13:16:10 +0100 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2016-11-24 15:26:53 +0100 |
commit | 7d6cd73d33b62021111a469b6a454ec357be295f (patch) | |
tree | 7feaea7fdb5d8d49c07a0836fd6f9dcc54290e69 /fs/quota/dquot.c | |
parent | ba6379f7e6c7e51b3c0e92672bc61bb6961c2b5e (diff) | |
download | op-kernel-dev-7d6cd73d33b62021111a469b6a454ec357be295f.zip op-kernel-dev-7d6cd73d33b62021111a469b6a454ec357be295f.tar.gz |
quota: Hold s_umount in exclusive mode when enabling / disabling quotas
Currently we hold s_umount semaphore only in shared mode when enabling
or disabling quotas and use dqonoff_mutex for serializing quota state
changes on a filesystem and also quota state changes with other places
depending on current quota state. Using dedicated mutex for this causes
possible deadlocks during filesystem freezing (see following commit for
details) so we transition to using s_umount semaphore for the necessary
synchronization whose lock ordering is properly handled by the
filesystem freezing code. As a start grab s_umount in exclusive mode
when enabling / disabling quotas.
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/quota/dquot.c')
-rw-r--r-- | fs/quota/dquot.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 1bfac28..047afb9 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c @@ -2107,6 +2107,10 @@ int dquot_disable(struct super_block *sb, int type, unsigned int flags) struct quota_info *dqopt = sb_dqopt(sb); struct inode *toputinode[MAXQUOTAS]; + /* s_umount should be held in exclusive mode */ + if (WARN_ON_ONCE(down_read_trylock(&sb->s_umount))) + up_read(&sb->s_umount); + /* Cannot turn off usage accounting without turning off limits, or * suspend quotas and simultaneously turn quotas off. */ if ((flags & DQUOT_USAGE_ENABLED && !(flags & DQUOT_LIMITS_ENABLED)) @@ -2371,6 +2375,10 @@ int dquot_resume(struct super_block *sb, int type) int ret = 0, cnt; unsigned int flags; + /* s_umount should be held in exclusive mode */ + if (WARN_ON_ONCE(down_read_trylock(&sb->s_umount))) + up_read(&sb->s_umount); + for (cnt = 0; cnt < MAXQUOTAS; cnt++) { if (type != -1 && cnt != type) continue; @@ -2430,6 +2438,9 @@ int dquot_enable(struct inode *inode, int type, int format_id, /* Just unsuspend quotas? */ BUG_ON(flags & DQUOT_SUSPENDED); + /* s_umount should be held in exclusive mode */ + if (WARN_ON_ONCE(down_read_trylock(&sb->s_umount))) + up_read(&sb->s_umount); if (!flags) return 0; |