Creating lots of files on Hammer

Michael Neumann mneumann at ntecs.de
Thu Jul 10 12:36:06 PDT 2008


Hi,

I wrote a script that generates 1 million files in one directory on the
hammer filesystem. The first 100k are created very quickly, then it
starts to get less predictive. It stops completely after creating 836k
files. I can still ping the machine, but I can't ssh into it any more.
It's a head-less system so I can tell what is going on exactly.
I'm using the attached C file like this:

  cr 1000000 test

Regards,

  Michael
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>

int main(int argc, char **argv)
{
  char path[100];
  int i, n, fh;

  if (argc != 3) {
    fprintf(stderr, "Usage: %s n dir\n", argv[0]);
    return -1;
  }

  n = atoi(argv[1]);
  for (i = 0; i < n; i++) {
    snprintf(path, 100, "%s/%d", argv[2], i);
    fh = open(path, O_CREAT | O_TRUNC | O_WRONLY);
    if (fh == -1)
      return -2;
    close(fh);

    if (i % 1000 == 0)
      printf("%d\n", i);
  }
  return 0;
}




More information about the Users mailing list