Permalink
Browse files

SA: Add buffered I/O support.

For use with care (just like non-direct).

Signed-off-by: Andrei Warkentin <andreiw@vmware.com>
  • Loading branch information...
1 parent 8dba5ca commit 91d6b3ecbbad79e35ba1b5bea065a52b4090aaea @andreiw committed Oct 27, 2011
Showing with 23 additions and 11 deletions.
  1. +6 −4 dev.c
  2. +4 −1 dev.h
  3. +11 −6 sa.c
  4. +2 −0 stats.c
View
10 dev.c
@@ -150,13 +150,15 @@ static void set_rtprio(void)
int setup_dev(struct device *dev,
const char *filename,
- bool no_direct)
+ unsigned dev_flags)
{
int err;
void *p;
- int flags = O_RDWR | O_SYNC | O_NOATIME;
- if (!no_direct)
- flags= O_DIRECT;
+ int flags = O_RDWR | O_NOATIME;
+ if (!(dev_flags & DEV_NO_DIRECT))
+ flags |= O_DIRECT;
+ if (!(dev_flags & DEV_NO_SYNC))
+ flags |= O_SYNC;
set_rtprio();
View
5 dev.h
@@ -36,7 +36,10 @@ enum writebuf {
WBUF_RAND,
};
-extern int setup_dev(struct device *dev, const char *filename, bool no_direct);
+#define DEV_NO_SYNC (1 << 0)
+#define DEV_NO_DIRECT (1 << 1)
+
+extern int setup_dev(struct device *dev, const char *filename, unsigned flags);
long long time_write(struct device *dev, off64_t pos, size_t size, enum writebuf which);
View
17 sa.c
@@ -190,11 +190,11 @@ int main(int argc, char **argv)
bool erase = false;
bool random = false;
bool do_read = false;
- bool no_direct = false;
+ unsigned dev_flags = 0;
while (1) {
int c;
- c = getopt(argc, argv, "s:o:a:c:r:veRdf");
+ c = getopt(argc, argv, "s:o:a:c:r:veRdfb");
if (c == -1)
break;
@@ -257,18 +257,21 @@ int main(int argc, char **argv)
do_read = true;
break;
case 'f':
- no_direct = true;
+ dev_flags |= DEV_NO_DIRECT;
+ break;
+ case 'b':
+ dev_flags |= DEV_NO_SYNC;
break;
};
}
if (!size || optind != (argc - 1)) {
- printf("%s -s size [-f] [-n] [-o offset] [-a align] [-c count] [-r repeats] dev\n",
+ printf("%s -s size [-f] [-d] [-e] [-R] [-o offset] [-a align] [-c count] [-r repeats] dev\n",
argv[0]);
return -1;
};
- returnif(setup_dev(&dev, argv[optind], no_direct));
+ returnif(setup_dev(&dev, argv[optind], dev_flags));
signal(SIGINT, &on_sigint);
siginterrupt(SIGINT, true);
@@ -299,8 +302,10 @@ int main(int argc, char **argv)
printf("\tdevice size = %ju\n", dev.size);
if (random)
printf("\tLFSR-random accesses\n");
- if (no_direct)
+ if (dev_flags & DEV_NO_DIRECT)
printf("\tnon-O_DIRECT I/O\n");
+ if (dev_flags & DEV_NO_SYNC)
+ printf("\tnon-O_SYNC I/O\n");
}
if (!repeat)
View
@@ -126,6 +126,8 @@ void stats_print(struct stats *stats)
if (stats->gindex) {
printf("Global stats:\n");
+ if (stats->verbose)
+ printf("\tProcessed: %ju\n", stats->gindex);
printf("\tMin %s latency: ", stats->op);
print_ns(stats->min, "s\n");
printf("\tMax %s latency: ", stats->op);

0 comments on commit 91d6b3e

Please sign in to comment.