Commit 56664461 authored by Wei-Yin Chen (陳威尹)'s avatar Wei-Yin Chen (陳威尹) Committed by Commit Bot

Support btrfs snapshot in gclient-new-workdir.py

If the repo is a btrfs subvolume, take a snapshot instead of using
"cp --reflink". Taking a snapshot is much faster, and uses less
disk space for metadata.

Bug: 721585
Change-Id: I97753dc30d46ff56d84d65f8d815c19d09cf104b
Reviewed-on: https://chromium-review.googlesource.com/513586Reviewed-by: 's avatarRobbie Iannucci <iannucci@chromium.org>
Commit-Queue: Wei-Yin Chen (陳威尹) <wychen@chromium.org>
parent b02daf0b
......@@ -60,18 +60,30 @@ def support_cow(src, dest):
return True
def try_vol_snapshot(src, dest):
try:
subprocess.check_call(['btrfs', 'subvol', 'snapshot', src, dest],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError:
return False
return True
def main():
args = parse_options()
gclient = os.path.join(args.repository, '.gclient')
new_gclient = os.path.join(args.new_workdir, '.gclient')
os.makedirs(args.new_workdir)
if args.reflink is None:
args.reflink = support_cow(gclient, new_gclient)
if args.reflink:
print('Copy-on-write support is detected.')
os.symlink(gclient, new_gclient)
if try_vol_snapshot(args.repository, args.new_workdir):
args.reflink = True
else:
os.makedirs(args.new_workdir)
if args.reflink is None:
args.reflink = support_cow(gclient, new_gclient)
if args.reflink:
print('Copy-on-write support is detected.')
os.symlink(gclient, new_gclient)
for root, dirs, _ in os.walk(args.repository):
if '.git' in dirs:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment