All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs: handle register_shrinker error
@ 2017-11-23 12:08 Michal Hocko
  2017-11-23 13:26 ` Christoph Hellwig
  0 siblings, 1 reply; 18+ messages in thread
From: Michal Hocko @ 2017-11-23 12:08 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: Dave Chinner, Tetsuo Handa, linux-xfs, LKML, Michal Hocko

From: Michal Hocko <mhocko@suse.com>

xfs_alloc_buftarg doesn't handle register_shrinker error path. While it
is unlikely to trigger it is not impossible especially with large NUMAs.
Let's handle the failure to make the code more robust.

Signed-off-by: Michal Hocko <mhocko@suse.com>
---

Hi,
this is not tested but it looks quite straightforward. There is one more
unchecked register_shrinker in xfs_qm_init_quotainfo but my absolute
lack of familiarity with the code didn't allow me to come up with a
mechanical fix like this one.

 fs/xfs/xfs_buf.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
index 4db6e8d780f6..dd0e18af990c 100644
--- a/fs/xfs/xfs_buf.c
+++ b/fs/xfs/xfs_buf.c
@@ -1827,7 +1827,10 @@ xfs_alloc_buftarg(
 	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)) {
+		percpu_counter_destroy(&btp->bt_io_count);
+		goto error;
+	}
 	return btp;
 
 error:
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-11-28 19:40 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2017-11-28 16:39                 ` Darrick J. Wong
2017-11-28 19:40                   ` Michal Hocko

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.