diff options
author | Christoph Hellwig <hch@infradead.org> | 2008-06-22 23:23:41 -0400 |
---|---|---|
committer | Niv Sardi <xaiki@debian.org> | 2008-07-28 02:58:52 -0400 |
commit | caf8aabdbc6849de772850d26d3dbe35e8f63bff (patch) | |
tree | 779c0b2c25f592d4e807b676d13ba975846aeacf | |
parent | ae23a5e87dbbf4657a82e1ff8ebc52ab50361c14 (diff) |
[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: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Tim Shimmin <tes@sgi.com>
Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
-rw-r--r-- | fs/xfs/xfs_attr.c | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c index 9d91af4929b1..49fac8d6db12 100644 --- a/fs/xfs/xfs_attr.c +++ b/fs/xfs/xfs_attr.c | |||
@@ -111,6 +111,17 @@ xfs_attr_name_to_xname( | |||
111 | return 0; | 111 | return 0; |
112 | } | 112 | } |
113 | 113 | ||
114 | STATIC int | ||
115 | xfs_inode_hasattr( | ||
116 | struct xfs_inode *ip) | ||
117 | { | ||
118 | if (!XFS_IFORK_Q(ip) || | ||
119 | (ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && | ||
120 | ip->i_d.di_anextents == 0)) | ||
121 | return 0; | ||
122 | return 1; | ||
123 | } | ||
124 | |||
114 | /*======================================================================== | 125 | /*======================================================================== |
115 | * Overall external interface routines. | 126 | * Overall external interface routines. |
116 | *========================================================================*/ | 127 | *========================================================================*/ |
@@ -122,10 +133,8 @@ xfs_attr_fetch(xfs_inode_t *ip, struct xfs_name *name, | |||
122 | xfs_da_args_t args; | 133 | xfs_da_args_t args; |
123 | int error; | 134 | int error; |
124 | 135 | ||
125 | if ((XFS_IFORK_Q(ip) == 0) || | 136 | if (!xfs_inode_hasattr(ip)) |
126 | (ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && | 137 | return ENOATTR; |
127 | ip->i_d.di_anextents == 0)) | ||
128 | return(ENOATTR); | ||
129 | 138 | ||
130 | /* | 139 | /* |
131 | * Fill in the arg structure for this request. | 140 | * Fill in the arg structure for this request. |
@@ -143,11 +152,7 @@ xfs_attr_fetch(xfs_inode_t *ip, struct xfs_name *name, | |||
143 | /* | 152 | /* |
144 | * Decide on what work routines to call based on the inode size. | 153 | * Decide on what work routines to call based on the inode size. |
145 | */ | 154 | */ |
146 | if (XFS_IFORK_Q(ip) == 0 || | 155 | if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { |
147 | (ip->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && | ||
148 | ip->i_d.di_anextents == 0)) { | ||
149 | error = XFS_ERROR(ENOATTR); | ||
150 | } else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { | ||
151 | error = xfs_attr_shortform_getvalue(&args); | 156 | error = xfs_attr_shortform_getvalue(&args); |
152 | } else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK)) { | 157 | } else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK)) { |
153 | error = xfs_attr_leaf_get(&args); | 158 | 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 | /* | 528 | /* |
524 | * Decide on what work routines to call based on the inode size. | 529 | * Decide on what work routines to call based on the inode size. |
525 | */ | 530 | */ |
526 | if (XFS_IFORK_Q(dp) == 0 || | 531 | if (!xfs_inode_hasattr(dp)) { |
527 | (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && | ||
528 | dp->i_d.di_anextents == 0)) { | ||
529 | error = XFS_ERROR(ENOATTR); | 532 | error = XFS_ERROR(ENOATTR); |
530 | goto out; | 533 | goto out; |
531 | } | 534 | } |
@@ -595,11 +598,9 @@ xfs_attr_remove( | |||
595 | return error; | 598 | return error; |
596 | 599 | ||
597 | xfs_ilock(dp, XFS_ILOCK_SHARED); | 600 | xfs_ilock(dp, XFS_ILOCK_SHARED); |
598 | if (XFS_IFORK_Q(dp) == 0 || | 601 | if (!xfs_inode_hasattr(dp)) { |
599 | (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && | ||
600 | dp->i_d.di_anextents == 0)) { | ||
601 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | 602 | xfs_iunlock(dp, XFS_ILOCK_SHARED); |
602 | return(XFS_ERROR(ENOATTR)); | 603 | return XFS_ERROR(ENOATTR); |
603 | } | 604 | } |
604 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | 605 | xfs_iunlock(dp, XFS_ILOCK_SHARED); |
605 | 606 | ||
@@ -615,9 +616,7 @@ xfs_attr_list_int(xfs_attr_list_context_t *context) | |||
615 | /* | 616 | /* |
616 | * Decide on what work routines to call based on the inode size. | 617 | * Decide on what work routines to call based on the inode size. |
617 | */ | 618 | */ |
618 | if (XFS_IFORK_Q(dp) == 0 || | 619 | if (!xfs_inode_hasattr(dp)) { |
619 | (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && | ||
620 | dp->i_d.di_anextents == 0)) { | ||
621 | error = 0; | 620 | error = 0; |
622 | } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { | 621 | } else if (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { |
623 | error = xfs_attr_shortform_list(context); | 622 | error = xfs_attr_shortform_list(context); |
@@ -810,12 +809,10 @@ xfs_attr_inactive(xfs_inode_t *dp) | |||
810 | ASSERT(! XFS_NOT_DQATTACHED(mp, dp)); | 809 | ASSERT(! XFS_NOT_DQATTACHED(mp, dp)); |
811 | 810 | ||
812 | xfs_ilock(dp, XFS_ILOCK_SHARED); | 811 | xfs_ilock(dp, XFS_ILOCK_SHARED); |
813 | if ((XFS_IFORK_Q(dp) == 0) || | 812 | if (!xfs_inode_hasattr(dp) || |
814 | (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) || | 813 | dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { |
815 | (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && | ||
816 | dp->i_d.di_anextents == 0)) { | ||
817 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | 814 | xfs_iunlock(dp, XFS_ILOCK_SHARED); |
818 | return(0); | 815 | return 0; |
819 | } | 816 | } |
820 | xfs_iunlock(dp, XFS_ILOCK_SHARED); | 817 | xfs_iunlock(dp, XFS_ILOCK_SHARED); |
821 | 818 | ||
@@ -848,10 +845,8 @@ xfs_attr_inactive(xfs_inode_t *dp) | |||
848 | /* | 845 | /* |
849 | * Decide on what work routines to call based on the inode size. | 846 | * Decide on what work routines to call based on the inode size. |
850 | */ | 847 | */ |
851 | if ((XFS_IFORK_Q(dp) == 0) || | 848 | if (!xfs_inode_hasattr(dp) || |
852 | (dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) || | 849 | dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { |
853 | (dp->i_d.di_aformat == XFS_DINODE_FMT_EXTENTS && | ||
854 | dp->i_d.di_anextents == 0)) { | ||
855 | error = 0; | 850 | error = 0; |
856 | goto out; | 851 | goto out; |
857 | } | 852 | } |