Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp768076ybh; Wed, 11 Mar 2020 10:23:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuXfcU764RhmfUghvW/G8JbYv5k+TKMwLrTUuThWCRJX8umCBxhtMR7XmtiDMWzTVC/7cGQ X-Received: by 2002:aca:c415:: with SMTP id u21mr2721169oif.49.1583947394442; Wed, 11 Mar 2020 10:23:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583947394; cv=none; d=google.com; s=arc-20160816; b=LS8bQHZd4hBdewTSS7wnVnUFF9yV74M4oiLqzmhJK4WbdnxS9vQhCGkOPtZkTGFetr 67DuKwuZrVsf1N7WGe2zhMAEY/oaB8ONosmmPxhiAn40m4RtBWkHxNg7G8u4/xUBIdvw gCSPtbeLe++kNOtIw8qXKhQLpdi6oL6/emoAwGeVAXvLQqS4fo08yNTqm5D5S4pJEzuA ZAvq6brzyGWNHWN6uuyspBKxW67NafQC8UAEY+BgaZtUCQ/WD6/OI5HyyKwQ1tsRfqps 9o901CYzOzsZzKNMrQa8ZyZx6hCsTgCVpFTlk9eEBcUMfWWQLD5Ua6Rwx7BCOR3AQADt vGeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=hq4VZjlxbrU0jNzTpzaoNvLaQplAsXRczdZekFK1DRo=; b=xvSXWHS6LQirctVAQA81ApJ8mEO3Kx5FHi+AYizpSHyLphxyhsAhjD2PDTXM9NW2XI 1C/NN/zqTib2FJZsBBlC9E1u8BFV9BerFWZLITFwQAKYHsTj+wHTJnbiu280spJmYEB4 1QxIwlkTiAqEOpTUOEGSi3YlC7NaFSmZ1SITPTuoSHFxwH3aIGpjjYFUUtCUVgx7SdiG gPyMfoD9ZYJqTJkID+9cBA/Akd+wHAs//z+KrsEgTOLhKDQ4nEchDLGvqHNxaozkqPnd BDpCzUUHXjyf3RKJZnhQVwCp+rgg3btRRJNnJFTy/8uvzobKmP/xTXD1ZaV8s3aFZD+i VVBA== 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 d8si403718oom.65.2020.03.11.10.23.00; Wed, 11 Mar 2020 10:23:14 -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 S1730385AbgCKRWi (ORCPT + 99 others); Wed, 11 Mar 2020 13:22:38 -0400 Received: from verein.lst.de ([213.95.11.211]:60536 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730351AbgCKRWi (ORCPT ); Wed, 11 Mar 2020 13:22:38 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id CC68568B05; Wed, 11 Mar 2020 18:22:34 +0100 (CET) Date: Wed, 11 Mar 2020 18:22:34 +0100 From: "hch@lst.de" To: "Rantala, Tommi T. (Nokia - FI/Espoo)" Cc: "hch@lst.de" , "david@fromorbit.com" , "darrick.wong@oracle.com" , "linux-xfs@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: 5.5 XFS getdents regression? Message-ID: <20200311172234.GA26340@lst.de> References: <72c5fd8e9a23dde619f70f21b8100752ec63e1d2.camel@nokia.com> <20200310221406.GO10776@dread.disaster.area> <862b6c718957aff7156bf04964b7242f5075e8a7.camel@nokia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <862b6c718957aff7156bf04964b7242f5075e8a7.camel@nokia.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 11, 2020 at 05:06:16PM +0000, Rantala, Tommi T. (Nokia - FI/Espoo) wrote: > On Wed, 2020-03-11 at 09:14 +1100, Dave Chinner wrote: > > On Tue, Mar 10, 2020 at 08:45:58AM +0000, Rantala, Tommi T. (Nokia - > > FI/Espoo) wrote: > > > Hello, > > > > > > One of my GitLab CI jobs stopped working after upgrading server > > > 5.4.18- > > > 100.fc30.x86_64 -> 5.5.7-100.fc30.x86_64. > > > (tested 5.5.8-100.fc30.x86_64 too, no change) > > > The server is fedora30 with XFS rootfs. > > > The problem reproduces always, and takes only couple minutes to run. > > > > > > The CI job fails in the beginning when doing "git clean" in docker > > > container, and failing to rmdir some directory: > > > "warning: failed to remove > > > .vendor/pkg/mod/golang.org/x/net@v0.0.0-20200114155413-6afb5195e5aa/in > > > tern > > > al/socket: Directory not empty" > > > > > > Quick google search finds some other people reporting similar problems > > > with 5.5.0: > > > https://gitlab.com/gitlab-org/gitlab-runner/issues/3185 > > > > Which appears to be caused by multiple gitlab processes modifying > > the directory at the same time. i.e. something is adding an entry to > > the directory at the same time something is trying to rm -rf it. > > That's a race condition, and would lead to the exact symptoms you > > see here, depending on where in the directory the new entry is > > added. > > OK traced "execve" with strace too, and it shows that it's "git clean > -ffdx" command (single process) that is being executed in the container, > which is doing the cleanup. > > Tested with 5.6-rc5, it's failing the same way. > > Spent some time to bisect this, and the problem is introduced by this: > > commit 263dde869bd09b1a709fd92118c7fff832773689 > Author: Christoph Hellwig > Date: Fri Nov 8 15:05:32 2019 -0800 > > xfs: cleanup xfs_dir2_block_getdents > > Use an offset as the main means for iteration, and only do pointer > arithmetics to find the data/unused entries. > > Signed-off-by: Christoph Hellwig > Reviewed-by: Darrick J. Wong > Signed-off-by: Darrick J. Wong > > > > Hmmmmm, looking at that commit, I think it slighty changed how the > "offset" is used compared to how the pointers were used. > > This cures the issue for me, tested (briefly) on top of 5.6-rc5. > Does it make sense...? > (Email client probably damages white-space, sorry, I'll send this properly > signed-off with git-send-email if it's OK) Thanks, this looks good. Although I wonder if the slightly different version below might be a little more elegant? diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c index 0d3b640cf1cc..871ec22c9aee 100644 --- a/fs/xfs/xfs_dir2_readdir.c +++ b/fs/xfs/xfs_dir2_readdir.c @@ -147,7 +147,7 @@ xfs_dir2_block_getdents( xfs_off_t cook; struct xfs_da_geometry *geo = args->geo; int lock_mode; - unsigned int offset; + unsigned int offset, next_offset; unsigned int end; /* @@ -173,9 +173,10 @@ xfs_dir2_block_getdents( * Loop over the data portion of the block. * Each object is a real entry (dep) or an unused one (dup). */ - offset = geo->data_entry_offset; end = xfs_dir3_data_end_offset(geo, bp->b_addr); - while (offset < end) { + for (offset = geo->data_entry_offset; + offset < end; + offset = next_offset) { struct xfs_dir2_data_unused *dup = bp->b_addr + offset; struct xfs_dir2_data_entry *dep = bp->b_addr + offset; uint8_t filetype; @@ -184,14 +185,15 @@ xfs_dir2_block_getdents( * Unused, skip it. */ if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) { - offset += be16_to_cpu(dup->length); + next_offset = offset + be16_to_cpu(dup->length); continue; } /* * Bump pointer for the next iteration. */ - offset += xfs_dir2_data_entsize(dp->i_mount, dep->namelen); + next_offset = offset + + xfs_dir2_data_entsize(dp->i_mount, dep->namelen); /* * The entry is before the desired starting point, skip it.