lkml.org 
[lkml]   [2017]   [Nov]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] xfs: handle register_shrinker error
Date
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
\
 
 \ /
  Last update: 2017-11-23 13:09    [W:0.059 / U:0.124 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site