All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@kernel.org>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Dave Chinner <david@fromorbit.com>,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	hch@infradead.org, linux-xfs@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] xfs: handle register_shrinker error
Date: Tue, 28 Nov 2017 10:35:51 +0100	[thread overview]
Message-ID: <20171128093551.mjwao7afv75me6ht@dhcp22.suse.cz> (raw)
In-Reply-To: <20171127174453.GC19379@magnolia>

On Mon 27-11-17 09:44:53, Darrick J. Wong wrote:
[...]
> > From 1009db61988c48c9a9e327a9d076945b29b02eee Mon Sep 17 00:00:00 2001
> > From: Michal Hocko <mhocko@suse.com>
> > Date: Thu, 23 Nov 2017 17:13:40 +0100
> > Subject: [PATCH] xfs: fortify xfs_alloc_buftarg error handling
> > 
> > percpu_counter_init failure path doesn't clean up &btp->bt_lru list.
> > Call list_lru_destroy in that error path. Similarly register_shrinker
> > error path is not handled.
> > 
> > While it is unlikely to trigger these error path, it is not impossible
> > especially the later might fail with large NUMAs.  Let's handle the
> > failure to make the code more robust.
> > 
> > Acked-by: Dave Chinner <dchinner@redhat.com>
> > Noticed-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> > Signed-off-by: Michal Hocko <mhocko@suse.com>
> > ---
> >  fs/xfs/xfs_buf.c | 15 ++++++++++-----
> >  1 file changed, 10 insertions(+), 5 deletions(-)
> > 
> > diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> > index 4db6e8d780f6..4c6e86d861fd 100644
> > --- a/fs/xfs/xfs_buf.c
> > +++ b/fs/xfs/xfs_buf.c
> > @@ -1815,22 +1815,27 @@ xfs_alloc_buftarg(
> >  	btp->bt_daxdev = dax_dev;
> >  
> >  	if (xfs_setsize_buftarg_early(btp, bdev))
> > -		goto error;
> > +		goto error_free;
> >  
> >  	if (list_lru_init(&btp->bt_lru))
> > -		goto error;
> > +		goto error_free;
> >  
> >  	if (percpu_counter_init(&btp->bt_io_count, 0, GFP_KERNEL))
> > -		goto error;
> > +		goto error_lru;
> >  
> >  	btp->bt_shrinker.count_objects = xfs_buftarg_shrink_count;
> >  	btp->bt_shrinker.scan_objects = xfs_buftarg_shrink_scan;
> >  	btp->bt_shrinker.seeks = DEFAULT_SEEKS;
> >  	btp->bt_shrinker.flags = SHRINKER_NUMA_AWARE;
> > -	register_shrinker(&btp->bt_shrinker);
> > +	if (register_shrinker(&btp->bt_shrinker))
> > +		goto error_pcpu;
> >  	return btp;
> >  
> > -error:
> > +error_pcpu:
> > +	percpu_counter_destroy(&btp->bt_io_count);
> > +error_lru:
> > +	list_lru_destroy(&btp->bt_lru);
> > +error_free:
> >  	kmem_free(btp);
> >  	return NULL;
> 
> This part looks ok,
> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

Are you going to apply the patch or should I re-send it with
acks/reviewed-by?
-- 
Michal Hocko
SUSE Labs

  reply	other threads:[~2017-11-28  9:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-23 12:08 [PATCH] xfs: handle register_shrinker error Michal Hocko
2017-11-23 13:26 ` Christoph Hellwig
2017-11-23 13:41   ` Michal Hocko
2017-11-23 16:01     ` Tetsuo Handa
2017-11-23 16:11       ` Michal Hocko
2017-11-23 16:17         ` Tetsuo Handa
2017-11-23 16:31           ` Michal Hocko
2017-11-23 22:00         ` Dave Chinner
2017-11-24  7:39           ` [PATCH v2] " Michal Hocko
2017-11-24 12:03             ` Tetsuo Handa
2017-11-24 12:09               ` Michal Hocko
2017-11-25 23:34               ` Dave Chinner
2017-11-26  2:14                 ` Tetsuo Handa
2017-11-27  8:05                   ` Michal Hocko
2017-11-27 17:44             ` Darrick J. Wong
2017-11-28  9:35               ` Michal Hocko [this message]
2017-11-28 16:39                 ` Darrick J. Wong
2017-11-28 19:40                   ` Michal Hocko

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=20171128093551.mjwao7afv75me6ht@dhcp22.suse.cz \
    --to=mhocko@kernel.org \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    /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.