Skip to contentSkip to conversation

Add lease testing

RFC PATCH Superseded [email protected] 3 participants 7 messages Sep 3, 2019 – Sep 5, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Add lease testing

From: Ira Weiny <[email protected]>

To get to a point of developing and testing the new Lease semantics for long term file pins[1], add a simple lease test.

Currently the following tests are performed based on the fcntl() man page.

    /*  1 */"Take Read Lease",
    /*  2 */"Take Write Lease",
    /*  3 */"Fail Write Lease if file is open somewhere else",
    /*  4 */"Fail Read Lease if opened with write permissions",
    /*  5 */"Read lease gets SIGIO on write open",
    /*  6 */"Write lease gets SIGIO on read open",

[1] https://lkml.org/lkml/2019/8/14/435

Ira Weiny (2):
src/leasetest: Add lease test executable
generic: Add Lease testing

 src/Makefile          |   2 +-
 src/leasetest.c       | 837 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/567     | 100 +++++
 tests/generic/567.out |   2 +
 tests/generic/group   |   1 +
 5 files changed, 941 insertions(+), 1 deletion(-)
 create mode 100644 src/leasetest.c
 create mode 100755 tests/generic/567
 create mode 100644 tests/generic/567.out
Signature · 1 line
2.20.1
#1 lore raw

RFC PATCH 1/2 src/leasetest: Add lease test executable

From: Ira Weiny <[email protected]>

locktest uses a pattern which is suitable for lease testing so this patch copies locktest as a framework and modifies it for lease testing.

Initial tests are built based on the existing fcntl() man page declared functionality.

---
 src/Makefile    |   2 +-
 src/leasetest.c | 837 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 838 insertions(+), 1 deletion(-)
 create mode 100644 src/leasetest.c
src/Makefile +1 -1
index c4fcf370431f..c34b4add6695 100644
@@ -28,7 +28,7 @@ LINUX_TARGETS = xfsctl bstat t_mtab getdevicesize preallo_rw_pattern_reader \
 	attr-list-by-handle-cursor-test listxattr dio-interleaved t_dir_type \
 	dio-invalidate-cache stat_test t_encrypted_d_revalidate \
 	attr_replace_test swapon mkswap t_attr_corruption t_open_tmpfiles \
-	fscrypt-crypt-util bulkstat_null_ocount
+	fscrypt-crypt-util bulkstat_null_ocount leasetest
 
 SUBDIRS = log-writes perf
 
src/leasetest.c new file +837 -0

837 lines not on this page · raw message

Signature · 1 line
2.20.1
#2 lore raw

RFC PATCH 2/2 generic: Add Lease testing

In reply to [email protected]

From: Ira Weiny <[email protected]>

Now that we have a leasetest executable add in a lease test script.

---
 tests/generic/567     | 100 ++++++++++++++++++++++++++++++++++++++++++
 tests/generic/567.out |   2 +
 tests/generic/group   |   1 +
 3 files changed, 103 insertions(+)
 create mode 100755 tests/generic/567
 create mode 100644 tests/generic/567.out
tests/generic/567 new file +100 -0
new file mode 100755
index 000000000000..3ef99c66b207
@@ -0,0 +1,100 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Intel Corp.  All Rights Reserved.
+#
+# FS QA Test 567
+#
+# Test Leases
+#
+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
+#debug="-d -d -d"
+debug=""
+
+TESTFILE=$TEST_DIR/lease_file
+
+_cleanup()
+{
+	kill $leasetest_pid2 > /dev/null 2>&1
+	kill $leasetest_pid1 > /dev/null 2>&1
+	rm -f $TESTFILE
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs generic
+_supported_os Linux
+_require_test
+_require_test_fcntl_advisory_locks
+
+# set up log files
+SERVER_LOG=$TEST_DIR/server.out
+CLIENT_LOG=$TEST_DIR/client.out
+rm -f $SERVER_LOG
+touch $SERVER_LOG
+rm -f $CLIENT_LOG
+touch $CLIENT_LOG
+
+if [ "$debug" != "" ]; then
+	echo "Test directory : $TEST_DIR"
+	echo "Result directory : $RESULT_DIR"
+	echo "Client log : $CLIENT_LOG"
+	echo "Server log : $SERVER_LOG"
+fi
+
+touch $TESTFILE
+
+# Start the server
+src/leasetest $debug $TESTFILE 2>&1 > $SERVER_LOG &
+leasetest_pid1=$!
+
+timeout=30
+while [ $timeout -gt 0 ]; do
+	sleep 1
+
+	PORT=$(cat $SERVER_LOG | grep "^server port: " | awk '{print $3}')
+	if [ -n "$PORT" ]; then
+		break
+	fi
+
+	# check the existence of server process
+	if ! kill -s 0 $leasetest_pid1 >/dev/null 2>&1; then
+		echo "Server died abnormally"
+		exit 1
+	fi
+
+	let timeout=timeout-1
+done
+
+if [ -z "$PORT" ]; then
+	echo "Could not get server port"
+	exit 1
+fi
+
+# Start the client
+src/leasetest $debug -p $PORT -h localhost $TESTFILE 2>&1 > $CLIENT_LOG
+leasetest_pid2=$!
+result=$?
+if [ $result -eq 0 ]; then
+	echo success!
+	status=0
+else
+	echo "Client reported failure ($result)"
+	cat $TEST_DIR/*.out
+fi
+
+if [ "$debug" != "" ]; then
+	echo "End file details"
+	ls -la $TESTFILE
+fi
+
+exit
tests/generic/567.out new file +2 -0
new file mode 100644
index 000000000000..dada957258fc
@@ -0,0 +1,2 @@
+QA output created by 567
+success!
tests/generic/group +1 -0
index d26c080fde30..1a48c93ff3bb 100644
@@ -569,3 +569,4 @@
 564 auto quick copy_range
 565 auto quick copy_range
 566 auto quick quota metadata
+567 auto quick locks
Signature · 1 line
2.20.1
#3 lore raw
In reply to [email protected]
Quoted 4 lines · On Tue, Sep 03, 2019 at 02:05:35PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

To get to a point of developing and testing the new Lease semantics for long term file pins[1], add a simple lease test.

Hi Ira,

Can you co-ordinate with Jeff on this? He just posted a patch to add F_SETLEASE testing with a new binary a few days ago...

https://marc.info/?l=fstests&m=156690934513424&w=2

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]
author
#4 lore raw
Quoted 6 lines · Dave Chinner
Quoted 4 lines · On Tue, Sep 03, 2019 at 02:05:35PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

To get to a point of developing and testing the new Lease semantics for long term file pins[1], add a simple lease test.

Quoted 7 lines

Hi Ira,

Can you co-ordinate with Jeff on this? He just posted a patch to add F_SETLEASE testing with a new binary a few days ago...

https://marc.info/?l=fstests&m=156690934513424&w=2

Sure.

Jeff,

Looking at your submission revealed I was missing 2 tests (shown in the diff below).

Would it be sufficient to add these to this submission and go with my series? Or would you prefer using fork vs the socket harness?

I think we may need a fork in the server side of my tests to work on duplicated FD's but right now I have more tests than you.

Let me know, Thanks,
Ira

commit 849633871b7c0b00a6ee2bb751c09cd6365da386 (lease-test-b0-v3)

Author: Ira Weiny <[email protected]>
Date:   Tue Sep 3 15:17:52 2019 -0700

src/leasetest: Add tests to match competing test

A competing patch to test leases was submitted in parallel.[1]

This adds tests which were covered in that patch set.

[1] https://marc.info/?l=fstests&m=156690934513424&w=2

src/leasetest.c +22 -0
index b30a4d05d039..729aca851493 100644
@@ -137,6 +137,8 @@ char *descriptions[] = {
     /*  4 */"Fail Read Lease if opened with write permissions",
     /*  5 */"Read lease gets SIGIO on write open",
     /*  6 */"Write lease gets SIGIO on read open",
+    /*  7 */"No SIGIO is sent with read lock on read open",
+    /*  8 */"Read lease gets SIGIO on write open",
 };
 
 static int64_t tests[][5] =
@@ -195,6 +197,26 @@ static int64_t tests[][5] =
                {6,     CMD_CLOSE,      0,              PASS,           SERVER  },
                {6,     CMD_CLOSE,      0,              PASS,           CLIENT  },
 
+       /* Don't get SIGIO when read lease is taken by read */
+               {7,     CMD_OPEN,       O_RDONLY,       PASS,           CLIENT  },
+               {7,     CMD_SETLEASE,   F_RDLCK,        PASS,           CLIENT  },
+               {7,     CMD_GETLEASE,   F_RDLCK,        PASS,           CLIENT  },
+               {7,     CMD_SIGIO,      0,              PASS,           CLIENT  },
+               {7,     CMD_OPEN,       O_RDONLY,       PASS,           SERVER  },
+               {7,     CMD_WAIT_SIGIO, 5,              FAIL,           CLIENT  },
+               {7,     CMD_CLOSE,      0,              PASS,           SERVER  },
+               {7,     CMD_CLOSE,      0,              PASS,           CLIENT  },
+
+       /* Get SIGIO when Read lease is broken by Write */
+               {8,     CMD_OPEN,       O_RDONLY,       PASS,           CLIENT  },
+               {8,     CMD_SETLEASE,   F_RDLCK,        PASS,           CLIENT  },
+               {8,     CMD_GETLEASE,   F_RDLCK,        PASS,           CLIENT  },
+               {8,     CMD_SIGIO,      0,              PASS,           CLIENT  },
+               {8,     CMD_OPEN,       O_RDWR,         PASS,           SERVER  },
+               {8,     CMD_WAIT_SIGIO, 5,              PASS,           CLIENT  },
+               {8,     CMD_CLOSE,      0,              PASS,           SERVER  },
+               {8,     CMD_CLOSE,      0,              PASS,           CLIENT  },
+
        /* indicate end of array */
        /* Must have an end for the SERVER and one for the CLIENT */
                {0,0,0,0,SERVER},
Acked-by
#5 lore raw
Quoted 75 lines · Ira Weiny
Quoted 6 lines · Dave Chinner
Quoted 4 lines · On Tue, Sep 03, 2019 at 02:05:35PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

To get to a point of developing and testing the new Lease semantics for long term file pins[1], add a simple lease test.

Quoted 7 lines

Hi Ira,

Can you co-ordinate with Jeff on this? He just posted a patch to add F_SETLEASE testing with a new binary a few days ago...

https://marc.info/?l=fstests&m=156690934513424&w=2

Sure.

Jeff,

Looking at your submission revealed I was missing 2 tests (shown in the diff below).

Would it be sufficient to add these to this submission and go with my series? Or would you prefer using fork vs the socket harness?

I think we may need a fork in the server side of my tests to work on duplicated FD's but right now I have more tests than you.

Let me know, Thanks,
Ira

commit 849633871b7c0b00a6ee2bb751c09cd6365da386 (lease-test-b0-v3)

Author: Ira Weiny <[email protected]>
Date:   Tue Sep 3 15:17:52 2019 -0700

src/leasetest: Add tests to match competing test

A competing patch to test leases was submitted in parallel.[1]

This adds tests which were covered in that patch set.

[1] https://marc.info/?l=fstests&m=156690934513424&w=2

src/leasetest.c +15 -0
index b30a4d05d039..729aca851493 100644
@@ -137,6 +137,8 @@ char *descriptions[] = {
     /*  4 */"Fail Read Lease if opened with write permissions",
     /*  5 */"Read lease gets SIGIO on write open",
     /*  6 */"Write lease gets SIGIO on read open",
+    /*  7 */"No SIGIO is sent with read lock on read open",
+    /*  8 */"Read lease gets SIGIO on write open",
 };
 
 static int64_t tests[][5] =
@@ -195,6 +197,26 @@ static int64_t tests[][5] =
                {6,     CMD_CLOSE,      0,              PASS,           SERVER  },
                {6,     CMD_CLOSE,      0,              PASS,           CLIENT  },
 
+       /* Don't get SIGIO when read lease is taken by read */
+               {7,     CMD_OPEN,       O_RDONLY,       PASS,           CLIENT  },
+               {7,     CMD_SETLEASE,   F_RDLCK,        PASS,           CLIENT  },
+               {7,     CMD_GETLEASE,   F_RDLCK,        PASS,           CLIENT  },
+               {7,     CMD_SIGIO,      0,              PASS,           CLIENT  },
+               {7,     CMD_OPEN,       O_RDONLY,       PASS,           SERVER  },
+               {7,     CMD_WAIT_SIGIO, 5,              FAIL,           CLIENT  },
+               {7,     CMD_CLOSE,      0,              PASS,           SERVER  },
+               {7,     CMD_CLOSE,      0,              PASS,           CLIENT  },
+
+       /* Get SIGIO when Read lease is broken by Write */
+               {8,     CMD_OPEN,       O_RDONLY,       PASS,           CLIENT  },
+               {8,     CMD_SETLEASE,   F_RDLCK,        PASS,           CLIENT  },

src/leasetest.c static int64_t tests[][5] = · line 222

Quoted 10 lines
src/leasetest.c +7 -0
+               {8,     CMD_GETLEASE,   F_RDLCK,        PASS,           CLIENT  },
+               {8,     CMD_SIGIO,      0,              PASS,           CLIENT  },
+               {8,     CMD_OPEN,       O_RDWR,         PASS,           SERVER  },
+               {8,     CMD_WAIT_SIGIO, 5,              PASS,           CLIENT  },
+               {8,     CMD_CLOSE,      0,              PASS,           SERVER  },
+               {8,     CMD_CLOSE,      0,              PASS,           CLIENT  },
+
        /* indicate end of array */
        /* Must have an end for the SERVER and one for the CLIENT */
                {0,0,0,0,SERVER},

Hi Ira,

Let's go with your testcase, including the patch above. It's more comprehensive than the one I proposed, and should be easier to extend in the future.

author
#6 lore raw
Quoted 91 lines

Subject: Re: [RFC PATCH 0/2] Add lease testing

Quoted 14 lines · Ira Weiny
Quoted 6 lines · Dave Chinner
Quoted 4 lines · On Tue, Sep 03, 2019 at 02:05:35PM -0700, [email protected] wrote:

From: Ira Weiny <[email protected]>

To get to a point of developing and testing the new Lease semantics for long term file pins[1], add a simple lease test.

Quoted 6 lines

Hi Ira,

Can you co-ordinate with Jeff on this? He just posted a patch to add F_SETLEASE testing with a new binary a few days ago...

https://marc.info/?l=fstests&m=156690934513424&w=2

Quoted 8 lines

Sure.

Jeff,

Looking at your submission revealed I was missing 2 tests (shown in the diff below).

Would it be sufficient to add these to this submission and go with my

series?

Quoted 52 lines

Or would you prefer using fork vs the socket harness?

I think we may need a fork in the server side of my tests to work on duplicated FD's but right now I have more tests than you.

Let me know, Thanks,
Ira

commit 849633871b7c0b00a6ee2bb751c09cd6365da386 (lease-test-b0-v3)

Author: Ira Weiny <[email protected]>
Date:   Tue Sep 3 15:17:52 2019 -0700

src/leasetest: Add tests to match competing test

A competing patch to test leases was submitted in parallel.[1]

This adds tests which were covered in that patch set.

[1] https://marc.info/?l=fstests&m=156690934513424&w=2

src/leasetest.c index renamed from src/leasetest.c +0 -0

b30a4d05d039..729aca851493 100644

src/leasetest.c +15 -0
@@ -137,6 +137,8 @@ char *descriptions[] = {
     /*  4 */"Fail Read Lease if opened with write permissions",
     /*  5 */"Read lease gets SIGIO on write open",
     /*  6 */"Write lease gets SIGIO on read open",
+    /*  7 */"No SIGIO is sent with read lock on read open",
+    /*  8 */"Read lease gets SIGIO on write open",
 };
 
 static int64_t tests[][5] =
@@ -195,6 +197,26 @@ static int64_t tests[][5] =
                {6,     CMD_CLOSE,      0,              PASS,           SERVER  },
                {6,     CMD_CLOSE,      0,              PASS,           CLIENT  },
 
+       /* Don't get SIGIO when read lease is taken by read */
+               {7,     CMD_OPEN,       O_RDONLY,       PASS,           CLIENT  },
+               {7,     CMD_SETLEASE,   F_RDLCK,        PASS,           CLIENT  },
+               {7,     CMD_GETLEASE,   F_RDLCK,        PASS,           CLIENT  },
+               {7,     CMD_SIGIO,      0,              PASS,           CLIENT  },
+               {7,     CMD_OPEN,       O_RDONLY,       PASS,           SERVER  },
+               {7,     CMD_WAIT_SIGIO, 5,              FAIL,           CLIENT  },
+               {7,     CMD_CLOSE,      0,              PASS,           SERVER  },
+               {7,     CMD_CLOSE,      0,              PASS,           CLIENT  },
+
+       /* Get SIGIO when Read lease is broken by Write */
+               {8,     CMD_OPEN,       O_RDONLY,       PASS,           CLIENT  },
+               {8,     CMD_SETLEASE,   F_RDLCK,        PASS,           CLIENT  },

src/leasetest.c static int64_t tests[][5] = · line 222

Quoted 10 lines
src/leasetest.c +7 -0
+               {8,     CMD_GETLEASE,   F_RDLCK,        PASS,           CLIENT  },
+               {8,     CMD_SIGIO,      0,              PASS,           CLIENT  },
+               {8,     CMD_OPEN,       O_RDWR,         PASS,           SERVER  },
+               {8,     CMD_WAIT_SIGIO, 5,              PASS,           CLIENT  },
+               {8,     CMD_CLOSE,      0,              PASS,           SERVER  },
+               {8,     CMD_CLOSE,      0,              PASS,           CLIENT  },
+
        /* indicate end of array */
        /* Must have an end for the SERVER and one for the CLIENT */
                {0,0,0,0,SERVER},

Hi Ira,

Quoted 5 lines

Let's go with your testcase, including the patch above. It's more comprehensive than the one I proposed, and should be easier to extend in the future.

Thanks! Give me a bit and I will submit V2 with this squashed into the original patch. I did some cleanup of locktest but other than that leasetest is pretty much a copy. Not sure if the community would like to see more changes or not.

Ira