summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKinglong Mee <mijinlong@open-fs.com>2017-11-07 22:21:22 -0500
committerAmar Tumballi <amarts@redhat.com>2017-11-28 22:33:53 +0000
commit718e2f2c6cf1f5e8fe8b299f686153495e7e784c (patch)
tree2a893c9a71167ea680fd89fba4b9cc194aad1677
parent858fae39936e5aee5ea4e3816a10ba310d04cf61 (diff)
gfapi: avoid nameless lookup when inode_find success
Ganesha calls pub_glfs_h_create_from_handle always with stat != NULL, for inode_find success, a nameless lookup seems unnecessary. Change-Id: I1242deefe8ff4af15a98cc3af7824233e24d62ad Signed-off-by: Kinglong Mee <mijinlong@open-fs.com>
-rw-r--r--api/src/glfs-handleops.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c
index 2693c2de306..0151289ab26 100644
--- a/api/src/glfs-handleops.c
+++ b/api/src/glfs-handleops.c
@@ -1270,6 +1270,7 @@ pub_glfs_h_create_from_handle (struct glfs *fs, unsigned char *handle, int len,
xlator_t *subvol = NULL;
struct glfs_object *object = NULL;
uint64_t ctx_value = LOOKUP_NOT_NEEDED;
+ gf_boolean_t lookup_needed = _gf_false;
/* validate in args */
if ((fs == NULL) || (handle == NULL) || (len != GFAPI_HANDLE_LENGTH)) {
@@ -1295,10 +1296,29 @@ pub_glfs_h_create_from_handle (struct glfs *fs, unsigned char *handle, int len,
newinode = inode_find (subvol->itable, loc.gfid);
if (newinode) {
- if (!stat) /* No need of lookup */
+ lookup_needed = inode_needs_lookup (newinode, THIS);
+ if (lookup_needed) {
+ loc.inode = newinode;
+ } else if (!stat) {
goto found;
+ } else {
+ /* populate loc */
+ GLFS_LOC_FILL_INODE (newinode, loc, fill_out);
+
+ /* fop/op */
+ ret = syncop_stat (subvol, &loc, &iatt, NULL, NULL);
+ DECODE_SYNCOP_ERR (ret);
+
+ if (ret) {
+fill_out:
+ /* Drop the reference hold in inode_find */
+ inode_unref (newinode);
+ goto out;
+ }
- loc.inode = newinode;
+ glfs_iatt_to_stat (fs, &iatt, stat);
+ goto found;
+ }
} else {
loc.inode = inode_new (subvol->itable);
if (!loc.inode) {