s3: Use SMB_VFS_PREAD_SEND in schedule_smb2_aio_read
[Samba/gebeck_regimport.git] / source3 / smbd / aio.c
bloba8d49899644a32018033563c533323e230af76a5
1 /*
2 Unix SMB/Netbios implementation.
3 Version 3.0
4 async_io read handling using POSIX async io.
5 Copyright (C) Jeremy Allison 2005.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "includes.h"
22 #include "smbd/smbd.h"
23 #include "smbd/globals.h"
24 #include "../lib/util/tevent_ntstatus.h"
26 #if defined(HAVE_AIO)
28 /* The signal we'll use to signify aio done. */
29 #ifndef RT_SIGNAL_AIO
30 #define RT_SIGNAL_AIO (SIGRTMIN+3)
31 #endif
33 #ifndef HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIVAL_PTR
34 #ifdef HAVE_STRUCT_SIGEVENT_SIGEV_VALUE_SIGVAL_PTR
35 #define sival_int sigval_int
36 #define sival_ptr sigval_ptr
37 #endif
38 #endif
40 /****************************************************************************
41 The buffer we keep around whilst an aio request is in process.
42 *****************************************************************************/
44 struct aio_extra {
45 struct aio_extra *next, *prev;
46 SMB_STRUCT_AIOCB acb;
47 files_struct *fsp;
48 struct smb_request *smbreq;
49 DATA_BLOB outbuf;
50 struct lock_struct lock;
51 bool write_through;
52 int (*handle_completion)(struct aio_extra *ex, int errcode);
55 /****************************************************************************
56 Accessor function to return write_through state.
57 *****************************************************************************/
59 bool aio_write_through_requested(struct aio_extra *aio_ex)
61 return aio_ex->write_through;
64 /****************************************************************************
65 Initialize the signal handler for aio read/write.
66 *****************************************************************************/
68 static void smbd_aio_signal_handler(struct tevent_context *ev_ctx,
69 struct tevent_signal *se,
70 int signum, int count,
71 void *_info, void *private_data)
73 siginfo_t *info = (siginfo_t *)_info;
74 struct aio_extra *aio_ex = (struct aio_extra *)
75 info->si_value.sival_ptr;
77 smbd_aio_complete_aio_ex(aio_ex);
78 TALLOC_FREE(aio_ex);
82 bool initialize_async_io_handler(void)
84 static bool tried_signal_setup = false;
86 if (aio_signal_event) {
87 return true;
89 if (tried_signal_setup) {
90 return false;
92 tried_signal_setup = true;
94 aio_signal_event = tevent_add_signal(server_event_context(),
95 server_event_context(),
96 RT_SIGNAL_AIO, SA_SIGINFO,
97 smbd_aio_signal_handler,
98 NULL);
99 if (!aio_signal_event) {
100 DEBUG(10, ("Failed to setup RT_SIGNAL_AIO handler\n"));
101 return false;
103 return true;
106 static int handle_aio_read_complete(struct aio_extra *aio_ex, int errcode);
107 static int handle_aio_write_complete(struct aio_extra *aio_ex, int errcode);
108 static int handle_aio_smb2_read_complete(struct aio_extra *aio_ex, int errcode);
109 static int handle_aio_smb2_write_complete(struct aio_extra *aio_ex, int errcode);
111 static int aio_extra_destructor(struct aio_extra *aio_ex)
113 DLIST_REMOVE(aio_list_head, aio_ex);
114 outstanding_aio_calls--;
115 return 0;
118 /****************************************************************************
119 Create the extended aio struct we must keep around for the lifetime
120 of the aio call.
121 *****************************************************************************/
123 static struct aio_extra *create_aio_extra(TALLOC_CTX *mem_ctx,
124 files_struct *fsp,
125 size_t buflen)
127 struct aio_extra *aio_ex = talloc_zero(mem_ctx, struct aio_extra);
129 if (!aio_ex) {
130 return NULL;
133 /* The output buffer stored in the aio_ex is the start of
134 the smb return buffer. The buffer used in the acb
135 is the start of the reply data portion of that buffer. */
137 if (buflen) {
138 aio_ex->outbuf = data_blob_talloc(aio_ex, NULL, buflen);
139 if (!aio_ex->outbuf.data) {
140 TALLOC_FREE(aio_ex);
141 return NULL;
144 DLIST_ADD(aio_list_head, aio_ex);
145 talloc_set_destructor(aio_ex, aio_extra_destructor);
146 aio_ex->fsp = fsp;
147 outstanding_aio_calls++;
148 return aio_ex;
151 static void aio_pread_smb1_done(struct tevent_req *req);
153 /****************************************************************************
154 Set up an aio request from a SMBreadX call.
155 *****************************************************************************/
157 NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
158 struct smb_request *smbreq,
159 files_struct *fsp, off_t startpos,
160 size_t smb_maxcnt)
162 struct aio_extra *aio_ex;
163 SMB_STRUCT_AIOCB *a;
164 size_t bufsize;
165 size_t min_aio_read_size = lp_aio_read_size(SNUM(conn));
166 struct tevent_req *req;
168 if (fsp->base_fsp != NULL) {
169 /* No AIO on streams yet */
170 DEBUG(10, ("AIO on streams not yet supported\n"));
171 return NT_STATUS_RETRY;
174 if ((!min_aio_read_size || (smb_maxcnt < min_aio_read_size))
175 && !SMB_VFS_AIO_FORCE(fsp)) {
176 /* Too small a read for aio request. */
177 DEBUG(10,("schedule_aio_read_and_X: read size (%u) too small "
178 "for minimum aio_read of %u\n",
179 (unsigned int)smb_maxcnt,
180 (unsigned int)min_aio_read_size ));
181 return NT_STATUS_RETRY;
184 /* Only do this on non-chained and non-chaining reads not using the
185 * write cache. */
186 if (req_is_in_chain(smbreq) || (lp_write_cache_size(SNUM(conn)) != 0)) {
187 return NT_STATUS_RETRY;
190 if (outstanding_aio_calls >= aio_pending_size) {
191 DEBUG(10,("schedule_aio_read_and_X: Already have %d aio "
192 "activities outstanding.\n",
193 outstanding_aio_calls ));
194 return NT_STATUS_RETRY;
197 /* The following is safe from integer wrap as we've already checked
198 smb_maxcnt is 128k or less. Wct is 12 for read replies */
200 bufsize = smb_size + 12 * 2 + smb_maxcnt;
202 if ((aio_ex = create_aio_extra(NULL, fsp, bufsize)) == NULL) {
203 DEBUG(10,("schedule_aio_read_and_X: malloc fail.\n"));
204 return NT_STATUS_NO_MEMORY;
206 aio_ex->handle_completion = handle_aio_read_complete;
208 construct_reply_common_req(smbreq, (char *)aio_ex->outbuf.data);
209 srv_set_message((char *)aio_ex->outbuf.data, 12, 0, True);
210 SCVAL(aio_ex->outbuf.data,smb_vwv0,0xFF); /* Never a chained reply. */
212 init_strict_lock_struct(fsp, (uint64_t)smbreq->smbpid,
213 (uint64_t)startpos, (uint64_t)smb_maxcnt, READ_LOCK,
214 &aio_ex->lock);
216 /* Take the lock until the AIO completes. */
217 if (!SMB_VFS_STRICT_LOCK(conn, fsp, &aio_ex->lock)) {
218 TALLOC_FREE(aio_ex);
219 return NT_STATUS_FILE_LOCK_CONFLICT;
222 a = &aio_ex->acb;
224 /* Now set up the aio record for the read call. */
226 a->aio_fildes = fsp->fh->fd;
227 a->aio_buf = smb_buf(aio_ex->outbuf.data);
228 a->aio_nbytes = smb_maxcnt;
229 a->aio_offset = startpos;
230 a->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
231 a->aio_sigevent.sigev_signo = RT_SIGNAL_AIO;
232 a->aio_sigevent.sigev_value.sival_ptr = aio_ex;
234 req = SMB_VFS_PREAD_SEND(aio_ex, fsp->conn->sconn->ev_ctx,
235 fsp, smb_buf(aio_ex->outbuf.data),
236 smb_maxcnt, startpos);
237 if (req == NULL) {
238 DEBUG(0,("schedule_aio_read_and_X: aio_read failed. "
239 "Error %s\n", strerror(errno) ));
240 SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock);
241 TALLOC_FREE(aio_ex);
242 return NT_STATUS_RETRY;
244 tevent_req_set_callback(req, aio_pread_smb1_done, aio_ex);
246 aio_ex->smbreq = talloc_move(aio_ex, &smbreq);
248 DEBUG(10,("schedule_aio_read_and_X: scheduled aio_read for file %s, "
249 "offset %.0f, len = %u (mid = %u)\n",
250 fsp_str_dbg(fsp), (double)startpos, (unsigned int)smb_maxcnt,
251 (unsigned int)aio_ex->smbreq->mid ));
253 return NT_STATUS_OK;
256 static void aio_pread_smb1_done(struct tevent_req *req)
258 struct aio_extra *aio_ex = tevent_req_callback_data(
259 req, struct aio_extra);
260 files_struct *fsp = aio_ex->fsp;
261 int outsize;
262 char *outbuf = (char *)aio_ex->outbuf.data;
263 char *data = smb_buf(outbuf);
264 ssize_t nread;
265 int err;
267 nread = SMB_VFS_PREAD_RECV(req, &err);
268 TALLOC_FREE(req);
270 DEBUG(10, ("pread_recv returned %d, err = %s\n", (int)nread,
271 (nread == -1) ? strerror(err) : "no error"));
273 if (fsp == NULL) {
274 DEBUG( 3, ("aio_pread_smb1_done: file closed whilst "
275 "aio outstanding (mid[%llu]).\n",
276 (unsigned long long)aio_ex->smbreq->mid));
277 TALLOC_FREE(aio_ex);
278 return;
281 /* Unlock now we're done. */
282 SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock);
284 if (nread < 0) {
285 DEBUG( 3, ("handle_aio_read_complete: file %s nread == %d. "
286 "Error = %s\n", fsp_str_dbg(fsp), (int)nread,
287 strerror(err)));
289 ERROR_NT(map_nt_error_from_unix(err));
290 outsize = srv_set_message(outbuf,0,0,true);
291 } else {
292 outsize = srv_set_message(outbuf, 12, nread, False);
293 SSVAL(outbuf,smb_vwv2, 0xFFFF); /* Remaining - must be * -1. */
294 SSVAL(outbuf,smb_vwv5, nread);
295 SSVAL(outbuf,smb_vwv6, smb_offset(data,outbuf));
296 SSVAL(outbuf,smb_vwv7, ((nread >> 16) & 1));
297 SSVAL(smb_buf(outbuf), -2, nread);
299 aio_ex->fsp->fh->pos = aio_ex->acb.aio_offset + nread;
300 aio_ex->fsp->fh->position_information = aio_ex->fsp->fh->pos;
302 DEBUG( 3, ("handle_aio_read_complete file %s max=%d "
303 "nread=%d\n", fsp_str_dbg(fsp),
304 (int)aio_ex->acb.aio_nbytes, (int)nread ) );
307 smb_setlen(outbuf, outsize - 4);
308 show_msg(outbuf);
309 if (!srv_send_smb(aio_ex->smbreq->sconn, outbuf,
310 true, aio_ex->smbreq->seqnum+1,
311 IS_CONN_ENCRYPTED(fsp->conn), NULL)) {
312 exit_server_cleanly("handle_aio_read_complete: srv_send_smb "
313 "failed.");
316 DEBUG(10, ("handle_aio_read_complete: scheduled aio_read completed "
317 "for file %s, offset %.0f, len = %u\n",
318 fsp_str_dbg(fsp), (double)aio_ex->acb.aio_offset,
319 (unsigned int)nread));
321 TALLOC_FREE(aio_ex);
324 static void aio_pwrite_smb1_done(struct tevent_req *req);
326 /****************************************************************************
327 Set up an aio request from a SMBwriteX call.
328 *****************************************************************************/
330 NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
331 struct smb_request *smbreq,
332 files_struct *fsp, const char *data,
333 off_t startpos,
334 size_t numtowrite)
336 struct aio_extra *aio_ex;
337 SMB_STRUCT_AIOCB *a;
338 size_t bufsize;
339 size_t min_aio_write_size = lp_aio_write_size(SNUM(conn));
340 struct tevent_req *req;
342 if (fsp->base_fsp != NULL) {
343 /* No AIO on streams yet */
344 DEBUG(10, ("AIO on streams not yet supported\n"));
345 return NT_STATUS_RETRY;
348 if ((!min_aio_write_size || (numtowrite < min_aio_write_size))
349 && !SMB_VFS_AIO_FORCE(fsp)) {
350 /* Too small a write for aio request. */
351 DEBUG(10,("schedule_aio_write_and_X: write size (%u) too "
352 "small for minimum aio_write of %u\n",
353 (unsigned int)numtowrite,
354 (unsigned int)min_aio_write_size ));
355 return NT_STATUS_RETRY;
358 /* Only do this on non-chained and non-chaining writes not using the
359 * write cache. */
360 if (req_is_in_chain(smbreq) || (lp_write_cache_size(SNUM(conn)) != 0)) {
361 return NT_STATUS_RETRY;
364 if (outstanding_aio_calls >= aio_pending_size) {
365 DEBUG(3,("schedule_aio_write_and_X: Already have %d aio "
366 "activities outstanding.\n",
367 outstanding_aio_calls ));
368 DEBUG(10,("schedule_aio_write_and_X: failed to schedule "
369 "aio_write for file %s, offset %.0f, len = %u "
370 "(mid = %u)\n",
371 fsp_str_dbg(fsp), (double)startpos,
372 (unsigned int)numtowrite,
373 (unsigned int)smbreq->mid ));
374 return NT_STATUS_RETRY;
377 bufsize = smb_size + 6*2;
379 if (!(aio_ex = create_aio_extra(NULL, fsp, bufsize))) {
380 DEBUG(0,("schedule_aio_write_and_X: malloc fail.\n"));
381 return NT_STATUS_NO_MEMORY;
383 aio_ex->handle_completion = handle_aio_write_complete;
384 aio_ex->write_through = BITSETW(smbreq->vwv+7,0);
386 construct_reply_common_req(smbreq, (char *)aio_ex->outbuf.data);
387 srv_set_message((char *)aio_ex->outbuf.data, 6, 0, True);
388 SCVAL(aio_ex->outbuf.data,smb_vwv0,0xFF); /* Never a chained reply. */
390 init_strict_lock_struct(fsp, (uint64_t)smbreq->smbpid,
391 (uint64_t)startpos, (uint64_t)numtowrite, WRITE_LOCK,
392 &aio_ex->lock);
394 /* Take the lock until the AIO completes. */
395 if (!SMB_VFS_STRICT_LOCK(conn, fsp, &aio_ex->lock)) {
396 TALLOC_FREE(aio_ex);
397 return NT_STATUS_FILE_LOCK_CONFLICT;
400 a = &aio_ex->acb;
402 /* Now set up the aio record for the write call. */
404 a->aio_fildes = fsp->fh->fd;
405 a->aio_buf = discard_const_p(char, data);
406 a->aio_nbytes = numtowrite;
407 a->aio_offset = startpos;
408 a->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
409 a->aio_sigevent.sigev_signo = RT_SIGNAL_AIO;
410 a->aio_sigevent.sigev_value.sival_ptr = aio_ex;
412 req = SMB_VFS_PWRITE_SEND(aio_ex, fsp->conn->sconn->ev_ctx, fsp,
413 data, numtowrite, startpos);
414 if (req == NULL) {
415 DEBUG(3,("schedule_aio_wrote_and_X: aio_write failed. "
416 "Error %s\n", strerror(errno) ));
417 SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock);
418 TALLOC_FREE(aio_ex);
419 return NT_STATUS_RETRY;
421 tevent_req_set_callback(req, aio_pwrite_smb1_done, aio_ex);
423 aio_ex->smbreq = talloc_move(aio_ex, &smbreq);
425 /* This should actually be improved to span the write. */
426 contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_WRITE);
427 contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_WRITE);
429 if (!aio_ex->write_through && !lp_syncalways(SNUM(fsp->conn))
430 && fsp->aio_write_behind) {
431 /* Lie to the client and immediately claim we finished the
432 * write. */
433 SSVAL(aio_ex->outbuf.data,smb_vwv2,numtowrite);
434 SSVAL(aio_ex->outbuf.data,smb_vwv4,(numtowrite>>16)&1);
435 show_msg((char *)aio_ex->outbuf.data);
436 if (!srv_send_smb(aio_ex->smbreq->sconn,
437 (char *)aio_ex->outbuf.data,
438 true, aio_ex->smbreq->seqnum+1,
439 IS_CONN_ENCRYPTED(fsp->conn),
440 &aio_ex->smbreq->pcd)) {
441 exit_server_cleanly("schedule_aio_write_and_X: "
442 "srv_send_smb failed.");
444 DEBUG(10,("schedule_aio_write_and_X: scheduled aio_write "
445 "behind for file %s\n", fsp_str_dbg(fsp)));
448 DEBUG(10,("schedule_aio_write_and_X: scheduled aio_write for file "
449 "%s, offset %.0f, len = %u (mid = %u) "
450 "outstanding_aio_calls = %d\n",
451 fsp_str_dbg(fsp), (double)startpos, (unsigned int)numtowrite,
452 (unsigned int)aio_ex->smbreq->mid, outstanding_aio_calls ));
454 return NT_STATUS_OK;
457 static void aio_pwrite_smb1_done(struct tevent_req *req)
459 struct aio_extra *aio_ex = tevent_req_callback_data(
460 req, struct aio_extra);
461 files_struct *fsp = aio_ex->fsp;
462 char *outbuf = (char *)aio_ex->outbuf.data;
463 ssize_t numtowrite = aio_ex->acb.aio_nbytes;
464 ssize_t nwritten;
465 int err;
467 nwritten = SMB_VFS_PWRITE_RECV(req, &err);
468 TALLOC_FREE(req);
470 DEBUG(10, ("pwrite_recv returned %d, err = %s\n", (int)nwritten,
471 (nwritten == -1) ? strerror(err) : "no error"));
473 if (fsp == NULL) {
474 DEBUG( 3, ("aio_pwrite_smb1_done: file closed whilst "
475 "aio outstanding (mid[%llu]).\n",
476 (unsigned long long)aio_ex->smbreq->mid));
477 TALLOC_FREE(aio_ex);
478 return;
481 /* Unlock now we're done. */
482 SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock);
484 if (fsp->aio_write_behind) {
486 if (nwritten != numtowrite) {
487 if (nwritten == -1) {
488 DEBUG(5,("handle_aio_write_complete: "
489 "aio_write_behind failed ! File %s "
490 "is corrupt ! Error %s\n",
491 fsp_str_dbg(fsp), strerror(err)));
492 } else {
493 DEBUG(0,("handle_aio_write_complete: "
494 "aio_write_behind failed ! File %s "
495 "is corrupt ! Wanted %u bytes but "
496 "only wrote %d\n", fsp_str_dbg(fsp),
497 (unsigned int)numtowrite,
498 (int)nwritten ));
500 } else {
501 DEBUG(10,("handle_aio_write_complete: "
502 "aio_write_behind completed for file %s\n",
503 fsp_str_dbg(fsp)));
505 /* TODO: should no return success in case of an error !!! */
506 TALLOC_FREE(aio_ex);
507 return;
510 /* We don't need outsize or set_message here as we've already set the
511 fixed size length when we set up the aio call. */
513 if (nwritten == -1) {
514 DEBUG(3, ("handle_aio_write: file %s wanted %u bytes. "
515 "nwritten == %d. Error = %s\n",
516 fsp_str_dbg(fsp), (unsigned int)numtowrite,
517 (int)nwritten, strerror(err)));
519 ERROR_NT(map_nt_error_from_unix(err));
520 srv_set_message(outbuf,0,0,true);
521 } else {
522 NTSTATUS status;
524 SSVAL(outbuf,smb_vwv2,nwritten);
525 SSVAL(outbuf,smb_vwv4,(nwritten>>16)&1);
526 if (nwritten < (ssize_t)numtowrite) {
527 SCVAL(outbuf,smb_rcls,ERRHRD);
528 SSVAL(outbuf,smb_err,ERRdiskfull);
531 DEBUG(3,("handle_aio_write: %s, num=%d wrote=%d\n",
532 fsp_fnum_dbg(fsp), (int)numtowrite, (int)nwritten));
533 status = sync_file(fsp->conn,fsp, aio_ex->write_through);
534 if (!NT_STATUS_IS_OK(status)) {
535 ERROR_BOTH(map_nt_error_from_unix(errno),
536 ERRHRD, ERRdiskfull);
537 srv_set_message(outbuf,0,0,true);
538 DEBUG(5, ("handle_aio_write: sync_file for %s "
539 "returned %s\n",
540 fsp_str_dbg(fsp), nt_errstr(status)));
543 aio_ex->fsp->fh->pos = aio_ex->acb.aio_offset + nwritten;
546 show_msg(outbuf);
547 if (!srv_send_smb(aio_ex->smbreq->sconn, outbuf,
548 true, aio_ex->smbreq->seqnum+1,
549 IS_CONN_ENCRYPTED(fsp->conn),
550 NULL)) {
551 exit_server_cleanly("handle_aio_write_complete: "
552 "srv_send_smb failed.");
555 DEBUG(10, ("handle_aio_write_complete: scheduled aio_write completed "
556 "for file %s, offset %.0f, requested %u, written = %u\n",
557 fsp_str_dbg(fsp), (double)aio_ex->acb.aio_offset,
558 (unsigned int)numtowrite, (unsigned int)nwritten));
560 TALLOC_FREE(aio_ex);
563 bool cancel_smb2_aio(struct smb_request *smbreq)
565 struct smbd_smb2_request *smb2req = smbreq->smb2req;
566 struct aio_extra *aio_ex = NULL;
567 int ret;
569 if (smb2req) {
570 aio_ex = talloc_get_type(smbreq->async_priv,
571 struct aio_extra);
574 if (aio_ex == NULL) {
575 return false;
578 if (aio_ex->fsp == NULL) {
579 return false;
582 ret = SMB_VFS_AIO_CANCEL(aio_ex->fsp, &aio_ex->acb);
583 if (ret != AIO_CANCELED) {
584 return false;
587 return true;
590 static void aio_pread_smb2_done(struct tevent_req *req);
592 /****************************************************************************
593 Set up an aio request from a SMB2 read call.
594 *****************************************************************************/
596 NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
597 struct smb_request *smbreq,
598 files_struct *fsp,
599 TALLOC_CTX *ctx,
600 DATA_BLOB *preadbuf,
601 off_t startpos,
602 size_t smb_maxcnt)
604 struct aio_extra *aio_ex;
605 SMB_STRUCT_AIOCB *a;
606 size_t min_aio_read_size = lp_aio_read_size(SNUM(conn));
607 struct tevent_req *req;
609 if (fsp->base_fsp != NULL) {
610 /* No AIO on streams yet */
611 DEBUG(10, ("AIO on streams not yet supported\n"));
612 return NT_STATUS_RETRY;
615 if ((!min_aio_read_size || (smb_maxcnt < min_aio_read_size))
616 && !SMB_VFS_AIO_FORCE(fsp)) {
617 /* Too small a read for aio request. */
618 DEBUG(10,("smb2: read size (%u) too small "
619 "for minimum aio_read of %u\n",
620 (unsigned int)smb_maxcnt,
621 (unsigned int)min_aio_read_size ));
622 return NT_STATUS_RETRY;
625 /* Only do this on reads not using the write cache. */
626 if (lp_write_cache_size(SNUM(conn)) != 0) {
627 return NT_STATUS_RETRY;
630 if (outstanding_aio_calls >= aio_pending_size) {
631 DEBUG(10,("smb2: Already have %d aio "
632 "activities outstanding.\n",
633 outstanding_aio_calls ));
634 return NT_STATUS_RETRY;
637 /* Create the out buffer. */
638 *preadbuf = data_blob_talloc(ctx, NULL, smb_maxcnt);
639 if (preadbuf->data == NULL) {
640 return NT_STATUS_NO_MEMORY;
643 if (!(aio_ex = create_aio_extra(smbreq->smb2req, fsp, 0))) {
644 return NT_STATUS_NO_MEMORY;
646 aio_ex->handle_completion = handle_aio_smb2_read_complete;
648 init_strict_lock_struct(fsp, (uint64_t)smbreq->smbpid,
649 (uint64_t)startpos, (uint64_t)smb_maxcnt, READ_LOCK,
650 &aio_ex->lock);
652 /* Take the lock until the AIO completes. */
653 if (!SMB_VFS_STRICT_LOCK(conn, fsp, &aio_ex->lock)) {
654 TALLOC_FREE(aio_ex);
655 return NT_STATUS_FILE_LOCK_CONFLICT;
658 a = &aio_ex->acb;
660 /* Now set up the aio record for the read call. */
662 a->aio_fildes = fsp->fh->fd;
663 a->aio_buf = preadbuf->data;
664 a->aio_nbytes = smb_maxcnt;
665 a->aio_offset = startpos;
666 a->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
667 a->aio_sigevent.sigev_signo = RT_SIGNAL_AIO;
668 a->aio_sigevent.sigev_value.sival_ptr = aio_ex;
670 req = SMB_VFS_PREAD_SEND(aio_ex, fsp->conn->sconn->ev_ctx, fsp,
671 preadbuf->data, smb_maxcnt, startpos);
672 if (req == NULL) {
673 DEBUG(0, ("smb2: SMB_VFS_PREAD_SEND failed. "
674 "Error %s\n", strerror(errno)));
675 SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock);
676 TALLOC_FREE(aio_ex);
677 return NT_STATUS_RETRY;
679 tevent_req_set_callback(req, aio_pread_smb2_done, aio_ex);
681 /* We don't need talloc_move here as both aio_ex and
682 * smbreq are children of smbreq->smb2req. */
683 aio_ex->smbreq = smbreq;
684 smbreq->async_priv = aio_ex;
686 DEBUG(10,("smb2: scheduled aio_read for file %s, "
687 "offset %.0f, len = %u (mid = %u)\n",
688 fsp_str_dbg(fsp), (double)startpos, (unsigned int)smb_maxcnt,
689 (unsigned int)aio_ex->smbreq->mid ));
691 return NT_STATUS_OK;
694 static void aio_pread_smb2_done(struct tevent_req *req)
696 struct aio_extra *aio_ex = tevent_req_callback_data(
697 req, struct aio_extra);
698 struct tevent_req *subreq = aio_ex->smbreq->smb2req->subreq;
699 files_struct *fsp = aio_ex->fsp;
700 NTSTATUS status;
701 ssize_t nread;
702 int err = 0;
704 nread = SMB_VFS_PREAD_RECV(req, &err);
705 TALLOC_FREE(req);
707 DEBUG(10, ("pread_recv returned %d, err = %s\n", (int)nread,
708 (nread == -1) ? strerror(err) : "no error"));
710 if (fsp == NULL) {
711 DEBUG( 3, ("aio_pread_smb2_done: file closed whilst "
712 "aio outstanding (mid[%llu]).\n",
713 (unsigned long long)aio_ex->smbreq->mid));
714 TALLOC_FREE(aio_ex);
715 return;
718 /* Unlock now we're done. */
719 SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock);
721 /* Common error or success code processing for async or sync
722 read returns. */
724 status = smb2_read_complete(subreq, nread, err);
726 if (nread > 0) {
727 fsp->fh->pos = aio_ex->acb.aio_offset + nread;
728 fsp->fh->position_information = fsp->fh->pos;
731 DEBUG(10, ("smb2: scheduled aio_read completed "
732 "for file %s, offset %.0f, len = %u "
733 "(errcode = %d, NTSTATUS = %s)\n",
734 fsp_str_dbg(aio_ex->fsp),
735 (double)aio_ex->acb.aio_offset,
736 (unsigned int)nread,
737 err, nt_errstr(status)));
739 if (!NT_STATUS_IS_OK(status)) {
740 tevent_req_nterror(subreq, status);
741 return;
743 tevent_req_done(subreq);
746 /****************************************************************************
747 Set up an aio request from a SMB2write call.
748 *****************************************************************************/
750 NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
751 struct smb_request *smbreq,
752 files_struct *fsp,
753 uint64_t in_offset,
754 DATA_BLOB in_data,
755 bool write_through)
757 struct aio_extra *aio_ex = NULL;
758 SMB_STRUCT_AIOCB *a = NULL;
759 size_t min_aio_write_size = lp_aio_write_size(SNUM(conn));
760 int ret;
762 if (fsp->base_fsp != NULL) {
763 /* No AIO on streams yet */
764 DEBUG(10, ("AIO on streams not yet supported\n"));
765 return NT_STATUS_RETRY;
768 if ((!min_aio_write_size || (in_data.length < min_aio_write_size))
769 && !SMB_VFS_AIO_FORCE(fsp)) {
770 /* Too small a write for aio request. */
771 DEBUG(10,("smb2: write size (%u) too "
772 "small for minimum aio_write of %u\n",
773 (unsigned int)in_data.length,
774 (unsigned int)min_aio_write_size ));
775 return NT_STATUS_RETRY;
778 /* Only do this on writes not using the write cache. */
779 if (lp_write_cache_size(SNUM(conn)) != 0) {
780 return NT_STATUS_RETRY;
783 if (outstanding_aio_calls >= aio_pending_size) {
784 DEBUG(3,("smb2: Already have %d aio "
785 "activities outstanding.\n",
786 outstanding_aio_calls ));
787 return NT_STATUS_RETRY;
790 if (!(aio_ex = create_aio_extra(smbreq->smb2req, fsp, 0))) {
791 return NT_STATUS_NO_MEMORY;
794 aio_ex->handle_completion = handle_aio_smb2_write_complete;
795 aio_ex->write_through = write_through;
797 init_strict_lock_struct(fsp, (uint64_t)smbreq->smbpid,
798 in_offset, (uint64_t)in_data.length, WRITE_LOCK,
799 &aio_ex->lock);
801 /* Take the lock until the AIO completes. */
802 if (!SMB_VFS_STRICT_LOCK(conn, fsp, &aio_ex->lock)) {
803 TALLOC_FREE(aio_ex);
804 return NT_STATUS_FILE_LOCK_CONFLICT;
807 a = &aio_ex->acb;
809 /* Now set up the aio record for the write call. */
811 a->aio_fildes = fsp->fh->fd;
812 a->aio_buf = in_data.data;
813 a->aio_nbytes = in_data.length;
814 a->aio_offset = in_offset;
815 a->aio_sigevent.sigev_notify = SIGEV_SIGNAL;
816 a->aio_sigevent.sigev_signo = RT_SIGNAL_AIO;
817 a->aio_sigevent.sigev_value.sival_ptr = aio_ex;
819 ret = SMB_VFS_AIO_WRITE(fsp, a);
820 if (ret == -1) {
821 DEBUG(3,("smb2: aio_write failed. "
822 "Error %s\n", strerror(errno) ));
823 SMB_VFS_STRICT_UNLOCK(conn, fsp, &aio_ex->lock);
824 TALLOC_FREE(aio_ex);
825 return NT_STATUS_RETRY;
828 /* We don't need talloc_move here as both aio_ex and
829 * smbreq are children of smbreq->smb2req. */
830 aio_ex->smbreq = smbreq;
831 smbreq->async_priv = aio_ex;
833 /* This should actually be improved to span the write. */
834 contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_WRITE);
835 contend_level2_oplocks_end(fsp, LEVEL2_CONTEND_WRITE);
838 * We don't want to do write behind due to ownership
839 * issues of the request structs. Maybe add it if I
840 * figure those out. JRA.
843 DEBUG(10,("smb2: scheduled aio_write for file "
844 "%s, offset %.0f, len = %u (mid = %u) "
845 "outstanding_aio_calls = %d\n",
846 fsp_str_dbg(fsp),
847 (double)in_offset,
848 (unsigned int)in_data.length,
849 (unsigned int)aio_ex->smbreq->mid,
850 outstanding_aio_calls ));
852 return NT_STATUS_OK;
855 /****************************************************************************
856 Complete the read and return the data or error back to the client.
857 Returns errno or zero if all ok.
858 *****************************************************************************/
860 static int handle_aio_read_complete(struct aio_extra *aio_ex, int errcode)
862 int outsize;
863 char *outbuf = (char *)aio_ex->outbuf.data;
864 char *data = smb_buf(outbuf);
865 ssize_t nread = SMB_VFS_AIO_RETURN(aio_ex->fsp,&aio_ex->acb);
867 if (nread < 0) {
868 /* We're relying here on the fact that if the fd is
869 closed then the aio will complete and aio_return
870 will return an error. Hopefully this is
871 true.... JRA. */
873 DEBUG( 3,( "handle_aio_read_complete: file %s nread == %d. "
874 "Error = %s\n",
875 fsp_str_dbg(aio_ex->fsp), (int)nread, strerror(errcode)));
877 ERROR_NT(map_nt_error_from_unix(errcode));
878 outsize = srv_set_message(outbuf,0,0,true);
879 } else {
880 outsize = srv_set_message(outbuf,12,nread,False);
881 SSVAL(outbuf,smb_vwv2,0xFFFF); /* Remaining - must be * -1. */
882 SSVAL(outbuf,smb_vwv5,nread);
883 SSVAL(outbuf,smb_vwv6,smb_offset(data,outbuf));
884 SSVAL(outbuf,smb_vwv7,((nread >> 16) & 1));
885 SSVAL(smb_buf(outbuf),-2,nread);
887 aio_ex->fsp->fh->pos = aio_ex->acb.aio_offset + nread;
888 aio_ex->fsp->fh->position_information = aio_ex->fsp->fh->pos;
890 DEBUG( 3, ( "handle_aio_read_complete file %s max=%d "
891 "nread=%d\n",
892 fsp_str_dbg(aio_ex->fsp),
893 (int)aio_ex->acb.aio_nbytes, (int)nread ) );
896 smb_setlen(outbuf,outsize - 4);
897 show_msg(outbuf);
898 if (!srv_send_smb(aio_ex->smbreq->sconn, outbuf,
899 true, aio_ex->smbreq->seqnum+1,
900 IS_CONN_ENCRYPTED(aio_ex->fsp->conn), NULL)) {
901 exit_server_cleanly("handle_aio_read_complete: srv_send_smb "
902 "failed.");
905 DEBUG(10,("handle_aio_read_complete: scheduled aio_read completed "
906 "for file %s, offset %.0f, len = %u\n",
907 fsp_str_dbg(aio_ex->fsp), (double)aio_ex->acb.aio_offset,
908 (unsigned int)nread ));
910 return errcode;
913 /****************************************************************************
914 Complete the write and return the data or error back to the client.
915 Returns error code or zero if all ok.
916 *****************************************************************************/
918 static int handle_aio_write_complete(struct aio_extra *aio_ex, int errcode)
920 files_struct *fsp = aio_ex->fsp;
921 char *outbuf = (char *)aio_ex->outbuf.data;
922 ssize_t numtowrite = aio_ex->acb.aio_nbytes;
923 ssize_t nwritten = SMB_VFS_AIO_RETURN(fsp,&aio_ex->acb);
925 if (fsp->aio_write_behind) {
926 if (nwritten != numtowrite) {
927 if (nwritten == -1) {
928 DEBUG(5,("handle_aio_write_complete: "
929 "aio_write_behind failed ! File %s "
930 "is corrupt ! Error %s\n",
931 fsp_str_dbg(fsp), strerror(errcode)));
932 } else {
933 DEBUG(0,("handle_aio_write_complete: "
934 "aio_write_behind failed ! File %s "
935 "is corrupt ! Wanted %u bytes but "
936 "only wrote %d\n", fsp_str_dbg(fsp),
937 (unsigned int)numtowrite,
938 (int)nwritten ));
939 errcode = EIO;
941 } else {
942 DEBUG(10,("handle_aio_write_complete: "
943 "aio_write_behind completed for file %s\n",
944 fsp_str_dbg(fsp)));
946 /* TODO: should no return 0 in case of an error !!! */
947 return 0;
950 /* We don't need outsize or set_message here as we've already set the
951 fixed size length when we set up the aio call. */
953 if(nwritten == -1) {
954 DEBUG( 3,( "handle_aio_write: file %s wanted %u bytes. "
955 "nwritten == %d. Error = %s\n",
956 fsp_str_dbg(fsp), (unsigned int)numtowrite,
957 (int)nwritten, strerror(errcode) ));
959 ERROR_NT(map_nt_error_from_unix(errcode));
960 srv_set_message(outbuf,0,0,true);
961 } else {
962 NTSTATUS status;
964 SSVAL(outbuf,smb_vwv2,nwritten);
965 SSVAL(outbuf,smb_vwv4,(nwritten>>16)&1);
966 if (nwritten < (ssize_t)numtowrite) {
967 SCVAL(outbuf,smb_rcls,ERRHRD);
968 SSVAL(outbuf,smb_err,ERRdiskfull);
971 DEBUG(3,("handle_aio_write: %s, num=%d wrote=%d\n",
972 fsp_fnum_dbg(fsp), (int)numtowrite, (int)nwritten));
973 status = sync_file(fsp->conn,fsp, aio_ex->write_through);
974 if (!NT_STATUS_IS_OK(status)) {
975 errcode = errno;
976 ERROR_BOTH(map_nt_error_from_unix(errcode),
977 ERRHRD, ERRdiskfull);
978 srv_set_message(outbuf,0,0,true);
979 DEBUG(5,("handle_aio_write: sync_file for %s returned %s\n",
980 fsp_str_dbg(fsp), nt_errstr(status)));
983 aio_ex->fsp->fh->pos = aio_ex->acb.aio_offset + nwritten;
985 mark_file_modified(aio_ex->fsp);
988 show_msg(outbuf);
989 if (!srv_send_smb(aio_ex->smbreq->sconn, outbuf,
990 true, aio_ex->smbreq->seqnum+1,
991 IS_CONN_ENCRYPTED(fsp->conn),
992 NULL)) {
993 exit_server_cleanly("handle_aio_write_complete: "
994 "srv_send_smb failed.");
997 DEBUG(10,("handle_aio_write_complete: scheduled aio_write completed "
998 "for file %s, offset %.0f, requested %u, written = %u\n",
999 fsp_str_dbg(fsp), (double)aio_ex->acb.aio_offset,
1000 (unsigned int)numtowrite, (unsigned int)nwritten ));
1002 return errcode;
1005 /****************************************************************************
1006 Complete the read and return the data or error back to the client.
1007 Returns errno or zero if all ok.
1008 *****************************************************************************/
1010 static int handle_aio_smb2_read_complete(struct aio_extra *aio_ex, int errcode)
1012 NTSTATUS status;
1013 struct tevent_req *subreq = aio_ex->smbreq->smb2req->subreq;
1014 ssize_t nread = SMB_VFS_AIO_RETURN(aio_ex->fsp,&aio_ex->acb);
1016 /* Common error or success code processing for async or sync
1017 read returns. */
1019 status = smb2_read_complete(subreq, nread, errcode);
1021 if (nread > 0) {
1022 aio_ex->fsp->fh->pos = aio_ex->acb.aio_offset + nread;
1023 aio_ex->fsp->fh->position_information = aio_ex->fsp->fh->pos;
1026 DEBUG(10,("smb2: scheduled aio_read completed "
1027 "for file %s, offset %.0f, len = %u "
1028 "(errcode = %d, NTSTATUS = %s)\n",
1029 fsp_str_dbg(aio_ex->fsp),
1030 (double)aio_ex->acb.aio_offset,
1031 (unsigned int)nread,
1032 errcode,
1033 nt_errstr(status) ));
1035 if (!NT_STATUS_IS_OK(status)) {
1036 tevent_req_nterror(subreq, status);
1037 return errcode;
1040 tevent_req_done(subreq);
1041 return errcode;
1044 /****************************************************************************
1045 Complete the SMB2 write and return the data or error back to the client.
1046 Returns error code or zero if all ok.
1047 *****************************************************************************/
1049 static int handle_aio_smb2_write_complete(struct aio_extra *aio_ex, int errcode)
1051 files_struct *fsp = aio_ex->fsp;
1052 ssize_t numtowrite = aio_ex->acb.aio_nbytes;
1053 ssize_t nwritten = SMB_VFS_AIO_RETURN(fsp,&aio_ex->acb);
1054 struct tevent_req *subreq = aio_ex->smbreq->smb2req->subreq;
1055 NTSTATUS status;
1057 status = smb2_write_complete(subreq, nwritten, errcode);
1059 DEBUG(10,("smb2: scheduled aio_write completed "
1060 "for file %s, offset %.0f, requested %u, "
1061 "written = %u (errcode = %d, NTSTATUS = %s)\n",
1062 fsp_str_dbg(fsp),
1063 (double)aio_ex->acb.aio_offset,
1064 (unsigned int)numtowrite,
1065 (unsigned int)nwritten,
1066 errcode,
1067 nt_errstr(status) ));
1069 if (!NT_STATUS_IS_OK(status)) {
1070 tevent_req_nterror(subreq, status);
1071 return errcode;
1074 mark_file_modified(fsp);
1076 tevent_req_done(subreq);
1077 return errcode;
1080 /****************************************************************************
1081 Handle any aio completion. Returns True if finished (and sets *perr if err
1082 was non-zero), False if not.
1083 *****************************************************************************/
1085 static bool handle_aio_completed(struct aio_extra *aio_ex, int *perr)
1087 files_struct *fsp = NULL;
1088 int err;
1090 if(!aio_ex) {
1091 DEBUG(3, ("handle_aio_completed: Non-existing aio_ex passed\n"));
1092 return false;
1095 if (!aio_ex->fsp) {
1096 DEBUG(3, ("handle_aio_completed: aio_ex->fsp == NULL\n"));
1097 return false;
1100 fsp = aio_ex->fsp;
1102 /* Ensure the operation has really completed. */
1103 err = SMB_VFS_AIO_ERROR(fsp, &aio_ex->acb);
1104 if (err == EINPROGRESS) {
1105 DEBUG(10,( "handle_aio_completed: operation mid %llu still in "
1106 "process for file %s\n",
1107 (unsigned long long)aio_ex->smbreq->mid,
1108 fsp_str_dbg(aio_ex->fsp)));
1109 return False;
1112 if (err == ECANCELED) {
1113 DEBUG(10,( "handle_aio_completed: operation mid %llu canceled "
1114 "for file %s\n",
1115 (unsigned long long)aio_ex->smbreq->mid,
1116 fsp_str_dbg(aio_ex->fsp)));
1119 /* Unlock now we're done. */
1120 SMB_VFS_STRICT_UNLOCK(fsp->conn, fsp, &aio_ex->lock);
1122 err = aio_ex->handle_completion(aio_ex, err);
1123 if (err) {
1124 *perr = err; /* Only save non-zero errors. */
1127 return True;
1130 /****************************************************************************
1131 Handle any aio completion inline.
1132 *****************************************************************************/
1134 void smbd_aio_complete_aio_ex(struct aio_extra *aio_ex)
1136 files_struct *fsp = NULL;
1137 int ret = 0;
1139 DEBUG(10,("smbd_aio_complete_mid: mid[%llu]\n",
1140 (unsigned long long)aio_ex->smbreq->mid));
1142 fsp = aio_ex->fsp;
1143 if (fsp == NULL) {
1144 /* file was closed whilst I/O was outstanding. Just
1145 * ignore. */
1146 DEBUG( 3,( "smbd_aio_complete_mid: file closed whilst "
1147 "aio outstanding (mid[%llu]).\n",
1148 (unsigned long long)aio_ex->smbreq->mid));
1149 return;
1152 if (!handle_aio_completed(aio_ex, &ret)) {
1153 return;
1157 /****************************************************************************
1158 We're doing write behind and the client closed the file. Wait up to 45
1159 seconds (my arbitrary choice) for the aio to complete. Return 0 if all writes
1160 completed, errno to return if not.
1161 *****************************************************************************/
1163 #define SMB_TIME_FOR_AIO_COMPLETE_WAIT 45
1165 int wait_for_aio_completion(files_struct *fsp)
1167 struct aio_extra *aio_ex;
1168 const SMB_STRUCT_AIOCB **aiocb_list;
1169 int aio_completion_count = 0;
1170 time_t start_time = time_mono(NULL);
1171 int seconds_left;
1173 for (seconds_left = SMB_TIME_FOR_AIO_COMPLETE_WAIT;
1174 seconds_left >= 0;) {
1175 int err = 0;
1176 int i;
1177 struct timespec ts;
1179 aio_completion_count = 0;
1180 for( aio_ex = aio_list_head; aio_ex; aio_ex = aio_ex->next) {
1181 if (aio_ex->fsp == fsp) {
1182 aio_completion_count++;
1186 if (!aio_completion_count) {
1187 return 0;
1190 DEBUG(3,("wait_for_aio_completion: waiting for %d aio events "
1191 "to complete.\n", aio_completion_count ));
1193 aiocb_list = SMB_MALLOC_ARRAY(const SMB_STRUCT_AIOCB *,
1194 aio_completion_count);
1195 if (!aiocb_list) {
1196 return ENOMEM;
1199 for( i = 0, aio_ex = aio_list_head;
1200 aio_ex;
1201 aio_ex = aio_ex->next) {
1202 if (aio_ex->fsp == fsp) {
1203 aiocb_list[i++] = &aio_ex->acb;
1207 /* Now wait up to seconds_left for completion. */
1208 ts.tv_sec = seconds_left;
1209 ts.tv_nsec = 0;
1211 DEBUG(10,("wait_for_aio_completion: %d events, doing a wait "
1212 "of %d seconds.\n",
1213 aio_completion_count, seconds_left ));
1215 err = SMB_VFS_AIO_SUSPEND(fsp, aiocb_list,
1216 aio_completion_count, &ts);
1218 DEBUG(10,("wait_for_aio_completion: returned err = %d, "
1219 "errno = %s\n", err, strerror(errno) ));
1221 if (err == -1 && errno == EAGAIN) {
1222 DEBUG(0,("wait_for_aio_completion: aio_suspend timed "
1223 "out waiting for %d events after a wait of "
1224 "%d seconds\n", aio_completion_count,
1225 seconds_left));
1226 /* Timeout. */
1227 SAFE_FREE(aiocb_list);
1228 /* We're hosed here - IO may complete
1229 and trample over memory if we free
1230 the aio_ex struct, but if we don't
1231 we leak IO requests. I think smb_panic()
1232 if the right thing to do here. JRA.
1234 smb_panic("AIO suspend timed out - cannot continue.");
1235 return EIO;
1238 /* One or more events might have completed - process them if
1239 * so. */
1240 for( i = 0; i < aio_completion_count; i++) {
1241 aio_ex = (struct aio_extra *)aiocb_list[i]->aio_sigevent.sigev_value.sival_ptr;
1243 if (!handle_aio_completed(aio_ex, &err)) {
1244 continue;
1246 TALLOC_FREE(aio_ex);
1249 SAFE_FREE(aiocb_list);
1250 seconds_left = SMB_TIME_FOR_AIO_COMPLETE_WAIT
1251 - (time_mono(NULL) - start_time);
1254 /* We timed out - we don't know why. Return ret if already an error,
1255 * else EIO. */
1256 DEBUG(10,("wait_for_aio_completion: aio_suspend timed out waiting "
1257 "for %d events\n",
1258 aio_completion_count));
1260 return EIO;
1263 #else
1265 bool initialize_async_io_handler(void)
1267 return false;
1270 NTSTATUS schedule_aio_read_and_X(connection_struct *conn,
1271 struct smb_request *smbreq,
1272 files_struct *fsp, off_t startpos,
1273 size_t smb_maxcnt)
1275 return NT_STATUS_RETRY;
1278 NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
1279 struct smb_request *smbreq,
1280 files_struct *fsp, const char *data,
1281 off_t startpos,
1282 size_t numtowrite)
1284 return NT_STATUS_RETRY;
1287 bool cancel_smb2_aio(struct smb_request *smbreq)
1289 return false;
1292 NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
1293 struct smb_request *smbreq,
1294 files_struct *fsp,
1295 TALLOC_CTX *ctx,
1296 DATA_BLOB *preadbuf,
1297 off_t startpos,
1298 size_t smb_maxcnt)
1300 return NT_STATUS_RETRY;
1303 NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
1304 struct smb_request *smbreq,
1305 files_struct *fsp,
1306 uint64_t in_offset,
1307 DATA_BLOB in_data,
1308 bool write_through)
1310 return NT_STATUS_RETRY;
1313 int wait_for_aio_completion(files_struct *fsp)
1315 return 0;
1318 void smbd_aio_complete_mid(uint64_t mid);
1320 #endif