s3:smbd/aio: add cancel_smb2_aio()
authorStefan Metzmacher <metze@samba.org>
Mon, 14 Nov 2011 08:52:47 +0000 (09:52 +0100)
committerStefan Metzmacher <metze@samba.org>
Tue, 15 Nov 2011 16:14:13 +0000 (17:14 +0100)
metze

source3/smbd/aio.c
source3/smbd/proto.h

index 98a35ed2060aa07c61f4cddcee64a9ba8e3d1530..a978c4f87c30f0070a57567dae546f26f90d19a8 100644 (file)
@@ -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,
index 0a68a6c3183bb7f0207216b89a19417ffc9a60ea..fe9076647e572844cdaf16b648b61b4a29a6103c 100644 (file)
@@ -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);