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/jfs | |
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/jfs')
-rw-r--r-- | fs/jfs/file.c | 4 | ||||
-rw-r--r-- | fs/jfs/inode.c | 3 | ||||
-rw-r--r-- | fs/jfs/namei.c | 15 |
3 files changed, 21 insertions, 1 deletions
diff --git a/fs/jfs/file.c b/fs/jfs/file.c index 2c201783836..f19bb33eb1e 100644 --- a/fs/jfs/file.c +++ b/fs/jfs/file.c | |||
@@ -48,7 +48,7 @@ static int jfs_open(struct inode *inode, struct file *file) | |||
48 | { | 48 | { |
49 | int rc; | 49 | int rc; |
50 | 50 | ||
51 | if ((rc = generic_file_open(inode, file))) | 51 | if ((rc = dquot_file_open(inode, file))) |
52 | return rc; | 52 | return rc; |
53 | 53 | ||
54 | /* | 54 | /* |
@@ -98,6 +98,8 @@ int jfs_setattr(struct dentry *dentry, struct iattr *iattr) | |||
98 | if (rc) | 98 | if (rc) |
99 | return rc; | 99 | return rc; |
100 | 100 | ||
101 | if (iattr->ia_valid & ATTR_SIZE) | ||
102 | vfs_dq_init(inode); | ||
101 | if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) || | 103 | if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) || |
102 | (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) { | 104 | (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) { |
103 | rc = dquot_transfer(inode, iattr); | 105 | rc = dquot_transfer(inode, iattr); |
diff --git a/fs/jfs/inode.c b/fs/jfs/inode.c index 22fa412c528..1aa2dda1659 100644 --- a/fs/jfs/inode.c +++ b/fs/jfs/inode.c | |||
@@ -146,6 +146,9 @@ void jfs_delete_inode(struct inode *inode) | |||
146 | { | 146 | { |
147 | jfs_info("In jfs_delete_inode, inode = 0x%p", inode); | 147 | jfs_info("In jfs_delete_inode, inode = 0x%p", inode); |
148 | 148 | ||
149 | if (!is_bad_inode(inode)) | ||
150 | vfs_dq_init(inode); | ||
151 | |||
149 | if (!is_bad_inode(inode) && | 152 | if (!is_bad_inode(inode) && |
150 | (JFS_IP(inode)->fileset == FILESYSTEM_I)) { | 153 | (JFS_IP(inode)->fileset == FILESYSTEM_I)) { |
151 | truncate_inode_pages(&inode->i_data, 0); | 154 | truncate_inode_pages(&inode->i_data, 0); |
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index 1d1390afe55..b7cc29da50b 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c | |||
@@ -85,6 +85,8 @@ static int jfs_create(struct inode *dip, struct dentry *dentry, int mode, | |||
85 | 85 | ||
86 | jfs_info("jfs_create: dip:0x%p name:%s", dip, dentry->d_name.name); | 86 | jfs_info("jfs_create: dip:0x%p name:%s", dip, dentry->d_name.name); |
87 | 87 | ||
88 | vfs_dq_init(dip); | ||
89 | |||
88 | /* | 90 | /* |
89 | * search parent directory for entry/freespace | 91 | * search parent directory for entry/freespace |
90 | * (dtSearch() returns parent directory page pinned) | 92 | * (dtSearch() returns parent directory page pinned) |
@@ -215,6 +217,8 @@ static int jfs_mkdir(struct inode *dip, struct dentry *dentry, int mode) | |||
215 | 217 | ||
216 | jfs_info("jfs_mkdir: dip:0x%p name:%s", dip, dentry->d_name.name); | 218 | jfs_info("jfs_mkdir: dip:0x%p name:%s", dip, dentry->d_name.name); |
217 | 219 | ||
220 | vfs_dq_init(dip); | ||
221 | |||
218 | /* link count overflow on parent directory ? */ | 222 | /* link count overflow on parent directory ? */ |
219 | if (dip->i_nlink == JFS_LINK_MAX) { | 223 | if (dip->i_nlink == JFS_LINK_MAX) { |
220 | rc = -EMLINK; | 224 | rc = -EMLINK; |
@@ -356,6 +360,7 @@ static int jfs_rmdir(struct inode *dip, struct dentry *dentry) | |||
356 | jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name); | 360 | jfs_info("jfs_rmdir: dip:0x%p name:%s", dip, dentry->d_name.name); |
357 | 361 | ||
358 | /* Init inode for quota operations. */ | 362 | /* Init inode for quota operations. */ |
363 | vfs_dq_init(dip); | ||
359 | vfs_dq_init(ip); | 364 | vfs_dq_init(ip); |
360 | 365 | ||
361 | /* directory must be empty to be removed */ | 366 | /* directory must be empty to be removed */ |
@@ -483,6 +488,7 @@ static int jfs_unlink(struct inode *dip, struct dentry *dentry) | |||
483 | jfs_info("jfs_unlink: dip:0x%p name:%s", dip, dentry->d_name.name); | 488 | jfs_info("jfs_unlink: dip:0x%p name:%s", dip, dentry->d_name.name); |
484 | 489 | ||
485 | /* Init inode for quota operations. */ | 490 | /* Init inode for quota operations. */ |
491 | vfs_dq_init(dip); | ||
486 | vfs_dq_init(ip); | 492 | vfs_dq_init(ip); |
487 | 493 | ||
488 | if ((rc = get_UCSname(&dname, dentry))) | 494 | if ((rc = get_UCSname(&dname, dentry))) |
@@ -805,6 +811,8 @@ static int jfs_link(struct dentry *old_dentry, | |||
805 | if (ip->i_nlink == 0) | 811 | if (ip->i_nlink == 0) |
806 | return -ENOENT; | 812 | return -ENOENT; |
807 | 813 | ||
814 | vfs_dq_init(dir); | ||
815 | |||
808 | tid = txBegin(ip->i_sb, 0); | 816 | tid = txBegin(ip->i_sb, 0); |
809 | 817 | ||
810 | mutex_lock_nested(&JFS_IP(dir)->commit_mutex, COMMIT_MUTEX_PARENT); | 818 | mutex_lock_nested(&JFS_IP(dir)->commit_mutex, COMMIT_MUTEX_PARENT); |
@@ -896,6 +904,8 @@ static int jfs_symlink(struct inode *dip, struct dentry *dentry, | |||
896 | 904 | ||
897 | jfs_info("jfs_symlink: dip:0x%p name:%s", dip, name); | 905 | jfs_info("jfs_symlink: dip:0x%p name:%s", dip, name); |
898 | 906 | ||
907 | vfs_dq_init(dip); | ||
908 | |||
899 | ssize = strlen(name) + 1; | 909 | ssize = strlen(name) + 1; |
900 | 910 | ||
901 | /* | 911 | /* |
@@ -1087,6 +1097,9 @@ static int jfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
1087 | jfs_info("jfs_rename: %s %s", old_dentry->d_name.name, | 1097 | jfs_info("jfs_rename: %s %s", old_dentry->d_name.name, |
1088 | new_dentry->d_name.name); | 1098 | new_dentry->d_name.name); |
1089 | 1099 | ||
1100 | vfs_dq_init(old_dir); | ||
1101 | vfs_dq_init(new_dir); | ||
1102 | |||
1090 | old_ip = old_dentry->d_inode; | 1103 | old_ip = old_dentry->d_inode; |
1091 | new_ip = new_dentry->d_inode; | 1104 | new_ip = new_dentry->d_inode; |
1092 | 1105 | ||
@@ -1360,6 +1373,8 @@ static int jfs_mknod(struct inode *dir, struct dentry *dentry, | |||
1360 | 1373 | ||
1361 | jfs_info("jfs_mknod: %s", dentry->d_name.name); | 1374 | jfs_info("jfs_mknod: %s", dentry->d_name.name); |
1362 | 1375 | ||
1376 | vfs_dq_init(dir); | ||
1377 | |||
1363 | if ((rc = get_UCSname(&dname, dentry))) | 1378 | if ((rc = get_UCSname(&dname, dentry))) |
1364 | goto out; | 1379 | goto out; |
1365 | 1380 | ||