Author: jra Date: 2005-06-15 01:23:06 +0000 (Wed, 15 Jun 2005) New Revision: 7600
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7600 Log: Fix up aio write-behind code. Ensure we reset the number of outstanding aio completes when we're in a loop (thanks valgrind :-). Jeremy. Modified: trunk/source/smbd/aio.c trunk/source/smbd/process.c Changeset: Modified: trunk/source/smbd/aio.c =================================================================== --- trunk/source/smbd/aio.c 2005-06-15 01:22:30 UTC (rev 7599) +++ trunk/source/smbd/aio.c 2005-06-15 01:23:06 UTC (rev 7600) @@ -454,7 +454,7 @@ fsp->fsp_name, strerror(errno) )); ret = errno; } else { - DEBUG(5,("handle_aio_write_complete: aio_write_behind failed ! File %s is corrupt ! \ + DEBUG(0,("handle_aio_write_complete: aio_write_behind failed ! File %s is corrupt ! \ Wanted %u bytes but only wrote %d\n", fsp->fsp_name, (unsigned int)numtowrite, (int)nwritten )); ret = EIO; } @@ -578,6 +578,7 @@ int i; struct timespec ts; + aio_completion_count = 0; for( aio_ex = aio_list_head; aio_ex; aio_ex = aio_ex->next) { if (aio_ex->fsp == fsp) { aio_completion_count++; @@ -588,7 +589,7 @@ return ret; } - DEBUG(10,("wait_for_aio_completion: waiting for %d aio events to complete.\n", + DEBUG(3,("wait_for_aio_completion: waiting for %d aio events to complete.\n", aio_completion_count )); aiocb_list = SMB_MALLOC_ARRAY(const SMB_STRUCT_AIOCB *, aio_completion_count); @@ -606,21 +607,29 @@ ts.tv_sec = seconds_left; ts.tv_nsec = 0; + DEBUG(3,("wait_for_aio_completion: doing a wait of %d seconds.\n", seconds_left )); + err = SMB_VFS_AIO_SUSPEND(fsp, aiocb_list, aio_completion_count, &ts); - if ((err == 0) || (err == -1 && errno == EINTR)) { - err = process_aio_queue(); - if (err) { - /* Only return non-zero errors. */ - ret = err; - } + if (err == -1 && errno == EAGAIN) { + /* Timeout. */ + break; } + err = process_aio_queue(); + if (err) { + /* Only return non-zero errors. */ + ret = err; + } + SAFE_FREE(aiocb_list); seconds_left -= (time(NULL) - start_time); } /* We timed out - we don't know why. Return ret if already an error, else EIO. */ + DEBUG(0,("wait_for_aio_completion: aio_suspend timed out waiting for %d events\n", + aio_completion_count)); + return ret ? ret : EIO; } Modified: trunk/source/smbd/process.c =================================================================== --- trunk/source/smbd/process.c 2005-06-15 01:22:30 UTC (rev 7599) +++ trunk/source/smbd/process.c 2005-06-15 01:23:06 UTC (rev 7600) @@ -286,15 +286,17 @@ { DEBUG(10,("async_processing: Doing async processing.\n")); - if (process_aio_queue()) { - return; - } + process_aio_queue(); /* check for oplock messages (both UDP and kernel) */ if (receive_local_message(buffer, buffer_len, 1)) { process_local_message(buffer, buffer_len); } + /* Do the aio check again after receive_local_message as it does a select + and may have eaten our signal. */ + process_aio_queue(); + if (got_sig_term) { exit_server("Caught TERM signal"); }