syscalls: add sync device test-cases
v4 cover syscalls: add sync device test-cases
This patch-set adds common test for minimal sectors written on device for various sync related syscalls:
1. syncfs()
2. sync()
3. fsync()
4. fdatasync()
5. sync_file_range()
Also this test is run on all supported filesystems on a test block device.
Changes in v4:
1. Update common library functions from reusability perspective.
2. Create separate patch for TEST_VOID macro.
3. Add check for broken /sys/block/<device>/stat file.
4. Miscellaneous fixups.
Changes in v3:
1. Scope increased from single patch to this patch-set to add common test for sync(), fsync(), fdatasync() and sync_file_range() syscalls.
2. Move common functionality to library functions.
3. Use %lu rather than %s while parsing sectors written.
4. Add config check for C library wrapper and fallback definition for syncfs() and sync_file_range() syscalls.
Changes in v2:
1. Remove unused header file include.
2. Remove redundant tst_device check.
3. Remove redundant flags from tst_test struct.
Sumit Garg (9):
lib/tst_device: add new api tst_dev_bytes_written()
lib: split tst_fill_file() to create new tst_fill_fd() lib/tst_test: define TEST_VOID() macro
syscalls: add syncfs() sync device test-case syscalls/sync: add sync device test-case syscalls/fsync: add sync device test-case syscalls/fdatasync: add sync device test-case syscalls/sync_file_range: Use C library wrapper if present syscalls/sync_file_range: add sync device test-case
configure.ac | 2 + include/lapi/sync_file_range.h | 57 +++++++++++++++++ include/lapi/syncfs.h | 21 +++++++ include/tst_device.h | 7 +++ include/tst_fs.h | 9 +++ include/tst_test.h | 7 +++ lib/tst_device.c | 29 +++++++++ lib/tst_fill_file.c | 40 +++++++----- m4/ltp-sync_file_range.m4 | 10 +++ m4/ltp-syncfs.m4 | 10 +++ runtest/syscalls | 6 ++ testcases/kernel/syscalls/fdatasync/.gitignore | 1 + testcases/kernel/syscalls/fdatasync/fdatasync03.c | 60 ++++++++++++++++++ testcases/kernel/syscalls/fsync/.gitignore | 1 + testcases/kernel/syscalls/fsync/fsync04.c | 60 ++++++++++++++++++ testcases/kernel/syscalls/sync/.gitignore | 1 + testcases/kernel/syscalls/sync/sync03.c | 60 ++++++++++++++++++ .../kernel/syscalls/sync_file_range/.gitignore | 1 + .../sync_file_range/check_sync_file_range.h | 21 +++++++ .../syscalls/sync_file_range/sync_file_range01.c | 62 ++----------------- .../syscalls/sync_file_range/sync_file_range02.c | 72 ++++++++++++++++++++++ testcases/kernel/syscalls/syncfs/.gitignore | 1 + testcases/kernel/syscalls/syncfs/Makefile | 8 +++ testcases/kernel/syscalls/syncfs/check_syncfs.h | 19 ++++++ testcases/kernel/syscalls/syncfs/syncfs01.c | 67 ++++++++++++++++++++ 25 files changed, 558 insertions(+), 74 deletions(-) create mode 100644 include/lapi/sync_file_range.h create mode 100644 include/lapi/syncfs.h create mode 100644 m4/ltp-sync_file_range.m4 create mode 100644 m4/ltp-syncfs.m4 create mode 100644 testcases/kernel/syscalls/fdatasync/fdatasync03.c create mode 100644 testcases/kernel/syscalls/fsync/fsync04.c create mode 100644 testcases/kernel/syscalls/sync/sync03.c create mode 100644 testcases/kernel/syscalls/sync_file_range/check_sync_file_range.h create mode 100644 testcases/kernel/syscalls/sync_file_range/sync_file_range02.c create mode 100644 testcases/kernel/syscalls/syncfs/.gitignore create mode 100644 testcases/kernel/syscalls/syncfs/Makefile create mode 100644 testcases/kernel/syscalls/syncfs/check_syncfs.h create mode 100644 testcases/kernel/syscalls/syncfs/syncfs01.c
Signature · 1 line
2.7.4
PATCH v4 1/9 lib/tst_device: add new api tst_dev_bytes_written()
This api reads test block device stat file and returns the bytes written since the last invocation of this api.
--- include/tst_device.h | 7 +++++++ lib/tst_device.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
include/tst_device.h +7 -0
@@ -44,4 +44,11 @@ int tst_umount(const char *path);*/ int tst_clear_device (const char *dev); +/* +* Reads test block device stat file and returns the bytes written since the +* last call of this function. +* @dev: test block device +*/ +unsigned long tst_dev_bytes_written (const char *dev); +#endif /* TST_DEVICE_H__ */
lib/tst_device.c +29 -0
@@ -45,6 +45,7 @@static char dev_path[1024 ];static int device_acquired; +static unsigned long prev_dev_sec_write;static const char *dev_variants[] = {"/dev/loop%i" ,
@@ -364,3 +365,31 @@ int tst_umount(const char *path) errno = err;return -1 ; } + +unsigned long tst_dev_bytes_written (const char *dev) +{ +struct stat st; +unsigned long dev_sec_write =0 , dev_bytes_written, io_ticks =0 ; +char dev_stat_path[1024 ]; + +snprintf (dev_stat_path,sizeof (dev_stat_path),"/sys/block/%s/stat" , +strrchr (dev,'/' ) +1 ); + +if (stat (dev_stat_path, &st) !=0 ) +tst_brkm (TCONF ,NULL ,"Test device stat file: %s not found" , + dev_stat_path); + +SAFE_FILE_SCANF (NULL , dev_stat_path, +"%*s %*s %*s %*s %*s %*s %lu %*s %*s %lu" , + &dev_sec_write, &io_ticks); + +if (!io_ticks) +tst_brkm (TCONF ,NULL ,"Test device stat file: %s broken" , + dev_stat_path); + + dev_bytes_written = (dev_sec_write - prev_dev_sec_write) *512 ; + + prev_dev_sec_write = dev_sec_write; + +return dev_bytes_written; +}
Signature · 1 line
2.7.4
PATCH v4 1/9 lib/tst_device: add new api tst_dev_bytes_written()
Hi!
This should get documented in the doc/test-writing-guidelines.txt probably under the 2.2.14 paragraph.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v4 1/9 lib/tst_device: add new api tst_dev_bytes_written()
Quoted 5 lines · Cyril Hrubis
Hi!
This should get documented in thedoc/test-writing-guidelines.txtprobably under the 2.2.14 paragraph.
Sure, will document it.
-Sumit
Quoted 3 lines
--
Cyril Hrubis
[email protected]
PATCH v4 2/9 lib: split tst_fill_file() to create new tst_fill_fd()
In reply to Sumit GargSplit tst_fill_file() api to create new tst_fill_fd() api which could be used to fill file using fd and allows syscalls tests to operate on fd.
--- include/tst_fs.h | 9 +++++++++ lib/tst_fill_file.c | 40 +++++++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 17 deletions(-)
include/tst_fs.h +9 -0
@@ -139,6 +139,15 @@ int tst_dir_is_empty_(void (*cleanup)(void), const char *name, int verbose);int tst_get_path (const char *prog_name,char *buf,size_t buf_len);/* +* Fill a file with specified pattern +* @fd: file descriptor +* @pattern: pattern +* @bs: block size +* @bcount: blocks count +*/ +int tst_fill_fd (int fd,char pattern,size_t bs,size_t bcount); + +/* * Creates/ovewrites a file with specified pattern * @path: path to file * @pattern: pattern
lib/tst_fill_file.c +23 -17
@@ -28,40 +28,46 @@#include "test.h" -int tst_fill_file (const char *path,char pattern,size_t bs,size_t bcount) +int tst_fill_fd (int fd,char pattern,size_t bs,size_t bcount) { -int fd; -size_t counter; +size_t i;char *buf; - fd =open (path,O_CREAT |O_WRONLY |O_TRUNC ,S_IRUSR |S_IWUSR ); -if (fd <0 ) -return -1 ; -/* Filling a memory buffer with provided pattern */ buf =malloc (bs); -if (buf ==NULL ) { -close (fd); - +if (buf ==NULL )return -1 ; - } -for (counter =0 ; counter < bs; counter++) - buf[counter] = pattern; +for (i =0 ; i < bs; i++) + buf[i] = pattern;/* Filling the file */ -for (counter =0 ; counter < bcount; counter++) { +for (i =0 ; i < bcount; i++) {if (write (fd, buf, bs) != (ssize_t )bs) {free (buf); -close (fd); -unlink (path); -return -1 ; } }free (buf); +return 0 ; +} + +int tst_fill_file (const char *path,char pattern,size_t bs,size_t bcount) +{ +int fd; + + fd =open (path,O_CREAT |O_WRONLY |O_TRUNC ,S_IRUSR |S_IWUSR ); +if (fd <0 ) +return -1 ; + +if (tst_fill_fd (fd, pattern, bs, bcount)) { +close (fd); +unlink (path); +return -1 ; + } +if (close (fd) <0 ) {unlink (path);
Signature · 1 line
2.7.4
PATCH v4 2/9 lib: split tst_fill_file() to create new tst_fill_fd()
Quoted 34 lines · Sumit Garg
Split
tst_fill_file()api to create newtst_fill_fd()api which could be used to fill file using fd and allows syscalls tests to operate on fd.Signed-off-by Sumit Garg <[email protected]>--- include/tst_fs.h | 9 +++++++++ lib/tst_fill_file.c | 40 +++++++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 17 deletions(-)include/tst_fs.h +9
-0@@ -139,6 +139,15 @@ int tst_dir_is_empty_(void (*cleanup)(void), const char *name, int verbose);int tst_get_path (const char *prog_name,char *buf,size_t buf_len);/* +* Fill a file with specified pattern +* @fd: file descriptor +* @pattern: pattern +* @bs: block size +* @bcount: blocks count +*/ +int tst_fill_fd (int fd,char pattern,size_t bs,size_t bcount); + +/* * Creates/ovewrites a file with specified pattern * @path: path to file * @pattern: pattern lib/tst_fill_file.c +0
-0
lib/tst_fill_file.c line 33
Quoted 9 lines
lib/tst_fill_file.c +2
-3@@ -28,40 +28,46 @@#include "test.h" -int tst_fill_file (const char *path,char pattern,size_t bs,size_t bcount) +int tst_fill_fd (int fd,char pattern,size_t bs,size_t bcount) { -int fd; -size_t counter; +size_t i;
Nitpicking perhaps but gratuitous variable renames don't make patches containing other changes easier to read. Nor, to be honest, does "counter" seem any more descriptive then i (since i is more idiomatic and therefore quicker to read).
Daniel.
Quoted 57 lines
lib/tst_fill_file.c +21
-14char *buf; - fd =open (path,O_CREAT |O_WRONLY |O_TRUNC ,S_IRUSR |S_IWUSR ); -if (fd <0 ) -return -1 ; -/* Filling a memory buffer with provided pattern */ buf =malloc (bs); -if (buf ==NULL ) { -close (fd); - +if (buf ==NULL )return -1 ; - } -for (counter =0 ; counter < bs; counter++) - buf[counter] = pattern; +for (i =0 ; i < bs; i++) + buf[i] = pattern;/* Filling the file */ -for (counter =0 ; counter < bcount; counter++) { +for (i =0 ; i < bcount; i++) {if (write (fd, buf, bs) != (ssize_t )bs) {free (buf); -close (fd); -unlink (path); -return -1 ; } }free (buf); +return 0 ; +} + +int tst_fill_file (const char *path,char pattern,size_t bs,size_t bcount) +{ +int fd; + + fd =open (path,O_CREAT |O_WRONLY |O_TRUNC ,S_IRUSR |S_IWUSR ); +if (fd <0 ) +return -1 ; + +if (tst_fill_fd (fd, pattern, bs, bcount)) { +close (fd); +unlink (path); +return -1 ; + } +if (close (fd) <0 ) {unlink (path);Signature · 1 line
2.7.4
PATCH v4 2/9 lib: split tst_fill_file() to create new tst_fill_fd()
Hi!
Quoted 11 lines
lib/tst_fill_file.c line 33
Quoted 6 lines
lib/tst_fill_file.c +2
-3-int tst_fill_file (const char *path,char pattern,size_t bs,size_t bcount) +int tst_fill_fd (int fd,char pattern,size_t bs,size_t bcount) { -int fd; -size_t counter; +size_t i;Nitpicking perhaps but gratuitous variable renames don't make patches containing other changes easier to read. Nor, to be honest, does "counter" seem any more descriptive then i (since i is more idiomatic and therefore quicker to read).
It seems you misread the patch as we are replacing the counter with i here and I asked for that since i is the idiomatic way of naming loop variables, so all the blame for this change goes to me :-).
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v4 2/9 lib: split tst_fill_file() to create new tst_fill_fd()
Quoted 13 lines · Cyril Hrubis
Hi!
Quoted 11 lines
lib/tst_fill_file.c line 33
Quoted 6 lines
lib/tst_fill_file.c +2
-3-int tst_fill_file (const char *path,char pattern,size_t bs,size_t bcount) +int tst_fill_fd (int fd,char pattern,size_t bs,size_t bcount) { -int fd; -size_t counter; +size_t i;Nitpicking perhaps but gratuitous variable renames don't make patches containing other changes easier to read. Nor, to be honest, does "counter" seem any more descriptive then i (since i is more idiomatic and therefore quicker to read).
Quoted 3 lines
It seems you misread the patch as we are replacing the counter with i here and I asked for that since i is the idiomatic way of naming loop variables, so all the blame for this change goes to me :-).
Quite right. I misread it. Sorry for the noise.
Daniel.
Quoted 4 lines
Signature · 3 lines
-- Cyril Hrubis [email protected]
PATCH v4 2/9 lib: split tst_fill_file() to create new tst_fill_fd()
In reply to Sumit GargHi!
Ideally these two functions should be noted in the test-writing-guidelines.txt as well.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v4 2/9 lib: split tst_fill_file() to create new tst_fill_fd()
Quoted 5 lines · Cyril Hrubis
Hi!
Ideally these two functions should be noted in the test-writing-guidelines.txt as well.
Agree, will document them.
-Sumit
Quoted 3 lines
--
Cyril Hrubis
[email protected]
PATCH v4 3/9 lib/tst_test: define TEST_VOID() macro
In reply to Sumit GargDefine TEST_VOID() macro for syscalls whose return type is void like sync() etc.
--- include/tst_test.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/tst_test.h +7 -0
@@ -216,6 +216,13 @@ void tst_reinit(void);TST_ERR = errno; \ } while (0) +#define TEST_VOID (SCALL ) \ + do { \ + errno = 0; \ + SCALL; \ + TST_ERR = errno; \ + } while (0) +extern long TST_RET ;extern int TST_ERR ;
Signature · 1 line
2.7.4
PATCH v4 4/9 syscalls: add syncfs() sync device test-case
In reply to Sumit Gargsyncfs01 tests to sync filesystem having large dirty file pages to block device. Also, it tests all supported filesystems on a test block device.
--- configure.ac | 1 + include/lapi/syncfs.h | 21 ++++++++ m4/ltp-syncfs.m4 | 10 ++++ runtest/syscalls | 2 + testcases/kernel/syscalls/syncfs/.gitignore | 1 + testcases/kernel/syscalls/syncfs/Makefile | 8 +++ testcases/kernel/syscalls/syncfs/check_syncfs.h | 19 +++++++ testcases/kernel/syscalls/syncfs/syncfs01.c | 67 +++++++++++++++++++++++++ 8 files changed, 129 insertions(+) create mode 100644 include/lapi/syncfs.h create mode 100644 m4/ltp-syncfs.m4 create mode 100644 testcases/kernel/syscalls/syncfs/.gitignore create mode 100644 testcases/kernel/syscalls/syncfs/Makefile create mode 100644 testcases/kernel/syscalls/syncfs/check_syncfs.h create mode 100644 testcases/kernel/syscalls/syncfs/syncfs01.c
configure.ac +1 -0
@@ -231,6 +231,7 @@ LTP_CHECK_TPACKET_V3 LTP_CHECK_RLIMIT64 LTP_DETECT_HOST_CPU LTP_CHECK_PERF_EVENT +LTP_CHECK_SYNCFS if test "x$with_numa" = xyes; then LTP_CHECK_SYSCALL_NUMA
include/lapi/syncfs.h new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2019 Linaro Limited. All rights reserved. +* Author: Sumit Garg <[email protected]> +*/ + +#ifndef SYNCFS_H +#define SYNCFS_H + +#include <sys/types.h> +#include "config.h" +#include "lapi/syscalls.h" + +#if !defined(HAVE_SYNCFS ) +int syncfs (int fd) +{ +return tst_syscall (__NR_syncfs, fd); +} +#endif + +#endif /* SYNCFS_H */
m4/ltp-syncfs.m4 new file +10 -0
@@ -0,0 +1,10 @@ +dnl SPDX-License-Identifier: GPL-2.0-or-later +dnl Copyright (c) 2019 Linaro Limited. All rights reserved. + +dnl +dnl LTP_CHECK_SYNCFS +dnl ---------------------------- +dnl +AC_DEFUN([LTP_CHECK_SYNCFS],[ +AC_CHECK_FUNCS(syncfs,,) +])
runtest/syscalls +2 -0
@@ -1346,6 +1346,8 @@ symlinkat01 symlinkat01 sync01 sync01 sync02 sync02 +syncfs01 syncfs01 + #testcases for sync_file_range sync_file_range01 sync_file_range01
testcases/kernel/syscalls/syncfs/.gitignore new file +1 -0
@@ -0,0 +1 @@ +syncfs01
testcases/kernel/syscalls/syncfs/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# Copyright (c) 2019 - Linaro Limited. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +include $(top_srcdir)/include/mk/generic_leaf_target.mk
testcases/kernel/syscalls/syncfs/check_syncfs.h new file +19 -0
@@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2019 Linaro Limited. All rights reserved. +* Author: Sumit Garg <[email protected]> +*/ + +#ifndef CHECK_SYNCFS_H +#define CHECK_SYNCFS_H + +void check_syncfs (void ) +{ +int ret; + + ret =syncfs (-1 ); +if (ret ==-1 && errno ==EINVAL ) +tst_brk (TCONF ,"syncfs() not supported" ); +} + +#endif /* CHECK_SYNCFS_H */
testcases/kernel/syscalls/syncfs/syncfs01.c new file +67 -0
67 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 5/9 syscalls/sync: add sync device test-case
In reply to Sumit Gargsync03 tests to sync file having large dirty file pages to block device. It tests all supported filesystems on a test block device.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/sync/.gitignore | 1 + testcases/kernel/syscalls/sync/sync03.c | 60 +++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 testcases/kernel/syscalls/sync/sync03.c
runtest/syscalls +1 -0
@@ -1345,6 +1345,7 @@ symlinkat01 symlinkat01 sync01 sync01 sync02 sync02 +sync03 sync03 syncfs01 syncfs01
testcases/kernel/syscalls/sync/.gitignore +1 -0
@@ -1,2 +1,3 @@ /sync01 /sync02 +/sync03
testcases/kernel/syscalls/sync/sync03.c new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 6/9 syscalls/fsync: add sync device test-case
In reply to Sumit Gargfsync04 tests to sync file having large dirty file pages to block device. Also, it tests all supported filesystems on a test block device.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/fsync/.gitignore | 1 + testcases/kernel/syscalls/fsync/fsync04.c | 60 ++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 testcases/kernel/syscalls/fsync/fsync04.c
runtest/syscalls +1 -0
@@ -347,6 +347,7 @@ fstatfs02_64 fstatfs02_64 fsync01 fsync01 fsync02 fsync02 fsync03 fsync03 +fsync04 fsync04 ftruncate01 ftruncate01 ftruncate01_64 ftruncate01_64
testcases/kernel/syscalls/fsync/.gitignore +1 -0
@@ -1,3 +1,4 @@ /fsync01 /fsync02 /fsync03 +/fsync04
testcases/kernel/syscalls/fsync/fsync04.c new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 7/9 syscalls/fdatasync: add sync device test-case
In reply to Sumit Gargfdatasync03 tests to sync file data having large dirty file pages to block device. Also, it tests all supported filesystems on a test block device.
--- runtest/syscalls | 1 + testcases/kernel/syscalls/fdatasync/.gitignore | 1 + testcases/kernel/syscalls/fdatasync/fdatasync03.c | 60 +++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 testcases/kernel/syscalls/fdatasync/fdatasync03.c
runtest/syscalls +1 -0
@@ -291,6 +291,7 @@ fcntl36_64 fcntl36_64 fdatasync01 fdatasync01 fdatasync02 fdatasync02 +fdatasync03 fdatasync03 fgetxattr01 fgetxattr01 fgetxattr02 fgetxattr02
testcases/kernel/syscalls/fdatasync/.gitignore +1 -0
@@ -1,2 +1,3 @@ /fdatasync01 /fdatasync02 +/fdatasync03
testcases/kernel/syscalls/fdatasync/fdatasync03.c new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 8/9 syscalls/sync_file_range: Use C library wrapper if present
In reply to Sumit GargAdd config check for C library wrapper for sync_file_range() syscall. Also, check for sync_file_range() presence via dummy call rather than kernel version check. And move fallback api to:include/lapi/sync_file_range.h
--- configure.ac | 1 + include/lapi/sync_file_range.h | 57 ++++++++++++++++++++ m4/ltp-sync_file_range.m4 | 10 ++++ .../sync_file_range/check_sync_file_range.h | 21 ++++++++ .../syscalls/sync_file_range/sync_file_range01.c | 62 ++-------------------- 5 files changed, 94 insertions(+), 57 deletions(-) create mode 100644 include/lapi/sync_file_range.h create mode 100644 m4/ltp-sync_file_range.m4 create mode 100644 testcases/kernel/syscalls/sync_file_range/check_sync_file_range.h
configure.ac +1 -0
@@ -232,6 +232,7 @@ LTP_CHECK_RLIMIT64 LTP_DETECT_HOST_CPU LTP_CHECK_PERF_EVENT LTP_CHECK_SYNCFS +LTP_CHECK_SYNC_FILE_RANGE if test "x$with_numa" = xyes; then LTP_CHECK_SYSCALL_NUMA
include/lapi/sync_file_range.h new file +57 -0
57 lines not on this page · raw message
m4/ltp-sync_file_range.m4 new file +10 -0
@@ -0,0 +1,10 @@ +dnl SPDX-License-Identifier: GPL-2.0-or-later +dnl Copyright (c) 2019 Linaro Limited. All rights reserved. + +dnl +dnl LTP_CHECK_SYNC_FILE_RANGE +dnl ---------------------------- +dnl +AC_DEFUN([LTP_CHECK_SYNC_FILE_RANGE],[ +AC_CHECK_FUNCS(sync_file_range,,) +])
testcases/kernel/syscalls/sync_file_range/check_sync_file_range.h new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2019 Linaro Limited. All rights reserved. +* Author: Sumit Garg <[email protected]> +*/ + +#ifndef CHECK_SYNC_FILE_RANGE_H +#define CHECK_SYNC_FILE_RANGE_H + +int check_sync_file_range (void ) +{ +int ret; + + ret =sync_file_range (-1 ,0 ,0 ,0 ); +if (ret ==-1 && errno ==EINVAL ) +return 0 ; + +return 1 ; +} + +#endif /* CHECK_SYNC_FILE_RANGE_H */
testcases/kernel/syscalls/sync_file_range/sync_file_range01.c +5 -57
84 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 9/9 syscalls/sync_file_range: add sync device test-case
In reply to Sumit Gargsync_file_range02 tests to sync file data range having large dirty file pages to block device. Also, it tests all supported filesystems on a test block device.
--- runtest/syscalls | 1 + .../kernel/syscalls/sync_file_range/.gitignore | 1 + .../syscalls/sync_file_range/sync_file_range02.c | 72 ++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 testcases/kernel/syscalls/sync_file_range/sync_file_range02.c
runtest/syscalls +1 -0
@@ -1353,6 +1353,7 @@ syncfs01 syncfs01 #testcases for sync_file_range sync_file_range01 sync_file_range01 +sync_file_range02 sync_file_range02 syscall01 syscall01
testcases/kernel/syscalls/sync_file_range/.gitignore +1 -0
@@ -1 +1,2 @@ /sync_file_range01 +/sync_file_range02
testcases/kernel/syscalls/sync_file_range/sync_file_range02.c new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 9/9 syscalls/sync_file_range: add sync device test-case
Hi!
This tests fails for me for fuse based filesystems, the call returns 0 but does not write anything, the questions is if this is desired behavior or not.
Also we should as well add a second test here that sync only a middle of a written region of a file and expects that the data written are somewhere between a few percents of the synced size.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v4 9/9 syscalls/sync_file_range: add sync device test-case
Quoted 6 lines · Cyril Hrubis
Hi!
This tests fails for me for fuse based filesystems, the call returns 0 but does not write anything, the questions is if this is desired behavior or not.
Interesting case. Do you see similar behaviour with other sync related syscalls?
AFAIK, fuse file-system operations are implemented in user-space daemons exported to kernel as callbacks via libfuse. Maybe we need to check fsync() callback operation [1] implementation?
[1] https://libfuse.github.io/doxygen/structfuse__operations.html
Quoted 4 lines
Also we should as well add a second test here that sync only a middle of a written region of a file and expects that the data written are somewhere between a few percents of the synced size.
Sure, will add a test for this.
-Sumit
Quoted 3 lines
--
Cyril Hrubis
[email protected]
PATCH v4 9/9 syscalls/sync_file_range: add sync device test-case
Hi!
Quoted 6 lines
Quoted 4 lines
This tests fails for me for fuse based filesystems, the call returns 0 but does not write anything, the questions is if this is desired behavior or not.
Interesting case. Do you see similar behaviour with other sync related syscalls?
Just this one, I would have expected that the new syscall is not wired into fuse yet hence it does nothing silently instead of returning EOPNOTSUPP which could break applications...
Quoted 4 lines
AFAIK, fuse file-system operations are implemented in user-space daemons exported to kernel as callbacks via libfuse. Maybe we need to check
fsync()callback operation [1] implementation?
Quoted 8 lines
[1] https://libfuse.github.io/doxygen/structfuse__operations.html
Quoted 4 lines
Also we should as well add a second test here that sync only a middle of a written region of a file and expects that the data written are somewhere between a few percents of the synced size.
Sure, will add a test for this.
Ideally this should be put into the existing test in order to spare time needed to format the devices etc.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v4 9/9 syscalls/sync_file_range: add sync device test-case
Quoted 6 lines · Cyril Hrubis
Hi!
Quoted 5 lines
Quoted 4 lines
This tests fails for me for fuse based filesystems, the call returns 0 but does not write anything, the questions is if this is desired behavior or not.
Quoted 11 lines
Quoted 1 line
Interesting case. Do you see similar behaviour with other sync related syscalls?
Just this one, I would have expected that the new syscall is not wired into fuse yet hence it does nothing silently instead of returning EOPNOTSUPP which could break applications...
Quoted 5 lines
AFAIK, fuse file-system operations are implemented in user-space daemons exported to kernel as callbacks via libfuse. Maybe we need to check
fsync()callback operation [1] implementation?[1] https://libfuse.github.io/doxygen/structfuse__operations.html
For file syncs I think (admitedly without having much VFS experience) that the writeback will end up being requested via the writepages VFS op; since we are writing back data from a single fd then the kernel doesn't need much help from the filesystem to find out which pages are affected so the "big" sync API in fuse is probably not needed here.
Daniel.
Quoted 14 lines
Quoted 7 lines
Quoted 5 lines
Also we should as well add a second test here that sync only a middle of a written region of a file and expects that the data written are somewhere between a few percents of the synced size.
Sure, will add a test for this.
Ideally this should be put into the existing test in order to spare time needed to format the devices etc.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH v4 9/9 syscalls/sync_file_range: add sync device test-case
Quoted 18 lines · Daniel Thompson
Quoted 16 lines · Cyril Hrubis
Hi!
Quoted 6 lines
Quoted 4 lines
This tests fails for me for fuse based filesystems, the call returns 0 but does not write anything, the questions is if this is desired behavior or not.
Interesting case. Do you see similar behaviour with other sync related syscalls?
Just this one, I would have expected that the new syscall is not wired into fuse yet hence it does nothing silently instead of returning EOPNOTSUPP which could break applications...
Quoted 4 lines
AFAIK, fuse file-system operations are implemented in user-space daemons exported to kernel as callbacks via libfuse. Maybe we need to check
fsync()callback operation [1] implementation?
Quoted 8 lines
Quoted 1 line
Quoted 1 line
[1] https://libfuse.github.io/doxygen/structfuse__operations.html
For file syncs I think (admitedly without having much VFS experience) that the writeback will end up being requested via the writepages VFS op; since we are writing back data from a single fd then the kernel doesn't need much help from the filesystem to find out which pages are affected so the "big" sync API in fuse is probably not needed here.
Hmm, I see in case of sync_file_range(), its handled via writepages VFS op. And fuse fsync() callback is used for fsync() and fdatasync() syscalls.
Quoted 15 lines
Daniel.
Quoted 11 lines
Quoted 7 lines
Quoted 5 lines
Also we should as well add a second test here that sync only a middle of a written region of a file and expects that the data written are somewhere between a few percents of the synced size.
Sure, will add a test for this.
Ideally this should be put into the existing test in order to spare time needed to format the devices etc.
Agree.
-Sumit
Quoted 3 lines
Quoted 3 lines
--
Cyril Hrubis
[email protected]
v4 cover syscalls: add sync device test-cases
In reply to Sumit GargHi!
Quoted 10 lines
This patch-set adds common test for minimal sectors written on device for various sync related syscalls:
1.syncfs()
2.sync()
3.fsync()
4.fdatasync()
5.sync_file_range()Also this test is run on all supported filesystems on a test block device.
Pushed with minor changes, good work, thanks.
I've changed the tests to print how much data was synced in a case of a failure and also removed the TST_ prefix from the macros defined in the tests as the TST_ prefix is reserved for the test library.
Signature · 2 lines
Cyril Hrubis [email protected]
v4 cover syscalls: add sync device test-cases
Quoted 10 lines · Cyril Hrubis
Hi!
Quoted 8 lines
This patch-set adds common test for minimal sectors written on device for various sync related syscalls:
1.syncfs()
2.sync()
3.fsync()
4.fdatasync()
5.sync_file_range()
Quoted 9 lines
Quoted 2 lines
Also this test is run on all supported filesystems on a test block device.
Pushed with minor changes, good work, thanks.
I've changed the tests to print how much data was synced in a case of a failure and also removed the
TST_prefix from the macros defined in the tests as theTST_prefix is reserved for the test library.
Thanks for these changes and merging this patch-set.
-Sumit
Quoted 3 lines
--
Cyril Hrubis
[email protected]