From dfedfec3593ca0fc026d8a094916824e1b90e60b Mon Sep 17 00:00:00 2001 From: Anand Avati Date: Mon, 22 Jul 2013 10:02:34 -0700 Subject: gfapi: perform open() on pre-existing inode in glfs_creat() Performing syncop_create() on a pre-existing file can result in opening the linkfile if DHT has a linkfile for the file. This is because dht_create() will perform the op on the hashed_subvol() and overwrite the layout in dht_create_cbk. Change-Id: I7a0db56921ec9fc3e278e0418db3b967f81e5598 BUG: 990410 Signed-off-by: Anand Avati Reviewed-on: http://review.gluster.org/5447 Reviewed-by: Raghavendra Talur Tested-by: Raghavendra Talur Tested-by: Gluster Build System --- api/src/glfs-fops.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'api') diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c index 0e4acb76..605913ae 100644 --- a/api/src/glfs-fops.c +++ b/api/src/glfs-fops.c @@ -388,8 +388,12 @@ retry: goto out; } - ret = syncop_create (subvol, &loc, flags, mode, glfd->fd, - xattr_req, &iatt); + if (ret == 0) { + ret = syncop_open (subvol, &loc, flags, glfd->fd); + } else { + ret = syncop_create (subvol, &loc, flags, mode, glfd->fd, + xattr_req, &iatt); + } ESTALE_RETRY (ret, errno, reval, &loc, retry); @@ -404,7 +408,7 @@ out: if (ret && glfd) { glfs_fd_destroy (glfd); glfd = NULL; - } else { + } else if (glfd) { fd_bind (glfd->fd); glfs_fd_bind (glfd); } -- cgit