All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] test unaligned punch hole at ENOSPC
@ 2018-09-28 14:50 Anand Jain
  2018-09-28 14:59 ` [PATCH v4] " Anand Jain
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Anand Jain @ 2018-09-28 14:50 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

Try to punch hole with unaligned size and offset when the FS
returns ENOSPC

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2->v3:
 add _require_xfs_io_command "fpunch"
 add more logs to $seqfull.full
   mount options and
   group profile info
 add sync after dd upto ENOSPC
 drop fallocate -p and use xfs_io punch to create holes
v1->v2: Use at least 256MB to test.
This test case fails on btrfs as of now.

 tests/btrfs/172     | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/172.out |  2 ++
 tests/btrfs/group   |  1 +
 3 files changed, 77 insertions(+)
 create mode 100755 tests/btrfs/172
 create mode 100644 tests/btrfs/172.out

diff --git a/tests/btrfs/172 b/tests/btrfs/172
new file mode 100755
index 000000000000..59413a5de12f
--- /dev/null
+++ b/tests/btrfs/172
@@ -0,0 +1,74 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Oracle. All Rights Reserved.
+#
+# FS QA Test 172
+#
+# Test if the unaligned (by size and offset) punch hole is successful when FS
+# is at ENOSPC.
+#
+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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_xfs_io_command "fpunch"
+
+_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
+
+# max_inline helps to create regular extent
+_scratch_mount "-o max_inline=0,nodatacow"
+
+cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
+$BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
+
+extent_size=$(_scratch_btrfs_sectorsize)
+unalign_by=512
+echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
+
+$XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 $((extent_size * 10))" \
+					$SCRATCH_MNT/testfile >> $seqres.full
+
+echo "Fill fs upto ENOSPC" >> $seqres.full
+dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
+sync
+
+hole_offset=0
+hole_len=$unalign_by
+$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
+
+hole_offset=$(($extent_size + $unalign_by))
+hole_len=$(($extent_size - $unalign_by))
+$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
+
+hole_offset=$(($extent_size * 2 + $unalign_by))
+hole_len=$(($extent_size * 5))
+$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/btrfs/172.out b/tests/btrfs/172.out
new file mode 100644
index 000000000000..ce2de3f0d107
--- /dev/null
+++ b/tests/btrfs/172.out
@@ -0,0 +1,2 @@
+QA output created by 172
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index feffc45b6564..7e1a638ab7e1 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -174,3 +174,4 @@
 169 auto quick send
 170 auto quick snapshot
 171 auto quick qgroup
+172 auto quick
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH v4] test unaligned punch hole at ENOSPC
  2018-09-28 14:50 [PATCH v3] test unaligned punch hole at ENOSPC Anand Jain
@ 2018-09-28 14:59 ` Anand Jain
  2018-09-28 17:08 ` [PATCH v3] " Filipe Manana
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Anand Jain @ 2018-09-28 14:59 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

Try to punch hole with unaligned size and offset when the FS
returns ENOSPC

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v3->v4:
 add to the group punch
v2->v3:
 add _require_xfs_io_command "fpunch"
 add more logs to $seqfull.full
   mount options and
   group profile info
 add sync after dd upto ENOSPC
 drop fallocate -p and use xfs_io punch to create holes
v1->v2: Use at least 256MB to test.
This test case fails on btrfs as of now.
 tests/btrfs/172     | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/172.out |  2 ++
 tests/btrfs/group   |  1 +
 3 files changed, 77 insertions(+)
 create mode 100755 tests/btrfs/172
 create mode 100644 tests/btrfs/172.out

diff --git a/tests/btrfs/172 b/tests/btrfs/172
new file mode 100755
index 000000000000..59413a5de12f
--- /dev/null
+++ b/tests/btrfs/172
@@ -0,0 +1,74 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Oracle. All Rights Reserved.
+#
+# FS QA Test 172
+#
+# Test if the unaligned (by size and offset) punch hole is successful when FS
+# is at ENOSPC.
+#
+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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_xfs_io_command "fpunch"
+
+_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
+
+# max_inline helps to create regular extent
+_scratch_mount "-o max_inline=0,nodatacow"
+
+cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
+$BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
+
+extent_size=$(_scratch_btrfs_sectorsize)
+unalign_by=512
+echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
+
+$XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 $((extent_size * 10))" \
+					$SCRATCH_MNT/testfile >> $seqres.full
+
+echo "Fill fs upto ENOSPC" >> $seqres.full
+dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
+sync
+
+hole_offset=0
+hole_len=$unalign_by
+$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
+
+hole_offset=$(($extent_size + $unalign_by))
+hole_len=$(($extent_size - $unalign_by))
+$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
+
+hole_offset=$(($extent_size * 2 + $unalign_by))
+hole_len=$(($extent_size * 5))
+$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/btrfs/172.out b/tests/btrfs/172.out
new file mode 100644
index 000000000000..ce2de3f0d107
--- /dev/null
+++ b/tests/btrfs/172.out
@@ -0,0 +1,2 @@
+QA output created by 172
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index feffc45b6564..45782565c3b7 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -174,3 +174,4 @@
 169 auto quick send
 170 auto quick snapshot
 171 auto quick qgroup
+172 auto quick punch
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] test unaligned punch hole at ENOSPC
  2018-09-28 14:50 [PATCH v3] test unaligned punch hole at ENOSPC Anand Jain
  2018-09-28 14:59 ` [PATCH v4] " Anand Jain
@ 2018-09-28 17:08 ` Filipe Manana
  2018-09-28 17:12   ` Filipe Manana
  2018-09-30  0:57   ` Anand Jain
  2018-09-29  0:51 ` [PATCH v5] " Anand Jain
  2018-09-30  1:39 ` [PATCH v6] " Anand Jain
  3 siblings, 2 replies; 11+ messages in thread
From: Filipe Manana @ 2018-09-28 17:08 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs

On Fri, Sep 28, 2018 at 3:51 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> Try to punch hole with unaligned size and offset when the FS
> returns ENOSPC

The FS returns ENOSPC is confusing. It's more clear to say when the
filesystem doesn't have more space available for data allocation.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v2->v3:
>  add _require_xfs_io_command "fpunch"
>  add more logs to $seqfull.full
>    mount options and
>    group profile info
>  add sync after dd upto ENOSPC
>  drop fallocate -p and use xfs_io punch to create holes
> v1->v2: Use at least 256MB to test.
> This test case fails on btrfs as of now.
>
>  tests/btrfs/172     | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/172.out |  2 ++
>  tests/btrfs/group   |  1 +
>  3 files changed, 77 insertions(+)
>  create mode 100755 tests/btrfs/172
>  create mode 100644 tests/btrfs/172.out
>
> diff --git a/tests/btrfs/172 b/tests/btrfs/172
> new file mode 100755
> index 000000000000..59413a5de12f
> --- /dev/null
> +++ b/tests/btrfs/172
> @@ -0,0 +1,74 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2018 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 172
> +#
> +# Test if the unaligned (by size and offset) punch hole is successful when FS
> +# is at ENOSPC.
> +#
> +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 -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +# real QA test starts here
> +
> +# Modify as appropriate.
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_scratch
> +_require_xfs_io_command "fpunch"
> +
> +_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
> +
> +# max_inline helps to create regular extent
max_inline ensures data is not inlined within metadata extents

> +_scratch_mount "-o max_inline=0,nodatacow"
> +
> +cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
> +$BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
> +
> +extent_size=$(_scratch_btrfs_sectorsize)
> +unalign_by=512
> +echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
> +
> +$XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 $((extent_size * 10))" \
> +                                       $SCRATCH_MNT/testfile >> $seqres.full
> +
> +echo "Fill fs upto ENOSPC" >> $seqres.full
Fill all space available for data and all unallocated space.

> +dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
Why do you use dd here and not xfs_io?

> +sync
Why is the sync needed?

> +
> +hole_offset=0
> +hole_len=$unalign_by
> +$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile

No need to pass -f anymore. No need for -d either.

> +
> +hole_offset=$(($extent_size + $unalign_by))
> +hole_len=$(($extent_size - $unalign_by))
> +$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile

No need to pass -f anymore. No need for -d either.

> +
> +hole_offset=$(($extent_size * 2 + $unalign_by))
> +hole_len=$(($extent_size * 5))
> +$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile

No need to pass -f anymore. No need for -d either.
> +
> +# success, all done
> +echo "Silence is golden"
> +status=0
> +exit
> diff --git a/tests/btrfs/172.out b/tests/btrfs/172.out
> new file mode 100644
> index 000000000000..ce2de3f0d107
> --- /dev/null
> +++ b/tests/btrfs/172.out
> @@ -0,0 +1,2 @@
> +QA output created by 172
> +Silence is golden
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index feffc45b6564..7e1a638ab7e1 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -174,3 +174,4 @@
>  169 auto quick send
>  170 auto quick snapshot
>  171 auto quick qgroup
> +172 auto quick
> --
> 1.8.3.1
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] test unaligned punch hole at ENOSPC
  2018-09-28 17:08 ` [PATCH v3] " Filipe Manana
@ 2018-09-28 17:12   ` Filipe Manana
  2018-09-29  0:13     ` Anand Jain
  2018-09-30  0:57   ` Anand Jain
  1 sibling, 1 reply; 11+ messages in thread
From: Filipe Manana @ 2018-09-28 17:12 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs

On Fri, Sep 28, 2018 at 6:08 PM Filipe Manana <fdmanana@gmail.com> wrote:
>
> On Fri, Sep 28, 2018 at 3:51 PM Anand Jain <anand.jain@oracle.com> wrote:
> >
> > Try to punch hole with unaligned size and offset when the FS
> > returns ENOSPC
>
> The FS returns ENOSPC is confusing. It's more clear to say when the
> filesystem doesn't have more space available for data allocation.
> >
> > Signed-off-by: Anand Jain <anand.jain@oracle.com>
> > ---
> > v2->v3:
> >  add _require_xfs_io_command "fpunch"
> >  add more logs to $seqfull.full
> >    mount options and
> >    group profile info
> >  add sync after dd upto ENOSPC
> >  drop fallocate -p and use xfs_io punch to create holes
> > v1->v2: Use at least 256MB to test.
> > This test case fails on btrfs as of now.
> >
> >  tests/btrfs/172     | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  tests/btrfs/172.out |  2 ++
> >  tests/btrfs/group   |  1 +
> >  3 files changed, 77 insertions(+)
> >  create mode 100755 tests/btrfs/172
> >  create mode 100644 tests/btrfs/172.out
> >
> > diff --git a/tests/btrfs/172 b/tests/btrfs/172
> > new file mode 100755
> > index 000000000000..59413a5de12f
> > --- /dev/null
> > +++ b/tests/btrfs/172
> > @@ -0,0 +1,74 @@
> > +#! /bin/bash
> > +# SPDX-License-Identifier: GPL-2.0
> > +# Copyright (c) 2018 Oracle. All Rights Reserved.
> > +#
> > +# FS QA Test 172
> > +#
> > +# Test if the unaligned (by size and offset) punch hole is successful when FS
> > +# is at ENOSPC.
> > +#
> > +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 -f $tmp.*
> > +}
> > +
> > +# get standard environment, filters and checks
> > +. ./common/rc
> > +. ./common/filter
> > +
> > +# remove previous $seqres.full before test
> > +rm -f $seqres.full
> > +
> > +# real QA test starts here
> > +
> > +# Modify as appropriate.
> > +_supported_fs btrfs
> > +_supported_os Linux
> > +_require_scratch
> > +_require_xfs_io_command "fpunch"
> > +
> > +_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
> > +
> > +# max_inline helps to create regular extent
> max_inline ensures data is not inlined within metadata extents
>
> > +_scratch_mount "-o max_inline=0,nodatacow"
> > +
> > +cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
> > +$BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
> > +
> > +extent_size=$(_scratch_btrfs_sectorsize)
> > +unalign_by=512
> > +echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
> > +
> > +$XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 $((extent_size * 10))" \
> > +                                       $SCRATCH_MNT/testfile >> $seqres.full

Also missing _require_odirect.
Why is direct IO needed? If not needed (which I don't see why), it can
be avoided.

> > +
> > +echo "Fill fs upto ENOSPC" >> $seqres.full
> Fill all space available for data and all unallocated space.
>
> > +dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
> Why do you use dd here and not xfs_io?
>
> > +sync
> Why is the sync needed?
>
> > +
> > +hole_offset=0
> > +hole_len=$unalign_by
> > +$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
>
> No need to pass -f anymore. No need for -d either.
>
> > +
> > +hole_offset=$(($extent_size + $unalign_by))
> > +hole_len=$(($extent_size - $unalign_by))
> > +$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
>
> No need to pass -f anymore. No need for -d either.
>
> > +
> > +hole_offset=$(($extent_size * 2 + $unalign_by))
> > +hole_len=$(($extent_size * 5))
> > +$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
>
> No need to pass -f anymore. No need for -d either.
> > +
> > +# success, all done
> > +echo "Silence is golden"
> > +status=0
> > +exit
> > diff --git a/tests/btrfs/172.out b/tests/btrfs/172.out
> > new file mode 100644
> > index 000000000000..ce2de3f0d107
> > --- /dev/null
> > +++ b/tests/btrfs/172.out
> > @@ -0,0 +1,2 @@
> > +QA output created by 172
> > +Silence is golden
> > diff --git a/tests/btrfs/group b/tests/btrfs/group
> > index feffc45b6564..7e1a638ab7e1 100644
> > --- a/tests/btrfs/group
> > +++ b/tests/btrfs/group
> > @@ -174,3 +174,4 @@
> >  169 auto quick send
> >  170 auto quick snapshot
> >  171 auto quick qgroup
> > +172 auto quick
> > --
> > 1.8.3.1
> >
>
>
> --
> Filipe David Manana,
>
> “Whether you think you can, or you think you can't — you're right.”



-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] test unaligned punch hole at ENOSPC
  2018-09-28 17:12   ` Filipe Manana
@ 2018-09-29  0:13     ` Anand Jain
  0 siblings, 0 replies; 11+ messages in thread
From: Anand Jain @ 2018-09-29  0:13 UTC (permalink / raw)
  To: fdmanana; +Cc: fstests, linux-btrfs



Thanks for the comments more below..


On 09/29/2018 01:12 AM, Filipe Manana wrote:
> On Fri, Sep 28, 2018 at 6:08 PM Filipe Manana <fdmanana@gmail.com> wrote:
>>
>> On Fri, Sep 28, 2018 at 3:51 PM Anand Jain <anand.jain@oracle.com> wrote:
>>>
>>> Try to punch hole with unaligned size and offset when the FS
>>> returns ENOSPC
>>
>> The FS returns ENOSPC is confusing. It's more clear to say when the
>> filesystem doesn't have more space available for data allocation.

  Will fix.

>>>
>>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>>> ---
>>> v2->v3:
>>>   add _require_xfs_io_command "fpunch"
>>>   add more logs to $seqfull.full
>>>     mount options and
>>>     group profile info
>>>   add sync after dd upto ENOSPC
>>>   drop fallocate -p and use xfs_io punch to create holes
>>> v1->v2: Use at least 256MB to test.
>>> This test case fails on btrfs as of now.
>>>
>>>   tests/btrfs/172     | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>   tests/btrfs/172.out |  2 ++
>>>   tests/btrfs/group   |  1 +
>>>   3 files changed, 77 insertions(+)
>>>   create mode 100755 tests/btrfs/172
>>>   create mode 100644 tests/btrfs/172.out
>>>
>>> diff --git a/tests/btrfs/172 b/tests/btrfs/172
>>> new file mode 100755
>>> index 000000000000..59413a5de12f
>>> --- /dev/null
>>> +++ b/tests/btrfs/172
>>> @@ -0,0 +1,74 @@
>>> +#! /bin/bash
>>> +# SPDX-License-Identifier: GPL-2.0
>>> +# Copyright (c) 2018 Oracle. All Rights Reserved.
>>> +#
>>> +# FS QA Test 172
>>> +#
>>> +# Test if the unaligned (by size and offset) punch hole is successful when FS
>>> +# is at ENOSPC.
>>> +#
>>> +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 -f $tmp.*
>>> +}
>>> +
>>> +# get standard environment, filters and checks
>>> +. ./common/rc
>>> +. ./common/filter
>>> +
>>> +# remove previous $seqres.full before test
>>> +rm -f $seqres.full
>>> +
>>> +# real QA test starts here
>>> +
>>> +# Modify as appropriate.
>>> +_supported_fs btrfs
>>> +_supported_os Linux
>>> +_require_scratch
>>> +_require_xfs_io_command "fpunch"
>>> +
>>> +_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
>>> +
>>> +# max_inline helps to create regular extent
>> max_inline ensures data is not inlined within metadata extents
>>
>>> +_scratch_mount "-o max_inline=0,nodatacow"
>>> +
>>> +cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
>>> +$BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
>>> +
>>> +extent_size=$(_scratch_btrfs_sectorsize)
>>> +unalign_by=512
>>> +echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
>>> +
>>> +$XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 $((extent_size * 10))" \
>>> +                                       $SCRATCH_MNT/testfile >> $seqres.full
> 
> Also missing _require_odirect.
> Why is direct IO needed? If not needed (which I don't see why), it can
> be avoided.

  You caught me direct is not required, will drop it.

Thanks, Anand

>>> +
>>> +echo "Fill fs upto ENOSPC" >> $seqres.full
>> Fill all space available for data and all unallocated space.
>>
>>> +dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
>> Why do you use dd here and not xfs_io?
>>
>>> +sync
>> Why is the sync needed?
>>
>>> +
>>> +hole_offset=0
>>> +hole_len=$unalign_by
>>> +$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
>>
>> No need to pass -f anymore. No need for -d either.
>>
>>> +
>>> +hole_offset=$(($extent_size + $unalign_by))
>>> +hole_len=$(($extent_size - $unalign_by))
>>> +$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
>>
>> No need to pass -f anymore. No need for -d either.
>>
>>> +
>>> +hole_offset=$(($extent_size * 2 + $unalign_by))
>>> +hole_len=$(($extent_size * 5))
>>> +$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
>>
>> No need to pass -f anymore. No need for -d either.
>>> +
>>> +# success, all done
>>> +echo "Silence is golden"
>>> +status=0
>>> +exit
>>> diff --git a/tests/btrfs/172.out b/tests/btrfs/172.out
>>> new file mode 100644
>>> index 000000000000..ce2de3f0d107
>>> --- /dev/null
>>> +++ b/tests/btrfs/172.out
>>> @@ -0,0 +1,2 @@
>>> +QA output created by 172
>>> +Silence is golden
>>> diff --git a/tests/btrfs/group b/tests/btrfs/group
>>> index feffc45b6564..7e1a638ab7e1 100644
>>> --- a/tests/btrfs/group
>>> +++ b/tests/btrfs/group
>>> @@ -174,3 +174,4 @@
>>>   169 auto quick send
>>>   170 auto quick snapshot
>>>   171 auto quick qgroup
>>> +172 auto quick
>>> --
>>> 1.8.3.1
>>>
>>
>>
>> --
>> Filipe David Manana,
>>
>> “Whether you think you can, or you think you can't — you're right.”
> 
> 
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v5] test unaligned punch hole at ENOSPC
  2018-09-28 14:50 [PATCH v3] test unaligned punch hole at ENOSPC Anand Jain
  2018-09-28 14:59 ` [PATCH v4] " Anand Jain
  2018-09-28 17:08 ` [PATCH v3] " Filipe Manana
@ 2018-09-29  0:51 ` Anand Jain
  2018-09-29 16:40   ` Filipe Manana
  2018-09-30  1:39 ` [PATCH v6] " Anand Jain
  3 siblings, 1 reply; 11+ messages in thread
From: Anand Jain @ 2018-09-29  0:51 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

Try to punch hole with unaligned size and offset when the FS is
full. Mainly holes are punched at locations which are unaligned
with the file extent boundaries when the FS is full by data.
As the punching holes at unaligned location will involve
truncating blocks instead of just dropping the extents, it shall
involve reserving data and metadata space for delalloc and data
alloc fails as the FS is full.

btrfs_punch_hole()
 btrfs_truncate_block()
   btrfs_check_data_free_space() <-- ENOSPC

We don't fail punch hole if the holes are aligned with the file
extent boundaries as it shall involve just dropping the related
extents.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v4->v5:
 Update the change log
 Drop the directio option for xfs_io
v3->v4:
 Add to the group punch
v2->v3:
 Add _require_xfs_io_command "fpunch"
 Add more logs to $seqfull.full
   mount options and
   group profile info
 Add sync after dd upto ENOSPC
 Drop fallocate -p and use xfs_io punch to create holes
 Use a testfile instead of filler file so that easy to trace
v1->v2: Use at least 256MB to test.
This test case fails on btrfs as of now.
 tests/btrfs/172     | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/172.out |  2 ++
 tests/btrfs/group   |  1 +
 3 files changed, 77 insertions(+)
 create mode 100755 tests/btrfs/172
 create mode 100644 tests/btrfs/172.out

diff --git a/tests/btrfs/172 b/tests/btrfs/172
new file mode 100755
index 000000000000..1ecf01d862a2
--- /dev/null
+++ b/tests/btrfs/172
@@ -0,0 +1,74 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Oracle. All Rights Reserved.
+#
+# FS QA Test 172
+#
+# Test if the unaligned (by size and offset) punch hole is successful when FS
+# is at ENOSPC.
+#
+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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_xfs_io_command "fpunch"
+
+_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
+
+# max_inline helps to create regular extent
+_scratch_mount "-o max_inline=0,nodatacow"
+
+cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
+$BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
+
+extent_size=$(_scratch_btrfs_sectorsize)
+unalign_by=512
+echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
+
+$XFS_IO_PROG -f -c "pwrite -S 0xab 0 $((extent_size * 10))" \
+					$SCRATCH_MNT/testfile >> $seqres.full
+
+echo "Fill fs upto ENOSPC" >> $seqres.full
+dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
+sync
+
+hole_offset=0
+hole_len=$unalign_by
+$XFS_IO_PROG -f -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
+
+hole_offset=$(($extent_size + $unalign_by))
+hole_len=$(($extent_size - $unalign_by))
+$XFS_IO_PROG -f -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
+
+hole_offset=$(($extent_size * 2 + $unalign_by))
+hole_len=$(($extent_size * 5))
+$XFS_IO_PROG -f -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/btrfs/172.out b/tests/btrfs/172.out
new file mode 100644
index 000000000000..ce2de3f0d107
--- /dev/null
+++ b/tests/btrfs/172.out
@@ -0,0 +1,2 @@
+QA output created by 172
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index feffc45b6564..45782565c3b7 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -174,3 +174,4 @@
 169 auto quick send
 170 auto quick snapshot
 171 auto quick qgroup
+172 auto quick punch
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v5] test unaligned punch hole at ENOSPC
  2018-09-29  0:51 ` [PATCH v5] " Anand Jain
@ 2018-09-29 16:40   ` Filipe Manana
  2018-09-30  0:46     ` Anand Jain
  0 siblings, 1 reply; 11+ messages in thread
From: Filipe Manana @ 2018-09-29 16:40 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs

On Sat, Sep 29, 2018 at 1:52 AM Anand Jain <anand.jain@oracle.com> wrote:
>
> Try to punch hole with unaligned size and offset when the FS is
> full. Mainly holes are punched at locations which are unaligned
> with the file extent boundaries when the FS is full by data.
> As the punching holes at unaligned location will involve
> truncating blocks instead of just dropping the extents, it shall
> involve reserving data and metadata space for delalloc and data
> alloc fails as the FS is full.
>
> btrfs_punch_hole()
>  btrfs_truncate_block()
>    btrfs_check_data_free_space() <-- ENOSPC
>
> We don't fail punch hole if the holes are aligned with the file
> extent boundaries as it shall involve just dropping the related
> extents.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v4->v5:
>  Update the change log
>  Drop the directio option for xfs_io

Except for the direct IO and change log, all my previous comments and
questions weren't addressed/ answered.
Thanks.

> v3->v4:
>  Add to the group punch
> v2->v3:
>  Add _require_xfs_io_command "fpunch"
>  Add more logs to $seqfull.full
>    mount options and
>    group profile info
>  Add sync after dd upto ENOSPC
>  Drop fallocate -p and use xfs_io punch to create holes
>  Use a testfile instead of filler file so that easy to trace
> v1->v2: Use at least 256MB to test.
> This test case fails on btrfs as of now.
>  tests/btrfs/172     | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/172.out |  2 ++
>  tests/btrfs/group   |  1 +
>  3 files changed, 77 insertions(+)
>  create mode 100755 tests/btrfs/172
>  create mode 100644 tests/btrfs/172.out
>
> diff --git a/tests/btrfs/172 b/tests/btrfs/172
> new file mode 100755
> index 000000000000..1ecf01d862a2
> --- /dev/null
> +++ b/tests/btrfs/172
> @@ -0,0 +1,74 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2018 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 172
> +#
> +# Test if the unaligned (by size and offset) punch hole is successful when FS
> +# is at ENOSPC.
> +#
> +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 -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +# real QA test starts here
> +
> +# Modify as appropriate.
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_scratch
> +_require_xfs_io_command "fpunch"
> +
> +_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
> +
> +# max_inline helps to create regular extent
> +_scratch_mount "-o max_inline=0,nodatacow"
> +
> +cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
> +$BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
> +
> +extent_size=$(_scratch_btrfs_sectorsize)
> +unalign_by=512
> +echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
> +
> +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 $((extent_size * 10))" \
> +                                       $SCRATCH_MNT/testfile >> $seqres.full
> +
> +echo "Fill fs upto ENOSPC" >> $seqres.full
> +dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
> +sync
> +
> +hole_offset=0
> +hole_len=$unalign_by
> +$XFS_IO_PROG -f -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
> +
> +hole_offset=$(($extent_size + $unalign_by))
> +hole_len=$(($extent_size - $unalign_by))
> +$XFS_IO_PROG -f -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
> +
> +hole_offset=$(($extent_size * 2 + $unalign_by))
> +hole_len=$(($extent_size * 5))
> +$XFS_IO_PROG -f -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
> +
> +# success, all done
> +echo "Silence is golden"
> +status=0
> +exit
> diff --git a/tests/btrfs/172.out b/tests/btrfs/172.out
> new file mode 100644
> index 000000000000..ce2de3f0d107
> --- /dev/null
> +++ b/tests/btrfs/172.out
> @@ -0,0 +1,2 @@
> +QA output created by 172
> +Silence is golden
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index feffc45b6564..45782565c3b7 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -174,3 +174,4 @@
>  169 auto quick send
>  170 auto quick snapshot
>  171 auto quick qgroup
> +172 auto quick punch
> --
> 1.8.3.1
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v5] test unaligned punch hole at ENOSPC
  2018-09-29 16:40   ` Filipe Manana
@ 2018-09-30  0:46     ` Anand Jain
  0 siblings, 0 replies; 11+ messages in thread
From: Anand Jain @ 2018-09-30  0:46 UTC (permalink / raw)
  To: fdmanana; +Cc: fstests, linux-btrfs



On 09/30/2018 12:40 AM, Filipe Manana wrote:
> On Sat, Sep 29, 2018 at 1:52 AM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> Try to punch hole with unaligned size and offset when the FS is
>> full. Mainly holes are punched at locations which are unaligned
>> with the file extent boundaries when the FS is full by data.
>> As the punching holes at unaligned location will involve
>> truncating blocks instead of just dropping the extents, it shall
>> involve reserving data and metadata space for delalloc and data
>> alloc fails as the FS is full.
>>
>> btrfs_punch_hole()
>>   btrfs_truncate_block()
>>     btrfs_check_data_free_space() <-- ENOSPC
>>
>> We don't fail punch hole if the holes are aligned with the file
>> extent boundaries as it shall involve just dropping the related
>> extents.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> v4->v5:
>>   Update the change log
>>   Drop the directio option for xfs_io
> 
> Except for the direct IO and change log, all my previous comments and
> questions weren't addressed/ answered.
> Thanks.

Ah. Now I notice there were two emails, I completely missed the other 
email. Will review. Thanks for pointing out.

Thanks, Anand


>> v3->v4:
>>   Add to the group punch
>> v2->v3:
>>   Add _require_xfs_io_command "fpunch"
>>   Add more logs to $seqfull.full
>>     mount options and
>>     group profile info
>>   Add sync after dd upto ENOSPC
>>   Drop fallocate -p and use xfs_io punch to create holes
>>   Use a testfile instead of filler file so that easy to trace
>> v1->v2: Use at least 256MB to test.
>> This test case fails on btrfs as of now.
>>   tests/btrfs/172     | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   tests/btrfs/172.out |  2 ++
>>   tests/btrfs/group   |  1 +
>>   3 files changed, 77 insertions(+)
>>   create mode 100755 tests/btrfs/172
>>   create mode 100644 tests/btrfs/172.out
>>
>> diff --git a/tests/btrfs/172 b/tests/btrfs/172
>> new file mode 100755
>> index 000000000000..1ecf01d862a2
>> --- /dev/null
>> +++ b/tests/btrfs/172
>> @@ -0,0 +1,74 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2018 Oracle. All Rights Reserved.
>> +#
>> +# FS QA Test 172
>> +#
>> +# Test if the unaligned (by size and offset) punch hole is successful when FS
>> +# is at ENOSPC.
>> +#
>> +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 -f $tmp.*
>> +}
>> +
>> +# get standard environment, filters and checks
>> +. ./common/rc
>> +. ./common/filter
>> +
>> +# remove previous $seqres.full before test
>> +rm -f $seqres.full
>> +
>> +# real QA test starts here
>> +
>> +# Modify as appropriate.
>> +_supported_fs btrfs
>> +_supported_os Linux
>> +_require_scratch
>> +_require_xfs_io_command "fpunch"
>> +
>> +_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
>> +
>> +# max_inline helps to create regular extent
>> +_scratch_mount "-o max_inline=0,nodatacow"
>> +
>> +cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
>> +$BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
>> +
>> +extent_size=$(_scratch_btrfs_sectorsize)
>> +unalign_by=512
>> +echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
>> +
>> +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 $((extent_size * 10))" \
>> +                                       $SCRATCH_MNT/testfile >> $seqres.full
>> +
>> +echo "Fill fs upto ENOSPC" >> $seqres.full
>> +dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
>> +sync
>> +
>> +hole_offset=0
>> +hole_len=$unalign_by
>> +$XFS_IO_PROG -f -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
>> +
>> +hole_offset=$(($extent_size + $unalign_by))
>> +hole_len=$(($extent_size - $unalign_by))
>> +$XFS_IO_PROG -f -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
>> +
>> +hole_offset=$(($extent_size * 2 + $unalign_by))
>> +hole_len=$(($extent_size * 5))
>> +$XFS_IO_PROG -f -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
>> +
>> +# success, all done
>> +echo "Silence is golden"
>> +status=0
>> +exit
>> diff --git a/tests/btrfs/172.out b/tests/btrfs/172.out
>> new file mode 100644
>> index 000000000000..ce2de3f0d107
>> --- /dev/null
>> +++ b/tests/btrfs/172.out
>> @@ -0,0 +1,2 @@
>> +QA output created by 172
>> +Silence is golden
>> diff --git a/tests/btrfs/group b/tests/btrfs/group
>> index feffc45b6564..45782565c3b7 100644
>> --- a/tests/btrfs/group
>> +++ b/tests/btrfs/group
>> @@ -174,3 +174,4 @@
>>   169 auto quick send
>>   170 auto quick snapshot
>>   171 auto quick qgroup
>> +172 auto quick punch
>> --
>> 1.8.3.1
>>
> 
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3] test unaligned punch hole at ENOSPC
  2018-09-28 17:08 ` [PATCH v3] " Filipe Manana
  2018-09-28 17:12   ` Filipe Manana
@ 2018-09-30  0:57   ` Anand Jain
  1 sibling, 0 replies; 11+ messages in thread
From: Anand Jain @ 2018-09-30  0:57 UTC (permalink / raw)
  To: fdmanana; +Cc: fstests, linux-btrfs



On 09/29/2018 01:08 AM, Filipe Manana wrote:
> On Fri, Sep 28, 2018 at 3:51 PM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> Try to punch hole with unaligned size and offset when the FS
>> returns ENOSPC
> 
> The FS returns ENOSPC is confusing. It's more clear to say when the
> filesystem doesn't have more space available for data allocation.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> v2->v3:
>>   add _require_xfs_io_command "fpunch"
>>   add more logs to $seqfull.full
>>     mount options and
>>     group profile info
>>   add sync after dd upto ENOSPC
>>   drop fallocate -p and use xfs_io punch to create holes
>> v1->v2: Use at least 256MB to test.
>> This test case fails on btrfs as of now.
>>
>>   tests/btrfs/172     | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>>   tests/btrfs/172.out |  2 ++
>>   tests/btrfs/group   |  1 +
>>   3 files changed, 77 insertions(+)
>>   create mode 100755 tests/btrfs/172
>>   create mode 100644 tests/btrfs/172.out
>>
>> diff --git a/tests/btrfs/172 b/tests/btrfs/172
>> new file mode 100755
>> index 000000000000..59413a5de12f
>> --- /dev/null
>> +++ b/tests/btrfs/172
>> @@ -0,0 +1,74 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (c) 2018 Oracle. All Rights Reserved.
>> +#
>> +# FS QA Test 172
>> +#
>> +# Test if the unaligned (by size and offset) punch hole is successful when FS
>> +# is at ENOSPC.
>> +#
>> +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 -f $tmp.*
>> +}
>> +
>> +# get standard environment, filters and checks
>> +. ./common/rc
>> +. ./common/filter
>> +
>> +# remove previous $seqres.full before test
>> +rm -f $seqres.full
>> +
>> +# real QA test starts here
>> +
>> +# Modify as appropriate.
>> +_supported_fs btrfs
>> +_supported_os Linux
>> +_require_scratch
>> +_require_xfs_io_command "fpunch"
>> +
>> +_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
>> +
>> +# max_inline helps to create regular extent
> max_inline ensures data is not inlined within metadata extents

  Right. Hmm I saw the term regular extent used some where,
  so used it here. Looks that wasn't better?

>> +_scratch_mount "-o max_inline=0,nodatacow"
>> +
>> +cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
>> +$BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
>> +
>> +extent_size=$(_scratch_btrfs_sectorsize)
>> +unalign_by=512
>> +echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
>> +
>> +$XFS_IO_PROG -f -d -c "pwrite -S 0xab 0 $((extent_size * 10))" \
>> +                                       $SCRATCH_MNT/testfile >> $seqres.full
>> +
>> +echo "Fill fs upto ENOSPC" >> $seqres.full
> Fill all space available for data and all unallocated space.

  Will update comment. (I hope that's what you mean?)

>> +dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
> Why do you use dd here and not xfs_io?

  What I figured out xfs_io can't write until FS is full, as you need to
  specify the size for pwrite. OR did I miss something? I see some test
  cases just specify some arbitrary large number big enough than the FS.
  I didn't like that approach.

>> +sync
> Why is the sync needed?

  Yep not needed. Will remove in v6.

>> +
>> +hole_offset=0
>> +hole_len=$unalign_by
>> +$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
> 
> No need to pass -f anymore. No need for -d either.

  Ah. Thanks will fix in v6.

>> +
>> +hole_offset=$(($extent_size + $unalign_by))
>> +hole_len=$(($extent_size - $unalign_by))
>> +$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
> 
> No need to pass -f anymore. No need for -d either.

  Will fix in v6.

>> +
>> +hole_offset=$(($extent_size * 2 + $unalign_by))
>> +hole_len=$(($extent_size * 5))
>> +$XFS_IO_PROG -f -d -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
> 
> No need to pass -f anymore. No need for -d either.

  Got it.

Thanks, Anand

>> +
>> +# success, all done
>> +echo "Silence is golden"
>> +status=0
>> +exit
>> diff --git a/tests/btrfs/172.out b/tests/btrfs/172.out
>> new file mode 100644
>> index 000000000000..ce2de3f0d107
>> --- /dev/null
>> +++ b/tests/btrfs/172.out
>> @@ -0,0 +1,2 @@
>> +QA output created by 172
>> +Silence is golden
>> diff --git a/tests/btrfs/group b/tests/btrfs/group
>> index feffc45b6564..7e1a638ab7e1 100644
>> --- a/tests/btrfs/group
>> +++ b/tests/btrfs/group
>> @@ -174,3 +174,4 @@
>>   169 auto quick send
>>   170 auto quick snapshot
>>   171 auto quick qgroup
>> +172 auto quick
>> --
>> 1.8.3.1
>>
> 
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v6] test unaligned punch hole at ENOSPC
  2018-09-28 14:50 [PATCH v3] test unaligned punch hole at ENOSPC Anand Jain
                   ` (2 preceding siblings ...)
  2018-09-29  0:51 ` [PATCH v5] " Anand Jain
@ 2018-09-30  1:39 ` Anand Jain
  2018-10-05  7:50   ` Filipe Manana
  3 siblings, 1 reply; 11+ messages in thread
From: Anand Jain @ 2018-09-30  1:39 UTC (permalink / raw)
  To: fstests; +Cc: linux-btrfs

Try to punch hole with unaligned size and offset when the FS is
full. Mainly holes are punched at locations which are unaligned
with the file extent boundaries when the FS is full by data.
As the punching holes at unaligned location will involve
truncating blocks instead of just dropping the extents, it shall
involve reserving data and metadata space for delalloc and so data
alloc fails as the FS is full.

btrfs_punch_hole()
 btrfs_truncate_block()
   btrfs_check_data_free_space() <-- ENOSPC

We don't fail punch hole if the holes are aligned with the file
extent boundaries as it shall involve just dropping the related
extents, without truncating data extent blocks.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v5->v6:
 fix comments at two places in the test case
 drop -f when using xfs_io to punch hole
 sync after dd is dropped
 change log is slightly updated
v4->v5:
 Update the change log
 Drop the directio option for xfs_io
v3->v4:
 Add to the group punch
v2->v3:
 Add _require_xfs_io_command "fpunch"
 Add more logs to $seqfull.full
   mount options and
   group profile info
 Add sync after dd upto ENOSPC
 Drop fallocate -p and use xfs_io punch to create holes
 Use a testfile instead of filler file so that easy to trace
v1->v2: Use at least 256MB to test.
This test case fails on btrfs as of now.
 tests/btrfs/172     | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/172.out |  2 ++
 tests/btrfs/group   |  1 +
 3 files changed, 76 insertions(+)
 create mode 100755 tests/btrfs/172
 create mode 100644 tests/btrfs/172.out

diff --git a/tests/btrfs/172 b/tests/btrfs/172
new file mode 100755
index 000000000000..0dffb2dff40b
--- /dev/null
+++ b/tests/btrfs/172
@@ -0,0 +1,73 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2018 Oracle. All Rights Reserved.
+#
+# FS QA Test 172
+#
+# Test if the unaligned (by size and offset) punch hole is successful when FS
+# is at ENOSPC.
+#
+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 -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_xfs_io_command "fpunch"
+
+_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
+
+# max_inline ensures data is not inlined within metadata extents
+_scratch_mount "-o max_inline=0,nodatacow"
+
+cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
+$BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
+
+extent_size=$(_scratch_btrfs_sectorsize)
+unalign_by=512
+echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
+
+$XFS_IO_PROG -f -c "pwrite -S 0xab 0 $((extent_size * 10))" \
+					$SCRATCH_MNT/testfile >> $seqres.full
+
+echo "Fill all space available for data and all unallocated space." >> $seqres.full
+dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
+
+hole_offset=0
+hole_len=$unalign_by
+$XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
+
+hole_offset=$(($extent_size + $unalign_by))
+hole_len=$(($extent_size - $unalign_by))
+$XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
+
+hole_offset=$(($extent_size * 2 + $unalign_by))
+hole_len=$(($extent_size * 5))
+$XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
diff --git a/tests/btrfs/172.out b/tests/btrfs/172.out
new file mode 100644
index 000000000000..ce2de3f0d107
--- /dev/null
+++ b/tests/btrfs/172.out
@@ -0,0 +1,2 @@
+QA output created by 172
+Silence is golden
diff --git a/tests/btrfs/group b/tests/btrfs/group
index feffc45b6564..45782565c3b7 100644
--- a/tests/btrfs/group
+++ b/tests/btrfs/group
@@ -174,3 +174,4 @@
 169 auto quick send
 170 auto quick snapshot
 171 auto quick qgroup
+172 auto quick punch
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v6] test unaligned punch hole at ENOSPC
  2018-09-30  1:39 ` [PATCH v6] " Anand Jain
@ 2018-10-05  7:50   ` Filipe Manana
  0 siblings, 0 replies; 11+ messages in thread
From: Filipe Manana @ 2018-10-05  7:50 UTC (permalink / raw)
  To: Anand Jain; +Cc: fstests, linux-btrfs

On Sun, Sep 30, 2018 at 2:40 AM Anand Jain <anand.jain@oracle.com> wrote:
>
> Try to punch hole with unaligned size and offset when the FS is
> full. Mainly holes are punched at locations which are unaligned
> with the file extent boundaries when the FS is full by data.
> As the punching holes at unaligned location will involve
> truncating blocks instead of just dropping the extents, it shall
> involve reserving data and metadata space for delalloc and so data
> alloc fails as the FS is full.
>
> btrfs_punch_hole()
>  btrfs_truncate_block()
>    btrfs_check_data_free_space() <-- ENOSPC
>
> We don't fail punch hole if the holes are aligned with the file
> extent boundaries as it shall involve just dropping the related
> extents, without truncating data extent blocks.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>

Looks good, thanks!

> ---
> v5->v6:
>  fix comments at two places in the test case
>  drop -f when using xfs_io to punch hole
>  sync after dd is dropped
>  change log is slightly updated
> v4->v5:
>  Update the change log
>  Drop the directio option for xfs_io
> v3->v4:
>  Add to the group punch
> v2->v3:
>  Add _require_xfs_io_command "fpunch"
>  Add more logs to $seqfull.full
>    mount options and
>    group profile info
>  Add sync after dd upto ENOSPC
>  Drop fallocate -p and use xfs_io punch to create holes
>  Use a testfile instead of filler file so that easy to trace
> v1->v2: Use at least 256MB to test.
> This test case fails on btrfs as of now.
>  tests/btrfs/172     | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/172.out |  2 ++
>  tests/btrfs/group   |  1 +
>  3 files changed, 76 insertions(+)
>  create mode 100755 tests/btrfs/172
>  create mode 100644 tests/btrfs/172.out
>
> diff --git a/tests/btrfs/172 b/tests/btrfs/172
> new file mode 100755
> index 000000000000..0dffb2dff40b
> --- /dev/null
> +++ b/tests/btrfs/172
> @@ -0,0 +1,73 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (c) 2018 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 172
> +#
> +# Test if the unaligned (by size and offset) punch hole is successful when FS
> +# is at ENOSPC.
> +#
> +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 -f $tmp.*
> +}
> +
> +# get standard environment, filters and checks
> +. ./common/rc
> +. ./common/filter
> +
> +# remove previous $seqres.full before test
> +rm -f $seqres.full
> +
> +# real QA test starts here
> +
> +# Modify as appropriate.
> +_supported_fs btrfs
> +_supported_os Linux
> +_require_scratch
> +_require_xfs_io_command "fpunch"
> +
> +_scratch_mkfs_sized $((256 * 1024 *1024)) >> $seqres.full
> +
> +# max_inline ensures data is not inlined within metadata extents
> +_scratch_mount "-o max_inline=0,nodatacow"
> +
> +cat /proc/self/mounts | grep $SCRATCH_DEV >> $seqres.full
> +$BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT >> $seqres.full
> +
> +extent_size=$(_scratch_btrfs_sectorsize)
> +unalign_by=512
> +echo extent_size=$extent_size unalign_by=$unalign_by >> $seqres.full
> +
> +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 $((extent_size * 10))" \
> +                                       $SCRATCH_MNT/testfile >> $seqres.full
> +
> +echo "Fill all space available for data and all unallocated space." >> $seqres.full
> +dd status=none if=/dev/zero of=$SCRATCH_MNT/filler bs=512 >> $seqres.full 2>&1
> +
> +hole_offset=0
> +hole_len=$unalign_by
> +$XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
> +
> +hole_offset=$(($extent_size + $unalign_by))
> +hole_len=$(($extent_size - $unalign_by))
> +$XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
> +
> +hole_offset=$(($extent_size * 2 + $unalign_by))
> +hole_len=$(($extent_size * 5))
> +$XFS_IO_PROG -c "fpunch $hole_offset $hole_len" $SCRATCH_MNT/testfile
> +
> +# success, all done
> +echo "Silence is golden"
> +status=0
> +exit
> diff --git a/tests/btrfs/172.out b/tests/btrfs/172.out
> new file mode 100644
> index 000000000000..ce2de3f0d107
> --- /dev/null
> +++ b/tests/btrfs/172.out
> @@ -0,0 +1,2 @@
> +QA output created by 172
> +Silence is golden
> diff --git a/tests/btrfs/group b/tests/btrfs/group
> index feffc45b6564..45782565c3b7 100644
> --- a/tests/btrfs/group
> +++ b/tests/btrfs/group
> @@ -174,3 +174,4 @@
>  169 auto quick send
>  170 auto quick snapshot
>  171 auto quick qgroup
> +172 auto quick punch
> --
> 1.8.3.1
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-10-05  7:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-28 14:50 [PATCH v3] test unaligned punch hole at ENOSPC Anand Jain
2018-09-28 14:59 ` [PATCH v4] " Anand Jain
2018-09-28 17:08 ` [PATCH v3] " Filipe Manana
2018-09-28 17:12   ` Filipe Manana
2018-09-29  0:13     ` Anand Jain
2018-09-30  0:57   ` Anand Jain
2018-09-29  0:51 ` [PATCH v5] " Anand Jain
2018-09-29 16:40   ` Filipe Manana
2018-09-30  0:46     ` Anand Jain
2018-09-30  1:39 ` [PATCH v6] " Anand Jain
2018-10-05  7:50   ` Filipe Manana

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.