… | |
… | |
228 | $nfd = IO::AIO::get_fdlimit |
228 | $nfd = IO::AIO::get_fdlimit |
229 | IO::AIO::min_fdlimit $nfd |
229 | IO::AIO::min_fdlimit $nfd |
230 | |
230 | |
231 | IO::AIO::sendfile $ofh, $ifh, $offset, $count |
231 | IO::AIO::sendfile $ofh, $ifh, $offset, $count |
232 | IO::AIO::fadvise $fh, $offset, $len, $advice |
232 | IO::AIO::fadvise $fh, $offset, $len, $advice |
|
|
233 | IO::AIO::fexecve $fh, $argv, $envp |
233 | |
234 | |
234 | IO::AIO::mmap $scalar, $length, $prot, $flags[, $fh[, $offset]] |
235 | IO::AIO::mmap $scalar, $length, $prot, $flags[, $fh[, $offset]] |
235 | IO::AIO::munmap $scalar |
236 | IO::AIO::munmap $scalar |
236 | IO::AIO::mremap $scalar, $new_length, $flags[, $new_address] |
237 | IO::AIO::mremap $scalar, $new_length, $flags[, $new_address] |
237 | IO::AIO::madvise $scalar, $offset, $length, $advice |
238 | IO::AIO::madvise $scalar, $offset, $length, $advice |
… | |
… | |
249 | |
250 | |
250 | # very much unportable syscalls |
251 | # very much unportable syscalls |
251 | IO::AIO::accept4 $r_fh, $sockaddr, $sockaddr_len, $flags |
252 | IO::AIO::accept4 $r_fh, $sockaddr, $sockaddr_len, $flags |
252 | IO::AIO::splice $r_fh, $r_off, $w_fh, $w_off, $length, $flags |
253 | IO::AIO::splice $r_fh, $r_off, $w_fh, $w_off, $length, $flags |
253 | IO::AIO::tee $r_fh, $w_fh, $length, $flags |
254 | IO::AIO::tee $r_fh, $w_fh, $length, $flags |
|
|
255 | |
254 | $actual_size = IO::AIO::pipesize $r_fh[, $new_size] |
256 | $actual_size = IO::AIO::pipesize $r_fh[, $new_size] |
255 | ($rfh, $wfh) = IO::AIO::pipe2 [$flags] |
257 | ($rfh, $wfh) = IO::AIO::pipe2 [$flags] |
|
|
258 | |
|
|
259 | $fh = IO::AIO::eventfd [$initval, [$flags]] |
256 | $fh = IO::AIO::memfd_create $pathname[, $flags] |
260 | $fh = IO::AIO::memfd_create $pathname[, $flags] |
257 | $fh = IO::AIO::eventfd [$initval, [$flags]] |
261 | |
258 | $fh = IO::AIO::timerfd_create $clockid[, $flags] |
262 | $fh = IO::AIO::timerfd_create $clockid[, $flags] |
259 | ($cur_interval, $cur_value) = IO::AIO::timerfd_settime $fh, $flags, $new_interval, $nbw_value |
263 | ($cur_interval, $cur_value) = IO::AIO::timerfd_settime $fh, $flags, $new_interval, $nbw_value |
260 | ($cur_interval, $cur_value) = IO::AIO::timerfd_gettime $fh |
264 | ($cur_interval, $cur_value) = IO::AIO::timerfd_gettime $fh |
|
|
265 | |
|
|
266 | $fh = IO::AIO::pidfd_open $pid[, $flags] |
|
|
267 | $status = IO::AIO::pidfd_send_signal $pidfh, $signal[, $siginfo[, $flags]] |
|
|
268 | $fh = IO::AIO::pidfd_getfd $pidfh, $targetfd[, $flags] |
|
|
269 | |
|
|
270 | $retval = IO::AIO::mount $special, $path, $fstype, $flags = 0, $data = undef |
|
|
271 | $retval = IO::AIO::umount $path, $flags = 0 |
261 | |
272 | |
262 | API NOTES |
273 | API NOTES |
263 | All the "aio_*" calls are more or less thin wrappers around the syscall |
274 | All the "aio_*" calls are more or less thin wrappers around the syscall |
264 | with the same name (sans "aio_"). The arguments are similar or |
275 | with the same name (sans "aio_"). The arguments are similar or |
265 | identical, and they all accept an additional (and optional) $callback |
276 | identical, and they all accept an additional (and optional) $callback |
… | |
… | |
332 | aio_open $pathname, $flags, $mode, $callback->($fh) |
343 | aio_open $pathname, $flags, $mode, $callback->($fh) |
333 | Asynchronously open or create a file and call the callback with a |
344 | Asynchronously open or create a file and call the callback with a |
334 | newly created filehandle for the file (or "undef" in case of an |
345 | newly created filehandle for the file (or "undef" in case of an |
335 | error). |
346 | error). |
336 | |
347 | |
337 | The pathname passed to "aio_open" must be absolute. See API NOTES, |
|
|
338 | above, for an explanation. |
|
|
339 | |
|
|
340 | The $flags argument is a bitmask. See the "Fcntl" module for a list. |
348 | The $flags argument is a bitmask. See the "Fcntl" module for a list. |
341 | They are the same as used by "sysopen". |
349 | They are the same as used by "sysopen". |
342 | |
350 | |
343 | Likewise, $mode specifies the mode of the newly created file, if it |
351 | Likewise, $mode specifies the mode of the newly created file, if it |
344 | didn't exist and "O_CREAT" has been given, just like perl's |
352 | didn't exist and "O_CREAT" has been given, just like perl's |
… | |
… | |
496 | aio_lstat $fh, $callback->($status) |
504 | aio_lstat $fh, $callback->($status) |
497 | Works almost exactly like perl's "stat" or "lstat" in void context. |
505 | Works almost exactly like perl's "stat" or "lstat" in void context. |
498 | The callback will be called after the stat and the results will be |
506 | The callback will be called after the stat and the results will be |
499 | available using "stat _" or "-s _" and other tests (with the |
507 | available using "stat _" or "-s _" and other tests (with the |
500 | exception of "-B" and "-T"). |
508 | exception of "-B" and "-T"). |
501 | |
|
|
502 | The pathname passed to "aio_stat" must be absolute. See API NOTES, |
|
|
503 | above, for an explanation. |
|
|
504 | |
509 | |
505 | Currently, the stats are always 64-bit-stats, i.e. instead of |
510 | Currently, the stats are always 64-bit-stats, i.e. instead of |
506 | returning an error when stat'ing a large file, the results will be |
511 | returning an error when stat'ing a large file, the results will be |
507 | silently truncated unless perl itself is compiled with large file |
512 | silently truncated unless perl itself is compiled with large file |
508 | support. |
513 | support. |
… | |
… | |
852 | print "everything else: @$nondirs\n"; |
857 | print "everything else: @$nondirs\n"; |
853 | }; |
858 | }; |
854 | |
859 | |
855 | Implementation notes. |
860 | Implementation notes. |
856 | |
861 | |
857 | The "aio_readdir" cannot be avoided, but "stat()"'ing every entry |
862 | The "aio_readdir" cannot be avoided, but stat()'ing every entry can. |
858 | can. |
|
|
859 | |
863 | |
860 | If readdir returns file type information, then this is used directly |
864 | If readdir returns file type information, then this is used directly |
861 | to find directories. |
865 | to find directories. |
862 | |
866 | |
863 | Otherwise, after reading the directory, the modification time, size |
867 | Otherwise, after reading the directory, the modification time, size |
… | |
… | |
943 | "FS_XFLAG_NODUMP", "FS_XFLAG_RTINHERIT", "FS_XFLAG_PROJINHERIT", |
947 | "FS_XFLAG_NODUMP", "FS_XFLAG_RTINHERIT", "FS_XFLAG_PROJINHERIT", |
944 | "FS_XFLAG_NOSYMLINKS", "FS_XFLAG_EXTSIZE", "FS_XFLAG_EXTSZINHERIT", |
948 | "FS_XFLAG_NOSYMLINKS", "FS_XFLAG_EXTSIZE", "FS_XFLAG_EXTSZINHERIT", |
945 | "FS_XFLAG_NODEFRAG", "FS_XFLAG_FILESTREAM", "FS_XFLAG_DAX", |
949 | "FS_XFLAG_NODEFRAG", "FS_XFLAG_FILESTREAM", "FS_XFLAG_DAX", |
946 | "FS_XFLAG_HASATTR", |
950 | "FS_XFLAG_HASATTR", |
947 | |
951 | |
|
|
952 | "BLKROSET", "BLKROGET", "BLKRRPART", "BLKGETSIZE", "BLKFLSBUF", |
|
|
953 | "BLKRASET", "BLKRAGET", "BLKFRASET", "BLKFRAGET", "BLKSECTSET", |
|
|
954 | "BLKSECTGET", "BLKSSZGET", "BLKBSZGET", "BLKBSZSET", "BLKGETSIZE64", |
|
|
955 | |
948 | aio_sync $callback->($status) |
956 | aio_sync $callback->($status) |
949 | Asynchronously call sync and call the callback when finished. |
957 | Asynchronously call sync and call the callback when finished. |
950 | |
958 | |
951 | aio_fsync $fh, $callback->($status) |
959 | aio_fsync $fh, $callback->($status) |
952 | Asynchronously call fsync on the given filehandle and call the |
960 | Asynchronously call fsync on the given filehandle and call the |
… | |
… | |
1591 | no longer exceeded. |
1599 | no longer exceeded. |
1592 | |
1600 | |
1593 | In other words, this setting does not enforce a queue limit, but can |
1601 | In other words, this setting does not enforce a queue limit, but can |
1594 | be used to make poll functions block if the limit is exceeded. |
1602 | be used to make poll functions block if the limit is exceeded. |
1595 | |
1603 | |
1596 | This is a very bad function to use in interactive programs because |
1604 | This is a bad function to use in interactive programs because it |
1597 | it blocks, and a bad way to reduce concurrency because it is |
1605 | blocks, and a bad way to reduce concurrency because it is inexact. |
1598 | inexact: Better use an "aio_group" together with a feed callback. |
1606 | If you need to issue many requests without being able to call a poll |
|
|
1607 | function on demand, it is better to use an "aio_group" together with |
|
|
1608 | a feed callback. |
1599 | |
1609 | |
1600 | Its main use is in scripts without an event loop - when you want to |
1610 | Its main use is in scripts without an event loop - when you want to |
1601 | stat a lot of files, you can write something like this: |
1611 | stat a lot of files, you can write something like this: |
1602 | |
1612 | |
1603 | IO::AIO::max_outstanding 32; |
1613 | IO::AIO::max_outstanding 32; |
… | |
… | |
1608 | } |
1618 | } |
1609 | |
1619 | |
1610 | IO::AIO::flush; |
1620 | IO::AIO::flush; |
1611 | |
1621 | |
1612 | The call to "poll_cb" inside the loop will normally return |
1622 | The call to "poll_cb" inside the loop will normally return |
1613 | instantly, but as soon as more thna 32 reqeusts are in-flight, it |
1623 | instantly, allowing the loop to progress, but as soon as more than |
1614 | will block until some requests have been handled. This keeps the |
1624 | 32 requests are in-flight, it will block until some requests have |
1615 | loop from pushing a large number of "aio_stat" requests onto the |
1625 | been handled. This keeps the loop from pushing a large number of |
1616 | queue. |
1626 | "aio_stat" requests onto the queue (which, with many paths to stat, |
|
|
1627 | can use up a lot of memory). |
1617 | |
1628 | |
1618 | The default value for "max_outstanding" is very large, so there is |
1629 | The default value for "max_outstanding" is very large, so there is |
1619 | no practical limit on the number of outstanding requests. |
1630 | no practical limit on the number of outstanding requests. |
1620 | |
1631 | |
1621 | STATISTICAL INFORMATION |
1632 | STATISTICAL INFORMATION |
… | |
… | |
1726 | IO::AIO implements some functions that are useful when you want to use |
1737 | IO::AIO implements some functions that are useful when you want to use |
1727 | some "Advanced I/O" function not available to in Perl, without going the |
1738 | some "Advanced I/O" function not available to in Perl, without going the |
1728 | "Asynchronous I/O" route. Many of these have an asynchronous "aio_*" |
1739 | "Asynchronous I/O" route. Many of these have an asynchronous "aio_*" |
1729 | counterpart. |
1740 | counterpart. |
1730 | |
1741 | |
|
|
1742 | $retval = IO::AIO::fexecve $fh, $argv, $envp |
|
|
1743 | A more-or-less direct equivalent to the POSIX "fexecve" functions, |
|
|
1744 | which allows you to specify the program to be executed via a file |
|
|
1745 | descriptor (or handle). Returns -1 and sets errno to "ENOSYS" if not |
|
|
1746 | available. |
|
|
1747 | |
|
|
1748 | $retval = IO::AIO::mount $special, $path, $fstype, $flags = 0, $data = |
|
|
1749 | undef |
|
|
1750 | Calls the GNU/Linux mount syscall with the given arguments. All |
|
|
1751 | except $flags are strings, and if $data is "undef", a "NULL" will be |
|
|
1752 | passed. |
|
|
1753 | |
|
|
1754 | The following values for $flags are available: |
|
|
1755 | |
|
|
1756 | "IO::AIO::MS_RDONLY", "IO::AIO::MS_NOSUID", "IO::AIO::MS_NODEV", |
|
|
1757 | "IO::AIO::MS_NOEXEC", "IO::AIO::MS_SYNCHRONOUS", |
|
|
1758 | "IO::AIO::MS_REMOUNT", "IO::AIO::MS_MANDLOCK", |
|
|
1759 | "IO::AIO::MS_DIRSYNC", "IO::AIO::MS_NOATIME", |
|
|
1760 | "IO::AIO::MS_NODIRATIME", "IO::AIO::MS_BIND", "IO::AIO::MS_MOVE", |
|
|
1761 | "IO::AIO::MS_REC", "IO::AIO::MS_SILENT", "IO::AIO::MS_POSIXACL", |
|
|
1762 | "IO::AIO::MS_UNBINDABLE", "IO::AIO::MS_PRIVATE", |
|
|
1763 | "IO::AIO::MS_SLAVE", "IO::AIO::MS_SHARED", "IO::AIO::MS_RELATIME", |
|
|
1764 | "IO::AIO::MS_KERNMOUNT", "IO::AIO::MS_I_VERSION", |
|
|
1765 | "IO::AIO::MS_STRICTATIME", "IO::AIO::MS_LAZYTIME", |
|
|
1766 | "IO::AIO::MS_ACTIVE", "IO::AIO::MS_NOUSER", "IO::AIO::MS_RMT_MASK", |
|
|
1767 | "IO::AIO::MS_MGC_VAL" and "IO::AIO::MS_MGC_MSK". |
|
|
1768 | |
|
|
1769 | $retval = IO::AIO::umount $path, $flags = 0 |
|
|
1770 | Invokes the GNU/Linux "umount" or "umount2" syscalls. Always calls |
|
|
1771 | "umount" if $flags is 0, otherwqise always tries to call "umount2". |
|
|
1772 | |
|
|
1773 | The following $flags are available: |
|
|
1774 | |
|
|
1775 | "IO::AIO::MNT_FORCE", "IO::AIO::MNT_DETACH", "IO::AIO::MNT_EXPIRE" |
|
|
1776 | and "IO::AIO::UMOUNT_NOFOLLOW". |
|
|
1777 | |
1731 | $numfd = IO::AIO::get_fdlimit |
1778 | $numfd = IO::AIO::get_fdlimit |
1732 | Tries to find the current file descriptor limit and returns it, or |
1779 | Tries to find the current file descriptor limit and returns it, or |
1733 | "undef" and sets $! in case of an error. The limit is one larger |
1780 | "undef" and sets $! in case of an error. The limit is one larger |
1734 | than the highest valid file descriptor number. |
1781 | than the highest valid file descriptor number. |
1735 | |
1782 | |
… | |
… | |
1828 | not available, the are 0): "IO::AIO::MAP_ANONYMOUS" (which is set to |
1875 | not available, the are 0): "IO::AIO::MAP_ANONYMOUS" (which is set to |
1829 | "MAP_ANON" if your system only provides this constant), |
1876 | "MAP_ANON" if your system only provides this constant), |
1830 | "IO::AIO::MAP_LOCKED", "IO::AIO::MAP_NORESERVE", |
1877 | "IO::AIO::MAP_LOCKED", "IO::AIO::MAP_NORESERVE", |
1831 | "IO::AIO::MAP_POPULATE", "IO::AIO::MAP_NONBLOCK", |
1878 | "IO::AIO::MAP_POPULATE", "IO::AIO::MAP_NONBLOCK", |
1832 | "IO::AIO::MAP_FIXED", "IO::AIO::MAP_GROWSDOWN", |
1879 | "IO::AIO::MAP_FIXED", "IO::AIO::MAP_GROWSDOWN", |
1833 | "IO::AIO::MAP_32BIT", "IO::AIO::MAP_HUGETLB" or |
1880 | "IO::AIO::MAP_32BIT", "IO::AIO::MAP_HUGETLB", "IO::AIO::MAP_STACK", |
1834 | "IO::AIO::MAP_STACK". |
1881 | "IO::AIO::MAP_FIXED_NOREPLACE", "IO::AIO::MAP_SHARED_VALIDATE", |
|
|
1882 | "IO::AIO::MAP_SYNC" or "IO::AIO::MAP_UNINITIALIZED". |
1835 | |
1883 | |
1836 | If $fh is "undef", then a file descriptor of -1 is passed. |
1884 | If $fh is "undef", then a file descriptor of -1 is passed. |
1837 | |
1885 | |
1838 | $offset is the offset from the start of the file - it generally must |
1886 | $offset is the offset from the start of the file - it generally must |
1839 | be a multiple of "IO::AIO::PAGESIZE" and defaults to 0. |
1887 | be a multiple of "IO::AIO::PAGESIZE" and defaults to 0. |
… | |
… | |
1971 | "ENOSYS". |
2019 | "ENOSYS". |
1972 | |
2020 | |
1973 | Please refer to memfd_create(2) for more info on this call. |
2021 | Please refer to memfd_create(2) for more info on this call. |
1974 | |
2022 | |
1975 | The following $flags values are available: "IO::AIO::MFD_CLOEXEC", |
2023 | The following $flags values are available: "IO::AIO::MFD_CLOEXEC", |
1976 | "IO::AIO::MFD_ALLOW_SEALING" and "IO::AIO::MFD_HUGETLB". |
2024 | "IO::AIO::MFD_ALLOW_SEALING", "IO::AIO::MFD_HUGETLB", |
|
|
2025 | "IO::AIO::MFD_HUGETLB_2MB" and "IO::AIO::MFD_HUGETLB_1GB". |
1977 | |
2026 | |
1978 | Example: create a new memfd. |
2027 | Example: create a new memfd. |
1979 | |
2028 | |
1980 | my $fh = IO::AIO::memfd_create "somenameforprocfd", IO::AIO::MFD_CLOEXEC |
2029 | my $fh = IO::AIO::memfd_create "somenameforprocfd", IO::AIO::MFD_CLOEXEC |
1981 | or die "memfd_create: $!\n"; |
2030 | or die "memfd_create: $!\n"; |