lustre: obd: preprocessor cleanups
cover lustre: obd: preprocessor cleanups
The obd.h, obd_class.h, and clio headers are littered with complex macros that are difficult to read. These macros existed to handle the obd stats and md stats which are lacking in the linux client. Newer versions do support md_stats so lets restore them as well as cleanup the ugly macros. This patch set is order dependent and is based on the first batch patch set for lustre 2.10 applied against the lustre-testing branch.
Ben Evans (4):
lustre: obdclass: remove CL_PAGE_INVOKE et. al.
lustre: obdclass: remove cl_for_each defines
lustre: obdclass: Code cleanup
lustre: obdclass: cleanup obd_class.h defines
James Simmons (1):
lustre: obdclass: restore md_stats code
John L. Hammond (3):
lustre: obd: remove obd_{get,put}ref()
lustre: obd: remove OBD ops based stats
lustre: obd: add md_stats to MDC and LMV devices
.../staging/lustre/lustre/include/lprocfs_status.h | 5 +- drivers/staging/lustre/lustre/include/obd.h | 20 +- drivers/staging/lustre/lustre/include/obd_class.h | 788 ++++++++++++--------- drivers/staging/lustre/lustre/llite/file.c | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 3 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 9 +- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 6 + drivers/staging/lustre/lustre/lov/lov_dev.c | 12 +- drivers/staging/lustre/lustre/lov/lov_internal.h | 2 + drivers/staging/lustre/lustre/lov/lov_obd.c | 44 +- drivers/staging/lustre/lustre/lov/lov_pool.c | 10 +- drivers/staging/lustre/lustre/lov/lov_request.c | 4 +- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 7 + drivers/staging/lustre/lustre/mdc/mdc_request.c | 8 +- drivers/staging/lustre/lustre/obdclass/Makefile | 5 +- drivers/staging/lustre/lustre/obdclass/cl_io.c | 26 +- drivers/staging/lustre/lustre/obdclass/cl_object.c | 21 +- drivers/staging/lustre/lustre/obdclass/cl_page.c | 275 +++---- drivers/staging/lustre/lustre/obdclass/class_obd.c | 1 - drivers/staging/lustre/lustre/obdclass/genops.c | 3 - .../staging/lustre/lustre/obdclass/kernelcomm.c | 7 +- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 4 +- .../lustre/lustre/obdclass/lprocfs_status.c | 66 +- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 2 +- drivers/staging/lustre/lustre/obdclass/uuid.c | 45 -- 25 files changed, 753 insertions(+), 622 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/obdclass/uuid.c
Signature · 1 line
1.8.3.1
PATCH 1/8 lustre: obdclass: remove CL_PAGE_INVOKE et. al.
From: Ben Evans <[email protected]>
CL_PAGE_INVOKE, CL_PAGE_INVOID and CL_PAGE_INVOKE_REVERSE merely obscure the list_for_each_entry calls to various virtual functions specified by CL_PAGE_OP, and arguments stuck into va_args.
These defines and their equivalent functions have been removed, and the list_for_each_entry has been put in place. CL_PAGE_OP has also been removed.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9523
Reviewed-on: https://review.whamcloud.com/27168
--- drivers/staging/lustre/lustre/obdclass/cl_page.c | 275 ++++++++++++----------- 1 file changed, 140 insertions(+), 135 deletions(-)
drivers/staging/lustre/lustre/obdclass/cl_page.c +140 -135
@@ -363,82 +363,6 @@ const struct cl_page_slice *cl_page_at(const struct cl_page *page, }EXPORT_SYMBOL (cl_page_at); -#define CL_PAGE_OP (opname) offsetof(struct cl_page_operations, opname) - -#define CL_PAGE_INVOKE (_env, _page, _op, _proto, ...) \ -({ \ - const struct lu_env *__env = (_env); \ - struct cl_page *__page = (_page); \ - const struct cl_page_slice *__scan; \ - int __result; \ - ptrdiff_t __op = (_op); \ - int (*__method)_proto; \ - \ - __result = 0; \ - list_for_each_entry(__scan, &__page->cp_layers, cpl_linkage) { \ - __method = *(void **)((char *)__scan->cpl_ops + __op); \ - if (__method) { \ - __result = (*__method)(__env, __scan, ## __VA_ARGS__); \ - if (__result != 0) \ - break; \ - } \ - } \ - if (__result > 0) \ - __result = 0; \ - __result; \ -}) - -#define CL_PAGE_INVOID (_env, _page, _op, _proto, ...) \ -do { \ - const struct lu_env *__env = (_env); \ - struct cl_page *__page = (_page); \ - const struct cl_page_slice *__scan; \ - ptrdiff_t __op = (_op); \ - void (*__method)_proto; \ - \ - list_for_each_entry(__scan, &__page->cp_layers, cpl_linkage) { \ - __method = *(void **)((char *)__scan->cpl_ops + __op); \ - if (__method) \ - (*__method)(__env, __scan, ## __VA_ARGS__); \ - } \ -} while (0) - -#define CL_PAGE_INVOID_REVERSE (_env, _page, _op, _proto, ...) \ -do { \ - const struct lu_env *__env = (_env); \ - struct cl_page *__page = (_page); \ - const struct cl_page_slice *__scan; \ - ptrdiff_t __op = (_op); \ - void (*__method)_proto; \ - \ - list_for_each_entry_reverse(__scan, &__page->cp_layers, cpl_linkage) { \ - __method = *(void **)((char *)__scan->cpl_ops + __op); \ - if (__method) \ - (*__method)(__env, __scan, ## __VA_ARGS__); \ - } \ -} while (0) - -static int cl_page_invoke (const struct lu_env *env, -struct cl_io *io,struct cl_page *page,ptrdiff_t op) - -{ -PINVRNT (env, page,cl_object_same (page->cp_obj, io->ci_obj)); -return CL_PAGE_INVOKE (env, page, op, - (const struct lu_env *, - const struct cl_page_slice *, struct cl_io *), - io); -} - -static void cl_page_invoid (const struct lu_env *env, -struct cl_io *io,struct cl_page *page,ptrdiff_t op) - -{ -PINVRNT (env, page,cl_object_same (page->cp_obj, io->ci_obj)); -CL_PAGE_INVOID (env, page, op, - (const struct lu_env *, - const struct cl_page_slice *, struct cl_io *), io); -} -static void cl_page_owner_clear (struct cl_page *page) {if (page->cp_owner) {
@@ -456,6 +380,7 @@ static void cl_page_owner_set(struct cl_page *page)void cl_page_disown0 (const struct lu_env *env,struct cl_io *io,struct cl_page *pg) { +const struct cl_page_slice *slice;enum cl_page_state state; state = pg->cp_state;
@@ -470,10 +395,10 @@ void cl_page_disown0(const struct lu_env *env,* uppermost layer (llite), responsible for VFS/VM interaction runs * last and can release locks safely. */ -CL_PAGE_INVOID_REVERSE (env, pg,CL_PAGE_OP (cpo_disown), - (const struct lu_env *, - const struct cl_page_slice *, struct cl_io *), - io); +list_for_each_entry_reverse (slice, &pg->cp_layers, cpl_linkage) { +if (slice->cpl_ops->cpo_disown) + (*slice->cpl_ops->cpo_disown)(env, slice, io); + } }/**
@@ -511,7 +436,8 @@ int cl_page_is_owned(const struct cl_page *pg, const struct cl_io *io)static int cl_page_own0 (const struct lu_env *env,struct cl_io *io,struct cl_page *pg,int nonblock) { -int result; +const struct cl_page_slice *slice; +int result =0 ;PINVRNT (env, pg, !cl_page_is_owned (pg, io));
@@ -519,24 +445,31 @@ static int cl_page_own0(const struct lu_env *env, struct cl_io *io,if (pg->cp_state ==CPS_FREEING ) { result = -ENOENT ; - }else { - result =CL_PAGE_INVOKE (env, pg,CL_PAGE_OP (cpo_own), - (const struct lu_env *, - const struct cl_page_slice *, - struct cl_io *, int), - io, nonblock); -if (result ==0 ) { -PASSERT (env, pg, !pg->cp_owner); - pg->cp_owner =cl_io_top (io); -cl_page_owner_set (pg); -if (pg->cp_state !=CPS_FREEING ) { -cl_page_state_set (env, pg,CPS_OWNED ); - }else { -cl_page_disown0 (env, io, pg); - result = -ENOENT ; - } + goto out; + } + +list_for_each_entry (slice, &pg->cp_layers, cpl_linkage) { +if (slice->cpl_ops->cpo_own) + result = (*slice->cpl_ops->cpo_own)(env, slice, + io, nonblock); +if (result !=0 ) +break ; + } +if (result >0 ) + result =0 ; + +if (result ==0 ) { +PASSERT (env, pg, !pg->cp_owner); + pg->cp_owner =cl_io_top (io); +cl_page_owner_set (pg); +if (pg->cp_state !=CPS_FREEING ) { +cl_page_state_set (env, pg,CPS_OWNED ); + }else { +cl_page_disown0 (env, io, pg); + result = -ENOENT ; } } +out:PINVRNT (env, pg,ergo (result ==0 ,cl_page_invariant (pg)));return result; }
@@ -577,11 +510,17 @@ int cl_page_own_try(const struct lu_env *env, struct cl_io *io,void cl_page_assume (const struct lu_env *env,struct cl_io *io,struct cl_page *pg) { +const struct cl_page_slice *slice; +PINVRNT (env, pg,cl_object_same (pg->cp_obj, io->ci_obj)); io =cl_io_top (io); -cl_page_invoid (env, io, pg,CL_PAGE_OP (cpo_assume)); +list_for_each_entry (slice, &pg->cp_layers, cpl_linkage) { +if (slice->cpl_ops->cpo_assume) + (*slice->cpl_ops->cpo_assume)(env, slice, io); + } +PASSERT (env, pg, !pg->cp_owner); pg->cp_owner =cl_io_top (io);cl_page_owner_set (pg);
@@ -603,16 +542,19 @@ void cl_page_assume(const struct lu_env *env,void cl_page_unassume (const struct lu_env *env,struct cl_io *io,struct cl_page *pg) { +const struct cl_page_slice *slice; +PINVRNT (env, pg,cl_page_is_owned (pg, io));PINVRNT (env, pg,cl_page_invariant (pg)); io =cl_io_top (io);cl_page_owner_clear (pg);cl_page_state_set (env, pg,CPS_CACHED ); -CL_PAGE_INVOID_REVERSE (env, pg,CL_PAGE_OP (cpo_unassume), - (const struct lu_env *, - const struct cl_page_slice *, struct cl_io *), - io); + +list_for_each_entry_reverse (slice, &pg->cp_layers, cpl_linkage) { +if (slice->cpl_ops->cpo_unassume) + (*slice->cpl_ops->cpo_unassume)(env, slice, io); + } }EXPORT_SYMBOL (cl_page_unassume);
@@ -651,10 +593,15 @@ void cl_page_disown(const struct lu_env *env,void cl_page_discard (const struct lu_env *env,struct cl_io *io,struct cl_page *pg) { +const struct cl_page_slice *slice; +PINVRNT (env, pg,cl_page_is_owned (pg, io));PINVRNT (env, pg,cl_page_invariant (pg)); -cl_page_invoid (env, io, pg,CL_PAGE_OP (cpo_discard)); +list_for_each_entry (slice, &pg->cp_layers, cpl_linkage) { +if (slice->cpl_ops->cpo_discard) + (*slice->cpl_ops->cpo_discard)(env, slice, io); + } }EXPORT_SYMBOL (cl_page_discard);
@@ -665,18 +612,20 @@ void cl_page_discard(const struct lu_env *env,*/ static void cl_page_delete0 (const struct lu_env *env,struct cl_page *pg) { +const struct cl_page_slice *slice; +PASSERT (env, pg, pg->cp_state !=CPS_FREEING );/* * Sever all ways to obtain new pointers to @pg. */ cl_page_owner_clear (pg); -cl_page_state_set0 (env, pg,CPS_FREEING ); -CL_PAGE_INVOID_REVERSE (env, pg,CL_PAGE_OP (cpo_delete), - (const struct lu_env *, - const struct cl_page_slice *)); +list_for_each_entry_reverse (slice, &pg->cp_layers, cpl_linkage) { +if (slice->cpl_ops->cpo_delete) + (*slice->cpl_ops->cpo_delete)(env, slice); + } }/**
@@ -721,10 +670,14 @@ void cl_page_delete(const struct lu_env *env, struct cl_page *pg)*/ void cl_page_export (const struct lu_env *env,struct cl_page *pg,int uptodate) { +const struct cl_page_slice *slice; +PINVRNT (env, pg,cl_page_invariant (pg)); -CL_PAGE_INVOID (env, pg,CL_PAGE_OP (cpo_export), - (const struct lu_env *, - const struct cl_page_slice *, int), uptodate); + +list_for_each_entry (slice, &pg->cp_layers, cpl_linkage) { +if (slice->cpl_ops->cpo_export) + (*slice->cpl_ops->cpo_export)(env, slice, uptodate); + } }EXPORT_SYMBOL (cl_page_export);
@@ -734,8 +687,8 @@ void cl_page_export(const struct lu_env *env, struct cl_page *pg, int uptodate)*/ int cl_page_is_vmlocked (const struct lu_env *env,const struct cl_page *pg) { -int result;const struct cl_page_slice *slice; +int result; slice =container_of (pg->cp_layers.next, const struct cl_page_slice, cpl_linkage);
@@ -776,7 +729,8 @@ static void cl_page_io_start(const struct lu_env *env,int cl_page_prep (const struct lu_env *env,struct cl_io *io,struct cl_page *pg,enum cl_req_type crt) { -int result; +const struct cl_page_slice *slice; +int result =0 ;PINVRNT (env, pg,cl_page_is_owned (pg, io));PINVRNT (env, pg,cl_page_invariant (pg));
@@ -789,9 +743,19 @@ int cl_page_prep(const struct lu_env *env, struct cl_io *io,*/ if (crt >=CRT_NR )return -EINVAL ; - result =cl_page_invoke (env, io, pg,CL_PAGE_OP (io[crt].cpo_prep)); -if (result ==0 ) + +list_for_each_entry (slice, &pg->cp_layers, cpl_linkage) { +if (slice->cpl_ops->cpo_own) + result = (*slice->cpl_ops->io[crt].cpo_prep)(env, slice, + io); +if (result !=0 ) +break ; + } + +if (result >=0 ) { + result =0 ;cl_page_io_start (env, pg, crt); + }CL_PAGE_HEADER (D_TRACE , env, pg,"%d %d\n" , crt, result);return result;
@@ -817,6 +781,7 @@ void cl_page_completion(const struct lu_env *env, struct cl_page *pg, enum cl_req_type crt, int ioret) { struct cl_sync_io *anchor = pg->cp_sync_io; +const struct cl_page_slice *slice;PASSERT (env, pg, crt <CRT_NR );PASSERT (env, pg, pg->cp_state ==cl_req_type_state (crt));
@@ -826,9 +791,13 @@ void cl_page_completion(const struct lu_env *env,cl_page_state_set (env, pg,CPS_CACHED );if (crt >=CRT_NR )return ; -CL_PAGE_INVOID_REVERSE (env, pg,CL_PAGE_OP (io[crt].cpo_completion), - (const struct lu_env *, - const struct cl_page_slice *, int), ioret); + +list_for_each_entry_reverse (slice, &pg->cp_layers, cpl_linkage) { +if (slice->cpl_ops->io[crt].cpo_completion) + (*slice->cpl_ops->io[crt].cpo_completion)(env, slice, + ioret); + } +if (anchor) {LASSERT (pg->cp_sync_io == anchor); pg->cp_sync_io =NULL ;
@@ -849,18 +818,26 @@ void cl_page_completion(const struct lu_env *env,int cl_page_make_ready (const struct lu_env *env,struct cl_page *pg,enum cl_req_type crt) { -int result; +const struct cl_page_slice *sli; +int result =0 ;PINVRNT (env, pg, crt <CRT_NR );if (crt >=CRT_NR )return -EINVAL ; - result =CL_PAGE_INVOKE (env, pg,CL_PAGE_OP (io[crt].cpo_make_ready), - (const struct lu_env *, - const struct cl_page_slice *)); -if (result ==0 ) { + +list_for_each_entry (sli, &pg->cp_layers, cpl_linkage) { +if (sli->cpl_ops->io[crt].cpo_make_ready) + result = (*sli->cpl_ops->io[crt].cpo_make_ready)(env, + sli); +if (result !=0 ) +break ; + } + +if (result >=0 ) {PASSERT (env, pg, pg->cp_state ==CPS_CACHED );cl_page_io_start (env, pg, crt); + result =0 ; }CL_PAGE_HEADER (D_TRACE , env, pg,"%d %d\n" , crt, result);return result;
@@ -878,12 +855,20 @@ int cl_page_make_ready(const struct lu_env *env, struct cl_page *pg,int cl_page_flush (const struct lu_env *env,struct cl_io *io,struct cl_page *pg) { -int result; +const struct cl_page_slice *slice; +int result =0 ;PINVRNT (env, pg,cl_page_is_owned (pg, io));PINVRNT (env, pg,cl_page_invariant (pg)); - result =cl_page_invoke (env, io, pg,CL_PAGE_OP (cpo_flush)); +list_for_each_entry (slice, &pg->cp_layers, cpl_linkage) { +if (slice->cpl_ops->cpo_flush) + result = (*slice->cpl_ops->cpo_flush)(env, slice, io); +if (result !=0 ) +break ; + } +if (result >0 ) + result =0 ;CL_PAGE_HEADER (D_TRACE , env, pg,"%d\n" , result);return result;
@@ -898,13 +883,16 @@ int cl_page_flush(const struct lu_env *env, struct cl_io *io,void cl_page_clip (const struct lu_env *env,struct cl_page *pg,int from,int to) { +const struct cl_page_slice *slice; +PINVRNT (env, pg,cl_page_invariant (pg));CL_PAGE_HEADER (D_TRACE , env, pg,"%d %d\n" , from, to); -CL_PAGE_INVOID (env, pg,CL_PAGE_OP (cpo_clip), - (const struct lu_env *, - const struct cl_page_slice *, int, int), - from, to); + +list_for_each_entry (slice, &pg->cp_layers, cpl_linkage) { +if (slice->cpl_ops->cpo_clip) + (*slice->cpl_ops->cpo_clip)(env, slice, from, to); + } }EXPORT_SYMBOL (cl_page_clip);
@@ -928,11 +916,18 @@ void cl_page_header_print(const struct lu_env *env, void *cookie,void cl_page_print (const struct lu_env *env,void *cookie,lu_printer_t printer,const struct cl_page *pg) { +const struct cl_page_slice *slice; +int result =0 ; +cl_page_header_print (env, cookie, printer, pg); -CL_PAGE_INVOKE (env, (struct cl_page *)pg,CL_PAGE_OP (cpo_print), - (const struct lu_env *env, - const struct cl_page_slice *slice, - void *cookie, lu_printer_t p), cookie, printer); + +list_for_each_entry (slice, &pg->cp_layers, cpl_linkage) { +if (slice->cpl_ops->cpo_print) + result = (*slice->cpl_ops->cpo_print)(env, slice, + cookie, printer); +if (result !=0 ) +break ; + } (*printer)(env, cookie,"end page@%p\n" , pg); }EXPORT_SYMBOL (cl_page_print);
@@ -942,9 +937,19 @@ void cl_page_print(const struct lu_env *env, void *cookie,*/ int cl_page_cancel (const struct lu_env *env,struct cl_page *page) { -return CL_PAGE_INVOKE (env, page,CL_PAGE_OP (cpo_cancel), - (const struct lu_env *, - const struct cl_page_slice *)); +const struct cl_page_slice *slice; +int result =0 ; + +list_for_each_entry (slice, &page->cp_layers, cpl_linkage) { +if (slice->cpl_ops->cpo_cancel) + result = (*slice->cpl_ops->cpo_cancel)(env, slice); +if (result !=0 ) +break ; + } +if (result >0 ) + result =0 ; + +return result; }/**
Signature · 1 line
1.8.3.1
PATCH 2/8 lustre: obdclass: remove cl_for_each defines
In reply to James SimmonsFrom: Ben Evans <[email protected]>
cl_for_each and cl_for_each_reverse are simply aliases for list_for_each_entry and list_for_each_entry_reverse There is no point to them so just get rid of them and eliminate any confusion.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9575
Reviewed-on: https://review.whamcloud.com/27385
--- drivers/staging/lustre/lustre/obdclass/cl_io.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-)
drivers/staging/lustre/lustre/obdclass/cl_io.c +11 -15
@@ -52,11 +52,6 @@* */ -#define cl_io_for_each (slice, io) \ - list_for_each_entry((slice), &io->ci_layers, cis_linkage) -#define cl_io_for_each_reverse (slice, io) \ - list_for_each_entry_reverse((slice), &io->ci_layers, cis_linkage) -static inline int cl_io_type_is_valid (enum cl_io_type type) {return CIT_READ <= type && type <CIT_OP_NR ;
@@ -343,13 +338,14 @@ int cl_io_lock(const struct lu_env *env, struct cl_io *io)LINVRNT (io->ci_state ==CIS_IT_STARTED );LINVRNT (cl_io_invariant (io)); -cl_io_for_each (scan, io) { +list_for_each_entry (scan, &io->ci_layers, cis_linkage) {if (!scan->cis_iop->op[io->ci_type].cio_lock)continue ; result = scan->cis_iop->op[io->ci_type].cio_lock (env, scan);if (result !=0 )break ; } +if (result ==0 ) {cl_io_locks_sort (io); result =cl_lockset_lock (env, io, &io->ci_lockset);
@@ -391,7 +387,7 @@ void cl_io_unlock(const struct lu_env *env, struct cl_io *io) link->cill_fini (env, link); } -cl_io_for_each_reverse (scan, io) { +list_for_each_entry_reverse (scan, &io->ci_layers, cis_linkage) {if (scan->cis_iop->op[io->ci_type].cio_unlock) scan->cis_iop->op[io->ci_type].cio_unlock (env, scan); }
@@ -416,7 +412,7 @@ int cl_io_iter_init(const struct lu_env *env, struct cl_io *io)LINVRNT (cl_io_invariant (io)); result =0 ; -cl_io_for_each (scan, io) { +list_for_each_entry (scan, &io->ci_layers, cis_linkage) {if (!scan->cis_iop->op[io->ci_type].cio_iter_init)continue ; result = scan->cis_iop->op[io->ci_type].cio_iter_init(env,
@@ -443,7 +439,7 @@ void cl_io_iter_fini(const struct lu_env *env, struct cl_io *io)LINVRNT (io->ci_state ==CIS_UNLOCKED );LINVRNT (cl_io_invariant (io)); -cl_io_for_each_reverse (scan, io) { +list_for_each_entry_reverse (scan, &io->ci_layers, cis_linkage) {if (scan->cis_iop->op[io->ci_type].cio_iter_fini) scan->cis_iop->op[io->ci_type].cio_iter_fini (env, scan); }
@@ -468,7 +464,7 @@ static void cl_io_rw_advance(const struct lu_env *env, struct cl_io *io, io->u.ci_rw.crw_count -= nob;/* layers have to be notified. */ -cl_io_for_each_reverse (scan, io) { +list_for_each_entry_reverse (scan, &io->ci_layers, cis_linkage) {if (scan->cis_iop->op[io->ci_type].cio_advance) scan->cis_iop->op[io->ci_type].cio_advance (env, scan, nob);
@@ -536,7 +532,7 @@ int cl_io_start(const struct lu_env *env, struct cl_io *io)LINVRNT (cl_io_invariant (io)); io->ci_state =CIS_IO_GOING ; -cl_io_for_each (scan, io) { +list_for_each_entry (scan, &io->ci_layers, cis_linkage) {if (!scan->cis_iop->op[io->ci_type].cio_start)continue ; result = scan->cis_iop->op[io->ci_type].cio_start (env, scan);
@@ -561,7 +557,7 @@ void cl_io_end(const struct lu_env *env, struct cl_io *io)LINVRNT (io->ci_state ==CIS_IO_GOING );LINVRNT (cl_io_invariant (io)); -cl_io_for_each_reverse (scan, io) { +list_for_each_entry_reverse (scan, &io->ci_layers, cis_linkage) {if (scan->cis_iop->op[io->ci_type].cio_end) scan->cis_iop->op[io->ci_type].cio_end (env, scan);/* TODO: error handling. */
@@ -584,7 +580,7 @@ int cl_io_read_ahead(const struct lu_env *env, struct cl_io *io,LINVRNT (io->ci_type ==CIT_READ || io->ci_type ==CIT_FAULT );LINVRNT (cl_io_invariant (io)); -cl_io_for_each (scan, io) { +list_for_each_entry (scan, &io->ci_layers, cis_linkage) {if (!scan->cis_iop->cio_read_ahead)continue ;
@@ -609,7 +605,7 @@ int cl_io_commit_async(const struct lu_env *env, struct cl_io *io,const struct cl_io_slice *scan;int result =0 ; -cl_io_for_each (scan, io) { +list_for_each_entry (scan, &io->ci_layers, cis_linkage) {if (!scan->cis_iop->cio_commit_async)continue ; result = scan->cis_iop->cio_commit_async(env, scan, queue,
@@ -637,7 +633,7 @@ int cl_io_submit_rw(const struct lu_env *env, struct cl_io *io,const struct cl_io_slice *scan;int result =0 ; -cl_io_for_each (scan, io) { +list_for_each_entry (scan, &io->ci_layers, cis_linkage) {if (!scan->cis_iop->cio_submit)continue ; result = scan->cis_iop->cio_submit (env, scan, crt, queue);
Signature · 1 line
1.8.3.1
PATCH 3/8 lustre: obdclass: Code cleanup
In reply to James SimmonsFrom: Ben Evans <[email protected]>
Remove uuid.c, and unroll class_uuid_unparse
Rewrite CL_ENV_INC and DEC
Remove D_KUC #define
WC-bug-id: https://jira.whamcloud.com/browse/LU-9855
Reviewed-on: https://review.whamcloud.com/28458
--- drivers/staging/lustre/lustre/include/obd_class.h | 40 +++++++------------ drivers/staging/lustre/lustre/llite/llite_lib.c | 3 +- drivers/staging/lustre/lustre/obdclass/Makefile | 5 +-- drivers/staging/lustre/lustre/obdclass/cl_object.c | 21 ++++++---- drivers/staging/lustre/lustre/obdclass/class_obd.c | 1 - .../staging/lustre/lustre/obdclass/kernelcomm.c | 7 ++-- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 2 +- drivers/staging/lustre/lustre/obdclass/uuid.c | 45 ---------------------- 8 files changed, 34 insertions(+), 90 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/obdclass/uuid.c
drivers/staging/lustre/lustre/include/obd_class.h +13 -27
@@ -497,9 +497,9 @@ static inline int obd_set_info_async(const struct lu_env *env,static inline int obd_setup (struct obd_device *obd,struct lustre_cfg *cfg) { -int rc;struct lu_device_type *ldt;struct lu_device *d; +int rc; ldt = obd->obd_type->typ_lu;if (ldt) {
@@ -536,15 +536,10 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg)static inline int obd_precleanup (struct obd_device *obd) { +struct lu_device_type *ldt = obd->obd_type->typ_lu; +struct lu_device *d = obd->obd_lu_dev;int rc; -struct lu_device_type *ldt; -struct lu_device *d; - rc =obd_check_dev (obd); -if (rc) -return rc; - ldt = obd->obd_type->typ_lu; - d = obd->obd_lu_dev;if (ldt && d) {struct lu_env env;
@@ -563,16 +558,10 @@ static inline int obd_precleanup(struct obd_device *obd)static inline int obd_cleanup (struct obd_device *obd) { +struct lu_device_type *ldt = obd->obd_type->typ_lu; +struct lu_device *d = obd->obd_lu_dev;int rc; -struct lu_device_type *ldt; -struct lu_device *d; - rc =obd_check_dev (obd); -if (rc) -return rc; - - ldt = obd->obd_type->typ_lu; - d = obd->obd_lu_dev;if (ldt && d) {struct lu_env env;
@@ -613,17 +602,11 @@ static inline void obd_cleanup_client_import(struct obd_device *obd)static inline int obd_process_config (struct obd_device *obd,int datalen,void *data) { +struct lu_device_type *ldt = obd->obd_type->typ_lu; +struct lu_device *d = obd->obd_lu_dev;int rc; -struct lu_device_type *ldt; -struct lu_device *d; - - rc =obd_check_dev (obd); -if (rc) -return rc; obd->obd_process_conf =1 ; - ldt = obd->obd_type->typ_lu; - d = obd->obd_lu_dev;if (ldt && d) {struct lu_env env;
@@ -1554,9 +1537,12 @@ struct lwp_register_item {/* obd_mount.c */ int lustre_check_exclusion (struct super_block *sb,char *svname); -/* uuid.c */ -typedef __u8 class_uuid_t [16 ]; -void class_uuid_unparse (class_uuid_t in,struct obd_uuid *out); +typedef u8 class_uuid_t [16 ]; + +static inline void class_uuid_unparse (class_uuid_t uu,struct obd_uuid *out) +{ +sprintf (out->uuid,"%pU" , uu); +}/* lustre_peer.c */ int lustre_uuid_to_peer (const char *uuid,lnet_nid_t *peer_nid,int index);
drivers/staging/lustre/lustre/llite/llite_lib.c +2 -1
@@ -98,7 +98,8 @@ static struct ll_sb_info *ll_init_sbi(void)SBI_DEFAULT_READAHEAD_WHOLE_MAX ;ll_generate_random_uuid (uuid); -class_uuid_unparse (uuid, &sbi->ll_sb_uuid); +sprintf (sbi->ll_sb_uuid.uuid,"%pU" , uuid); +CDEBUG (D_CONFIG ,"generated uuid: %s\n" , sbi->ll_sb_uuid.uuid); sbi->ll_flags |=LL_SBI_VERBOSE ;
drivers/staging/lustre/lustre/obdclass/Makefile +2 -3
@@ -4,9 +4,8 @@ ccflags-y += -I$(srctree)/drivers/staging/lustre/lustre/include obj-$(CONFIG_LUSTRE_FS) += obdclass.o -obdclass-y := obd_sysfs.o \ - llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \ - genops.o uuid.o lprocfs_status.o lprocfs_counters.o \ +obdclass-y := llog.o llog_cat.o llog_obd.o llog_swab.o class_obd.o debug.o \ + genops.o obd_sysfs.o lprocfs_status.o lprocfs_counters.o \ lustre_handles.o lustre_peer.o statfs_pack.o linkea.o \ obdo.o obd_config.o obd_mount.o lu_object.o lu_ref.o \ cl_object.o cl_page.o cl_lock.o cl_io.o kernelcomm.o
drivers/staging/lustre/lustre/obdclass/cl_object.c +13 -8
@@ -572,8 +572,13 @@ struct cl_env {void *ce_debug; }; -#define CL_ENV_INC (counter) -#define CL_ENV_DEC (counter) +static void cl_env_inc (enum cache_stats_item item) +{ +} + +static void cl_env_dec (enum cache_stats_item item) +{ +}static void cl_env_init0 (struct cl_env *cle,void *debug) {
@@ -583,7 +588,7 @@ static void cl_env_init0(struct cl_env *cle, void *debug) cle->ce_ref =1 ; cle->ce_debug = debug; -CL_ENV_INC (busy); +cl_env_inc (CS_busy); }static struct lu_env *cl_env_new (__u32 ctx_tags,__u32 ses_tags,void *debug)
@@ -614,8 +619,8 @@ static struct lu_env *cl_env_new(__u32 ctx_tags, __u32 ses_tags, void *debug)kmem_cache_free (cl_env_kmem, cle); env =ERR_PTR (rc); }else { -CL_ENV_INC (create); -CL_ENV_INC (total); +cl_env_inc (CS_create); +cl_env_inc (CS_total); } }else { env =ERR_PTR (-ENOMEM );
@@ -625,7 +630,7 @@ static struct lu_env *cl_env_new(__u32 ctx_tags, __u32 ses_tags, void *debug)static void cl_env_fini (struct cl_env *cle) { -CL_ENV_DEC (total); +cl_env_dec (CS_total);lu_context_fini (&cle->ce_lu.le_ctx);lu_context_fini (&cle->ce_ses);kmem_cache_free (cl_env_kmem, cle);
@@ -781,7 +786,7 @@ void cl_env_put(struct lu_env *env, u16 *refcheck)if (--cle->ce_ref ==0 ) {int cpu =get_cpu (); -CL_ENV_DEC (busy); +cl_env_dec (CS_busy); cle->ce_debug =NULL ;cl_env_exit (cle);/*
@@ -902,7 +907,7 @@ void cl_env_percpu_put(struct lu_env *env) cle->ce_ref--;LASSERT (cle->ce_ref ==0 ); -CL_ENV_DEC (busy); +cl_env_dec (CS_busy); cle->ce_debug =NULL ;put_cpu ();
drivers/staging/lustre/lustre/obdclass/class_obd.c +0 -1
@@ -585,7 +585,6 @@ static long obd_class_ioctl(struct file *filp, unsigned int cmd, .fops = &obd_psdev_fops, }; -#define OBD_INIT_CHECK static int obd_init_checks (void ) {__u64 u64val, div64val;
drivers/staging/lustre/lustre/obdclass/kernelcomm.c +3 -4
@@ -37,7 +37,6 @@*/ #define DEBUG_SUBSYSTEM S_CLASS -#define D_KUC D_OTHER#include <linux/file.h> #include <linux/libcfs/libcfs.h>
@@ -77,7 +76,7 @@ int libcfs_kkuc_msg_put(struct file *filp, void *payload)if (rc <0 )CWARN ("message send failed (%d)\n" , rc);else -CDEBUG (D_KUC ,"Sent message rc=%d, fp=%p\n" , rc, filp); +CDEBUG (D_HSM ,"Sent message rc=%d, fp=%p\n" , rc, filp);return rc; }
@@ -146,7 +145,7 @@ int libcfs_kkuc_group_add(struct file *filp, int uid, unsigned int group,list_add (®->kr_chain, &kkuc_groups[group]);up_write (&kg_sem); -CDEBUG (D_KUC ,"Added uid=%d fp=%p to group %d\n" , uid, filp, group); +CDEBUG (D_HSM ,"Added uid=%d fp=%p to group %d\n" , uid, filp, group);return 0 ; }
@@ -176,7 +175,7 @@ int libcfs_kkuc_group_rem(int uid, unsigned int group)list_for_each_entry_safe (reg, next, &kkuc_groups[group], kr_chain) {if (!uid || (uid == reg->kr_uid)) {list_del (®->kr_chain); -CDEBUG (D_KUC ,"Removed uid=%d fp=%p from group %d\n" , +CDEBUG (D_HSM ,"Removed uid=%d fp=%p from group %d\n" , reg->kr_uid, reg->kr_fp, group);if (reg->kr_fp)fput (reg->kr_fp);
drivers/staging/lustre/lustre/obdclass/obd_mount.c +1 -1
@@ -336,7 +336,7 @@ int lustre_start_mgc(struct super_block *sb) }ll_generate_random_uuid (uuidc); -class_uuid_unparse (uuidc, uuid); +sprintf (uuid->uuid,"%pU" , uuidc);/* Start the MGC */ rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME,
drivers/staging/lustre/lustre/obdclass/uuid.c deleted +0 -45
45 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 4/8 lustre: obdclass: cleanup obd_class.h defines
In reply to James SimmonsFrom: Ben Evans <[email protected]>
Get rid of OBT and CTXTP defines.
Remove OBD_CHECK_DT_OP
Convert EXP_CHECK_MD_OP into a function.
Remove CTXT_CHECK_OP.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9855
Reviewed-on: https://review.whamcloud.com/29286
WC-bug-id: https://jira.whamcloud.com/browse/LU-11169
Reviewed-on: https://review.whamcloud.com/#/c/32906
--- drivers/staging/lustre/lustre/include/obd_class.h | 437 +++++++++++++++------- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 4 +- 2 files changed, 311 insertions(+), 130 deletions(-)
drivers/staging/lustre/lustre/include/obd_class.h +309 -128
@@ -303,10 +303,8 @@ static inline int lprocfs_climp_check(struct obd_device *obd)void obdo_to_ioobj (const struct obdo *oa,struct obd_ioobj *ioobj); -#define OBT (dev) ((dev)->obd_type)#define OBP (dev, op) ((dev)->obd_type->typ_dt_ops->op)#define MDP (dev, op) ((dev)->obd_type->typ_md_ops->op) -#define CTXTP (ctxt, op) ((ctxt)->loc_logops->lop_##op)/* * Ensure obd_setup: used for cleanup which must be called
@@ -393,56 +391,16 @@ static inline int obd_check_dev_active(struct obd_device *obd) } \ }while (0 ) -#define EXP_CHECK_MD_OP (exp, op) \ -do { \ - if (!(exp)) { \ - CERROR("obd_" #op ": NULL export\n"); \ - return -ENODEV; \ - } \ - if (!(exp)->exp_obd || !OBT((exp)->exp_obd)) { \ - CERROR("obd_" #op ": cleaned up obd\n"); \ - return -EOPNOTSUPP; \ - } \ - if (!OBT((exp)->exp_obd) || !MDP((exp)->exp_obd, op)) { \ - CERROR("%s: obd_" #op ": dev %d no operation\n",\ - (exp)->exp_obd->obd_name, \ - (exp)->exp_obd->obd_minor); \ - return -EOPNOTSUPP; \ - } \ -} while (0) - -#define OBD_CHECK_DT_OP (obd, op, err) \ -do { \ - if (!OBT(obd) || !OBP((obd), op)) { \ - if (err) \ - CERROR("%s: no obd_" #op " operation\n", \ - obd->obd_name); \ - return err; \ - } \ -} while (0) +static inline int exp_check_ops(struct obd_export *exp) +{ +if (!exp) +return -ENODEV ; -#define EXP_CHECK_DT_OP (exp, op) \ -do { \ - if (!(exp)) { \ - CERROR("obd_" #op ": NULL export\n"); \ - return -ENODEV; \ - } \ - if (!(exp)->exp_obd || !OBT((exp)->exp_obd)) { \ - CERROR("obd_" #op ": cleaned up obd\n"); \ - return -EOPNOTSUPP; \ - } \ - OBD_CHECK_DT_OP((exp)->exp_obd, op, -EOPNOTSUPP); \ -} while (0) +if (!exp->exp_obd || !exp->exp_obd->obd_type) +return -EOPNOTSUPP ; -#define CTXT_CHECK_OP (ctxt, op, err) \ -do { \ - if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \ - if (err) \ - CERROR("%s: no lop_" #op " operation\n", \ - ctxt->loc_obd->obd_name); \ - return err; \ - } \ -} while (0) +return 0 ; +}static inline int class_devno_max (void ) {
@@ -455,7 +413,15 @@ static inline int obd_get_info(const struct lu_env *env, {int rc; -EXP_CHECK_DT_OP (exp, get_info); + rc =exp_check_ops (exp); +if (rc) +return rc; + +if (!exp->exp_obd->obd_type->typ_dt_ops->get_info) { +CERROR ("%s: no %s operation\n" , + exp->exp_obd->obd_name, __func__); +return -ENOTSUPP ; + }EXP_COUNTER_INCREMENT (exp, get_info); rc =OBP (exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val);
@@ -469,7 +435,15 @@ static inline int obd_set_info_async(const struct lu_env *env, {int rc; -EXP_CHECK_DT_OP (exp, set_info_async); + rc =exp_check_ops (exp); +if (rc) +return rc; + +if (!exp->exp_obd->obd_type->typ_dt_ops->set_info_async) { +CERROR ("%s: no %s operation\n" , + exp->exp_obd->obd_name, __func__); +return -ENOTSUPP ; + }EXP_COUNTER_INCREMENT (exp, set_info_async); rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen,
@@ -484,14 +458,14 @@ static inline int obd_set_info_async(const struct lu_env *env,* pieces of configuration process are still based on obd devices. * * Specifically, lu_device_type_operations::ldto_device_alloc() methods fully -* subsume ->o_setup() methods of obd devices they replace. The same for -* lu_device_operations::ldo_process_config() and ->o_process_config(). As a +* subsume ->setup() methods of obd devices they replace. The same for +* lu_device_operations::ldo_process_config() and ->process_config(). As a * result, obd_setup() and obd_process_config() branch and call one XOR * another. * * Yet neither lu_device_type_operations::ldto_device_fini() nor * lu_device_type_operations::ldto_device_free() fully implement the -* functionality of ->o_precleanup() and ->o_cleanup() they override. Hence, +* functionality of ->precleanup() and ->o_cleanup() they override. Hence, * obd_precleanup() and obd_cleanup() call both lu_device and obd operations. */
@@ -527,7 +501,11 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg)lu_context_fini (&session_ctx); }else { -OBD_CHECK_DT_OP (obd, setup, -EOPNOTSUPP ); +if (!obd->obd_type->typ_dt_ops->setup) { +CERROR ("%s: no %s operation\n" , obd->obd_name, + __func__); +return -EOPNOTSUPP ; + }OBD_COUNTER_INCREMENT (obd, setup); rc =OBP (obd, setup)(obd, cfg); }
@@ -549,7 +527,9 @@ static inline int obd_precleanup(struct obd_device *obd)lu_env_fini (&env); } } -OBD_CHECK_DT_OP (obd, precleanup,0 ); +if (!obd->obd_type->typ_dt_ops->precleanup) +return 0 ; +OBD_COUNTER_INCREMENT (obd, precleanup); rc =OBP (obd, precleanup)(obd);
@@ -572,7 +552,9 @@ static inline int obd_cleanup(struct obd_device *obd) obd->obd_lu_dev =NULL ; } } -OBD_CHECK_DT_OP (obd, cleanup,0 ); +if (!obd->obd_type->typ_dt_ops->cleanup) +return 0 ; +OBD_COUNTER_INCREMENT (obd, cleanup); rc =OBP (obd, cleanup)(obd);
@@ -599,8 +581,8 @@ static inline void obd_cleanup_client_import(struct obd_device *obd)up_write (&obd->u.cli.cl_sem); } -static inline int -obd_process_config (struct obd_device *obd,int datalen,void *data) +static inline int obd_process_config (struct obd_device *obd,int datalen, +void *data) {struct lu_device_type *ldt = obd->obd_type->typ_lu;struct lu_device *d = obd->obd_lu_dev;
@@ -616,7 +598,11 @@ static inline void obd_cleanup_client_import(struct obd_device *obd)lu_env_fini (&env); } }else { -OBD_CHECK_DT_OP (obd, process_config, -EOPNOTSUPP ); +if (!obd->obd_type->typ_dt_ops->process_config) { +CERROR ("%s: no %s operation\n" , + obd->obd_name, __func__); +return -EOPNOTSUPP ; + } rc =OBP (obd, process_config)(obd, datalen, data); }OBD_COUNTER_INCREMENT (obd, process_config);
@@ -630,7 +616,15 @@ static inline int obd_create(const struct lu_env *env, struct obd_export *exp, {int rc; -EXP_CHECK_DT_OP (exp, create); + rc =exp_check_ops (exp); +if (rc) +return rc; + +if (!exp->exp_obd->obd_type->typ_dt_ops->create) { +CERROR ("%s: no %s operation\n" , + exp->exp_obd->obd_name, __func__); +return -EOPNOTSUPP ; + }EXP_COUNTER_INCREMENT (exp, create); rc =OBP (exp->exp_obd, create)(env, exp, obdo);
@@ -642,7 +636,15 @@ static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, {int rc; -EXP_CHECK_DT_OP (exp, destroy); + rc =exp_check_ops (exp); +if (rc) +return rc; + +if (!exp->exp_obd->obd_type->typ_dt_ops->destroy) { +CERROR ("%s: no %s operation\n" , + exp->exp_obd->obd_name, __func__); +return -EOPNOTSUPP ; + }EXP_COUNTER_INCREMENT (exp, destroy); rc =OBP (exp->exp_obd, destroy)(env, exp, obdo);
@@ -654,7 +656,15 @@ static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, {int rc; -EXP_CHECK_DT_OP (exp, getattr); + rc =exp_check_ops (exp); +if (rc) +return rc; + +if (!exp->exp_obd->obd_type->typ_dt_ops->getattr) { +CERROR ("%s: no %s operation\n" , + exp->exp_obd->obd_name, __func__); +return -EOPNOTSUPP ; + }EXP_COUNTER_INCREMENT (exp, getattr); rc =OBP (exp->exp_obd, getattr)(env, exp, oa);
@@ -666,7 +676,15 @@ static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, {int rc; -EXP_CHECK_DT_OP (exp, setattr); + rc =exp_check_ops (exp); +if (rc) +return rc; + +if (!exp->exp_obd->obd_type->typ_dt_ops->setattr) { +CERROR ("%s: no %s operation\n" , + exp->exp_obd->obd_name, __func__); +return -EOPNOTSUPP ; + }EXP_COUNTER_INCREMENT (exp, setattr); rc =OBP (exp->exp_obd, setattr)(env, exp, oa);
@@ -682,7 +700,11 @@ static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, rc =obd_check_dev_active (obd);if (rc)return rc; -OBD_CHECK_DT_OP (obd, add_conn, -EOPNOTSUPP ); + +if (!obd->obd_type || !obd->obd_type->typ_dt_ops->add_conn) { +CERROR ("%s: no %s operation\n" , obd->obd_name, __func__); +return -EOPNOTSUPP ; + }OBD_COUNTER_INCREMENT (obd, add_conn); rc =OBP (obd, add_conn)(imp, uuid, priority);
@@ -697,7 +719,11 @@ static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) rc =obd_check_dev_active (obd);if (rc)return rc; -OBD_CHECK_DT_OP (obd, del_conn, -EOPNOTSUPP ); + +if (!obd->obd_type || !obd->obd_type->typ_dt_ops->del_conn) { +CERROR ("%s: no %s operation\n" , obd->obd_name, __func__); +return -EOPNOTSUPP ; + }OBD_COUNTER_INCREMENT (obd, del_conn); rc =OBP (obd, del_conn)(imp, uuid);
@@ -708,7 +734,10 @@ static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) {struct obd_uuid *uuid; -OBD_CHECK_DT_OP (exp->exp_obd, get_uuid,NULL ); +if (!exp->exp_obd->obd_type || + !exp->exp_obd->obd_type->typ_dt_ops->get_uuid) +return NULL ; +EXP_COUNTER_INCREMENT (exp, get_uuid); uuid =OBP (exp->exp_obd, get_uuid)(exp);
@@ -727,16 +756,18 @@ static inline int obd_connect(const struct lu_env *env,struct obd_connect_data *data, void *localdata) { +/* for post-condition check */ + u64 ocf = data ? data->ocd_connect_flags : 0;int rc; -__u64 ocf = data ? data->ocd_connect_flags :0 ;/* -* for post-condition -* check -*/ rc =obd_check_dev_active (obd);if (rc)return rc; -OBD_CHECK_DT_OP (obd, connect, -EOPNOTSUPP ); + +if (!obd->obd_type || !obd->obd_type->typ_dt_ops->connect) { +CERROR ("%s: no %s operation\n" , obd->obd_name, __func__); +return -EOPNOTSUPP ; + }OBD_COUNTER_INCREMENT (obd, connect); rc =OBP (obd, connect)(env, exp, obd, cluuid, data, localdata);
@@ -753,13 +784,16 @@ static inline int obd_reconnect(const struct lu_env *env,struct obd_connect_data *d, void *localdata) { + u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition check */int rc; -__u64 ocf = d ? d->ocd_connect_flags :0 ;/* for post-condition check */ rc =obd_check_dev_active (obd);if (rc)return rc; -OBD_CHECK_DT_OP (obd, reconnect,0 ); + +if (!obd->obd_type || !obd->obd_type->typ_dt_ops->reconnect) +return 0 ; +OBD_COUNTER_INCREMENT (obd, reconnect); rc =OBP (obd, reconnect)(env, exp, obd, cluuid, d, localdata);
@@ -772,7 +806,15 @@ static inline int obd_disconnect(struct obd_export *exp) {int rc; -EXP_CHECK_DT_OP (exp, disconnect); + rc =exp_check_ops (exp); +if (rc) +return rc; + +if (!exp->exp_obd->obd_type->typ_dt_ops->disconnect) { +CERROR ("%s: no %s operation\n" , + exp->exp_obd->obd_name, __func__); +return -ENOTSUPP ; + }EXP_COUNTER_INCREMENT (exp, disconnect); rc =OBP (exp->exp_obd, disconnect)(exp);
@@ -784,7 +826,8 @@ static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, {int rc; -OBD_CHECK_DT_OP (obd, fid_init,0 ); +if (!obd->obd_type || !obd->obd_type->typ_dt_ops->fid_init) +return 0 ;OBD_COUNTER_INCREMENT (obd, fid_init); rc =OBP (obd, fid_init)(obd, exp, type);
@@ -795,7 +838,8 @@ static inline int obd_fid_fini(struct obd_device *obd) {int rc; -OBD_CHECK_DT_OP (obd, fid_fini,0 ); +if (!obd->obd_type || !obd->obd_type->typ_dt_ops->fid_fini) +return 0 ;OBD_COUNTER_INCREMENT (obd, fid_fini); rc =OBP (obd, fid_fini)(obd);
@@ -809,7 +853,15 @@ static inline int obd_fid_alloc(const struct lu_env *env, {int rc; -EXP_CHECK_DT_OP (exp, fid_alloc); + rc =exp_check_ops (exp); +if (rc) +return rc; + +if (!exp->exp_obd->obd_type->typ_dt_ops->fid_alloc) { +CERROR ("%s: no %s operation\n" , + exp->exp_obd->obd_name, __func__); +return -ENOTSUPP ; + }EXP_COUNTER_INCREMENT (exp, fid_alloc); rc =OBP (exp->exp_obd, fid_alloc)(env, exp, fid, op_data);
@@ -820,7 +872,10 @@ static inline int obd_pool_new(struct obd_device *obd, char *poolname) {int rc; -OBD_CHECK_DT_OP (obd, pool_new, -EOPNOTSUPP ); +if (!obd->obd_type || !obd->obd_type->typ_dt_ops->pool_new) { +CERROR ("%s: no %s operation\n" , obd->obd_name, __func__); +return -EOPNOTSUPP ; + }OBD_COUNTER_INCREMENT (obd, pool_new); rc =OBP (obd, pool_new)(obd, poolname);
@@ -831,20 +886,25 @@ static inline int obd_pool_del(struct obd_device *obd, char *poolname) {int rc; -OBD_CHECK_DT_OP (obd, pool_del, -EOPNOTSUPP ); +if (!obd->obd_type || !obd->obd_type->typ_dt_ops->pool_del) { +CERROR ("%s: no %s operation\n" , obd->obd_name, __func__); +return -EOPNOTSUPP ; + }OBD_COUNTER_INCREMENT (obd, pool_del); rc =OBP (obd, pool_del)(obd, poolname);return rc; } -static inline int obd_pool_add (struct obd_device *obd, -char *poolname, +static inline int obd_pool_add (struct obd_device *obd,char *poolname,char *ostname) {int rc; -OBD_CHECK_DT_OP (obd, pool_add, -EOPNOTSUPP ); +if (!obd->obd_type || !obd->obd_type->typ_dt_ops->pool_add) { +CERROR ("%s: no %s operation\n" , obd->obd_name, __func__); +return -EOPNOTSUPP ; + }OBD_COUNTER_INCREMENT (obd, pool_add); rc =OBP (obd, pool_add)(obd, poolname, ostname);
@@ -857,7 +917,10 @@ static inline int obd_pool_rem(struct obd_device *obd, {int rc; -OBD_CHECK_DT_OP (obd, pool_rem, -EOPNOTSUPP ); +if (!obd->obd_type || !obd->obd_type->typ_dt_ops->pool_rem) { +CERROR ("%s: no %s operation\n" , obd->obd_name, __func__); +return -EOPNOTSUPP ; + }OBD_COUNTER_INCREMENT (obd, pool_rem); rc =OBP (obd, pool_rem)(obd, poolname, ostname);
@@ -866,7 +929,7 @@ static inline int obd_pool_rem(struct obd_device *obd,static inline void obd_getref (struct obd_device *obd) { -if (OBT (obd) &&OBP (obd, getref)) { +if (obd->obd_type &&OBP (obd, getref)) {OBD_COUNTER_INCREMENT (obd, getref);OBP (obd, getref)(obd); }
@@ -874,7 +937,7 @@ static inline void obd_getref(struct obd_device *obd)static inline void obd_putref (struct obd_device *obd) { -if (OBT (obd) &&OBP (obd, putref)) { +if (obd->obd_type &&OBP (obd, putref)) {OBD_COUNTER_INCREMENT (obd, putref);OBP (obd, putref)(obd); }
@@ -884,7 +947,7 @@ static inline int obd_init_export(struct obd_export *exp) {int rc =0 ; -if ((exp)->exp_obd &&OBT ((exp)->exp_obd) && +if (exp->exp_obd && exp->exp_obd->obd_type &&OBP ((exp)->exp_obd, init_export)) rc =OBP (exp->exp_obd, init_export)(exp);return rc;
@@ -892,7 +955,7 @@ static inline int obd_init_export(struct obd_export *exp)static inline int obd_destroy_export (struct obd_export *exp) { -if ((exp)->exp_obd &&OBT ((exp)->exp_obd) && +if (exp->exp_obd && exp->exp_obd->obd_type &&OBP ((exp)->exp_obd, destroy_export))OBP (exp->exp_obd, destroy_export)(exp);return 0 ;
@@ -915,7 +978,10 @@ static inline int obd_statfs_async(struct obd_export *exp,return -EINVAL ; obd = exp->exp_obd; -OBD_CHECK_DT_OP (obd, statfs, -EOPNOTSUPP ); +if (!obd->obd_type || !obd->obd_type->typ_dt_ops->statfs) { +CERROR ("%s: no %s operation\n" , obd->obd_name, __func__); +return -EOPNOTSUPP ; + }OBD_COUNTER_INCREMENT (obd, statfs); CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n",
@@ -969,13 +1035,16 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *osfs, __u64 max_age, __u32 flags) { - int rc = 0; struct obd_device *obd = exp->exp_obd; +int rc =0 ;if (!obd)return -EINVAL ; -OBD_CHECK_DT_OP (obd, statfs, -EOPNOTSUPP ); +if (!obd->obd_type || !obd->obd_type->typ_dt_ops->statfs) { +CERROR ("%s: no %s operation\n" , obd->obd_name, __func__); +return -EOPNOTSUPP ; + }OBD_COUNTER_INCREMENT (obd, statfs); CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n",
@@ -1009,7 +1078,15 @@ static inline int obd_preprw(const struct lu_env *env, int cmd, {int rc; -EXP_CHECK_DT_OP (exp, preprw); + rc =exp_check_ops (exp); +if (rc) +return rc; + +if (!exp->exp_obd->obd_type->typ_dt_ops->preprw) { +CERROR ("%s: no %s operation\n" , + exp->exp_obd->obd_name, __func__); +return -ENOTSUPP ; + }EXP_COUNTER_INCREMENT (exp, preprw); rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote,
@@ -1021,13 +1098,23 @@ static inline int obd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, struct obdo *oa, int objcount, struct obd_ioobj *obj, struct niobuf_remote *rnb, int pages, - struct niobuf_local *local, int rc) + struct niobuf_local *local, int orig_rc) { -EXP_CHECK_DT_OP (exp ,commitrw ); + int rc; + + rc =exp_check_ops (exp); +if (rc) +return rc; + +if (!exp->exp_obd->obd_type->typ_dt_ops->commitrw) { +CERROR ("%s: no %s operation\n" , + exp->exp_obd->obd_name, __func__); +return -ENOTSUPP ; + }EXP_COUNTER_INCREMENT (exp, commitrw); rc =OBP (exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj, - rnb, pages, local, rc); + rnb, pages, local, orig_rc);return rc; }
@@ -1036,7 +1123,15 @@ static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, {int rc; -EXP_CHECK_DT_OP (exp, iocontrol); + rc =exp_check_ops (exp); +if (rc) +return rc; + +if (!exp->exp_obd->obd_type->typ_dt_ops->iocontrol) { +CERROR ("%s: no %s operation\n" , + exp->exp_obd->obd_name, __func__); +return -ENOTSUPP ; + }EXP_COUNTER_INCREMENT (exp, iocontrol); rc =OBP (exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg);
@@ -1108,7 +1203,15 @@ static inline int obd_quotactl(struct obd_export *exp, {int rc; -EXP_CHECK_DT_OP (exp, quotactl); + rc =exp_check_ops (exp); +if (rc) +return rc; + +if (!exp->exp_obd->obd_type->typ_dt_ops->quotactl) { +CERROR ("%s: no %s operation\n" , + exp->exp_obd->obd_name, __func__); +return -ENOTSUPP ; + }EXP_COUNTER_INCREMENT (exp, quotactl); rc =OBP (exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl);
@@ -1129,7 +1232,7 @@ static inline int obd_health_check(const struct lu_env *env,int rc;/* don't use EXP_CHECK_DT_OP, because NULL method is normal here */ -if (!obd || !OBT (obd)) { +if (!obd || !obd->obd_type) {CERROR ("cleaned up obd\n" );return -EOPNOTSUPP ; }
@@ -1166,7 +1269,9 @@ static inline int md_get_root(struct obd_export *exp, const char *fileset, {int rc; -EXP_CHECK_MD_OP (exp, get_root); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, get_root); rc =MDP (exp->exp_obd, get_root)(exp, fileset, fid);return rc;
@@ -1177,7 +1282,9 @@ static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, {int rc; -EXP_CHECK_MD_OP (exp, getattr); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, getattr); rc =MDP (exp->exp_obd, getattr)(exp, op_data, request);return rc;
@@ -1188,7 +1295,9 @@ static inline int md_null_inode(struct obd_export *exp, {int rc; -EXP_CHECK_MD_OP (exp, null_inode); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, null_inode); rc =MDP (exp->exp_obd, null_inode)(exp, fid);return rc;
@@ -1200,7 +1309,9 @@ static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, {int rc; -EXP_CHECK_MD_OP (exp, close); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, close); rc =MDP (exp->exp_obd, close)(exp, op_data, mod, request);return rc;
@@ -1213,7 +1324,9 @@ static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, {int rc; -EXP_CHECK_MD_OP (exp, create); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, create); rc =MDP (exp->exp_obd, create)(exp, op_data, data, datalen, mode, uid, gid, cap_effective, rdev, request);
@@ -1229,7 +1342,9 @@ static inline int md_enqueue(struct obd_export *exp, {int rc; -EXP_CHECK_MD_OP (exp, enqueue); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, enqueue); rc =MDP (exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh, extra_lock_flags);
@@ -1242,7 +1357,9 @@ static inline int md_getattr_name(struct obd_export *exp, {int rc; -EXP_CHECK_MD_OP (exp, getattr_name); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, getattr_name); rc =MDP (exp->exp_obd, getattr_name)(exp, op_data, request);return rc;
@@ -1257,7 +1374,9 @@ static inline int md_intent_lock(struct obd_export *exp, {int rc; -EXP_CHECK_MD_OP (exp, intent_lock); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, intent_lock); rc =MDP (exp->exp_obd, intent_lock)(exp, op_data, it, reqp, cb_blocking, extra_lock_flags);
@@ -1269,7 +1388,9 @@ static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, {int rc; -EXP_CHECK_MD_OP (exp, link); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, link); rc =MDP (exp->exp_obd, link)(exp, op_data, request);return rc;
@@ -1281,7 +1402,9 @@ static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, {int rc; -EXP_CHECK_MD_OP (exp, rename); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, rename); rc =MDP (exp->exp_obd, rename)(exp, op_data, old, oldlen, new, newlen, request);
@@ -1294,7 +1417,9 @@ static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, {int rc; -EXP_CHECK_MD_OP (exp, setattr); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, setattr); rc =MDP (exp->exp_obd, setattr)(exp, op_data, ea, ealen, request);return rc;
@@ -1305,7 +1430,9 @@ static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid, {int rc; -EXP_CHECK_MD_OP (exp, sync); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, sync); rc =MDP (exp->exp_obd, sync)(exp, fid, request);return rc;
@@ -1319,7 +1446,9 @@ static inline int md_read_page(struct obd_export *exp, {int rc; -EXP_CHECK_MD_OP (exp, read_page); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, read_page); rc =MDP (exp->exp_obd, read_page)(exp, op_data, cb_op, hash_offset, ppage);
@@ -1331,7 +1460,9 @@ static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, {int rc; -EXP_CHECK_MD_OP (exp, unlink); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, unlink); rc =MDP (exp->exp_obd, unlink)(exp, op_data, request);return rc;
@@ -1343,7 +1474,11 @@ static inline int md_get_lustre_md(struct obd_export *exp,struct obd_export *md_exp, struct lustre_md *md) { -EXP_CHECK_MD_OP (exp ,get_lustre_md ); + int rc; + + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, get_lustre_md);return MDP (exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md); }
@@ -1351,7 +1486,11 @@ static inline int md_get_lustre_md(struct obd_export *exp,static inline int md_free_lustre_md (struct obd_export *exp,struct lustre_md *md) { -EXP_CHECK_MD_OP (exp, free_lustre_md); +int rc; + + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, free_lustre_md);return MDP (exp->exp_obd, free_lustre_md)(exp, md); }
@@ -1361,7 +1500,11 @@ static inline int md_merge_attr(struct obd_export *exp,struct cl_attr *attr, ldlm_blocking_callback cb) { -EXP_CHECK_MD_OP (exp ,merge_attr ); + int rc; + + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, merge_attr);return MDP (exp->exp_obd, merge_attr)(exp, lsm, attr, cb); }
@@ -1372,7 +1515,11 @@ static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid, unsigned int xattr_flags, u32 suppgid, struct ptlrpc_request **request) { -EXP_CHECK_MD_OP (exp ,setxattr ); + int rc; + + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, setxattr); return MDP(exp->exp_obd, setxattr)(exp, fid, obd_md_valid, name, value, value_size, xattr_flags,
@@ -1383,7 +1530,11 @@ static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid, u64 obd_md_valid, const char *name, size_t buf_size, struct ptlrpc_request **req) { -EXP_CHECK_MD_OP (exp ,getxattr ); + int rc; + + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, getxattr);return MDP (exp->exp_obd, getxattr)(exp, fid, obd_md_valid, name, buf_size, req);
@@ -1393,7 +1544,11 @@ static inline int md_set_open_replay_data(struct obd_export *exp,struct obd_client_handle *och, struct lookup_intent *it) { -EXP_CHECK_MD_OP (exp ,set_open_replay_data ); + int rc; + + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, set_open_replay_data);return MDP (exp->exp_obd, set_open_replay_data)(exp, och, it); }
@@ -1401,7 +1556,11 @@ static inline int md_set_open_replay_data(struct obd_export *exp,static inline int md_clear_open_replay_data (struct obd_export *exp,struct obd_client_handle *och) { -EXP_CHECK_MD_OP (exp, clear_open_replay_data); +int rc; + + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, clear_open_replay_data);return MDP (exp->exp_obd, clear_open_replay_data)(exp, och); }
@@ -1410,7 +1569,11 @@ static inline int md_set_lock_data(struct obd_export *exp,const struct lustre_handle *lockh, void *data, __u64 *bits) { -EXP_CHECK_MD_OP (exp ,set_lock_data ); + int rc; + + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, set_lock_data);return MDP (exp->exp_obd, set_lock_data)(exp, lockh, data, bits); }
@@ -1424,7 +1587,9 @@ static inline int md_cancel_unused(struct obd_export *exp, {int rc; -EXP_CHECK_MD_OP (exp, cancel_unused); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, cancel_unused); rc = MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode,
@@ -1439,7 +1604,11 @@ static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags,enum ldlm_mode mode, struct lustre_handle *lockh) { -EXP_CHECK_MD_OP (exp ,lock_match ); + int rc; + + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, lock_match);return MDP (exp->exp_obd, lock_match)(exp, flags, fid, type, policy, mode, lockh);
@@ -1448,7 +1617,11 @@ static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags,static inline int md_init_ea_size (struct obd_export *exp,u32 easize,u32 def_asize) { -EXP_CHECK_MD_OP (exp, init_ea_size); +int rc; + + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, init_ea_size);return MDP (exp->exp_obd, init_ea_size)(exp, easize, def_asize); }
@@ -1458,7 +1631,9 @@ static inline int md_intent_getattr_async(struct obd_export *exp, {int rc; -EXP_CHECK_MD_OP (exp, intent_getattr_async); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, intent_getattr_async); rc =MDP (exp->exp_obd, intent_getattr_async)(exp, minfo);return rc;
@@ -1470,7 +1645,9 @@ static inline int md_revalidate_lock(struct obd_export *exp, {int rc; -EXP_CHECK_MD_OP (exp, revalidate_lock); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, revalidate_lock); rc =MDP (exp->exp_obd, revalidate_lock)(exp, it, fid, bits);return rc;
@@ -1483,7 +1660,9 @@ static inline int md_get_fid_from_lsm(struct obd_export *exp, {int rc; -EXP_CHECK_MD_OP (exp, get_fid_from_lsm); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, get_fid_from_lsm); rc =MDP (exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen, fid);return rc;
@@ -1502,7 +1681,9 @@ static inline int md_unpackmd(struct obd_export *exp, {int rc; -EXP_CHECK_MD_OP (exp, unpackmd); + rc =exp_check_ops (exp); +if (rc) +return rc;EXP_MD_COUNTER_INCREMENT (exp, unpackmd); rc =MDP (exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size);return rc;
drivers/staging/lustre/lustre/obdclass/llog_obd.c +2 -2
@@ -93,8 +93,8 @@ int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt) !!obd->obd_stopping, !!obd->obd_set_up);/* cleanup the llog ctxt here */ -if (CTXTP (ctxt, cleanup)) - rc =CTXTP (ctxt, cleanup)(env, ctxt); +if (ctxt->loc_logops->lop_cleanup) + rc = ctxt->loc_logops->lop_cleanup (env, ctxt);llog_ctxt_destroy (ctxt);wake_up (&olg->olg_waitq);
Signature · 1 line
1.8.3.1
Alexey Lyashkov
NAKPATCH 4/8 lustre: obdclass: cleanup obd_class.h defines
NAK.
Please use same as original patch
' struct niobuf_local *local, int orig_rc' vs ' struct niobuf_local *local, const int orig_rc'.
?On 17/09/2018, 20:31, "James Simmons" <[email protected]> wrote:
From: Ben Evans <[email protected]> Get rid of OBT and CTXTP defines. Remove OBD_CHECK_DT_OP Convert EXP_CHECK_MD_OP into a function. Remove CTXT_CHECK_OP. Signed-off-by: Ben Evans <[email protected]> Signed-off-by: Alexey Lyashkov <[email protected]> WC-bug-id: https://jira.whamcloud.com/browse/LU-9855 Reviewed-on: https://review.whamcloud.com/29286 WC-bug-id: https://jira.whamcloud.com/browse/LU-11169 Reviewed-on: https://review.whamcloud.com/#/c/32906 Reviewed-by: John L. Hammond <[email protected]> Reviewed-by: Steve Guminski <[email protected]> Reviewed-by: James Simmons <[email protected]> Reviewed-by: Oleg Drokin <[email protected]> Signed-off-by: James Simmons <[email protected]> --- drivers/staging/lustre/lustre/include/obd_class.h | 437 +++++++++++++++------- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 4 +- 2 files changed, 311 insertions(+), 130 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index c6fb2e1..aab1092 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -303,10 +303,8 @@ static inline int lprocfs_climp_check(struct obd_device *obd) void obdo_to_ioobj(const struct obdo *oa, struct obd_ioobj *ioobj); -#define OBT(dev) ((dev)->obd_type) #define OBP(dev, op) ((dev)->obd_type->typ_dt_ops->op) #define MDP(dev, op) ((dev)->obd_type->typ_md_ops->op) -#define CTXTP(ctxt, op) ((ctxt)->loc_logops->lop_##op) /* * Ensure obd_setup: used for cleanup which must be called @@ -393,56 +391,16 @@ static inline int obd_check_dev_active(struct obd_device *obd) } \ } while (0) -#define EXP_CHECK_MD_OP(exp, op) \ -do { \ - if (!(exp)) { \ - CERROR("obd_" #op ": NULL export\n"); \ - return -ENODEV; \ - } \ - if (!(exp)->exp_obd || !OBT((exp)->exp_obd)) { \ - CERROR("obd_" #op ": cleaned up obd\n"); \ - return -EOPNOTSUPP; \ - } \ - if (!OBT((exp)->exp_obd) || !MDP((exp)->exp_obd, op)) { \ - CERROR("%s: obd_" #op ": dev %d no operation\n",\ - (exp)->exp_obd->obd_name, \ - (exp)->exp_obd->obd_minor); \ - return -EOPNOTSUPP; \ - } \ -} while (0) - -#define OBD_CHECK_DT_OP(obd, op, err) \ -do { \ - if (!OBT(obd) || !OBP((obd), op)) { \ - if (err) \ - CERROR("%s: no obd_" #op " operation\n", \ - obd->obd_name); \ - return err; \ - } \ -} while (0) +static inline int exp_check_ops(struct obd_export *exp) +{ + if (!exp) + return -ENODEV; -#define EXP_CHECK_DT_OP(exp, op) \ -do { \ - if (!(exp)) { \ - CERROR("obd_" #op ": NULL export\n"); \ - return -ENODEV; \ - } \ - if (!(exp)->exp_obd || !OBT((exp)->exp_obd)) { \ - CERROR("obd_" #op ": cleaned up obd\n"); \ - return -EOPNOTSUPP; \ - } \ - OBD_CHECK_DT_OP((exp)->exp_obd, op, -EOPNOTSUPP); \ -} while (0) + if (!exp->exp_obd || !exp->exp_obd->obd_type) + return -EOPNOTSUPP; -#define CTXT_CHECK_OP(ctxt, op, err) \ -do { \ - if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \ - if (err) \ - CERROR("%s: no lop_" #op " operation\n", \ - ctxt->loc_obd->obd_name); \ - return err; \ - } \ -} while (0) + return 0; +} static inline int class_devno_max(void) { @@ -455,7 +413,15 @@ static inline int obd_get_info(const struct lu_env *env, { int rc; - EXP_CHECK_DT_OP(exp, get_info); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->get_info) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, get_info); rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val); @@ -469,7 +435,15 @@ static inline int obd_set_info_async(const struct lu_env *env, { int rc; - EXP_CHECK_DT_OP(exp, set_info_async); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->set_info_async) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, set_info_async); rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen, @@ -484,14 +458,14 @@ static inline int obd_set_info_async(const struct lu_env *env, * pieces of configuration process are still based on obd devices. * * Specifically, lu_device_type_operations::ldto_device_alloc() methods fully - * subsume ->o_setup() methods of obd devices they replace. The same for - * lu_device_operations::ldo_process_config() and ->o_process_config(). As a + * subsume ->setup() methods of obd devices they replace. The same for + * lu_device_operations::ldo_process_config() and ->process_config(). As a * result, obd_setup() and obd_process_config() branch and call one XOR * another. * * Yet neither lu_device_type_operations::ldto_device_fini() nor * lu_device_type_operations::ldto_device_free() fully implement the - * functionality of ->o_precleanup() and ->o_cleanup() they override. Hence, + * functionality of ->precleanup() and ->o_cleanup() they override. Hence, * obd_precleanup() and obd_cleanup() call both lu_device and obd operations. */ @@ -527,7 +501,11 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) lu_context_fini(&session_ctx); } else { - OBD_CHECK_DT_OP(obd, setup, -EOPNOTSUPP); + if (!obd->obd_type->typ_dt_ops->setup) { + CERROR("%s: no %s operation\n", obd->obd_name, + __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, setup); rc = OBP(obd, setup)(obd, cfg); } @@ -549,7 +527,9 @@ static inline int obd_precleanup(struct obd_device *obd) lu_env_fini(&env); } } - OBD_CHECK_DT_OP(obd, precleanup, 0); + if (!obd->obd_type->typ_dt_ops->precleanup) + return 0; + OBD_COUNTER_INCREMENT(obd, precleanup); rc = OBP(obd, precleanup)(obd); @@ -572,7 +552,9 @@ static inline int obd_cleanup(struct obd_device *obd) obd->obd_lu_dev = NULL; } } - OBD_CHECK_DT_OP(obd, cleanup, 0); + if (!obd->obd_type->typ_dt_ops->cleanup) + return 0; + OBD_COUNTER_INCREMENT(obd, cleanup); rc = OBP(obd, cleanup)(obd); @@ -599,8 +581,8 @@ static inline void obd_cleanup_client_import(struct obd_device *obd) up_write(&obd->u.cli.cl_sem); } -static inline int -obd_process_config(struct obd_device *obd, int datalen, void *data) +static inline int obd_process_config(struct obd_device *obd, int datalen, + void *data) { struct lu_device_type *ldt = obd->obd_type->typ_lu; struct lu_device *d = obd->obd_lu_dev; @@ -616,7 +598,11 @@ static inline void obd_cleanup_client_import(struct obd_device *obd) lu_env_fini(&env); } } else { - OBD_CHECK_DT_OP(obd, process_config, -EOPNOTSUPP); + if (!obd->obd_type->typ_dt_ops->process_config) { + CERROR("%s: no %s operation\n", + obd->obd_name, __func__); + return -EOPNOTSUPP; + } rc = OBP(obd, process_config)(obd, datalen, data); } OBD_COUNTER_INCREMENT(obd, process_config); @@ -630,7 +616,15 @@ static inline int obd_create(const struct lu_env *env, struct obd_export *exp, { int rc; - EXP_CHECK_DT_OP(exp, create); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->create) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -EOPNOTSUPP; + } EXP_COUNTER_INCREMENT(exp, create); rc = OBP(exp->exp_obd, create)(env, exp, obdo); @@ -642,7 +636,15 @@ static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, { int rc; - EXP_CHECK_DT_OP(exp, destroy); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->destroy) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -EOPNOTSUPP; + } EXP_COUNTER_INCREMENT(exp, destroy); rc = OBP(exp->exp_obd, destroy)(env, exp, obdo); @@ -654,7 +656,15 @@ static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, { int rc; - EXP_CHECK_DT_OP(exp, getattr); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->getattr) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -EOPNOTSUPP; + } EXP_COUNTER_INCREMENT(exp, getattr); rc = OBP(exp->exp_obd, getattr)(env, exp, oa); @@ -666,7 +676,15 @@ static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, { int rc; - EXP_CHECK_DT_OP(exp, setattr); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->setattr) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -EOPNOTSUPP; + } EXP_COUNTER_INCREMENT(exp, setattr); rc = OBP(exp->exp_obd, setattr)(env, exp, oa); @@ -682,7 +700,11 @@ static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, rc = obd_check_dev_active(obd); if (rc) return rc; - OBD_CHECK_DT_OP(obd, add_conn, -EOPNOTSUPP); + + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->add_conn) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, add_conn); rc = OBP(obd, add_conn)(imp, uuid, priority); @@ -697,7 +719,11 @@ static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) rc = obd_check_dev_active(obd); if (rc) return rc; - OBD_CHECK_DT_OP(obd, del_conn, -EOPNOTSUPP); + + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->del_conn) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, del_conn); rc = OBP(obd, del_conn)(imp, uuid); @@ -708,7 +734,10 @@ static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) { struct obd_uuid *uuid; - OBD_CHECK_DT_OP(exp->exp_obd, get_uuid, NULL); + if (!exp->exp_obd->obd_type || + !exp->exp_obd->obd_type->typ_dt_ops->get_uuid) + return NULL; + EXP_COUNTER_INCREMENT(exp, get_uuid); uuid = OBP(exp->exp_obd, get_uuid)(exp); @@ -727,16 +756,18 @@ static inline int obd_connect(const struct lu_env *env, struct obd_connect_data *data, void *localdata) { + /* for post-condition check */ + u64 ocf = data ? data->ocd_connect_flags : 0; int rc; - __u64 ocf = data ? data->ocd_connect_flags : 0; /* - * for post-condition - * check - */ rc = obd_check_dev_active(obd); if (rc) return rc; - OBD_CHECK_DT_OP(obd, connect, -EOPNOTSUPP); + + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->connect) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, connect); rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata); @@ -753,13 +784,16 @@ static inline int obd_reconnect(const struct lu_env *env, struct obd_connect_data *d, void *localdata) { + u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition check */ int rc; - __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition check */ rc = obd_check_dev_active(obd); if (rc) return rc; - OBD_CHECK_DT_OP(obd, reconnect, 0); + + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->reconnect) + return 0; + OBD_COUNTER_INCREMENT(obd, reconnect); rc = OBP(obd, reconnect)(env, exp, obd, cluuid, d, localdata); @@ -772,7 +806,15 @@ static inline int obd_disconnect(struct obd_export *exp) { int rc; - EXP_CHECK_DT_OP(exp, disconnect); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->disconnect) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, disconnect); rc = OBP(exp->exp_obd, disconnect)(exp); @@ -784,7 +826,8 @@ static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, { int rc; - OBD_CHECK_DT_OP(obd, fid_init, 0); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->fid_init) + return 0; OBD_COUNTER_INCREMENT(obd, fid_init); rc = OBP(obd, fid_init)(obd, exp, type); @@ -795,7 +838,8 @@ static inline int obd_fid_fini(struct obd_device *obd) { int rc; - OBD_CHECK_DT_OP(obd, fid_fini, 0); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->fid_fini) + return 0; OBD_COUNTER_INCREMENT(obd, fid_fini); rc = OBP(obd, fid_fini)(obd); @@ -809,7 +853,15 @@ static inline int obd_fid_alloc(const struct lu_env *env, { int rc; - EXP_CHECK_DT_OP(exp, fid_alloc); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->fid_alloc) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, fid_alloc); rc = OBP(exp->exp_obd, fid_alloc)(env, exp, fid, op_data); @@ -820,7 +872,10 @@ static inline int obd_pool_new(struct obd_device *obd, char *poolname) { int rc; - OBD_CHECK_DT_OP(obd, pool_new, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->pool_new) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, pool_new); rc = OBP(obd, pool_new)(obd, poolname); @@ -831,20 +886,25 @@ static inline int obd_pool_del(struct obd_device *obd, char *poolname) { int rc; - OBD_CHECK_DT_OP(obd, pool_del, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->pool_del) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, pool_del); rc = OBP(obd, pool_del)(obd, poolname); return rc; } -static inline int obd_pool_add(struct obd_device *obd, - char *poolname, +static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ostname) { int rc; - OBD_CHECK_DT_OP(obd, pool_add, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->pool_add) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, pool_add); rc = OBP(obd, pool_add)(obd, poolname, ostname); @@ -857,7 +917,10 @@ static inline int obd_pool_rem(struct obd_device *obd, { int rc; - OBD_CHECK_DT_OP(obd, pool_rem, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->pool_rem) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, pool_rem); rc = OBP(obd, pool_rem)(obd, poolname, ostname); @@ -866,7 +929,7 @@ static inline int obd_pool_rem(struct obd_device *obd, static inline void obd_getref(struct obd_device *obd) { - if (OBT(obd) && OBP(obd, getref)) { + if (obd->obd_type && OBP(obd, getref)) { OBD_COUNTER_INCREMENT(obd, getref); OBP(obd, getref)(obd); } @@ -874,7 +937,7 @@ static inline void obd_getref(struct obd_device *obd) static inline void obd_putref(struct obd_device *obd) { - if (OBT(obd) && OBP(obd, putref)) { + if (obd->obd_type && OBP(obd, putref)) { OBD_COUNTER_INCREMENT(obd, putref); OBP(obd, putref)(obd); } @@ -884,7 +947,7 @@ static inline int obd_init_export(struct obd_export *exp) { int rc = 0; - if ((exp)->exp_obd && OBT((exp)->exp_obd) && + if (exp->exp_obd && exp->exp_obd->obd_type && OBP((exp)->exp_obd, init_export)) rc = OBP(exp->exp_obd, init_export)(exp); return rc; @@ -892,7 +955,7 @@ static inline int obd_init_export(struct obd_export *exp) static inline int obd_destroy_export(struct obd_export *exp) { - if ((exp)->exp_obd && OBT((exp)->exp_obd) && + if (exp->exp_obd && exp->exp_obd->obd_type && OBP((exp)->exp_obd, destroy_export)) OBP(exp->exp_obd, destroy_export)(exp); return 0; @@ -915,7 +978,10 @@ static inline int obd_statfs_async(struct obd_export *exp, return -EINVAL; obd = exp->exp_obd; - OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->statfs) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, statfs); CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n", @@ -969,13 +1035,16 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *osfs, __u64 max_age, __u32 flags) { - int rc = 0; struct obd_device *obd = exp->exp_obd; + int rc = 0; if (!obd) return -EINVAL; - OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->statfs) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, statfs); CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n", @@ -1009,7 +1078,15 @@ static inline int obd_preprw(const struct lu_env *env, int cmd, { int rc; - EXP_CHECK_DT_OP(exp, preprw); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->preprw) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, preprw); rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote, @@ -1021,13 +1098,23 @@ static inline int obd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, struct obdo *oa, int objcount, struct obd_ioobj *obj, struct niobuf_remote *rnb, int pages, - struct niobuf_local *local, int rc) + struct niobuf_local *local, int orig_rc) { - EXP_CHECK_DT_OP(exp, commitrw); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->commitrw) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, commitrw); rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj, - rnb, pages, local, rc); + rnb, pages, local, orig_rc); return rc; } @@ -1036,7 +1123,15 @@ static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, { int rc; - EXP_CHECK_DT_OP(exp, iocontrol); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->iocontrol) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, iocontrol); rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg); @@ -1108,7 +1203,15 @@ static inline int obd_quotactl(struct obd_export *exp, { int rc; - EXP_CHECK_DT_OP(exp, quotactl); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->quotactl) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, quotactl); rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl); @@ -1129,7 +1232,7 @@ static inline int obd_health_check(const struct lu_env *env, int rc; /* don't use EXP_CHECK_DT_OP, because NULL method is normal here */ - if (!obd || !OBT(obd)) { + if (!obd || !obd->obd_type) { CERROR("cleaned up obd\n"); return -EOPNOTSUPP; } @@ -1166,7 +1269,9 @@ static inline int md_get_root(struct obd_export *exp, const char *fileset, { int rc; - EXP_CHECK_MD_OP(exp, get_root); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, get_root); rc = MDP(exp->exp_obd, get_root)(exp, fileset, fid); return rc; @@ -1177,7 +1282,9 @@ static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, getattr); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, getattr); rc = MDP(exp->exp_obd, getattr)(exp, op_data, request); return rc; @@ -1188,7 +1295,9 @@ static inline int md_null_inode(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, null_inode); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, null_inode); rc = MDP(exp->exp_obd, null_inode)(exp, fid); return rc; @@ -1200,7 +1309,9 @@ static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, close); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, close); rc = MDP(exp->exp_obd, close)(exp, op_data, mod, request); return rc; @@ -1213,7 +1324,9 @@ static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, create); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, create); rc = MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode, uid, gid, cap_effective, rdev, request); @@ -1229,7 +1342,9 @@ static inline int md_enqueue(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, enqueue); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, enqueue); rc = MDP(exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh, extra_lock_flags); @@ -1242,7 +1357,9 @@ static inline int md_getattr_name(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, getattr_name); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, getattr_name); rc = MDP(exp->exp_obd, getattr_name)(exp, op_data, request); return rc; @@ -1257,7 +1374,9 @@ static inline int md_intent_lock(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, intent_lock); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, intent_lock); rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, it, reqp, cb_blocking, extra_lock_flags); @@ -1269,7 +1388,9 @@ static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, link); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, link); rc = MDP(exp->exp_obd, link)(exp, op_data, request); return rc; @@ -1281,7 +1402,9 @@ static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, rename); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, rename); rc = MDP(exp->exp_obd, rename)(exp, op_data, old, oldlen, new, newlen, request); @@ -1294,7 +1417,9 @@ static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, setattr); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, setattr); rc = MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, request); return rc; @@ -1305,7 +1430,9 @@ static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid, { int rc; - EXP_CHECK_MD_OP(exp, sync); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, sync); rc = MDP(exp->exp_obd, sync)(exp, fid, request); return rc; @@ -1319,7 +1446,9 @@ static inline int md_read_page(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, read_page); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, read_page); rc = MDP(exp->exp_obd, read_page)(exp, op_data, cb_op, hash_offset, ppage); @@ -1331,7 +1460,9 @@ static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, unlink); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, unlink); rc = MDP(exp->exp_obd, unlink)(exp, op_data, request); return rc; @@ -1343,7 +1474,11 @@ static inline int md_get_lustre_md(struct obd_export *exp, struct obd_export *md_exp, struct lustre_md *md) { - EXP_CHECK_MD_OP(exp, get_lustre_md); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, get_lustre_md); return MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md); } @@ -1351,7 +1486,11 @@ static inline int md_get_lustre_md(struct obd_export *exp, static inline int md_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { - EXP_CHECK_MD_OP(exp, free_lustre_md); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, free_lustre_md); return MDP(exp->exp_obd, free_lustre_md)(exp, md); } @@ -1361,7 +1500,11 @@ static inline int md_merge_attr(struct obd_export *exp, struct cl_attr *attr, ldlm_blocking_callback cb) { - EXP_CHECK_MD_OP(exp, merge_attr); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, merge_attr); return MDP(exp->exp_obd, merge_attr)(exp, lsm, attr, cb); } @@ -1372,7 +1515,11 @@ static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid, unsigned int xattr_flags, u32 suppgid, struct ptlrpc_request **request) { - EXP_CHECK_MD_OP(exp, setxattr); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, setxattr); return MDP(exp->exp_obd, setxattr)(exp, fid, obd_md_valid, name, value, value_size, xattr_flags, @@ -1383,7 +1530,11 @@ static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid, u64 obd_md_valid, const char *name, size_t buf_size, struct ptlrpc_request **req) { - EXP_CHECK_MD_OP(exp, getxattr); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, getxattr); return MDP(exp->exp_obd, getxattr)(exp, fid, obd_md_valid, name, buf_size, req); @@ -1393,7 +1544,11 @@ static inline int md_set_open_replay_data(struct obd_export *exp, struct obd_client_handle *och, struct lookup_intent *it) { - EXP_CHECK_MD_OP(exp, set_open_replay_data); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, set_open_replay_data); return MDP(exp->exp_obd, set_open_replay_data)(exp, och, it); } @@ -1401,7 +1556,11 @@ static inline int md_set_open_replay_data(struct obd_export *exp, static inline int md_clear_open_replay_data(struct obd_export *exp, struct obd_client_handle *och) { - EXP_CHECK_MD_OP(exp, clear_open_replay_data); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, clear_open_replay_data); return MDP(exp->exp_obd, clear_open_replay_data)(exp, och); } @@ -1410,7 +1569,11 @@ static inline int md_set_lock_data(struct obd_export *exp, const struct lustre_handle *lockh, void *data, __u64 *bits) { - EXP_CHECK_MD_OP(exp, set_lock_data); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, set_lock_data); return MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits); } @@ -1424,7 +1587,9 @@ static inline int md_cancel_unused(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, cancel_unused); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, cancel_unused); rc = MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode, @@ -1439,7 +1604,11 @@ static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags, enum ldlm_mode mode, struct lustre_handle *lockh) { - EXP_CHECK_MD_OP(exp, lock_match); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, lock_match); return MDP(exp->exp_obd, lock_match)(exp, flags, fid, type, policy, mode, lockh); @@ -1448,7 +1617,11 @@ static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags, static inline int md_init_ea_size(struct obd_export *exp, u32 easize, u32 def_asize) { - EXP_CHECK_MD_OP(exp, init_ea_size); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, init_ea_size); return MDP(exp->exp_obd, init_ea_size)(exp, easize, def_asize); } @@ -1458,7 +1631,9 @@ static inline int md_intent_getattr_async(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, intent_getattr_async); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, intent_getattr_async); rc = MDP(exp->exp_obd, intent_getattr_async)(exp, minfo); return rc; @@ -1470,7 +1645,9 @@ static inline int md_revalidate_lock(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, revalidate_lock); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, revalidate_lock); rc = MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits); return rc; @@ -1483,7 +1660,9 @@ static inline int md_get_fid_from_lsm(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, get_fid_from_lsm); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, get_fid_from_lsm); rc = MDP(exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen, fid); return rc; @@ -1502,7 +1681,9 @@ static inline int md_unpackmd(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, unpackmd); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, unpackmd); rc = MDP(exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size); return rc; diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 26aea11..e074b6e 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -93,8 +93,8 @@ int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt) !!obd->obd_stopping, !!obd->obd_set_up); /* cleanup the llog ctxt here */ - if (CTXTP(ctxt, cleanup)) - rc = CTXTP(ctxt, cleanup)(env, ctxt); + if (ctxt->loc_logops->lop_cleanup) + rc = ctxt->loc_logops->lop_cleanup(env, ctxt); llog_ctxt_destroy(ctxt); wake_up(&olg->olg_waitq); -- 1.8.3.1
PATCH 4/8 lustre: obdclass: cleanup obd_class.h defines
Quoted 4 lines · Alexey Lyashkov
NAK.
Please use same as original patch
' structniobuf_local*local, intorig_rc' vs ' structniobuf_local*local, const intorig_rc'.
I've added the "const" and appled the patch. Thanks.
NeilBrown
Quoted 977 lines
?On 17/09/2018, 20:31, "James Simmons" <[email protected]> wrote:
From: Ben Evans <[email protected]> Get rid of OBT and CTXTP defines. Remove OBD_CHECK_DT_OP Convert EXP_CHECK_MD_OP into a function. Remove CTXT_CHECK_OP. Signed-off-by: Ben Evans <[email protected]> Signed-off-by: Alexey Lyashkov <[email protected]> WC-bug-id: https://jira.whamcloud.com/browse/LU-9855 Reviewed-on: https://review.whamcloud.com/29286 WC-bug-id: https://jira.whamcloud.com/browse/LU-11169 Reviewed-on: https://review.whamcloud.com/#/c/32906 Reviewed-by: John L. Hammond <[email protected]> Reviewed-by: Steve Guminski <[email protected]> Reviewed-by: James Simmons <[email protected]> Reviewed-by: Oleg Drokin <[email protected]> Signed-off-by: James Simmons <[email protected]> --- drivers/staging/lustre/lustre/include/obd_class.h | 437 +++++++++++++++------- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 4 +- 2 files changed, 311 insertions(+), 130 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index c6fb2e1..aab1092 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -303,10 +303,8 @@ static inline int lprocfs_climp_check(struct obd_device *obd) void obdo_to_ioobj(const struct obdo *oa, struct obd_ioobj *ioobj); -#define OBT(dev) ((dev)->obd_type) #define OBP(dev, op) ((dev)->obd_type->typ_dt_ops->op) #define MDP(dev, op) ((dev)->obd_type->typ_md_ops->op) -#define CTXTP(ctxt, op) ((ctxt)->loc_logops->lop_##op) /* * Ensure obd_setup: used for cleanup which must be called @@ -393,56 +391,16 @@ static inline int obd_check_dev_active(struct obd_device *obd) } \ } while (0) -#define EXP_CHECK_MD_OP(exp, op) \ -do { \ - if (!(exp)) { \ - CERROR("obd_" #op ": NULL export\n"); \ - return -ENODEV; \ - } \ - if (!(exp)->exp_obd || !OBT((exp)->exp_obd)) { \ - CERROR("obd_" #op ": cleaned up obd\n"); \ - return -EOPNOTSUPP; \ - } \ - if (!OBT((exp)->exp_obd) || !MDP((exp)->exp_obd, op)) { \ - CERROR("%s: obd_" #op ": dev %d no operation\n",\ - (exp)->exp_obd->obd_name, \ - (exp)->exp_obd->obd_minor); \ - return -EOPNOTSUPP; \ - } \ -} while (0) - -#define OBD_CHECK_DT_OP(obd, op, err) \ -do { \ - if (!OBT(obd) || !OBP((obd), op)) { \ - if (err) \ - CERROR("%s: no obd_" #op " operation\n", \ - obd->obd_name); \ - return err; \ - } \ -} while (0) +static inline int exp_check_ops(struct obd_export *exp) +{ + if (!exp) + return -ENODEV; -#define EXP_CHECK_DT_OP(exp, op) \ -do { \ - if (!(exp)) { \ - CERROR("obd_" #op ": NULL export\n"); \ - return -ENODEV; \ - } \ - if (!(exp)->exp_obd || !OBT((exp)->exp_obd)) { \ - CERROR("obd_" #op ": cleaned up obd\n"); \ - return -EOPNOTSUPP; \ - } \ - OBD_CHECK_DT_OP((exp)->exp_obd, op, -EOPNOTSUPP); \ -} while (0) + if (!exp->exp_obd || !exp->exp_obd->obd_type) + return -EOPNOTSUPP; -#define CTXT_CHECK_OP(ctxt, op, err) \ -do { \ - if (!OBT(ctxt->loc_obd) || !CTXTP((ctxt), op)) { \ - if (err) \ - CERROR("%s: no lop_" #op " operation\n", \ - ctxt->loc_obd->obd_name); \ - return err; \ - } \ -} while (0) + return 0; +} static inline int class_devno_max(void) { @@ -455,7 +413,15 @@ static inline int obd_get_info(const struct lu_env *env, { int rc; - EXP_CHECK_DT_OP(exp, get_info); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->get_info) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, get_info); rc = OBP(exp->exp_obd, get_info)(env, exp, keylen, key, vallen, val); @@ -469,7 +435,15 @@ static inline int obd_set_info_async(const struct lu_env *env, { int rc; - EXP_CHECK_DT_OP(exp, set_info_async); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->set_info_async) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, set_info_async); rc = OBP(exp->exp_obd, set_info_async)(env, exp, keylen, key, vallen, @@ -484,14 +458,14 @@ static inline int obd_set_info_async(const struct lu_env *env, * pieces of configuration process are still based on obd devices. * * Specifically, lu_device_type_operations::ldto_device_alloc() methods fully - * subsume ->o_setup() methods of obd devices they replace. The same for - * lu_device_operations::ldo_process_config() and ->o_process_config(). As a + * subsume ->setup() methods of obd devices they replace. The same for + * lu_device_operations::ldo_process_config() and ->process_config(). As a * result, obd_setup() and obd_process_config() branch and call one XOR * another. * * Yet neither lu_device_type_operations::ldto_device_fini() nor * lu_device_type_operations::ldto_device_free() fully implement the - * functionality of ->o_precleanup() and ->o_cleanup() they override. Hence, + * functionality of ->precleanup() and ->o_cleanup() they override. Hence, * obd_precleanup() and obd_cleanup() call both lu_device and obd operations. */ @@ -527,7 +501,11 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) lu_context_fini(&session_ctx); } else { - OBD_CHECK_DT_OP(obd, setup, -EOPNOTSUPP); + if (!obd->obd_type->typ_dt_ops->setup) { + CERROR("%s: no %s operation\n", obd->obd_name, + __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, setup); rc = OBP(obd, setup)(obd, cfg); } @@ -549,7 +527,9 @@ static inline int obd_precleanup(struct obd_device *obd) lu_env_fini(&env); } } - OBD_CHECK_DT_OP(obd, precleanup, 0); + if (!obd->obd_type->typ_dt_ops->precleanup) + return 0; + OBD_COUNTER_INCREMENT(obd, precleanup); rc = OBP(obd, precleanup)(obd); @@ -572,7 +552,9 @@ static inline int obd_cleanup(struct obd_device *obd) obd->obd_lu_dev = NULL; } } - OBD_CHECK_DT_OP(obd, cleanup, 0); + if (!obd->obd_type->typ_dt_ops->cleanup) + return 0; + OBD_COUNTER_INCREMENT(obd, cleanup); rc = OBP(obd, cleanup)(obd); @@ -599,8 +581,8 @@ static inline void obd_cleanup_client_import(struct obd_device *obd) up_write(&obd->u.cli.cl_sem); } -static inline int -obd_process_config(struct obd_device *obd, int datalen, void *data) +static inline int obd_process_config(struct obd_device *obd, int datalen, + void *data) { struct lu_device_type *ldt = obd->obd_type->typ_lu; struct lu_device *d = obd->obd_lu_dev; @@ -616,7 +598,11 @@ static inline void obd_cleanup_client_import(struct obd_device *obd) lu_env_fini(&env); } } else { - OBD_CHECK_DT_OP(obd, process_config, -EOPNOTSUPP); + if (!obd->obd_type->typ_dt_ops->process_config) { + CERROR("%s: no %s operation\n", + obd->obd_name, __func__); + return -EOPNOTSUPP; + } rc = OBP(obd, process_config)(obd, datalen, data); } OBD_COUNTER_INCREMENT(obd, process_config); @@ -630,7 +616,15 @@ static inline int obd_create(const struct lu_env *env, struct obd_export *exp, { int rc; - EXP_CHECK_DT_OP(exp, create); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->create) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -EOPNOTSUPP; + } EXP_COUNTER_INCREMENT(exp, create); rc = OBP(exp->exp_obd, create)(env, exp, obdo); @@ -642,7 +636,15 @@ static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, { int rc; - EXP_CHECK_DT_OP(exp, destroy); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->destroy) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -EOPNOTSUPP; + } EXP_COUNTER_INCREMENT(exp, destroy); rc = OBP(exp->exp_obd, destroy)(env, exp, obdo); @@ -654,7 +656,15 @@ static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, { int rc; - EXP_CHECK_DT_OP(exp, getattr); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->getattr) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -EOPNOTSUPP; + } EXP_COUNTER_INCREMENT(exp, getattr); rc = OBP(exp->exp_obd, getattr)(env, exp, oa); @@ -666,7 +676,15 @@ static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, { int rc; - EXP_CHECK_DT_OP(exp, setattr); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->setattr) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -EOPNOTSUPP; + } EXP_COUNTER_INCREMENT(exp, setattr); rc = OBP(exp->exp_obd, setattr)(env, exp, oa); @@ -682,7 +700,11 @@ static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, rc = obd_check_dev_active(obd); if (rc) return rc; - OBD_CHECK_DT_OP(obd, add_conn, -EOPNOTSUPP); + + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->add_conn) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, add_conn); rc = OBP(obd, add_conn)(imp, uuid, priority); @@ -697,7 +719,11 @@ static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) rc = obd_check_dev_active(obd); if (rc) return rc; - OBD_CHECK_DT_OP(obd, del_conn, -EOPNOTSUPP); + + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->del_conn) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, del_conn); rc = OBP(obd, del_conn)(imp, uuid); @@ -708,7 +734,10 @@ static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) { struct obd_uuid *uuid; - OBD_CHECK_DT_OP(exp->exp_obd, get_uuid, NULL); + if (!exp->exp_obd->obd_type || + !exp->exp_obd->obd_type->typ_dt_ops->get_uuid) + return NULL; + EXP_COUNTER_INCREMENT(exp, get_uuid); uuid = OBP(exp->exp_obd, get_uuid)(exp); @@ -727,16 +756,18 @@ static inline int obd_connect(const struct lu_env *env, struct obd_connect_data *data, void *localdata) { + /* for post-condition check */ + u64 ocf = data ? data->ocd_connect_flags : 0; int rc; - __u64 ocf = data ? data->ocd_connect_flags : 0; /* - * for post-condition - * check - */ rc = obd_check_dev_active(obd); if (rc) return rc; - OBD_CHECK_DT_OP(obd, connect, -EOPNOTSUPP); + + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->connect) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, connect); rc = OBP(obd, connect)(env, exp, obd, cluuid, data, localdata); @@ -753,13 +784,16 @@ static inline int obd_reconnect(const struct lu_env *env, struct obd_connect_data *d, void *localdata) { + u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition check */ int rc; - __u64 ocf = d ? d->ocd_connect_flags : 0; /* for post-condition check */ rc = obd_check_dev_active(obd); if (rc) return rc; - OBD_CHECK_DT_OP(obd, reconnect, 0); + + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->reconnect) + return 0; + OBD_COUNTER_INCREMENT(obd, reconnect); rc = OBP(obd, reconnect)(env, exp, obd, cluuid, d, localdata); @@ -772,7 +806,15 @@ static inline int obd_disconnect(struct obd_export *exp) { int rc; - EXP_CHECK_DT_OP(exp, disconnect); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->disconnect) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, disconnect); rc = OBP(exp->exp_obd, disconnect)(exp); @@ -784,7 +826,8 @@ static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, { int rc; - OBD_CHECK_DT_OP(obd, fid_init, 0); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->fid_init) + return 0; OBD_COUNTER_INCREMENT(obd, fid_init); rc = OBP(obd, fid_init)(obd, exp, type); @@ -795,7 +838,8 @@ static inline int obd_fid_fini(struct obd_device *obd) { int rc; - OBD_CHECK_DT_OP(obd, fid_fini, 0); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->fid_fini) + return 0; OBD_COUNTER_INCREMENT(obd, fid_fini); rc = OBP(obd, fid_fini)(obd); @@ -809,7 +853,15 @@ static inline int obd_fid_alloc(const struct lu_env *env, { int rc; - EXP_CHECK_DT_OP(exp, fid_alloc); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->fid_alloc) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, fid_alloc); rc = OBP(exp->exp_obd, fid_alloc)(env, exp, fid, op_data); @@ -820,7 +872,10 @@ static inline int obd_pool_new(struct obd_device *obd, char *poolname) { int rc; - OBD_CHECK_DT_OP(obd, pool_new, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->pool_new) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, pool_new); rc = OBP(obd, pool_new)(obd, poolname); @@ -831,20 +886,25 @@ static inline int obd_pool_del(struct obd_device *obd, char *poolname) { int rc; - OBD_CHECK_DT_OP(obd, pool_del, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->pool_del) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, pool_del); rc = OBP(obd, pool_del)(obd, poolname); return rc; } -static inline int obd_pool_add(struct obd_device *obd, - char *poolname, +static inline int obd_pool_add(struct obd_device *obd, char *poolname, char *ostname) { int rc; - OBD_CHECK_DT_OP(obd, pool_add, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->pool_add) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, pool_add); rc = OBP(obd, pool_add)(obd, poolname, ostname); @@ -857,7 +917,10 @@ static inline int obd_pool_rem(struct obd_device *obd, { int rc; - OBD_CHECK_DT_OP(obd, pool_rem, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->pool_rem) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, pool_rem); rc = OBP(obd, pool_rem)(obd, poolname, ostname); @@ -866,7 +929,7 @@ static inline int obd_pool_rem(struct obd_device *obd, static inline void obd_getref(struct obd_device *obd) { - if (OBT(obd) && OBP(obd, getref)) { + if (obd->obd_type && OBP(obd, getref)) { OBD_COUNTER_INCREMENT(obd, getref); OBP(obd, getref)(obd); } @@ -874,7 +937,7 @@ static inline void obd_getref(struct obd_device *obd) static inline void obd_putref(struct obd_device *obd) { - if (OBT(obd) && OBP(obd, putref)) { + if (obd->obd_type && OBP(obd, putref)) { OBD_COUNTER_INCREMENT(obd, putref); OBP(obd, putref)(obd); } @@ -884,7 +947,7 @@ static inline int obd_init_export(struct obd_export *exp) { int rc = 0; - if ((exp)->exp_obd && OBT((exp)->exp_obd) && + if (exp->exp_obd && exp->exp_obd->obd_type && OBP((exp)->exp_obd, init_export)) rc = OBP(exp->exp_obd, init_export)(exp); return rc; @@ -892,7 +955,7 @@ static inline int obd_init_export(struct obd_export *exp) static inline int obd_destroy_export(struct obd_export *exp) { - if ((exp)->exp_obd && OBT((exp)->exp_obd) && + if (exp->exp_obd && exp->exp_obd->obd_type && OBP((exp)->exp_obd, destroy_export)) OBP(exp->exp_obd, destroy_export)(exp); return 0; @@ -915,7 +978,10 @@ static inline int obd_statfs_async(struct obd_export *exp, return -EINVAL; obd = exp->exp_obd; - OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->statfs) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, statfs); CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n", @@ -969,13 +1035,16 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *osfs, __u64 max_age, __u32 flags) { - int rc = 0; struct obd_device *obd = exp->exp_obd; + int rc = 0; if (!obd) return -EINVAL; - OBD_CHECK_DT_OP(obd, statfs, -EOPNOTSUPP); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->statfs) { + CERROR("%s: no %s operation\n", obd->obd_name, __func__); + return -EOPNOTSUPP; + } OBD_COUNTER_INCREMENT(obd, statfs); CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n", @@ -1009,7 +1078,15 @@ static inline int obd_preprw(const struct lu_env *env, int cmd, { int rc; - EXP_CHECK_DT_OP(exp, preprw); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->preprw) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, preprw); rc = OBP(exp->exp_obd, preprw)(env, cmd, exp, oa, objcount, obj, remote, @@ -1021,13 +1098,23 @@ static inline int obd_commitrw(const struct lu_env *env, int cmd, struct obd_export *exp, struct obdo *oa, int objcount, struct obd_ioobj *obj, struct niobuf_remote *rnb, int pages, - struct niobuf_local *local, int rc) + struct niobuf_local *local, int orig_rc) { - EXP_CHECK_DT_OP(exp, commitrw); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->commitrw) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, commitrw); rc = OBP(exp->exp_obd, commitrw)(env, cmd, exp, oa, objcount, obj, - rnb, pages, local, rc); + rnb, pages, local, orig_rc); return rc; } @@ -1036,7 +1123,15 @@ static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, { int rc; - EXP_CHECK_DT_OP(exp, iocontrol); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->iocontrol) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, iocontrol); rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg); @@ -1108,7 +1203,15 @@ static inline int obd_quotactl(struct obd_export *exp, { int rc; - EXP_CHECK_DT_OP(exp, quotactl); + rc = exp_check_ops(exp); + if (rc) + return rc; + + if (!exp->exp_obd->obd_type->typ_dt_ops->quotactl) { + CERROR("%s: no %s operation\n", + exp->exp_obd->obd_name, __func__); + return -ENOTSUPP; + } EXP_COUNTER_INCREMENT(exp, quotactl); rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl); @@ -1129,7 +1232,7 @@ static inline int obd_health_check(const struct lu_env *env, int rc; /* don't use EXP_CHECK_DT_OP, because NULL method is normal here */ - if (!obd || !OBT(obd)) { + if (!obd || !obd->obd_type) { CERROR("cleaned up obd\n"); return -EOPNOTSUPP; } @@ -1166,7 +1269,9 @@ static inline int md_get_root(struct obd_export *exp, const char *fileset, { int rc; - EXP_CHECK_MD_OP(exp, get_root); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, get_root); rc = MDP(exp->exp_obd, get_root)(exp, fileset, fid); return rc; @@ -1177,7 +1282,9 @@ static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, getattr); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, getattr); rc = MDP(exp->exp_obd, getattr)(exp, op_data, request); return rc; @@ -1188,7 +1295,9 @@ static inline int md_null_inode(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, null_inode); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, null_inode); rc = MDP(exp->exp_obd, null_inode)(exp, fid); return rc; @@ -1200,7 +1309,9 @@ static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, close); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, close); rc = MDP(exp->exp_obd, close)(exp, op_data, mod, request); return rc; @@ -1213,7 +1324,9 @@ static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, create); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, create); rc = MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode, uid, gid, cap_effective, rdev, request); @@ -1229,7 +1342,9 @@ static inline int md_enqueue(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, enqueue); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, enqueue); rc = MDP(exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh, extra_lock_flags); @@ -1242,7 +1357,9 @@ static inline int md_getattr_name(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, getattr_name); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, getattr_name); rc = MDP(exp->exp_obd, getattr_name)(exp, op_data, request); return rc; @@ -1257,7 +1374,9 @@ static inline int md_intent_lock(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, intent_lock); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, intent_lock); rc = MDP(exp->exp_obd, intent_lock)(exp, op_data, it, reqp, cb_blocking, extra_lock_flags); @@ -1269,7 +1388,9 @@ static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, link); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, link); rc = MDP(exp->exp_obd, link)(exp, op_data, request); return rc; @@ -1281,7 +1402,9 @@ static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, rename); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, rename); rc = MDP(exp->exp_obd, rename)(exp, op_data, old, oldlen, new, newlen, request); @@ -1294,7 +1417,9 @@ static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, setattr); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, setattr); rc = MDP(exp->exp_obd, setattr)(exp, op_data, ea, ealen, request); return rc; @@ -1305,7 +1430,9 @@ static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid, { int rc; - EXP_CHECK_MD_OP(exp, sync); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, sync); rc = MDP(exp->exp_obd, sync)(exp, fid, request); return rc; @@ -1319,7 +1446,9 @@ static inline int md_read_page(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, read_page); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, read_page); rc = MDP(exp->exp_obd, read_page)(exp, op_data, cb_op, hash_offset, ppage); @@ -1331,7 +1460,9 @@ static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, { int rc; - EXP_CHECK_MD_OP(exp, unlink); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, unlink); rc = MDP(exp->exp_obd, unlink)(exp, op_data, request); return rc; @@ -1343,7 +1474,11 @@ static inline int md_get_lustre_md(struct obd_export *exp, struct obd_export *md_exp, struct lustre_md *md) { - EXP_CHECK_MD_OP(exp, get_lustre_md); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, get_lustre_md); return MDP(exp->exp_obd, get_lustre_md)(exp, req, dt_exp, md_exp, md); } @@ -1351,7 +1486,11 @@ static inline int md_get_lustre_md(struct obd_export *exp, static inline int md_free_lustre_md(struct obd_export *exp, struct lustre_md *md) { - EXP_CHECK_MD_OP(exp, free_lustre_md); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, free_lustre_md); return MDP(exp->exp_obd, free_lustre_md)(exp, md); } @@ -1361,7 +1500,11 @@ static inline int md_merge_attr(struct obd_export *exp, struct cl_attr *attr, ldlm_blocking_callback cb) { - EXP_CHECK_MD_OP(exp, merge_attr); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, merge_attr); return MDP(exp->exp_obd, merge_attr)(exp, lsm, attr, cb); } @@ -1372,7 +1515,11 @@ static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid, unsigned int xattr_flags, u32 suppgid, struct ptlrpc_request **request) { - EXP_CHECK_MD_OP(exp, setxattr); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, setxattr); return MDP(exp->exp_obd, setxattr)(exp, fid, obd_md_valid, name, value, value_size, xattr_flags, @@ -1383,7 +1530,11 @@ static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid, u64 obd_md_valid, const char *name, size_t buf_size, struct ptlrpc_request **req) { - EXP_CHECK_MD_OP(exp, getxattr); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, getxattr); return MDP(exp->exp_obd, getxattr)(exp, fid, obd_md_valid, name, buf_size, req); @@ -1393,7 +1544,11 @@ static inline int md_set_open_replay_data(struct obd_export *exp, struct obd_client_handle *och, struct lookup_intent *it) { - EXP_CHECK_MD_OP(exp, set_open_replay_data); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, set_open_replay_data); return MDP(exp->exp_obd, set_open_replay_data)(exp, och, it); } @@ -1401,7 +1556,11 @@ static inline int md_set_open_replay_data(struct obd_export *exp, static inline int md_clear_open_replay_data(struct obd_export *exp, struct obd_client_handle *och) { - EXP_CHECK_MD_OP(exp, clear_open_replay_data); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, clear_open_replay_data); return MDP(exp->exp_obd, clear_open_replay_data)(exp, och); } @@ -1410,7 +1569,11 @@ static inline int md_set_lock_data(struct obd_export *exp, const struct lustre_handle *lockh, void *data, __u64 *bits) { - EXP_CHECK_MD_OP(exp, set_lock_data); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, set_lock_data); return MDP(exp->exp_obd, set_lock_data)(exp, lockh, data, bits); } @@ -1424,7 +1587,9 @@ static inline int md_cancel_unused(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, cancel_unused); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, cancel_unused); rc = MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode, @@ -1439,7 +1604,11 @@ static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags, enum ldlm_mode mode, struct lustre_handle *lockh) { - EXP_CHECK_MD_OP(exp, lock_match); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, lock_match); return MDP(exp->exp_obd, lock_match)(exp, flags, fid, type, policy, mode, lockh); @@ -1448,7 +1617,11 @@ static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags, static inline int md_init_ea_size(struct obd_export *exp, u32 easize, u32 def_asize) { - EXP_CHECK_MD_OP(exp, init_ea_size); + int rc; + + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, init_ea_size); return MDP(exp->exp_obd, init_ea_size)(exp, easize, def_asize); } @@ -1458,7 +1631,9 @@ static inline int md_intent_getattr_async(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, intent_getattr_async); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, intent_getattr_async); rc = MDP(exp->exp_obd, intent_getattr_async)(exp, minfo); return rc; @@ -1470,7 +1645,9 @@ static inline int md_revalidate_lock(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, revalidate_lock); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, revalidate_lock); rc = MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits); return rc; @@ -1483,7 +1660,9 @@ static inline int md_get_fid_from_lsm(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, get_fid_from_lsm); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, get_fid_from_lsm); rc = MDP(exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen, fid); return rc; @@ -1502,7 +1681,9 @@ static inline int md_unpackmd(struct obd_export *exp, { int rc; - EXP_CHECK_MD_OP(exp, unpackmd); + rc = exp_check_ops(exp); + if (rc) + return rc; EXP_MD_COUNTER_INCREMENT(exp, unpackmd); rc = MDP(exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size); return rc; diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c index 26aea11..e074b6e 100644 --- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c @@ -93,8 +93,8 @@ int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt) !!obd->obd_stopping, !!obd->obd_set_up); /* cleanup the llog ctxt here */ - if (CTXTP(ctxt, cleanup))
Quoted 10 lines
- rc = CTXTP(ctxt, cleanup)(env, ctxt);
+ if (ctxt->loc_logops->lop_cleanup)
+ rc = ctxt->loc_logops->lop_cleanup(env, ctxt);
llog_ctxt_destroy(ctxt);
wake_up(&olg->olg_waitq);
--
1.8.3.1-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180924/273463a6/attachment-0001.sig>
PATCH 5/8 lustre: obd: remove obd_{get,put}ref()
In reply to James SimmonsFrom: "John L. Hammond" <[email protected]>
obd_getref() and obd_putref() are only used in the lov layer and only implemented by the lov layer. So they can be removed in favor of direct calls. Rename lov_{get,put}ref() to lov_tgts_{get,put}ref() since they do not manage references on the lov device but on its targets array.
WC-bug-id: https://jira.whamcloud.com/browse/LU-11051
Reviewed-on: https://review.whamcloud.com/32529
--- drivers/staging/lustre/lustre/include/obd.h | 7 ---- drivers/staging/lustre/lustre/include/obd_class.h | 16 --------- drivers/staging/lustre/lustre/lov/lov_dev.c | 12 ++++--- drivers/staging/lustre/lustre/lov/lov_internal.h | 2 ++ drivers/staging/lustre/lustre/lov/lov_obd.c | 44 +++++++++++------------ drivers/staging/lustre/lustre/lov/lov_pool.c | 10 +++--- drivers/staging/lustre/lustre/lov/lov_request.c | 4 +-- 7 files changed, 39 insertions(+), 56 deletions(-)
drivers/staging/lustre/lustre/include/obd.h +0 -7
@@ -882,13 +882,6 @@ struct obd_ops { char *ostname);int (*pool_rem)(struct obd_device *obd,char *poolname,char *ostname); -void (*getref)(struct obd_device *obd); -void (*putref)(struct obd_device *obd); -/* -* NOTE: If adding ops, add another LPROCFS_OBD_OP_INIT() line -* to lprocfs_alloc_obd_stats() in obdclass/lprocfs_status.c. -* Also, add a wrapper function in include/linux/obd_class.h. -*/ };/* lmv structures */
drivers/staging/lustre/lustre/include/obd_class.h +0 -16
@@ -927,22 +927,6 @@ static inline int obd_pool_rem(struct obd_device *obd,return rc; } -static inline void obd_getref (struct obd_device *obd) -{ -if (obd->obd_type &&OBP (obd, getref)) { -OBD_COUNTER_INCREMENT (obd, getref); -OBP (obd, getref)(obd); - } -} - -static inline void obd_putref (struct obd_device *obd) -{ -if (obd->obd_type &&OBP (obd, putref)) { -OBD_COUNTER_INCREMENT (obd, putref); -OBP (obd, putref)(obd); - } -} -static inline int obd_init_export (struct obd_export *exp) {int rc =0 ;
drivers/staging/lustre/lustre/lov/lov_dev.c +8 -4
@@ -266,7 +266,7 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev,struct cl_device *cl;int rc; -obd_getref (obd); +lov_tgts_getref (obd); tgt = obd->u.lov.lov_tgts[index];
@@ -291,7 +291,9 @@ static int lov_cl_add_target(const struct lu_env *env, struct lu_device *dev, rc =PTR_ERR (cl); } } -obd_putref (obd); + +lov_tgts_putref (obd); +return rc; }
@@ -304,7 +306,7 @@ static int lov_process_config(const struct lu_env *env,int gen;__u32 index; -obd_getref (obd); +lov_tgts_getref (obd); cmd = cfg->lcfg_command; rc =lov_process_config_base (d->ld_obd, cfg, &index, &gen);
@@ -321,7 +323,9 @@ static int lov_process_config(const struct lu_env *env,break ; } } -obd_putref (obd); + +lov_tgts_putref (obd); +return rc; }
drivers/staging/lustre/lustre/lov/lov_internal.h +2 -0
@@ -207,6 +207,8 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,int lov_fini_statfs_set (struct lov_request_set *set);/* lov_obd.c */ +void lov_tgts_getref (struct obd_device *obd); +void lov_tgts_putref (struct obd_device *obd);void lov_stripe_lock (struct lov_stripe_md *md);void lov_stripe_unlock (struct lov_stripe_md *md);void lov_fix_desc (struct lov_desc *desc);
drivers/staging/lustre/lustre/lov/lov_obd.c +21 -23
171 lines not on this page · raw message
drivers/staging/lustre/lustre/lov/lov_pool.c +6 -4
@@ -470,7 +470,7 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname)obd_str2uuid (&ost_uuid, ostname);/* search ost in lov array */ -obd_getref (obd); +lov_tgts_getref (obd);for (lov_idx =0 ; lov_idx < lov->desc.ld_tgt_count; lov_idx++) {if (!lov->lov_tgts[lov_idx])continue ;
@@ -492,8 +492,9 @@ int lov_pool_add(struct obd_device *obd, char *poolname, char *ostname) ostname, poolname, pool_tgt_count(pool)); out: -obd_putref (obd); +lov_tgts_putref (obd);lov_pool_putref (pool); +return rc; }
@@ -517,7 +518,7 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname)obd_str2uuid (&ost_uuid, ostname); -obd_getref (obd); +lov_tgts_getref (obd);/* search ost in lov array, to get index */ for (lov_idx =0 ; lov_idx < lov->desc.ld_tgt_count; lov_idx++) {if (!lov->lov_tgts[lov_idx])
@@ -540,7 +541,8 @@ int lov_pool_remove(struct obd_device *obd, char *poolname, char *ostname) poolname); out: -obd_putref (obd); +lov_tgts_putref (obd);lov_pool_putref (pool); +return rc; }
drivers/staging/lustre/lustre/lov/lov_request.c +2 -2
@@ -266,7 +266,7 @@ static int cb_statfs_update(void *cookie, int rc)if (rc) goto out; -obd_getref (lovobd); +lov_tgts_getref (lovobd); tgt = lov->lov_tgts[lovreq->rq_idx];if (!tgt || !tgt->ltd_active) goto out_update;
@@ -280,7 +280,7 @@ static int cb_statfs_update(void *cookie, int rc) out_update:lov_update_statfs (osfs, lov_sfs, success); -obd_putref (lovobd); +lov_tgts_putref (lovobd); out:return 0 ; }
Signature · 1 line
1.8.3.1
PATCH 6/8 lustre: obd: remove OBD ops based stats
In reply to James SimmonsFrom: "John L. Hammond" <[email protected]>
Stats maintained via the OBD operations wrappers (obd_setup(), obd_cleanup(), ...) are less and less interesting to the point that we should remove them. The only stats files affected by this are obdfilter.*.stats, obdfilter.*.exports.*.stats and obdecho.*.stats which are server side only.
WC-bug-id: https://jira.whamcloud.com/browse/LU-11052
Reviewed-on: https://review.whamcloud.com/32602
--- drivers/staging/lustre/lustre/include/obd.h | 1 - drivers/staging/lustre/lustre/include/obd_class.h | 66 +---------------------- 2 files changed, 2 insertions(+), 65 deletions(-)
drivers/staging/lustre/lustre/include/obd.h +0 -1
@@ -598,7 +598,6 @@ struct obd_device {/* Fields used by LProcFS */ struct lprocfs_stats *obd_stats; -unsigned int obd_cntr_base;struct lprocfs_stats *md_stats;unsigned int md_cntr_base;
drivers/staging/lustre/lustre/include/obd_class.h +2 -64
259 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 7/8 lustre: obdclass: restore md_stats code
In reply to James SimmonsOriginally the linux lustre client contained the md_stats code but no one used it at that time so some parts of the code was removed. The remaining md_stats code is layered in many levels of macros that make the code difficult to read as well as introduce undetected errors. This patch peels away the macro wrappers by replacing it with the function lprocfs_count_incr() which doesn't care about the order of the function pointers in struct md_ops as the original code did.
WC-bug-id: https://jira.whamcloud.com/browse/LU-9855
Reviewed-on: https://review.whamcloud.com/32822
--- .../staging/lustre/lustre/include/lprocfs_status.h | 5 +- drivers/staging/lustre/lustre/include/obd.h | 8 +- drivers/staging/lustre/lustre/include/obd_class.h | 233 +++++++++++---------- drivers/staging/lustre/lustre/obdclass/genops.c | 3 - .../lustre/lustre/obdclass/lprocfs_status.c | 66 +++++- 5 files changed, 192 insertions(+), 123 deletions(-)
drivers/staging/lustre/lustre/include/lprocfs_status.h +3 -2
@@ -442,11 +442,12 @@ __u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx, lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags);void lprocfs_clear_stats (struct lprocfs_stats *stats);void lprocfs_free_stats (struct lprocfs_stats **stats); +int ldebugfs_alloc_md_stats (struct obd_device *obddev, +unsigned int num_private_stats); +void ldebugfs_free_md_stats (struct obd_device *obddev);void lprocfs_counter_init (struct lprocfs_stats *stats,int index,unsigned int conf,const char *name,const char *units); -struct obd_export ; -int lprocfs_exp_cleanup (struct obd_export *exp);extern const struct file_operations lprocfs_stats_seq_fops;/* lprocfs_status.c */
drivers/staging/lustre/lustre/include/obd.h +1 -7
@@ -599,8 +599,7 @@ struct obd_device {/* Fields used by LProcFS */ struct lprocfs_stats *obd_stats; -struct lprocfs_stats *md_stats; -unsigned int md_cntr_base; +struct lprocfs_stats *obd_md_stats;struct dentry *obd_debugfs_entry;struct dentry *obd_svc_debugfs_entry;
@@ -1000,11 +999,6 @@ struct md_ops {int (*unpackmd)(struct obd_export *exp,struct lmv_stripe_md **plsm,const union lmv_mds_md *lmv,size_t lmv_size); -/* -* NOTE: If adding ops, add another LPROCFS_MD_OP_INIT() line to -* lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a -* wrapper function in include/linux/obd_class.h. -*/ };static inline struct md_open_data *obd_mod_alloc (void )
drivers/staging/lustre/lustre/include/obd_class.h +124 -109
445 lines not on this page · raw message
drivers/staging/lustre/lustre/obdclass/genops.c +0 -3
@@ -712,9 +712,6 @@ void class_export_put(struct obd_export *exp)CDEBUG (D_IOCTL ,"final put %p/%s\n" , exp, exp->exp_client_uuid.uuid); -/* release nid stat refererence */ -lprocfs_exp_cleanup (exp); -obd_zombie_export_add (exp); } }
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +64 -2
75 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH 8/8 lustre: obd: add md_stats to MDC and LMV devices
In reply to James SimmonsFrom: "John L. Hammond" <[email protected]>
Enable md_stats for MDC and LMV devices. These stats track usage of the md_ops methods (from the OBD layer, not to be confused with md_device methods) and are exported through the files /sys/fs/lustre/{lmv,mdc}/*/md_stats.
Rename m_sync to m_fsync making the counter name (fsync) more intuitive. The operations counted are close, create, enqueue, getattr, intent_lock, link, rename, setattr, fsync, readpage, unlink, setxattr, getxattr, intent_getattr_async, and revalidate_lock.
WC-bug-id: https://jira.whamcloud.com/browse/LU-2484
Reviewed-on: http://review.whamcloud.com/4827
--- drivers/staging/lustre/lustre/include/obd.h | 4 ++-- drivers/staging/lustre/lustre/include/obd_class.h | 6 +++--- drivers/staging/lustre/lustre/llite/file.c | 2 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 9 +++++---- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 6 ++++++ drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 7 +++++++ drivers/staging/lustre/lustre/mdc/mdc_request.c | 8 +++++--- 7 files changed, 29 insertions(+), 13 deletions(-)
drivers/staging/lustre/lustre/include/obd.h +2 -2
@@ -942,8 +942,8 @@ struct md_ops { struct ptlrpc_request **); int (*setattr)(struct obd_export *, struct md_op_data *, void *,size_t ,struct ptlrpc_request **); -int (*sync)(struct obd_export *,const struct lu_fid *, -struct ptlrpc_request **); +int (*fsync)(struct obd_export *,const struct lu_fid *, +struct ptlrpc_request **);int (*read_page)(struct obd_export *,struct md_op_data *,struct md_callback *cb_op,__u64 hash_offset,struct page **ppage);
drivers/staging/lustre/lustre/include/obd_class.h +3 -3
@@ -1350,8 +1350,8 @@ static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data,return MDP (exp->exp_obd, setattr)(exp, op_data, ea, ealen, request); } -static inline int md_sync (struct obd_export *exp,const struct lu_fid *fid, -struct ptlrpc_request **request) +static inline int md_fsync (struct obd_export *exp,const struct lu_fid *fid, +struct ptlrpc_request **request) {int rc;
@@ -1362,7 +1362,7 @@ static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid,lprocfs_counter_incr (exp->exp_obd->obd_md_stats,LPROC_MD_FSYNC ); -return MDP (exp->exp_obd, sync)(exp, fid, request); +return MDP (exp->exp_obd, fsync)(exp, fid, request); } static inline int md_read_page(struct obd_export *exp,
drivers/staging/lustre/lustre/llite/file.c +1 -1
@@ -2656,7 +2656,7 @@ int ll_fsync(struct file *file, loff_t start, loff_t end, int datasync) } } - err =md_sync (ll_i2sbi (inode)->ll_md_exp,ll_inode2fid (inode), &req); + err =md_fsync (ll_i2sbi (inode)->ll_md_exp,ll_inode2fid (inode), &req);if (!rc) rc = err;if (!err)
drivers/staging/lustre/lustre/lmv/lmv_obd.c +5 -4
@@ -1989,8 +1989,8 @@ static int lmv_setattr(struct obd_export *exp, struct md_op_data *op_data,return md_setattr (tgt->ltd_exp, op_data, ea, ealen, request); } -static int lmv_sync (struct obd_export *exp,const struct lu_fid *fid, -struct ptlrpc_request **request) +static int lmv_fsync (struct obd_export *exp,const struct lu_fid *fid, +struct ptlrpc_request **request) {struct obd_device *obd = exp->exp_obd;struct lmv_obd *lmv = &obd->u.lmv;
@@ -2000,7 +2000,7 @@ static int lmv_sync(struct obd_export *exp, const struct lu_fid *fid,if (IS_ERR (tgt))return PTR_ERR (tgt); -return md_sync (tgt->ltd_exp, fid, request); +return md_fsync (tgt->ltd_exp, fid, request); }/**
@@ -2502,6 +2502,7 @@ static int lmv_precleanup(struct obd_device *obd) {fld_client_debugfs_fini (&obd->u.lmv.lmv_fld);lprocfs_obd_cleanup (obd); +ldebugfs_free_md_stats (obd);return 0 ; }
@@ -3079,7 +3080,7 @@ static int lmv_merge_attr(struct obd_export *exp, .rename = lmv_rename, .setattr = lmv_setattr, .setxattr = lmv_setxattr, - .sync = lmv_sync, + .fsync = lmv_fsync, .read_page = lmv_read_page, .unlink = lmv_unlink, .init_ea_size = lmv_init_ea_size,
drivers/staging/lustre/lustre/lmv/lproc_lmv.c +6 -0
@@ -168,6 +168,12 @@ int lmv_tunables_init(struct obd_device *obd)if (rc)return rc; + rc =ldebugfs_alloc_md_stats (obd,0 ); +if (rc) { +lprocfs_obd_cleanup (obd); +return rc; + } +debugfs_create_file ("target_obd" ,0444 , obd->obd_debugfs_entry, obd, &lmv_debugfs_target_fops);
drivers/staging/lustre/lustre/mdc/lproc_mdc.c +7 -0
@@ -210,8 +210,15 @@ int mdc_tunables_init(struct obd_device *obd)if (rc)return rc; + rc =ldebugfs_alloc_md_stats (obd,0 ); +if (rc) { +lprocfs_obd_cleanup (obd); +return rc; + } + rc =sptlrpc_lprocfs_cliobd_attach (obd);if (rc) { +ldebugfs_free_md_stats (obd);lprocfs_obd_cleanup (obd);return rc; }
drivers/staging/lustre/lustre/mdc/mdc_request.c +5 -3
@@ -2487,8 +2487,8 @@ static int mdc_get_info(const struct lu_env *env, struct obd_export *exp,return rc; } -static int mdc_sync (struct obd_export *exp,const struct lu_fid *fid, -struct ptlrpc_request **request) +static int mdc_fsync (struct obd_export *exp,const struct lu_fid *fid, +struct ptlrpc_request **request) {struct ptlrpc_request *req;int rc;
@@ -2677,6 +2677,7 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)return 0 ; err_llog_cleanup: +ldebugfs_free_md_stats (obd);ptlrpc_lprocfs_unregister_obd (obd); err_osc_cleanup:client_obd_cleanup (obd);
@@ -2716,6 +2717,7 @@ static int mdc_precleanup(struct obd_device *obd)obd_cleanup_client_import (obd);ptlrpc_lprocfs_unregister_obd (obd);lprocfs_obd_cleanup (obd); +ldebugfs_free_md_stats (obd);mdc_llog_finish (obd);return 0 ; }
@@ -2772,7 +2774,7 @@ static int mdc_process_config(struct obd_device *obd, u32 len, void *buf) .setattr = mdc_setattr, .setxattr = mdc_setxattr, .getxattr = mdc_getxattr, - .sync = mdc_sync, + .fsync = mdc_fsync, .read_page = mdc_read_page, .unlink = mdc_unlink, .cancel_unused = mdc_cancel_unused,
Signature · 1 line
1.8.3.1
cover lustre: obd: preprocessor cleanups
In reply to James SimmonsQuoted 14 lines · James Simmons
The
obd.h,obd_class.h, and clio headers are littered with complex macros that are difficult to read. These macros existed to handle the obd stats and md stats which are lacking in the linux client. Newer versions do supportmd_statsso lets restore them as well as cleanup the ugly macros. This patch set is order dependent and is based on the first batch patch set for lustre 2.10 applied against the lustre-testing branch.Ben Evans (4):
lustre: obdclass: removeCL_PAGE_INVOKEet. al.
lustre: obdclass: removecl_for_eachdefines
lustre: obdclass: Code cleanup
lustre: obdclass: cleanupobd_class.hdefines
Quoted 7 lines
James Simmons (1):
lustre: obdclass: restoremd_statscodeJohn L. Hammond (3):
lustre: obd: remove obd_{get,put}ref()
lustre: obd: remove OBD ops based stats
lustre: obd: addmd_statsto MDC and LMV devices
Thanks. I've applied all of these.
NeilBrown
Quoted 20 lines
.../staging/lustre/lustre/include/lprocfs_status.h | 5 +- drivers/staging/lustre/lustre/include/obd.h | 20 +- drivers/staging/lustre/lustre/include/obd_class.h | 788 ++++++++++++--------- drivers/staging/lustre/lustre/llite/file.c | 2 +- drivers/staging/lustre/lustre/llite/llite_lib.c | 3 +- drivers/staging/lustre/lustre/lmv/lmv_obd.c | 9 +- drivers/staging/lustre/lustre/lmv/lproc_lmv.c | 6 + drivers/staging/lustre/lustre/lov/lov_dev.c | 12 +- drivers/staging/lustre/lustre/lov/lov_internal.h | 2 + drivers/staging/lustre/lustre/lov/lov_obd.c | 44 +- drivers/staging/lustre/lustre/lov/lov_pool.c | 10 +- drivers/staging/lustre/lustre/lov/lov_request.c | 4 +- drivers/staging/lustre/lustre/mdc/lproc_mdc.c | 7 + drivers/staging/lustre/lustre/mdc/mdc_request.c | 8 +- drivers/staging/lustre/lustre/obdclass/Makefile | 5 +- drivers/staging/lustre/lustre/obdclass/cl_io.c | 26 +- drivers/staging/lustre/lustre/obdclass/cl_object.c | 21 +- drivers/staging/lustre/lustre/obdclass/cl_page.c | 275 +++---- drivers/staging/lustre/lustre/obdclass/class_obd.c | 1 -
Quoted 11 lines
drivers/staging/lustre/lustre/obdclass/genops.c | 3 - .../staging/lustre/lustre/obdclass/kernelcomm.c | 7 +- drivers/staging/lustre/lustre/obdclass/llog_obd.c | 4 +- .../lustre/lustre/obdclass/lprocfs_status.c | 66 +- drivers/staging/lustre/lustre/obdclass/obd_mount.c | 2 +- drivers/staging/lustre/lustre/obdclass/uuid.c | 45 -- 25 files changed, 753 insertions(+), 622 deletions(-) delete mode 100644 drivers/staging/lustre/lustre/obdclass/uuid.cSignature · 1 line
1.8.3.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <http://lists.lustre.org/pipermail/lustre-devel-lustre.org/attachments/20180927/f2dccf8c/attachment.sig>