From patchwork Thu Nov 23 13:35:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10072805 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 56ECC60353 for ; Thu, 23 Nov 2017 13:36:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4020E2A063 for ; Thu, 23 Nov 2017 13:36:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 34E5A2A06B; Thu, 23 Nov 2017 13:36:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A3A82A068 for ; Thu, 23 Nov 2017 13:36:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752829AbdKWNfv (ORCPT ); Thu, 23 Nov 2017 08:35:51 -0500 Received: from www262.sakura.ne.jp ([202.181.97.72]:14077 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752734AbdKWNfu (ORCPT ); Thu, 23 Nov 2017 08:35:50 -0500 Received: from fsav408.sakura.ne.jp (fsav408.sakura.ne.jp [133.242.250.107]) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id vANDZYKF072544; Thu, 23 Nov 2017 22:35:35 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav408.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav408.sakura.ne.jp); Thu, 23 Nov 2017 22:35:34 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav408.sakura.ne.jp) Received: from AQUA (softbank126072090071.bbtec.net [126.72.90.71]) (authenticated bits=0) by www262.sakura.ne.jp (8.14.5/8.14.5) with ESMTP id vANDZYw9072541; Thu, 23 Nov 2017 22:35:34 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) To: jack@suse.cz, mhocko@kernel.org Cc: viro@zeniv.linux.org.uk, david@fromorbit.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, akpm@linux-foundation.org Subject: Re: [PATCH] fs: handle shrinker registration failure in sget_userns From: Tetsuo Handa References: <20171123115247.30685-1-mhocko@kernel.org> <20171123122616.GC6324@quack2.suse.cz> <20171123124541.sjdkavie47wfahrs@dhcp22.suse.cz> <20171123125345.exih2j4jv4shn3yz@dhcp22.suse.cz> <20171123125626.GD6324@quack2.suse.cz> In-Reply-To: <20171123125626.GD6324@quack2.suse.cz> Message-Id: <201711232235.CDI34369.FLOtQVHFSJOOMF@I-love.SAKURA.ne.jp> X-Mailer: Winbiff [Version 2.51 PL2] X-Accept-Language: ja,en,zh Date: Thu, 23 Nov 2017 22:35:34 +0900 Mime-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Jan Kara wrote: > Looks good to me now. You can add: > > Reviewed-by: Jan Kara > It does not look good to me, for "goto fail" can call destroy_unused_super() before s->s_shrink.list is initialized. Also, the comment block saying "this object isn't exposed yet" wants to be updated? --- fs/super.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fs/super.c b/fs/super.c index 80b118c..44f0c6b 100644 --- a/fs/super.c +++ b/fs/super.c @@ -197,6 +197,7 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, if (!s) return NULL; + INIT_LIST_HEAD(&s->s_shrink.list); INIT_LIST_HEAD(&s->s_mounts); s->s_user_ns = get_user_ns(user_ns); @@ -260,9 +261,8 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags, s->s_shrink.count_objects = super_cache_count; s->s_shrink.batch = 1024; s->s_shrink.flags = SHRINKER_NUMA_AWARE | SHRINKER_MEMCG_AWARE; - INIT_LIST_HEAD(&s->s_shrink.list); - return s; - + if (register_shrinker(&s->s_shrink) == 0) + return s; fail: destroy_unused_super(s); return NULL; @@ -512,10 +512,6 @@ struct super_block *sget_userns(struct file_system_type *type, s = alloc_super(type, (flags & ~SB_SUBMOUNT), user_ns); if (!s) return ERR_PTR(-ENOMEM); - if (register_shrinker(&s->s_shrink)) { - destroy_unused_super(s); - return ERR_PTR(-ENOMEM); - } goto retry; }