From: Al Viro <viro@ZenIV.linux.org.uk>
To: Josef Bacik <josef@redhat.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] Btrfs: fix num_start_workers count if we fail to make an alloc
Date: Sat, 19 Nov 2011 01:37:39 +0000 [thread overview]
Message-ID: <20111119013739.GA30125@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20111118202056.GA2203@ZenIV.linux.org.uk>
On Fri, Nov 18, 2011 at 08:20:56PM +0000, Al Viro wrote:
> On Fri, Nov 18, 2011 at 02:38:54PM -0500, Josef Bacik wrote:
> > Al pointed out that if we fail to start a worker for whatever reason (ENOMEM
> > basically), we could leak our count for num_start_workers, and so we'd think we
> > had more workers than we actually do. This could cause us to shrink workers
> > when we shouldn't or not start workers when we should. So check the return
> > value and if we failed fix num_start_workers and fallback. Thanks,
>
> It's actually uglier than that; consider check_pending_workers_create()
> where we
> * bump the num_start_workers
> * call start_new_worker(), which can fail, and then we have the same
> leak; if it doesn't fail, it schedules a call of start_new_worker_func()
> * when start_new_worker_func() runs, it does btrfs_start_workers(),
> which can run into the same leak again (this time on another pool - one
> we have as ->async_helper).
Nuts... AFAICS, we _always_ leak ->num_start_workers here (i.e. when
check_pending_workers_create() finds ->atomic_start_pending set). In
effect, we bump it once in check_pending_workers_create() itself, then
another time (on the same pool) when start_new_worker_func() calls
btrfs_start_workers(). That one will be dropped when we manage to
start the thread, but the first one won't.
Shouldn't we use __btrfs_start_workers() instead here?
next prev parent reply other threads:[~2011-11-19 1:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-18 19:38 [PATCH] Btrfs: fix num_start_workers count if we fail to make an alloc Josef Bacik
2011-11-18 20:20 ` Al Viro
2011-11-19 1:37 ` Al Viro [this message]
2011-11-19 2:12 ` Al Viro
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=20111119013739.GA30125@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=josef@redhat.com \
--cc=linux-btrfs@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).