long timeout);
void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor,
int ioret);
+struct cl_dio_aio *cl_aio_alloc(struct kiocb *iocb);
static inline void cl_sync_io_init(struct cl_sync_io *anchor, int nr)
{
cl_sync_io_init_notify(anchor, nr, NULL, NULL);
}
#endif
-#ifndef HAVE_AIO_COMPLETE
-static inline void aio_complete(struct kiocb *iocb, ssize_t res, ssize_t res2)
-{
- if (iocb->ki_complete)
- iocb->ki_complete(iocb, res, res2);
-}
-#endif
-
/** direct IO pages */
struct ll_dio_pages {
struct cl_dio_aio *ldp_aio;
loff_t ldp_file_offset;
};
-static void ll_aio_end(const struct lu_env *env, struct cl_sync_io *anchor)
-{
- struct cl_dio_aio *aio = container_of(anchor, typeof(*aio), cda_sync);
- ssize_t ret = anchor->csi_sync_rc;
-
- ENTRY;
-
- /* release pages */
- while (aio->cda_pages.pl_nr > 0) {
- struct cl_page *page = cl_page_list_first(&aio->cda_pages);
-
- cl_page_get(page);
- cl_page_list_del(env, &aio->cda_pages, page);
- cl_page_delete(env, page);
- cl_page_put(env, page);
- }
-
- if (!is_sync_kiocb(aio->cda_iocb))
- aio_complete(aio->cda_iocb, ret ?: aio->cda_bytes, 0);
-
- EXIT;
-}
-
-static struct cl_dio_aio *ll_aio_alloc(struct kiocb *iocb)
-{
- struct cl_dio_aio *aio;
-
- OBD_ALLOC_PTR(aio);
- if (aio != NULL) {
- /*
- * Hold one ref so that it won't be released until
- * every pages is added.
- */
- cl_sync_io_init_notify(&aio->cda_sync, 1, is_sync_kiocb(iocb) ?
- NULL : aio, ll_aio_end);
- cl_page_list_init(&aio->cda_pages);
- aio->cda_iocb = iocb;
- }
- return aio;
-}
-
static int
ll_direct_rw_pages(const struct lu_env *env, struct cl_io *io, size_t size,
int rw, struct inode *inode, struct ll_dio_pages *pv)
io = lcc->lcc_io;
LASSERT(io != NULL);
- aio = ll_aio_alloc(iocb);
+ aio = cl_aio_alloc(iocb);
if (!aio)
RETURN(-ENOMEM);
struct cl_sync_io clt_anchor;
};
+extern struct kmem_cache *cl_dio_aio_kmem;
+
struct cl_thread_info *cl_env_info(const struct lu_env *env);
void cl_page_disown0(const struct lu_env *env,
struct cl_io *io, struct cl_page *pg);
}
EXPORT_SYMBOL(cl_sync_io_wait);
+#ifndef HAVE_AIO_COMPLETE
+static inline void aio_complete(struct kiocb *iocb, ssize_t res, ssize_t res2)
+{
+ if (iocb->ki_complete)
+ iocb->ki_complete(iocb, res, res2);
+}
+#endif
+
+static void cl_aio_end(const struct lu_env *env, struct cl_sync_io *anchor)
+{
+ struct cl_dio_aio *aio = container_of(anchor, typeof(*aio), cda_sync);
+ ssize_t ret = anchor->csi_sync_rc;
+
+ ENTRY;
+
+ /* release pages */
+ while (aio->cda_pages.pl_nr > 0) {
+ struct cl_page *page = cl_page_list_first(&aio->cda_pages);
+
+ cl_page_get(page);
+ cl_page_list_del(env, &aio->cda_pages, page);
+ cl_page_delete(env, page);
+ cl_page_put(env, page);
+ }
+
+ if (!is_sync_kiocb(aio->cda_iocb))
+ aio_complete(aio->cda_iocb, ret ?: aio->cda_bytes, 0);
+
+ EXIT;
+}
+
+struct cl_dio_aio *cl_aio_alloc(struct kiocb *iocb)
+{
+ struct cl_dio_aio *aio;
+
+ OBD_SLAB_ALLOC_PTR_GFP(aio, cl_dio_aio_kmem, GFP_NOFS);
+ if (aio != NULL) {
+ /*
+ * Hold one ref so that it won't be released until
+ * every pages is added.
+ */
+ cl_sync_io_init_notify(&aio->cda_sync, 1, is_sync_kiocb(iocb) ?
+ NULL : aio, cl_aio_end);
+ cl_page_list_init(&aio->cda_pages);
+ aio->cda_iocb = iocb;
+ }
+ return aio;
+}
+EXPORT_SYMBOL(cl_aio_alloc);
+
+
/**
* Indicate that transfer of a single page completed.
*/
* memory here rather than when cl_sync_io_wait() completes.
*/
if (aio)
- OBD_FREE_PTR(aio);
+ OBD_SLAB_FREE_PTR(aio, cl_dio_aio_kmem);
}
EXIT;
}
#include "cl_internal.h"
static struct kmem_cache *cl_env_kmem;
+struct kmem_cache *cl_dio_aio_kmem;
/** Lock class of cl_object_header::coh_attr_guard */
static struct lock_class_key cl_attr_guard_class;
};
static struct lu_kmem_descr cl_object_caches[] = {
- {
- .ckd_cache = &cl_env_kmem,
- .ckd_name = "cl_env_kmem",
- .ckd_size = sizeof (struct cl_env)
- },
- {
- .ckd_cache = NULL
- }
+ {
+ .ckd_cache = &cl_env_kmem,
+ .ckd_name = "cl_env_kmem",
+ .ckd_size = sizeof(struct cl_env)
+ },
+ {
+ .ckd_cache = &cl_dio_aio_kmem,
+ .ckd_name = "cl_dio_aio_kmem",
+ .ckd_size = sizeof(struct cl_dio_aio)
+ },
+ {
+ .ckd_cache = NULL
+ }
};
/**