Test the new fanotify FAN_FS_ERROR event
v4 cover Test the new fanotify FAN_FS_ERROR event
Hi,
FAN_FS_ERROR was merged into Linus tree, and the PIDFD testcases reached LTP. Therefore, I'm sending a new version of the FAN_FS_ERROR LTP tests. This is the v4 of this patchset, and it applies the feedback of the previous version.
Thanks,
---
Original cover letter:
FAN_FS_ERROR is a new (still unmerged) fanotify event to monitor fileystem errors. This patchset introduces a new LTP test for this feature.
Testing file system errors is slightly tricky, in particular because they are mostly file system dependent. Since there are only patches for ext4, I choose to make the test around it, since there wouldn't be much to do with other file systems. The second challenge is how we cause the file system errors, since there is no error injection for ext4 in Linux. In this series, this is done by corrupting specific data in the test device with the help of debugfs.
The FAN_FS_ERROR feature is flying around linux-ext4 and fsdevel, and the latest version is available on the branch below:
https://gitlab.collabora.com/krisman/linux -b fanotify-notifications-v9
A proper manpage description is also available on the respective mailing list, or in the branch below:
https://gitlab.collabora.com/krisman/man-pages.git -b fan-fs-error
Please, let me know your thoughts.
Gabriel Krisman Bertazi (9):
syscalls: fanotify: Add macro to require specific mark types
syscalls: fanotify: Add macro to require specific events syscalls/fanotify22: Introduce FAN_FS_ERROR test syscalls/fanotify22: Validate the generic error info syscalls/fanotify22: Validate incoming FID in FAN_FS_ERROR syscalls/fanotify22: Support submission of debugfs commands syscalls/fanotify22: Create a corrupted file syscalls/fanotify22: Test file event with broken inode syscalls/fanotify22: Test capture of multiple errors
configure.ac | 3 +- testcases/kernel/syscalls/fanotify/.gitignore | 1 + testcases/kernel/syscalls/fanotify/fanotify.h | 65 +++- .../kernel/syscalls/fanotify/fanotify03.c | 4 +- .../kernel/syscalls/fanotify/fanotify10.c | 3 +- .../kernel/syscalls/fanotify/fanotify12.c | 3 +- .../kernel/syscalls/fanotify/fanotify22.c | 314 ++++++++++++++++++ 7 files changed, 385 insertions(+), 8 deletions(-) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify22.c
Signature · 1 line
2.33.0
PATCH v4 1/9 syscalls: fanotify: Add macro to require specific mark types
Like done for init flags and event types, and a macro to require a specific mark type.
--- testcases/kernel/syscalls/fanotify/fanotify.h | 5 +++++ 1 file changed, 5 insertions(+)
testcases/kernel/syscalls/fanotify/fanotify.h +5 -0
@@ -399,4 +399,9 @@ static inline int fanotify_mark_supported_by_kernel(uint64_t flag) return rval; } +#define REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL (mark_type) do { \ + fanotify_init_flags_err_msg(#mark_type, __FILE__, __LINE__, tst_brk_, \ + fanotify_mark_supported_by_kernel(mark_type)); \ +} while (0) +#endif /* __FANOTIFY_H__ */
Signature · 1 line
2.33.0
PATCH v4 2/9 syscalls: fanotify: Add macro to require specific events
In reply to Gabriel Krisman BertaziAdd a helper for tests to fail if an event is not available in the kernel. Since some events only work with REPORT_FID or a specific class, update the verifier to allow those to be specified.
---
If I understand correctly, the decision was to leave fanotify10 unchanged and this is what I've done here.
Changes since v1:
- Use SAFE_FANOTIFY_INIT instead of open coding. (Amir)
- Use FAN_CLASS_NOTIF for fanotify12 testcase. (Amir)
--- testcases/kernel/syscalls/fanotify/fanotify.h | 17 ++++++++++++++--- testcases/kernel/syscalls/fanotify/fanotify03.c | 4 ++-- testcases/kernel/syscalls/fanotify/fanotify10.c | 3 ++- testcases/kernel/syscalls/fanotify/fanotify12.c | 3 ++- 4 files changed, 20 insertions(+), 7 deletions(-)
testcases/kernel/syscalls/fanotify/fanotify.h +14 -3
@@ -287,14 +287,16 @@ static inline void require_fanotify_access_permissions_supported_by_kernel(void)SAFE_CLOSE (fd); } -static inline int fanotify_events_supported_by_kernel (uint64_t mask) +static inline int fanotify_events_supported_by_kernel (uint64_t mask, +unsigned int init_flags, +unsigned int mark_flags) {int fd;int rval =0 ; - fd =SAFE_FANOTIFY_INIT (FAN_CLASS_CONTENT ,O_RDONLY ); + fd =SAFE_FANOTIFY_INIT (init_flags,O_RDONLY ); -if (fanotify_mark (fd,FAN_MARK_ADD , mask,AT_FDCWD ,"." ) <0 ) { +if (fanotify_mark (fd,FAN_MARK_ADD | mark_flags, mask,AT_FDCWD ,"." ) <0 ) {if (errno ==EINVAL ) { rval =-1 ; }else {
@@ -404,4 +406,13 @@ static inline int fanotify_mark_supported_by_kernel(uint64_t flag) fanotify_mark_supported_by_kernel(mark_type)); \ } while (0) +#define REQUIRE_FANOTIFY_EVENTS_SUPPORTED_ON_FS (init_flags, mark_type, mask, fname) do { \ + if (mark_type) \ + REQUIRE_MARK_TYPE_SUPPORTED_BY_KERNEL(mark_type); \ + if (init_flags) \ + REQUIRE_FANOTIFY_INIT_FLAGS_SUPPORTED_ON_FS(init_flags, fname); \ + fanotify_init_flags_err_msg(#mask, __FILE__, __LINE__, tst_brk_, \ + fanotify_events_supported_by_kernel(mask, init_flags, mark_type)); \ +} while (0) +#endif /* __FANOTIFY_H__ */
testcases/kernel/syscalls/fanotify/fanotify03.c +2 -2
@@ -323,8 +323,8 @@ static void setup(void)require_fanotify_access_permissions_supported_by_kernel (); filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); - exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC_PERM ); - + exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC_PERM , +FAN_CLASS_CONTENT ,0 );sprintf (fname,MOUNT_PATH "/fname_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"1" );
testcases/kernel/syscalls/fanotify/fanotify10.c +2 -1
@@ -509,7 +509,8 @@ cleanup:static void setup (void ) { - exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC ); + exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC , +FAN_CLASS_CONTENT ,0 ); filesystem_mark_unsupported =fanotify_mark_supported_by_kernel (FAN_MARK_FILESYSTEM ); fan_report_dfid_unsupported =fanotify_init_flags_supported_on_fs (FAN_REPORT_DFID_NAME ,MOUNT_PATH );
testcases/kernel/syscalls/fanotify/fanotify12.c +2 -1
@@ -222,7 +222,8 @@ cleanup:static void do_setup (void ) { - exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC ); + exec_events_unsupported =fanotify_events_supported_by_kernel (FAN_OPEN_EXEC , +FAN_CLASS_NOTIF ,0 );sprintf (fname,"fname_%d" ,getpid ());SAFE_FILE_PRINTF (fname,"1" );
Signature · 1 line
2.33.0
PATCH v4 3/9 syscalls/fanotify22: Introduce FAN_FS_ERROR test
In reply to Gabriel Krisman Bertazifanotify22 is a new test validating the FAN_FS_ERROR file system error event. This adds some basic structure for the next patches and a single test of error reporting during filesystem abort
The strategy for error reporting testing in fanotify22 goes like this:
- Generate a broken filesystem
- Start FAN_FS_ERROR monitoring group
- Make the file system notice the error through ordinary operations
- Observe the event generated
FAN_FS_ERROR was added in the kernel by Linux commit 9709bd548f11 ("fanotify: Allow users to request FAN_FS_ERROR events").
---
Changes since v3:
- fanotify21 -> fanotify22 (Matthew)
Changes since v1:
- Move defines to header file.
- Move fanotify_mark(2) to do_test (Amir)
- Merge abort test here
--- testcases/kernel/syscalls/fanotify/.gitignore | 1 + testcases/kernel/syscalls/fanotify/fanotify.h | 3 + .../kernel/syscalls/fanotify/fanotify22.c | 140 ++++++++++++++++++ 3 files changed, 144 insertions(+) create mode 100644 testcases/kernel/syscalls/fanotify/fanotify22.c
testcases/kernel/syscalls/fanotify/.gitignore +1 -0
@@ -19,4 +19,5 @@ /fanotify19 /fanotify20 /fanotify21 +/fanotify22 /fanotify_child
testcases/kernel/syscalls/fanotify/fanotify.h +3 -0
@@ -127,6 +127,9 @@ static inline int safe_fanotify_mark(const char *file, const int lineno,#ifndef FAN_OPEN_EXEC_PERM #define FAN_OPEN_EXEC_PERM 0x00040000#endif +#ifndef FAN_FS_ERROR +#define FAN_FS_ERROR 0x00008000 +#endif /* Additional error status codes that can be returned to userspace */ #ifndef FAN_NOPIDFD
testcases/kernel/syscalls/fanotify/fanotify22.c new file +140 -0
140 lines not on this page · raw message
Signature · 1 line
2.33.0
PATCH v4 4/9 syscalls/fanotify22: Validate the generic error info
In reply to Gabriel Krisman BertaziImplement some validation for the generic error info record emitted by the kernel. The error number is fs-specific but, well, we only support ext4 for now anyway.
---
Changes since v2:
- check for error record type in autotools (Amir)
Changes since v1:
- Move defines to header file.
--- configure.ac | 3 +- testcases/kernel/syscalls/fanotify/fanotify.h | 32 ++++++++++++++++ .../kernel/syscalls/fanotify/fanotify22.c | 37 ++++++++++++++++++- 3 files changed, 70 insertions(+), 2 deletions(-)
configure.ac +2 -1
@@ -160,7 +160,8 @@ AC_CHECK_MEMBERS([struct utsname.domainname],,,[ AC_CHECK_TYPES([enum kcmp_type],,,[#include <linux/kcmp.h>]) AC_CHECK_TYPES([struct acct_v3],,,[#include <sys/acct.h>]) AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include <linux/if_alg.h>]) -AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header],,,[#include <sys/fanotify.h>]) +AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header, + struct fanotify_event_info_error],[],[],[#include <sys/fanotify.h>]) AC_CHECK_TYPES([struct file_dedupe_range],,,[#include <linux/fs.h>]) AC_CHECK_TYPES([struct file_handle],,,[
testcases/kernel/syscalls/fanotify/fanotify.h +32 -0
@@ -181,6 +181,9 @@ typedef struct {#ifndef FAN_EVENT_INFO_TYPE_PIDFD #define FAN_EVENT_INFO_TYPE_PIDFD 4#endif +#ifndef FAN_EVENT_INFO_TYPE_ERROR +#define FAN_EVENT_INFO_TYPE_ERROR 5 +#endif #ifndef HAVE_STRUCT_FANOTIFY_EVENT_INFO_HEADER struct fanotify_event_info_header {
@@ -205,6 +208,14 @@ struct fanotify_event_info_pidfd { };#endif /* HAVE_STRUCT_FANOTIFY_EVENT_INFO_PIDFD */ +#ifndef HAVE_STRUCT_FANOTIFY_EVENT_INFO_ERROR +struct fanotify_event_info_error { +struct fanotify_event_info_header hdr; +__s32 error; +__u32 error_count; +}; +#endif /* HAVE_STRUCT_FANOTIFY_EVENT_INFO_ERROR */ +/* NOTE: only for struct fanotify_event_info_fid */ #ifdef HAVE_STRUCT_FANOTIFY_EVENT_INFO_FID_FSID___VAL # define FSID_VAL_MEMBER (fsid, i) (fsid.__val[i])
@@ -418,4 +429,25 @@ static inline int fanotify_mark_supported_by_kernel(uint64_t flag) fanotify_events_supported_by_kernel(mask, init_flags, mark_type)); \ } while (0) +struct fanotify_event_info_header *get_event_info( +struct fanotify_event_metadata *event, +int info_type) +{ +struct fanotify_event_info_header *hdr =NULL ; +char *start = (char *) event; +int off; + +for (off = event->metadata_len; (off+sizeof (*hdr)) < event->event_len; + off += hdr->len) { + hdr = (struct fanotify_event_info_header *) &(start[off]); +if (hdr->info_type == info_type) +return hdr; + } +return NULL ; +} + +#define get_event_info_error (event) \ + ((struct fanotify_event_info_error *) \ + get_event_info((event), FAN_EVENT_INFO_TYPE_ERROR)) +#endif /* __FANOTIFY_H__ */
testcases/kernel/syscalls/fanotify/fanotify22.c +36 -1
@@ -48,14 +48,38 @@ static void trigger_fs_abort(void)static struct test_case {char *name; +int error; +unsigned int error_count;void (*trigger_error)(void ); } testcases[] = { { .name ="Trigger abort" , .trigger_error = &trigger_fs_abort, + .error_count =1 , + .error =ESHUTDOWN , }, }; +int check_error_event_info_error (struct fanotify_event_info_error *info_error, +const struct test_case *ex) +{ +int fail =0 ; + +if (info_error->error_count != ex->error_count) { +tst_res (TFAIL ,"%s: Unexpected error_count (%d!=%d)" , + ex->name, info_error->error_count, ex->error_count); + fail++; + } + +if (info_error->error != ex->error) { +tst_res (TFAIL ,"%s: Unexpected error code value (%d!=%d)" , + ex->name, info_error->error, ex->error); + fail++; + } + +return fail; +} +int check_error_event_metadata (struct fanotify_event_metadata *event) {int fail =0 ;
@@ -78,6 +102,8 @@ void check_event(char *buf, size_t len, const struct test_case *ex) {struct fanotify_event_metadata *event = (struct fanotify_event_metadata *) buf; +struct fanotify_event_info_error *info_error; +int fail =0 ;if (len <FAN_EVENT_METADATA_LEN ) {tst_res (TFAIL ,"No event metadata found" );
@@ -87,7 +113,16 @@ void check_event(char *buf, size_t len, const struct test_case *ex)if (check_error_event_metadata (event))return ; -tst_res (TPASS ,"Successfully received: %s" , ex->name); + info_error =get_event_info_error (event); +if (info_error) + fail +=check_error_event_info_error (info_error, ex); +else { +tst_res (TFAIL ,"Generic error record not found" ); + fail++; + } + +if (!fail) +tst_res (TPASS ,"Successfully received: %s" , ex->name); }static void do_test (unsigned int i)
Signature · 1 line
2.33.0
Re: [PATCH v4 4/9] syscalls/fanotify22: Validate the generic error info
Quoted 24 lines · Gabriel Krisman Bertazi
Implement some validation for the generic error info record emitted by the kernel. The error number is fs-specific but, well, we only support ext4 for now anyway.
Reviewed-by Amir Goldstein <[email protected]>Signed-off-by Gabriel Krisman Bertazi <[email protected]>---
Changes since v2:
- check for error record type in autotools (Amir)
Changes since v1:
- Move defines to header file.--- configure.ac | 3 +- testcases/kernel/syscalls/fanotify/fanotify.h | 32 ++++++++++++++++ .../kernel/syscalls/fanotify/fanotify22.c | 37 ++++++++++++++++++- 3 files changed, 70 insertions(+), 2 deletions(-)configure.ac +0
-0
configure.ac AC_CHECK_MEMBERS([struct utsname.domainname],,,[ · line 164
Quoted 6 lines
configure.ac +2
-1@@ -160,7 +160,8 @@ AC_CHECK_MEMBERS([struct utsname.domainname],,,[ AC_CHECK_TYPES([enum kcmp_type],,,[#include <linux/kcmp.h>]) AC_CHECK_TYPES([struct acct_v3],,,[#include <sys/acct.h>]) AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include <linux/if_alg.h>]) -AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header],,,[#include <sys/fanotify.h>]) +AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header, + struct fanotify_event_info_error],[],[],[#include <sys/fanotify.h>])
Doh! it seems like fanotify_event_info_pidfd was dropped between v2 -> v3 in Matthew's patches.
Petr,
Can you please fix this.
Thanks,
Amir.
Re: [PATCH v4 4/9] syscalls/fanotify22: Validate the generic error info
...
Quoted 10 lines
configure.ac AC_CHECK_MEMBERS([struct utsname.domainname],,,[ · line 164
Quoted 3 lines
configure.ac +2
-1-AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header],,,[#include <sys/fanotify.h>]) +AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header, + struct fanotify_event_info_error],[],[],[#include <sys/fanotify.h>])Doh! it seems like
fanotify_event_info_pidfdwas dropped between v2 -> v3 in Matthew's patches.Petr,
Can you please fix this.
Hi Amir,
thanks for info, sure I'll fix it on Monday.
Kind regards,
Petr
Quoted 2 lines
Thanks,
Amir.
Re: [PATCH v4 4/9] syscalls/fanotify22: Validate the generic error info
Hi Amir,
Quoted 8 lines
...
Quoted 6 lines
configure.ac AC_CHECK_MEMBERS([struct utsname.domainname],,,[ · line 164
Quoted 3 lines
configure.ac +2
-1-AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header],,,[#include <sys/fanotify.h>]) +AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header, + struct fanotify_event_info_error],[],[],[#include <sys/fanotify.h>])Doh! it seems like
fanotify_event_info_pidfdwas dropped between v2 -> v3 in Matthew's patches.
Quoted 7 lines
Quoted 3 lines
Petr,
Can you please fix this.
Hi Amir,
thanks for info, sure I'll fix it on Monday.
Fixed now. Thanks!
Kind regards,
Petr
Quoted 5 lines
Kind regards,
PetrQuoted 2 lines
Thanks,
Amir.
PATCH v4 5/9 syscalls/fanotify22: Validate incoming FID in FAN_FS_ERROR
In reply to Gabriel Krisman BertaziVerify the FID provided in the event. If the FH has size 0, this is assumed to be a superblock error (i.e. null FH).
---
Changes since v2:
- Move FILEID_INVALID define to header file (Amir)
- Don't use FSID_VAL_MEMBER (Petr)
Changes since v1:
- Move defines to header file.
- Use 0-len FH for sb error
--- testcases/kernel/syscalls/fanotify/fanotify.h | 8 +++ .../kernel/syscalls/fanotify/fanotify22.c | 60 +++++++++++++++++++ 2 files changed, 68 insertions(+)
testcases/kernel/syscalls/fanotify/fanotify.h +8 -0
@@ -255,6 +255,10 @@ static inline void fanotify_get_fid(const char *path, __kernel_fsid_t *fsid, } } +#ifndef FILEID_INVALID +#define FILEID_INVALID 0xff +#endif +struct fanotify_fid_t {__kernel_fsid_t fsid;struct file_handle handle;
@@ -450,4 +454,8 @@ struct fanotify_event_info_header *get_event_info( ((struct fanotify_event_info_error *) \ get_event_info((event), FAN_EVENT_INFO_TYPE_ERROR)) +#define get_event_info_fid (event) \ + ((struct fanotify_event_info_fid *) \ + get_event_info((event), FAN_EVENT_INFO_TYPE_FID)) +#endif /* __FANOTIFY_H__ */
testcases/kernel/syscalls/fanotify/fanotify22.c +60 -0
105 lines not on this page · raw message
Signature · 1 line
2.33.0
PATCH v4 6/9 syscalls/fanotify22: Support submission of debugfs commands
In reply to Gabriel Krisman BertaziIn order to test FAN_FS_ERROR, we want to corrupt the filesystem. The easiest way to do it is by using debugfs. Add a small helper to issue debugfs requests. Since most likely this will be the only testcase to need this, don't bother making it a proper helper for now.
---
changes since v1:
- Add .needs_cmds to require debugfs
--- testcases/kernel/syscalls/fanotify/fanotify22.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
testcases/kernel/syscalls/fanotify/fanotify22.c +12 -1
@@ -49,6 +49,13 @@ static void trigger_fs_abort(void) MS_REMOUNT|MS_RDONLY, "abort"); } +static void do_debugfs_request (const char *dev,char *request) +{ +const char *cmd[] = {"debugfs" ,"-w" , dev,"-R" , request,NULL }; + +SAFE_CMD (cmd,NULL ,NULL ); +} + static struct test_case { char *name; int error;
@@ -227,7 +234,11 @@ static struct tst_test test = { .mount_device = 1, .mntpoint = MOUNT_PATH, .needs_root = 1, - .dev_fs_type ="ext4" + .dev_fs_type = "ext4", + .needs_cmds = (const char *[]) { +"debugfs" , +NULL + } };#else
Signature · 1 line
2.33.0
PATCH v4 7/9 syscalls/fanotify22: Create a corrupted file
In reply to Gabriel Krisman BertaziAllocate a test directory and corrupt it with debugfs. The corruption is done by writing an invalid inode mode. This file can be later looked up to trigger a corruption error.
--- testcases/kernel/syscalls/fanotify/fanotify22.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
testcases/kernel/syscalls/fanotify/fanotify22.c +16 -0
@@ -39,9 +39,12 @@ static char event_buf[BUF_SIZE];int fd_notify;#define MOUNT_PATH "test_mnt" +#define BASE_DIR "internal_dir" +#define BAD_DIR BASE_DIR"/bad_dir"/* These expected FIDs are common to multiple tests */ static struct fanotify_fid_t null_fid; +static struct fanotify_fid_t bad_file_fid;static void trigger_fs_abort (void ) {
@@ -197,6 +200,18 @@ static void do_test(unsigned int i)check_event (event_buf, read_len, tcase); } +static void pre_corrupt_fs (void ) +{ +SAFE_MKDIR (MOUNT_PATH "/" BASE_DIR ,0777 ); +SAFE_MKDIR (MOUNT_PATH "/" BAD_DIR ,0777 ); + +fanotify_save_fid (MOUNT_PATH "/" BAD_DIR , &bad_file_fid); + +SAFE_UMOUNT (MOUNT_PATH ); +do_debugfs_request (tst_device->dev,"sif " BAD_DIR " mode 0xff" ); +SAFE_MOUNT (tst_device->dev,MOUNT_PATH , tst_device->fs_type,0 ,NULL ); +} +static void init_null_fid (void ) {/* Use fanotify_save_fid to fill the fsid and overwrite the
@@ -213,6 +228,7 @@ static void setup(void)REQUIRE_FANOTIFY_EVENTS_SUPPORTED_ON_FS (FAN_CLASS_NOTIF |FAN_REPORT_FID ,FAN_MARK_FILESYSTEM ,FAN_FS_ERROR ,"." ); +pre_corrupt_fs (); fd_notify =SAFE_FANOTIFY_INIT (FAN_CLASS_NOTIF |FAN_REPORT_FID ,O_RDONLY );
Signature · 1 line
2.33.0
PATCH v4 8/9 syscalls/fanotify22: Test file event with broken inode
In reply to Gabriel Krisman BertaziThis test corrupts an inode entry with an invalid mode through debugfs and then tries to access it. This should result in a ext4 error, which we monitor through the fanotify group.
In order for this test to succeed, it requires a kernel fix introduced by kernel commit 124e7c61deb2 ("ext4: fix error code saved on super block during file system abort"), which is added to .tags.
--- .../kernel/syscalls/fanotify/fanotify22.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+)
testcases/kernel/syscalls/fanotify/fanotify22.c +26 -0
@@ -34,6 +34,10 @@#ifdef HAVE_SYS_FANOTIFY_H #include "fanotify.h" +#ifndef EFSCORRUPTED +#define EFSCORRUPTED EUCLEAN/* Filesystem is corrupted */ +#endif +#define BUF_SIZE 256static char event_buf[BUF_SIZE ];int fd_notify;
@@ -59,6 +63,17 @@ static void do_debugfs_request(const char *dev, char *request)SAFE_CMD (cmd,NULL ,NULL ); } +static void tcase2_trigger_lookup (void ) +{ +int ret; + +/* SAFE_OPEN cannot be used here because we expect it to fail. */ + ret =open (MOUNT_PATH "/" BAD_DIR ,O_RDONLY ,0 ); +if (ret !=-1 && errno !=EUCLEAN ) +tst_res (TFAIL ,"Unexpected lookup result(%d) of %s (%d!=%d)" , + ret,BAD_DIR , errno,EUCLEAN ); +} + static struct test_case { char *name; int error;
@@ -73,6 +88,13 @@ static struct test_case { .error = ESHUTDOWN, .fid = &null_fid, }, + { + .name = "Lookup of inode with invalid mode", + .trigger_error = &tcase2_trigger_lookup, + .error_count = 1, + .error = EFSCORRUPTED, + .fid = &bad_file_fid, + }, }; int check_error_event_info_fid(struct fanotify_event_info_fid *fid,
@@ -251,6 +273,10 @@ static struct tst_test test = { .mntpoint = MOUNT_PATH, .needs_root = 1, .dev_fs_type = "ext4", + .tags = (const struct tst_tag []) { + {"linux-git" ,"124e7c61deb2" }, + {} + }, .needs_cmds = (const char *[]) {"debugfs" ,NULL
Signature · 1 line
2.33.0
PATCH v4 9/9 syscalls/fanotify22: Test capture of multiple errors
In reply to Gabriel Krisman BertaziWhen multiple FS errors occur, only the first is stored. This testcase validates this behavior by issuing two different errors and making sure only the first is stored, while the second is simply accumulated in error_count.
--- .../kernel/syscalls/fanotify/fanotify22.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+)
testcases/kernel/syscalls/fanotify/fanotify22.c +26 -0
@@ -74,6 +74,18 @@ static void tcase2_trigger_lookup(void) ret, BAD_DIR, errno, EUCLEAN); } +static void tcase3_trigger (void ) +{ +trigger_fs_abort (); +tcase2_trigger_lookup (); +} + +static void tcase4_trigger (void ) +{ +tcase2_trigger_lookup (); +trigger_fs_abort (); +} + static struct test_case { char *name; int error;
@@ -95,6 +107,20 @@ static struct test_case { .error = EFSCORRUPTED, .fid = &bad_file_fid, }, + { + .name = "Multiple error submission", + .trigger_error = &tcase3_trigger, + .error_count = 2, + .error = ESHUTDOWN, + .fid = &null_fid, + }, + { + .name = "Multiple error submission 2", + .trigger_error = &tcase4_trigger, + .error_count = 2, + .error = EFSCORRUPTED, + .fid = &bad_file_fid, + } }; int check_error_event_info_fid(struct fanotify_event_info_fid *fid,
Signature · 1 line
2.33.0
Quoted 29 lines · Gabriel Krisman Bertazi
Hi,
FAN_FS_ERRORwas merged into Linus tree, and the PIDFD testcases reached LTP. Therefore, I'm sending a new version of theFAN_FS_ERRORLTP tests. This is the v4 of this patchset, and it applies the feedback of the previous version.Thanks,
---
Original cover letter:
FAN_FS_ERRORis a new (still unmerged) fanotify event to monitor fileystem errors. This patchset introduces a new LTP test for this feature.Testing file system errors is slightly tricky, in particular because they are mostly file system dependent. Since there are only patches for ext4, I choose to make the test around it, since there wouldn't be much to do with other file systems. The second challenge is how we cause the file system errors, since there is no error injection for ext4 in Linux. In this series, this is done by corrupting specific data in the test device with the help of debugfs.
The
FAN_FS_ERRORfeature is flying around linux-ext4 and fsdevel, and the latest version is available on the branch below:
Quoted 9 lines
https://gitlab.collabora.com/krisman/linux -b fanotify-notifications-v9
A proper manpage description is also available on the respective mailing list, or in the branch below:
https://gitlab.collabora.com/krisman/man-pages.git -b fan-fs-error
Please, let me know your thoughts.
Gabriel,
Can you please push these v4 patches to your gitlab tree?
Thanks,
Amir.
Quoted 36 lines · Amir Goldstein
Quoted 34 lines · Gabriel Krisman Bertazi
Hi,
FAN_FS_ERRORwas merged into Linus tree, and the PIDFD testcases reached LTP. Therefore, I'm sending a new version of theFAN_FS_ERRORLTP tests. This is the v4 of this patchset, and it applies the feedback of the previous version.Thanks,
---
Original cover letter:
FAN_FS_ERRORis a new (still unmerged) fanotify event to monitor fileystem errors. This patchset introduces a new LTP test for this feature.Testing file system errors is slightly tricky, in particular because they are mostly file system dependent. Since there are only patches for ext4, I choose to make the test around it, since there wouldn't be much to do with other file systems. The second challenge is how we cause the file system errors, since there is no error injection for ext4 in Linux. In this series, this is done by corrupting specific data in the test device with the help of debugfs.
The
FAN_FS_ERRORfeature is flying around linux-ext4 and fsdevel, and the latest version is available on the branch below:https://gitlab.collabora.com/krisman/linux -b fanotify-notifications-v9
A proper manpage description is also available on the respective mailing list, or in the branch below:
Quoted 8 lines
Quoted 4 lines
https://gitlab.collabora.com/krisman/man-pages.git -b fan-fs-error
Please, let me know your thoughts.
Gabriel,
Can you please push these v4 patches to your gitlab tree?
Hi Amir,
I have pushed v4 to :
https://gitlab.collabora.com/krisman/ltp.git -b fan-fs-error_v4
Thank you!
Signature · 1 line
Gabriel Krisman Bertazi
Quoted 10 lines
Quoted 10 lines
Quoted 7 lines
A proper manpage description is also available on the respective mailing list, or in the branch below:
https://gitlab.collabora.com/krisman/man-pages.git -b fan-fs-error
Please, let me know your thoughts.
Gabriel,
Quoted 8 lines
Quoted 1 line
Can you please push these v4 patches to your gitlab tree?
Hi Amir,
I have pushed v4 to :
https://gitlab.collabora.com/krisman/ltp.git -b fan-fs-error_v4
Thanks. I've based my fan_rename ltp branch on this.
I would like to do the same for the man-page update branch. However, Matthew's man page updates for v5.15 are conflicting with your changes, so after Matthew posts v2 of his man page patch, please rebase your changes on top of his branch.
Ideally, you could have waited until Matthew's changes are merged upstream, like you did for ltp before rebasing, but man-pages maintainers are quite behind on merging updates, so we will need to collaborate between us in the meanwhile.
Thanks,
Amir.
Hi all,
<snip>
Quoted 5 lines
Hi Amir,
I have pushed v4 to :
https://gitlab.collabora.com/krisman/ltp.git -b fan-fs-error_v4
FYI I've rebased it on my fix 3b2ea2e00 ("configure.ac: Add struct fanotify_event_info_pidfd check")
https://github.com/linux-test-project/ltp.git -b gertazi/fanotify21.v4.fixes
diff to krisman/fan-fs-error_v4:
configure.ac +2 -2
@@ -160,8 +160,8 @@ AC_CHECK_MEMBERS([struct utsname.domainname],,,[ AC_CHECK_TYPES([enum kcmp_type],,,[#include <linux/kcmp.h>]) AC_CHECK_TYPES([struct acct_v3],,,[#include <sys/acct.h>]) AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include <linux/if_alg.h>]) -AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header, - struct fanotify_event_info_error],[],[],[#include <sys/fanotify.h>]) +AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_error, + struct fanotify_event_info_header, struct fanotify_event_info_pidfd],,,[#include <sys/fanotify.h>]) AC_CHECK_TYPES([struct file_dedupe_range],,,[#include <linux/fs.h>]) AC_CHECK_TYPES([struct file_handle],,,[
Kind regards,
Petr
Quoted 7 lines · Petr Vorel
Hi all,
<snip>
Quoted 3 lines
Hi Amir,
I have pushed v4 to :
Quoted 8 lines
Quoted 1 line
https://gitlab.collabora.com/krisman/ltp.git -b fan-fs-error_v4
FYI I've rebased it on my fix
3b2ea2e00("configure.ac: Add structfanotify_event_info_pidfdcheck")https://github.com/linux-test-project/ltp.git -b gertazi/fanotify21.v4.fixes
diff to krisman/fan-fs-error_v4:
Petr,
Should I send a v5 or is v4 getting picked up and merged with the fixup hunk?
Thanks,
Signature · 1 line
Gabriel Krisman Bertazi
Hi all,
Quoted 14 lines
Quoted 11 lines · Petr Vorel
Hi all,
<snip>
Quoted 5 lines
Hi Amir,
I have pushed v4 to :
https://gitlab.collabora.com/krisman/ltp.git -b fan-fs-error_v4
FYI I've rebased it on my fix
3b2ea2e00("configure.ac: Add structfanotify_event_info_pidfdcheck")
Quoted 8 lines
Quoted 3 lines
https://github.com/linux-test-project/ltp.git -b gertazi/fanotify21.v4.fixes
diff to krisman/fan-fs-error_v4:
Petr,
Should I send a v5 or is v4 getting picked up and merged with the fixup hunk?
No need to sent v4, I'll merge it from my branch. This is info for Amir, which wanted to use your git tree to base his patchset on (if it wasn't relevant only to patches for man-pages).
Kind regards,
Petr
Hi all,
<snip>
Quoted 10 lines
Quoted 5 lines
Hi Amir,
I have pushed v4 to :
https://gitlab.collabora.com/krisman/ltp.git -b fan-fs-error_v4
FYI I've rebased it on my fix
3b2ea2e00("configure.ac: Add structfanotify_event_info_pidfdcheck")https://github.com/linux-test-project/ltp.git -b gertazi/fanotify21.v4.fixes
FYI I removed branch from official LTP repository and put it to my fork
https://github.com/pevik/ltp.git -b fan-fs-error_v4.fixes
Kind regards,
Petr
Quoted 20 lines
diff to krisman/fan-fs-error_v4:
configure.ac +2
-2@@ -160,8 +160,8 @@ AC_CHECK_MEMBERS([struct utsname.domainname],,,[ AC_CHECK_TYPES([enum kcmp_type],,,[#include <linux/kcmp.h>]) AC_CHECK_TYPES([struct acct_v3],,,[#include <sys/acct.h>]) AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include <linux/if_alg.h>]) -AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_header, - struct fanotify_event_info_error],[],[],[#include <sys/fanotify.h>]) +AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_error, + struct fanotify_event_info_header, struct fanotify_event_info_pidfd],,,[#include <sys/fanotify.h>]) AC_CHECK_TYPES([struct file_dedupe_range],,,[#include <linux/fs.h>]) AC_CHECK_TYPES([struct file_handle],,,[Kind regards,
Petr
Quoted 10 lines · Petr Vorel
Hi all,
<snip>
Quoted 5 lines
Quoted 5 lines
Hi Amir,
I have pushed v4 to :
https://gitlab.collabora.com/krisman/ltp.git -b fan-fs-error_v4
Quoted 8 lines
Quoted 4 lines
FYI I've rebased it on my fix
3b2ea2e00("configure.ac: Add structfanotify_event_info_pidfdcheck")https://github.com/linux-test-project/ltp.git -b gertazi/fanotify21.v4.fixes
FYI I removed branch from official LTP repository and put it to my fork
https://github.com/pevik/ltp.git -b fan-fs-error_v4.fixes
Hi Petr,
Are you waiting with this merge for after release of v5.16? or is it just waiting behind other work?
Just asking out of curiosity.
I've based my tests for fan_rename (queued for v5.17) on top of your branch.
Thanks,
Amir.
Hi Amir,
[ Cc Cyril and Richie ]
Quoted 16 lines · Petr Vorel
Quoted 14 lines
Hi all,
<snip>
Quoted 10 lines
Quoted 5 lines
Hi Amir,
I have pushed v4 to :
https://gitlab.collabora.com/krisman/ltp.git -b fan-fs-error_v4
FYI I've rebased it on my fix
3b2ea2e00("configure.ac: Add structfanotify_event_info_pidfdcheck")https://github.com/linux-test-project/ltp.git -b gertazi/fanotify21.v4.fixes
Quoted 8 lines
Quoted 2 lines
FYI I removed branch from official LTP repository and put it to my fork
https://github.com/pevik/ltp.git -b fan-fs-error_v4.fixesHi Petr,
Are you waiting with this merge for after release of v5.16? or is it just waiting behind other work?
Yes. Thanks for this input, we're just discussing our policy about tests for new (kernel) release functionality. First we agreed to wait [1] (due problems described in [2]), Richie is suggesting to merge earlier [2], although Cyril had doubts it's worth of the work [3].
Kind regards,
Petr
Quoted 5 lines
Just asking out of curiosity.
I've based my tests forfan_rename(queued for v5.17) on top of your branch.Thanks,
Amir.
[1] https://lore.kernel.org/ltp/[email protected]/
[2] https://lore.kernel.org/ltp/[email protected]/
[3] https://lore.kernel.org/ltp/Ybc5QJSZM3YIji70@yuki/
Hi all,
v5.16 released => patchset merged.
Thanks!
Kind regards,
Petr
Quoted 6 lines · Petr Vorel
Hi all,
v5.16 released => patchset merged.
Thanks!
Guys,
Looks like we have a regression.
With kernel v5.17-rc1, test fanotify22 blocks on the first test case, because the expected ECORRUPTED event on remount,abort is never received. The multiple error test cases also fail for the same reason.
Gabriel,
Are you aware of any ext4 change that could explain this regression?
In any case, Petr, I suggest adding a short timeout to the test instead of the default 5min.
Test takes less than 1 second on my VM on v5.16, so...
Thanks,
Amir.
Quoted 5 lines · Amir Goldstein
Quoted 3 lines · Petr Vorel
Hi all,
Quoted 7 lines
Quoted 3 lines
v5.16 released => patchset merged.
Thanks!Guys,
Looks like we have a regression.
agreed, "abort" option stopped working:
https://gitlab.com/cki-project/kernel-tests/-/issues/945
Lukas pointed out this patch that didn't make it in yet:
https://lkml.org/lkml/2021/12/21/384
This should be new version:
https://lore.kernel.org/linux-ext4/YcSYvk5DdGjjB9q%[email protected]/T/#t
Quoted 18 lines
With kernel v5.17-rc1, test fanotify22 blocks on the first test case, because the expected ECORRUPTED event on remount,abort is never received. The multiple error test cases also fail for the same reason.
Gabriel,
Are you aware of any ext4 change that could explain this regression?
In any case, Petr, I suggest adding a short timeout to the test instead of the default 5min.
Test takes less than 1 second on my VM on v5.16, so...Thanks,
Amir.--
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 5 lines · Jan Stancek
Quoted 3 lines · Amir Goldstein
Guys,
Looks like we have a regression.
Quoted 7 lines
agreed, "abort" option stopped working:
https://gitlab.com/cki-project/kernel-tests/-/issues/945Lukas pointed out this patch that didn't make it in yet:
https://lkml.org/lkml/2021/12/21/384
This should be new version:
https://lore.kernel.org/linux-ext4/YcSYvk5DdGjjB9q%[email protected]/T/#t
I gave this patch a try and verified it fixes the test case regression. Let me ask Ted to make sure it is merged for the 5.17 release.
Thanks,
Signature · 1 line
Gabriel Krisman Bertazi
Hi Amir,
Quoted 15 lines · Petr Vorel
Quoted 5 lines
Hi all,
v5.16 released => patchset merged.
Thanks!Guys,
Looks like we have a regression.
With kernel v5.17-rc1, test fanotify22 blocks on the first test case, because the expected ECORRUPTED event on remount,abort is never received. The multiple error test cases also fail for the same reason.
Quoted 7 lines
Gabriel,
Are you aware of any ext4 change that could explain this regression?
In any case, Petr, I suggest adding a short timeout to the test instead of the default 5min.
Test takes less than 1 second on my VM on v5.16, so...
We usually don't lower the default timeout, but here it's a good idea since here it blocks. It's similar speed on my machine, but I'd be conservative and put timeout 10 sec. Sending patch.
Kind regards,
Petr
Quoted 2 lines
Thanks,
Amir.
Hi!
Quoted 6 lines
Quoted 3 lines
In any case, Petr, I suggest adding a short timeout to the test instead of the default 5min.
Test takes less than 1 second on my VM on v5.16, so...We usually don't lower the default timeout, but here it's a good idea since here it blocks. It's similar speed on my machine, but I'd be conservative and put timeout 10 sec. Sending patch.
Actually I hope to change the default timeout once I finish my runtime patchset to something more reasonable as majority of LTP tests finish under one second.
Signature · 2 lines
Cyril Hrubis [email protected]
Quoted 11 lines
Hi!
Quoted 6 lines
Quoted 3 lines
In any case, Petr, I suggest adding a short timeout to the test instead of the default 5min.
Test takes less than 1 second on my VM on v5.16, so...We usually don't lower the default timeout, but here it's a good idea since here it blocks. It's similar speed on my machine, but I'd be conservative and put timeout 10 sec. Sending patch.
Actually I hope to change the default timeout once I finish my runtime patchset to something more reasonable as majority of LTP tests finish under one second.
+1. We can then revert that temporary fix for fanotify22.
Kind regards,
Petr