Nice :) Do mention your script in the upstream doc here:
https://github.com/gluster/glusterfs/blob/master/doc/debugging/gfid-to-path.md

Regards,
 -Prashanth Pai

----- Original Message -----
From: "Aravinda" <avish...@redhat.com>
To: "Gluster Devel" <gluster-devel@gluster.org>
Sent: Monday, February 2, 2015 5:20:56 PM
Subject: [Gluster-devel] GFID to Path Conversion if Historical Changelogs       
available

Hi,

While discussing about the possible options to convert from GFID to 
path, Venky suggested to search in Historical GlusterFS Changelogs and 
get the information about Parent GFID and basename of the file. This 
method works well for FOPs except Rename and Hard links.

Approach:
---------
Will consider b67b95a4-8bdc-44d5-aedd-b9b66fb0af95 as GFID for all 
illustrations and file name as file1

1. If .glusterfs/b6/7b/b67b95a4-8bdc-44d5-aedd-b9b66fb0af95 is Symlink, 
Readlink and Convert to relative path and Print(Easy conversion, done :))
2. If not Symlink, Stat on file 
.glusterfs/b6/7b/b67b95a4-8bdc-44d5-aedd-b9b66fb0af95 and get 
st_ctime(For example ctime is 1422694569)
3. Search for CHANGELOG.1422694565, CHANGELOG.1422694566.. 
CHANGELOG.1422694590. Break when you get actual Changelog file, else 
break after MAX try.
4. If we didn't get valid Changelog file for that GFID, log GFID in stderr.
5. If Changelog file is available, Search in Changelog file for the 
ENTRY pattern. If found extract Parent GFID and basename. Convert Parent 
GFID to Path using readlink and add basename.
6. Get xattr trusted.gfid on the path we got and compare with input 
GFID. If both are same then we are Good, else log in stderr. (File may 
be changed after Create, may be Rename)
7. Collect all GFIDs from stderr and convert to Path using find . 
-samefile <GFID FILE>

I created a Script using Python to find Path from GFID. Works really 
well if Changelog is enabled before file/dir Creation.

https://github.com/aravindavk/gfid_to_path

Usage:
------
Download the Python Script(gfid_to_path) from 
https://github.com/aravindavk/gfid_to_path and place it in any bin 
directory which is available in PATH

     chmod +x /usr/local/bin/gfid_to_path

To convert single GFID to Path
------------------------------
     echo <GFID> | gfid_to_path <BRICK_PATH>

     echo b67b95a4-8bdc-44d5-aedd-b9b66fb0af95 | gfid_to_path 
/exports/bricks/b1

To convert list of GFIDs into Path,
----------------------------------
     gfid_to_path <BRICK_PATH> <GFIDS LIST FILE>

     gfid_to_path /exports/bricks/b1 ~/collected_gfids.txt

To record Converted paths in ~/good.txt and failures in ~/bad.txt
-----------------------------------------------------------------
     gfid_to_path <BRICK_PATH> <GFIDS LIST FILE> 1> GOOD_FILE 2> BAD_FILE

     gfid_to_path /exports/bricks/b1 ~/collected_gfids.txt 1> ~/good.txt 
2> ~/bad.txt


Source is available in Github.
     git clone https://github.com/aravindavk/gfid_to_path.git

C & S Welcome.

--
regards
Aravinda
http://aravindavk.in
_______________________________________________
Gluster-devel mailing list
Gluster-devel@gluster.org
http://www.gluster.org/mailman/listinfo/gluster-devel
_______________________________________________
Gluster-devel mailing list
Gluster-devel@gluster.org
http://www.gluster.org/mailman/listinfo/gluster-devel

Reply via email to