From: Ralph Boehme Date: Wed, 20 May 2020 20:58:29 +0000 (+0200) Subject: vfs_aio_pthread: implement SMB_VFS_OPENAT() X-Git-Tag: ldb-2.2.0~402 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bae76f8644b349d1eeca7992c0741f4d6be78213;p=thirdparty%2Fsamba.git vfs_aio_pthread: implement SMB_VFS_OPENAT() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_aio_pthread.c b/source3/modules/vfs_aio_pthread.c index 2c8ef350818..37f883b47ce 100644 --- a/source3/modules/vfs_aio_pthread.c +++ b/source3/modules/vfs_aio_pthread.c @@ -502,11 +502,70 @@ static int aio_pthread_open_fn(vfs_handle_struct *handle, TALLOC_FREE(fspcwd); return fd; } + +static int aio_pthread_openat_fn(vfs_handle_struct *handle, + const struct files_struct *dirfsp, + const struct smb_filename *smb_fname, + struct files_struct *fsp, + int flags, + mode_t mode) +{ + int my_errno = 0; + int fd = -1; + bool aio_allow_open = lp_parm_bool( + SNUM(handle->conn), "aio_pthread", "aio open", false); + + if (smb_fname->stream_name != NULL) { + /* Don't handle stream opens. */ + errno = ENOENT; + return -1; + } + + if (!aio_allow_open) { + /* aio opens turned off. */ + return openat(dirfsp->fh->fd, + smb_fname->base_name, + flags, + mode); + } + + if (!(flags & O_CREAT)) { + /* Only creates matter. */ + return openat(dirfsp->fh->fd, + smb_fname->base_name, + flags, + mode); + } + + if (!(flags & O_EXCL)) { + /* Only creates with O_EXCL matter. */ + return openat(dirfsp->fh->fd, + smb_fname->base_name, + flags, + mode); + } + + /* + * See if this is a reentrant call - i.e. is this a + * restart of an existing open that just completed. + */ + + if (find_completed_open(fsp, + &fd, + &my_errno)) { + errno = my_errno; + return fd; + } + + /* Ok, it's a create exclusive call - pass it to a thread helper. */ + return open_async(dirfsp, smb_fname, fsp, flags, mode); +} #endif static struct vfs_fn_pointers vfs_aio_pthread_fns = { #if defined(HAVE_OPENAT) && defined(HAVE_LINUX_THREAD_CREDENTIALS) .open_fn = aio_pthread_open_fn, + .openat_fn = aio_pthread_openat_fn, #endif };