[PATCH 15/15] Add create benchmark command to debugfs
Valerie Aurora
val at versity.com
Wed Mar 12 07:33:54 PDT 2025
Add the "bcreate" command to debugfs to create a bunch of files.
Signed-off-by: Valerie Aurora <val at versity.com>
---
cli/debugfs.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/cli/debugfs.c b/cli/debugfs.c
index 07f6b5f..e0a5aa2 100644
--- a/cli/debugfs.c
+++ b/cli/debugfs.c
@@ -38,6 +38,44 @@ struct debugfs_context {
#define LINE_SIZE (PATH_MAX * 5)
#define MAX_ARGC ((LINE_SIZE + 1) / 2)
+static void cmd_bcreate(struct debugfs_context *ctx, int argc, char **argv)
+{
+ struct ngnfs_dir_lookup_entry lent;
+ char filename[NGNFS_NAME_MAX];
+ char *dir;
+ u64 creates, i;
+ int ret;
+
+ if (argc != 3) {
+ printf("usage: %s <directory name> <number creates>\n", argv[0]);
+ return;
+ }
+
+ dir = argv[1];
+ ret = parse_ull(&creates, argv[2], 1, NGNFS_LINK_MAX - 1);
+ if (ret < 0) {
+ printf("number of creates must be between 1 and %d\n", NGNFS_LINK_MAX - 1);
+ return;
+ }
+
+ ret = ngnfs_dir_mkdir(ctx->nfi, &ctx->cwd_ig, 0755, dir, strlen(dir)) ?:
+ ngnfs_dir_lookup(ctx->nfi, &ctx->cwd_ig, dir, strlen(dir), &lent);
+
+ if (ret < 0) {
+ printf("error creating %s:"ENOF"\n", dir, ENOA(-ret));
+ return;
+ }
+
+ for (i = 0; i < creates; i++) {
+ snprintf(filename, sizeof(filename), "%llu", i);
+ ret = ngnfs_dir_create(ctx->nfi, &lent.ig, 0644, filename, strlen(filename));
+ if (ret < 0) {
+ printf("create error: "ENOF"\n", ENOA(-ret));
+ return;
+ }
+ }
+}
+
static void cmd_brename(struct debugfs_context *ctx, int argc, char **argv)
{
struct ngnfs_dir_lookup_entry lent, sub_lent;
@@ -405,6 +443,7 @@ static struct command {
char *name;
void (*func)(struct debugfs_context *ctx, int argc, char **argv);
} commands[] = {
+ { "bcreate", cmd_bcreate, },
{ "brename", cmd_brename, },
{ "cd", cmd_cd, },
{ "create", cmd_create, },
--
2.48.1
More information about the ngnfs-devel
mailing list