Пример #1
0
Файл: main.c Проект: wtaysom/tau
int mkdirp (int argc, char *argv[])
{
	int	i;
	int	rc;
FN;
	for (i = 1; i < argc; i++) {
		rc = Mknode(argv[i], S_IFDIR);
		if (rc) {
			printf("Couldn't mkdir %s\n", argv[i]);
			return rc;
		}
	}
	return 0;
}
Пример #2
0
Файл: main.c Проект: wtaysom/tau
int genp (int argc, char *argv[])
{
	int	n;
	int	i;
	int	rc;
	char	*name;

	if (argc > 1) {
		n = atoi(argv[1]);
	} else {
		n = 10;
	}
	for (i = 0; i < n; i++) {
		name = gen_name();
		rc = Mknode(name, S_IFDIR);
		if (rc) {
			return rc;
		}
	}
	return 0;
}
Пример #3
0
static void Test(Properties &prop) {
    FileSystemState *tablefs_data;
    tablefs_data = new tablefs::FileSystemState(prop.getPropertyInt("threshold"),
                                          prop.getProperty("metadir").c_str(),
                                          prop.getProperty("datadir").c_str(),
                                          prop.getProperty("logfile").c_str(),
                                          prop.getPropertyInt("sync.time.limit",-1));

    SetState(tablefs_data);

    Init(NULL);

    int mem_lock_size = 400;
    mem_lock_size = prop.getPropertyInt("mem.lock.size", 400);
    TraceLoader loader(mem_lock_size);
    loader.LoadTrace(prop.getProperty("tracefile").c_str());

    Monitor mon = Monitor(prop.getProperty("mon.partition"), 
                          prop.getProperty("mon.filesystem"));
    Monitor tmon = Monitor(prop.getProperty("mon.partition"), 
                           prop.getProperty("mon.filesystem"));
    mon.DoMonitor();
    tmon.DoMonitor();

    sync();

    srand(100);
    time_t time1 = time(NULL);
    int cnt = 0;
    for (int i = 0; i < loader.getNumPaths(); ++i) {
    	char filetype;
    	char* path = loader.getPath(i, filetype);
        Stat(path);
        if (filetype == 'f') {
            Mknode(path);
        } else
        if (filetype == 'd') {
            Mkdir(path);
        }
        Stat(path);
        cnt ++;
        if (cnt >= 1000) {
          tmon.DoMonitor();
          cnt = 0;
        }
    }

    time_t time2 = time(NULL);
    mon.DoMonitor();
    tmon.DoMonitor();
    printf("create directory tree , %d\n", (int) (time2 - time1));
    int nquery = prop.getPropertyInt("num.query");
    int npath = loader.getNumPaths();
    printf("nquery %d npath %d\n", nquery, npath);
    cnt = 0;
    for (int i = 0; i < nquery; ++i) {
      int pi = rand() % npath;
      char* path = loader.getPath(pi);
      if ((i & 3) == 0) {
        Chmod(path, 777);
      } else 
      if ((i & 3) == 1) {
        struct timespec tv[2];
        tv[0].tv_sec = time(NULL);
        tv[1].tv_sec = time(NULL);
        UpdateTimens(path, tv);
      } else {
        Stat(path);
      }
      cnt++;
      if (cnt >= 1000) {
        tmon.DoMonitor();
        cnt = 0;
      }
    }

    time_t time3 = time(NULL);
    mon.DoMonitor();
    tmon.DoMonitor();
    printf("update and query , %d\n", (int) (time3 - time2));

    char tpath[256];
    sprintf(tpath, "%s/test.txt", prop.getProperty("metadir").c_str()); 
    int fd = open(tpath, O_WRONLY); 
    fsync(fd);
    close(fd);
    sync();
    
    for (int i = 0; i < 20; ++i) {
      sleep(1);
      tmon.DoMonitor();
    }

    time_t time4 = time(NULL);
    mon.DoMonitor();
    tmon.DoMonitor();
    printf("sync , %d\n", (int) (time4 - time3));

    mon.Report();
    tmon.Report();

    Destroy(tablefs_data);
}