diff options
author | Christoph Hellwig <hch@infradead.org> | 2010-03-03 09:05:06 -0500 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2010-03-04 18:20:30 -0500 |
commit | 907f4554e2521cb28b0009d17167760650a9561c (patch) | |
tree | 68dc49163fd34331f8efbd63592c8f1baa387031 /fs/ext4/namei.c | |
parent | 9f7547580263d4a55efe06ce5cfd567f568be6e8 (diff) |
dquot: move dquot initialization responsibility into the filesystem
Currently various places in the VFS call vfs_dq_init directly. This means
we tie the quota code into the VFS. Get rid of that and make the
filesystem responsible for the initialization. For most metadata operations
this is a straight forward move into the methods, but for truncate and
open it's a bit more complicated.
For truncate we currently only call vfs_dq_init for the sys_truncate case
because open already takes care of it for ftruncate and open(O_TRUNC) - the
new code causes an additional vfs_dq_init for those which is harmless.
For open the initialization is moved from do_filp_open into the open method,
which means it happens slightly earlier now, and only for regular files.
The latter is fine because we don't need to initialize it for operations
on special files, and we already do it as part of the namespace operations
for directories.
Add a dquot_file_open helper that filesystems that support generic quotas
can use to fill in ->open.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs/ext4/namei.c')
-rw-r--r-- | fs/ext4/namei.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 17a17e10dd60..20f55c2e7571 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
@@ -1766,6 +1766,8 @@ static int ext4_create(struct inode *dir, struct dentry *dentry, int mode, | |||
1766 | struct inode *inode; | 1766 | struct inode *inode; |
1767 | int err, retries = 0; | 1767 | int err, retries = 0; |
1768 | 1768 | ||
1769 | vfs_dq_init(dir); | ||
1770 | |||
1769 | retry: | 1771 | retry: |
1770 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + | 1772 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + |
1771 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1773 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
@@ -1800,6 +1802,8 @@ static int ext4_mknod(struct inode *dir, struct dentry *dentry, | |||
1800 | if (!new_valid_dev(rdev)) | 1802 | if (!new_valid_dev(rdev)) |
1801 | return -EINVAL; | 1803 | return -EINVAL; |
1802 | 1804 | ||
1805 | vfs_dq_init(dir); | ||
1806 | |||
1803 | retry: | 1807 | retry: |
1804 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + | 1808 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + |
1805 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1809 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
@@ -1837,6 +1841,8 @@ static int ext4_mkdir(struct inode *dir, struct dentry *dentry, int mode) | |||
1837 | if (EXT4_DIR_LINK_MAX(dir)) | 1841 | if (EXT4_DIR_LINK_MAX(dir)) |
1838 | return -EMLINK; | 1842 | return -EMLINK; |
1839 | 1843 | ||
1844 | vfs_dq_init(dir); | ||
1845 | |||
1840 | retry: | 1846 | retry: |
1841 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + | 1847 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + |
1842 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1848 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
@@ -2136,7 +2142,9 @@ static int ext4_rmdir(struct inode *dir, struct dentry *dentry) | |||
2136 | 2142 | ||
2137 | /* Initialize quotas before so that eventual writes go in | 2143 | /* Initialize quotas before so that eventual writes go in |
2138 | * separate transaction */ | 2144 | * separate transaction */ |
2145 | vfs_dq_init(dir); | ||
2139 | vfs_dq_init(dentry->d_inode); | 2146 | vfs_dq_init(dentry->d_inode); |
2147 | |||
2140 | handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); | 2148 | handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); |
2141 | if (IS_ERR(handle)) | 2149 | if (IS_ERR(handle)) |
2142 | return PTR_ERR(handle); | 2150 | return PTR_ERR(handle); |
@@ -2195,7 +2203,9 @@ static int ext4_unlink(struct inode *dir, struct dentry *dentry) | |||
2195 | 2203 | ||
2196 | /* Initialize quotas before so that eventual writes go | 2204 | /* Initialize quotas before so that eventual writes go |
2197 | * in separate transaction */ | 2205 | * in separate transaction */ |
2206 | vfs_dq_init(dir); | ||
2198 | vfs_dq_init(dentry->d_inode); | 2207 | vfs_dq_init(dentry->d_inode); |
2208 | |||
2199 | handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); | 2209 | handle = ext4_journal_start(dir, EXT4_DELETE_TRANS_BLOCKS(dir->i_sb)); |
2200 | if (IS_ERR(handle)) | 2210 | if (IS_ERR(handle)) |
2201 | return PTR_ERR(handle); | 2211 | return PTR_ERR(handle); |
@@ -2250,6 +2260,8 @@ static int ext4_symlink(struct inode *dir, | |||
2250 | if (l > dir->i_sb->s_blocksize) | 2260 | if (l > dir->i_sb->s_blocksize) |
2251 | return -ENAMETOOLONG; | 2261 | return -ENAMETOOLONG; |
2252 | 2262 | ||
2263 | vfs_dq_init(dir); | ||
2264 | |||
2253 | retry: | 2265 | retry: |
2254 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + | 2266 | handle = ext4_journal_start(dir, EXT4_DATA_TRANS_BLOCKS(dir->i_sb) + |
2255 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 5 + | 2267 | EXT4_INDEX_EXTRA_TRANS_BLOCKS + 5 + |
@@ -2308,6 +2320,8 @@ static int ext4_link(struct dentry *old_dentry, | |||
2308 | if (inode->i_nlink >= EXT4_LINK_MAX) | 2320 | if (inode->i_nlink >= EXT4_LINK_MAX) |
2309 | return -EMLINK; | 2321 | return -EMLINK; |
2310 | 2322 | ||
2323 | vfs_dq_init(dir); | ||
2324 | |||
2311 | /* | 2325 | /* |
2312 | * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing | 2326 | * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing |
2313 | * otherwise has the potential to corrupt the orphan inode list. | 2327 | * otherwise has the potential to corrupt the orphan inode list. |
@@ -2358,6 +2372,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
2358 | struct ext4_dir_entry_2 *old_de, *new_de; | 2372 | struct ext4_dir_entry_2 *old_de, *new_de; |
2359 | int retval, force_da_alloc = 0; | 2373 | int retval, force_da_alloc = 0; |
2360 | 2374 | ||
2375 | vfs_dq_init(old_dir); | ||
2376 | vfs_dq_init(new_dir); | ||
2377 | |||
2361 | old_bh = new_bh = dir_bh = NULL; | 2378 | old_bh = new_bh = dir_bh = NULL; |
2362 | 2379 | ||
2363 | /* Initialize quotas before so that eventual writes go | 2380 | /* Initialize quotas before so that eventual writes go |