diff options
author | Jan Kara <jack@suse.com> | 2015-06-29 10:08:45 -0400 |
---|---|---|
committer | Jan Kara <jack@suse.com> | 2015-07-23 14:59:37 -0400 |
commit | c2edb305d6846ee8af7b5133845e23943d128e4c (patch) | |
tree | b87a0e482f3b7d0e80bc6cd473a2cc11901a5bb6 /fs/ext2 | |
parent | 6184fc0b8dd76c6aedc7a26e93254993e14e52de (diff) |
ext2: Handle error from dquot_initalize()
dquot_initialize() can now return error. Handle it where possible.
Signed-off-by: Jan Kara <jack@suse.com>
Diffstat (limited to 'fs/ext2')
-rw-r--r-- | fs/ext2/ialloc.c | 5 | ||||
-rw-r--r-- | fs/ext2/inode.c | 7 | ||||
-rw-r--r-- | fs/ext2/namei.c | 46 |
3 files changed, 43 insertions, 15 deletions
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index 5c04a0ddea80..efe5fb21c533 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c | |||
@@ -577,7 +577,10 @@ got: | |||
577 | goto fail; | 577 | goto fail; |
578 | } | 578 | } |
579 | 579 | ||
580 | dquot_initialize(inode); | 580 | err = dquot_initialize(inode); |
581 | if (err) | ||
582 | goto fail_drop; | ||
583 | |||
581 | err = dquot_alloc_inode(inode); | 584 | err = dquot_alloc_inode(inode); |
582 | if (err) | 585 | if (err) |
583 | goto fail_drop; | 586 | goto fail_drop; |
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c index 5c09776d347f..a3a404c5df2e 100644 --- a/fs/ext2/inode.c +++ b/fs/ext2/inode.c | |||
@@ -1552,8 +1552,11 @@ int ext2_setattr(struct dentry *dentry, struct iattr *iattr) | |||
1552 | if (error) | 1552 | if (error) |
1553 | return error; | 1553 | return error; |
1554 | 1554 | ||
1555 | if (is_quota_modification(inode, iattr)) | 1555 | if (is_quota_modification(inode, iattr)) { |
1556 | dquot_initialize(inode); | 1556 | error = dquot_initialize(inode); |
1557 | if (error) | ||
1558 | return error; | ||
1559 | } | ||
1557 | if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) || | 1560 | if ((iattr->ia_valid & ATTR_UID && !uid_eq(iattr->ia_uid, inode->i_uid)) || |
1558 | (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) { | 1561 | (iattr->ia_valid & ATTR_GID && !gid_eq(iattr->ia_gid, inode->i_gid))) { |
1559 | error = dquot_transfer(inode, iattr); | 1562 | error = dquot_transfer(inode, iattr); |
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c index 13ec54a99c96..b4841e3066a5 100644 --- a/fs/ext2/namei.c +++ b/fs/ext2/namei.c | |||
@@ -96,8 +96,11 @@ struct dentry *ext2_get_parent(struct dentry *child) | |||
96 | static int ext2_create (struct inode * dir, struct dentry * dentry, umode_t mode, bool excl) | 96 | static int ext2_create (struct inode * dir, struct dentry * dentry, umode_t mode, bool excl) |
97 | { | 97 | { |
98 | struct inode *inode; | 98 | struct inode *inode; |
99 | int err; | ||
99 | 100 | ||
100 | dquot_initialize(dir); | 101 | err = dquot_initialize(dir); |
102 | if (err) | ||
103 | return err; | ||
101 | 104 | ||
102 | inode = ext2_new_inode(dir, mode, &dentry->d_name); | 105 | inode = ext2_new_inode(dir, mode, &dentry->d_name); |
103 | if (IS_ERR(inode)) | 106 | if (IS_ERR(inode)) |
@@ -143,7 +146,9 @@ static int ext2_mknod (struct inode * dir, struct dentry *dentry, umode_t mode, | |||
143 | if (!new_valid_dev(rdev)) | 146 | if (!new_valid_dev(rdev)) |
144 | return -EINVAL; | 147 | return -EINVAL; |
145 | 148 | ||
146 | dquot_initialize(dir); | 149 | err = dquot_initialize(dir); |
150 | if (err) | ||
151 | return err; | ||
147 | 152 | ||
148 | inode = ext2_new_inode (dir, mode, &dentry->d_name); | 153 | inode = ext2_new_inode (dir, mode, &dentry->d_name); |
149 | err = PTR_ERR(inode); | 154 | err = PTR_ERR(inode); |
@@ -169,7 +174,9 @@ static int ext2_symlink (struct inode * dir, struct dentry * dentry, | |||
169 | if (l > sb->s_blocksize) | 174 | if (l > sb->s_blocksize) |
170 | goto out; | 175 | goto out; |
171 | 176 | ||
172 | dquot_initialize(dir); | 177 | err = dquot_initialize(dir); |
178 | if (err) | ||
179 | goto out; | ||
173 | 180 | ||
174 | inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO, &dentry->d_name); | 181 | inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO, &dentry->d_name); |
175 | err = PTR_ERR(inode); | 182 | err = PTR_ERR(inode); |
@@ -212,7 +219,9 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir, | |||
212 | struct inode *inode = d_inode(old_dentry); | 219 | struct inode *inode = d_inode(old_dentry); |
213 | int err; | 220 | int err; |
214 | 221 | ||
215 | dquot_initialize(dir); | 222 | err = dquot_initialize(dir); |
223 | if (err) | ||
224 | return err; | ||
216 | 225 | ||
217 | inode->i_ctime = CURRENT_TIME_SEC; | 226 | inode->i_ctime = CURRENT_TIME_SEC; |
218 | inode_inc_link_count(inode); | 227 | inode_inc_link_count(inode); |
@@ -233,7 +242,9 @@ static int ext2_mkdir(struct inode * dir, struct dentry * dentry, umode_t mode) | |||
233 | struct inode * inode; | 242 | struct inode * inode; |
234 | int err; | 243 | int err; |
235 | 244 | ||
236 | dquot_initialize(dir); | 245 | err = dquot_initialize(dir); |
246 | if (err) | ||
247 | return err; | ||
237 | 248 | ||
238 | inode_inc_link_count(dir); | 249 | inode_inc_link_count(dir); |
239 | 250 | ||
@@ -279,13 +290,17 @@ static int ext2_unlink(struct inode * dir, struct dentry *dentry) | |||
279 | struct inode * inode = d_inode(dentry); | 290 | struct inode * inode = d_inode(dentry); |
280 | struct ext2_dir_entry_2 * de; | 291 | struct ext2_dir_entry_2 * de; |
281 | struct page * page; | 292 | struct page * page; |
282 | int err = -ENOENT; | 293 | int err; |
283 | 294 | ||
284 | dquot_initialize(dir); | 295 | err = dquot_initialize(dir); |
296 | if (err) | ||
297 | goto out; | ||
285 | 298 | ||
286 | de = ext2_find_entry (dir, &dentry->d_name, &page); | 299 | de = ext2_find_entry (dir, &dentry->d_name, &page); |
287 | if (!de) | 300 | if (!de) { |
301 | err = -ENOENT; | ||
288 | goto out; | 302 | goto out; |
303 | } | ||
289 | 304 | ||
290 | err = ext2_delete_entry (de, page); | 305 | err = ext2_delete_entry (de, page); |
291 | if (err) | 306 | if (err) |
@@ -323,14 +338,21 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry, | |||
323 | struct ext2_dir_entry_2 * dir_de = NULL; | 338 | struct ext2_dir_entry_2 * dir_de = NULL; |
324 | struct page * old_page; | 339 | struct page * old_page; |
325 | struct ext2_dir_entry_2 * old_de; | 340 | struct ext2_dir_entry_2 * old_de; |
326 | int err = -ENOENT; | 341 | int err; |
342 | |||
343 | err = dquot_initialize(old_dir); | ||
344 | if (err) | ||
345 | goto out; | ||
327 | 346 | ||
328 | dquot_initialize(old_dir); | 347 | err = dquot_initialize(new_dir); |
329 | dquot_initialize(new_dir); | 348 | if (err) |
349 | goto out; | ||
330 | 350 | ||
331 | old_de = ext2_find_entry (old_dir, &old_dentry->d_name, &old_page); | 351 | old_de = ext2_find_entry (old_dir, &old_dentry->d_name, &old_page); |
332 | if (!old_de) | 352 | if (!old_de) { |
353 | err = -ENOENT; | ||
333 | goto out; | 354 | goto out; |
355 | } | ||
334 | 356 | ||
335 | if (S_ISDIR(old_inode->i_mode)) { | 357 | if (S_ISDIR(old_inode->i_mode)) { |
336 | err = -EIO; | 358 | err = -EIO; |