From f8bb9ac26aad8c0068bcc45a34ecb4a73cc06e7a Mon Sep 17 00:00:00 2001 From: Soumya Koduri Date: Wed, 22 Apr 2015 22:34:41 +0530 Subject: gfapi: Skip and delete the upcall entry if not found We could run into situations where in gfapi received a upcall notification for a file and the file may have got deleted by then. Hence, incase of error while trying to create handle from gfid, log it, delete the entry and return with CBK_NULL reason. Change-Id: I191f10f44d6804be07734a6be63a3ca08f455f0e BUG: 1213773 Signed-off-by: Soumya Koduri Reviewed-on: http://review.gluster.org/10341 Reviewed-by: Kaleb KEITHLEY Tested-by: Gluster Build System --- api/src/glfs-handleops.c | 52 +++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 20 deletions(-) (limited to 'api/src/glfs-handleops.c') diff --git a/api/src/glfs-handleops.c b/api/src/glfs-handleops.c index b3f65e05fef..c3ac789569d 100644 --- a/api/src/glfs-handleops.c +++ b/api/src/glfs-handleops.c @@ -1705,26 +1705,38 @@ pub_glfs_h_poll_upcall (struct glfs *fs, struct callback_arg *up_arg) NULL); if (!object) { - errno = ENOMEM; - goto out; - } - - upcall_data = &u_list->upcall_data; - - switch (upcall_data->event_type) { - case GF_UPCALL_CACHE_INVALIDATION: - /* XXX: Need to revisit this to support - * GFAPI_INODE_UPDATE if required. - */ - ca_data = upcall_data->data; - GF_VALIDATE_OR_GOTO ("glfs_h_poll_upcall", - ca_data, out); - reason = GFAPI_INODE_INVALIDATE; - up_arg->flags = ca_data->flags; - up_arg->expire_time_attr = ca_data->expire_time_attr; - break; - default: - break; + /* It could so happen that the file which got + * upcall notification may have got deleted + * by other thread. Irrespective of the error, + * log it and return with CBK_NULL reason. + * + * Applications will ignore this notification + * as up_arg->object will be NULL */ + gf_log (subvol->name, GF_LOG_WARNING, + "handle creation of %s failed: %s", + uuid_utoa (gfid), strerror (errno)); + + reason = GFAPI_CBK_EVENT_NULL; + } else { + + upcall_data = &u_list->upcall_data; + + switch (upcall_data->event_type) { + case GF_UPCALL_CACHE_INVALIDATION: + /* XXX: Need to revisit this to support + * GFAPI_INODE_UPDATE if required. + */ + ca_data = upcall_data->data; + GF_VALIDATE_OR_GOTO ("glfs_h_poll_upcall", + ca_data, out); + reason = GFAPI_INODE_INVALIDATE; + up_arg->flags = ca_data->flags; + up_arg->expire_time_attr = ca_data->expire_time_attr; + + break; + default: + break; + } } up_arg->object = object; -- cgit