summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-handle.c
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2012-02-15 17:20:40 +0530
committerAnand Avati <avati@redhat.com>2012-02-16 22:48:57 -0800
commit47e748fe60c46d543c87f3228eb59d6580db8cf1 (patch)
treef5b244d4e1e0f5fd595e3235985b7bc921c8f330 /xlators/storage/posix/src/posix-handle.c
parent4cc4e47f6cad1127ad425cc0ab10bc42ab1411c8 (diff)
posix: handle some internal behavior in posix_mknod()
assume a case of link() systemcall, which is handled in distribute by creating a 'linkfile' in hashed subvolume, if the 'oldloc' is present in different subvolume. we have same 'gfid' for the linkfile as that of file for consistency. Now, a file with multiple hardlinks, we may end up with 'hardlinked' linkfiles. dht create linkfile using 'mknod()' fop, and as now posix_mknod() is not equipped to handle this situation. this patch fixes the situation by looking at the 'internal' key set in the dictionary to differentiate the call which originates from inside with regular system calls. Change-Id: Ibff7c31f8e0c8bdae035c705c93a295f080ff985 BUG: 763844 Signed-off-by: Amar Tumballi <amar@gluster.com> Reviewed-on: http://review.gluster.com/2755 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-handle.c')
-rw-r--r--xlators/storage/posix/src/posix-handle.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/xlators/storage/posix/src/posix-handle.c b/xlators/storage/posix/src/posix-handle.c
index b0693324d32..9b6df445ed5 100644
--- a/xlators/storage/posix/src/posix-handle.c
+++ b/xlators/storage/posix/src/posix-handle.c
@@ -619,3 +619,20 @@ posix_handle_unset (xlator_t *this, uuid_t gfid, const char *basename)
return ret;
}
+
+int
+posix_create_link_if_gfid_exists (xlator_t *this, uuid_t gfid,
+ char *real_path)
+{
+ int ret = -1;
+ struct stat stbuf = {0,};
+ char *newpath = NULL;
+
+ MAKE_HANDLE_PATH (newpath, this, gfid, NULL);
+ ret = lstat (newpath, &stbuf);
+ if (!ret) {
+ ret = link (newpath, real_path);
+ }
+
+ return ret;
+}