summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2012-07-12 10:10:32 -0700
committerJeremy Allison <jra@samba.org>2012-07-13 00:35:47 +0200
commite454681276ffa34984dda56e74d2fda05a24636c (patch)
tree1e5ccca809ec9423af603f05a2b439413470ffd3
parenta7c63ac1b7bc3f9c9a0e8786046644194e270f10 (diff)
downloadsamba-e454681276ffa34984dda56e74d2fda05a24636c.tar.gz
samba-e454681276ffa34984dda56e74d2fda05a24636c.tar.bz2
samba-e454681276ffa34984dda56e74d2fda05a24636c.zip
Linux-specific optimization in aio_open code.
Use initial_allocation_size to allocate on disk if sent. Ignore failures (upper level will cope). Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Jul 13 00:35:48 CEST 2012 on sn-devel-104
-rw-r--r--source3/modules/vfs_aio_pthread.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/source3/modules/vfs_aio_pthread.c b/source3/modules/vfs_aio_pthread.c
index 4525beb818..2c6121dbe5 100644
--- a/source3/modules/vfs_aio_pthread.c
+++ b/source3/modules/vfs_aio_pthread.c
@@ -27,6 +27,9 @@
#include "smbd/smbd.h"
#include "smbd/globals.h"
#include "lib/pthreadpool/pthreadpool.h"
+#ifdef HAVE_LINUX_FALLOC_H
+#include <linux/falloc.h>
+#endif
struct aio_extra;
static struct pthreadpool *pool;
@@ -635,6 +638,7 @@ struct aio_open_private_data {
char *dname;
struct smbd_server_connection *sconn;
const struct security_unix_token *ux_tok;
+ uint64_t initial_allocation_size;
/* Returns. */
int ret_fd;
int ret_errno;
@@ -769,6 +773,23 @@ static void aio_open_worker(void *private_data)
} else {
/* Create was successful. */
opd->ret_errno = 0;
+
+#if defined(HAVE_LINUX_FALLOCATE)
+ /*
+ * See if we can set the initial
+ * allocation size. We don't record
+ * the return for this as it's an
+ * optimization - the upper layer
+ * will also do this for us once
+ * the open returns.
+ */
+ if (opd->initial_allocation_size) {
+ (void)fallocate(opd->ret_fd,
+ FALLOC_FL_KEEP_SIZE,
+ 0,
+ (off_t)opd->initial_allocation_size);
+ }
+#endif
}
}
@@ -810,6 +831,7 @@ static struct aio_open_private_data *create_private_open_data(const files_struct
opd->mid = fsp->mid;
opd->in_progress = true;
opd->sconn = fsp->conn->sconn;
+ opd->initial_allocation_size = fsp->initial_allocation_size;
/* Copy our current credentials. */
opd->ux_tok = copy_unix_token(opd, get_current_utok(fsp->conn));