struct echo_page {
struct cl_page_slice ep_cl;
- struct cl_sync_io *ep_sync_io;
cfs_page_t *ep_vmpage;
};
struct cl_2queue eti_queue;
struct cl_io eti_io;
- struct cl_sync_io eti_anchor;
struct cl_lock_descr eti_descr;
struct lu_fid eti_fid;
};
static void echo_page_discard(const struct lu_env *env,
const struct cl_page_slice *slice,
- struct cl_io *_)
+ struct cl_io *unused)
{
cl_page_delete(env, slice->cpl_page);
}
const struct cl_page_slice *slice,
int ioret)
{
- struct echo_page *ecp = cl2echo_page(slice);
- struct cl_sync_io *anchor = ecp->ep_sync_io;
- ENTRY;
-
- LASSERT(anchor != NULL);
- ecp->ep_sync_io = NULL;
- cl_sync_io_note(anchor, ioret);
- EXIT;
+ LASSERT(slice->cpl_page->cp_sync_io != NULL);
}
static void echo_page_fini(const struct lu_env *env,
static int echo_page_prep(const struct lu_env *env,
const struct cl_page_slice *slice,
- struct cl_io *_)
+ struct cl_io *unused)
{
return 0;
}
static int echo_lock_fits_into(const struct lu_env *env,
const struct cl_lock_slice *slice,
const struct cl_lock_descr *need,
- const struct cl_io *_)
+ const struct cl_io *unused)
{
return 1;
}
struct echo_page *ep;
ENTRY;
- OBD_SLAB_ALLOC_PTR(ep, echo_page_kmem);
+ OBD_SLAB_ALLOC_PTR_GFP(ep, echo_page_kmem, CFS_ALLOC_IO);
if (ep != NULL) {
struct echo_object *eco = cl2echo_obj(obj);
ep->ep_vmpage = vmpage;
static int echo_lock_init(const struct lu_env *env,
struct cl_object *obj, struct cl_lock *lock,
- const struct cl_io *_)
+ const struct cl_io *unused)
{
struct echo_lock *el;
ENTRY;
- OBD_SLAB_ALLOC_PTR(el, echo_lock_kmem);
+ OBD_SLAB_ALLOC_PTR_GFP(el, echo_lock_kmem, CFS_ALLOC_IO);
if (el != NULL) {
cl_lock_slice_add(lock, &el->el_cl, obj, &echo_lock_ops);
el->el_object = cl2echo_obj(obj);
/* we're the top dev. */
LASSERT(hdr == NULL);
- OBD_SLAB_ALLOC_PTR(eco, echo_object_kmem);
+ OBD_SLAB_ALLOC_PTR_GFP(eco, echo_object_kmem, CFS_ALLOC_IO);
if (eco != NULL) {
struct cl_object_header *hdr = &eco->eo_hdr;
{
struct echo_thread_info *info;
- OBD_SLAB_ALLOC_PTR(info, echo_thread_kmem);
+ OBD_SLAB_ALLOC_PTR_GFP(info, echo_thread_kmem, CFS_ALLOC_IO);
if (info == NULL)
info = ERR_PTR(-ENOMEM);
return info;
{
struct echo_session_info *session;
- OBD_SLAB_ALLOC_PTR(session, echo_session_kmem);
+ OBD_SLAB_ALLOC_PTR_GFP(session, echo_session_kmem, CFS_ALLOC_IO);
if (session == NULL)
session = ERR_PTR(-ENOMEM);
return session;
tgt = class_name2obd(lustre_cfg_string(cfg, 1));
LASSERT(tgt != NULL);
next = tgt->obd_lu_dev;
- if (!lu_device_is_cl(next))
+ if (next != NULL && !lu_device_is_cl(next))
next = NULL;
/*
}
static int cl_echo_async_brw(const struct lu_env *env, struct cl_io *io,
- enum cl_req_type _, struct cl_2queue *queue)
+ enum cl_req_type unused, struct cl_2queue *queue)
{
struct cl_page *clp;
struct cl_page *temp;
int result = 0;
ENTRY;
- cl_page_list_splice(&queue->c2_qin, &queue->c2_qout);
- cl_page_list_for_each_safe(clp, temp, &queue->c2_qout) {
+ cl_page_list_for_each_safe(clp, temp, &queue->c2_qin) {
int rc;
rc = cl_page_cache_add(env, io, clp, CRT_WRITE);
if (rc == 0)
continue;
- cl_page_list_move(&queue->c2_qin, &queue->c2_qout, clp);
result = result ?: rc;
}
- RETURN(list_empty(&queue->c2_qout.pl_pages) ? result : 0);
+ RETURN(result);
}
static int cl_echo_object_brw(struct echo_object *eco, int rw, obd_off offset,
struct echo_thread_info *info;
struct cl_object *obj = echo_obj2cl(eco);
struct echo_device *ed = eco->eo_dev;
- struct cl_sync_io *anchor;
struct cl_2queue *queue;
struct cl_io *io;
struct cl_page *clp;
- struct echo_page *ep;
int page_size = cl_page_size(obj);
int refcheck;
info = echo_env_info(env);
io = &info->eti_io;
- anchor = &info->eti_anchor;
queue = &info->eti_queue;
- cl_sync_io_init(anchor, npages);
cl_2queue_init(queue);
rc = cl_io_init(env, io, CIT_MISC, obj);
if (rc < 0)
break;
}
- ep = cl2echo_page(cl_page_at(clp, &echo_device_type));
- ep->ep_sync_io = anchor;
cl_2queue_add(queue, clp);
/* drop the reference count for cl_page_find, so that the page
enum cl_req_type typ = rw == READ ? CRT_READ : CRT_WRITE;
async = async && (typ == CRT_WRITE);
- rc = (async ? cl_echo_async_brw : cl_io_submit_rw)(env, io,
- typ, queue);
+ if (async)
+ rc = cl_echo_async_brw(env, io, typ, queue);
+ else
+ rc = cl_io_submit_sync(env, io, typ, queue,
+ CRP_NORMAL, 0);
CDEBUG(D_INFO, "echo_client %s write returns %d\n",
async ? "async" : "sync", rc);
- if (rc == 0) {
- /*
- * If some pages weren't sent for any reason (e.g.,
- * direct-io read found up-to-date pages in the
- * cache), count them as completed to avoid infinite
- * wait.
- */
- cl_page_list_for_each(clp, &queue->c2_qin)
- cl_sync_io_note(anchor, +1);
- /* wait for the IO to be finished. */
- rc = cl_sync_io_wait(env, io, &queue->c2_qout, anchor);
- }
}
cl_2queue_discard(env, io, queue);
{
struct echo_client_obd *ec = &obddev->u.echo_client;
struct obd_device *tgt;
- struct lustre_handle conn = {0, };
struct obd_uuid echo_uuid = { "ECHO_UUID" };
struct obd_connect_data *ocd = NULL;
int rc;
ocd->ocd_version = LUSTRE_VERSION_CODE;
ocd->ocd_group = FILTER_GROUP_ECHO;
- rc = obd_connect(NULL, &conn, tgt, &echo_uuid, ocd, NULL);
+ rc = obd_connect(NULL, &ec->ec_exp, tgt, &echo_uuid, ocd, NULL);
OBD_FREE(ocd, sizeof(*ocd));
lustre_cfg_string(lcfg, 1));
return (rc);
}
- ec->ec_exp = class_conn2export(&conn);
RETURN(rc);
}
}
static int echo_client_connect(const struct lu_env *env,
- struct lustre_handle *conn,
+ struct obd_export **exp,
struct obd_device *src, struct obd_uuid *cluuid,
struct obd_connect_data *data, void *localdata)
{
- struct obd_export *exp;
int rc;
+ struct lustre_handle conn = { 0 };
ENTRY;
- rc = class_connect(conn, src, cluuid);
+ rc = class_connect(&conn, src, cluuid);
if (rc == 0) {
- exp = class_conn2export(conn);
- class_export_put(exp);
+ *exp = class_conn2export(&conn);
}
RETURN (rc);