From patchwork Fri Jul 8 20:45:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Schumaker X-Patchwork-Id: 957352 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p68Kk34V003299 for ; Fri, 8 Jul 2011 20:46:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753513Ab1GHUqD (ORCPT ); Fri, 8 Jul 2011 16:46:03 -0400 Received: from mx2.netapp.com ([216.240.18.37]:23224 "EHLO mx2.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753100Ab1GHUqC (ORCPT ); Fri, 8 Jul 2011 16:46:02 -0400 X-IronPort-AV: E=Sophos;i="4.65,500,1304319600"; d="scan'208";a="561394091" Received: from smtp1.corp.netapp.com ([10.57.156.124]) by mx2-out.netapp.com with ESMTP; 08 Jul 2011 13:46:02 -0700 Received: from davros.hq.netapp.com ([10.63.233.104]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id p68Kjx6I027863; Fri, 8 Jul 2011 13:46:01 -0700 (PDT) From: bjschuma@netapp.com To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, Bryan Schumaker Subject: [PATCH 1/2] NFSD: Clean up fault injection file creation Date: Fri, 8 Jul 2011 16:45:58 -0400 Message-Id: <1310157959-11429-2-git-send-email-bjschuma@netapp.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1310157959-11429-1-git-send-email-bjschuma@netapp.com> References: <1310157959-11429-1-git-send-email-bjschuma@netapp.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 08 Jul 2011 20:46:05 +0000 (UTC) From: Bryan Schumaker I think it is easier to specify an action and an item (such as "forget" and "clients") once, rather than having to state them multiple times for the same macro. Signed-off-by: Bryan Schumaker --- fs/nfsd/fault_inject.c | 39 ++++++++++++++++++++++----------------- 1 files changed, 22 insertions(+), 17 deletions(-) diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c index 3dd1c32..7f5ac83 100644 --- a/fs/nfsd/fault_inject.c +++ b/fs/nfsd/fault_inject.c @@ -12,26 +12,28 @@ static void nfsd_forget_everything(void); struct nfsd_fault_inject_op { - char *name; - char *text; + char *action; + char *item; + char *file; int file_data; void (*func)(void); }; -#define INJECTION_OP(op_name, op_text, op_func) \ -{ \ - .name = op_name, \ - .text = op_text, \ - .func = op_func, \ +#define INJECTION_OP(op_action, op_item, op_func) \ +{ \ + .action = op_action, \ + .item = op_item, \ + .file = op_action"_"op_item, \ + .func = op_func, \ } static struct nfsd_fault_inject_op inject_ops[] = { - INJECTION_OP("forget_clients", "forget all clients", nfsd_forget_all_clients), - INJECTION_OP("forget_locks", "forget all locks", nfsd_forget_all_locks), - INJECTION_OP("forget_open_owners", "forget all open owners", nfsd_forget_all_open_owners), - INJECTION_OP("forget_delegations", "forget all delegations", nfsd_forget_all_delegations), - INJECTION_OP("forget_everything", "forget everything", nfsd_forget_everything), - INJECTION_OP("recall_delegations", "recall all delegations", nfsd_recall_all_delegations), + INJECTION_OP("forget", "clients", nfsd_forget_all_clients), + INJECTION_OP("forget", "locks", nfsd_forget_all_locks), + INJECTION_OP("forget", "open_owners", nfsd_forget_all_open_owners), + INJECTION_OP("forget", "delegations", nfsd_forget_all_delegations), + INJECTION_OP("forget", "everything", nfsd_forget_everything), + INJECTION_OP("recall", "delegations", nfsd_recall_all_delegations), }; static long int NUM_INJECT_OPS = sizeof(inject_ops) / sizeof(struct nfsd_fault_inject_op); @@ -48,10 +50,13 @@ static void nfsd_forget_everything(void) static int nfsd_inject_set(void *data, u64 val) { int i; + struct nfsd_fault_inject_op *op; for (i = 0; i < NUM_INJECT_OPS; i++) { - if (&inject_ops[i].file_data == data) { - printk(KERN_INFO "%s %s Server will %s", __FILE__, __func__, inject_ops[i].text); - inject_ops[i].func(); + op = &inject_ops[i]; + if (&op->file_data == data) { + printk(KERN_INFO "%s %s Server will %s all %s", __FILE__, + __func__, op->action, op->item); + op->func(); } } return 0; @@ -83,7 +88,7 @@ nfsd_fault_inject_init(void) for (i = 0; i < NUM_INJECT_OPS; i++) { op = &inject_ops[i]; - debugfs_create_file(op->name, mode, debug_dir, &op->file_data, &fops_nfsd); + debugfs_create_file(op->file, mode, debug_dir, &op->file_data, &fops_nfsd); } return 0; fail: