geo-rep: Add support for xattrs

This patch adds support for xattrs. When it sees SETXATTR
in Changelog, it adds the file to data queue. rsync/tar+ssh
will take care of syncing xattrs. User set xattrs will be
synced to Slave.

New config interface is introduced, sync-xattrs
Which can be set using geo-rep config(Default is True)

gluster volume geo-replication <VOLUME> <SLAVEHOST>::<SLAVEVOL> \
               config sync-xattrs false

Change-Id: I70626d854a0d616469dd54d61e5ef155ed8b67d8
BUG: 1196690
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: http://review.gluster.org/9499
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kotresh HR <khiremat@redhat.com>
Reviewed-by: Saravanakumar Arumugam <sarumuga@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
This commit is contained in:
Aravinda VK 2015-01-28 17:19:42 +05:30 committed by Vijay Bellur
parent c3e6d6b547
commit 1455ee4003
3 changed files with 13 additions and 3 deletions

View File

@ -231,6 +231,7 @@ def main_i():
op.add_option('--ignore-deletes', default=False, action='store_true')
op.add_option('--isolated-slave', default=False, action='store_true')
op.add_option('--use-rsync-xattrs', default=False, action='store_true')
op.add_option('--sync-xattrs', default=True, action='store_true')
op.add_option('--pause-on-start', default=False, action='store_true')
op.add_option('-L', '--log-level', metavar='LVL')
op.add_option('-r', '--remote-gsyncd', metavar='CMD',

View File

@ -971,6 +971,11 @@ class GMasterChangelogMixin(GMasterCommon):
st_mtime=ec[6])))
else:
meta_gfid.add((os.path.join(pfx, ec[0]), ))
elif ec[1] == 'SETXATTR':
# To sync xattr use rsync/tar, --xattrs switch
# to rsync and tar
if boolify(gconf.sync_xattrs):
datas.add(os.path.join(pfx, ec[0]))
else:
logging.warn('got invalid changelog type: %s' % (et))
logging.debug('entries: %s' % repr(entries))

View File

@ -830,7 +830,7 @@ class SlaveRemote(object):
['-avR0', '--inplace', '--files-from=-', '--super',
'--stats', '--numeric-ids', '--no-implied-dirs'] + \
gconf.rsync_options.split() + \
(boolify(gconf.use_rsync_xattrs) and ['--xattrs'] or []) + \
(boolify(gconf.sync_xattrs) and ['--xattrs'] or []) + \
['.'] + list(args)
po = Popen(argv, stdin=subprocess.PIPE, stderr=subprocess.PIPE)
for f in files:
@ -852,9 +852,13 @@ class SlaveRemote(object):
raise GsyncdError("no files to sync")
logging.debug("files: " + ", ".join(files))
(host, rdir) = slaveurl.split(':')
tar_cmd = ["tar", "-cf", "-", "--files-from", "-"]
tar_cmd = ["tar"] + \
(boolify(gconf.sync_xattrs) and ['--xattrs'] or []) + \
["-cf", "-", "--files-from", "-"]
ssh_cmd = gconf.ssh_command_tar.split() + \
[host, "tar", "--overwrite", "-xf", "-", "-C", rdir]
[host, "tar"] + \
(boolify(gconf.sync_xattrs) and ['--xattrs'] or []) + \
["--overwrite", "-xf", "-", "-C", rdir]
p0 = Popen(tar_cmd, stdout=subprocess.PIPE,
stdin=subprocess.PIPE, stderr=subprocess.PIPE)
p1 = Popen(ssh_cmd, stdin=p0.stdout, stderr=subprocess.PIPE)