aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_attr.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2014-05-13 02:34:24 -0400
committerDave Chinner <david@fromorbit.com>2014-05-13 02:34:24 -0400
commitb87d022c275bce66553a27b68790e7c91927875f (patch)
treed231a7de70d6aa9fbbf5e9a4eb5c19e1d6902250 /fs/xfs/xfs_attr.c
parentc5b4ac39a4cb6a9a79025106a471f0738b3cb525 (diff)
xfs: fold xfs_attr_get_int into xfs_attr_get
This allows doing an unlocked check if an attr for is present at all and slightly reduce the lock hold time if we actually do an attr get. Plus various minor style fixes to the new xfs_attr_get. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_attr.c')
-rw-r--r--fs/xfs/xfs_attr.c79
1 files changed, 27 insertions, 52 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index eb3ae8fcaf74..01f226710079 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -106,26 +106,34 @@ xfs_inode_hasattr(
106 * Overall external interface routines. 106 * Overall external interface routines.
107 *========================================================================*/ 107 *========================================================================*/
108 108
109STATIC int 109int
110xfs_attr_get_int( 110xfs_attr_get(
111 struct xfs_inode *ip, 111 struct xfs_inode *ip,
112 struct xfs_name *name, 112 const unsigned char *name,
113 unsigned char *value, 113 unsigned char *value,
114 int *valuelenp, 114 int *valuelenp,
115 int flags) 115 int flags)
116{ 116{
117 xfs_da_args_t args; 117 struct xfs_da_args args;
118 int error; 118 struct xfs_name xname;
119 uint lock_mode;
120 int error;
121
122 XFS_STATS_INC(xs_attr_get);
123
124 if (XFS_FORCED_SHUTDOWN(ip->i_mount))
125 return EIO;
119 126
120 if (!xfs_inode_hasattr(ip)) 127 if (!xfs_inode_hasattr(ip))
121 return ENOATTR; 128 return ENOATTR;
122 129
123 /* 130 error = xfs_attr_name_to_xname(&xname, name);
124 * Fill in the arg structure for this request. 131 if (error)
125 */ 132 return error;
126 memset((char *)&args, 0, sizeof(args)); 133
127 args.name = name->name; 134 memset(&args, 0, sizeof(args));
128 args.namelen = name->len; 135 args.name = xname.name;
136 args.namelen = xname.len;
129 args.value = value; 137 args.value = value;
130 args.valuelen = *valuelenp; 138 args.valuelen = *valuelenp;
131 args.flags = flags; 139 args.flags = flags;
@@ -133,52 +141,19 @@ xfs_attr_get_int(
133 args.dp = ip; 141 args.dp = ip;
134 args.whichfork = XFS_ATTR_FORK; 142 args.whichfork = XFS_ATTR_FORK;
135 143
136 /* 144 lock_mode = xfs_ilock_attr_map_shared(ip);
137 * Decide on what work routines to call based on the inode size. 145 if (!xfs_inode_hasattr(ip))
138 */ 146 error = ENOATTR;
139 if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { 147 else if (ip->i_d.di_aformat == XFS_DINODE_FMT_LOCAL)
140 error = xfs_attr_shortform_getvalue(&args); 148 error = xfs_attr_shortform_getvalue(&args);
141 } else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK)) { 149 else if (xfs_bmap_one_block(ip, XFS_ATTR_FORK))
142 error = xfs_attr_leaf_get(&args); 150 error = xfs_attr_leaf_get(&args);
143 } else { 151 else
144 error = xfs_attr_node_get(&args); 152 error = xfs_attr_node_get(&args);
145 } 153 xfs_iunlock(ip, lock_mode);
146 154
147 /*
148 * Return the number of bytes in the value to the caller.
149 */
150 *valuelenp = args.valuelen; 155 *valuelenp = args.valuelen;
151 156 return error == EEXIST ? 0 : error;
152 if (error == EEXIST)
153 error = 0;
154 return(error);
155}
156
157int
158xfs_attr_get(
159 xfs_inode_t *ip,
160 const unsigned char *name,
161 unsigned char *value,
162 int *valuelenp,
163 int flags)
164{
165 int error;
166 struct xfs_name xname;
167 uint lock_mode;
168
169 XFS_STATS_INC(xs_attr_get);
170
171 if (XFS_FORCED_SHUTDOWN(ip->i_mount))
172 return(EIO);
173
174 error = xfs_attr_name_to_xname(&xname, name);
175 if (error)
176 return error;
177
178 lock_mode = xfs_ilock_attr_map_shared(ip);
179 error = xfs_attr_get_int(ip, &xname, value, valuelenp, flags);
180 xfs_iunlock(ip, lock_mode);
181 return(error);
182} 157}
183 158
184/* 159/*