From: Zhang Yi <yi.zhang@xxxxxxxxxx> Add fstress to suppoet fallocate FALLOC_FL_WRITE_ZEROES command by introducing OP_WZERO operation. Signed-off-by: Zhang Yi <yi.zhang@xxxxxxxxxx> --- ltp/fsstress.c | 12 ++++++++++++ src/global.h | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 3d248ee2..ed2a54ab 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -114,6 +114,7 @@ typedef enum { OP_MWRITE, OP_PUNCH, OP_ZERO, + OP_WZERO, OP_COLLAPSE, OP_INSERT, OP_READ, @@ -245,6 +246,7 @@ void mread_f(opnum_t, long); void mwrite_f(opnum_t, long); void punch_f(opnum_t, long); void zero_f(opnum_t, long); +void wzero_f(opnum_t, long); void collapse_f(opnum_t, long); void insert_f(opnum_t, long); void unshare_f(opnum_t, long); @@ -312,6 +314,7 @@ struct opdesc ops[OP_LAST] = { [OP_MWRITE] = {"mwrite", mwrite_f, 2, 1 }, [OP_PUNCH] = {"punch", punch_f, 1, 1 }, [OP_ZERO] = {"zero", zero_f, 1, 1 }, + [OP_WZERO] = {"wzero", wzero_f, 1, 1 }, [OP_COLLAPSE] = {"collapse", collapse_f, 1, 1 }, [OP_INSERT] = {"insert", insert_f, 1, 1 }, [OP_READ] = {"read", read_f, 1, 0 }, @@ -3758,6 +3761,7 @@ struct print_flags falloc_flags [] = { { FALLOC_FL_NO_HIDE_STALE, "NO_HIDE_STALE"}, { FALLOC_FL_COLLAPSE_RANGE, "COLLAPSE_RANGE"}, { FALLOC_FL_ZERO_RANGE, "ZERO_RANGE"}, + { FALLOC_FL_WRITE_ZEROES, "WRITE_ZEROES"}, { FALLOC_FL_INSERT_RANGE, "INSERT_RANGE"}, { FALLOC_FL_UNSHARE_RANGE, "UNSHARE_RANGE"}, { -1, NULL} @@ -4446,6 +4450,14 @@ zero_f(opnum_t opno, long r) #endif } +void +wzero_f(opnum_t opno, long r) +{ +#ifdef HAVE_LINUX_FALLOC_H + do_fallocate(opno, r, FALLOC_FL_WRITE_ZEROES); +#endif +} + void collapse_f(opnum_t opno, long r) { diff --git a/src/global.h b/src/global.h index fbc0a0b5..6b1e30c9 100644 --- a/src/global.h +++ b/src/global.h @@ -175,6 +175,10 @@ #define FALLOC_FL_ZERO_RANGE 0x10 #endif +#ifndef FALLOC_FL_WRITE_ZEROES +#define FALLOC_FL_WRITE_ZEROES 0x80 +#endif + #ifndef FALLOC_FL_INSERT_RANGE #define FALLOC_FL_INSERT_RANGE 0x20 #endif -- 2.46.1