gfapi: Fix in glfs_h_create_from_handle
While constructing glfs_object from the handle given, incase if inode is found in the inode table, we need not do "syncop_lookup" unless we need to return the inode attributes. BUG: 1200262 Change-Id: I4682d9e4420a0bcb1b3e807b801ccb3d8de3d2cd Signed-off-by: Soumya Koduri <skoduri@redhat.com> Reviewed-on: http://review.gluster.org/10232 Tested-by: NetBSD Build System Reviewed-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
parent
aa87c31d8d
commit
b464723a48
@ -1145,9 +1145,12 @@ pub_glfs_h_create_from_handle (struct glfs *fs, unsigned char *handle, int len,
|
||||
memcpy (loc.gfid, handle, GFAPI_HANDLE_LENGTH);
|
||||
|
||||
newinode = inode_find (subvol->itable, loc.gfid);
|
||||
if (newinode)
|
||||
if (newinode) {
|
||||
if (!stat) /* No need of lookup */
|
||||
goto found;
|
||||
|
||||
loc.inode = newinode;
|
||||
else {
|
||||
} else {
|
||||
loc.inode = inode_new (subvol->itable);
|
||||
if (!loc.inode) {
|
||||
errno = ENOMEM;
|
||||
@ -1179,6 +1182,7 @@ pub_glfs_h_create_from_handle (struct glfs *fs, unsigned char *handle, int len,
|
||||
if (stat)
|
||||
glfs_iatt_to_stat (fs, &iatt, stat);
|
||||
|
||||
found:
|
||||
object = GF_CALLOC (1, sizeof(struct glfs_object),
|
||||
glfs_mt_glfs_object_t);
|
||||
if (object == NULL) {
|
||||
@ -1693,7 +1697,7 @@ pub_glfs_h_poll_upcall (struct glfs *fs, struct callback_arg *up_arg)
|
||||
if (found) {
|
||||
object = glfs_h_create_from_handle (fs, gfid,
|
||||
GFAPI_HANDLE_LENGTH,
|
||||
&up_arg->buf);
|
||||
NULL);
|
||||
|
||||
if (!object) {
|
||||
errno = ENOMEM;
|
||||
|
@ -215,6 +215,9 @@ ssize_t glfs_h_extract_handle (struct glfs_object *object,
|
||||
unsigned char *handle, int len) __THROW
|
||||
GFAPI_PUBLIC(glfs_h_extract_handle, 3.4.0);
|
||||
|
||||
/* Given a handle, looks up the inode and creates glfs_object.
|
||||
* In addition, if provided 'stat', copies the inode attributes
|
||||
*/
|
||||
struct glfs_object *glfs_h_create_from_handle (struct glfs *fs,
|
||||
unsigned char *handle, int len,
|
||||
struct stat *stat) __THROW
|
||||
|
Loading…
x
Reference in New Issue
Block a user