Commit 4a81afa4 authored by gregor herrmann's avatar gregor herrmann

New upstream version 4.34

parent 8e6ffbd1
......@@ -169,13 +169,13 @@ use common::sense;
use base 'Exporter';
BEGIN {
our $VERSION = 4.33;
our $VERSION = 4.34;
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
aio_scandir aio_symlink aio_readlink aio_realpath aio_sync
aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range aio_allocate
aio_pathsync aio_readahead aio_fiemap
aio_scandir aio_symlink aio_readlink aio_realpath aio_fcntl aio_ioctl
aio_sync aio_fsync aio_syncfs aio_fdatasync aio_sync_file_range
aio_pathsync aio_readahead aio_fiemap aio_allocate
aio_rename aio_link aio_move aio_copy aio_group
aio_nop aio_mknod aio_load aio_rmtree aio_mkdir aio_chown
aio_chmod aio_utime aio_truncate
......@@ -242,6 +242,8 @@ documentation.
aio_copy $srcpath, $dstpath, $callback->($status)
aio_move $srcpath, $dstpath, $callback->($status)
aio_rmtree $pathname, $callback->($status)
aio_fcntl $fh, $cmd, $arg, $callback->($status)
aio_ioctl $fh, $request, $buf, $callback->($status)
aio_sync $callback->($status)
aio_syncfs $fh, $callback->($status)
aio_fsync $fh, $callback->($status)
......@@ -1229,6 +1231,25 @@ sub aio_rmtree($;$) {
$grp
}
=item aio_fcntl $fh, $cmd, $arg, $callback->($status)
=item aio_ioctl $fh, $request, $buf, $callback->($status)
These work just like the C<fcntl> and C<ioctl> built-in functions, except
they execute asynchronously and pass the return value to the callback.
Both calls can be used for a lot of things, some of which make more sense
to run asynchronously in their own thread, while some others make less
sense. For example, calls that block waiting for external events, such
as locking, will also lock down an I/O thread while it is waiting, which
can deadlock the whole I/O system. At the same time, there might be no
alternative to using a thread to wait.
So in general, you should only use these calls for things that do
(filesystem) I/O, not for things that wait for other events (network,
other processes), although if you are careful and know what you are doing,
you still can.
=item aio_sync $callback->($status)
Asynchronously call sync and call the callback when finished.
......@@ -2067,7 +2088,6 @@ C<IO::AIO::MAP_SHARED> or
C<IO::AIO::MAP_PRIVATE>,
or a number of system-specific flags (when not available, the are C<0>):
C<IO::AIO::MAP_ANONYMOUS> (which is set to C<MAP_ANON> if your system only provides this constant),
C<IO::AIO::MAP_HUGETLB>,
C<IO::AIO::MAP_LOCKED>,
C<IO::AIO::MAP_NORESERVE>,
C<IO::AIO::MAP_POPULATE>,
......
......@@ -987,7 +987,6 @@ BOOT:
const_iv (MAP_ANONYMOUS)
/* linuxish */
const_iv (MAP_HUGETLB)
const_iv (MAP_LOCKED)
const_iv (MAP_NORESERVE)
const_iv (MAP_POPULATE)
......@@ -1298,6 +1297,46 @@ aio_read (SV *fh, SV *offset, SV *length, SV8 *data, IV dataoffset, SV *callback
}
}
void
aio_ioctl (SV *fh, unsigned long request, SV8 *arg, SV *callback = &PL_sv_undef)
ALIAS:
aio_ioctl = EIO_IOCTL
aio_fcntl = EIO_FCNTL
PPCODE:
{
int fd = s_fileno_croak (fh, 0);
char *svptr;
if (SvPOK (arg) || !SvNIOK (arg))
{
STRLEN svlen;
/* perl uses IOCPARM_LEN for fcntl, so we do, too */
#ifdef IOCPARM_LEN
STRLEN need = IOCPARM_LEN (request);
#else
STRLEN need = 256;
#endif
if (svlen < need)
svptr = SvGROW (arg, need);
}
else
svptr = (char *)SvIV (arg);
{
dREQ;
req->type = ix;
req->sv1 = newSVsv (fh);
req->int1 = fd;
req->int2 = (long)request;
req->sv2 = SvREFCNT_inc (arg);
req->ptr2 = svptr;
REQ_SEND;
}
}
void
aio_readlink (SV8 *pathname, SV *callback = &PL_sv_undef)
ALIAS:
......@@ -1368,7 +1407,7 @@ major (UV dev)
ALIAS:
minor = 1
CODE:
RETVAL = ix ? major (dev) : minor (dev);
RETVAL = ix ? minor (dev) : major (dev);
OUTPUT:
RETVAL
......
......@@ -31,11 +31,23 @@ TODO: renameat RENAME_EXCHANGE, RENAME_NOREPLACE, RENAME_EXCHANGE
TODO: fcntl F_GETLKP/F_SETLKP/F_SETLKPW, http://lwn.net/Articles/586904/
TODO: flink + AT_EMPTY_PATH
TODO: name_to_handle_At + open_by_handle_at = clone fds
TODO: lchown
TODO: rewrite rmtree et al. to support working directories (also speed them up)
TODO: maybe IO::AIO leaks fds when requests are cancelled? maybe initialise result to -1?
TODO: aio_wd should use O_PATH on linux, due to lacking O_SEARCH (http://comments.gmane.org/gmane.linux.file-systems/33611)
http://www.openwall.com/lists/musl/2013/02/23/4
TODO: aio_fcntl/ioctl test.
4.34 Sun May 1 19:18:24 CEST 2016
- def0.h was not properly generated during previous release, causing
compile errors on various platforms.
- major/minor were accidentally switched (reported by Alexander Lishenyuk).
- removed duplicate definition of MAP_HUGETLB, that was found due to
a bug in Perl::Tidy (testcase by alaska332@gmail.com).
- added (untested!) aio_fcntl, aio_ioctl requests.
- (libeio) names set via prctl are truncated to 15 chars + nul, not 16,
as manpages-dev originally claimed.
4.33 Mon Jan 18 12:50:10 CET 2016
- add IO::AIO::pipe2 function.
......
......@@ -4,7 +4,7 @@
"unknown"
],
"dynamic_config" : 1,
"generated_by" : "ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001",
"generated_by" : "ExtUtils::MakeMaker version 7.1, CPAN::Meta::Converter version 2.150001",
"license" : [
"unknown"
],
......@@ -38,5 +38,5 @@
}
},
"release_status" : "stable",
"version" : 4.33
"version" : 4.34
}
......@@ -8,7 +8,7 @@ configure_requires:
Canary::Stability: '2001'
ExtUtils::MakeMaker: '6.52'
dynamic_config: 1
generated_by: 'ExtUtils::MakeMaker version 7.0401, CPAN::Meta::Converter version 2.150001'
generated_by: 'ExtUtils::MakeMaker version 7.1, CPAN::Meta::Converter version 2.150001'
license: unknown
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
......@@ -20,4 +20,4 @@ no_index:
- inc
requires:
common::sense: '0'
version: 4.33
version: 4.34
......@@ -186,6 +186,8 @@ FUNCTIONS
aio_copy $srcpath, $dstpath, $callback->($status)
aio_move $srcpath, $dstpath, $callback->($status)
aio_rmtree $pathname, $callback->($status)
aio_fcntl $fh, $cmd, $arg, $callback->($status)
aio_ioctl $fh, $request, $buf, $callback->($status)
aio_sync $callback->($status)
aio_syncfs $fh, $callback->($status)
aio_fsync $fh, $callback->($status)
......@@ -890,6 +892,24 @@ FUNCTIONS
uses "aio_scandir" to recurse into and rmdir directories, and unlink
everything else.
aio_fcntl $fh, $cmd, $arg, $callback->($status)
aio_ioctl $fh, $request, $buf, $callback->($status)
These work just like the "fcntl" and "ioctl" built-in functions,
except they execute asynchronously and pass the return value to the
callback.
Both calls can be used for a lot of things, some of which make more
sense to run asynchronously in their own thread, while some others
make less sense. For example, calls that block waiting for external
events, such as locking, will also lock down an I/O thread while it
is waiting, which can deadlock the whole I/O system. At the same
time, there might be no alternative to using a thread to wait.
So in general, you should only use these calls for things that do
(filesystem) I/O, not for things that wait for other events
(network, other processes), although if you are careful and know
what you are doing, you still can.
aio_sync $callback->($status)
Asynchronously call sync and call the callback when finished.
......@@ -1640,11 +1660,11 @@ FUNCTIONS
"IO::AIO::MAP_PRIVATE", or a number of system-specific flags (when
not available, the are 0): "IO::AIO::MAP_ANONYMOUS" (which is set to
"MAP_ANON" if your system only provides this constant),
"IO::AIO::MAP_HUGETLB", "IO::AIO::MAP_LOCKED",
"IO::AIO::MAP_NORESERVE", "IO::AIO::MAP_POPULATE",
"IO::AIO::MAP_NONBLOCK", "IO::AIO::MAP_FIXED",
"IO::AIO::MAP_GROWSDOWN", "IO::AIO::MAP_32BIT",
"IO::AIO::MAP_HUGETLB" or "IO::AIO::MAP_STACK".
"IO::AIO::MAP_LOCKED", "IO::AIO::MAP_NORESERVE",
"IO::AIO::MAP_POPULATE", "IO::AIO::MAP_NONBLOCK",
"IO::AIO::MAP_FIXED", "IO::AIO::MAP_GROWSDOWN",
"IO::AIO::MAP_32BIT", "IO::AIO::MAP_HUGETLB" or
"IO::AIO::MAP_STACK".
If $fh is "undef", then a file descriptor of -1 is passed.
......
......@@ -9,6 +9,45 @@
#ifndef EBADR
#define EBADR 0
#endif
#ifndef SEEK_DATA
#define SEEK_DATA 0
#endif
#ifndef SEEK_HOLE
#define SEEK_HOLE 0
#endif
#ifndef POSIX_FADV_NORMAL
#define POSIX_FADV_NORMAL 0
#endif
#ifndef POSIX_FADV_SEQUENTIAL
#define POSIX_FADV_SEQUENTIAL 0
#endif
#ifndef POSIX_FADV_RANDOM
#define POSIX_FADV_RANDOM 0
#endif
#ifndef POSIX_FADV_NOREUSE
#define POSIX_FADV_NOREUSE 0
#endif
#ifndef POSIX_FADV_WILLNEED
#define POSIX_FADV_WILLNEED 0
#endif
#ifndef POSIX_FADV_DONTNEED
#define POSIX_FADV_DONTNEED 0
#endif
#ifndef POSIX_MADV_NORMAL
#define POSIX_MADV_NORMAL 0
#endif
#ifndef POSIX_MADV_SEQUENTIAL
#define POSIX_MADV_SEQUENTIAL 0
#endif
#ifndef POSIX_MADV_RANDOM
#define POSIX_MADV_RANDOM 0
#endif
#ifndef POSIX_MADV_WILLNEED
#define POSIX_MADV_WILLNEED 0
#endif
#ifndef POSIX_MADV_DONTNEED
#define POSIX_MADV_DONTNEED 0
#endif
#ifndef O_RDONLY
#define O_RDONLY 0
#endif
......@@ -105,39 +144,6 @@
#ifndef S_IFMT
#define S_IFMT 0
#endif
#ifndef POSIX_FADV_NORMAL
#define POSIX_FADV_NORMAL 0
#endif
#ifndef POSIX_FADV_SEQUENTIAL
#define POSIX_FADV_SEQUENTIAL 0
#endif
#ifndef POSIX_FADV_RANDOM
#define POSIX_FADV_RANDOM 0
#endif
#ifndef POSIX_FADV_NOREUSE
#define POSIX_FADV_NOREUSE 0
#endif
#ifndef POSIX_FADV_WILLNEED
#define POSIX_FADV_WILLNEED 0
#endif
#ifndef POSIX_FADV_DONTNEED
#define POSIX_FADV_DONTNEED 0
#endif
#ifndef POSIX_MADV_NORMAL
#define POSIX_MADV_NORMAL 0
#endif
#ifndef POSIX_MADV_SEQUENTIAL
#define POSIX_MADV_SEQUENTIAL 0
#endif
#ifndef POSIX_MADV_RANDOM
#define POSIX_MADV_RANDOM 0
#endif
#ifndef POSIX_MADV_WILLNEED
#define POSIX_MADV_WILLNEED 0
#endif
#ifndef POSIX_MADV_DONTNEED
#define POSIX_MADV_DONTNEED 0
#endif
#ifndef ST_RDONLY
#define ST_RDONLY 0
#endif
......@@ -192,12 +198,12 @@
#ifndef MAP_SHARED
#define MAP_SHARED 0
#endif
#ifndef MAP_FIXED
#define MAP_FIXED 0
#endif
#ifndef MAP_ANONYMOUS
#define MAP_ANONYMOUS 0
#endif
#ifndef MAP_HUGETLB
#define MAP_HUGETLB 0
#endif
#ifndef MAP_LOCKED
#define MAP_LOCKED 0
#endif
......@@ -210,6 +216,18 @@
#ifndef MAP_NONBLOCK
#define MAP_NONBLOCK 0
#endif
#ifndef MAP_GROWSDOWN
#define MAP_GROWSDOWN 0
#endif
#ifndef MAP_32BIT
#define MAP_32BIT 0
#endif
#ifndef MAP_HUGETLB
#define MAP_HUGETLB 0
#endif
#ifndef MAP_STACK
#define MAP_STACK 0
#endif
#ifndef FIEMAP_FLAG_SYNC
#define FIEMAP_FLAG_SYNC 0
#endif
......@@ -264,9 +282,3 @@
#ifndef SPLICE_F_GIFT
#define SPLICE_F_GIFT 0
#endif
#ifndef SEEK_DATA
#define SEEK_DATA 0
#endif
#ifndef SEEK_HOLE
#define SEEK_HOLE 0
#endif
/*
* libeio implementation
*
* Copyright (c) 2007,2008,2009,2010,2011,2012,2013 Marc Alexander Lehmann <libeio@schmorp.de>
* Copyright (c) 2007,2008,2009,2010,2011,2012,2013,2016 Marc Alexander Lehmann <libeio@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
......@@ -44,11 +44,6 @@
#include "eio.h"
#include "ecb.h"
#ifdef EIO_STACKSIZE
# define X_STACKSIZE EIO_STACKSIZE
#endif
#include "xthread.h"
#include <errno.h>
#include <stddef.h>
#include <stdlib.h>
......@@ -124,6 +119,8 @@ static void eio_destroy (eio_req *req);
#define dup2(fd1,fd2) _dup2 (fd1, fd2)
#define pipe(fds) _pipe (fds, 4096, O_BINARY)
#define fcntl(fd,cmd,arg) EIO_ENOSYS ()
#define ioctl(fd,cmd,arg) EIO_ENOSYS ()
#define fchmod(fd,mode) EIO_ENOSYS ()
#define chown(path,uid,gid) EIO_ENOSYS ()
#define fchown(fd,uid,gid) EIO_ENOSYS ()
......@@ -285,10 +282,6 @@ static void eio_destroy (eio_req *req);
# include <sys/syscall.h>
#endif
#if HAVE_SYS_PRCTL_H
# include <sys/prctl.h>
#endif
#if HAVE_SENDFILE
# if __linux
# include <sys/sendfile.h>
......@@ -1818,6 +1811,9 @@ eio_execute (etp_worker *self, eio_req *req)
? pwrite (req->int1, req->ptr2, req->size, req->offs)
: write (req->int1, req->ptr2, req->size); break;
case EIO_FCNTL: req->result = fcntl (req->int1, (int) req->int2, req->ptr2); break;
case EIO_IOCTL: req->result = ioctl (req->int1, (unsigned long)req->int2, req->ptr2); break;
case EIO_READAHEAD: req->result = readahead (req->int1, req->offs, req->size); break;
case EIO_SENDFILE: req->result = eio__sendfile (req->int1, req->int2, req->offs, req->size); break;
......@@ -2087,6 +2083,16 @@ eio_req *eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio
REQ (EIO_WRITE); req->int1 = fd; req->offs = offset; req->size = length; req->ptr2 = buf; SEND;
}
eio_req *eio_fcntl (int fd, int cmd, void *arg, int pri, eio_cb cb, void *data)
{
REQ (EIO_IOCTL); req->int1 = fd; req->int2 = cmd; req->ptr2 = arg; SEND;
}
eio_req *eio_ioctl (int fd, unsigned long request, void *buf, int pri, eio_cb cb, void *data)
{
REQ (EIO_IOCTL); req->int1 = fd; req->int2 = request; req->ptr2 = buf; SEND;
}
eio_req *eio_fstat (int fd, int pri, eio_cb cb, void *data)
{
REQ (EIO_FSTAT); req->int1 = fd; SEND;
......
/*
* libeio API header
*
* Copyright (c) 2007,2008,2009,2010,2011,2012,2015 Marc Alexander Lehmann <libeio@schmorp.de>
* Copyright (c) 2007,2008,2009,2010,2011,2012,2015,2016 Marc Alexander Lehmann <libeio@schmorp.de>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modifica-
......@@ -187,7 +187,7 @@ enum
EIO_WD_OPEN, EIO_WD_CLOSE,
EIO_CLOSE, EIO_DUP2,
EIO_SEEK, EIO_READ, EIO_WRITE,
EIO_SEEK, EIO_READ, EIO_WRITE, EIO_FCNTL, EIO_IOCTL,
EIO_READAHEAD, EIO_SENDFILE,
EIO_FSTAT, EIO_FSTATVFS,
EIO_FTRUNCATE, EIO_FUTIME, EIO_FCHMOD, EIO_FCHOWN,
......@@ -253,13 +253,13 @@ struct eio_req
eio_ssize_t result; /* result of syscall, e.g. result = read (... */
off_t offs; /* read, write, truncate, readahead, sync_file_range, fallocate: file offset, mknod: dev_t */
size_t size; /* read, write, readahead, sendfile, msync, mlock, sync_file_range, fallocate: length */
void *ptr1; /* all applicable requests: pathname, old name; readdir: optional eio_dirents */
void *ptr1; /* all applicable requests: pathname, old name, readdir: optional eio_dirents */
void *ptr2; /* all applicable requests: new name or memory buffer; readdir: name strings */
eio_tstamp nv1; /* utime, futime: atime; busy: sleep time */
eio_tstamp nv2; /* utime, futime: mtime */
int int1; /* all applicable requests: file descriptor; sendfile: output fd; open, msync, mlockall, readdir: flags */
long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode, seek: whence, sync_file_range, fallocate: flags */
long int2; /* chown, fchown: uid; sendfile: input fd; open, chmod, mkdir, mknod: file mode, seek: whence, fcntl, ioctl: request, sync_file_range, fallocate: flags */
long int3; /* chown, fchown: gid; rename, link: working directory of new name */
int errorno; /* errno value on syscall return */
......@@ -344,6 +344,8 @@ eio_req *eio_readahead (int fd, off_t offset, size_t length, int pri, eio_cb cb,
eio_req *eio_seek (int fd, off_t offset, int whence, int pri, eio_cb cb, void *data);
eio_req *eio_read (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data);
eio_req *eio_write (int fd, void *buf, size_t length, off_t offset, int pri, eio_cb cb, void *data);
eio_req *eio_fcntl (int fd, int cmd, void *arg, int pri, eio_cb cb, void *data);
eio_req *eio_ioctl (int fd, unsigned long request, void *buf, int pri, eio_cb cb, void *data);
eio_req *eio_fstat (int fd, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */
eio_req *eio_fstatvfs (int fd, int pri, eio_cb cb, void *data); /* stat buffer=ptr2 allocated dynamically */
eio_req *eio_futime (int fd, eio_tstamp atime, eio_tstamp mtime, int pri, eio_cb cb, void *data);
......
......@@ -37,6 +37,15 @@
* either the BSD or the GPL.
*/
#if HAVE_SYS_PRCTL_H
# include <sys/prctl.h>
#endif
#ifdef EIO_STACKSIZE
# define X_STACKSIZE EIO_STACKSIZE
#endif
#include "xthread.h"
#ifndef ETP_API_DECL
# define ETP_API_DECL static
#endif
......@@ -311,7 +320,7 @@ etp_proc_init (void)
{
#if HAVE_PRCTL_SET_NAME
/* provide a more sensible "thread name" */
char name[16 + 1];
char name[15 + 1];
const int namelen = sizeof (name) - 1;
int len;
......
......@@ -28,10 +28,10 @@ T_VAL64
$var = ($type)SvVAL64 ($arg);
T_AIO_RFD
$var = s_fileno_croak ($arg, 0);
$var = s_fileno_croak ($arg, 0);
T_AIO_WFD
$var = s_fileno_croak ($arg, 1);
$var = s_fileno_croak ($arg, 1);
OUTPUT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment