diff mbox

[1/7] ocfs2: test reflinking to inline data files

Message ID 148149317133.31093.439907074888693999.stgit@birch.djwong.org (mailing list archive)
State New, archived
Headers show

Commit Message

Darrick J. Wong Dec. 11, 2016, 9:52 p.m. UTC
Make sure that we can handle reflinking from and to inline-data files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 common/reflink       |    2 +
 tests/ocfs2/001      |   88 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/ocfs2/001.out  |   14 ++++++++
 tests/ocfs2/Makefile |   20 +++++++++++
 tests/ocfs2/group    |    1 +
 5 files changed, 124 insertions(+), 1 deletion(-)
 create mode 100755 tests/ocfs2/001
 create mode 100644 tests/ocfs2/001.out
 create mode 100644 tests/ocfs2/Makefile
 create mode 100644 tests/ocfs2/group

Comments

Darrick J. Wong Dec. 12, 2016, 6:09 p.m. UTC | #1
On Mon, Dec 12, 2016 at 05:01:20PM +0800, Eryu Guan wrote:
> On Sun, Dec 11, 2016 at 01:52:51PM -0800, Darrick J. Wong wrote:
> > Make sure that we can handle reflinking from and to inline-data files.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  common/reflink       |    2 +
> >  tests/ocfs2/001      |   88 ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/ocfs2/001.out  |   14 ++++++++
> >  tests/ocfs2/Makefile |   20 +++++++++++
> >  tests/ocfs2/group    |    1 +
> >  5 files changed, 124 insertions(+), 1 deletion(-)
> >  create mode 100755 tests/ocfs2/001
> >  create mode 100644 tests/ocfs2/001.out
> >  create mode 100644 tests/ocfs2/Makefile
> >  create mode 100644 tests/ocfs2/group
> > 
> > 
> > diff --git a/common/reflink b/common/reflink
> > index 9d51729..d048045 100644
> > --- a/common/reflink
> > +++ b/common/reflink
> > @@ -197,7 +197,7 @@ _cp_reflink() {
> >  	file1="$1"
> >  	file2="$2"
> >  
> > -	cp --reflink=always -p "$file1" "$file2"
> > +	cp --reflink=always -p -f "$file1" "$file2"
> 
> I'm still seeing "File exists" error with this patch, tested with your
> ocfs2-vfs-reflink-6 branch, compiled on openSUSE Tumbleweed.
> 
> FSTYP         -- ocfs2
> PLATFORM      -- Linux/x86_64 bootp-73-5-234 4.9.0-rc8.djwong-ocfs2+
> MKFS_OPTIONS  -- --fs-features=local /dev/sda5
> MOUNT_OPTIONS -- /dev/sda5 /mnt/testarea/scratch
> 
> ocfs2/001        - output mismatch (see /root/xfstests/results//ocfs2/ocfs2/001.out.bad)
>     --- tests/ocfs2/001.out     2016-12-12 13:51:38.053909486 +0800
>     +++ /root/xfstests/results//ocfs2/ocfs2/001.out.bad 2016-12-12 16:49:35.038882697 +0800
>     @@ -1,14 +1,18 @@
>      QA output created by 001
>     +mkfs.ocfs2 1.8.4

I guess I'll have to neuter this on newer ocfs2-tools.  (Still running 1.6.4
here).

>      Format and mount
>      Create the original files
>      reflink into the start of file2
>     +cp: failed to reflink '/mnt/testarea/scratch/test-001/file2' from '/mnt/testarea/scratch/test-001/file1': File exists
>      reflink past the stuff in file3
>     ...
>     (Run 'diff -u tests/ocfs2/001.out /root/xfstests/results//ocfs2/ocfs2/001.out.bad'  to see the entire diff)
> 
> --- tests/ocfs2/001.out 2016-12-12 13:51:38.053909486 +0800
> +++ /root/xfstests/results//ocfs2/ocfs2/001.out.bad     2016-12-12 16:44:31.991943842 +0800
> @@ -1,14 +1,18 @@
>  QA output created by 001
> +mkfs.ocfs2 1.8.4
>  Format and mount
>  Create the original files
>  reflink into the start of file2
> +cp: failed to reflink '/mnt/testarea/scratch/test-001/file2' from '/mnt/testarea/scratch/test-001/file1': File exists
>  reflink past the stuff in file3
>  reflink an inline-data file to a regular one
> +cp: failed to reflink '/mnt/testarea/scratch/test-001/file5' from '/mnt/testarea/scratch/test-001/file4': File exists
>  reflink an inline-data file to another inline-data file
> +cp: failed to reflink '/mnt/testarea/scratch/test-001/file6' from '/mnt/testarea/scratch/test-001/file4': File exists
>  Verify the whole mess
>  2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file1
> -2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file2
> +401b30e3b8b5d629635a5c613cdb7919  SCRATCH_MNT/test-001/file2
>  4e68a2e24b6b0f386ab39d01d902293d  SCRATCH_MNT/test-001/file3
>  009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file4
> -009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file5
> -009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file6
> +2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file5
> +60b725f10c9c85c70d97880dfe8191b3  SCRATCH_MNT/test-001/file6
> 
> I did the "reflink into the start of file2" test manually, and strace
> showed that it is file1 reports EEXIST.
> 
> open("/mnt/ocfs2/testfile1", O_RDONLY)  = 3
> fstat(3, {st_mode=S_IFREG|0600, st_size=65536, ...}) = 0
> ioctl(3, _IOC(_IOC_WRITE, 0x6f, 0x04, 0x18), 0x7ffc8daf09f0) = -1 EEXIST (File exists)

Wait, that's the ocfs2 reflink ioctl, not FICLONE.  Well that explains
why the functional parts of the tests fail.  I looked at latest coreutils
source, which does not use OCFS2_IOC_REFLINK, so I guess this must be an
opensuse thing?

--D

> 
> The same test on XFS works fine. Did I miss anything?
> 
> Thanks,
> Eryu
Darrick J. Wong Dec. 13, 2016, 7:11 a.m. UTC | #2
On Tue, Dec 13, 2016 at 11:20:57AM +0800, Eryu Guan wrote:
> On Mon, Dec 12, 2016 at 10:09:22AM -0800, Darrick J. Wong wrote:
> > On Mon, Dec 12, 2016 at 05:01:20PM +0800, Eryu Guan wrote:
> > > On Sun, Dec 11, 2016 at 01:52:51PM -0800, Darrick J. Wong wrote:
> > > > Make sure that we can handle reflinking from and to inline-data files.
> > > > 
> > > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > > ---
> > > >  common/reflink       |    2 +
> > > >  tests/ocfs2/001      |   88 ++++++++++++++++++++++++++++++++++++++++++++++++++
> > > >  tests/ocfs2/001.out  |   14 ++++++++
> > > >  tests/ocfs2/Makefile |   20 +++++++++++
> > > >  tests/ocfs2/group    |    1 +
> > > >  5 files changed, 124 insertions(+), 1 deletion(-)
> > > >  create mode 100755 tests/ocfs2/001
> > > >  create mode 100644 tests/ocfs2/001.out
> > > >  create mode 100644 tests/ocfs2/Makefile
> > > >  create mode 100644 tests/ocfs2/group
> > > > 
> > > > 
> > > > diff --git a/common/reflink b/common/reflink
> > > > index 9d51729..d048045 100644
> > > > --- a/common/reflink
> > > > +++ b/common/reflink
> > > > @@ -197,7 +197,7 @@ _cp_reflink() {
> > > >  	file1="$1"
> > > >  	file2="$2"
> > > >  
> > > > -	cp --reflink=always -p "$file1" "$file2"
> > > > +	cp --reflink=always -p -f "$file1" "$file2"
> > > 
> > > I'm still seeing "File exists" error with this patch, tested with your
> > > ocfs2-vfs-reflink-6 branch, compiled on openSUSE Tumbleweed.
> > > 
> > > FSTYP         -- ocfs2
> > > PLATFORM      -- Linux/x86_64 bootp-73-5-234 4.9.0-rc8.djwong-ocfs2+
> > > MKFS_OPTIONS  -- --fs-features=local /dev/sda5
> > > MOUNT_OPTIONS -- /dev/sda5 /mnt/testarea/scratch
> > > 
> > > ocfs2/001        - output mismatch (see /root/xfstests/results//ocfs2/ocfs2/001.out.bad)
> > >     --- tests/ocfs2/001.out     2016-12-12 13:51:38.053909486 +0800
> > >     +++ /root/xfstests/results//ocfs2/ocfs2/001.out.bad 2016-12-12 16:49:35.038882697 +0800
> > >     @@ -1,14 +1,18 @@
> > >      QA output created by 001
> > >     +mkfs.ocfs2 1.8.4
> > 
> > I guess I'll have to neuter this on newer ocfs2-tools.  (Still running 1.6.4
> > here).
> 
> I have a patch pending on review that could fix & filter this, FYI
> 
> fstests: teach _scratch_mkfs to handle mkfs option conflicts
> https://www.spinics.net/lists/fstests/msg04550.html

<nod> I actually meant the printing of the mkfs version string.

> 
> > 
> > >      Format and mount
> > >      Create the original files
> > >      reflink into the start of file2
> > >     +cp: failed to reflink '/mnt/testarea/scratch/test-001/file2' from '/mnt/testarea/scratch/test-001/file1': File exists
> > >      reflink past the stuff in file3
> > >     ...
> > >     (Run 'diff -u tests/ocfs2/001.out /root/xfstests/results//ocfs2/ocfs2/001.out.bad'  to see the entire diff)
> > > 
> > > --- tests/ocfs2/001.out 2016-12-12 13:51:38.053909486 +0800
> > > +++ /root/xfstests/results//ocfs2/ocfs2/001.out.bad     2016-12-12 16:44:31.991943842 +0800
> > > @@ -1,14 +1,18 @@
> > >  QA output created by 001
> > > +mkfs.ocfs2 1.8.4
> > >  Format and mount
> > >  Create the original files
> > >  reflink into the start of file2
> > > +cp: failed to reflink '/mnt/testarea/scratch/test-001/file2' from '/mnt/testarea/scratch/test-001/file1': File exists
> > >  reflink past the stuff in file3
> > >  reflink an inline-data file to a regular one
> > > +cp: failed to reflink '/mnt/testarea/scratch/test-001/file5' from '/mnt/testarea/scratch/test-001/file4': File exists
> > >  reflink an inline-data file to another inline-data file
> > > +cp: failed to reflink '/mnt/testarea/scratch/test-001/file6' from '/mnt/testarea/scratch/test-001/file4': File exists
> > >  Verify the whole mess
> > >  2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file1
> > > -2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file2
> > > +401b30e3b8b5d629635a5c613cdb7919  SCRATCH_MNT/test-001/file2
> > >  4e68a2e24b6b0f386ab39d01d902293d  SCRATCH_MNT/test-001/file3
> > >  009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file4
> > > -009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file5
> > > -009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file6
> > > +2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file5
> > > +60b725f10c9c85c70d97880dfe8191b3  SCRATCH_MNT/test-001/file6
> > > 
> > > I did the "reflink into the start of file2" test manually, and strace
> > > showed that it is file1 reports EEXIST.
> > > 
> > > open("/mnt/ocfs2/testfile1", O_RDONLY)  = 3
> > > fstat(3, {st_mode=S_IFREG|0600, st_size=65536, ...}) = 0
> > > ioctl(3, _IOC(_IOC_WRITE, 0x6f, 0x04, 0x18), 0x7ffc8daf09f0) = -1 EEXIST (File exists)
> > 
> > Wait, that's the ocfs2 reflink ioctl, not FICLONE.  Well that explains
> > why the functional parts of the tests fail.  I looked at latest coreutils
> > source, which does not use OCFS2_IOC_REFLINK, so I guess this must be an
> > opensuse thing?
> 
> Ok, I'll try a newer coreutils.

coreutils 8.26 (latest) doesn't have any OCFS2_IOC_REFLINK support; I
suspect a distro patch in the srpm or something....

--D

> 
> Thanks,
> Eryu
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Darrick J. Wong Dec. 13, 2016, 9:35 p.m. UTC | #3
On Mon, Dec 12, 2016 at 11:11:36PM -0800, Darrick J. Wong wrote:
> On Tue, Dec 13, 2016 at 11:20:57AM +0800, Eryu Guan wrote:
> > On Mon, Dec 12, 2016 at 10:09:22AM -0800, Darrick J. Wong wrote:
> > > On Mon, Dec 12, 2016 at 05:01:20PM +0800, Eryu Guan wrote:
> > > > On Sun, Dec 11, 2016 at 01:52:51PM -0800, Darrick J. Wong wrote:
> > > > > Make sure that we can handle reflinking from and to inline-data files.
> > > > > 
> > > > > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > > > > ---
> > > > >  common/reflink       |    2 +
> > > > >  tests/ocfs2/001      |   88 ++++++++++++++++++++++++++++++++++++++++++++++++++
> > > > >  tests/ocfs2/001.out  |   14 ++++++++
> > > > >  tests/ocfs2/Makefile |   20 +++++++++++
> > > > >  tests/ocfs2/group    |    1 +
> > > > >  5 files changed, 124 insertions(+), 1 deletion(-)
> > > > >  create mode 100755 tests/ocfs2/001
> > > > >  create mode 100644 tests/ocfs2/001.out
> > > > >  create mode 100644 tests/ocfs2/Makefile
> > > > >  create mode 100644 tests/ocfs2/group
> > > > > 
> > > > > 
> > > > > diff --git a/common/reflink b/common/reflink
> > > > > index 9d51729..d048045 100644
> > > > > --- a/common/reflink
> > > > > +++ b/common/reflink
> > > > > @@ -197,7 +197,7 @@ _cp_reflink() {
> > > > >  	file1="$1"
> > > > >  	file2="$2"
> > > > >  
> > > > > -	cp --reflink=always -p "$file1" "$file2"
> > > > > +	cp --reflink=always -p -f "$file1" "$file2"
> > > > 
> > > > I'm still seeing "File exists" error with this patch, tested with your
> > > > ocfs2-vfs-reflink-6 branch, compiled on openSUSE Tumbleweed.
> > > > 
> > > > FSTYP         -- ocfs2
> > > > PLATFORM      -- Linux/x86_64 bootp-73-5-234 4.9.0-rc8.djwong-ocfs2+
> > > > MKFS_OPTIONS  -- --fs-features=local /dev/sda5
> > > > MOUNT_OPTIONS -- /dev/sda5 /mnt/testarea/scratch
> > > > 
> > > > ocfs2/001        - output mismatch (see /root/xfstests/results//ocfs2/ocfs2/001.out.bad)
> > > >     --- tests/ocfs2/001.out     2016-12-12 13:51:38.053909486 +0800
> > > >     +++ /root/xfstests/results//ocfs2/ocfs2/001.out.bad 2016-12-12 16:49:35.038882697 +0800
> > > >     @@ -1,14 +1,18 @@
> > > >      QA output created by 001
> > > >     +mkfs.ocfs2 1.8.4
> > > 
> > > I guess I'll have to neuter this on newer ocfs2-tools.  (Still running 1.6.4
> > > here).
> > 
> > I have a patch pending on review that could fix & filter this, FYI
> > 
> > fstests: teach _scratch_mkfs to handle mkfs option conflicts
> > https://www.spinics.net/lists/fstests/msg04550.html
> 
> <nod> I actually meant the printing of the mkfs version string.
> 
> > 
> > > 
> > > >      Format and mount
> > > >      Create the original files
> > > >      reflink into the start of file2
> > > >     +cp: failed to reflink '/mnt/testarea/scratch/test-001/file2' from '/mnt/testarea/scratch/test-001/file1': File exists
> > > >      reflink past the stuff in file3
> > > >     ...
> > > >     (Run 'diff -u tests/ocfs2/001.out /root/xfstests/results//ocfs2/ocfs2/001.out.bad'  to see the entire diff)
> > > > 
> > > > --- tests/ocfs2/001.out 2016-12-12 13:51:38.053909486 +0800
> > > > +++ /root/xfstests/results//ocfs2/ocfs2/001.out.bad     2016-12-12 16:44:31.991943842 +0800
> > > > @@ -1,14 +1,18 @@
> > > >  QA output created by 001
> > > > +mkfs.ocfs2 1.8.4
> > > >  Format and mount
> > > >  Create the original files
> > > >  reflink into the start of file2
> > > > +cp: failed to reflink '/mnt/testarea/scratch/test-001/file2' from '/mnt/testarea/scratch/test-001/file1': File exists
> > > >  reflink past the stuff in file3
> > > >  reflink an inline-data file to a regular one
> > > > +cp: failed to reflink '/mnt/testarea/scratch/test-001/file5' from '/mnt/testarea/scratch/test-001/file4': File exists
> > > >  reflink an inline-data file to another inline-data file
> > > > +cp: failed to reflink '/mnt/testarea/scratch/test-001/file6' from '/mnt/testarea/scratch/test-001/file4': File exists
> > > >  Verify the whole mess
> > > >  2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file1
> > > > -2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file2
> > > > +401b30e3b8b5d629635a5c613cdb7919  SCRATCH_MNT/test-001/file2
> > > >  4e68a2e24b6b0f386ab39d01d902293d  SCRATCH_MNT/test-001/file3
> > > >  009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file4
> > > > -009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file5
> > > > -009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file6
> > > > +2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file5
> > > > +60b725f10c9c85c70d97880dfe8191b3  SCRATCH_MNT/test-001/file6
> > > > 
> > > > I did the "reflink into the start of file2" test manually, and strace
> > > > showed that it is file1 reports EEXIST.
> > > > 
> > > > open("/mnt/ocfs2/testfile1", O_RDONLY)  = 3
> > > > fstat(3, {st_mode=S_IFREG|0600, st_size=65536, ...}) = 0
> > > > ioctl(3, _IOC(_IOC_WRITE, 0x6f, 0x04, 0x18), 0x7ffc8daf09f0) = -1 EEXIST (File exists)
> > > 
> > > Wait, that's the ocfs2 reflink ioctl, not FICLONE.  Well that explains
> > > why the functional parts of the tests fail.  I looked at latest coreutils
> > > source, which does not use OCFS2_IOC_REFLINK, so I guess this must be an
> > > opensuse thing?
> > 
> > Ok, I'll try a newer coreutils.
> 
> coreutils 8.26 (latest) doesn't have any OCFS2_IOC_REFLINK support; I
> suspect a distro patch in the srpm or something....

Confirmed.  SuSE's coreutils package has a patch that tries the ocfs2
reflink ioctl and bails out of cp without trying the btrfs/vfs clone
ioctl if the ocfs2 ioctl returns EEXIST.  I suppose that'll have to get
fixed in their coreutils package, but until then it'll just be broken.
:/

FWIW I also confirm that none of (upstream, RHEL, OL, Debian, or Ubuntu)
have this patch, so this shouldn't be a problem on any of them.

--D

> 
> --D
> 
> > 
> > Thanks,
> > Eryu
> > --
> > To unsubscribe from this list: send the line "unsubscribe fstests" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
Zhen Ren Dec. 14, 2016, 7:32 a.m. UTC | #4
Hi!

On 12/14/2016 05:35 AM, Darrick J. Wong wrote:
> On Mon, Dec 12, 2016 at 11:11:36PM -0800, Darrick J. Wong wrote:
>> coreutils 8.26 (latest) doesn't have any OCFS2_IOC_REFLINK support; I
>> suspect a distro patch in the srpm or something....
> Confirmed.  SuSE's coreutils package has a patch that tries the ocfs2
> reflink ioctl and bails out of cp without trying the btrfs/vfs clone
> ioctl if the ocfs2 ioctl returns EEXIST.  I suppose that'll have to get
> fixed in their coreutils package, but until then it'll just be broken.
> :/
>
> FWIW I also confirm that none of (upstream, RHEL, OL, Debian, or Ubuntu)
> have this patch, so this shouldn't be a problem on any of them.

I'm going to fix this issue for openSUSE. Thanks for your guys' efforts!

Thanks!
Eric
>
> --D
>
>> --D
>>
>>> Thanks,
>>> Eryu
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe fstests" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> --
>> To unsubscribe from this list: send the line "unsubscribe fstests" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> --
> To unsubscribe from this list: send the line "unsubscribe fstests" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
diff mbox

Patch

diff --git a/common/reflink b/common/reflink
index 9d51729..d048045 100644
--- a/common/reflink
+++ b/common/reflink
@@ -197,7 +197,7 @@  _cp_reflink() {
 	file1="$1"
 	file2="$2"
 
-	cp --reflink=always -p "$file1" "$file2"
+	cp --reflink=always -p -f "$file1" "$file2"
 }
 
 # Reflink some file1 into file2
diff --git a/tests/ocfs2/001 b/tests/ocfs2/001
new file mode 100755
index 0000000..afb9ce9
--- /dev/null
+++ b/tests/ocfs2/001
@@ -0,0 +1,88 @@ 
+#! /bin/bash
+# FS QA Test No. 001
+#
+# Ensure that reflink works correctly with inline-data files.
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
+#
+# 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.
+#
+# This program is distributed in the hope that it would 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, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1    # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+    cd /
+    rm -rf $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/reflink
+
+# real QA test starts here
+_supported_os Linux
+_supported_fs ocfs2
+_require_scratch_reflink
+_require_cp_reflink
+
+rm -f $seqres.full
+
+echo "Format and mount"
+_scratch_mkfs --fs-features=local,unwritten,refcount,inline-data > $seqres.full 2>&1
+tunefs.ocfs2 --query '%H' $SCRATCH_DEV | grep -q 'inline-data' || \
+	_notrun "Inline data is not supported."
+_scratch_mount >> $seqres.full 2>&1
+
+testdir=$SCRATCH_MNT/test-$seq
+mkdir $testdir
+
+sz=65536
+echo "Create the original files"
+$XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file1 >> $seqres.full
+echo x > $testdir/file2
+echo x > $testdir/file3
+echo y > $testdir/file4
+$XFS_IO_PROG -f -c "pwrite -S 0x61 -b $sz 0 $sz" $testdir/file5 >> $seqres.full
+echo a > $testdir/file6
+_scratch_cycle_mount
+
+echo "reflink into the start of file2"
+_cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
+
+echo "reflink past the stuff in file3"
+_reflink_range $testdir/file1 0 $testdir/file3 $sz $sz >> $seqres.full
+
+echo "reflink an inline-data file to a regular one"
+_cp_reflink $testdir/file4 $testdir/file5 >> $seqres.full
+
+echo "reflink an inline-data file to another inline-data file"
+_cp_reflink $testdir/file4 $testdir/file6 >> $seqres.full
+
+echo "Verify the whole mess"
+_scratch_cycle_mount
+md5sum $testdir/file* | _filter_scratch
+
+# success, all done
+status=0
+exit
diff --git a/tests/ocfs2/001.out b/tests/ocfs2/001.out
new file mode 100644
index 0000000..99fa43a
--- /dev/null
+++ b/tests/ocfs2/001.out
@@ -0,0 +1,14 @@ 
+QA output created by 001
+Format and mount
+Create the original files
+reflink into the start of file2
+reflink past the stuff in file3
+reflink an inline-data file to a regular one
+reflink an inline-data file to another inline-data file
+Verify the whole mess
+2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file1
+2d61aa54b58c2e94403fb092c3dbc027  SCRATCH_MNT/test-001/file2
+4e68a2e24b6b0f386ab39d01d902293d  SCRATCH_MNT/test-001/file3
+009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file4
+009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file5
+009520053b00386d1173f3988c55d192  SCRATCH_MNT/test-001/file6
diff --git a/tests/ocfs2/Makefile b/tests/ocfs2/Makefile
new file mode 100644
index 0000000..70a4f16
--- /dev/null
+++ b/tests/ocfs2/Makefile
@@ -0,0 +1,20 @@ 
+#
+# Copyright (c) 2016 Oracle.  All Rights Reserved.
+#
+
+TOPDIR = ../..
+include $(TOPDIR)/include/builddefs
+
+OCFS2_DIR = ocfs2
+TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(OCFS2_DIR)
+
+include $(BUILDRULES)
+
+install:
+	$(INSTALL) -m 755 -d $(TARGET_DIR)
+	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
+	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
+
+# Nothing.
+install-dev install-lib:
diff --git a/tests/ocfs2/group b/tests/ocfs2/group
new file mode 100644
index 0000000..28e6807
--- /dev/null
+++ b/tests/ocfs2/group
@@ -0,0 +1 @@ 
+001 auto quick clone