jfroebe has asked for the wisdom of the Perl Monks concerning the following question:
I've written a C program that creates a 20GB file using O_DIRECT and O_ASYNC correctly. The trick to write to a file using O_DIRECT is that I have to align the buffer with respect to the memory block size.
When I write a similar program using Perl, I receive the expected "System write error: Invalid argument" as the buffer is not aligned.
So, my question is: Is it possible, in Perl, to align the buffer?
#!/usr/bin/perl use strict; use warnings; $|++; use Fcntl qw(:DEFAULT O_ASYNC O_DIRECT); my $FH; sysopen($FH, "./test.dat", O_WRONLY | O_TRUNC | O_CREAT | O_ASYNC | O_ +DIRECT, 0666); my $BUFFER = "0"x1048576; my $BUFSIZE = 1048576; for (my $i = 0; $i < 20480; $i++) { my $written = syswrite($FH, $BUFFER, $BUFSIZE); die "System write error: $!\n" unless defined $written; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: O_DIRECT & O_ASYNC, Linux & Perl
by sgifford (Prior) on May 11, 2007 at 03:04 UTC | |
by jfroebe (Parson) on May 11, 2007 at 03:48 UTC | |
|
Re: O_DIRECT & O_ASYNC, Linux & Perl
by tirwhan (Abbot) on May 11, 2007 at 03:44 UTC | |
by jfroebe (Parson) on May 11, 2007 at 03:50 UTC |