On Sat, Dec 20, 2008 at 09:55:55AM +0100, Jim Meyering wrote: > "Matt Harden" <[email protected]> wrote: > > I'd like to suggest adding the ability to dd(1) to open the file in > > concurrent I/O mode. This applies only to AIX systems and the JFS2 > > filesystem. I had a need to do this and was able to do it easily thanks > > to the design of coreutils. As a sysadmin sometimes you have to open a > > file in CIO mode because if any other program has the file open already > > in CIO mode, the OS will not allow it to be opened in "normal" mode. > > Also when using CIO mode, I/O that is not block-aligned is very slow. > > This makes dd a good utility for copying data to/from files in CIO mode. > > > > Anyway, here are some simple patches to coreutils and gnulib that give this > > capability to dd. > > Thanks for the contribution. > This is small enough, and your first, so you don't need > a copyright assignment. However, if you don't mind doing > a little more work, it would accelerate the acceptance of this > change: > > write an entry in NEWS, under "New features" (note that they're > alphabetized on tool name) > > don't say that O_CIO is AIX/JFS2-specific: > a quick search suggests HP-UX also honors it, and it can be > useful on VxFS, e.g., > > https://vias.symantec.com/docportal/sf/5.0/hpux/html/fs_ref/pr_ch_fsio_fs5.html
I didn't know that. It appears to be a more recent development outside of AIX. > > also, see the contribution guidelines in HACKING for the recommended > use of "git format-patch" to prepare a change set. i.e., write a > commit log entry that mentions each affected file, using the same > format as other log entries. OK. > > diff --git a/lib/fcntl.in.h b/lib/fcntl.in.h > > index fd7520e..dea7449 100644 > > --- a/lib/fcntl.in.h > > +++ b/lib/fcntl.in.h > > @@ -70,6 +70,10 @@ extern void _gl_register_fd (int fd, const char > > *filename); > > > > /* Fix up the O_* macros. */ > > > > +#ifndef O_CIO > > +# define O_CIO 0 > > +#endif > > I'd rather not make this change to gnulib's fcntl.in.h > right now, since it would make code that tests for the existence > of O_CIO using "#ifndef O_CIO" mistakenly determine that > it's supported. > So please move that change into dd.c. You have the exact same situation with O_DIRECT, O_DSYNC, O_NDELAY, and the rest right now. I'm sure you're well aware of that however, so I've gone ahead and done what you asked. Also I noticed I had left O_CIO out of the section that chooses a unique value for O_FULLBLOCK so I added it there as well. Patch in git format-patch format attached. Thanks, Matt
>From 1b910012141aa389dd4f057f535fc5bf5dbe8368 Mon Sep 17 00:00:00 2001 From: Matt Harden <[email protected]> Date: Sun, 21 Dec 2008 22:06:16 -0600 Subject: [PATCH] Add support to dd for opening files in Concurrent I/O (CIO) mode. * src/dd.c (O_CIO): New flag. * src/dd.c (O_FULLBLOCK): Add O_CIO to the list of flags that O_FULLBLOCK should be greater than. * src/dd.c (flags): Give the name "cio" to the new O_CIO flag, mirroring the treatment of O_DIRECT. * src/dd.c (usage): Add a description of the new flag when it is available. * doc/coreutils.text (dd invocation): Describe the new flag. * NEWS: Mention the new feature. --- NEWS | 3 +++ doc/coreutils.texi | 8 ++++++++ src/dd.c | 12 +++++++++++- 3 files changed, 22 insertions(+), 1 deletions(-) diff --git a/NEWS b/NEWS index 717af04..f605330 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,9 @@ GNU coreutils NEWS -*- outline -*- ** New features + dd accepts iflag=cio and oflag=cio to open the file in CIO (concurrent I/O) + mode where this feature is available. + ls --color now highlights hard linked files, too stat -f recognizes the Lustre file system type diff --git a/doc/coreutils.texi b/doc/coreutils.texi index bbc2710..a582dfd 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -7729,6 +7729,14 @@ If you combine this flag with the @samp{...@var{file}} operand, you should also specify @samp{conv=notrunc} unless you want the output file to be truncated before being appended to. +...@item cio +...@opindex cio +...@cindex concurrent I/O +Use concurrent I/O mode for data. This mode performs direct I/O +and drops the POSIX requirement to serialize all I/O to the same file. +A file cannot be opened in CIO mode and with a standard open at the +same time. + @item direct @opindex direct @cindex direct I/O diff --git a/src/dd.c b/src/dd.c index e54cc14..7639612 100644 --- a/src/dd.c +++ b/src/dd.c @@ -66,6 +66,12 @@ static void process_signals (void); # define SIGINFO SIGUSR1 #endif +/* This may belong in GNULIB's fcntl module instead. + Define O_CIO to 0 if it is not supported by this OS. */ +#ifndef O_CIO +# define O_CIO 0 +#endif + #if ! HAVE_FDATASYNC # define fdatasync(fd) (errno = ENOSYS, -1) #endif @@ -264,6 +270,7 @@ enum /* Use a value that is larger than that of any other O_ symbol. */ O_FULLBLOCK = ((MAX (O_APPEND, MAX (O_BINARY, + MAX (O_CIO, MAX (O_DIRECT, MAX (O_DIRECTORY, MAX (O_DSYNC, @@ -272,7 +279,7 @@ enum MAX (O_NOFOLLOW, MAX (O_NOLINKS, MAX (O_NONBLOCK, - MAX (O_SYNC, O_TEXT)))))))))))) << 1) + MAX (O_SYNC, O_TEXT))))))))))))) << 1) }; /* Ensure that we didn't shift it off the end. */ @@ -288,6 +295,7 @@ static struct symbol_value const flags[] = { {"append", O_APPEND}, {"binary", O_BINARY}, + {"cio", O_CIO}, {"direct", O_DIRECT}, {"directory", O_DIRECTORY}, {"dsync", O_DSYNC}, @@ -508,6 +516,8 @@ Each FLAG symbol may be:\n\ \n\ append append mode (makes sense only for output; conv=notrunc suggested)\n\ "), stdout); + if (O_CIO) + fputs (_(" cio use concurrent I/O for data\n"), stdout); if (O_DIRECT) fputs (_(" direct use direct I/O for data\n"), stdout); if (O_DIRECTORY) -- 1.5.6.4
_______________________________________________ Bug-coreutils mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-coreutils
