Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3289187imm; Sun, 29 Jul 2018 15:08:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfhUiS9LmdecTy6Y1kyG8So0nwDxySxHHCL91y1afbbJMPG5dgPWOyFp1nhM0dGLY0e6vNP X-Received: by 2002:a65:520d:: with SMTP id o13-v6mr13858567pgp.282.1532902108208; Sun, 29 Jul 2018 15:08:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532902108; cv=none; d=google.com; s=arc-20160816; b=lSVUqzQ0nL+JG1UyfEMbKmdviG/4Y6wbQmq5wn6SSFO5jZVJb37cmLS6yCMyoqtA00 CbFu8tMN2D7wyMXfsW/gpqphUCS3XMsYLI6fTKWB4FZ2Zf8WG+STtzKmaUWyyPNc4bK/ uqvOBF//01SCGoZPLXRdCxxUdTmEbteF3pMXQdOqYBVPPn2ZBN7qwTwlsjwfYmwe6B5s Jeg1I8n0yLMsZdxxryr38/aRfCdTfWBM+6+NZ2E5acUA2N3okafmBHbnPhrPzKDmYCke k9g6yQORvht2eQJPWkrsneDA63u7gzZvppHKZQssX3KK7BJkeLDNNJeP/ZV599+LAkWx hRSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=OyA7rn6FemdVGnt/ka7kQEqwUMOnLEeAPFoDNTqcdOU=; b=etiUIhIPajxPJe0d+xY7zvXuCp5YebLNk7JKGpfAwsp9Tlnz48HnaRtJnbjEPg+Qok YolLYnx8Z1brE2hVsDoglnvJLH+k68Bt2LfNc7q2GcvimlgCX3da75Qo9hXSWgMqLyK5 3d8YU5C/nY0Oc2pdBBvOgDm8e6YpM+MN2ZadMUSJ17V2M4WTkCnQLwEwJeIXCgDuN7W1 17s599JFSPeeJg6c+FqWYqN6nzicluyrtBr2iTbGUS/K3Ex4NAvqP0oFKDc5WkiKBFie M2bVeNWda3wE1hovJFl5vs9BTd0iACPSrUpIkoiCWazSDuuAGvb8UZXjA2h+syHH0uy5 OUsg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6-v6si7718617pgv.669.2018.07.29.15.08.13; Sun, 29 Jul 2018 15:08:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732100AbeG2Xg4 (ORCPT + 99 others); Sun, 29 Jul 2018 19:36:56 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:51580 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbeG2Xg4 (ORCPT ); Sun, 29 Jul 2018 19:36:56 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.87 #1 (Red Hat Linux)) id 1fjto6-0003VL-3v; Sun, 29 Jul 2018 22:04:54 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Miklos Szeredi Subject: [PATCH 03/16] vfs: don't evict uninitialized inode Date: Sun, 29 Jul 2018 23:04:40 +0100 Message-Id: <20180729220453.13431-3-viro@ZenIV.linux.org.uk> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20180729220453.13431-1-viro@ZenIV.linux.org.uk> References: <20180729220317.GB30522@ZenIV.linux.org.uk> <20180729220453.13431-1-viro@ZenIV.linux.org.uk> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miklos Szeredi iput() ends up calling ->evict() on new inode, which is not yet initialized by owning fs. So use destroy_inode() instead. Add to sb->s_inodes list only if inode is not in I_CREATING state (meaning that it wasn't allocated with new_inode(), which already does the insertion). Reported-by: Al Viro Signed-off-by: Miklos Szeredi Fixes: 80ea09a002bf ("vfs: factor out inode_insert5()") Signed-off-by: Al Viro --- fs/inode.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 04dd7e0d5142..0aa5b29b6f87 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1050,6 +1050,7 @@ struct inode *inode_insert5(struct inode *inode, unsigned long hashval, { struct hlist_head *head = inode_hashtable + hash(inode->i_sb, hashval); struct inode *old; + bool creating = inode->i_state & I_CREATING; again: spin_lock(&inode_hash_lock); @@ -1083,6 +1084,8 @@ struct inode *inode_insert5(struct inode *inode, unsigned long hashval, inode->i_state |= I_NEW; hlist_add_head(&inode->i_hash, head); spin_unlock(&inode->i_lock); + if (!creating) + inode_sb_list_add(inode); unlock: spin_unlock(&inode_hash_lock); @@ -1117,12 +1120,13 @@ struct inode *iget5_locked(struct super_block *sb, unsigned long hashval, struct inode *inode = ilookup5(sb, hashval, test, data); if (!inode) { - struct inode *new = new_inode(sb); + struct inode *new = alloc_inode(sb); if (new) { + new->i_state = 0; inode = inode_insert5(new, hashval, test, set, data); if (unlikely(inode != new)) - iput(new); + destroy_inode(new); } } return inode; -- 2.11.0