add patch clear_lockdep_subtype_for_quota_files
[ext4-patch-queue.git] / clear_lockdep_subtype_for_quota_files
blob09434130bf372c618311ba0d1727ffca546162cd
1 ext4: clear lockdep subtype for quota files on quota off
3 From: Jan Kara <jack@suse.cz>
5 Quota files have special ranking of i_data_sem lock. We inform lockdep
6 about it when turning on quotas however when turning quotas off, we
7 don't clear the lockdep subclass from i_data_sem lock and thus when the
8 inode gets later reused for a normal file or directory, lockdep gets
9 confused and complains about possible deadlocks. Fix the problem by
10 resetting lockdep subclass of i_data_sem on quota off.
12 Cc: stable@vger.kernel.org
13 Fixes: daf647d2dd58cec59570d7698a45b98e580f2076
14 Reported-and-tested-by: Ross Zwisler <ross.zwisler@linux.intel.com>
15 Reviewed-by: Andreas Dilger <adilger@dilger.ca>
16 Signed-off-by: Jan Kara <jack@suse.cz>
17 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
18 ---
19  fs/ext4/super.c | 14 +++++---------
20  1 file changed, 5 insertions(+), 9 deletions(-)
22 Changes since v1: Updated tags.
24 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
25 index a9c72e39a4ee..77043dc7f704 100644
26 --- a/fs/ext4/super.c
27 +++ b/fs/ext4/super.c
28 @@ -846,14 +846,9 @@ static inline void ext4_quota_off_umount(struct super_block *sb)
29  {
30         int type;
32 -       if (ext4_has_feature_quota(sb)) {
33 -               dquot_disable(sb, -1,
34 -                             DQUOT_USAGE_ENABLED | DQUOT_LIMITS_ENABLED);
35 -       } else {
36 -               /* Use our quota_off function to clear inode flags etc. */
37 -               for (type = 0; type < EXT4_MAXQUOTAS; type++)
38 -                       ext4_quota_off(sb, type);
39 -       }
40 +       /* Use our quota_off function to clear inode flags etc. */
41 +       for (type = 0; type < EXT4_MAXQUOTAS; type++)
42 +               ext4_quota_off(sb, type);
43  }
44  #else
45  static inline void ext4_quota_off_umount(struct super_block *sb)
46 @@ -5476,7 +5471,7 @@ static int ext4_quota_off(struct super_block *sb, int type)
47                 goto out;
49         err = dquot_quota_off(sb, type);
50 -       if (err)
51 +       if (err || ext4_has_feature_quota(sb))
52                 goto out_put;
54         inode_lock(inode);
55 @@ -5496,6 +5491,7 @@ static int ext4_quota_off(struct super_block *sb, int type)
56  out_unlock:
57         inode_unlock(inode);
58  out_put:
59 +       lockdep_set_quota_inode(inode, I_DATA_SEM_NORMAL);
60         iput(inode);
61         return err;
62  out:
63 -- 
64 2.12.0