From patchwork Mon Jun 11 11:32:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10457571 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 59770601A0 for ; Mon, 11 Jun 2018 11:32:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BFD128421 for ; Mon, 11 Jun 2018 11:32:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 40BB928429; Mon, 11 Jun 2018 11:32:45 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 F08AA28421 for ; Mon, 11 Jun 2018 11:32:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932860AbeFKLcg (ORCPT ); Mon, 11 Jun 2018 07:32:36 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:35897 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932804AbeFKLcf (ORCPT ); Mon, 11 Jun 2018 07:32:35 -0400 Received: by mail-wr0-f194.google.com with SMTP id f16-v6so20024457wrm.3 for ; Mon, 11 Jun 2018 04:32:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=BvosY+glcajskazeW3QKx7oNpuMskaqjo8F6Czy62cY=; b=Xgbmx+wHheYnG/qHNvQydbn9aGXNWE8sSNqIZBp+1ecXIf7mM/1zmq8Bl7EbFTL9HY lEamNfLfF+A2nK1qX0KbZdFpwQw2XvyuQRSghDm2Tp/zaIWmfYH87SKu6F77lQ2Fvhct v4l7bd8BJDph2nGF3Cd0jsHNx7COieWzSko/o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=BvosY+glcajskazeW3QKx7oNpuMskaqjo8F6Czy62cY=; b=X3hM7bBsEigUc+767Hx79cB4rtSYcOonqFh33WkxMVWv7NoiwJBuhDbi6Pqa1H5lEm h3OPI+2LB1c/GzXVyVyaHkSSsfUXuJxnnwTuNFOTqeHAs7PZLeHCtlwVn0OSKheshs6H bKPwkCevCw1UER9C+5vkimpDarxbwVfONprwRUsEfFG+GqkI4j7u2HwlF+dyxBW8zEs+ Ph9FJMSQ8RO5i3am0FeXiX5mDcmWn6QZJFLJkfWZ2MnHfjVJ4+bZhp04kND4HNR0pr3v vVQvXE78sRvugATW9ZhgPeFujZ2kvg8NlwzzvyFaW9zTR3Lga3fjJ/RrLPq8S4C2qIsM N1/g== X-Gm-Message-State: APt69E2jgNHKj17d6fL3sbnCKTKtd+zSwtq0oFz7z5B07QFgVrg7mGnC WZkx97rYH+GM+i9/AnivX5MoZA== X-Google-Smtp-Source: ADUXVKL4wnyiU9eo5YTUVQjIP9XhexkCT+BIfFouDXmmJ748vXNsIQUdS/OIW1y6PjbDxC+iuaRfsA== X-Received: by 2002:adf:86ae:: with SMTP id 43-v6mr11580554wrx.281.1528716753810; Mon, 11 Jun 2018 04:32:33 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (C2B0E321.catv.pool.telekom.hu. [194.176.227.33]) by smtp.gmail.com with ESMTPSA id z5-v6sm23300034wrh.10.2018.06.11.04.32.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Jun 2018 04:32:32 -0700 (PDT) Date: Mon, 11 Jun 2018 13:32:30 +0200 From: Miklos Szeredi To: Al Viro Cc: Miklos Szeredi , overlayfs , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 09/11] vfs: factor out inode_insert5() Message-ID: <20180611113230.GI23785@veci.piliscsaba.redhat.com> References: <20180529144143.16378-1-mszeredi@redhat.com> <20180529144143.16378-10-mszeredi@redhat.com> <20180610054902.GQ30522@ZenIV.linux.org.uk> <20180610060159.GS30522@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) 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 On Mon, Jun 11, 2018 at 11:15:55AM +0200, Miklos Szeredi wrote: > On Sun, Jun 10, 2018 at 8:02 AM, Al Viro wrote: > > On Sun, Jun 10, 2018 at 06:49:10AM +0100, Al Viro wrote: > >> On Tue, May 29, 2018 at 04:41:41PM +0200, Miklos Szeredi wrote: > >> > From: Miklos Szeredi > >> > > >> > Split out common helper for race free insertion of an already allocated > >> > inode into the cache. Use this from iget5_locked() and > >> > insert_inode_locked4(). Make iget5_locked() use new_inode()/iput() instead > >> > of alloc_inode()/destroy_inode() directly. > >> > >> ... thus hitting the sucker with ->evict_inode(), in condition that is quite > >> likely to be unfit to be seen by that. > >> > >> NAK. > > > > To clarify: objection here is against the switch to new_inode/iput. The rest is > > sane. What makes new_inode() better here, anyway? > > Umm, got to look into this. The patch has already been pulled by > Linus, but I hope it's salvageable. Incremental follows. I think it's cleaner to initialize i_state and i_sb_list up front (hence the use of new_inode()), but could just as well add to sb list afterwards. diff --git a/fs/inode.c b/fs/inode.c index 0df41bb77e0f..03c0d7c1296f 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1098,8 +1098,10 @@ struct inode *iget5_locked(struct super_block *sb, unsigned long hashval, if (new) { inode = inode_insert5(new, hashval, test, set, data); - if (unlikely(inode != new)) - iput(new); + if (unlikely(inode != new)) { + inode_sb_list_del(inode); + destroy_inode(new); + } } } return inode;