From 7a9a66cc5fb7f06118fab1fc2ae1c43cfbb1178f Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Thu, 29 Jan 2015 15:53:19 +0530 Subject: tools: Finds missing files in gluster volume given backend brickpath The tool finds the missing files in a geo-replication slave volume. The tool crawls backend .glusterfs of the brickpath, which is passed as a parameter and stats each entry on slave volume mount to check the presence of file. The mount used is aux-gfid-mount, hence no path conversion is required and is fast. The tool needs to be run on every node in cluster for each brickpath of geo-rep master volume to find missing files on slave volume. The tool is generic enough and can be used in non geo-replication context as well. Most of the crawler code is leverged from Avati's xfind and is modified to crawl only .glusterfs (https://github.com/avati/xsync) Thanks Aravinda for scripts to convert gfid to path. Change-Id: I84deaaaf638f7c571ff1319b67a3440fe27da810 BUG: 1187140 Signed-off-by: Aravinda VK Signed-off-by: Kotresh HR Reviewed-on: http://review.gluster.org/9503 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- tools/gfind_missing_files/gfid_to_path.sh | 42 +++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 tools/gfind_missing_files/gfid_to_path.sh (limited to 'tools/gfind_missing_files/gfid_to_path.sh') diff --git a/tools/gfind_missing_files/gfid_to_path.sh b/tools/gfind_missing_files/gfid_to_path.sh new file mode 100644 index 00000000000..20ac6a94fd2 --- /dev/null +++ b/tools/gfind_missing_files/gfid_to_path.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +## Copyright (c) 2015 Red Hat, Inc. +## This file is part of GlusterFS. +## +## This file is licensed to you under your choice of the GNU Lesser +## General Public License, version 3 or any later version (LGPLv3 or +## later), or the GNU General Public License, version 2 (GPLv2), in all +## cases as published by the Free Software Foundation. + +E_BADARGS=65 + + +function gfid_to_path() +{ + brick_dir=$1; + gfid_file=$(readlink -e $2); + + current_dir=$(pwd); + cd $brick_dir; + + while read gfid + do + to_search=`echo .glusterfs/${gfid:0:2}"/"${gfid:2:2}"/"$gfid`; + find . -samefile $to_search | grep -v $to_search; + done < $gfid_file; + + cd $current_dir; +} + + +function main(){ + if [ $# -ne 2 ] + then + echo "Usage: `basename $0` BRICK_DIR GFID_FILE"; + exit $E_BADARGS; + fi + + gfid_to_path $1 $2; +} + +main "$@"; -- cgit