summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-11-14 09:52:47 +0100
committerStefan Metzmacher <metze@samba.org>2011-11-15 17:14:13 +0100
commit2802be75e38d5ae64ad5ec36e46d0799c77eec30 (patch)
treecf8bd9b2d8a89960b2aacf2f07824042d79328a9
parent0cd67698ca69d82936da29658103ce449d797c25 (diff)
downloadsamba-2802be75e38d5ae64ad5ec36e46d0799c77eec30.tar.gz
samba-2802be75e38d5ae64ad5ec36e46d0799c77eec30.tar.bz2
samba-2802be75e38d5ae64ad5ec36e46d0799c77eec30.zip
s3:smbd/aio: add cancel_smb2_aio()
metze
-rw-r--r--source3/smbd/aio.c38
-rw-r--r--source3/smbd/proto.h1
2 files changed, 39 insertions, 0 deletions
diff --git a/source3/smbd/aio.c b/source3/smbd/aio.c
index 98a35ed206..a978c4f87c 100644
--- a/source3/smbd/aio.c
+++ b/source3/smbd/aio.c
@@ -380,6 +380,37 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
return NT_STATUS_OK;
}
+bool cancel_smb2_aio(struct smb_request *smbreq)
+{
+ struct smbd_smb2_request *smb2req = smbreq->smb2req;
+ struct aio_extra *aio_ex = NULL;
+ int ret;
+
+ if (smbreq) {
+ smb2req = smbreq->smb2req;
+ }
+
+ if (smb2req) {
+ aio_ex = talloc_get_type(smbreq->async_priv,
+ struct aio_extra);
+ }
+
+ if (aio_ex == NULL) {
+ return false;
+ }
+
+ if (aio_ex->fsp == NULL) {
+ return false;
+ }
+
+ ret = SMB_VFS_AIO_CANCEL(aio_ex->fsp, &aio_ex->acb);
+ if (ret != AIO_CANCELED) {
+ return false;
+ }
+
+ return true;
+}
+
/****************************************************************************
Set up an aio request from a SMB2 read call.
*****************************************************************************/
@@ -476,6 +507,7 @@ NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
/* We don't need talloc_move here as both aio_ex and
* smbreq are children of smbreq->smb2req. */
aio_ex->smbreq = smbreq;
+ smbreq->async_priv = aio_ex;
DEBUG(10,("smb2: scheduled aio_read for file %s, "
"offset %.0f, len = %u (mid = %u)\n",
@@ -576,6 +608,7 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
/* We don't need talloc_move here as both aio_ex and
* smbreq are children of smbreq->smb2req. */
aio_ex->smbreq = smbreq;
+ smbreq->async_priv = aio_ex;
/* This should actually be improved to span the write. */
contend_level2_oplocks_begin(fsp, LEVEL2_CONTEND_WRITE);
@@ -1039,6 +1072,11 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
return NT_STATUS_RETRY;
}
+bool cancel_smb2_aio(struct smb_request *smbreq)
+{
+ return false;
+}
+
NTSTATUS schedule_smb2_aio_read(connection_struct *conn,
struct smb_request *smbreq,
files_struct *fsp,
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 0a68a6c318..fe9076647e 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -86,6 +86,7 @@ NTSTATUS schedule_aio_smb2_write(connection_struct *conn,
uint64_t in_offset,
DATA_BLOB in_data,
bool write_through);
+bool cancel_smb2_aio(struct smb_request *smbreq);
int wait_for_aio_completion(files_struct *fsp);
void cancel_aio_by_fsp(files_struct *fsp);
void smbd_aio_complete_aio_ex(struct aio_extra *aio_ex);