/** \defgroup cl_page cl_page
* @{ */
-enum {
- CLP_GANG_OKAY = 0,
- CLP_GANG_RESCHED,
- CLP_GANG_AGAIN,
- CLP_GANG_ABORT
-};
-/* callback of cl_page_gang_lookup() */
-
struct cl_page *cl_page_find (const struct lu_env *env,
struct cl_object *obj,
pgoff_t idx, struct page *vmpage,
(void)osc_io_unplug0(env, cli, osc, 0);
}
-typedef int (*osc_page_gang_cbt)(const struct lu_env *, struct cl_io *,
- struct osc_page *, void *);
-int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
- struct osc_object *osc, pgoff_t start, pgoff_t end,
- osc_page_gang_cbt cb, void *cbdata);
-int osc_discard_cb(const struct lu_env *env, struct cl_io *io,
- struct osc_page *ops, void *cbdata);
+typedef bool (*osc_page_gang_cbt)(const struct lu_env *, struct cl_io *,
+ struct osc_page *, void *);
+bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
+ struct osc_object *osc, pgoff_t start, pgoff_t end,
+ osc_page_gang_cbt cb, void *cbdata);
+bool osc_discard_cb(const struct lu_env *env, struct cl_io *io,
+ struct osc_page *ops, void *cbdata);
/* osc_dev.c */
int osc_device_init(const struct lu_env *env, struct lu_device *d,
/**
* Check if page @page is covered by an extra lock or discard it.
*/
-static int mdc_check_and_discard_cb(const struct lu_env *env, struct cl_io *io,
- struct osc_page *ops, void *cbdata)
+static bool mdc_check_and_discard_cb(const struct lu_env *env, struct cl_io *io,
+ struct osc_page *ops, void *cbdata)
{
struct osc_thread_info *info = osc_env_info(env);
struct osc_object *osc = cbdata;
}
info->oti_next_index = index + 1;
- return CLP_GANG_OKAY;
+ return true;
}
/**
struct osc_thread_info *info = osc_env_info(env);
struct cl_io *io = &info->oti_io;
osc_page_gang_cbt cb;
- int res;
int result;
ENTRY;
cb = discard ? osc_discard_cb : mdc_check_and_discard_cb;
info->oti_fn_index = info->oti_next_index = start;
- do {
- res = osc_page_gang_lookup(env, io, osc, info->oti_next_index,
- end, cb, (void *)osc);
- if (info->oti_next_index > end)
- break;
- if (res == CLP_GANG_RESCHED)
- cond_resched();
- } while (res != CLP_GANG_OKAY);
+ osc_page_gang_lookup(env, io, osc, info->oti_next_index,
+ end, cb, (void *)osc);
out:
cl_io_fini(env, io);
RETURN(result);
/**
* Returns a list of pages by a given [start, end] of \a obj.
*
- * \param resched If not NULL, then we give up before hogging CPU for too
- * long and set *resched = 1, in that case caller should implement a retry
- * logic.
- *
* Gang tree lookup (radix_tree_gang_lookup()) optimization is absolutely
* crucial in the face of [offset, EOF] locks.
*
* Return at least one page in @queue unless there is no covered page.
*/
-int osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
- struct osc_object *osc, pgoff_t start, pgoff_t end,
- osc_page_gang_cbt cb, void *cbdata)
+bool osc_page_gang_lookup(const struct lu_env *env, struct cl_io *io,
+ struct osc_object *osc, pgoff_t start, pgoff_t end,
+ osc_page_gang_cbt cb, void *cbdata)
{
struct osc_page *ops;
struct pagevec *pagevec;
unsigned int nr;
unsigned int i;
unsigned int j;
- int res = CLP_GANG_OKAY;
+ bool res = true;
bool tree_lock = true;
ENTRY;
for (i = 0; i < j; ++i) {
ops = pvec[i];
- if (res == CLP_GANG_OKAY)
+ if (res)
res = (*cb)(env, io, ops, cbdata);
page = ops->ops_cl.cpl_page;
if (nr < OTI_PVEC_SIZE || end_of_region)
break;
- if (res == CLP_GANG_OKAY && need_resched())
- res = CLP_GANG_RESCHED;
- if (res != CLP_GANG_OKAY)
+ if (!res)
break;
+ if (need_resched())
+ cond_resched();
spin_lock(&osc->oo_tree_lock);
tree_lock = true;
/**
* Check if page @page is covered by an extra lock or discard it.
*/
-static int check_and_discard_cb(const struct lu_env *env, struct cl_io *io,
+static bool check_and_discard_cb(const struct lu_env *env, struct cl_io *io,
struct osc_page *ops, void *cbdata)
{
struct osc_thread_info *info = osc_env_info(env);
}
info->oti_next_index = index + 1;
- return CLP_GANG_OKAY;
+ return true;
}
-int osc_discard_cb(const struct lu_env *env, struct cl_io *io,
+bool osc_discard_cb(const struct lu_env *env, struct cl_io *io,
struct osc_page *ops, void *cbdata)
{
struct osc_thread_info *info = osc_env_info(env);
LASSERT(page->cp_state == CPS_FREEING);
}
- return CLP_GANG_OKAY;
+ return true;
}
EXPORT_SYMBOL(osc_discard_cb);
struct osc_thread_info *info = osc_env_info(env);
struct cl_io *io = osc_env_thread_io(env);
osc_page_gang_cbt cb;
- int res;
int result;
ENTRY;
cb = discard ? osc_discard_cb : check_and_discard_cb;
info->oti_fn_index = info->oti_next_index = start;
- do {
- res = osc_page_gang_lookup(env, io, osc,
- info->oti_next_index, end, cb, osc);
- if (info->oti_next_index > end)
- break;
- if (res == CLP_GANG_RESCHED)
- cond_resched();
- } while (res != CLP_GANG_OKAY);
+ osc_page_gang_lookup(env, io, osc,
+ info->oti_next_index, end, cb, osc);
out:
cl_io_fini(env, io);
RETURN(result);
/**
* Checks that there are no pages being written in the extent being truncated.
*/
-static int trunc_check_cb(const struct lu_env *env, struct cl_io *io,
+static bool trunc_check_cb(const struct lu_env *env, struct cl_io *io,
struct osc_page *ops , void *cbdata)
{
struct cl_page *page = ops->ops_cl.cpl_page;
CDEBUG(D_CACHE, "page %p index %lu locked for %d.\n",
ops, osc_index(ops), oap->oap_cmd & OBD_BRW_RWMASK);
- return CLP_GANG_OKAY;
+ return true;
}
static void osc_trunc_check(const struct lu_env *env, struct cl_io *io,
}
EXPORT_SYMBOL(osc_ldlm_glimpse_ast);
-static int weigh_cb(const struct lu_env *env, struct cl_io *io,
- struct osc_page *ops, void *cbdata)
+static bool weigh_cb(const struct lu_env *env, struct cl_io *io,
+ struct osc_page *ops, void *cbdata)
{
struct cl_page *page = ops->ops_cl.cpl_page;
if (cl_page_is_vmlocked(env, page) || PageDirty(page->cp_vmpage) ||
PageWriteback(page->cp_vmpage))
- return CLP_GANG_ABORT;
+ return false;
*(pgoff_t *)cbdata = osc_index(ops) + 1;
- return CLP_GANG_OKAY;
+ return true;
}
static unsigned long osc_lock_weight(const struct lu_env *env,
RETURN(result);
page_index = cl_index(obj, start);
- do {
- result = osc_page_gang_lookup(env, io, oscobj,
- page_index, cl_index(obj, end),
- weigh_cb, (void *)&page_index);
- if (result == CLP_GANG_ABORT)
- break;
- if (result == CLP_GANG_RESCHED)
- cond_resched();
- } while (result != CLP_GANG_OKAY);
+
+ if (!osc_page_gang_lookup(env, io, oscobj,
+ page_index, cl_index(obj, end),
+ weigh_cb, (void *)&page_index))
+ result = 1;
cl_io_fini(env, io);
- return result == CLP_GANG_ABORT ? 1 : 0;
+ return result;
}
/**