aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2/namei.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext2/namei.c')
-rw-r--r--fs/ext2/namei.c51
1 files changed, 34 insertions, 17 deletions
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index dd7175ce5606..71efb0e9a3f2 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -31,6 +31,7 @@
31 */ 31 */
32 32
33#include <linux/pagemap.h> 33#include <linux/pagemap.h>
34#include <linux/quotaops.h>
34#include "ext2.h" 35#include "ext2.h"
35#include "xattr.h" 36#include "xattr.h"
36#include "acl.h" 37#include "acl.h"
@@ -99,24 +100,27 @@ struct dentry *ext2_get_parent(struct dentry *child)
99 */ 100 */
100static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, struct nameidata *nd) 101static int ext2_create (struct inode * dir, struct dentry * dentry, int mode, struct nameidata *nd)
101{ 102{
102 struct inode * inode = ext2_new_inode (dir, mode); 103 struct inode *inode;
103 int err = PTR_ERR(inode); 104
104 if (!IS_ERR(inode)) { 105 dquot_initialize(dir);
105 inode->i_op = &ext2_file_inode_operations; 106
106 if (ext2_use_xip(inode->i_sb)) { 107 inode = ext2_new_inode(dir, mode);
107 inode->i_mapping->a_ops = &ext2_aops_xip; 108 if (IS_ERR(inode))
108 inode->i_fop = &ext2_xip_file_operations; 109 return PTR_ERR(inode);
109 } else if (test_opt(inode->i_sb, NOBH)) { 110
110 inode->i_mapping->a_ops = &ext2_nobh_aops; 111 inode->i_op = &ext2_file_inode_operations;
111 inode->i_fop = &ext2_file_operations; 112 if (ext2_use_xip(inode->i_sb)) {
112 } else { 113 inode->i_mapping->a_ops = &ext2_aops_xip;
113 inode->i_mapping->a_ops = &ext2_aops; 114 inode->i_fop = &ext2_xip_file_operations;
114 inode->i_fop = &ext2_file_operations; 115 } else if (test_opt(inode->i_sb, NOBH)) {
115 } 116 inode->i_mapping->a_ops = &ext2_nobh_aops;
116 mark_inode_dirty(inode); 117 inode->i_fop = &ext2_file_operations;
117 err = ext2_add_nondir(dentry, inode); 118 } else {
119 inode->i_mapping->a_ops = &ext2_aops;
120 inode->i_fop = &ext2_file_operations;
118 } 121 }
119 return err; 122 mark_inode_dirty(inode);
123 return ext2_add_nondir(dentry, inode);
120} 124}
121 125
122static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev) 126static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_t rdev)
@@ -127,6 +131,8 @@ static int ext2_mknod (struct inode * dir, struct dentry *dentry, int mode, dev_
127 if (!new_valid_dev(rdev)) 131 if (!new_valid_dev(rdev))
128 return -EINVAL; 132 return -EINVAL;
129 133
134 dquot_initialize(dir);
135
130 inode = ext2_new_inode (dir, mode); 136 inode = ext2_new_inode (dir, mode);
131 err = PTR_ERR(inode); 137 err = PTR_ERR(inode);
132 if (!IS_ERR(inode)) { 138 if (!IS_ERR(inode)) {
@@ -151,6 +157,8 @@ static int ext2_symlink (struct inode * dir, struct dentry * dentry,
151 if (l > sb->s_blocksize) 157 if (l > sb->s_blocksize)
152 goto out; 158 goto out;
153 159
160 dquot_initialize(dir);
161
154 inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO); 162 inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO);
155 err = PTR_ERR(inode); 163 err = PTR_ERR(inode);
156 if (IS_ERR(inode)) 164 if (IS_ERR(inode))
@@ -194,6 +202,8 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
194 if (inode->i_nlink >= EXT2_LINK_MAX) 202 if (inode->i_nlink >= EXT2_LINK_MAX)
195 return -EMLINK; 203 return -EMLINK;
196 204
205 dquot_initialize(dir);
206
197 inode->i_ctime = CURRENT_TIME_SEC; 207 inode->i_ctime = CURRENT_TIME_SEC;
198 inode_inc_link_count(inode); 208 inode_inc_link_count(inode);
199 atomic_inc(&inode->i_count); 209 atomic_inc(&inode->i_count);
@@ -216,6 +226,8 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, int mode)
216 if (dir->i_nlink >= EXT2_LINK_MAX) 226 if (dir->i_nlink >= EXT2_LINK_MAX)
217 goto out; 227 goto out;
218 228
229 dquot_initialize(dir);
230
219 inode_inc_link_count(dir); 231 inode_inc_link_count(dir);
220 232
221 inode = ext2_new_inode (dir, S_IFDIR | mode); 233 inode = ext2_new_inode (dir, S_IFDIR | mode);
@@ -262,6 +274,8 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry)
262 struct page * page; 274 struct page * page;
263 int err = -ENOENT; 275 int err = -ENOENT;
264 276
277 dquot_initialize(dir);
278
265 de = ext2_find_entry (dir, &dentry->d_name, &page); 279 de = ext2_find_entry (dir, &dentry->d_name, &page);
266 if (!de) 280 if (!de)
267 goto out; 281 goto out;
@@ -304,6 +318,9 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
304 struct ext2_dir_entry_2 * old_de; 318 struct ext2_dir_entry_2 * old_de;
305 int err = -ENOENT; 319 int err = -ENOENT;
306 320
321 dquot_initialize(old_dir);
322 dquot_initialize(new_dir);
323
307 old_de = ext2_find_entry (old_dir, &old_dentry->d_name, &old_page); 324 old_de = ext2_find_entry (old_dir, &old_dentry->d_name, &old_page);
308 if (!old_de) 325 if (!old_de)
309 goto out; 326 goto out;