From bbe55d953e8db49a56779ad24b428d03ffa8ce83 Mon Sep 17 00:00:00 2001 From: Olaf Flebbe Date: Tue, 16 Feb 2010 14:00:18 +0100 Subject: [PATCH] handle strict allocation with async i/o too: Fall back to synchronous. --- source3/smbd/aio.c | 30 +++++++++++++++++++++++++++++- 1 files changed, 29 insertions(+), 1 deletions(-) diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c index 406ec1b..bacaf7c 100644 --- a/source3/smbd/aio.c +++ b/source3/smbd/aio.c @@ -211,8 +211,10 @@ bool schedule_aio_write_and_X(connection_struct *conn, { struct aio_extra *aio_ex; SMB_STRUCT_AIOCB *a; + SMB_STRUCT_STAT st; size_t bufsize; bool write_through = BITSETW(req->vwv+7,0); + bool other_aio_found; size_t min_aio_write_size = lp_aio_write_size(SNUM(conn)); int ret; @@ -233,7 +235,7 @@ bool schedule_aio_write_and_X(connection_struct *conn, } /* Only do this on non-chained and non-chaining reads not using the - * write cache. */ + write cache. */ if (req_is_in_chain(req) || (lp_write_cache_size(SNUM(conn)) != 0)) { return False; } @@ -251,6 +253,32 @@ bool schedule_aio_write_and_X(connection_struct *conn, return False; } + other_aio_found = false; + /* Make sure there are no outstanding aio writes on same fsp */ + for( aio_ex = aio_list_head; aio_ex; aio_ex = aio_ex->next) { + if (fsp == aio_ex->fsp) { + /* Don't do preallocate detection if other */ + /* aio statements are outstanding */ + /* this should not happen! */ + other_aio_found = true; + break; + } + } + + if (!other_aio_found) { + ret = SMB_VFS_FSTAT(fsp, &st); + if (ret == -1) { + /* This should not happen, fall back to synchronous */ + return False; + } + + if (startpos > st.st_size) { + /* let a synchronous write handle allocating */ + if (lp_strict_allocate(SNUM(fsp->conn))) + return False; + } + } + bufsize = smb_size + 6*2; if (!(aio_ex = create_aio_extra(fsp, bufsize))) { -- 1.6.0.2