Page MenuHomeFreeBSD

D33785.diff
No OneTemporary

D33785.diff

diff --git a/sbin/ggate/ggated/Makefile b/sbin/ggate/ggated/Makefile
--- a/sbin/ggate/ggated/Makefile
+++ b/sbin/ggate/ggated/Makefile
@@ -6,7 +6,7 @@
MAN= ggated.8
SRCS= ggated.c ggate.c
-LIBADD= pthread util
+LIBADD= pthread util geom
CFLAGS+= -I${.CURDIR:H}/shared
diff --git a/sbin/ggate/ggated/ggated.c b/sbin/ggate/ggated/ggated.c
--- a/sbin/ggate/ggated/ggated.c
+++ b/sbin/ggate/ggated/ggated.c
@@ -46,6 +46,7 @@
#include <inttypes.h>
#include <fcntl.h>
#include <libgen.h>
+#include <libgeom.h>
#include <libutil.h>
#include <paths.h>
#include <pthread.h>
@@ -749,7 +750,8 @@
req->r_data = NULL;
break;
case GGATE_CMD_FLUSH:
- data = fsync(fd);
+ fsync(fd);
+ data = g_flush(fd);
if (data != 0)
req->r_error = errno;
break;
diff --git a/tests/sys/geom/class/gate/ggate_test.sh b/tests/sys/geom/class/gate/ggate_test.sh
--- a/tests/sys/geom/class/gate/ggate_test.sh
+++ b/tests/sys/geom/class/gate/ggate_test.sh
@@ -5,6 +5,48 @@
PORT=33080
CONF=gg.exports
+atf_test_case ggate_flush cleanup
+ggate_flush_head()
+{
+ atf_set "descr" "a flush on the ggatec side makes it all the way to ggated"
+ atf_set "require.progs" "ggatec ggated gnop"
+ atf_set "require.user" "root"
+ atf_set "timeout" 60
+}
+
+ggate_flush_body()
+{
+ load_ggate
+ us=$(alloc_ggate_dev)
+ md=$(alloc_md)
+ gnop create /dev/$md
+ echo "localhost RW /dev/$md.nop" > $CONF
+ atf_check ggated -p $PORT -F $PIDFILE $CONF
+ atf_check ggatec create -p $PORT -u $us localhost /dev/$md.nop
+
+ ggate_dev=/dev/ggate${us}
+ wait_for_ggate_device ${ggate_dev}
+ # trigger some flushing.
+ atf_check -s exit:0 -e ignore -o ignore zpool create testpool4ggateflush ${ggate_dev}
+
+ numflushes=$(gnop list /dev/$md.nop | grep Flushes | awk '{ print $2 }')
+
+ zpool destroy testpool4ggateflush
+ #gnop destroy /dev/$md.nop
+
+ if [ ${numflushes} -gt "0" ]
+ then
+ atf_pass
+ fi
+
+ atf_fail "No flushes arrived on ggated side"
+}
+
+ggate_flush_cleanup()
+{
+ common_cleanup
+}
+
atf_test_case ggatec_trim cleanup
ggatec_trim_head()
{
@@ -28,7 +70,7 @@
ggate_dev=/dev/ggate${us}
wait_for_ggate_device ${ggate_dev}
- # ggatec only supports read or write.
+ # ggatec only supports read, write or flush, but not trim (yet).
atf_check -s not-exit:0 -e ignore -o ignore trim -q -f ${ggate_dev}
}
@@ -55,10 +97,15 @@
work=$(alloc_md)
src=$(alloc_md)
+ # we are going to check whether copying data from $src into $work via
+ # $ggate_dev produces the same bytes (checksum).
+
+ # init target device $work (which is going to be wrapped as $ggate_dev)
+ # with garbage that's different from what we have in $src.
atf_check -e ignore -o ignore \
- dd if=/dev/random of=/dev/$work bs=1m count=1 conv=notrunc
+ dd if=/dev/random of=/dev/$work bs=1m count=64 conv=notrunc
atf_check -e ignore -o ignore \
- dd if=/dev/random of=/dev/$src bs=1m count=1 conv=notrunc
+ dd if=/dev/random of=/dev/$src bs=1m count=64 conv=notrunc
echo $CONF >> $PLAINFILES
echo "127.0.0.1 RW /dev/$work" > $CONF
@@ -70,8 +117,9 @@
wait_for_ggate_device ${ggate_dev}
+ # copy from $src into $work via $ggate_dev.
atf_check -e ignore -o ignore \
- dd if=/dev/${src} of=${ggate_dev} bs=1m count=1 conv=notrunc
+ dd if=/dev/${src} of=${ggate_dev} bs=1m count=64 conv=notrunc
checksum /dev/$src /dev/$work
}
@@ -135,9 +183,9 @@
src=$(alloc_md)
atf_check -e ignore -o ignore \
- dd if=/dev/random of=$work bs=1m count=1 conv=notrunc
+ dd if=/dev/random of=$work bs=1m count=64 conv=notrunc
atf_check -e ignore -o ignore \
- dd if=/dev/random of=$src bs=1m count=1 conv=notrunc
+ dd if=/dev/random of=$src bs=1m count=64 conv=notrunc
atf_check ggatel create -u $us /dev/$work
@@ -146,7 +194,7 @@
wait_for_ggate_device ${ggate_dev}
atf_check -e ignore -o ignore \
- dd if=/dev/$src of=${ggate_dev} bs=1m count=1 conv=notrunc
+ dd if=/dev/$src of=${ggate_dev} bs=1m count=64 conv=notrunc
checksum /dev/$src /dev/$work
}
@@ -162,6 +210,7 @@
atf_add_test_case ggatel_file
atf_add_test_case ggatel_md
atf_add_test_case ggatec_trim
+ atf_add_test_case ggate_flush
}
alloc_ggate_dev()
@@ -180,7 +229,7 @@
{
local md
- md=$(mdconfig -a -t malloc -s 1M) || \
+ md=$(mdconfig -a -t malloc -s 64M) || \
atf_fail "failed to allocate md device"
echo ${md} >> md.devs
echo ${md}

File Metadata

Mime Type
text/plain
Expires
Mon, Feb 9, 2:34 AM (22 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28527071
Default Alt Text
D33785.diff (4 KB)

Event Timeline