1 ext4: quota macros cleanup
3 Currently all quota block reservation macros contains hardcoded "2"
4 aka MAXQUOTAS value. This is no good because in some places it is not
5 obvious to understand what does this digit represent. Let's introduce
6 new macro with self descriptive name.
7 diff --git a/fs/ext4/ext4_jbd2.h b/fs/ext4/ext4_jbd2.h
8 index a286598..9062d05 100644
9 --- a/fs/ext4/ext4_jbd2.h
10 +++ b/fs/ext4/ext4_jbd2.h
13 #define EXT4_DATA_TRANS_BLOCKS(sb) (EXT4_SINGLEDATA_TRANS_BLOCKS(sb) + \
14 EXT4_XATTR_TRANS_BLOCKS - 2 + \
15 - 2*EXT4_QUOTA_TRANS_BLOCKS(sb))
16 + EXT4_MAXQUOTAS_TRANS_BLOCKS(sb))
19 * Define the number of metadata blocks we need to account to modify data.
21 * This include super block, inode block, quota blocks and xattr blocks
23 #define EXT4_META_TRANS_BLOCKS(sb) (EXT4_XATTR_TRANS_BLOCKS + \
24 - 2*EXT4_QUOTA_TRANS_BLOCKS(sb))
25 + EXT4_MAXQUOTAS_TRANS_BLOCKS(sb))
27 /* Delete operations potentially hit one directory's namespace plus an
28 * entire inode, plus arbitrary amounts of bitmap/indirection data. Be
30 * but inode, sb and group updates are done only once */
31 #define EXT4_QUOTA_INIT_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_INIT_ALLOC*\
32 (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_INIT_REWRITE) : 0)
34 #define EXT4_QUOTA_DEL_BLOCKS(sb) (test_opt(sb, QUOTA) ? (DQUOT_DEL_ALLOC*\
35 (EXT4_SINGLEDATA_TRANS_BLOCKS(sb)-3)+3+DQUOT_DEL_REWRITE) : 0)
38 #define EXT4_QUOTA_INIT_BLOCKS(sb) 0
39 #define EXT4_QUOTA_DEL_BLOCKS(sb) 0
41 +#define EXT4_MAXQUOTAS_TRANS_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_TRANS_BLOCKS(sb))
42 +#define EXT4_MAXQUOTAS_INIT_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_INIT_BLOCKS(sb))
43 +#define EXT4_MAXQUOTAS_DEL_BLOCKS(sb) (MAXQUOTAS*EXT4_QUOTA_DEL_BLOCKS(sb))
46 ext4_mark_iloc_dirty(handle_t *handle,
47 diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
48 index 10539e3..0efe010 100644
49 --- a/fs/ext4/extents.c
50 +++ b/fs/ext4/extents.c
51 @@ -2167,7 +2167,7 @@ ext4_ext_rm_leaf(handle_t *handle, struct inode *inode,
53 credits += (ext_depth(inode)) + 1;
55 - credits += 2 * EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb);
56 + credits += EXT4_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb);
58 err = ext4_ext_truncate_extend_restart(handle, inode, credits);
60 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
61 index 5c5bc5d..08964b9 100644
64 @@ -5221,7 +5221,7 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr)
66 /* (user+group)*(old+new) structure, inode write (sb,
67 * inode block, ? - but truncate inode update has it) */
68 - handle = ext4_journal_start(inode, 2*(EXT4_QUOTA_INIT_BLOCKS(inode->i_sb)+
69 + handle = ext4_journal_start(inode, (EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb)+
70 EXT4_QUOTA_DEL_BLOCKS(inode->i_sb))+3);
72 error = PTR_ERR(handle);
73 diff --git a/fs/ext4/migrate.c b/fs/ext4/migrate.c
74 index a93d5b8..cee81d5 100644
75 --- a/fs/ext4/migrate.c
76 +++ b/fs/ext4/migrate.c
77 @@ -238,7 +238,7 @@ static int extend_credit_for_blkdel(handle_t *handle, struct inode *inode)
78 * So allocate a credit of 3. We may update
79 * quota (user and group).
81 - needed = 3 + 2*EXT4_QUOTA_TRANS_BLOCKS(inode->i_sb);
82 + needed = 3 + EXT4_MAXQUOTAS_TRANS_BLOCKS(inode->i_sb);
84 if (ext4_journal_extend(handle, needed) != 0)
85 retval = ext4_journal_restart(handle, needed);
86 @@ -477,7 +477,7 @@ int ext4_ext_migrate(struct inode *inode)
87 handle = ext4_journal_start(inode,
88 EXT4_DATA_TRANS_BLOCKS(inode->i_sb) +
89 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
90 - 2 * EXT4_QUOTA_INIT_BLOCKS(inode->i_sb)
91 + EXT4_MAXQUOTAS_INIT_BLOCKS(inode->i_sb)
94 retval = PTR_ERR(handle);
95 diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
96 index 7c8fe80..4ad3881 100644
99 @@ -1783,7 +1783,7 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, int mode,
101 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
102 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
103 - 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
104 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
106 return PTR_ERR(handle);
108 @@ -1817,7 +1817,7 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry,
110 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
111 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
112 - 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
113 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
115 return PTR_ERR(handle);
117 @@ -1854,7 +1854,7 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode)
119 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
120 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 +
121 - 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
122 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
124 return PTR_ERR(handle);
126 @@ -2267,7 +2267,7 @@ static int ext4_symlink(struct inode *dir,
128 handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) +
129 EXT4_INDEX_EXTRA_TRANS_BLOCKS + 5 +
130 - 2*EXT4_QUOTA_INIT_BLOCKS(dir->i_sb));
131 + EXT4_MAXQUOTAS_INIT_BLOCKS(dir->i_sb));
133 return PTR_ERR(handle);