[PATCH] xfs_quota: fall back silently if XFS_GETNEXTQUOTA fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After XFS_GETNEXTQUOTA feature has been merged into linux kernel and
xfsprogs, xfs_quota use Q_XGETNEXTQUOTA for report and dump, and
fall back to old XFS_GETQUOTA ioctl if XFS_GETNEXTQUOTA fails.

But when XFS_GETNEXTQUOTA fails, xfs_quota print a warning as
"XFS_GETQUOTA: Invalid argument". That's due to kernel can't
recognize XFS_GETNEXTQUOTA ioctl and return EINVAL. At this time,
the warning is helpless, xfs_quota just need to fall back.

Signed-off-by: Zorro Lang <zlang@xxxxxxxxxx>
---

Hi,

Both dump_file and report_mount have this problem, so I fix them
together.

xfstests xfs/299 can reproduce this bug in report_mount, the
newest xfs/106 can reproduce both(dump and report, hope I didn't
miss others:).

This patch checks "if cmd == XFS_GETQUOTA", but I'm thinking about
if we should check "if !(cmd == XFS_GETNEXTQUOTA && errno == EINVAL)"?

The first one don't print all errors from XFS_GETNEXTQUOTA, but the
second one only for EINVAL error.

So the question become should we:
1) fall back silently if XFS_GETNEXTQUOTA fails?
2) Or fall back silently if kernel has no XFS_GETNEXTQUOTA feature?

I think both of them make sense. What do you think?

Thanks,
Zorro


 quota/report.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/quota/report.c b/quota/report.c
index 59290e1..70220b4 100644
--- a/quota/report.c
+++ b/quota/report.c
@@ -90,8 +90,10 @@ dump_file(
 	else
 		cmd = XFS_GETQUOTA;
 
+	/* Fall back silently if XFS_GETNEXTQUOTA fails, warn on XFS_GETQUOTA */
 	if (xfsquotactl(cmd, dev, type, id, (void *)&d) < 0) {
-		if (errno != ENOENT && errno != ENOSYS && errno != ESRCH)
+		if (errno != ENOENT && errno != ENOSYS && errno != ESRCH &&
+		    cmd == XFS_GETQUOTA)
 			perror("XFS_GETQUOTA");
 		return 0;
 	}
@@ -347,8 +349,10 @@ report_mount(
 	else
 		cmd = XFS_GETQUOTA;
 
+	/* Fall back silently if XFS_GETNEXTQUOTA fails, warn on XFS_GETQUOTA*/
 	if (xfsquotactl(cmd, dev, type, id, (void *)&d) < 0) {
-		if (errno != ENOENT && errno != ENOSYS && errno != ESRCH)
+		if (errno != ENOENT && errno != ENOSYS && errno != ESRCH &&
+		    cmd == XFS_GETQUOTA)
 			perror("XFS_GETQUOTA");
 		return 0;
 	}
-- 
2.7.4

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs



[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux