|
|
cb8e9e |
From 2a4e3b9ca03e5d751ce51549408c774e71defcb6 Mon Sep 17 00:00:00 2001
|
|
|
cb8e9e |
From: Milind Changire <mchangir@redhat.com>
|
|
|
cb8e9e |
Date: Fri, 3 Jul 2015 12:02:11 +0530
|
|
|
cb8e9e |
Subject: [PATCH 202/212] tools/glusterfind: RENAME and MODIFY issues
|
|
|
cb8e9e |
|
|
|
cb8e9e |
If Modification happens before RENAME, GFID to Path Conversion
|
|
|
cb8e9e |
converts it into New Path. Delete Modify Entry and insert again
|
|
|
cb8e9e |
So that MODIFY <NEW NAME> comes after RENAME.
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Default value of pgfids and basenames changed to "" instead of NULL
|
|
|
cb8e9e |
Also fixed RENAME issue of displaying "RENAME <NEW NAME> <NEW NAME>".
|
|
|
cb8e9e |
Also fixed RENAME followed by missing MODIFY
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Change-Id: Ie67219cc049a427e95ab6426bb890b02ffc1a853
|
|
|
cb8e9e |
BUG: 1228247
|
|
|
cb8e9e |
Reviewed-On: http://review.gluster.org/#/c/11443/
|
|
|
cb8e9e |
Signed-off-by: Milind Changire <mchangir@redhat.com>
|
|
|
cb8e9e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/52285
|
|
|
cb8e9e |
Reviewed-by: Kotresh Hiremath Ravishankar <khiremat@redhat.com>
|
|
|
cb8e9e |
Reviewed-by: Venky Shankar <vshankar@redhat.com>
|
|
|
cb8e9e |
Tested-by: Venky Shankar <vshankar@redhat.com>
|
|
|
cb8e9e |
---
|
|
|
cb8e9e |
tools/glusterfind/src/changelogdata.py | 39 +++++++++++++++++++++++---------
|
|
|
cb8e9e |
tools/glusterfind/src/main.py | 3 +-
|
|
|
cb8e9e |
2 files changed, 30 insertions(+), 12 deletions(-)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
diff --git a/tools/glusterfind/src/changelogdata.py b/tools/glusterfind/src/changelogdata.py
|
|
|
cb8e9e |
index c42aa2a..08d711b 100644
|
|
|
cb8e9e |
--- a/tools/glusterfind/src/changelogdata.py
|
|
|
cb8e9e |
+++ b/tools/glusterfind/src/changelogdata.py
|
|
|
cb8e9e |
@@ -100,10 +100,10 @@ class ChangelogData(object):
|
|
|
cb8e9e |
ts VARCHAR,
|
|
|
cb8e9e |
type VARCHAR,
|
|
|
cb8e9e |
gfid VARCHAR(40),
|
|
|
cb8e9e |
- pgfid1 VARCHAR(40),
|
|
|
cb8e9e |
- bn1 VARCHAR(500),
|
|
|
cb8e9e |
- pgfid2 VARCHAR(40),
|
|
|
cb8e9e |
- bn2 VARCHAR(500),
|
|
|
cb8e9e |
+ pgfid1 VARCHAR(40) DEFAULT '',
|
|
|
cb8e9e |
+ bn1 VARCHAR(500) DEFAULT '',
|
|
|
cb8e9e |
+ pgfid2 VARCHAR(40) DEFAULT '',
|
|
|
cb8e9e |
+ bn2 VARCHAR(500) DEFAULT '',
|
|
|
cb8e9e |
path1 VARCHAR DEFAULT '',
|
|
|
cb8e9e |
path2 VARCHAR DEFAULT ''
|
|
|
cb8e9e |
)
|
|
|
cb8e9e |
@@ -283,7 +283,7 @@ class ChangelogData(object):
|
|
|
cb8e9e |
|
|
|
cb8e9e |
def append_path1(self, path, inode):
|
|
|
cb8e9e |
# || is for concatenate in SQL
|
|
|
cb8e9e |
- query = """UPDATE gfidpath SET path1 = ',' || ?
|
|
|
cb8e9e |
+ query = """UPDATE gfidpath SET path1 = path1 || ',' || ?
|
|
|
cb8e9e |
WHERE gfid IN (SELECT gfid FROM inodegfid WHERE inode = ?)"""
|
|
|
cb8e9e |
self.cursor.execute(query, (path, inode))
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -344,16 +344,32 @@ class ChangelogData(object):
|
|
|
cb8e9e |
"pgfid1": pgfid1, "bn1": bn1})
|
|
|
cb8e9e |
elif self.gfidpath_exists({"gfid": data[1], "type": "RENAME",
|
|
|
cb8e9e |
"pgfid2": pgfid1, "bn2": bn1}):
|
|
|
cb8e9e |
- # If <OLD_PGFID>/<BNAME> is same as <PGFID2>/<BN2>(may be previous
|
|
|
cb8e9e |
- # RENAME) then UPDATE <NEW_PGFID>/<BNAME> as <PGFID2>/<BN2>
|
|
|
cb8e9e |
- self.gfidpath_update({"pgfid2": pgfid2, "bn2": bn2},
|
|
|
cb8e9e |
- {"gfid": data[1], "type": "RENAME",
|
|
|
cb8e9e |
- "pgfid2": pgfid1, "bn2": bn1})
|
|
|
cb8e9e |
+ # If we are renaming file back to original name then just
|
|
|
cb8e9e |
+ # delete the entry since it will effectively be a no-op
|
|
|
cb8e9e |
+ if self.gfidpath_exists({"gfid": data[1], "type": "RENAME",
|
|
|
cb8e9e |
+ "pgfid2": pgfid1, "bn2": bn1,
|
|
|
cb8e9e |
+ "pgfid1": pgfid2, "bn1": bn2}):
|
|
|
cb8e9e |
+ self.gfidpath_delete({"gfid": data[1], "type": "RENAME",
|
|
|
cb8e9e |
+ "pgfid2": pgfid1, "bn2": bn1})
|
|
|
cb8e9e |
+ else:
|
|
|
cb8e9e |
+ # If <OLD_PGFID>/<BNAME> is same as <PGFID2>/<BN2>
|
|
|
cb8e9e |
+ # (may be previous RENAME)
|
|
|
cb8e9e |
+ # then UPDATE <NEW_PGFID>/<BNAME> as <PGFID2>/<BN2>
|
|
|
cb8e9e |
+ self.gfidpath_update({"pgfid2": pgfid2, "bn2": bn2},
|
|
|
cb8e9e |
+ {"gfid": data[1], "type": "RENAME",
|
|
|
cb8e9e |
+ "pgfid2": pgfid1, "bn2": bn1})
|
|
|
cb8e9e |
else:
|
|
|
cb8e9e |
# Else insert as RENAME
|
|
|
cb8e9e |
self.gfidpath_add(changelogfile, RecordType.RENAME, data[1],
|
|
|
cb8e9e |
pgfid1, bn1, pgfid2, bn2)
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+ if self.gfidpath_exists({"gfid": data[1], "type": "MODIFY"}):
|
|
|
cb8e9e |
+ # If MODIFY exists already for that GFID, remove it and insert
|
|
|
cb8e9e |
+ # again so that MODIFY entry comes after RENAME entry
|
|
|
cb8e9e |
+ # Output will have MODIFY <NEWNAME>
|
|
|
cb8e9e |
+ self.gfidpath_delete({"gfid": data[1], "type": "MODIFY"})
|
|
|
cb8e9e |
+ self.gfidpath_add(changelogfile, RecordType.MODIFY, data[1])
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
def when_link_symlink(self, changelogfile, data):
|
|
|
cb8e9e |
# E <GFID> <LINK|SYMLINK> <PGFID>/<BASENAME>
|
|
|
cb8e9e |
# Add as New record in Db as Type NEW
|
|
|
cb8e9e |
@@ -366,7 +382,8 @@ class ChangelogData(object):
|
|
|
cb8e9e |
|
|
|
cb8e9e |
def when_data_meta(self, changelogfile, data):
|
|
|
cb8e9e |
# If GFID row exists, Ignore else Add to Db
|
|
|
cb8e9e |
- if not self.gfidpath_exists({"gfid": data[1]}):
|
|
|
cb8e9e |
+ if not self.gfidpath_exists({"gfid": data[1], "type": "NEW"}) and \
|
|
|
cb8e9e |
+ not self.gfidpath_exists({"gfid": data[1], "type": "MODIFY"}):
|
|
|
cb8e9e |
self.gfidpath_add(changelogfile, RecordType.MODIFY, data[1])
|
|
|
cb8e9e |
|
|
|
cb8e9e |
def when_unlink_rmdir(self, changelogfile, data):
|
|
|
cb8e9e |
diff --git a/tools/glusterfind/src/main.py b/tools/glusterfind/src/main.py
|
|
|
cb8e9e |
index 8d32295..9a6a2ac 100644
|
|
|
cb8e9e |
--- a/tools/glusterfind/src/main.py
|
|
|
cb8e9e |
+++ b/tools/glusterfind/src/main.py
|
|
|
cb8e9e |
@@ -433,7 +433,8 @@ def mode_pre(session_dir, args):
|
|
|
cb8e9e |
# Multiple paths in case of Hardlinks
|
|
|
cb8e9e |
paths = row[1].split(",")
|
|
|
cb8e9e |
for p in paths:
|
|
|
cb8e9e |
- if p == "":
|
|
|
cb8e9e |
+ if p == "" or p.replace("%2F%2F","%2F") == \
|
|
|
cb8e9e |
+ row[2].replace("%2F%2F","%2F"):
|
|
|
cb8e9e |
continue
|
|
|
cb8e9e |
f.write("%s %s %s\n" % (row[0], p, row[2]))
|
|
|
cb8e9e |
|
|
|
cb8e9e |
--
|
|
|
cb8e9e |
1.7.1
|
|
|
cb8e9e |
|