From 6ee742fd5c56819ebe7eba65f4133d02c318916e Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Thu, 11 Jul 2019 22:09:39 -0500 Subject: [PATCH] LU-12431 clio: remove default csi_end_io handler Since the csi_end_io is empty remove it. Provide an initialize that supports a custom end_io handler. Cray-bug-id: LUS-7330 Signed-off-by: Shaun Tancheff Change-Id: If62c2536772136bfafc6e99ad1dbd9b466735201 Reviewed-on: https://review.whamcloud.com/35400 Tested-by: jenkins Reviewed-by: Neil Brown Reviewed-by: James Simmons Tested-by: Maloo Reviewed-by: Oleg Drokin --- lustre/include/cl_object.h | 27 +++++++++++++++++---------- lustre/llite/rw.c | 2 +- lustre/obdclass/cl_io.c | 35 ++++++++++++++++------------------- lustre/obdclass/cl_lock.c | 2 +- lustre/osc/osc_lock.c | 2 +- 5 files changed, 36 insertions(+), 32 deletions(-) diff --git a/lustre/include/cl_object.h b/lustre/include/cl_object.h index b13d1d0..0524f34 100644 --- a/lustre/include/cl_object.h +++ b/lustre/include/cl_object.h @@ -2471,6 +2471,22 @@ void cl_req_attr_set(const struct lu_env *env, struct cl_object *obj, /** \defgroup cl_sync_io cl_sync_io * @{ */ +struct cl_sync_io; + +typedef void (cl_sync_io_end_t)(const struct lu_env *, struct cl_sync_io *); + +void cl_sync_io_init_notify(struct cl_sync_io *anchor, int nr, + cl_sync_io_end_t *end); + +int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, + long timeout); +void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, + int ioret); +static inline void cl_sync_io_init(struct cl_sync_io *anchor, int nr) +{ + cl_sync_io_init_notify(anchor, nr, NULL); +} + /** * Anchor for synchronous transfer. This is allocated on a stack by thread * doing synchronous transfer, and a pointer to this structure is set up in @@ -2485,18 +2501,9 @@ struct cl_sync_io { /** completion to be signaled when transfer is complete. */ wait_queue_head_t csi_waitq; /** callback to invoke when this IO is finished */ - void (*csi_end_io)(const struct lu_env *, - struct cl_sync_io *); + cl_sync_io_end_t *csi_end_io; }; -void cl_sync_io_init(struct cl_sync_io *anchor, int nr, - void (*end)(const struct lu_env *, struct cl_sync_io *)); -int cl_sync_io_wait(const struct lu_env *env, struct cl_sync_io *anchor, - long timeout); -void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, - int ioret); -void cl_sync_io_end(const struct lu_env *env, struct cl_sync_io *anchor); - /** @} cl_sync_io */ /** \defgroup cl_env cl_env diff --git a/lustre/llite/rw.c b/lustre/llite/rw.c index d8f4075..c4e06bb 100644 --- a/lustre/llite/rw.c +++ b/lustre/llite/rw.c @@ -1263,7 +1263,7 @@ int ll_io_read_page(const struct lu_env *env, struct cl_io *io, cl_page_disown(env, io, page); } else { anchor = &vvp_env_info(env)->vti_anchor; - cl_sync_io_init(anchor, 1, &cl_sync_io_end); + cl_sync_io_init(anchor, 1); page->cp_sync_io = anchor; cl_2queue_add(queue, page); diff --git a/lustre/obdclass/cl_io.c b/lustre/obdclass/cl_io.c index ce59926..207dd95 100644 --- a/lustre/obdclass/cl_io.c +++ b/lustre/obdclass/cl_io.c @@ -654,7 +654,7 @@ int cl_io_submit_sync(const struct lu_env *env, struct cl_io *io, pg->cp_sync_io = anchor; } - cl_sync_io_init(anchor, queue->c2_qin.pl_nr, &cl_sync_io_end); + cl_sync_io_init(anchor, queue->c2_qin.pl_nr); rc = cl_io_submit_rw(env, io, iot, queue); if (rc == 0) { /* @@ -1111,23 +1111,18 @@ void cl_req_attr_set(const struct lu_env *env, struct cl_object *obj, } EXPORT_SYMBOL(cl_req_attr_set); -/* - * cl_sync_io_end callback is issued as cl_sync_io completes and before - * control of anchor reverts to model used by the caller of cl_sync_io_init() - * - * NOTE: called with spinlock on anchor->csi_waitq.lock - */ -void cl_sync_io_end(const struct lu_env *env, struct cl_sync_io *anchor) -{ - /* deprecated pending future removal */ -} -EXPORT_SYMBOL(cl_sync_io_end); - /** - * Initialize synchronous io wait anchor + * Initialize synchronous io wait \a anchor for \a nr pages with optional + * \a end handler. + * \param anchor owned by caller, initialzied here. + * \param nr number of pages initally pending in sync. + * \param end optional callback sync_io completion, can be used to + * trigger erasure coding, integrity, dedupe, or similar operation. + * \q end is called with a spinlock on anchor->csi_waitq.lock */ -void cl_sync_io_init(struct cl_sync_io *anchor, int nr, - void (*end)(const struct lu_env *, struct cl_sync_io *)) + +void cl_sync_io_init_notify(struct cl_sync_io *anchor, int nr, + cl_sync_io_end_t *end) { ENTRY; memset(anchor, 0, sizeof(*anchor)); @@ -1135,10 +1130,9 @@ void cl_sync_io_init(struct cl_sync_io *anchor, int nr, atomic_set(&anchor->csi_sync_nr, nr); anchor->csi_sync_rc = 0; anchor->csi_end_io = end; - LASSERT(end != NULL); EXIT; } -EXPORT_SYMBOL(cl_sync_io_init); +EXPORT_SYMBOL(cl_sync_io_init_notify); /** * Wait until all IO completes. Transfer completion routine has to call @@ -1194,6 +1188,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)) { + cl_sync_io_end_t *end_io = anchor->csi_end_io; + /* * Holding the lock across both the decrement and * the wakeup ensures cl_sync_io_wait() doesn't complete @@ -1203,7 +1199,8 @@ void cl_sync_io_note(const struct lu_env *env, struct cl_sync_io *anchor, * completes. */ wake_up_all_locked(&anchor->csi_waitq); - anchor->csi_end_io(env, anchor); + if (end_io) + end_io(env, anchor); spin_unlock(&anchor->csi_waitq.lock); /* Can't access anchor any more */ diff --git a/lustre/obdclass/cl_lock.c b/lustre/obdclass/cl_lock.c index 30c7186..ba8126f 100644 --- a/lustre/obdclass/cl_lock.c +++ b/lustre/obdclass/cl_lock.c @@ -205,7 +205,7 @@ int cl_lock_request(const struct lu_env *env, struct cl_io *io, if ((enq_flags & CEF_GLIMPSE) && !(enq_flags & CEF_SPECULATIVE)) { anchor = &cl_env_info(env)->clt_anchor; - cl_sync_io_init(anchor, 1, cl_sync_io_end); + cl_sync_io_init(anchor, 1); } rc = cl_lock_enqueue(env, io, lock, anchor); diff --git a/lustre/osc/osc_lock.c b/lustre/osc/osc_lock.c index abef4f6..a5b6aa3 100644 --- a/lustre/osc/osc_lock.c +++ b/lustre/osc/osc_lock.c @@ -872,7 +872,7 @@ restart: continue; /* wait for conflicting lock to be canceled */ - cl_sync_io_init(waiter, 1, cl_sync_io_end); + cl_sync_io_init(waiter, 1); oscl->ols_owner = waiter; spin_lock(&tmp_oscl->ols_lock); -- 1.8.3.1