Whamcloud - gitweb
LU-4198 clio: AIO support for direct IO
[fs/lustre-release.git] / lustre / obdclass / cl_io.c
index 824aa6e..93a2657 100644 (file)
@@ -1124,7 +1124,7 @@ EXPORT_SYMBOL(cl_req_attr_set);
  */
 
 void cl_sync_io_init_notify(struct cl_sync_io *anchor, int nr,
-                           cl_sync_io_end_t *end)
+                           struct cl_dio_aio *aio, cl_sync_io_end_t *end)
 {
        ENTRY;
        memset(anchor, 0, sizeof(*anchor));
@@ -1132,6 +1132,7 @@ void cl_sync_io_init_notify(struct cl_sync_io *anchor, int nr,
        atomic_set(&anchor->csi_sync_nr, nr);
        anchor->csi_sync_rc = 0;
        anchor->csi_end_io = end;
+       anchor->csi_aio = aio;
        EXIT;
 }
 EXPORT_SYMBOL(cl_sync_io_init_notify);
@@ -1188,6 +1189,8 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
        LASSERT(atomic_read(&anchor->csi_sync_nr) > 0);
        if (atomic_dec_and_lock(&anchor->csi_sync_nr,
                                &anchor->csi_waitq.lock)) {
+               struct cl_dio_aio *aio = NULL;
+
                cl_sync_io_end_t *end_io = anchor->csi_end_io;
 
                /*
@@ -1201,9 +1204,17 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
                wake_up_all_locked(&anchor->csi_waitq);
                if (end_io)
                        end_io(env, anchor);
+               if (anchor->csi_aio)
+                       aio = anchor->csi_aio;
+
                spin_unlock(&anchor->csi_waitq.lock);
 
-               /* Can't access anchor any more */
+               /**
+                * If anchor->csi_aio is set, we are responsible for freeing
+                * memory here rather than when cl_sync_io_wait() completes.
+                */
+               if (aio)
+                       OBD_FREE_PTR(aio);
        }
        EXIT;
 }