From patchwork Sun Sep 25 10:09:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 9349647 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 567EC601C2 for ; Sun, 25 Sep 2016 10:10:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 389E128C1C for ; Sun, 25 Sep 2016 10:10:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 14CC728C9F; Sun, 25 Sep 2016 10:10: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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from oss.sgi.com (oss.sgi.com [192.48.182.195]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4EBC328C1C for ; Sun, 25 Sep 2016 10:10:22 +0000 (UTC) Received: from oss.sgi.com (localhost [IPv6:::1]) by oss.sgi.com (Postfix) with ESMTP id 3536D7CA1; Sun, 25 Sep 2016 05:10:20 -0500 (CDT) X-Original-To: xfs@oss.sgi.com Delivered-To: xfs@oss.sgi.com Received: from relay.sgi.com (relay1.corp.sgi.com [137.38.102.111]) by oss.sgi.com (Postfix) with ESMTP id A0E337CA0 for ; Sun, 25 Sep 2016 05:10:16 -0500 (CDT) Received: from cuda.sgi.com (cuda2.sgi.com [192.48.176.25]) by relay1.corp.sgi.com (Postfix) with ESMTP id 640508F8040 for ; Sun, 25 Sep 2016 03:10:13 -0700 (PDT) X-ASG-Debug-ID: 1474798208-0bf57b1c5ca7b70001-NocioJ Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by cuda.sgi.com with ESMTP id Fv6GhxcDljjeCZ83 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Sun, 25 Sep 2016 03:10:09 -0700 (PDT) X-Barracuda-Envelope-From: eguan@redhat.com X-Barracuda-Effective-Source-IP: mx1.redhat.com[209.132.183.28] X-Barracuda-Apparent-Source-IP: 209.132.183.28 X-ASG-Whitelist: Client Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8E6C57F7A5; Sun, 25 Sep 2016 10:10:08 +0000 (UTC) Received: from localhost (vpn1-6-18.pek2.redhat.com [10.72.6.18]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u8PAA60Y008926; Sun, 25 Sep 2016 06:10:07 -0400 From: Eryu Guan To: linux-xfs@vger.kernel.org Subject: [PATCH] libxcmd: fix counting of xfs entries in fs_table_insert Date: Sun, 25 Sep 2016 18:09:22 +0800 X-ASG-Orig-Subj: [PATCH] libxcmd: fix counting of xfs entries in fs_table_insert Message-Id: <1474798162-25960-1-git-send-email-eguan@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Sun, 25 Sep 2016 10:10:08 +0000 (UTC) X-Barracuda-Connect: mx1.redhat.com[209.132.183.28] X-Barracuda-Start-Time: 1474798209 X-Barracuda-Encrypted: ECDHE-RSA-AES256-GCM-SHA384 X-Barracuda-URL: https://192.48.176.25:443/cgi-mod/mark.cgi X-Barracuda-Scan-Msg-Size: 1525 X-Virus-Scanned: by bsmtpd at sgi.com X-Barracuda-BRTS-Status: 1 Cc: billodo@redhat.com, Eryu Guan , xfs@oss.sgi.com X-BeenThere: xfs@oss.sgi.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: XFS Filesystem from SGI List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xfs-bounces@oss.sgi.com Sender: xfs-bounces@oss.sgi.com X-Virus-Scanned: ClamAV using ClamSMTP Commit bb80e3d6cd04 ("libxcmd: populate fs table with xfs entries first, foreign entries last") adds a new counter "xfs_fs_count" and increases the counter when inserting an XFS entry. But it missed a counter when fs_count is zero (inserting the first path) and the entry has no FS_FOREIGN bit set, i.e. the first XFS entry doesn't increase xfs_fs_count. This results in args_command() mess and infinite loop in xfs/244 when testing v4 XFS (xfs/244 notrun on v5 XFS, but this bug still reproduces on v5 XFS). e.g. mkfs -t xfs -f /dev/sda5 mount -o pquota /dev/sda5 /mnt/xfs mkdir /mnt/xfs/project touch /mnt/xfs/project/testfile xfs_quota -x -c "project -s -p /mnt/xfs/project/testfile 1" /dev/sda5 Fix it by increasing xfs_fs_count when flags has no FS_FOREIGN bit. Signed-off-by: Eryu Guan Reviewed-by: Christoph Hellwig --- libxcmd/paths.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libxcmd/paths.c b/libxcmd/paths.c index 3455217..97f47cf 100644 --- a/libxcmd/paths.c +++ b/libxcmd/paths.c @@ -147,7 +147,6 @@ fs_table_insert( memmove(&fs_table[xfs_fs_count + 1], &fs_table[xfs_fs_count], sizeof(fs_path_t)*(fs_count - xfs_fs_count)); fs_path = &fs_table[xfs_fs_count]; - xfs_fs_count++; } fs_path->fs_dir = dir; fs_path->fs_prid = prid; @@ -159,6 +158,8 @@ fs_table_insert( fs_path->fs_logdev = logdev; fs_path->fs_rtdev = rtdev; fs_count++; + if (!(flags & FS_FOREIGN)) + xfs_fs_count++; return 0;