From owner-svn-src-user@FreeBSD.ORG Mon Sep 26 12:20:33 2011 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AE4BE106564A; Mon, 26 Sep 2011 12:20:33 +0000 (UTC) (envelope-from des@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 93C2B8FC0C; Mon, 26 Sep 2011 12:20:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8QCKXnS074010; Mon, 26 Sep 2011 12:20:33 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8QCKXWQ074007; Mon, 26 Sep 2011 12:20:33 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201109261220.p8QCKXWQ074007@svn.freebsd.org> From: Dag-Erling Smorgrav Date: Mon, 26 Sep 2011 12:20:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225766 - user/des/phybs X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Sep 2011 12:20:33 -0000 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)