|
@@ -22,10 +22,14 @@
|
|
|
#define EXTRA_BUFFERS 2
|
|
|
#define WRITE_INTERVAL 1
|
|
|
|
|
|
+
|
|
|
#define RAID_STRIP_SIZE 256
|
|
|
#define RAID_DISKS 8
|
|
|
#define STRIPS_AT_ONCE 2
|
|
|
|
|
|
+#define FS_MIN_BLOCK_SIZE (1024 * RAID_STRIP_SIZE)
|
|
|
+#define FS_BLOCK_SIZE (1024 * RAID_STRIP_SIZE * RAID_DISKS)
|
|
|
+
|
|
|
#ifdef AIO_MODE
|
|
|
# define SYNC_MODE
|
|
|
#endif /* AIO_MODE */
|
|
@@ -62,6 +66,7 @@ int main(int argc, char *argv[]) {
|
|
|
char *buffer;
|
|
|
long double mcoef = 1000000. / (1024 * 1024);
|
|
|
int flags = O_RDONLY|O_NOATIME|O_LARGEFILE;
|
|
|
+ struct stat st;
|
|
|
|
|
|
#ifdef AIO_MODE
|
|
|
int i;
|
|
@@ -79,11 +84,16 @@ int main(int argc, char *argv[]) {
|
|
|
posix_memalign((void**)&buffer, FASTWRITER_SYNCIO_ALIGN, BUFSIZE);
|
|
|
|
|
|
if (argc < 2) {
|
|
|
- printf("Usage: %s <directory|device> [skip|size]\n", argv[0]);
|
|
|
+ printf("Usage: %s <directory|file|device> [skip|size]\n", argv[0]);
|
|
|
exit(0);
|
|
|
}
|
|
|
|
|
|
- if (strstr(argv[1], "/dev/")) {
|
|
|
+ if (stat(argv[1], &st)) {
|
|
|
+ printf("stat on (%s) have failed", argv[1]);
|
|
|
+ exit(-1);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (strstr(argv[1], "/dev/")||(S_ISREG(st.st_mode))) {
|
|
|
if (argc > 2) {
|
|
|
max_size = atol(argv[2]);
|
|
|
max_size *= 1024 * 1024 * 1024;
|
|
@@ -125,8 +135,8 @@ int main(int argc, char *argv[]) {
|
|
|
#ifdef AIO_MODE
|
|
|
err = io_submit(aio, AIO_MODE, ioptr);
|
|
|
if (err != AIO_MODE) {
|
|
|
- printf("io_submit returned %i\n", err);
|
|
|
- perror("Failed to submit initial AIO jobs");
|
|
|
+ printf("Failed to submit initial AIO job, io_submit returned %i\n", err);
|
|
|
+ exit(-1);
|
|
|
}
|
|
|
#endif /* AIO_MODE */
|
|
|
|
|
@@ -155,7 +165,10 @@ int main(int argc, char *argv[]) {
|
|
|
for (i = 0; i < err; i++) {
|
|
|
struct io_event *ep = &ev[events + i];
|
|
|
int doneio = (uintptr_t)ep->data;
|
|
|
- if (ep->res2 || (ep->res != BLOCK_SIZE)) perror("Error in async IO");
|
|
|
+ if (ep->res2 || (ep->res != BLOCK_SIZE)) {
|
|
|
+ printf("Error in async IO\n");
|
|
|
+ exit(-1);
|
|
|
+ }
|
|
|
done[doneio%(AIO_MODE + EXTRA_BUFFERS)] = 1;
|
|
|
// printf("done (%i): %i\n", i, doneio);
|
|
|
}
|
|
@@ -169,7 +182,10 @@ int main(int argc, char *argv[]) {
|
|
|
io_prep_pread(newio, fd, buffer + (schedio % (AIO_MODE + EXTRA_BUFFERS)) * BLOCK_SIZE, BLOCK_SIZE, schedio * BLOCK_SIZE);
|
|
|
io_set_callback(newio, (void*)(uintptr_t)schedio);
|
|
|
err = io_submit(aio, 1, &newio);
|
|
|
- if (err != 1) perror("Failed to submit AIO jobs");
|
|
|
+ if (err != 1) {
|
|
|
+ printf("Failed to submit AIO jobs %i", err);
|
|
|
+ exit(-1);
|
|
|
+ }
|
|
|
schedio++;
|
|
|
}
|
|
|
events = i + 1;
|
|
@@ -249,8 +265,6 @@ int main(int argc, char *argv[]) {
|
|
|
skip = 0;
|
|
|
dir = opendir(".");
|
|
|
while ((ent = readdir(dir))) {
|
|
|
- struct stat st;
|
|
|
-
|
|
|
if (((skip++)%SKIP) != run) continue;
|
|
|
|
|
|
if (stat(ent->d_name, &st)) continue;
|
|
@@ -268,6 +282,7 @@ int main(int argc, char *argv[]) {
|
|
|
# ifdef FS_SYNC_MODE
|
|
|
if (size < BLOCK_SIZE) size = BLOCK_SIZE;
|
|
|
# endif /* FS_SYNC_MODE */
|
|
|
+ if (size < FS_MIN_BLOCK_SIZE) size = FS_BLOCK_SIZE;
|
|
|
#endif
|
|
|
|
|
|
if (!files)
|