gfs2: fix to detect failure of register_shrinker
authorChao Yu <yuchao0@huawei.com>
Wed, 21 Sep 2016 17:09:40 +0000 (12:09 -0500)
committerBob Peterson <rpeterso@redhat.com>
Wed, 21 Sep 2016 17:09:40 +0000 (12:09 -0500)
register_shrinker can fail after commit 1d3d4437eae1 ("vmscan: per-node
deferred work"), we should detect the failure of it, otherwise we may
fail to register shrinker after gfs2 module was been inited successfully.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
fs/gfs2/glock.c
fs/gfs2/main.c

index c8e2e7f620517f1eeb8fb5f08e5e4ee37431965d..14cbf60167a7aed5532f5adaf848dd32c432c138 100644 (file)
@@ -1781,7 +1781,13 @@ int __init gfs2_glock_init(void)
                return -ENOMEM;
        }
 
-       register_shrinker(&glock_shrinker);
+       ret = register_shrinker(&glock_shrinker);
+       if (ret) {
+               destroy_workqueue(gfs2_delete_workqueue);
+               destroy_workqueue(glock_workqueue);
+               rhashtable_destroy(&gl_hash_table);
+               return ret;
+       }
 
        return 0;
 }
index 74fd0139e6c2edf8db28af3423ff6f5680e6a0e8..67d1fc4668f77730f879710ba2d393cfd579d1be 100644 (file)
@@ -145,7 +145,9 @@ static int __init init_gfs2_fs(void)
        if (!gfs2_qadata_cachep)
                goto fail;
 
-       register_shrinker(&gfs2_qd_shrinker);
+       error = register_shrinker(&gfs2_qd_shrinker);
+       if (error)
+               goto fail;
 
        error = register_filesystem(&gfs2_fs_type);
        if (error)