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/udf/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/udf/namei.c')
-rw-r--r-- | fs/udf/namei.c | 17 |
1 files changed, 17 insertions, 0 deletions
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) { |