aboutsummaryrefslogtreecommitdiffstats
path: root/fs/udf
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2010-03-03 09:05:06 -0500
committerJan Kara <jack@suse.cz>2010-03-04 18:20:30 -0500
commit907f4554e2521cb28b0009d17167760650a9561c (patch)
tree68dc49163fd34331f8efbd63592c8f1baa387031 /fs/udf
parent9f7547580263d4a55efe06ce5cfd567f568be6e8 (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/udf')
-rw-r--r--fs/udf/file.c5
-rw-r--r--fs/udf/inode.c4
-rw-r--r--fs/udf/namei.c17
3 files changed, 25 insertions, 1 deletions
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 2df7fcb677b3..013fa44d9a5e 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -208,7 +208,7 @@ const struct file_operations udf_file_operations = {
208 .read = do_sync_read, 208 .read = do_sync_read,
209 .aio_read = generic_file_aio_read, 209 .aio_read = generic_file_aio_read,
210 .ioctl = udf_ioctl, 210 .ioctl = udf_ioctl,
211 .open = generic_file_open, 211 .open = dquot_file_open,
212 .mmap = generic_file_mmap, 212 .mmap = generic_file_mmap,
213 .write = do_sync_write, 213 .write = do_sync_write,
214 .aio_write = udf_file_aio_write, 214 .aio_write = udf_file_aio_write,
@@ -227,6 +227,9 @@ static int udf_setattr(struct dentry *dentry, struct iattr *iattr)
227 if (error) 227 if (error)
228 return error; 228 return error;
229 229
230 if (iattr->ia_valid & ATTR_SIZE)
231 vfs_dq_init(inode);
232
230 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) || 233 if ((iattr->ia_valid & ATTR_UID && iattr->ia_uid != inode->i_uid) ||
231 (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) { 234 (iattr->ia_valid & ATTR_GID && iattr->ia_gid != inode->i_gid)) {
232 error = dquot_transfer(inode, iattr); 235 error = dquot_transfer(inode, iattr);
diff --git a/fs/udf/inode.c b/fs/udf/inode.c
index 1199e8e21ee2..f19520268404 100644
--- a/fs/udf/inode.c
+++ b/fs/udf/inode.c
@@ -36,6 +36,7 @@
36#include <linux/pagemap.h> 36#include <linux/pagemap.h>
37#include <linux/buffer_head.h> 37#include <linux/buffer_head.h>
38#include <linux/writeback.h> 38#include <linux/writeback.h>
39#include <linux/quotaops.h>
39#include <linux/slab.h> 40#include <linux/slab.h>
40#include <linux/crc-itu-t.h> 41#include <linux/crc-itu-t.h>
41 42
@@ -70,6 +71,9 @@ static int udf_get_block(struct inode *, sector_t, struct buffer_head *, int);
70 71
71void udf_delete_inode(struct inode *inode) 72void udf_delete_inode(struct inode *inode)
72{ 73{
74 if (!is_bad_inode(inode))
75 vfs_dq_init(inode);
76
73 truncate_inode_pages(&inode->i_data, 0); 77 truncate_inode_pages(&inode->i_data, 0);
74 78
75 if (is_bad_inode(inode)) 79 if (is_bad_inode(inode))
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index cd2115060fdc..e360c3fc4ae4 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -563,6 +563,8 @@ static int udf_create(struct inode *dir, struct dentry *dentry, int mode,
563 int err; 563 int err;
564 struct udf_inode_info *iinfo; 564 struct udf_inode_info *iinfo;
565 565
566 vfs_dq_init(dir);
567
566 lock_kernel(); 568 lock_kernel();
567 inode = udf_new_inode(dir, mode, &err); 569 inode = udf_new_inode(dir, mode, &err);
568 if (!inode) { 570 if (!inode) {
@@ -616,6 +618,8 @@ static int udf_mknod(struct inode *dir, struct dentry *dentry, int mode,
616 if (!old_valid_dev(rdev)) 618 if (!old_valid_dev(rdev))
617 return -EINVAL; 619 return -EINVAL;
618 620
621 vfs_dq_init(dir);
622
619 lock_kernel(); 623 lock_kernel();
620 err = -EIO; 624 err = -EIO;
621 inode = udf_new_inode(dir, mode, &err); 625 inode = udf_new_inode(dir, mode, &err);
@@ -662,6 +666,8 @@ static int udf_mkdir(struct inode *dir, struct dentry *dentry, int mode)
662 struct udf_inode_info *dinfo = UDF_I(dir); 666 struct udf_inode_info *dinfo = UDF_I(dir);
663 struct udf_inode_info *iinfo; 667 struct udf_inode_info *iinfo;
664 668
669 vfs_dq_init(dir);
670
665 lock_kernel(); 671 lock_kernel();
666 err = -EMLINK; 672 err = -EMLINK;
667 if (dir->i_nlink >= (256 << sizeof(dir->i_nlink)) - 1) 673 if (dir->i_nlink >= (256 << sizeof(dir->i_nlink)) - 1)
@@ -799,6 +805,8 @@ static int udf_rmdir(struct inode *dir, struct dentry *dentry)
799 struct fileIdentDesc *fi, cfi; 805 struct fileIdentDesc *fi, cfi;
800 struct kernel_lb_addr tloc; 806 struct kernel_lb_addr tloc;
801 807
808 vfs_dq_init(dir);
809
802 retval = -ENOENT; 810 retval = -ENOENT;
803 lock_kernel(); 811 lock_kernel();
804 fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi); 812 fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi);
@@ -845,6 +853,8 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
845 struct fileIdentDesc cfi; 853 struct fileIdentDesc cfi;
846 struct kernel_lb_addr tloc; 854 struct kernel_lb_addr tloc;
847 855
856 vfs_dq_init(dir);
857
848 retval = -ENOENT; 858 retval = -ENOENT;
849 lock_kernel(); 859 lock_kernel();
850 fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi); 860 fi = udf_find_entry(dir, &dentry->d_name, &fibh, &cfi);
@@ -899,6 +909,8 @@ static int udf_symlink(struct inode *dir, struct dentry *dentry,
899 struct buffer_head *bh; 909 struct buffer_head *bh;
900 struct udf_inode_info *iinfo; 910 struct udf_inode_info *iinfo;
901 911
912 vfs_dq_init(dir);
913
902 lock_kernel(); 914 lock_kernel();
903 inode = udf_new_inode(dir, S_IFLNK, &err); 915 inode = udf_new_inode(dir, S_IFLNK, &err);
904 if (!inode) 916 if (!inode)
@@ -1069,6 +1081,8 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
1069 int err; 1081 int err;
1070 struct buffer_head *bh; 1082 struct buffer_head *bh;
1071 1083
1084 vfs_dq_init(dir);
1085
1072 lock_kernel(); 1086 lock_kernel();
1073 if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1) { 1087 if (inode->i_nlink >= (256 << sizeof(inode->i_nlink)) - 1) {
1074 unlock_kernel(); 1088 unlock_kernel();
@@ -1131,6 +1145,9 @@ static int udf_rename(struct inode *old_dir, struct dentry *old_dentry,
1131 struct kernel_lb_addr tloc; 1145 struct kernel_lb_addr tloc;
1132 struct udf_inode_info *old_iinfo = UDF_I(old_inode); 1146 struct udf_inode_info *old_iinfo = UDF_I(old_inode);
1133 1147
1148 vfs_dq_init(old_dir);
1149 vfs_dq_init(new_dir);
1150
1134 lock_kernel(); 1151 lock_kernel();
1135 ofi = udf_find_entry(old_dir, &old_dentry->d_name, &ofibh, &ocfi); 1152 ofi = udf_find_entry(old_dir, &old_dentry->d_name, &ofibh, &ocfi);
1136 if (ofi) { 1153 if (ofi) {