From: "J. Bruce Fields" <bfields@fieldses.org>
To: bjschuma@netapp.com
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/3] NFSD: Added fault injection
Date: Fri, 28 Oct 2011 17:24:50 -0400 [thread overview]
Message-ID: <20111028212450.GA7441@fieldses.org> (raw)
In-Reply-To: <1319455259-3136-1-git-send-email-bjschuma@netapp.com>
On Mon, Oct 24, 2011 at 07:20:57AM -0400, bjschuma@netapp.com wrote:
...
> diff --git a/fs/nfsd/fault_inject.c b/fs/nfsd/fault_inject.c
> new file mode 100644
> index 0000000..1ac4134
> --- /dev/null
> +++ b/fs/nfsd/fault_inject.c
> @@ -0,0 +1,90 @@
...
> +int nfsd_fault_inject_init(void)
> +{
> + unsigned int i;
> + struct nfsd_fault_inject_op *op;
> + mode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
> +
> + debug_dir = debugfs_create_dir("nfsd", NULL);
> + if (!debug_dir)
> + goto fail;
> +
> + for (i = 0; i < NUM_INJECT_OPS; i++) {
> + op = &inject_ops[i];
> + debugfs_create_file(op->file, mode, debug_dir, op, &fops_nfsd);
I think you need to check the return value and "goto fail" on NULL.
(Do you also need to put the returned dentry on success? Checking other
callers.... No, I guess not, OK.)
> + }
> + return 0;
> +
> +fail:
> + nfsd_fault_inject_cleanup();
> + return -ENOMEM;
> +}
...
> diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> index db34a58..e67f30c 100644
> --- a/fs/nfsd/nfsctl.c
> +++ b/fs/nfsd/nfsctl.c
...
> @@ -1130,6 +1131,9 @@ static int __init init_nfsd(void)
> retval = nfs4_state_init(); /* nfs4 locking state */
> if (retval)
> return retval;
> + retval = nfsd_fault_inject_init(); /* nfsd fault injection controls */
> + if (retval)
> + goto out_cleanup_fault_injection;
> nfsd_stat_init(); /* Statistics */
> retval = nfsd_reply_cache_init();
> if (retval)
> @@ -1161,6 +1165,8 @@ out_free_cache:
> out_free_stat:
> nfsd_stat_shutdown();
> nfsd4_free_slabs();
> +out_cleanup_fault_injection:
> + nfsd_fault_inject_cleanup();
Check the cleanup here again.... The slabs are allocated in state_init,
so you need to do that on nfsd_fault_inject_init, but you *don't* need
the fault_inject_cleanup in that case, since fault_inject_init cleanup
cleans up after itself--that's needed only on later failures.
--b.
> return retval;
> }
>
> @@ -1174,6 +1180,7 @@ static void __exit exit_nfsd(void)
> nfsd_lockd_shutdown();
> nfsd_idmap_shutdown();
> nfsd4_free_slabs();
> + nfsd_fault_inject_cleanup();
> unregister_filesystem(&nfsd_fs_type);
> }
>
> --
> 1.7.7
>
next prev parent reply other threads:[~2011-10-28 21:24 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-24 11:20 [PATCH 1/3] NFSD: Added fault injection bjschuma
2011-10-24 11:20 ` [PATCH 2/3] NFSD: Added fault injection script bjschuma
2011-10-24 11:20 ` [PATCH 3/3] NFSD: Added fault injection documentation bjschuma
2011-10-28 21:24 ` J. Bruce Fields [this message]
2011-11-01 14:08 ` [PATCH 1/3] NFSD: Added fault injection Bryan Schumaker
2011-11-01 14:17 ` J. Bruce Fields
2011-11-01 14:22 ` Bryan Schumaker
2011-11-01 14:35 ` J. Bruce Fields
-- strict thread matches above, loose matches on Subject: below --
2011-11-01 17:35 bjschuma
2011-11-04 21:30 ` J. Bruce Fields
2011-10-07 17:44 bjschuma
2011-10-17 22:18 ` J. Bruce Fields
2011-10-17 22:57 ` Bryan Schumaker
2011-10-18 17:43 ` J. Bruce Fields
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20111028212450.GA7441@fieldses.org \
--to=bfields@fieldses.org \
--cc=bjschuma@netapp.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).