Change smbd_aio_complete_mid() -> smbd_aio_complete_aio_ex(). Simplifies
authorJeremy Allison <jra@samba.org>
Fri, 4 Jun 2010 18:30:46 +0000 (11:30 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 4 Jun 2010 18:30:46 +0000 (11:30 -0700)
the code and eliminates find_aio_ex().

Jeremy.

source3/include/proto.h
source3/include/smb.h
source3/modules/vfs_aio_fork.c
source3/smbd/aio.c

index 884ce3f07fa03442162019e05b056f82a365f072..41ab440fd8eb9fba86917b9ed5604c740a41a636 100644 (file)
@@ -5321,7 +5321,7 @@ NTSTATUS schedule_aio_write_and_X(connection_struct *conn,
                              size_t numtowrite);
 int wait_for_aio_completion(files_struct *fsp);
 void cancel_aio_by_fsp(files_struct *fsp);
-void smbd_aio_complete_mid(uint64_t mid);
+void smbd_aio_complete_aio_ex(struct aio_extra *aio_ex);
 
 /* The following definitions come from smbd/blocking.c  */
 
index d20a04ea97473bd0e59d56686a31bc6b66a1bb92..877588a5595a8c61802266e8f0c4594c9a72b597 100644 (file)
@@ -1963,4 +1963,7 @@ struct deferred_open_record;
 #define CSC_POLICY_PROGRAMS 2
 #define CSC_POLICY_DISABLE 3
 
+/* Used inside aio code. */
+struct aio_extra;
+
 #endif /* _SMB_H */
index 8fd89362bc48c9396bcd77946cd9e98e595d409c..38a1c21e298a6f589f6046167d4b1fd21c1164fa 100644 (file)
@@ -382,8 +382,8 @@ static void handle_aio_completion(struct event_context *event_ctx,
                                  struct fd_event *event, uint16 flags,
                                  void *p)
 {
+       struct aio_extra *aio_ex = NULL;
        struct aio_child *child = (struct aio_child *)p;
-       uint64_t mid;
 
        DEBUG(10, ("handle_aio_completion called with flags=%d\n", flags));
 
@@ -411,12 +411,7 @@ static void handle_aio_completion(struct event_context *event_ctx,
                       child->retval.size);
        }
 
-       /* FIXME - this won't work for SMB2. */
-       mid = (uint64_t)child->aiocb->aio_sigevent.sigev_value.sival_int;
-
-       DEBUG(10, ("mid %d finished\n", (int)mid));
-
-       smbd_aio_complete_mid(mid);
+       smbd_aio_complete_aio_ex(aio_ex);
 }
 
 static int aio_child_destructor(struct aio_child *child)
index 8cc26f1fef1e6ef081511e4f395f176452a4db98..c7a70b3e5432c9727733bc1cf8f1aa22b22c6fd6 100644 (file)
@@ -62,7 +62,7 @@ static void smbd_aio_signal_handler(struct tevent_context *ev_ctx,
        struct aio_extra *aio_ex = (struct aio_extra *)
                                info->si_value.sival_ptr;
 
-       smbd_aio_complete_mid(aio_ex->req->mid);
+       smbd_aio_complete_aio_ex(aio_ex);
 }
 
 
@@ -122,26 +122,6 @@ static struct aio_extra *create_aio_extra(files_struct *fsp, size_t buflen)
        return aio_ex;
 }
 
-/****************************************************************************
- Given the mid find the extended aio struct containing it.
-*****************************************************************************/
-
-static struct aio_extra *find_aio_ex(uint64_t mid)
-{
-       struct aio_extra *p;
-
-       for( p = aio_list_head; p; p = p->next) {
-               if (mid == p->req->mid) {
-                       return p;
-               }
-       }
-       return NULL;
-}
-
-/****************************************************************************
- We can have these many aio buffers in flight.
-*****************************************************************************/
-
 /****************************************************************************
  Set up an aio request from a SMBreadX call.
 *****************************************************************************/
@@ -577,23 +557,15 @@ static bool handle_aio_completed(struct aio_extra *aio_ex, int *perr)
  Handle any aio completion inline.
 *****************************************************************************/
 
-void smbd_aio_complete_mid(uint64_t mid)
+void smbd_aio_complete_aio_ex(struct aio_extra *aio_ex)
 {
        files_struct *fsp = NULL;
-       struct aio_extra *aio_ex = find_aio_ex(mid);
        int ret = 0;
 
        outstanding_aio_calls--;
 
        DEBUG(10,("smbd_aio_complete_mid: mid[%llu]\n",
-               (unsigned long long)mid));
-
-       if (!aio_ex) {
-               DEBUG(3,("smbd_aio_complete_mid: Can't find record to "
-                       "match mid %llu.\n",
-                       (unsigned long long)mid));
-               return;
-       }
+               (unsigned long long)aio_ex->req->mid));
 
        fsp = aio_ex->fsp;
        if (fsp == NULL) {
@@ -601,7 +573,7 @@ void smbd_aio_complete_mid(uint64_t mid)
                 * ignore. */
                DEBUG( 3,( "smbd_aio_complete_mid: file closed whilst "
                        "aio outstanding (mid[%llu]).\n",
-                       (unsigned long long)mid));
+                       (unsigned long long)aio_ex->req->mid));
                return;
        }