From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S971626AbeCSVhu (ORCPT ); Mon, 19 Mar 2018 17:37:50 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:33770 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933303AbeCSVhn (ORCPT ); Mon, 19 Mar 2018 17:37:43 -0400 X-Google-Smtp-Source: AG47ELux3p4s54kvdPv5HA0grVLmRExNwUzZ9IyKu7t8qk+QI0m+YfEvIKjg0s8BJoU23KV7ZLKJTZya+h1SGBGrrz4= MIME-Version: 1.0 In-Reply-To: References: From: Cong Wang Date: Mon, 19 Mar 2018 14:37:22 -0700 Message-ID: Subject: Re: xfs: list corruption in xfs_setup_inode() To: Dave Chinner , darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org, LKML , Christoph Hellwig , Al Viro Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 30, 2017 at 2:55 PM, Cong Wang wrote: > Hello, > > We triggered a list corruption (double add) warning below on our 4.9 > kernel (the 4.9 kernel we use is based on -stable release, with only a > few unrelated networking backports): We still keep getting this warning on 4.9 kernel. Looking into this again, it seems xfs_setup_inode() could be called twice if an XFS inode is gotten from disk? Once in xfs_iget() => xfs_setup_existing_inode(), and once in xfs_ialloc(). Does the following patch (compile-only) make any sense? Again, I don't want to pretend to understand XFS... diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 604ee384a00a..6761b1f8fa2f 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -775,6 +775,7 @@ xfs_ialloc( int error; struct timespec tv; struct inode *inode; + bool had_imode; /* * Call the space management code to pick @@ -801,6 +802,7 @@ xfs_ialloc( return error; ASSERT(ip != NULL); inode = VFS_I(ip); + had_imode = !!inode->i_mode; /* * We always convert v1 inodes to v2 now - we only support filesystems @@ -946,7 +948,8 @@ xfs_ialloc( xfs_trans_log_inode(tp, ip, flags); /* now that we have an i_mode we can setup the inode structure */ - xfs_setup_inode(ip); + if (!had_imode) + xfs_setup_inode(ip); *ipp = ip; return 0;