From: Christoph Hellwig <hch@lst.de>
To: xfs@oss.sgi.com
Subject: [PATCH 4/5] xfs: simplify attr name setup
Date: Sat, 3 May 2014 17:20:14 +0200 [thread overview]
Message-ID: <1399130415-5382-5-git-send-email-hch@lst.de> (raw)
In-Reply-To: <1399130415-5382-1-git-send-email-hch@lst.de>
Replace xfs_attr_name_to_xname with a new xfs_attr_args_init helper that
sets up the basic da_args structure without using a temporary xfs_name
structure.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/xfs_attr.c | 74 +++++++++++++++++++++--------------------------------
1 file changed, 29 insertions(+), 45 deletions(-)
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index a96e27b..1208621 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -77,17 +77,26 @@ STATIC int xfs_attr_refillstate(xfs_da_state_t *state);
STATIC int
-xfs_attr_name_to_xname(
- struct xfs_name *xname,
- const unsigned char *aname)
+xfs_attr_args_init(
+ struct xfs_da_args *args,
+ struct xfs_inode *dp,
+ const unsigned char *name,
+ int flags)
{
- if (!aname)
+
+ if (!name)
return EINVAL;
- xname->name = aname;
- xname->len = strlen((char *)aname);
- if (xname->len >= MAXNAMELEN)
+
+ memset(args, 0, sizeof(*args));
+ args->whichfork = XFS_ATTR_FORK;
+ args->dp = dp;
+ args->flags = flags;
+ args->name = name;
+ args->namelen = strlen((const char *)name);
+ if (args->namelen >= MAXNAMELEN)
return EFAULT; /* match IRIX behaviour */
+ args->hashval = xfs_da_hashname(args->name, args->namelen);
return 0;
}
@@ -115,7 +124,6 @@ xfs_attr_get(
int flags)
{
struct xfs_da_args args;
- struct xfs_name xname;
uint lock_mode;
int error;
@@ -127,19 +135,12 @@ xfs_attr_get(
if (!xfs_inode_hasattr(ip))
return ENOATTR;
- error = xfs_attr_name_to_xname(&xname, name);
+ error = xfs_attr_args_init(&args, ip, name, flags);
if (error)
return error;
- memset(&args, 0, sizeof(args));
- args.name = xname.name;
- args.namelen = xname.len;
args.value = value;
args.valuelen = *valuelenp;
- args.flags = flags;
- args.hashval = xfs_da_hashname(args.name, args.namelen);
- args.dp = ip;
- args.whichfork = XFS_ATTR_FORK;
lock_mode = xfs_ilock_attr_map_shared(ip);
if (!xfs_inode_hasattr(ip))
@@ -208,7 +209,6 @@ xfs_attr_set(
struct xfs_da_args args;
struct xfs_bmap_free flist;
struct xfs_trans_res tres;
- struct xfs_name xname;
xfs_fsblock_t firstblock;
int rsvd = (flags & ATTR_ROOT) != 0;
int error, err2, committed, local;
@@ -218,10 +218,19 @@ xfs_attr_set(
if (XFS_FORCED_SHUTDOWN(dp->i_mount))
return EIO;
- error = xfs_attr_name_to_xname(&xname, name);
+ error = xfs_attr_args_init(&args, dp, name, flags);
if (error)
return error;
+ args.value = value;
+ args.valuelen = valuelen;
+ args.firstblock = &firstblock;
+ args.flist = &flist;
+ args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
+
+ /* Size is now blocks for attribute data */
+ args.total = xfs_attr_calc_size(dp, args.namelen, valuelen, &local);
+
error = xfs_qm_dqattach(dp, 0);
if (error)
return error;
@@ -232,29 +241,13 @@ xfs_attr_set(
*/
if (XFS_IFORK_Q(dp) == 0) {
int sf_size = sizeof(xfs_attr_sf_hdr_t) +
- XFS_ATTR_SF_ENTSIZE_BYNAME(xname.len, valuelen);
+ XFS_ATTR_SF_ENTSIZE_BYNAME(args.namelen, valuelen);
error = xfs_bmap_add_attrfork(dp, sf_size, rsvd);
if (error)
return error;
}
- memset(&args, 0, sizeof(args));
- args.name = xname.name;
- args.namelen = xname.len;
- args.value = value;
- args.valuelen = valuelen;
- args.flags = flags;
- args.hashval = xfs_da_hashname(args.name, args.namelen);
- args.dp = dp;
- args.firstblock = &firstblock;
- args.flist = &flist;
- args.whichfork = XFS_ATTR_FORK;
- args.op_flags = XFS_DA_OP_ADDNAME | XFS_DA_OP_OKNOENT;
-
- /* Size is now blocks for attribute data */
- args.total = xfs_attr_calc_size(dp, xname.len, valuelen, &local);
-
/*
* Start our first transaction of the day.
*
@@ -425,7 +418,6 @@ xfs_attr_remove(
struct xfs_mount *mp = dp->i_mount;
struct xfs_da_args args;
struct xfs_bmap_free flist;
- struct xfs_name xname;
xfs_fsblock_t firstblock;
int error;
@@ -437,20 +429,12 @@ xfs_attr_remove(
if (!xfs_inode_hasattr(dp))
return ENOATTR;
- error = xfs_attr_name_to_xname(&xname, name);
+ error = xfs_attr_args_init(&args, dp, name, flags);
if (error)
return error;
- memset(&args, 0, sizeof(args));
- args.name = xname.name;
- args.namelen = xname.len;
- args.flags = flags;
- args.hashval = xfs_da_hashname(args.name, args.namelen);
- args.dp = dp;
args.firstblock = &firstblock;
args.flist = &flist;
- args.total = 0;
- args.whichfork = XFS_ATTR_FORK;
/*
* we have no control over the attribute names that userspace passes us
--
1.7.10.4
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2014-05-03 15:18 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-03 15:20 attr cleanups Christoph Hellwig
2014-05-03 15:20 ` [PATCH 1/5] xfs: fold xfs_attr_set_int into xfs_attr_set Christoph Hellwig
2014-05-05 20:21 ` Brian Foster
2014-05-03 15:20 ` [PATCH 2/5] xfs: fold xfs_attr_get_int into xfs_attr_get Christoph Hellwig
2014-05-05 20:21 ` Brian Foster
2014-05-03 15:20 ` [PATCH 3/5] xfs: fold xfs_attr_remove_int into xfs_attr_remove Christoph Hellwig
2014-05-05 20:21 ` Brian Foster
2014-05-05 20:56 ` Dave Chinner
2014-05-05 21:08 ` Brian Foster
2014-05-03 15:20 ` Christoph Hellwig [this message]
2014-05-05 20:21 ` [PATCH 4/5] xfs: simplify attr name setup Brian Foster
2014-05-03 15:20 ` [PATCH 5/5] xfs: pass struct da_args to xfs_attr_calc_size Christoph Hellwig
2014-05-05 20:21 ` Brian Foster
2014-05-06 8:06 ` [PATCH 5/5 v2] " Christoph Hellwig
2014-05-06 9:09 ` Dave Chinner
2014-05-03 16:04 ` attr cleanups Mark Tinguely
2014-05-04 10:16 ` Christoph Hellwig
2014-05-04 21:52 ` Dave Chinner
2014-05-05 13:24 ` Mark Tinguely
2014-05-05 20:55 ` Dave Chinner
2014-05-06 19:40 ` Mark Tinguely
2014-05-06 20:51 ` Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399130415-5382-5-git-send-email-hch@lst.de \
--to=hch@lst.de \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).