… | |
… | |
168 | use common::sense; |
168 | use common::sense; |
169 | |
169 | |
170 | use base 'Exporter'; |
170 | use base 'Exporter'; |
171 | |
171 | |
172 | BEGIN { |
172 | BEGIN { |
173 | our $VERSION = '4.13'; |
173 | our $VERSION = '4.15'; |
174 | |
174 | |
175 | our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close |
175 | our @AIO_REQ = qw(aio_sendfile aio_seek aio_read aio_write aio_open aio_close |
176 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
176 | aio_stat aio_lstat aio_unlink aio_rmdir aio_readdir aio_readdirx |
177 | aio_scandir aio_symlink aio_readlink aio_realpath aio_sync |
177 | aio_scandir aio_symlink aio_readlink aio_realpath aio_sync |
178 | aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range aio_fallocate |
178 | aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range aio_fallocate |
179 | aio_pathsync aio_readahead |
179 | aio_pathsync aio_readahead aio_fiemap |
180 | aio_rename aio_link aio_move aio_copy aio_group |
180 | aio_rename aio_link aio_move aio_copy aio_group |
181 | aio_nop aio_mknod aio_load aio_rmtree aio_mkdir aio_chown |
181 | aio_nop aio_mknod aio_load aio_rmtree aio_mkdir aio_chown |
182 | aio_chmod aio_utime aio_truncate |
182 | aio_chmod aio_utime aio_truncate |
183 | aio_msync aio_mtouch aio_mlock aio_mlockall |
183 | aio_msync aio_mtouch aio_mlock aio_mlockall |
184 | aio_statvfs |
184 | aio_statvfs |
… | |
… | |
413 | |
413 | |
414 | =cut |
414 | =cut |
415 | |
415 | |
416 | =item aio_seek $fh, $offset, $whence, $callback->($offs) |
416 | =item aio_seek $fh, $offset, $whence, $callback->($offs) |
417 | |
417 | |
418 | Seeks the filehandle to the new C<$offset>, similarly to perl'S |
418 | Seeks the filehandle to the new C<$offset>, similarly to perl's |
419 | C<sysseek>. The C<$whence> can use the traditional values (C<0> for |
419 | C<sysseek>. The C<$whence> can use the traditional values (C<0> for |
420 | C<IO::AIO::SEEK_SET>, C<1> for C<IO::AIO::SEEK_CUR> or C<2> for |
420 | C<IO::AIO::SEEK_SET>, C<1> for C<IO::AIO::SEEK_CUR> or C<2> for |
421 | C<IO::AIO::SEEK_END>). |
421 | C<IO::AIO::SEEK_END>). |
422 | |
422 | |
423 | The resulting absolute offset will be passed to the callback, or C<-1> in |
423 | The resulting absolute offset will be passed to the callback, or C<-1> in |
424 | case of an error. |
424 | case of an error. |
425 | |
425 | |
426 | In theory, the C<$whence> constants could be different than the |
426 | In theory, the C<$whence> constants could be different than the |
427 | corresponding values from L<Fcntl>, but perl guarantees they are the same, |
427 | corresponding values from L<Fcntl>, but perl guarantees they are the same, |
428 | so don't panic. |
428 | so don't panic. |
|
|
429 | |
|
|
430 | As a GNU/Linux (and maybe Solaris) extension, also the constants |
|
|
431 | C<IO::AIO::SEEK_DATA> and C<IO::AIO::SEEK_HOLE> are available, if they |
|
|
432 | could be found. No guarantees about suitability for use in C<aio_seek> or |
|
|
433 | Perl's C<sysseek> can be made though, although I would naively assume they |
|
|
434 | "just work". |
429 | |
435 | |
430 | =item aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval) |
436 | =item aio_read $fh,$offset,$length, $data,$dataoffset, $callback->($retval) |
431 | |
437 | |
432 | =item aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval) |
438 | =item aio_write $fh,$offset,$length, $data,$dataoffset, $callback->($retval) |
433 | |
439 | |
… | |
… | |
1249 | |
1255 | |
1250 | Example: asynchronously lock all current and future pages into memory. |
1256 | Example: asynchronously lock all current and future pages into memory. |
1251 | |
1257 | |
1252 | aio_mlockall IO::AIO::MCL_FUTURE; |
1258 | aio_mlockall IO::AIO::MCL_FUTURE; |
1253 | |
1259 | |
|
|
1260 | =item aio_fiemap $fh, $start, $length, $flags, $count, $cb->(\@extents) |
|
|
1261 | |
|
|
1262 | Queries the extents of the given file (by calling the Linux FIEMAP ioctl, |
|
|
1263 | see L<http://cvs.schmorp.de/IO-AIO/doc/fiemap.txt> for details). If the |
|
|
1264 | C<ioctl> is not available on your OS, then this rquiest will fail with |
|
|
1265 | C<ENOSYS>. |
|
|
1266 | |
|
|
1267 | C<$start> is the starting offset to query extents for, C<$length> is the |
|
|
1268 | size of the range to query - if it is C<undef>, then the whole file will |
|
|
1269 | be queried. |
|
|
1270 | |
|
|
1271 | C<$flags> is a combination of flags (C<IO::AIO::FIEMAP_FLAG_SYNC> or |
|
|
1272 | C<IO::AIO::FIEMAP_FLAG_XATTR> - C<IO::AIO::FIEMAP_FLAGS_COMPAT> is also |
|
|
1273 | exported), and is normally C<0> or C<IO::AIO::FIEMAP_FLAG_SYNC> to query |
|
|
1274 | the data portion. |
|
|
1275 | |
|
|
1276 | C<$count> is the maximum number of extent records to return. If it is |
|
|
1277 | C<undef>, then IO::AIO queries all extents of the file. As a very special |
|
|
1278 | case, if it is C<0>, then the callback receives the number of extents |
|
|
1279 | instead of the extents themselves. |
|
|
1280 | |
|
|
1281 | If an error occurs, the callback receives no arguments. The special |
|
|
1282 | C<errno> value C<IO::AIO::EBADR> is available to test for flag errors. |
|
|
1283 | |
|
|
1284 | Otherwise, the callback receives an array reference with extent |
|
|
1285 | structures. Each extent structure is an array reference itself, with the |
|
|
1286 | following members: |
|
|
1287 | |
|
|
1288 | [$logical, $physical, $length, $flags] |
|
|
1289 | |
|
|
1290 | Flags is any combination of the following flag values (typically either C<0> |
|
|
1291 | or C<IO::AIO::FIEMAP_EXTENT_LAST>): |
|
|
1292 | |
|
|
1293 | C<IO::AIO::FIEMAP_EXTENT_LAST>, C<IO::AIO::FIEMAP_EXTENT_UNKNOWN>, |
|
|
1294 | C<IO::AIO::FIEMAP_EXTENT_DELALLOC>, C<IO::AIO::FIEMAP_EXTENT_ENCODED>, |
|
|
1295 | C<IO::AIO::FIEMAP_EXTENT_DATA_ENCRYPTED>, C<IO::AIO::FIEMAP_EXTENT_NOT_ALIGNED>, |
|
|
1296 | C<IO::AIO::FIEMAP_EXTENT_DATA_INLINE>, C<IO::AIO::FIEMAP_EXTENT_DATA_TAIL>, |
|
|
1297 | C<IO::AIO::FIEMAP_EXTENT_UNWRITTEN>, C<IO::AIO::FIEMAP_EXTENT_MERGED> or |
|
|
1298 | C<IO::AIO::FIEMAP_EXTENT_SHARED>. |
|
|
1299 | |
1254 | =item aio_group $callback->(...) |
1300 | =item aio_group $callback->(...) |
1255 | |
1301 | |
1256 | This is a very special aio request: Instead of doing something, it is a |
1302 | This is a very special aio request: Instead of doing something, it is a |
1257 | container for other aio requests, which is useful if you want to bundle |
1303 | container for other aio requests, which is useful if you want to bundle |
1258 | many requests into a single, composite, request with a definite callback |
1304 | many requests into a single, composite, request with a definite callback |
… | |
… | |
1923 | Calls the C<munlockall> function. |
1969 | Calls the C<munlockall> function. |
1924 | |
1970 | |
1925 | On systems that do not implement C<munlockall>, this function returns |
1971 | On systems that do not implement C<munlockall>, this function returns |
1926 | ENOSYS, otherwise the return value of C<munlockall>. |
1972 | ENOSYS, otherwise the return value of C<munlockall>. |
1927 | |
1973 | |
|
|
1974 | =item IO::AIO::splice $r_fh, $r_off, $w_fh, $w_off, $length, $flags |
|
|
1975 | |
|
|
1976 | Calls the GNU/Linux C<splice(2)> syscall, if available. If C<$r_off> or |
|
|
1977 | C<$w_off> are C<undef>, then C<NULL> is passed for these, otherwise they |
|
|
1978 | should be the file offset. |
|
|
1979 | |
|
|
1980 | The following symbol flag values are available: C<IO::AIO::SPLICE_F_MOVE>, |
|
|
1981 | C<IO::AIO::SPLICE_F_NONBLOCK>, C<IO::AIO::SPLICE_F_MORE> and |
|
|
1982 | C<IO::AIO::SPLICE_F_GIFT>. |
|
|
1983 | |
|
|
1984 | See the C<splice(2)> manpage for details. |
|
|
1985 | |
|
|
1986 | =item IO::AIO::tee $r_fh, $w_fh, $length, $flags |
|
|
1987 | |
|
|
1988 | Calls the GNU/Linux C<tee(2)> syscall, see it's manpage and the |
|
|
1989 | description for C<IO::AIO::splice> above for details. |
|
|
1990 | |
1928 | =back |
1991 | =back |
1929 | |
1992 | |
1930 | =cut |
1993 | =cut |
1931 | |
1994 | |
1932 | min_parallel 8; |
1995 | min_parallel 8; |