mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
d3ee456dfb
commit
7c909772f1
|
@ -310,12 +310,13 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name,
|
||||||
|
|
||||||
if (name == NULL)
|
if (name == NULL)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
name_len = strlen(name);
|
|
||||||
|
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
value_len = 0;
|
value_len = 0;
|
||||||
|
|
||||||
if (name_len > 255 || value_len > MAX_VALUE_LEN)
|
name_len = strlen(name);
|
||||||
|
|
||||||
|
if (name_len > F2FS_NAME_LEN || value_len > MAX_VALUE_LEN)
|
||||||
return -ERANGE;
|
return -ERANGE;
|
||||||
|
|
||||||
f2fs_balance_fs(sbi);
|
f2fs_balance_fs(sbi);
|
||||||
|
@ -326,8 +327,8 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name,
|
||||||
struct dnode_of_data dn;
|
struct dnode_of_data dn;
|
||||||
|
|
||||||
if (!alloc_nid(sbi, &fi->i_xattr_nid)) {
|
if (!alloc_nid(sbi, &fi->i_xattr_nid)) {
|
||||||
mutex_unlock_op(sbi, NODE_NEW);
|
error = -ENOSPC;
|
||||||
return -ENOSPC;
|
goto exit;
|
||||||
}
|
}
|
||||||
set_new_dnode(&dn, inode, NULL, NULL, fi->i_xattr_nid);
|
set_new_dnode(&dn, inode, NULL, NULL, fi->i_xattr_nid);
|
||||||
mark_inode_dirty(inode);
|
mark_inode_dirty(inode);
|
||||||
|
@ -336,8 +337,8 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name,
|
||||||
if (IS_ERR(page)) {
|
if (IS_ERR(page)) {
|
||||||
alloc_nid_failed(sbi, fi->i_xattr_nid);
|
alloc_nid_failed(sbi, fi->i_xattr_nid);
|
||||||
fi->i_xattr_nid = 0;
|
fi->i_xattr_nid = 0;
|
||||||
mutex_unlock_op(sbi, NODE_NEW);
|
error = PTR_ERR(page);
|
||||||
return PTR_ERR(page);
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
alloc_nid_done(sbi, fi->i_xattr_nid);
|
alloc_nid_done(sbi, fi->i_xattr_nid);
|
||||||
|
@ -349,8 +350,8 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name,
|
||||||
/* The inode already has an extended attribute block. */
|
/* The inode already has an extended attribute block. */
|
||||||
page = get_node_page(sbi, fi->i_xattr_nid);
|
page = get_node_page(sbi, fi->i_xattr_nid);
|
||||||
if (IS_ERR(page)) {
|
if (IS_ERR(page)) {
|
||||||
mutex_unlock_op(sbi, NODE_NEW);
|
error = PTR_ERR(page);
|
||||||
return PTR_ERR(page);
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
base_addr = page_address(page);
|
base_addr = page_address(page);
|
||||||
|
@ -438,6 +439,7 @@ int f2fs_setxattr(struct inode *inode, int name_index, const char *name,
|
||||||
return 0;
|
return 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
f2fs_put_page(page, 1);
|
f2fs_put_page(page, 1);
|
||||||
|
exit:
|
||||||
mutex_unlock_op(sbi, NODE_NEW);
|
mutex_unlock_op(sbi, NODE_NEW);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue