--- IO-AIO/AIO.pm 2017/09/22 12:17:49 1.277 +++ IO-AIO/AIO.pm 2018/02/19 13:37:13 1.280 @@ -173,7 +173,7 @@ use base 'Exporter'; BEGIN { - our $VERSION = 4.35; + our $VERSION = 4.4; our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx @@ -185,6 +185,7 @@ aio_chmod aio_utime aio_truncate aio_msync aio_mtouch aio_mlock aio_mlockall aio_statvfs + aio_slurp aio_wd); our @EXPORT = (@AIO_REQ, qw(aioreq_pri aioreq_nice)); @@ -279,7 +280,8 @@ IO::AIO::nreqs IO::AIO::nready IO::AIO::npending - IO::AIO::min_fdlimit $nfd; + $nfd = IO::AIO::get_fdlimit [EXPERIMENTAL] + IO::AIO::min_fdlimit $nfd [EXPERIMENTAL] IO::AIO::sendfile $ofh, $ifh, $offset, $count IO::AIO::fadvise $fh, $offset, $len, $advice @@ -612,91 +614,6 @@ fsid => 1810 } -Here is a (likely partial - send me updates!) list of fsid values used by -Linux - it is safe to hardcode these when C<$^O> is C: - - 0x0000adf5 adfs - 0x0000adff affs - 0x5346414f afs - 0x09041934 anon-inode filesystem - 0x00000187 autofs - 0x42465331 befs - 0x1badface bfs - 0x42494e4d binfmt_misc - 0x9123683e btrfs - 0x0027e0eb cgroupfs - 0xff534d42 cifs - 0x73757245 coda - 0x012ff7b7 coh - 0x28cd3d45 cramfs - 0x453dcd28 cramfs-wend (wrong endianness) - 0x64626720 debugfs - 0x00001373 devfs - 0x00001cd1 devpts - 0x0000f15f ecryptfs - 0x00414a53 efs - 0x0000137d ext - 0x0000ef53 ext2/ext3/ext4 - 0x0000ef51 ext2 - 0xf2f52010 f2fs - 0x00004006 fat - 0x65735546 fuseblk - 0x65735543 fusectl - 0x0bad1dea futexfs - 0x01161970 gfs2 - 0x47504653 gpfs - 0x00004244 hfs - 0xf995e849 hpfs - 0x00c0ffee hostfs - 0x958458f6 hugetlbfs - 0x2bad1dea inotifyfs - 0x00009660 isofs - 0x000072b6 jffs2 - 0x3153464a jfs - 0x6b414653 k-afs - 0x0bd00bd0 lustre - 0x0000137f minix - 0x0000138f minix 30 char names - 0x00002468 minix v2 - 0x00002478 minix v2 30 char names - 0x00004d5a minix v3 - 0x19800202 mqueue - 0x00004d44 msdos - 0x0000564c novell - 0x00006969 nfs - 0x6e667364 nfsd - 0x00003434 nilfs - 0x5346544e ntfs - 0x00009fa1 openprom - 0x7461636F ocfs2 - 0x00009fa0 proc - 0x6165676c pstorefs - 0x0000002f qnx4 - 0x68191122 qnx6 - 0x858458f6 ramfs - 0x52654973 reiserfs - 0x00007275 romfs - 0x67596969 rpc_pipefs - 0x73636673 securityfs - 0xf97cff8c selinux - 0x0000517b smb - 0x534f434b sockfs - 0x73717368 squashfs - 0x62656572 sysfs - 0x012ff7b6 sysv2 - 0x012ff7b5 sysv4 - 0x01021994 tmpfs - 0x15013346 udf - 0x00011954 ufs - 0x54190100 ufs byteswapped - 0x00009fa2 usbdevfs - 0x01021997 v9fs - 0xa501fcf5 vxfs - 0xabba1974 xenfs - 0x012ff7b4 xenix - 0x58465342 xfs - 0x012fd16d xia - =item aio_utime $fh_or_path, $atime, $mtime, $callback->($status) Works like perl's C function (including the special case of $atime @@ -927,11 +844,42 @@ =back +=item aio_slurp $pathname, $offset, $length, $data, $callback->($status) + +Opens, reads and closes the given file. The data is put into C<$data>, +which is resized as required. + +If C<$offset> is negative, then it is counted from the end of the file. + +If C<$length> is zero, then the remaining length of the file is +used. Also, in this case, the same limitations to modifying C<$data> apply +as when IO::AIO::mmap is used, i.e. it must only be modified in-place +with C. If the size of the file is known, specifying a non-zero +C<$length> results in a performance advantage. + +This request is similar to the older C request, but since it is +a single request, it might be more efficient to use. + +Example: load F into C<$passwd>. + + my $passwd; + aio_slurp "/etc/passwd", 0, 0, $passwd, sub { + $_[0] >= 0 + or die "/etc/passwd: $!\n"; + + printf "/etc/passwd is %d bytes long, and contains:\n", length $passwd; + print $passwd; + }; + IO::AIO::flush; + + =item aio_load $pathname, $data, $callback->($status) This is a composite request that tries to fully load the given file into memory. Status is the same as with aio_read. +Using C might be more efficient, as it is a single request. + =cut sub aio_load($$;$) { @@ -1484,10 +1432,11 @@ C, C or C. -At the time of this writing (Linux 3.2), this requets is unreliable unless +At the time of this writing (Linux 3.2), this request is unreliable unless C<$count> is C, as the kernel has all sorts of bugs preventing -it to return all extents of a range for files with large number of -extents. The code works around all these issues if C<$count> is undef. +it to return all extents of a range for files with a large number of +extents. The code (only) works around all these issues if C<$count> is +C. =item aio_group $callback->(...) @@ -2071,12 +2020,16 @@ =item $numfd = IO::AIO::get_fdlimit +This function is I and subject to change. + Tries to find the current file descriptor limit and returns it, or C and sets C<$!> in case of an error. The limit is one larger than the highest valid file descriptor number. =item IO::AIO::min_fdlimit [$numfd] +This function is I and subject to change. + Try to increase the current file descriptor limit(s) to at least C<$numfd> by changing the soft or hard file descriptor resource limit. If C<$numfd> is missing, it will try to set a very high limit, although this is not