提交 caf8aabd 编写于 作者: C Christoph Hellwig 提交者: Niv Sardi

[XFS] Factor out code for whether inode has attributes or not.

SGI-PV: 983394

SGI-Modid: xfs-linux-melb:xfs-kern:31323a
Signed-off-by: NChristoph Hellwig <hch@infradead.org>
Signed-off-by: NTim Shimmin <tes@sgi.com>
Signed-off-by: NLachlan McIlroy <lachlan@sgi.com>
上级 ae23a5e8
...@@ -111,6 +111,17 @@ xfs_attr_name_to_xname( ...@@ -111,6 +111,17 @@ xfs_attr_name_to_xname(
return 0; return 0;
} }
STATIC int
xfs_inode_hasattr(
struct xfs_inode *ip)
{
if (!XFS_IFORK_Q(ip) ||
(ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
ip->i_d.di_anextents == 0))
return 0;
return 1;
}
/*======================================================================== /*========================================================================
* Overall external interface routines. * Overall external interface routines.
*========================================================================*/ *========================================================================*/
...@@ -122,10 +133,8 @@ xfs_attr_fetch(xfs_inode_t *ip, struct xfs_name *name, ...@@ -122,10 +133,8 @@ xfs_attr_fetch(xfs_inode_t *ip, struct xfs_name *name,
xfs_da_args_t args; xfs_da_args_t args;
int error; int error;
if ((XFS_IFORK_Q(ip) == 0) || if (!xfs_inode_hasattr(ip))
(ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && return ENOATTR;
ip->i_d.di_anextents == 0))
return(ENOATTR);
/* /*
* Fill in the arg structure for this request. * Fill in the arg structure for this request.
...@@ -143,11 +152,7 @@ xfs_attr_fetch(xfs_inode_t *ip, struct xfs_name *name, ...@@ -143,11 +152,7 @@ xfs_attr_fetch(xfs_inode_t *ip, struct xfs_name *name,
/* /*
* Decide on what work routines to call based on the inode size. * Decide on what work routines to call based on the inode size.
*/ */
if (XFS_IFORK_Q(ip) == 0 || if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
(ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
ip->i_d.di_anextents == 0)) {
error = XFS_ERROR(ENOATTR);
} else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
error = xfs_attr_shortform_getvalue(&args); error = xfs_attr_shortform_getvalue(&args);
} else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK)) { } else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK)) {
error = xfs_attr_leaf_get(&args); error = xfs_attr_leaf_get(&args);
...@@ -523,9 +528,7 @@ xfs_attr_remove_int(xfs_inode_t *dp, struct xfs_name *name, int flags) ...@@ -523,9 +528,7 @@ xfs_attr_remove_int(xfs_inode_t *dp, struct xfs_name *name, int flags)
/* /*
* Decide on what work routines to call based on the inode size. * Decide on what work routines to call based on the inode size.
*/ */
if (XFS_IFORK_Q(dp) == 0 || if (!xfs_inode_hasattr(dp)) {
(dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
dp->i_d.di_anextents == 0)) {
error = XFS_ERROR(ENOATTR); error = XFS_ERROR(ENOATTR);
goto out; goto out;
} }
...@@ -595,11 +598,9 @@ xfs_attr_remove( ...@@ -595,11 +598,9 @@ xfs_attr_remove(
return error; return error;
xfs_ilock(dp, XFS_ILOCK_SHARED); xfs_ilock(dp, XFS_ILOCK_SHARED);
if (XFS_IFORK_Q(dp) == 0 || if (!xfs_inode_hasattr(dp)) {
(dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
dp->i_d.di_anextents == 0)) {
xfs_iunlock(dp, XFS_ILOCK_SHARED); xfs_iunlock(dp, XFS_ILOCK_SHARED);
return(XFS_ERROR(ENOATTR)); return XFS_ERROR(ENOATTR);
} }
xfs_iunlock(dp, XFS_ILOCK_SHARED); xfs_iunlock(dp, XFS_ILOCK_SHARED);
...@@ -615,9 +616,7 @@ xfs_attr_list_int(xfs_attr_list_context_t *context) ...@@ -615,9 +616,7 @@ xfs_attr_list_int(xfs_attr_list_context_t *context)
/* /*
* Decide on what work routines to call based on the inode size. * Decide on what work routines to call based on the inode size.
*/ */
if (XFS_IFORK_Q(dp) == 0 || if (!xfs_inode_hasattr(dp)) {
(dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
dp->i_d.di_anextents == 0)) {
error = 0; error = 0;
} else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
error = xfs_attr_shortform_list(context); error = xfs_attr_shortform_list(context);
...@@ -810,12 +809,10 @@ xfs_attr_inactive(xfs_inode_t *dp) ...@@ -810,12 +809,10 @@ xfs_attr_inactive(xfs_inode_t *dp)
ASSERT(! XFS_NOT_DQATTACHED(mp, dp)); ASSERT(! XFS_NOT_DQATTACHED(mp, dp));
xfs_ilock(dp, XFS_ILOCK_SHARED); xfs_ilock(dp, XFS_ILOCK_SHARED);
if ((XFS_IFORK_Q(dp) == 0) || if (!xfs_inode_hasattr(dp) ||
(dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) || dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
(dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
dp->i_d.di_anextents == 0)) {
xfs_iunlock(dp, XFS_ILOCK_SHARED); xfs_iunlock(dp, XFS_ILOCK_SHARED);
return(0); return 0;
} }
xfs_iunlock(dp, XFS_ILOCK_SHARED); xfs_iunlock(dp, XFS_ILOCK_SHARED);
...@@ -848,10 +845,8 @@ xfs_attr_inactive(xfs_inode_t *dp) ...@@ -848,10 +845,8 @@ xfs_attr_inactive(xfs_inode_t *dp)
/* /*
* Decide on what work routines to call based on the inode size. * Decide on what work routines to call based on the inode size.
*/ */
if ((XFS_IFORK_Q(dp) == 0) || if (!xfs_inode_hasattr(dp) ||
(dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) || dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) {
(dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS &&
dp->i_d.di_anextents == 0)) {
error = 0; error = 0;
goto out; goto out;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册