diff options
author | Niels de Vos <ndevos@redhat.com> | 2015-02-27 15:30:04 +0100 |
---|---|---|
committer | Niels de Vos <ndevos@redhat.com> | 2015-02-28 09:30:03 -0800 |
commit | 32dd227726ce60b2e60b8df61ca174d96a1b8b34 (patch) | |
tree | bd50617f0a1a689ab01dffeec613701c58e7fe28 /xlators/nfs | |
parent | 5b4755e9494b80f7b57c1515773991c962af0a2a (diff) |
nfs: nfs3_stat_to_fattr3() improvement
During a review of backorti http://review.gluster.org/9170, Kaleb points
out:
ick, return-by-value. About 50% slower than passing a pointer to the
target struct.
Change-Id: I4464e6a4e50d82d446a834892d0308332b7c32d0
BUG: 1197142
Reported-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: http://review.gluster.org/9772
Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/nfs')
-rw-r--r-- | xlators/nfs/server/src/acl3.c | 6 | ||||
-rw-r--r-- | xlators/nfs/server/src/nfs3-helpers.c | 92 |
2 files changed, 47 insertions, 51 deletions
diff --git a/xlators/nfs/server/src/acl3.c b/xlators/nfs/server/src/acl3.c index b00e8170ebd..b1e5d95d087 100644 --- a/xlators/nfs/server/src/acl3.c +++ b/xlators/nfs/server/src/acl3.c @@ -49,8 +49,8 @@ nfs3_call_state_init (struct nfs3_state *s, rpcsvc_request_t *req, xlator_t *v); extern int nfs3_fh_validate (struct nfs3_fh *fh); -extern fattr3 -nfs3_stat_to_fattr3 (struct iatt *buf); +extern void +nfs3_stat_to_fattr3 (struct iatt *buf, fattr3 *fa); #define acl3_validate_nfs3_state(request, state, status, label, retval) \ do { \ @@ -409,7 +409,7 @@ acl3_stat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, getaclreply->attr_follows = TRUE; deviceid = nfs3_request_xlator_deviceid (cs->req); nfs3_map_deviceid_to_statdev (buf, deviceid); - getaclreply->attr = nfs3_stat_to_fattr3 (buf); + nfs3_stat_to_fattr3 (buf, &(getaclreply->attr)); nfs_request_user_init (&nfu, cs->req); if (buf->ia_type == IA_IFDIR) { diff --git a/xlators/nfs/server/src/nfs3-helpers.c b/xlators/nfs/server/src/nfs3-helpers.c index cba127b41da..f6c6eb52ad0 100644 --- a/xlators/nfs/server/src/nfs3-helpers.c +++ b/xlators/nfs/server/src/nfs3-helpers.c @@ -284,85 +284,82 @@ nfs3_fill_lookup3res_error (lookup3res *res, nfsstat3 stat, } -fattr3 -nfs3_stat_to_fattr3 (struct iatt *buf) +void +nfs3_stat_to_fattr3 (struct iatt *buf, fattr3 *fa) { - fattr3 fa = {0, }; - - if (buf == NULL) - goto out; + if (buf == NULL || fa == NULL) { + errno = EINVAL; + return; + } if (IA_ISDIR (buf->ia_type)) - fa.type = NF3DIR; + fa->type = NF3DIR; else if (IA_ISREG (buf->ia_type)) - fa.type = NF3REG; + fa->type = NF3REG; else if (IA_ISCHR (buf->ia_type)) - fa.type = NF3CHR; + fa->type = NF3CHR; else if (IA_ISBLK (buf->ia_type)) - fa.type = NF3BLK; + fa->type = NF3BLK; else if (IA_ISFIFO (buf->ia_type)) - fa.type = NF3FIFO; + fa->type = NF3FIFO; else if (IA_ISLNK (buf->ia_type)) - fa.type = NF3LNK; + fa->type = NF3LNK; else if (IA_ISSOCK (buf->ia_type)) - fa.type = NF3SOCK; + fa->type = NF3SOCK; if (IA_PROT_RUSR (buf->ia_prot)) - fa.mode |= NFS3MODE_ROWNER; + fa->mode |= NFS3MODE_ROWNER; if (IA_PROT_WUSR (buf->ia_prot)) - fa.mode |= NFS3MODE_WOWNER; + fa->mode |= NFS3MODE_WOWNER; if (IA_PROT_XUSR (buf->ia_prot)) - fa.mode |= NFS3MODE_XOWNER; + fa->mode |= NFS3MODE_XOWNER; if (IA_PROT_RGRP (buf->ia_prot)) - fa.mode |= NFS3MODE_RGROUP; + fa->mode |= NFS3MODE_RGROUP; if (IA_PROT_WGRP (buf->ia_prot)) - fa.mode |= NFS3MODE_WGROUP; + fa->mode |= NFS3MODE_WGROUP; if (IA_PROT_XGRP (buf->ia_prot)) - fa.mode |= NFS3MODE_XGROUP; + fa->mode |= NFS3MODE_XGROUP; if (IA_PROT_ROTH (buf->ia_prot)) - fa.mode |= NFS3MODE_ROTHER; + fa->mode |= NFS3MODE_ROTHER; if (IA_PROT_WOTH (buf->ia_prot)) - fa.mode |= NFS3MODE_WOTHER; + fa->mode |= NFS3MODE_WOTHER; if (IA_PROT_XOTH (buf->ia_prot)) - fa.mode |= NFS3MODE_XOTHER; + fa->mode |= NFS3MODE_XOTHER; if (IA_PROT_SUID (buf->ia_prot)) - fa.mode |= NFS3MODE_SETXUID; + fa->mode |= NFS3MODE_SETXUID; if (IA_PROT_SGID (buf->ia_prot)) - fa.mode |= NFS3MODE_SETXGID; + fa->mode |= NFS3MODE_SETXGID; if (IA_PROT_STCKY (buf->ia_prot)) - fa.mode |= NFS3MODE_SAVESWAPTXT; + fa->mode |= NFS3MODE_SAVESWAPTXT; - fa.nlink = buf->ia_nlink; - fa.uid = buf->ia_uid; - fa.gid = buf->ia_gid; - fa.size = buf->ia_size; - fa.used = (buf->ia_blocks * 512); + fa->nlink = buf->ia_nlink; + fa->uid = buf->ia_uid; + fa->gid = buf->ia_gid; + fa->size = buf->ia_size; + fa->used = (buf->ia_blocks * 512); if ((IA_ISCHR (buf->ia_type) || IA_ISBLK (buf->ia_type))) { - fa.rdev.specdata1 = ia_major (buf->ia_rdev); - fa.rdev.specdata2 = ia_minor (buf->ia_rdev); + fa->rdev.specdata1 = ia_major (buf->ia_rdev); + fa->rdev.specdata2 = ia_minor (buf->ia_rdev); } else { - fa.rdev.specdata1 = 0; - fa.rdev.specdata2 = 0; + fa->rdev.specdata1 = 0; + fa->rdev.specdata2 = 0; } - fa.fsid = buf->ia_dev; - fa.fileid = nfs3_iatt_gfid_to_ino (buf); - - fa.atime.seconds = buf->ia_atime; - fa.atime.nseconds = buf->ia_atime_nsec; + fa->fsid = buf->ia_dev; + fa->fileid = nfs3_iatt_gfid_to_ino (buf); - fa.ctime.seconds = buf->ia_ctime; - fa.ctime.nseconds = buf->ia_ctime_nsec; + fa->atime.seconds = buf->ia_atime; + fa->atime.nseconds = buf->ia_atime_nsec; - fa.mtime.seconds = buf->ia_mtime; - fa.mtime.nseconds = buf->ia_mtime_nsec; + fa->ctime.seconds = buf->ia_ctime; + fa->ctime.nseconds = buf->ia_ctime_nsec; -out: - return fa; + fa->mtime.seconds = buf->ia_mtime; + fa->mtime.nseconds = buf->ia_mtime_nsec; } @@ -381,7 +378,7 @@ nfs3_stat_to_post_op_attr (struct iatt *buf) if (nfs_zero_filled_stat (buf)) goto out; - attr.post_op_attr_u.attributes = nfs3_stat_to_fattr3 (buf); + nfs3_stat_to_fattr3 (buf, &(attr.post_op_attr_u.attributes)); attr.attributes_follow = TRUE; out: @@ -472,8 +469,7 @@ nfs3_fill_getattr3res (getattr3res *res, nfsstat3 stat, struct iatt *buf, return; nfs3_map_deviceid_to_statdev (buf, deviceid); - res->getattr3res_u.resok.obj_attributes = nfs3_stat_to_fattr3 (buf); - + nfs3_stat_to_fattr3 (buf, &(res->getattr3res_u.resok.obj_attributes)); } |