From patchwork Mon Sep 17 17:31:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10603233 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CC8D157B for ; Mon, 17 Sep 2018 17:33:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 37AFE27F98 for ; Mon, 17 Sep 2018 17:33:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BA892837D; Mon, 17 Sep 2018 17:33:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5C55527F98 for ; Mon, 17 Sep 2018 17:33:03 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C811F9C104F; Mon, 17 Sep 2018 10:31:50 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 67FF021F850 for ; Mon, 17 Sep 2018 10:31:25 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id EA1CE9EB; Mon, 17 Sep 2018 13:31:23 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id E84022B3; Mon, 17 Sep 2018 13:31:23 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 17 Sep 2018 13:31:14 -0400 Message-Id: <1537205481-6899-2-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> References: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 1/8] lustre: obdclass: remove CL_PAGE_INVOKE et. al. X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Evans 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. Signed-off-by: Ben Evans WC-bug-id: https://jira.whamcloud.com/browse/LU-9523 Reviewed-on: https://review.whamcloud.com/27168 Reviewed-by: Jinshan Xiong Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/obdclass/cl_page.c | 275 ++++++++++++----------- 1 file changed, 140 insertions(+), 135 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c index 916cf81..00df94b 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_page.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c @@ -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; } /** From patchwork Mon Sep 17 17:31:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10603237 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2D38157B for ; Mon, 17 Sep 2018 17:33:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B117C27F98 for ; Mon, 17 Sep 2018 17:33:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A39082837D; Mon, 17 Sep 2018 17:33:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 384C427F98 for ; Mon, 17 Sep 2018 17:33:09 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 39BC09C109C; Mon, 17 Sep 2018 10:31:53 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id BA22721F850 for ; Mon, 17 Sep 2018 10:31:25 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id ECE629EC; Mon, 17 Sep 2018 13:31:23 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id EB2262B7; Mon, 17 Sep 2018 13:31:23 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 17 Sep 2018 13:31:15 -0400 Message-Id: <1537205481-6899-3-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> References: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 2/8] lustre: obdclass: remove cl_for_each defines X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Evans 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. Signed-off-by: Ben Evans WC-bug-id: https://jira.whamcloud.com/browse/LU-9575 Reviewed-on: https://review.whamcloud.com/27385 Reviewed-by: Dmitry Eremin Reviewed-by: James Simmons Reviewed-by: Jinshan Xiong Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/obdclass/cl_io.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c index 3a96d4a..879383ae 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_io.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c @@ -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); From patchwork Mon Sep 17 17:31:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10603207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7B48157B for ; Mon, 17 Sep 2018 17:32:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D37002A299 for ; Mon, 17 Sep 2018 17:32:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C793C2A2A3; Mon, 17 Sep 2018 17:32:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 053872A29A for ; Mon, 17 Sep 2018 17:32:40 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 30F0821F8A1; Mon, 17 Sep 2018 10:31:40 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 18D6D21FA25 for ; Mon, 17 Sep 2018 10:31:26 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id F00869ED; Mon, 17 Sep 2018 13:31:23 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id EE2452B3; Mon, 17 Sep 2018 13:31:23 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 17 Sep 2018 13:31:16 -0400 Message-Id: <1537205481-6899-4-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> References: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 3/8] lustre: obdclass: Code cleanup X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Evans Remove uuid.c, and unroll class_uuid_unparse Rewrite CL_ENV_INC and DEC Remove D_KUC #define Signed-off-by: Ben Evans WC-bug-id: https://jira.whamcloud.com/browse/LU-9855 Reviewed-on: https://review.whamcloud.com/28458 Reviewed-by: John L. Hammond Reviewed-by: Dmitry Eremin Reviewed-by: Patrick Farrell Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- 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 diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 39a5eca..c6fb2e1 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -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); diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c index 3de6e886..22b545e 100644 --- a/drivers/staging/lustre/lustre/llite/llite_lib.c +++ b/drivers/staging/lustre/lustre/llite/llite_lib.c @@ -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; diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile index 19c8bd9..b1fac48 100644 --- a/drivers/staging/lustre/lustre/obdclass/Makefile +++ b/drivers/staging/lustre/lustre/obdclass/Makefile @@ -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 diff --git a/drivers/staging/lustre/lustre/obdclass/cl_object.c b/drivers/staging/lustre/lustre/obdclass/cl_object.c index d1d7bec..09fc7e7 100644 --- a/drivers/staging/lustre/lustre/obdclass/cl_object.c +++ b/drivers/staging/lustre/lustre/obdclass/cl_object.c @@ -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(); diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c index 2d23608..2103d2a 100644 --- a/drivers/staging/lustre/lustre/obdclass/class_obd.c +++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c @@ -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; diff --git a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c index 0fcfecf..3b006df 100644 --- a/drivers/staging/lustre/lustre/obdclass/kernelcomm.c +++ b/drivers/staging/lustre/lustre/obdclass/kernelcomm.c @@ -37,7 +37,6 @@ */ #define DEBUG_SUBSYSTEM S_CLASS -#define D_KUC D_OTHER #include #include @@ -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); diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c index f59e7c4..33a67fd 100644 --- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c +++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c @@ -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, diff --git a/drivers/staging/lustre/lustre/obdclass/uuid.c b/drivers/staging/lustre/lustre/obdclass/uuid.c deleted file mode 100644 index ec8c6dc..0000000 --- a/drivers/staging/lustre/lustre/obdclass/uuid.c +++ /dev/null @@ -1,45 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * GPL HEADER START - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 only, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License version 2 for more details (a copy is included - * in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU General Public License - * version 2 along with this program; If not, see - * http://www.gnu.org/licenses/gpl-2.0.html - * - * GPL HEADER END - */ -/* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. - * Use is subject to license terms. - */ -/* - * This file is part of Lustre, http://www.lustre.org/ - * Lustre is a trademark of Sun Microsystems, Inc. - * - * lustre/obdclass/uuid.c - * - * Public include file for the UUID library - */ - -#define DEBUG_SUBSYSTEM S_CLASS - -#include -#include - -void class_uuid_unparse(class_uuid_t uu, struct obd_uuid *out) -{ - sprintf(out->uuid, "%pU", uu); -} -EXPORT_SYMBOL(class_uuid_unparse); From patchwork Mon Sep 17 17:31:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10603243 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B46006CB for ; Mon, 17 Sep 2018 17:33:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF92326246 for ; Mon, 17 Sep 2018 17:33:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A36822832D; Mon, 17 Sep 2018 17:33:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2818726246 for ; Mon, 17 Sep 2018 17:33:18 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id BAE8621F8A0; Mon, 17 Sep 2018 10:32:00 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 6A3FA21FA25 for ; Mon, 17 Sep 2018 10:31:26 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id F2BB69EE; Mon, 17 Sep 2018 13:31:23 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id F185C2B3; Mon, 17 Sep 2018 13:31:23 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 17 Sep 2018 13:31:17 -0400 Message-Id: <1537205481-6899-5-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> References: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 4/8] lustre: obdclass: cleanup obd_class.h defines X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexey Lyashkov , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Ben Evans 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 Signed-off-by: Alexey Lyashkov 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 Reviewed-by: Steve Guminski Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- 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); From patchwork Mon Sep 17 17:31:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10603225 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F09FC157B for ; Mon, 17 Sep 2018 17:32:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EE89B2A29A for ; Mon, 17 Sep 2018 17:32:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2EFF2A2AB; Mon, 17 Sep 2018 17:32:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3024B2A29A for ; Mon, 17 Sep 2018 17:32:55 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 0129A9C069B; Mon, 17 Sep 2018 10:31:46 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id BD36C21FA25 for ; Mon, 17 Sep 2018 10:31:26 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 014F59F2; Mon, 17 Sep 2018 13:31:24 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 003CE2B3; Mon, 17 Sep 2018 13:31:23 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 17 Sep 2018 13:31:18 -0400 Message-Id: <1537205481-6899-6-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> References: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 5/8] lustre: obd: remove obd_{get,put}ref() X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "John L. Hammond" 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. Signed-off-by: John L. Hammond WC-bug-id: https://jira.whamcloud.com/browse/LU-11051 Reviewed-on: https://review.whamcloud.com/32529 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- 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(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 50e97b4..44f9b10 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -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 */ diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index aab1092..eb0a53d 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -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; diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c index c7db234..abf2ede 100644 --- a/drivers/staging/lustre/lustre/lov/lov_dev.c +++ b/drivers/staging/lustre/lustre/lov/lov_dev.c @@ -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; } diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h index dbb79d4..44a997e 100644 --- a/drivers/staging/lustre/lustre/lov/lov_internal.h +++ b/drivers/staging/lustre/lustre/lov/lov_internal.h @@ -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); diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c index 3483f9b..6959b91 100644 --- a/drivers/staging/lustre/lustre/lov/lov_obd.c +++ b/drivers/staging/lustre/lustre/lov/lov_obd.c @@ -62,7 +62,7 @@ /* Keep a refcount of lov->tgt usage to prevent racing with addition/deletion. * Any function that expects lov_tgts to remain stationary must take a ref. */ -static void lov_getref(struct obd_device *obd) +void lov_tgts_getref(struct obd_device *obd) { struct lov_obd *lov = &obd->u.lov; @@ -74,7 +74,7 @@ static void lov_getref(struct obd_device *obd) static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt); -static void lov_putref(struct obd_device *obd) +void lov_tgts_putref(struct obd_device *obd) { struct lov_obd *lov = &obd->u.lov; @@ -231,7 +231,7 @@ static int lov_connect(const struct lu_env *env, if (data) lov->lov_ocd = *data; - obd_getref(obd); + lov_tgts_getref(obd); lov->lov_tgts_kobj = kobject_create_and_add("target_obds", &obd->obd_kset.kobj); @@ -258,7 +258,7 @@ static int lov_connect(const struct lu_env *env, obd->obd_name, rc); } } - obd_putref(obd); + lov_tgts_putref(obd); return 0; } @@ -326,7 +326,7 @@ static int lov_disconnect(struct obd_export *exp) /* Let's hold another reference so lov_del_obd doesn't spin through * putref every time */ - obd_getref(obd); + lov_tgts_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { if (lov->lov_tgts[i] && lov->lov_tgts[i]->ltd_exp) { @@ -335,7 +335,7 @@ static int lov_disconnect(struct obd_export *exp) } } - obd_putref(obd); + lov_tgts_putref(obd); out: rc = class_disconnect(exp); /* bz 9811 */ @@ -359,7 +359,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, CDEBUG(D_INFO, "Searching in lov %p for uuid %s event(%d)\n", lov, uuid->uuid, ev); - obd_getref(obd); + lov_tgts_getref(obd); for (index = 0; index < lov->desc.ld_tgt_count; index++) { tgt = lov->lov_tgts[index]; if (!tgt) @@ -426,7 +426,7 @@ static int lov_set_osc_active(struct obd_device *obd, struct obd_uuid *uuid, } out: - obd_putref(obd); + lov_tgts_putref(obd); return index; } @@ -574,7 +574,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, return 0; } - obd_getref(obd); + lov_tgts_getref(obd); rc = lov_connect_obd(obd, index, active, &lov->lov_ocd); if (rc) @@ -604,7 +604,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp, obd_uuid2str(&tgt->ltd_uuid)); lov_del_target(obd, index, NULL, 0); } - obd_putref(obd); + lov_tgts_putref(obd); return rc; } @@ -624,7 +624,7 @@ int lov_del_target(struct obd_device *obd, __u32 index, /* to make sure there's no ongoing lov_notify() now */ down_write(&lov->lov_notify_lock); - obd_getref(obd); + lov_tgts_getref(obd); if (!lov->lov_tgts[index]) { CERROR("LOV target at index %d is not setup.\n", index); @@ -647,9 +647,9 @@ int lov_del_target(struct obd_device *obd, __u32 index, lov->lov_tgts[index]->ltd_reap = 1; lov->lov_death_row++; - /* we really delete it from obd_putref */ + /* we really delete it from lov_tgts_putref */ out: - obd_putref(obd); + lov_tgts_putref(obd); up_write(&lov->lov_notify_lock); return rc; @@ -812,7 +812,7 @@ static int lov_cleanup(struct obd_device *obd) if (lov->lov_tgts) { int i; - obd_getref(obd); + lov_tgts_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { if (!lov->lov_tgts[i]) continue; @@ -829,7 +829,7 @@ static int lov_cleanup(struct obd_device *obd) atomic_read(&lov->lov_refcount)); lov_del_target(obd, i, NULL, 0); } - obd_putref(obd); + lov_tgts_putref(obd); kfree(lov->lov_tgts); lov->lov_tgt_size = 0; } @@ -1182,7 +1182,7 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp, if (!vallen || !val) return -EFAULT; - obd_getref(obddev); + lov_tgts_getref(obddev); if (KEY_IS(KEY_MAX_EASIZE)) { u32 max_stripe_count = min_t(u32, ld->ld_active_tgt_count, @@ -1200,7 +1200,7 @@ static int lov_get_info(const struct lu_env *env, struct obd_export *exp, rc = -EINVAL; } - obd_putref(obddev); + lov_tgts_putref(obddev); return rc; } @@ -1222,7 +1222,7 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, return -ENOMEM; } - obd_getref(obddev); + lov_tgts_getref(obddev); count = lov->desc.ld_tgt_count; if (KEY_IS(KEY_CHECKSUM)) { @@ -1251,7 +1251,7 @@ static int lov_set_info_async(const struct lu_env *env, struct obd_export *exp, rc = err; } - obd_putref(obddev); + lov_tgts_putref(obddev); if (no_set) { err = ptlrpc_set_wait(set); if (!rc) @@ -1294,7 +1294,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, } /* for lov tgt */ - obd_getref(obd); + lov_tgts_getref(obd); for (i = 0; i < lov->desc.ld_tgt_count; i++) { int err; @@ -1326,7 +1326,7 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, bhardlimit += oqctl->qc_dqblk.dqb_bhardlimit; } } - obd_putref(obd); + lov_tgts_putref(obd); if (oqctl->qc_cmd == Q_GETOQUOTA) { oqctl->qc_dqblk.dqb_curspace = curspace; @@ -1352,8 +1352,6 @@ static int lov_quotactl(struct obd_device *obd, struct obd_export *exp, .pool_rem = lov_pool_remove, .pool_add = lov_pool_add, .pool_del = lov_pool_del, - .getref = lov_getref, - .putref = lov_putref, .quotactl = lov_quotactl, }; diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c index b2a88ba..c79c2ae 100644 --- a/drivers/staging/lustre/lustre/lov/lov_pool.c +++ b/drivers/staging/lustre/lustre/lov/lov_pool.c @@ -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; } diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c index cb8567f..8ca13ed 100644 --- a/drivers/staging/lustre/lustre/lov/lov_request.c +++ b/drivers/staging/lustre/lustre/lov/lov_request.c @@ -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; } From patchwork Mon Sep 17 17:31:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10603215 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7FE917E1 for ; Mon, 17 Sep 2018 17:32:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D71D22A27F for ; Mon, 17 Sep 2018 17:32:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB2CC2A2AD; Mon, 17 Sep 2018 17:32:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 069E72A27F for ; Mon, 17 Sep 2018 17:32:47 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 2CF709C0549; Mon, 17 Sep 2018 10:31:43 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 1D62C21FA25 for ; Mon, 17 Sep 2018 10:31:27 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 045809F3; Mon, 17 Sep 2018 13:31:24 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 0303C2B3; Mon, 17 Sep 2018 13:31:24 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 17 Sep 2018 13:31:19 -0400 Message-Id: <1537205481-6899-7-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> References: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 6/8] lustre: obd: remove OBD ops based stats X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "John L. Hammond" 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. Signed-off-by: John L. Hammond WC-bug-id: https://jira.whamcloud.com/browse/LU-11052 Reviewed-on: https://review.whamcloud.com/32602 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Jesse Hanley Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- drivers/staging/lustre/lustre/include/obd.h | 1 - drivers/staging/lustre/lustre/include/obd_class.h | 66 +---------------------- 2 files changed, 2 insertions(+), 65 deletions(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 44f9b10..8691aec 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -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; diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index eb0a53d..0c1922e 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -334,33 +334,6 @@ static inline int obd_check_dev_active(struct obd_device *obd) return rc; } -#define OBD_COUNTER_OFFSET(op) \ - ((offsetof(struct obd_ops, op) - \ - offsetof(struct obd_ops, iocontrol)) \ - / sizeof(((struct obd_ops *)(0))->iocontrol)) - -#define OBD_COUNTER_INCREMENT(obdx, op) \ -do { \ - if ((obdx)->obd_stats) { \ - unsigned int coffset; \ - coffset = (unsigned int)((obdx)->obd_cntr_base) + \ - OBD_COUNTER_OFFSET(op); \ - LASSERT(coffset < (obdx)->obd_stats->ls_num); \ - lprocfs_counter_incr((obdx)->obd_stats, coffset); \ - } \ -} while (0) - -#define EXP_COUNTER_INCREMENT(export, op) \ -do { \ - if ((export)->exp_obd->obd_stats) { \ - unsigned int coffset; \ - coffset = (unsigned int)((export)->exp_obd->obd_cntr_base) + \ - OBD_COUNTER_OFFSET(op); \ - LASSERT(coffset < (export)->exp_obd->obd_stats->ls_num); \ - lprocfs_counter_incr((export)->exp_obd->obd_stats, coffset); \ - } \ -} while (0) - #define MD_COUNTER_OFFSET(op) \ ((offsetof(struct md_ops, op) - \ offsetof(struct md_ops, get_root)) \ @@ -422,7 +395,6 @@ static inline int obd_get_info(const struct lu_env *env, 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); return rc; @@ -444,7 +416,6 @@ static inline int obd_set_info_async(const struct lu_env *env, 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, val, set); @@ -506,7 +477,6 @@ static inline int obd_setup(struct obd_device *obd, struct lustre_cfg *cfg) __func__); return -EOPNOTSUPP; } - OBD_COUNTER_INCREMENT(obd, setup); rc = OBP(obd, setup)(obd, cfg); } return rc; @@ -530,8 +500,6 @@ static inline int obd_precleanup(struct obd_device *obd) if (!obd->obd_type->typ_dt_ops->precleanup) return 0; - OBD_COUNTER_INCREMENT(obd, precleanup); - rc = OBP(obd, precleanup)(obd); return rc; } @@ -555,8 +523,6 @@ static inline int obd_cleanup(struct obd_device *obd) if (!obd->obd_type->typ_dt_ops->cleanup) return 0; - OBD_COUNTER_INCREMENT(obd, cleanup); - rc = OBP(obd, cleanup)(obd); return rc; } @@ -605,7 +571,6 @@ static inline int obd_process_config(struct obd_device *obd, int datalen, } rc = OBP(obd, process_config)(obd, datalen, data); } - OBD_COUNTER_INCREMENT(obd, process_config); obd->obd_process_conf = 0; return rc; @@ -625,7 +590,6 @@ static inline int obd_create(const struct lu_env *env, struct obd_export *exp, exp->exp_obd->obd_name, __func__); return -EOPNOTSUPP; } - EXP_COUNTER_INCREMENT(exp, create); rc = OBP(exp->exp_obd, create)(env, exp, obdo); return rc; @@ -645,7 +609,6 @@ static inline int obd_destroy(const struct lu_env *env, struct obd_export *exp, exp->exp_obd->obd_name, __func__); return -EOPNOTSUPP; } - EXP_COUNTER_INCREMENT(exp, destroy); rc = OBP(exp->exp_obd, destroy)(env, exp, obdo); return rc; @@ -665,7 +628,6 @@ static inline int obd_getattr(const struct lu_env *env, struct obd_export *exp, exp->exp_obd->obd_name, __func__); return -EOPNOTSUPP; } - EXP_COUNTER_INCREMENT(exp, getattr); rc = OBP(exp->exp_obd, getattr)(env, exp, oa); return rc; @@ -685,7 +647,6 @@ static inline int obd_setattr(const struct lu_env *env, struct obd_export *exp, exp->exp_obd->obd_name, __func__); return -EOPNOTSUPP; } - EXP_COUNTER_INCREMENT(exp, setattr); rc = OBP(exp->exp_obd, setattr)(env, exp, oa); return rc; @@ -705,7 +666,6 @@ static inline int obd_add_conn(struct obd_import *imp, struct obd_uuid *uuid, 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); return rc; @@ -724,7 +684,6 @@ static inline int obd_del_conn(struct obd_import *imp, struct obd_uuid *uuid) 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); return rc; @@ -738,8 +697,6 @@ static inline struct obd_uuid *obd_get_uuid(struct obd_export *exp) !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); return uuid; } @@ -768,7 +725,6 @@ static inline int obd_connect(const struct lu_env *env, 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); /* check that only subset is granted */ @@ -794,8 +750,6 @@ static inline int obd_reconnect(const struct lu_env *env, 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); /* check that only subset is granted */ LASSERT(ergo(d, (d->ocd_connect_flags & ocf) == d->ocd_connect_flags)); @@ -815,7 +769,6 @@ static inline int obd_disconnect(struct obd_export *exp) exp->exp_obd->obd_name, __func__); return -ENOTSUPP; } - EXP_COUNTER_INCREMENT(exp, disconnect); rc = OBP(exp->exp_obd, disconnect)(exp); return rc; @@ -828,7 +781,6 @@ static inline int obd_fid_init(struct obd_device *obd, struct obd_export *exp, 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); return rc; @@ -840,7 +792,6 @@ static inline int obd_fid_fini(struct obd_device *obd) 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); return rc; @@ -862,7 +813,6 @@ static inline int obd_fid_alloc(const struct lu_env *env, 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); return rc; @@ -876,7 +826,6 @@ static inline int obd_pool_new(struct obd_device *obd, char *poolname) 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); return rc; @@ -890,7 +839,6 @@ static inline int obd_pool_del(struct obd_device *obd, char *poolname) 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; @@ -905,7 +853,6 @@ static inline int obd_pool_add(struct obd_device *obd, char *poolname, 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); return rc; @@ -921,7 +868,6 @@ static inline int obd_pool_rem(struct obd_device *obd, 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); return rc; @@ -966,7 +912,6 @@ static inline int obd_statfs_async(struct obd_export *exp, 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", obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age); @@ -1029,7 +974,6 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, 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", obd->obd_osfs_age, max_age); @@ -1071,7 +1015,6 @@ static inline int obd_preprw(const struct lu_env *env, int cmd, 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, pages, local); @@ -1095,7 +1038,6 @@ static inline int obd_commitrw(const struct lu_env *env, int cmd, 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, orig_rc); @@ -1116,7 +1058,6 @@ static inline int obd_iocontrol(unsigned int cmd, struct obd_export *exp, exp->exp_obd->obd_name, __func__); return -ENOTSUPP; } - EXP_COUNTER_INCREMENT(exp, iocontrol); rc = OBP(exp->exp_obd, iocontrol)(cmd, exp, len, karg, uarg); return rc; @@ -1130,10 +1071,9 @@ static inline void obd_import_event(struct obd_device *obd, CERROR("NULL device\n"); return; } - if (obd->obd_set_up && OBP(obd, import_event)) { - OBD_COUNTER_INCREMENT(obd, import_event); + + if (obd->obd_set_up && OBP(obd, import_event)) OBP(obd, import_event)(obd, imp, event); - } } static inline int obd_notify(struct obd_device *obd, @@ -1156,7 +1096,6 @@ static inline int obd_notify(struct obd_device *obd, return -ENOSYS; } - OBD_COUNTER_INCREMENT(obd, notify); rc = OBP(obd, notify)(obd, watched, ev); return rc; } @@ -1196,7 +1135,6 @@ static inline int obd_quotactl(struct obd_export *exp, exp->exp_obd->obd_name, __func__); return -ENOTSUPP; } - EXP_COUNTER_INCREMENT(exp, quotactl); rc = OBP(exp->exp_obd, quotactl)(exp->exp_obd, exp, oqctl); return rc; From patchwork Mon Sep 17 17:31:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10603239 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D37E9157B for ; Mon, 17 Sep 2018 17:33:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF50326246 for ; Mon, 17 Sep 2018 17:33:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C32B82832D; Mon, 17 Sep 2018 17:33:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A970D26246 for ; Mon, 17 Sep 2018 17:33:10 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id DE45D9C10B9; Mon, 17 Sep 2018 10:31:53 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 6F6C721F7F9 for ; Mon, 17 Sep 2018 10:31:27 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 07E149F4; Mon, 17 Sep 2018 13:31:24 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 061432B3; Mon, 17 Sep 2018 13:31:24 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 17 Sep 2018 13:31:20 -0400 Message-Id: <1537205481-6899-8-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> References: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 7/8] lustre: obdclass: restore md_stats code X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: James Simmons , Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP Originally 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. Signed-off-by: James Simmons WC-bug-id: https://jira.whamcloud.com/browse/LU-9855 Reviewed-on: https://review.whamcloud.com/32822 Reviewed-by: Ben Evans Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- .../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(-) diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h index 5da26e3..c22ae3d 100644 --- a/drivers/staging/lustre/lustre/include/lprocfs_status.h +++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h @@ -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 */ diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 8691aec..6e78c50 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -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) diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 0c1922e..2514b39 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -334,36 +334,6 @@ static inline int obd_check_dev_active(struct obd_device *obd) return rc; } -#define MD_COUNTER_OFFSET(op) \ - ((offsetof(struct md_ops, op) - \ - offsetof(struct md_ops, get_root)) \ - / sizeof(((struct md_ops *)(0))->get_root)) - -#define MD_COUNTER_INCREMENT(obdx, op) \ -do { \ - if ((obd)->md_stats) { \ - unsigned int coffset; \ - coffset = (unsigned int)((obdx)->md_cntr_base) + \ - MD_COUNTER_OFFSET(op); \ - LASSERT(coffset < (obdx)->md_stats->ls_num); \ - lprocfs_counter_incr((obdx)->md_stats, coffset); \ - } \ -} while (0) - -#define EXP_MD_COUNTER_INCREMENT(export, op) \ -do { \ - if ((export)->exp_obd->obd_stats) { \ - unsigned int coffset; \ - coffset = (unsigned int)((export)->exp_obd->md_cntr_base) + \ - MD_COUNTER_OFFSET(op); \ - LASSERT(coffset < (export)->exp_obd->md_stats->ls_num); \ - lprocfs_counter_incr((export)->exp_obd->md_stats, coffset); \ - if ((export)->exp_md_stats) \ - lprocfs_counter_incr( \ - (export)->exp_md_stats, coffset); \ - } \ -} while (0) - static inline int exp_check_ops(struct obd_export *exp) { if (!exp) @@ -1186,6 +1156,25 @@ static inline int obd_register_observer(struct obd_device *obd, } /* metadata helpers */ +enum mps_stat_idx { + LPROC_MD_CLOSE, + LPROC_MD_CREATE, + LPROC_MD_ENQUEUE, + LPROC_MD_GETATTR, + LPROC_MD_INTENT_LOCK, + LPROC_MD_LINK, + LPROC_MD_RENAME, + LPROC_MD_SETATTR, + LPROC_MD_FSYNC, + LPROC_MD_READ_PAGE, + LPROC_MD_UNLINK, + LPROC_MD_SETXATTR, + LPROC_MD_GETXATTR, + LPROC_MD_INTENT_GETATTR_ASYNC, + LPROC_MD_REVALIDATE_LOCK, + LPROC_MD_LAST_OPC, +}; + static inline int md_get_root(struct obd_export *exp, const char *fileset, struct lu_fid *fid) { @@ -1194,9 +1183,8 @@ static inline int md_get_root(struct obd_export *exp, const char *fileset, 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; + + return MDP(exp->exp_obd, get_root)(exp, fileset, fid); } static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, @@ -1207,9 +1195,11 @@ static inline int md_getattr(struct obd_export *exp, struct md_op_data *op_data, 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; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_GETATTR); + + return MDP(exp->exp_obd, getattr)(exp, op_data, request); } static inline int md_null_inode(struct obd_export *exp, @@ -1220,9 +1210,8 @@ static inline int md_null_inode(struct obd_export *exp, 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; + + return MDP(exp->exp_obd, null_inode)(exp, fid); } static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, @@ -1234,25 +1223,29 @@ static inline int md_close(struct obd_export *exp, struct md_op_data *op_data, 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; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_CLOSE); + + return MDP(exp->exp_obd, close)(exp, op_data, mod, request); } static inline int md_create(struct obd_export *exp, struct md_op_data *op_data, const void *data, size_t datalen, umode_t mode, uid_t uid, gid_t gid, kernel_cap_t cap_effective, - __u64 rdev, struct ptlrpc_request **request) + u64 rdev, struct ptlrpc_request **request) { int rc; 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); - return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_CREATE); + + return MDP(exp->exp_obd, create)(exp, op_data, data, datalen, mode, + uid, gid, cap_effective, rdev, request); } static inline int md_enqueue(struct obd_export *exp, @@ -1260,17 +1253,19 @@ static inline int md_enqueue(struct obd_export *exp, const union ldlm_policy_data *policy, struct md_op_data *op_data, struct lustre_handle *lockh, - __u64 extra_lock_flags) + u64 extra_lock_flags) { int rc; 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); - return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_ENQUEUE); + + return MDP(exp->exp_obd, enqueue)(exp, einfo, policy, op_data, lockh, + extra_lock_flags); } static inline int md_getattr_name(struct obd_export *exp, @@ -1282,9 +1277,8 @@ static inline int md_getattr_name(struct obd_export *exp, 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; + + return MDP(exp->exp_obd, getattr_name)(exp, op_data, request); } static inline int md_intent_lock(struct obd_export *exp, @@ -1292,17 +1286,19 @@ static inline int md_intent_lock(struct obd_export *exp, struct lookup_intent *it, struct ptlrpc_request **reqp, ldlm_blocking_callback cb_blocking, - __u64 extra_lock_flags) + u64 extra_lock_flags) { int rc; 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); - return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_INTENT_LOCK); + + return MDP(exp->exp_obd, intent_lock)(exp, op_data, it, reqp, + cb_blocking, extra_lock_flags); } static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, @@ -1313,24 +1309,29 @@ static inline int md_link(struct obd_export *exp, struct md_op_data *op_data, 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; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_LINK); + + return MDP(exp->exp_obd, link)(exp, op_data, request); } static inline int md_rename(struct obd_export *exp, struct md_op_data *op_data, - const char *old, size_t oldlen, const char *new, - size_t newlen, struct ptlrpc_request **request) + const char *old_name, size_t oldlen, + const char *new_name, size_t newlen, + struct ptlrpc_request **request) { int rc; 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); - return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_RENAME); + + return MDP(exp->exp_obd, rename)(exp, op_data, old_name, oldlen, + new_name, newlen, request); } static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, @@ -1342,9 +1343,11 @@ static inline int md_setattr(struct obd_export *exp, struct md_op_data *op_data, 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; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_SETATTR); + + 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, @@ -1355,15 +1358,17 @@ static inline int md_sync(struct obd_export *exp, const struct lu_fid *fid, 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; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_FSYNC); + + return MDP(exp->exp_obd, sync)(exp, fid, request); } static inline int md_read_page(struct obd_export *exp, struct md_op_data *op_data, struct md_callback *cb_op, - __u64 hash_offset, + u64 hash_offset, struct page **ppage) { int rc; @@ -1371,10 +1376,12 @@ static inline int md_read_page(struct obd_export *exp, 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); - return rc; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_READ_PAGE); + + return MDP(exp->exp_obd, read_page)(exp, op_data, cb_op, hash_offset, + ppage); } static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, @@ -1385,9 +1392,11 @@ static inline int md_unlink(struct obd_export *exp, struct md_op_data *op_data, 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; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_UNLINK); + + return MDP(exp->exp_obd, unlink)(exp, op_data, request); } static inline int md_get_lustre_md(struct obd_export *exp, @@ -1401,7 +1410,7 @@ static inline int md_get_lustre_md(struct obd_export *exp, 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); } @@ -1413,7 +1422,7 @@ static inline int md_free_lustre_md(struct obd_export *exp, 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); } @@ -1427,7 +1436,7 @@ static inline int md_merge_attr(struct obd_export *exp, 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); } @@ -1442,7 +1451,10 @@ static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid, rc = exp_check_ops(exp); if (rc) return rc; - EXP_MD_COUNTER_INCREMENT(exp, setxattr); + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_SETXATTR); + return MDP(exp->exp_obd, setxattr)(exp, fid, obd_md_valid, name, value, value_size, xattr_flags, suppgid, request); @@ -1457,7 +1469,10 @@ static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid, rc = exp_check_ops(exp); if (rc) return rc; - EXP_MD_COUNTER_INCREMENT(exp, getxattr); + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_GETXATTR); + return MDP(exp->exp_obd, getxattr)(exp, fid, obd_md_valid, name, buf_size, req); } @@ -1471,7 +1486,7 @@ static inline int md_set_open_replay_data(struct obd_export *exp, 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); } @@ -1483,7 +1498,7 @@ static inline int md_clear_open_replay_data(struct obd_export *exp, 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); } @@ -1496,7 +1511,7 @@ static inline int md_set_lock_data(struct obd_export *exp, 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); } @@ -1512,11 +1527,9 @@ static inline int md_cancel_unused(struct obd_export *exp, 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, - flags, opaque); - return rc; + return MDP(exp->exp_obd, cancel_unused)(exp, fid, policy, mode, + flags, opaque); } static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags, @@ -1531,7 +1544,7 @@ static inline enum ldlm_mode md_lock_match(struct obd_export *exp, __u64 flags, 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); } @@ -1544,7 +1557,7 @@ static inline int md_init_ea_size(struct obd_export *exp, u32 easize, 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); } @@ -1556,9 +1569,11 @@ static inline int md_intent_getattr_async(struct obd_export *exp, 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; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_INTENT_GETATTR_ASYNC); + + return MDP(exp->exp_obd, intent_getattr_async)(exp, minfo); } static inline int md_revalidate_lock(struct obd_export *exp, @@ -1570,9 +1585,11 @@ static inline int md_revalidate_lock(struct obd_export *exp, 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; + + lprocfs_counter_incr(exp->exp_obd->obd_md_stats, + LPROC_MD_REVALIDATE_LOCK); + + return MDP(exp->exp_obd, revalidate_lock)(exp, it, fid, bits); } static inline int md_get_fid_from_lsm(struct obd_export *exp, @@ -1585,9 +1602,8 @@ static inline int md_get_fid_from_lsm(struct obd_export *exp, 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; + + return MDP(exp->exp_obd, get_fid_from_lsm)(exp, lsm, name, namelen, fid); } /* @@ -1606,9 +1622,8 @@ static inline int md_unpackmd(struct obd_export *exp, 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; + + return MDP(exp->exp_obd, unpackmd)(exp, plsm, lmm, lmm_size); } /* OBD Metadata Support */ diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c index 29ed498..59891a8 100644 --- a/drivers/staging/lustre/lustre/obdclass/genops.c +++ b/drivers/staging/lustre/lustre/obdclass/genops.c @@ -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); } } diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c index a540abb..dc1d540 100644 --- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c +++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c @@ -1403,11 +1403,73 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int index, } EXPORT_SYMBOL(lprocfs_counter_init); -int lprocfs_exp_cleanup(struct obd_export *exp) +static const char * const mps_stats[] = { + [LPROC_MD_CLOSE] = "close", + [LPROC_MD_CREATE] = "create", + [LPROC_MD_ENQUEUE] = "enqueue", + [LPROC_MD_GETATTR] = "getattr", + [LPROC_MD_INTENT_LOCK] = "intent_lock", + [LPROC_MD_LINK] = "link", + [LPROC_MD_RENAME] = "rename", + [LPROC_MD_SETATTR] = "setattr", + [LPROC_MD_FSYNC] = "fsync", + [LPROC_MD_READ_PAGE] = "read_page", + [LPROC_MD_UNLINK] = "unlink", + [LPROC_MD_SETXATTR] = "setxattr", + [LPROC_MD_GETXATTR] = "getxattr", + [LPROC_MD_INTENT_GETATTR_ASYNC] = "intent_getattr_async", + [LPROC_MD_REVALIDATE_LOCK] = "revalidate_lock", +}; + +int ldebugfs_alloc_md_stats(struct obd_device *obd, + unsigned int num_private_stats) { + struct lprocfs_stats *stats; + unsigned int num_stats; + int i; + + /* No obd device debugfs tree to attach too */ + if (!obd->obd_debugfs_entry) { + CWARN("%s: missing debugfs tree for registering md_stats.\n", + obd->obd_name); + return 0; + } + + if (obd->obd_md_stats) + return -EINVAL; + + num_stats = ARRAY_SIZE(mps_stats) + num_private_stats; + stats = lprocfs_alloc_stats(num_stats, 0); + if (!stats) + return -ENOMEM; + + for (i = 0; i < ARRAY_SIZE(mps_stats); i++) { + lprocfs_counter_init(stats, i, 0, mps_stats[i], "reqs"); + if (!stats->ls_cnt_header[i].lc_name) { + CERROR("Missing md_stat initializer md_op operation at offset %d. Aborting.\n", + i); + LBUG(); + } + } + obd->obd_md_stats = stats; + + debugfs_create_file("md_stats", 0644, obd->obd_debugfs_entry, + obd->obd_md_stats, &lprocfs_stats_seq_fops); return 0; } -EXPORT_SYMBOL(lprocfs_exp_cleanup); +EXPORT_SYMBOL(ldebugfs_alloc_md_stats); + +void ldebugfs_free_md_stats(struct obd_device *obd) +{ + struct lprocfs_stats *stats = obd->obd_md_stats; + + if (!stats) + return; + + obd->obd_md_stats = NULL; + lprocfs_free_stats(&stats); +} +EXPORT_SYMBOL(ldebugfs_free_md_stats); __s64 lprocfs_read_helper(struct lprocfs_counter *lc, struct lprocfs_counter_header *header, From patchwork Mon Sep 17 17:31:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 10603223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C513F17E1 for ; Mon, 17 Sep 2018 17:32:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C44E92A29A for ; Mon, 17 Sep 2018 17:32:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8A3D2A2AB; Mon, 17 Sep 2018 17:32:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 324872A29A for ; Mon, 17 Sep 2018 17:32:54 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 5D10D9C065E; Mon, 17 Sep 2018 10:31:46 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C412B21F7F9 for ; Mon, 17 Sep 2018 10:31:27 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 0AA3B9F5; Mon, 17 Sep 2018 13:31:24 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 091162B7; Mon, 17 Sep 2018 13:31:24 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 17 Sep 2018 13:31:21 -0400 Message-Id: <1537205481-6899-9-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> References: <1537205481-6899-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 8/8] lustre: obd: add md_stats to MDC and LMV devices X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: "John L. Hammond" 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. Signed-off-by: John L. Hammond WC-bug-id: https://jira.whamcloud.com/browse/LU-2484 Reviewed-on: http://review.whamcloud.com/4827 Reviewed-by: Andreas Dilger Reviewed-by: wangdi Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- 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(-) diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h index 6e78c50..11e7ae8 100644 --- a/drivers/staging/lustre/lustre/include/obd.h +++ b/drivers/staging/lustre/lustre/include/obd.h @@ -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); diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h index 2514b39..824d378 100644 --- a/drivers/staging/lustre/lustre/include/obd_class.h +++ b/drivers/staging/lustre/lustre/include/obd_class.h @@ -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, diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c index 94760eb..092fa99 100644 --- a/drivers/staging/lustre/lustre/llite/file.c +++ b/drivers/staging/lustre/lustre/llite/file.c @@ -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) diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index cf2a4c6..71bd843 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -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, diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c index efc12ad..4e30026 100644 --- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c +++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c @@ -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); diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c index a205c61..ffc1085 100644 --- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c +++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c @@ -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; } diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index 2108877..8f8e3d2 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c @@ -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,