From: "Verma, Vishal L" <vishal.l.verma@intel.com>
To: "Williams, Dan J" <dan.j.williams@intel.com>,
"jmoyer@redhat.com" <jmoyer@redhat.com>
Cc: "linux-nvdimm@lists.01.org" <linux-nvdimm@lists.01.org>
Subject: Re: [patch] btt: fix uninitialized err_lock
Date: Wed, 13 Dec 2017 21:38:39 +0000 [thread overview]
Message-ID: <1513201117.3301.127.camel@intel.com> (raw)
In-Reply-To: <x49d13i9uui.fsf@segfault.boston.devel.redhat.com>
On Wed, 2017-12-13 at 16:33 -0500, Jeff Moyer wrote:
> Hi,
>
> When a sector mode namespace is initially created, the arena's
> err_lock
> is not initialized. If, on the other hand, the namespace already
> exists, the mutex is initialized. To fix the issue, I moved the
> mutex
> initialization into the arena_alloc, which is called by both
> discover_arenas and create_arenas.
>
> This was discovered on an older kernel where mutex_trylock checks the
> count to determine whether the lock is held. Because the data
> structure
> is kzalloc-d, that count was 0 (held), and I/O to the device would
> hang
> forever waiting for the lock to be released (see btt_write_pg, for
> example). Current kernels have a different mutex implementation that
> checks for a non-null owner, and so this doesn't show up as a
> problem.
> If that lock were ever contended, it might cause issues, but you'd
> have
> to be really unlucky, I think.
>
> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Ah, good find - the fix looks good to me.
Reviewed-by: Vishal Verma <vishal.l.verma@intel.com>
>
> diff --git a/drivers/nvdimm/btt.c b/drivers/nvdimm/btt.c
> index e949e33..5860f99 100644
> --- a/drivers/nvdimm/btt.c
> +++ b/drivers/nvdimm/btt.c
> @@ -630,6 +630,7 @@ static struct arena_info *alloc_arena(struct btt
> *btt, size_t size,
> return NULL;
> arena->nd_btt = btt->nd_btt;
> arena->sector_size = btt->sector_size;
> + mutex_init(&arena->err_lock);
>
> if (!size)
> return arena;
> @@ -758,7 +759,6 @@ static int discover_arenas(struct btt *btt)
> arena->external_lba_start = cur_nlba;
> parse_arena_meta(arena, super, cur_off);
>
> - mutex_init(&arena->err_lock);
> ret = btt_freelist_init(arena);
> if (ret)
> goto out;
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2017-12-13 21:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-13 21:33 [patch] btt: fix uninitialized err_lock Jeff Moyer
2017-12-13 21:38 ` Verma, Vishal L [this message]
2018-01-15 18:16 ` Jeff Moyer
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=1513201117.3301.127.camel@intel.com \
--to=vishal.l.verma@intel.com \
--cc=dan.j.williams@intel.com \
--cc=jmoyer@redhat.com \
--cc=linux-nvdimm@lists.01.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.