xfs
[Top] [All Lists]

[PATCH] libxcmd: fix counting of xfs entries in fs_table_insert

To: linux-xfs@xxxxxxxxxxxxxxx
Subject: [PATCH] libxcmd: fix counting of xfs entries in fs_table_insert
From: Eryu Guan <eguan@xxxxxxxxxx>
Date: Sun, 25 Sep 2016 18:09:22 +0800
Cc: xfs@xxxxxxxxxxx, billodo@xxxxxxxxxx, Eryu Guan <eguan@xxxxxxxxxx>
Delivered-to: xfs@xxxxxxxxxxx
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 <eguan@xxxxxxxxxx>
---
 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;
 
-- 
2.7.4

<Prev in Thread] Current Thread [Next in Thread>