From 2cd2532e149847771319ad56b8b745f0f38c0bd4 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/5884 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- api/src/glfs-fops.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/api/src/glfs-fops.c b/api/src/glfs-fops.c index dd9ea451a..1794e603f 100644 --- a/api/src/glfs-fops.c +++ b/api/src/glfs-fops.c @@ -394,8 +394,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); -- cgit