Skip to contentSkip to conversation

xfstests: test writing to device node on an RO filesystem

PATCH In review Eric Sandeen 5 participants 9 messages Mar 14, 2013 – Mar 15, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfstests: test writing to device node on an RO filesystem

we should be able to open device nodes for writing even if they live on a readonly filesytem.

---

(I may have *cough* broken this on a backport once, hence the test)

315 new file +79 -0
new file mode 100755
index 0000000..8b8ecc6
@@ -0,0 +1,79 @@
+#! /bin/bash
+# FS QA Test No. 315
+#
+# Test that we can write to a device node residing on a RO filesystem
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2013 Red Hat, Inc.  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
+#-----------------------------------------------------------------------
+#
+# creator
[email protected]	
+
+seq=`basename $0`
+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
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+
+DEVNULL=$SCRATCH_MNT/devnull
+DEVZERO=$SCRATCH_MNT/devzero
+
+_scratch_mount
+
+rm -f $DEVNULL $DEVZERO
+
+mknod $DEVNULL c 1 3 || _fail "Could not create devnull device"
+mknod $DEVZERO c 1 5 || _fail "Could not create devzero device"
+
+_scratch_unmount || _fail "Could not unmount scratch device"
+_scratch_mount -o ro || _fail "Could not remount scratch readonly"
+
+# We should be able to read & write to/from these devices even on an RO fs
+echo "== try to create new file"
+touch $SCRATCH_MNT/this_should_fail 2>&1 | _filter_scratch
+echo "== prite to null device"
+xfs_io -c "pwrite 0 512" /dev/null | _filter_xfs_io
+echo "== pread from zero device"
+xfs_io -c "pread 0 512" /dev/zero | _filter_xfs_io
+
+echo "== truncating write to null device"
+echo foo >> $DEVNULL 2>&1 | _filter_scratch
+echo "== appending write to null device"
+echo foo >> $DEVNULL 2>&1 | _filter_scratch
+
+# success, all done
+status=0
+exit
315.out new file +11 -0
new file mode 100644
index 0000000..d07c567
@@ -0,0 +1,11 @@
+QA output created by 315
+== try to create new file
+touch: cannot touch `SCRATCH_MNT/this_should_fail': Read-only file system
+== prite to null device
+wrote 512/512 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+== pread from zero device
+read 512/512 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+== truncating write to null device
+== appending write to null device
group +1 -0
index fcbdfb6..fd838ef 100644
@@ -430,3 +430,4 @@ stress
 305 aio dangerous enospc rw stress
 313 auto quick
 314 auto
+315 auto rw

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw

Am Donnerstag, 14. März 2013 schrieb Eric Sandeen:

Quoted 2 lines

we should be able to open device nodes for writing even if they live on a readonly filesytem.

Just saw a typo. See below.

Quoted 76 lines

---

(I may have *cough* broken this on a backport once, hence the test)

315 new file +64 -0
new file mode 100755
index 0000000..8b8ecc6
@@ -0,0 +1,79 @@
+#! /bin/bash
+# FS QA Test No. 315
+#
+# Test that we can write to a device node residing on a RO filesystem
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2013 Red Hat, Inc.  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
+#-----------------------------------------------------------------------
+#
+# creator
[email protected]
+
+seq=`basename $0`
+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
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+
+DEVNULL=$SCRATCH_MNT/devnull
+DEVZERO=$SCRATCH_MNT/devzero
+
+_scratch_mount
+
+rm -f $DEVNULL $DEVZERO
+
+mknod $DEVNULL c 1 3 || _fail "Could not create devnull device"
+mknod $DEVZERO c 1 5 || _fail "Could not create devzero device"
+
+_scratch_unmount || _fail "Could not unmount scratch device"
+_scratch_mount -o ro || _fail "Could not remount scratch readonly"
+
+# We should be able to read & write to/from these devices even on an RO

fs +echo "== try to create new file"

315 line 67

Quoted 2 lines
315 new file +2 -0
+touch $SCRATCH_MNT/this_should_fail 2>&1 | _filter_scratch
+echo "== prite to null device"

prite => pwrite

Quoted 34 lines
315 new file +12 -0
+xfs_io -c "pwrite 0 512" /dev/null | _filter_xfs_io
+echo "== pread from zero device"
+xfs_io -c "pread 0 512" /dev/zero | _filter_xfs_io
+
+echo "== truncating write to null device"
+echo foo >> $DEVNULL 2>&1 | _filter_scratch
+echo "== appending write to null device"
+echo foo >> $DEVNULL 2>&1 | _filter_scratch
+
+# success, all done
+status=0
+exit
315.out new file +3 -0
new file mode 100644
index 0000000..d07c567
@@ -0,0 +1,11 @@
+QA output created by 315
+== try to create new file
+touch: cannot touch `SCRATCH_MNT/this_should_fail': Read-only file

system +== prite to null device

315.out new file +7 -0
+wrote 512/512 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+== pread from zero device
+read 512/512 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+== truncating write to null device
+== appending write to null device
group +0 -0
index fcbdfb6..fd838ef 100644

group stress · line 433

Quoted 4 lines
group +1 -0
@@ -430,3 +430,4 @@ stress
 305 aio dangerous enospc rw stress
 313 auto quick
 314 auto
+315 auto rw

Thanks,

Signature · 7 lines
Martin 'Helios' Steigerwald - http://www.Lichtvoll.de
GPG: 03B0 0D6C 0040 0710 4AFA  B82F 991B EAAC A599 84C7

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#2 lore raw
Quoted 5 lines · Martin Steigerwald

Am Donnerstag, 14. März 2013 schrieb Eric Sandeen:

Quoted 2 lines

we should be able to open device nodes for writing even if they live on a readonly filesytem.

Just saw a typo. See below.

Just informational ;) Ok, I can fix it up unless SGI just does it on merge.

Thanks,
-Eric

Quoted 113 lines
Quoted 76 lines

---

(I may have *cough* broken this on a backport once, hence the test)

315 new file +64 -0
new file mode 100755
index 0000000..8b8ecc6
@@ -0,0 +1,79 @@
+#! /bin/bash
+# FS QA Test No. 315
+#
+# Test that we can write to a device node residing on a RO filesystem
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2013 Red Hat, Inc.  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
+#-----------------------------------------------------------------------
+#
+# creator
[email protected]
+
+seq=`basename $0`
+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
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+
+DEVNULL=$SCRATCH_MNT/devnull
+DEVZERO=$SCRATCH_MNT/devzero
+
+_scratch_mount
+
+rm -f $DEVNULL $DEVZERO
+
+mknod $DEVNULL c 1 3 || _fail "Could not create devnull device"
+mknod $DEVZERO c 1 5 || _fail "Could not create devzero device"
+
+_scratch_unmount || _fail "Could not unmount scratch device"
+_scratch_mount -o ro || _fail "Could not remount scratch readonly"
+
+# We should be able to read & write to/from these devices even on an RO

fs +echo "== try to create new file"

315 line 67

Quoted 2 lines
315 new file +2 -0
+touch $SCRATCH_MNT/this_should_fail 2>&1 | _filter_scratch
+echo "== prite to null device"

prite => pwrite

Quoted 32 lines
315 new file +12 -0
+xfs_io -c "pwrite 0 512" /dev/null | _filter_xfs_io
+echo "== pread from zero device"
+xfs_io -c "pread 0 512" /dev/zero | _filter_xfs_io
+
+echo "== truncating write to null device"
+echo foo >> $DEVNULL 2>&1 | _filter_scratch
+echo "== appending write to null device"
+echo foo >> $DEVNULL 2>&1 | _filter_scratch
+
+# success, all done
+status=0
+exit
315.out new file +3 -0
new file mode 100644
index 0000000..d07c567
@@ -0,0 +1,11 @@
+QA output created by 315
+== try to create new file
+touch: cannot touch `SCRATCH_MNT/this_should_fail': Read-only file

system +== prite to null device

315.out new file +7 -0
+wrote 512/512 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+== pread from zero device
+read 512/512 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+== truncating write to null device
+== appending write to null device
group +0 -1
index fcbdfb6..fd838ef 100644
--- a/group
Quoted 9 lines

group stress · line 433

Quoted 6 lines

+++ b/group

group +1 -0
@@ -430,3 +430,4 @@ stress
 305 aio dangerous enospc rw stress
 313 auto quick
 314 auto
+315 auto rw

Thanks,

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw
In reply to Eric Sandeen
Quoted 58 lines · Eric Sandeen

we should be able to open device nodes for writing even if they live on a readonly filesytem.

---

(I may have *cough* broken this on a backport once, hence the test)

315 new file +44 -0
new file mode 100755
index 0000000..8b8ecc6
@@ -0,0 +1,79 @@
+#! /bin/bash
+# FS QA Test No. 315
+#
+# Test that we can write to a device node residing on a RO filesystem
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2013 Red Hat, Inc.  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
+#-----------------------------------------------------------------------
+#
+# creator
[email protected]	
+
+seq=`basename $0`
+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
+
+# real QA test starts here

315 line 54

Quoted 10 lines
315 new file +10 -0
+
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+
+DEVNULL=$SCRATCH_MNT/devnull
+DEVZERO=$SCRATCH_MNT/devzero
+
+_scratch_mount

You need to _scratch_mkfs first.

Quoted 5 lines
315 new file +5 -0
+rm -f $DEVNULL $DEVZERO
+
+mknod $DEVNULL c 1 3 || _fail "Could not create devnull device"
+mknod $DEVZERO c 1 5 || _fail "Could not create devzero device"
+

315 line 70

Quoted 10 lines
315 new file +10 -0
+_scratch_unmount || _fail "Could not unmount scratch device"
+_scratch_mount -o ro || _fail "Could not remount scratch readonly"
+
+# We should be able to read & write to/from these devices even on an RO fs
+echo "== try to create new file"
+touch $SCRATCH_MNT/this_should_fail 2>&1 | _filter_scratch
+echo "== prite to null device"
+xfs_io -c "pwrite 0 512" /dev/null | _filter_xfs_io
+echo "== pread from zero device"
+xfs_io -c "pread 0 512" /dev/zero | _filter_xfs_io

$XFS_IO_PROG

Yeah, I know, we don't do that in lots of places, but we should change them all to the Proper Way....

315 line 73

Quoted 3 lines
315 new file +3 -0
+
+echo "== truncating write to null device"
+echo foo >> $DEVNULL 2>&1 | _filter_scratch

That doesn't truncate.

-Dave.

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#4 lore raw

PATCH v2 1/1 xfstests: test writing to device node on an RO filesystem

In reply to Eric Sandeen

We should be able to open device nodes for writing even if they live on a readonly filesytem.

---

V2: fix typos, use XFS_IO_PROG, fix c&p error on echo, remember _scratch_mkfs

315 new file +81 -0
new file mode 100755
index 0000000..0443d9f
@@ -0,0 +1,81 @@
+#! /bin/bash
+# FS QA Test No. 315
+#
+# Test RW open of a device on a RO fs
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2013 Red Hat, Inc.  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
+#-----------------------------------------------------------------------
+#
+# creator
[email protected]	
+
+seq=`basename $0`
+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
+
+# real QA test starts here
+
+# Modify as appropriate.
+_supported_fs generic
+_supported_os Linux
+_require_scratch
+
+DEVNULL=$SCRATCH_MNT/devnull
+DEVZERO=$SCRATCH_MNT/devzero
+
+rm -f $seq.full
+_scratch_mkfs > $seq.full 2>&1
+_scratch_mount
+
+rm -f $DEVNULL $DEVZERO
+
+mknod $DEVNULL c 1 3 || _fail "Could not create devnull device"
+mknod $DEVZERO c 1 5 || _fail "Could not create devzero device"
+
+_scratch_unmount || _fail "Could not unmount scratch device"
+_scratch_mount -o ro || _fail "Could notemount scratch readonly"
+
+# We should be able to read & write to/from these devices even on an RO fs
+echo "== try to create new file"
+touch $SCRATCH_MNT/this_should_fail 2>&1 | _filter_scratch
+echo "== pwrite to null device"
+$XFS_IO_PROG -c "pwrite 0 512" /dev/null | _filter_xfs_io
+echo "== pread from zero device"
+$XFS_IO_PROG -c "pread 0 512" /dev/zero | _filter_xfs_io
+
+echo "== truncating write to null device"
+echo foo > $DEVNULL 2>&1 | _filter_scratch
+echo "== appending write to null device"
+echo foo >> $DEVNULL 2>&1 | _filter_scratch
+
+# success, all done
+status=0
+exit
315.out new file +11 -0
new file mode 100644
index 0000000..19791ed
@@ -0,0 +1,11 @@
+QA output created by 315
+== try to create new file
+touch: cannot touch `SCRATCH_MNT/this_should_fail': Read-only file system
+== pwrite to null device
+wrote 512/512 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+== pread from zero device
+read 512/512 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+== truncating write to null device
+== appending write to null device
group +1 -0
index fcbdfb6..1c53068 100644
@@ -423,3 +423,4 @@ stress
 305 aio dangerous enospc rw stress
 313 auto quick
 314 auto
+315 auto rw

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by on v2 1/1
#5 lore raw
Quoted 5 lines · Eric Sandeen

We should be able to open device nodes for writing even if they live on a readonly filesytem.

---

looks ok except for one thing - it should be part of the quick group....

Signature · 7 lines
Dave Chinner
[email protected]

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v2 1/1
#6 lore raw
In reply to Eric Sandeen

Eric,

Thanks again for the new test. A few minor issues that can be corrected at commit time.

I can correct this a commit time.

quilt refresh
Warning: trailing whitespace in line 24 of 306
Refreshed patch patches/V2-xfstests-test-writing-to-device-node-on-an-RO-filesystem.patch

Do you also want me to add this top the quick group as Dave suggested when I commit this?

Thanks
--Rich

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#7 lore raw
Quoted 6 lines · Rich Johnston

Eric,

Thanks again for the new test. A few minor issues that can be corrected at commit time.

Quoted 7 lines

I can correct this a commit time.

quilt refresh
Warning: trailing whitespace in line 24 of 306
Refreshed patch patches/V2-xfstests-test-writing-to-device-node-on-an-RO-filesystem.patch

Do you also want me to add this top the quick group as Dave suggested when I commit this?

Sure, thanks for that, and sorry my patches always seem so sloppy. I mean well, and I try. I'll try harder. ;)

-Eric

Quoted 5 lines

Thanks
--Rich

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

Reviewed-by Dave Chinner Reviewed-by
#8 lore raw
Quoted 9 lines · Eric Sandeen
Quoted 8 lines · Rich Johnston

Eric,

Thanks again for the new test. A few minor issues that can be corrected at commit time.

I can correct this a commit time.

Quoted 7 lines
Quoted 5 lines

quilt refresh
Warning: trailing whitespace in line 24 of 306
Refreshed patch patches/V2-xfstests-test-writing-to-device-node-on-an-RO-filesystem.patch

Do you also want me to add this top the quick group as Dave suggested when I commit this?

Sure, thanks for that, and sorry my patches always seem so sloppy. I mean well, and I try. I'll try harder. ;)

Hehe no worries.

Quoted 9 lines

-Eric

Quoted 5 lines

Thanks
--Rich

This has been commited (with the correct test number this time ;) )

Thanks
--Rich

commit f835afd3f0f2bab78b5b303744bb9ad441276c02

Author: Eric Sandeen <[email protected]>
Date:   Fri Mar 15 02:37:34 2013 +0000

xfstests: test writing to device node on an RO filesystem

We should be able to open device nodes for writing even if they live on a readonly filesytem.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs