summaryrefslogtreecommitdiffstats
path: root/xlators/features/snapview-server/src/snapview-server-helpers.c
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2016-02-10 06:39:22 +0530
committerRajesh Joseph <rjoseph@redhat.com>2016-03-23 04:03:52 -0700
commited4feadc8c60fce1d8d99e0732351b92230d6321 (patch)
treea075150b6867a32c702939bb08728ca878fa0d48 /xlators/features/snapview-server/src/snapview-server-helpers.c
parentf5f43424994859f263165f0cdebedffd5f08fdcc (diff)
uss/gluster: generate gfid for snapshot files from snapname and gfid
This is a backport of http://review.gluster.org/#/c/9255/ If 'a' and 'b' are hardlinks, we need to generate a virtual gfid for these files so that the inode number for 'a' and 'b' are same. Generate gfid as below: gfid_of_a = MD5(snapname + back_end_gfid(a)) if '/dir1/a' and '/dir2/b' are hardlinks, then inode number should be same for all below files: /mnt/.snaps/snap1/dir1/a /mnt/.snaps/snap1/dir2/b /mnt/dir1/.snaps/snap1/a /mnt/dir2/.snaps/snap1/b > Change-Id: Ifda793455610e554f3f1e4cbb90d44c02cda4b0f > BUG: 1171703 > Signed-off-by: vmallika <vmallika@redhat.com> Change-Id: I917b2fe2915d88f69700bc8c3283e9c613e13bb8 BUG: 1316099 Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/13656 Smoke: Gluster Build System <jenkins@build.gluster.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Rajesh Joseph <rjoseph@redhat.com>
Diffstat (limited to 'xlators/features/snapview-server/src/snapview-server-helpers.c')
-rw-r--r--xlators/features/snapview-server/src/snapview-server-helpers.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/xlators/features/snapview-server/src/snapview-server-helpers.c b/xlators/features/snapview-server/src/snapview-server-helpers.c
index 92ffdf512ef..0303f4d6df6 100644
--- a/xlators/features/snapview-server/src/snapview-server-helpers.c
+++ b/xlators/features/snapview-server/src/snapview-server-helpers.c
@@ -335,6 +335,21 @@ out:
}
void
+svs_uuid_generate (uuid_t gfid, char *snapname, uuid_t origin_gfid)
+{
+ unsigned char md5_sum[MD5_DIGEST_LENGTH] = {0};
+ char ino_string[NAME_MAX + 32] = "";
+ int ret = 0;
+
+ GF_ASSERT (snapname);
+
+ ret = snprintf (ino_string, sizeof (ino_string), "%s%s",
+ snapname, uuid_utoa(origin_gfid));
+ MD5((unsigned char *)ino_string, strlen(ino_string), md5_sum);
+ gf_uuid_copy (gfid, md5_sum);
+}
+
+void
svs_fill_ino_from_gfid (struct iatt *buf)
{
uint64_t temp_ino = 0;