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/ext3 | |
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/ext3')
-rw-r--r-- | fs/ext3/file.c | 2 | ||||
-rw-r--r-- | fs/ext3/inode.c | 5 | ||||
-rw-r--r-- | fs/ext3/namei.c | 18 |
3 files changed, 24 insertions, 1 deletions
diff --git a/fs/ext3/file.c b/fs/ext3/file.c index a86d3302cdc2..3c7fb11a3b29 100644 --- a/fs/ext3/file.c +++ b/fs/ext3/file.c | |||
@@ -62,7 +62,7 @@ const struct file_operations ext3_file_operations = { | |||
62 | .compat_ioctl = ext3_compat_ioctl, | 62 | .compat_ioctl = ext3_compat_ioctl, |
63 | #endif | 63 | #endif |
64 | .mmap = generic_file_mmap, | 64 | .mmap = generic_file_mmap, |
65 | .open = generic_file_open, | 65 | .open = dquot_file_open, |
66 | .release = ext3_release_file, | 66 | .release = ext3_release_file, |
67 | .fsync = ext3_sync_file, | 67 | .fsync = ext3_sync_file, |
68 | .splice_read = generic_file_splice_read, | 68 | .splice_read = generic_file_splice_read, |
diff --git a/fs/ext3/inode.c b/fs/ext3/inode.c index 14d40a4dd6f0..d7962b0c57b3 100644 --- a/fs/ext3/inode.c +++ b/fs/ext3/inode.c | |||
@@ -196,6 +196,9 @@ void ext3_delete_inode (struct inode * inode) | |||
196 | { | 196 | { |
197 | handle_t *handle; | 197 | handle_t *handle; |
198 | 198 | ||
199 | if (!is_bad_inode(inode)) | ||
200 | vfs_dq_init(inode); | ||
201 | |||
199 | truncate_inode_pages(&inode->i_data, 0); | 202 | truncate_inode_pages(&inode->i_data, 0); |
200 | 203 | ||
201 | if (is_bad_inode(inode)) | 204 | if (is_bad_inode(inode)) |
@@ -3148,6 +3151,8 @@ int ext3_setattr(struct dentry *dentry, struct iattr *attr) | |||
3148 | if (error) | 3151 | if (error) |
3149 | return error; | 3152 | return error; |
3150 | 3153 | ||
3154 | if (ia_valid & ATTR_SIZE) | ||
3155 | vfs_dq_init(inode); | ||
3151 | if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || | 3156 | if ((ia_valid & ATTR_UID && attr->ia_uid != inode->i_uid) || |
3152 | (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) { | 3157 | (ia_valid & ATTR_GID && attr->ia_gid != inode->i_gid)) { |
3153 | handle_t *handle; | 3158 | handle_t *handle; |
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 7b0e44f7d66f..a492b371b134 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
@@ -1696,6 +1696,8 @@ static int ext3_create (struct inode * dir, struct dentry * dentry, int mode, | |||
1696 | struct inode * inode; | 1696 | struct inode * inode; |
1697 | int err, retries = 0; | 1697 | int err, retries = 0; |
1698 | 1698 | ||
1699 | vfs_dq_init(dir); | ||
1700 | |||
1699 | retry: | 1701 | retry: |
1700 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + | 1702 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + |
1701 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1703 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
@@ -1730,6 +1732,8 @@ static int ext3_mknod (struct inode * dir, struct dentry *dentry, | |||
1730 | if (!new_valid_dev(rdev)) | 1732 | if (!new_valid_dev(rdev)) |
1731 | return -EINVAL; | 1733 | return -EINVAL; |
1732 | 1734 | ||
1735 | vfs_dq_init(dir); | ||
1736 | |||
1733 | retry: | 1737 | retry: |
1734 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + | 1738 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + |
1735 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1739 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
@@ -1766,6 +1770,8 @@ static int ext3_mkdir(struct inode * dir, struct dentry * dentry, int mode) | |||
1766 | if (dir->i_nlink >= EXT3_LINK_MAX) | 1770 | if (dir->i_nlink >= EXT3_LINK_MAX) |
1767 | return -EMLINK; | 1771 | return -EMLINK; |
1768 | 1772 | ||
1773 | vfs_dq_init(dir); | ||
1774 | |||
1769 | retry: | 1775 | retry: |
1770 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + | 1776 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + |
1771 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + | 1777 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 3 + |
@@ -2060,7 +2066,9 @@ static int ext3_rmdir (struct inode * dir, struct dentry *dentry) | |||
2060 | 2066 | ||
2061 | /* Initialize quotas before so that eventual writes go in | 2067 | /* Initialize quotas before so that eventual writes go in |
2062 | * separate transaction */ | 2068 | * separate transaction */ |
2069 | vfs_dq_init(dir); | ||
2063 | vfs_dq_init(dentry->d_inode); | 2070 | vfs_dq_init(dentry->d_inode); |
2071 | |||
2064 | handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); | 2072 | handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); |
2065 | if (IS_ERR(handle)) | 2073 | if (IS_ERR(handle)) |
2066 | return PTR_ERR(handle); | 2074 | return PTR_ERR(handle); |
@@ -2119,7 +2127,9 @@ static int ext3_unlink(struct inode * dir, struct dentry *dentry) | |||
2119 | 2127 | ||
2120 | /* Initialize quotas before so that eventual writes go | 2128 | /* Initialize quotas before so that eventual writes go |
2121 | * in separate transaction */ | 2129 | * in separate transaction */ |
2130 | vfs_dq_init(dir); | ||
2122 | vfs_dq_init(dentry->d_inode); | 2131 | vfs_dq_init(dentry->d_inode); |
2132 | |||
2123 | handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); | 2133 | handle = ext3_journal_start(dir, EXT3_DELETE_TRANS_BLOCKS(dir->i_sb)); |
2124 | if (IS_ERR(handle)) | 2134 | if (IS_ERR(handle)) |
2125 | return PTR_ERR(handle); | 2135 | return PTR_ERR(handle); |
@@ -2174,6 +2184,8 @@ static int ext3_symlink (struct inode * dir, | |||
2174 | if (l > dir->i_sb->s_blocksize) | 2184 | if (l > dir->i_sb->s_blocksize) |
2175 | return -ENAMETOOLONG; | 2185 | return -ENAMETOOLONG; |
2176 | 2186 | ||
2187 | vfs_dq_init(dir); | ||
2188 | |||
2177 | retry: | 2189 | retry: |
2178 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + | 2190 | handle = ext3_journal_start(dir, EXT3_DATA_TRANS_BLOCKS(dir->i_sb) + |
2179 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 + | 2191 | EXT3_INDEX_EXTRA_TRANS_BLOCKS + 5 + |
@@ -2228,6 +2240,9 @@ static int ext3_link (struct dentry * old_dentry, | |||
2228 | 2240 | ||
2229 | if (inode->i_nlink >= EXT3_LINK_MAX) | 2241 | if (inode->i_nlink >= EXT3_LINK_MAX) |
2230 | return -EMLINK; | 2242 | return -EMLINK; |
2243 | |||
2244 | vfs_dq_init(dir); | ||
2245 | |||
2231 | /* | 2246 | /* |
2232 | * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing | 2247 | * Return -ENOENT if we've raced with unlink and i_nlink is 0. Doing |
2233 | * otherwise has the potential to corrupt the orphan inode list. | 2248 | * otherwise has the potential to corrupt the orphan inode list. |
@@ -2278,6 +2293,9 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry, | |||
2278 | struct ext3_dir_entry_2 * old_de, * new_de; | 2293 | struct ext3_dir_entry_2 * old_de, * new_de; |
2279 | int retval, flush_file = 0; | 2294 | int retval, flush_file = 0; |
2280 | 2295 | ||
2296 | vfs_dq_init(old_dir); | ||
2297 | vfs_dq_init(new_dir); | ||
2298 | |||
2281 | old_bh = new_bh = dir_bh = NULL; | 2299 | old_bh = new_bh = dir_bh = NULL; |
2282 | 2300 | ||
2283 | /* Initialize quotas before so that eventual writes go | 2301 | /* Initialize quotas before so that eventual writes go |