diff options
author | Namjae Jeon <namjae.jeon@samsung.com> | 2013-03-17 04:26:39 -0400 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk.kim@samsung.com> | 2013-03-20 05:30:15 -0400 |
commit | 7c909772f1222dd82098659da4d0c41d8a051790 (patch) | |
tree | 9e1ce1175d34ffc8114b861e613b78c62a9edb0e | |
parent | d3ee456dfbed1992bcaa0096d9bc76a691b0e700 (diff) |
f2fs: reorganize f2fs_setxattr
make use of F2FS_NAME_LEN for name length checking,
change return conditions at few places, by assigning
storing the errorvalue in 'error' and making a common
exit path.
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Amit Sahrawat <a.sahrawat@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
-rw-r--r-- | fs/f2fs/xattr.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index 8038c0496504..3bfea80610ff 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c | |||
@@ -310,12 +310,13 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name, | |||
310 | 310 | ||
311 | if (name == NULL) | 311 | if (name == NULL) |
312 | return -EINVAL; | 312 | return -EINVAL; |
313 | name_len = strlen(name); | ||
314 | 313 | ||
315 | if (value == NULL) | 314 | if (value == NULL) |
316 | value_len = 0; | 315 | value_len = 0; |
317 | 316 | ||
318 | if (name_len > 255 || value_len > MAX_VALUE_LEN) | 317 | name_len = strlen(name); |
318 | |||
319 | if (name_len > F2FS_NAME_LEN || value_len > MAX_VALUE_LEN) | ||
319 | return -ERANGE; | 320 | return -ERANGE; |
320 | 321 | ||
321 | f2fs_balance_fs(sbi); | 322 | f2fs_balance_fs(sbi); |
@@ -326,8 +327,8 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name, | |||
326 | struct dnode_of_data dn; | 327 | struct dnode_of_data dn; |
327 | 328 | ||
328 | if (!alloc_nid(sbi, &fi->i_xattr_nid)) { | 329 | if (!alloc_nid(sbi, &fi->i_xattr_nid)) { |
329 | mutex_unlock_op(sbi, NODE_NEW); | 330 | error = -ENOSPC; |
330 | return -ENOSPC; | 331 | goto exit; |
331 | } | 332 | } |
332 | set_new_dnode(&dn, inode, NULL, NULL, fi->i_xattr_nid); | 333 | set_new_dnode(&dn, inode, NULL, NULL, fi->i_xattr_nid); |
333 | mark_inode_dirty(inode); | 334 | mark_inode_dirty(inode); |
@@ -336,8 +337,8 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name, | |||
336 | if (IS_ERR(page)) { | 337 | if (IS_ERR(page)) { |
337 | alloc_nid_failed(sbi, fi->i_xattr_nid); | 338 | alloc_nid_failed(sbi, fi->i_xattr_nid); |
338 | fi->i_xattr_nid = 0; | 339 | fi->i_xattr_nid = 0; |
339 | mutex_unlock_op(sbi, NODE_NEW); | 340 | error = PTR_ERR(page); |
340 | return PTR_ERR(page); | 341 | goto exit; |
341 | } | 342 | } |
342 | 343 | ||
343 | alloc_nid_done(sbi, fi->i_xattr_nid); | 344 | alloc_nid_done(sbi, fi->i_xattr_nid); |
@@ -349,8 +350,8 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name, | |||
349 | /* The inode already has an extended attribute block. */ | 350 | /* The inode already has an extended attribute block. */ |
350 | page = get_node_page(sbi, fi->i_xattr_nid); | 351 | page = get_node_page(sbi, fi->i_xattr_nid); |
351 | if (IS_ERR(page)) { | 352 | if (IS_ERR(page)) { |
352 | mutex_unlock_op(sbi, NODE_NEW); | 353 | error = PTR_ERR(page); |
353 | return PTR_ERR(page); | 354 | goto exit; |
354 | } | 355 | } |
355 | 356 | ||
356 | base_addr = page_address(page); | 357 | base_addr = page_address(page); |
@@ -438,6 +439,7 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name, | |||
438 | return 0; | 439 | return 0; |
439 | cleanup: | 440 | cleanup: |
440 | f2fs_put_page(page, 1); | 441 | f2fs_put_page(page, 1); |
442 | exit: | ||
441 | mutex_unlock_op(sbi, NODE_NEW); | 443 | mutex_unlock_op(sbi, NODE_NEW); |
442 | return error; | 444 | return error; |
443 | } | 445 | } |