mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
QA test to exercise unwritten extent conversion for sync direct I/O
Merge of master-melb:xfs-cmds:28769a by kenmcd. QA test to exercise unwritten extent conversion for sync direct I/O.
This commit is contained in:
@@ -0,0 +1,65 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
# FSQA Test No. 167
|
||||||
|
#
|
||||||
|
# unwritten extent conversion test
|
||||||
|
#
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright (c) 2007 Silicon Graphics, Inc. All Rights Reserved.
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
# creator
|
||||||
|
owner=dgc@sgi.com
|
||||||
|
|
||||||
|
seq=`basename $0`
|
||||||
|
echo "QA output created by $seq"
|
||||||
|
|
||||||
|
here=`pwd`
|
||||||
|
tmp=/tmp/$$
|
||||||
|
rm -f $seq.full
|
||||||
|
status=1 # failure is the default!
|
||||||
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||||
|
|
||||||
|
_cleanup()
|
||||||
|
{
|
||||||
|
killall -q -TERM fsstress 2> /dev/null
|
||||||
|
_cleanup_testdir
|
||||||
|
}
|
||||||
|
|
||||||
|
workout()
|
||||||
|
{
|
||||||
|
procs=100
|
||||||
|
nops=15000
|
||||||
|
$FSSTRESS_PROG -d $SCRATCH_MNT -p $procs -n $nops $FSSTRESS_AVOID \
|
||||||
|
>>$seq.full &
|
||||||
|
sleep 2
|
||||||
|
}
|
||||||
|
|
||||||
|
# get standard environment, filters and checks
|
||||||
|
. ./common.rc
|
||||||
|
. ./common.filter
|
||||||
|
|
||||||
|
# real QA test starts here
|
||||||
|
_supported_fs xfs
|
||||||
|
_supported_os Linux
|
||||||
|
|
||||||
|
_setup_testdir
|
||||||
|
_require_scratch
|
||||||
|
_scratch_mkfs_xfs >/dev/null 2>&1
|
||||||
|
_scratch_mount
|
||||||
|
|
||||||
|
TEST_FILE=$SCRATCH_MNT/test_file
|
||||||
|
TEST_PROG=$here/src/unwritten_sync
|
||||||
|
LOOPS=100
|
||||||
|
|
||||||
|
echo "*** test unwritten extent conversion under heavy I/O"
|
||||||
|
|
||||||
|
workout
|
||||||
|
|
||||||
|
rm -f $TEST_FILE
|
||||||
|
$TEST_PROG $LOOPS $TEST_FILE
|
||||||
|
killall -q -TERM fsstress 2> /dev/null
|
||||||
|
|
||||||
|
echo " *** test done"
|
||||||
|
|
||||||
|
status=0
|
||||||
|
exit
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
QA output created by 167
|
||||||
|
*** test unwritten extent conversion under heavy I/O
|
||||||
|
*** test done
|
||||||
@@ -251,3 +251,4 @@ dmapi
|
|||||||
164 rw pattern auto
|
164 rw pattern auto
|
||||||
165 rw pattern auto
|
165 rw pattern auto
|
||||||
166 rw metadata auto
|
166 rw metadata auto
|
||||||
|
167 rw metadata auto
|
||||||
|
|||||||
+4
-1
@@ -10,7 +10,7 @@ TARGETS = dirstress fill fill2 getpagesize holes lstat64 \
|
|||||||
mmapcat append_reader append_writer dirperf metaperf \
|
mmapcat append_reader append_writer dirperf metaperf \
|
||||||
devzero feature alloc fault fstest t_access_root \
|
devzero feature alloc fault fstest t_access_root \
|
||||||
godown resvtest writemod makeextents itrash \
|
godown resvtest writemod makeextents itrash \
|
||||||
multi_open_unlink dmiperf
|
multi_open_unlink dmiperf unwritten_sync
|
||||||
|
|
||||||
LINUX_TARGETS = loggen xfsctl bstat t_mtab getdevicesize \
|
LINUX_TARGETS = loggen xfsctl bstat t_mtab getdevicesize \
|
||||||
preallo_rw_pattern_reader preallo_rw_pattern_writer ftrunc trunc \
|
preallo_rw_pattern_reader preallo_rw_pattern_writer ftrunc trunc \
|
||||||
@@ -108,6 +108,9 @@ looptest: looptest.o
|
|||||||
locktest: locktest.o
|
locktest: locktest.o
|
||||||
$(LINKTEST)
|
$(LINKTEST)
|
||||||
|
|
||||||
|
unwritten_sync: unwritten_sync.o
|
||||||
|
$(LINKTEST)
|
||||||
|
|
||||||
ifeq ($(PKG_PLATFORM),irix)
|
ifeq ($(PKG_PLATFORM),irix)
|
||||||
fill2: fill2.o
|
fill2: fill2.o
|
||||||
$(LINKTEST) -lgen
|
$(LINKTEST) -lgen
|
||||||
|
|||||||
@@ -0,0 +1,154 @@
|
|||||||
|
#include <sys/types.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <xfs/xfs.h>
|
||||||
|
|
||||||
|
/* test thanks to judith@sgi.com */
|
||||||
|
|
||||||
|
#define IO_SIZE 1048576
|
||||||
|
|
||||||
|
void
|
||||||
|
print_getbmapx(
|
||||||
|
const char *pathname,
|
||||||
|
int fd,
|
||||||
|
int64_t start,
|
||||||
|
int64_t limit);
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int fd;
|
||||||
|
char *buf;
|
||||||
|
struct dioattr dio;
|
||||||
|
xfs_flock64_t flock;
|
||||||
|
off_t offset;
|
||||||
|
char *file;
|
||||||
|
int loops;
|
||||||
|
|
||||||
|
if(argc != 3) {
|
||||||
|
fprintf(stderr, "%s <loops> <file>\n", argv[0]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
loops = strtoull(argv[1], NULL, 0);
|
||||||
|
if (errno) {
|
||||||
|
perror("strtoull");
|
||||||
|
exit(errno);
|
||||||
|
}
|
||||||
|
file = argv[2];
|
||||||
|
|
||||||
|
while (loops-- > 0) {
|
||||||
|
sleep(1);
|
||||||
|
fd = open(file, O_RDWR|O_CREAT|O_DIRECT, 0666);
|
||||||
|
if (fd < 0) {
|
||||||
|
perror("open");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (xfsctl(file, fd, XFS_IOC_DIOINFO, &dio) < 0) {
|
||||||
|
perror("dioinfo");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((dio.d_miniosz > IO_SIZE) || (dio.d_maxiosz < IO_SIZE)) {
|
||||||
|
fprintf(stderr, "Test won't work - iosize out of range"
|
||||||
|
" (dio.d_miniosz=%d, dio.d_maxiosz=%d)\n",
|
||||||
|
dio.d_miniosz, dio.d_maxiosz);
|
||||||
|
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
buf = (char *)memalign(dio.d_mem , IO_SIZE);
|
||||||
|
if (buf == NULL) {
|
||||||
|
fprintf(stderr,"Can't get memory\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
memset(buf,'Z',IO_SIZE);
|
||||||
|
offset = 0;
|
||||||
|
|
||||||
|
flock.l_whence = 0;
|
||||||
|
flock.l_start= 0;
|
||||||
|
flock.l_len = IO_SIZE*21;
|
||||||
|
if (xfsctl(file, fd, XFS_IOC_RESVSP64, &flock) < 0) {
|
||||||
|
perror("xfsctl ");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
for (i = 0; i < 21; i++) {
|
||||||
|
if (pwrite(fd, buf, IO_SIZE, offset) != IO_SIZE) {
|
||||||
|
perror("pwrite");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
offset += IO_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
print_getbmapx(file, fd, 0, 0);
|
||||||
|
|
||||||
|
flock.l_whence = 0;
|
||||||
|
flock.l_start= 0;
|
||||||
|
flock.l_len = 0;
|
||||||
|
xfsctl(file, fd, XFS_IOC_FREESP64, &flock);
|
||||||
|
print_getbmapx(file, fd, 0, 0);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
print_getbmapx(
|
||||||
|
const char *pathname,
|
||||||
|
int fd,
|
||||||
|
int64_t start,
|
||||||
|
int64_t limit)
|
||||||
|
{
|
||||||
|
struct getbmapx bmapx[50];
|
||||||
|
int array_size = sizeof(bmapx) / sizeof(bmapx[0]);
|
||||||
|
int x;
|
||||||
|
int foundone = 0;
|
||||||
|
int foundany = 0;
|
||||||
|
|
||||||
|
again:
|
||||||
|
foundone = 0;
|
||||||
|
memset(bmapx, '\0', sizeof(bmapx));
|
||||||
|
|
||||||
|
bmapx[0].bmv_offset = start;
|
||||||
|
bmapx[0].bmv_length = -1; /* limit - start; */
|
||||||
|
bmapx[0].bmv_count = array_size;
|
||||||
|
bmapx[0].bmv_entries = 0; /* no entries filled in yet */
|
||||||
|
|
||||||
|
bmapx[0].bmv_iflags = BMV_IF_PREALLOC;
|
||||||
|
|
||||||
|
x = array_size;
|
||||||
|
for (;;) {
|
||||||
|
if (x > bmapx[0].bmv_entries) {
|
||||||
|
if (x != array_size) {
|
||||||
|
break; /* end of file */
|
||||||
|
}
|
||||||
|
if (xfsctl(pathname, fd, XFS_IOC_GETBMAPX, bmapx) < 0) {
|
||||||
|
fprintf(stderr, "XFS_IOC_GETBMAPX failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (bmapx[0].bmv_entries == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
x = 1; /* back at first extent in buffer */
|
||||||
|
}
|
||||||
|
if (bmapx[x].bmv_oflags & 1) {
|
||||||
|
fprintf(stderr, "FOUND ONE %lld %lld %x\n",
|
||||||
|
bmapx[x].bmv_offset, bmapx[x].bmv_length,bmapx[x].bmv_oflags);
|
||||||
|
foundone = 1;
|
||||||
|
foundany = 1;
|
||||||
|
}
|
||||||
|
x++;
|
||||||
|
}
|
||||||
|
if (foundone) {
|
||||||
|
sleep(1);
|
||||||
|
fprintf(stderr,"Repeat\n");
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
if (foundany) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user