xfstests: fsstress: Add fallocate insert range operation
PATCH v7 10/11 xfstests: fsstress: Add fallocate insert range operation
This commit adds insert operation support for fsstress, which is meant to exercise fallocate FALLOC_FL_INSERT_RANGE support.
--- ltp/fsstress.c | 19 ++++++++++++++++--- src/global.h | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-)
ltp/fsstress.c +16 -3
@@ -72,6 +72,7 @@ typedef enum {OP_PUNCH ,OP_ZERO ,OP_COLLAPSE , +OP_INSERT ,OP_READ ,OP_READLINK , OP_RENAME,
@@ -170,6 +171,7 @@ void mknod_f(int, long);void punch_f (int ,long );void zero_f (int ,long );void collapse_f (int ,long ); +void insert_f (int ,long );void read_f (int ,long );void readlink_f (int ,long );void rename_f (int ,long );
@@ -209,6 +211,7 @@ opdesc_t ops[] = { { OP_PUNCH, "punch", punch_f, 1, 1 }, { OP_ZERO, "zero", zero_f, 1, 1 }, { OP_COLLAPSE, "collapse", collapse_f, 1, 1 }, + { OP_INSERT, "insert", insert_f, 1, 1 }, { OP_READ, "read", read_f, 1, 0 }, { OP_READLINK, "readlink", readlink_f, 1, 0 }, { OP_RENAME, "rename", rename_f, 2, 1 },
@@ -2176,6 +2179,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_INSERT_RANGE, "INSERT_RANGE"}, { -1, NULL} };
@@ -2227,10 +2231,11 @@ do_fallocate(int opno, long r, int mode) off %= maxfsize; len = (off64_t)(random () % (1024 *1024 ));/* -* Collapse range requires off and len to be block aligned, make it -* more likely to be the case. +* Collapse/insert range requires off and len to be block aligned, +* make it more likely to be the case. */ -if ((mode &FALLOC_FL_COLLAPSE_RANGE ) && (opno %2 )) { +if ((mode & (FALLOC_FL_COLLAPSE_RANGE |FALLOC_FL_INSERT_RANGE )) && + (opno %2 )) { off = ((off + stb.st_blksize -1 ) & ~(stb.st_blksize -1 )); len = ((len + stb.st_blksize -1 ) & ~(stb.st_blksize -1 )); }
@@ -2656,6 +2661,14 @@ collapse_f(int opno, long r) }void +insert_f (int opno,long r) +{ +#ifdef HAVE_LINUX_FALLOC_H +do_fallocate (opno, r,FALLOC_FL_INSERT_RANGE ); +#endif +} + +void read_f (int opno,long r) {char *buf;
src/global.h +4 -0
@@ -172,6 +172,10 @@#define FALLOC_FL_ZERO_RANGE 0x10#endif +#ifndef FALLOC_FL_INSERT_RANGE +#define FALLOC_FL_INSERT_RANGE 0x20 +#endif +#endif /* HAVE_LINUX_FALLOC_H */ #endif /* GLOBAL_H */
Signature · 6 lines
1.7.11-rc0 _______________________________________________ xfs mailing list [email protected] http://oss.sgi.com/mailman/listinfo/xfs
Quoted 6 lines · Namjae Jeon
This commit adds insert operation support for fsstress, which is meant to exercise fallocate
FALLOC_FL_INSERT_RANGEsupport.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Ashish Sangwan <[email protected]>---
It might be nice to avoid setting FALLOC_FL_KEEP_SIZE for insert and collapse ops alike (see the only use of KEEP_SIZE in fsstress.c) to increase the likelihood of valid fallocate() calls. We currently set it randomly, but unconditionally across all fallocate ops.
That could be done in a separate patch, however, and this looks good to me:
Quoted 88 lines
ltp/fsstress.c | 19 ++++++++++++++++--- src/global.h | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-)ltp/fsstress.c +16
-3@@ -72,6 +72,7 @@ typedef enum {OP_PUNCH ,OP_ZERO ,OP_COLLAPSE , +OP_INSERT ,OP_READ ,OP_READLINK , OP_RENAME,@@ -170,6 +171,7 @@ void mknod_f(int, long);void punch_f (int ,long );void zero_f (int ,long );void collapse_f (int ,long ); +void insert_f (int ,long );void read_f (int ,long );void readlink_f (int ,long );void rename_f (int ,long );@@ -209,6 +211,7 @@ opdesc_t ops[] = { { OP_PUNCH, "punch", punch_f, 1, 1 }, { OP_ZERO, "zero", zero_f, 1, 1 }, { OP_COLLAPSE, "collapse", collapse_f, 1, 1 }, + { OP_INSERT, "insert", insert_f, 1, 1 }, { OP_READ, "read", read_f, 1, 0 }, { OP_READLINK, "readlink", readlink_f, 1, 0 }, { OP_RENAME, "rename", rename_f, 2, 1 },@@ -2176,6 +2179,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_INSERT_RANGE, "INSERT_RANGE"}, { -1, NULL} };@@ -2227,10 +2231,11 @@ do_fallocate(int opno, long r, int mode) off %= maxfsize; len = (off64_t)(random () % (1024 *1024 ));/* -* Collapse range requires off and len to be block aligned, make it -* more likely to be the case. +* Collapse/insert range requires off and len to be block aligned, +* make it more likely to be the case. */ -if ((mode &FALLOC_FL_COLLAPSE_RANGE ) && (opno %2 )) { +if ((mode & (FALLOC_FL_COLLAPSE_RANGE |FALLOC_FL_INSERT_RANGE )) && + (opno %2 )) { off = ((off + stb.st_blksize -1 ) & ~(stb.st_blksize -1 )); len = ((len + stb.st_blksize -1 ) & ~(stb.st_blksize -1 )); }@@ -2656,6 +2661,14 @@ collapse_f(int opno, long r) }void +insert_f (int opno,long r) +{ +#ifdef HAVE_LINUX_FALLOC_H +do_fallocate (opno, r,FALLOC_FL_INSERT_RANGE ); +#endif +} + +void read_f (int opno,long r) {char *buf;src/global.h +4
-0@@ -172,6 +172,10 @@#define FALLOC_FL_ZERO_RANGE 0x10#endif +#ifndef FALLOC_FL_INSERT_RANGE +#define FALLOC_FL_INSERT_RANGE 0x20 +#endif +#endif /* HAVE_LINUX_FALLOC_H */ #endif /* GLOBAL_H */ Signature · 1 line
1.7.11-rc0
Quoted 9 lines · Namjae Jeon
Quoted 6 lines
This commit adds insert operation support for fsstress, which is meant to exercise fallocate
FALLOC_FL_INSERT_RANGEsupport.Signed-off-by Namjae Jeon <[email protected]>Signed-off-by Ashish Sangwan <[email protected]>---
Quoted 7 lines
It might be nice to avoid setting
FALLOC_FL_KEEP_SIZEfor insert and collapse ops alike (see the only use ofKEEP_SIZEinfsstress.c) to increase the likelihood of validfallocate()calls. We currently set it randomly, but unconditionally across all fallocate ops.That could be done in a separate patch, however, and this looks good to me:
Thank you! I will share a separate patch.
Quoted 91 lines
Reviewed-by Brian Foster <[email protected]>Quoted 88 lines
ltp/fsstress.c | 19 ++++++++++++++++--- src/global.h | 4 ++++ 2 files changed, 20 insertions(+), 3 deletions(-)ltp/fsstress.c +16
-3@@ -72,6 +72,7 @@ typedef enum {OP_PUNCH ,OP_ZERO ,OP_COLLAPSE , +OP_INSERT ,OP_READ ,OP_READLINK , OP_RENAME,@@ -170,6 +171,7 @@ void mknod_f(int, long);void punch_f (int ,long );void zero_f (int ,long );void collapse_f (int ,long ); +void insert_f (int ,long );void read_f (int ,long );void readlink_f (int ,long );void rename_f (int ,long );@@ -209,6 +211,7 @@ opdesc_t ops[] = { { OP_PUNCH, "punch", punch_f, 1, 1 }, { OP_ZERO, "zero", zero_f, 1, 1 }, { OP_COLLAPSE, "collapse", collapse_f, 1, 1 }, + { OP_INSERT, "insert", insert_f, 1, 1 }, { OP_READ, "read", read_f, 1, 0 }, { OP_READLINK, "readlink", readlink_f, 1, 0 }, { OP_RENAME, "rename", rename_f, 2, 1 },@@ -2176,6 +2179,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_INSERT_RANGE, "INSERT_RANGE"}, { -1, NULL} };@@ -2227,10 +2231,11 @@ do_fallocate(int opno, long r, int mode) off %= maxfsize; len = (off64_t)(random () % (1024 *1024 ));/* -* Collapse range requires off and len to be block aligned, make it -* more likely to be the case. +* Collapse/insert range requires off and len to be block aligned, +* make it more likely to be the case. */ -if ((mode &FALLOC_FL_COLLAPSE_RANGE ) && (opno %2 )) { +if ((mode & (FALLOC_FL_COLLAPSE_RANGE |FALLOC_FL_INSERT_RANGE )) && + (opno %2 )) { off = ((off + stb.st_blksize -1 ) & ~(stb.st_blksize -1 )); len = ((len + stb.st_blksize -1 ) & ~(stb.st_blksize -1 )); }@@ -2656,6 +2661,14 @@ collapse_f(int opno, long r) }void +insert_f (int opno,long r) +{ +#ifdef HAVE_LINUX_FALLOC_H +do_fallocate (opno, r,FALLOC_FL_INSERT_RANGE ); +#endif +} + +void read_f (int opno,long r) {char *buf;src/global.h +4
-1@@ -172,6 +172,10 @@#define FALLOC_FL_ZERO_RANGE 0x10#endif +#ifndef FALLOC_FL_INSERT_RANGE +#define FALLOC_FL_INSERT_RANGE 0x20 +#endif +#endif /* HAVE_LINUX_FALLOC_H */ #endif /* GLOBAL_H */ --1.7.11-rc0