[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: BTRFS file clone support for cp
From: |
Giuseppe Scrivano |
Subject: |
Re: BTRFS file clone support for cp |
Date: |
Wed, 29 Jul 2009 21:43:06 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/23.0.96 (gnu/linux) |
Hi,
I cleaned a bit the Pádraig's example in a new test case.
The second patch fixes a problem that I introduced with the commit
e81c4d88c2fce526c02693d539e22c7468dc452b.
Any comment?
Regards,
Giuseppe
>From 555192badb1a02dd730a3385e2540f48033b3de0 Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <address@hidden>
Date: Wed, 29 Jul 2009 20:31:20 +0200
Subject: [PATCH 1/2] tests: add a test for btrfs' copy-on-write file clone
operation
* tests/Makefile.am: Consider the new test.
* tests/cp/file-clone: New file.
---
tests/Makefile.am | 1 +
tests/cp/file-clone | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 58 insertions(+), 0 deletions(-)
create mode 100755 tests/cp/file-clone
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 59737a0..9841aa3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -20,6 +20,7 @@ EXTRA_DIST = \
root_tests = \
chown/basic \
+ cp/file-clone \
cp/cp-a-selinux \
cp/preserve-gid \
cp/special-bits \
diff --git a/tests/cp/file-clone b/tests/cp/file-clone
new file mode 100755
index 0000000..42d2a91
--- /dev/null
+++ b/tests/cp/file-clone
@@ -0,0 +1,57 @@
+#!/bin/sh
+# Make sure file-clone on a btrfs file system works properly.
+
+# Copyright (C) 2009 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+if test "$VERBOSE" = yes; then
+ set -x
+ cp --version
+fi
+
+. $srcdir/test-lib.sh
+
+require_root_
+require_sparse_support_
+
+fail=0
+
+mkfs.btrfs --version || skip_test_ "btrfs userland tools not installed"
+
+dd bs=1M count=300 if=/dev/zero of=btrfs.img || framework_failure
+
+mkfs.btrfs btrfs.img || framework_failure
+
+mkdir btrfs || framework_failure
+
+mount -t btrfs -o loop btrfs.img btrfs || framework_failure
+
+dd bs=1M count=200 if=/dev/zero of=btrfs/alloc.test || (umount btrfs;
+ framework_failure)
+
+# If the file is cloned, only additional space for metadata is required.
+# Two 200Mb files can be present even if the total file system space is 300Mb.
+cp btrfs/alloc.test btrfs/clone.test || fail=1
+rm btrfs/clone.test
+
+# When --sparse={always,never} is used, the file is copied without any cloning.
+# Use --sparse=never to be sure the file is copied without holes and it is not
+# possible since there is not enough free space.
+cp --sparse=never btrfs/alloc.test btrfs/clone.test && fail=1
+
+umount btrfs
+
+Exit $fail
--
1.6.3.3
>From 0348010828d201c0790c06e1427cc4b813c605db Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <address@hidden>
Date: Wed, 29 Jul 2009 20:57:29 +0200
Subject: [PATCH 2/2] tail: exit successfully on watched process death
* src/tail.c (tail_forever_inotify): If a PID is specified and the
watched process is death, exit with an EXIT_SUCCESS code.
---
src/tail.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/tail.c b/src/tail.c
index a73ffa2..5efaf57 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -1280,7 +1280,7 @@ tail_forever_inotify (int wd, struct File_spec *f, size_t
n_files,
{
/* See if the process we are monitoring is still alive. */
if (kill (pid, 0) != 0 && errno != EPERM)
- break;
+ exit (EXIT_SUCCESS);
continue;
}
--
1.6.3.3
- Re: BTRFS file clone support for cp, (continued)
- Re: BTRFS file clone support for cp, Andi Kleen, 2009/07/30
- Re: BTRFS file clone support for cp, Pádraig Brady, 2009/07/30
- Re: BTRFS file clone support for cp, Jim Meyering, 2009/07/30
- Re: BTRFS file clone support for cp, Andi Kleen, 2009/07/30
- Re: BTRFS file clone support for cp, Joel Becker, 2009/07/30
- Re: BTRFS file clone support for cp, Pádraig Brady, 2009/07/30
- Re: BTRFS file clone support for cp, Tomasz Chmielewski, 2009/07/30
- Re: BTRFS file clone support for cp, Chris Mason, 2009/07/29
- Re: BTRFS file clone support for cp,
Giuseppe Scrivano <=
- Re: BTRFS file clone support for cp, Pádraig Brady, 2009/07/29
- Re: BTRFS file clone support for cp, Giuseppe Scrivano, 2009/07/30
- Re: BTRFS file clone support for cp, Pádraig Brady, 2009/07/30
- Re: BTRFS file clone support for cp, Giuseppe Scrivano, 2009/07/31
- Re: BTRFS file clone support for cp, Pádraig Brady, 2009/07/31
- Re: BTRFS file clone support for cp, Jim Meyering, 2009/07/31
- Re: BTRFS file clone support for cp, Jim Meyering, 2009/07/30
- Re: BTRFS file clone support for cp, Pádraig Brady, 2009/07/30
- Re: BTRFS file clone support for cp, Jim Meyering, 2009/07/30