Date: Mon, 26 Sep 2011 12:20:33 +0000 (UTC) From: Dag-Erling Smorgrav <des@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r225766 - user/des/phybs Message-ID: <201109261220.p8QCKXWQ074007@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: des Date: Mon Sep 26 12:20:33 2011 New Revision: 225766 URL: http://svn.freebsd.org/changeset/base/225766 Log: Add an option to open the device O_SYNC. Modified: user/des/phybs/phybs.1 user/des/phybs/phybs.c Modified: user/des/phybs/phybs.1 ============================================================================== --- user/des/phybs/phybs.1 Mon Sep 26 12:08:15 2011 (r225765) +++ user/des/phybs/phybs.1 Mon Sep 26 12:20:33 2011 (r225766) @@ -34,7 +34,7 @@ .Nd reveal a storage device's physical block size .Sh SYNOPSIS .Nm -.Op Fl rtw +.Op Fl rsw .Op Fl l Ar minsize .Op Fl h Ar maxsize .Op Fl t Ar total @@ -48,10 +48,10 @@ large I/O operations at various (mis-)al .Pp The .Nm -utility makes a series of passes with increasing block sizes. In each -pass, it either reads or writes (or both) a number of blocks at -increasing offsets relative to the ideal alignment, which is assumed -to be multiples of the block size. +utility makes a series of passes with increasing block sizes. +In each pass, it either reads or writes (or both) a number of +non-consecutive blocks at increasing offsets relative to the ideal +alignment, which is assumed to be multiples of the block size. The results are presented in terms of time elapsed, transactions per second and kB per second. .Pp @@ -79,6 +79,8 @@ The default is the device's logical bloc .It Fl r Perform read operations. This is the default. +.It Fl s +Open the device in synchronous mode. .It Fl t Ar total Specify the total amount of data to read or write in each pass. This must be a power of two and a multiple of the maximum block size Modified: user/des/phybs/phybs.c ============================================================================== --- user/des/phybs/phybs.c Mon Sep 26 12:08:15 2011 (r225765) +++ user/des/phybs/phybs.c Mon Sep 26 12:20:33 2011 (r225766) @@ -52,6 +52,7 @@ static unsigned int maxsize; static unsigned int total; static int opt_r; +static int opt_s; static int opt_w; static int tty = 0; @@ -115,7 +116,7 @@ usage(void) { fprintf(stderr, "usage: phybs %s\n", - "[-rw] [-l minsize] [-h maxsize] [-t total] device"); + "[-rsw] [-l minsize] [-h maxsize] [-t total] device"); exit(1); } @@ -143,11 +144,11 @@ int main(int argc, char *argv[]) { struct stat st; - int fd, opt; + int fd, mode, opt; tty = isatty(STDOUT_FILENO); - while ((opt = getopt(argc, argv, "h:l:rt:w")) != -1) + while ((opt = getopt(argc, argv, "h:l:rst:w")) != -1) switch (opt) { case 'h': maxsize = poweroftwo(opt, optarg); @@ -158,6 +159,9 @@ main(int argc, char *argv[]) case 'r': opt_r = 1; break; + case 's': + opt_s = 1; + break; case 't': total = poweroftwo(opt, optarg); break; @@ -178,7 +182,10 @@ main(int argc, char *argv[]) if (!opt_r && !opt_w) opt_r = 1; - if ((fd = open(device, opt_w ? O_RDWR : O_RDONLY)) == -1) + mode = opt_w ? O_RDWR : O_RDONLY; + if (opt_s) + mode |= O_SYNC; + if ((fd = open(device, mode)) == -1) err(errno == EPERM ? EX_NOPERM : EX_OSERR, "open(%s)", device); if (fstat(fd, &st) != 0)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201109261220.p8QCKXWQ074007>