Skip to contentSkip to conversation

xfs_quota: fix false error reporting of project inheritance flag is not set

PATCH Superseded Achilles Gaikwad 3 participants 5 messages Jan 5, 2019 – Jan 6, 2019

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_quota: fix false error reporting of project inheritance flag is not set

xfs_quota project check results in "project inheritance flag is not set" error
https://bugzilla.redhat.com/show_bug.cgi?id=1663502

---
 quota/project.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
quota/project.c +3 -1
index e4e7a012..8c9be08b 100644
@@ -99,6 +99,7 @@ check_project(
 {
 	struct fsxattr		fsx;
 	int			fd;
+	int			isdir;
 
 	if (recurse_depth >= 0 && data->level > recurse_depth)
 		return -1;
@@ -126,7 +127,8 @@ check_project(
 			printf(_("%s - project identifier is not set"
 				 " (inode=%u, tree=%u)\n"),
 				path, fsx.fsx_projid, (unsigned int)prid);
-		if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT))
+		isdir = S_ISDIR(stat->st_mode);
+		if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT) && isdir)
 			printf(_("%s - project inheritance flag is not set\n"),
 				path);
 	}
Signature · 1 line
2.20.1
#1 lore raw
Quoted 14 lines · Achilles Gaikwad

xfs_quota project check results in "project inheritance flag is not set" error
https://bugzilla.redhat.com/show_bug.cgi?id=1663502

---
 quota/project.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
quota/project.c +0 -0
index e4e7a012..8c9be08b 100644

quota/project.c check_project( · line 102

Quoted 4 lines
quota/project.c +1 -0
@@ -99,6 +99,7 @@ check_project(
 {
 	struct fsxattr		fsx;
 	int			fd;
+	int			isdir;

Use bool for boolean values, or...

quota/project.c check_project( · line 131

Quoted 10 lines
quota/project.c +2 -1
 	if (recurse_depth >= 0 && data->level > recurse_depth)
 		return -1;
@@ -126,7 +127,8 @@ check_project(
 			printf(_("%s - project identifier is not set"
 				 " (inode=%u, tree=%u)\n"),
 				path, fsx.fsx_projid, (unsigned int)prid);
-		if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT))
+		isdir = S_ISDIR(stat->st_mode);
+		if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT) && isdir)

...move the S_ISDIR test directly into the if condition test?

Otherwise looks fine to me.

--D

Quoted 6 lines
quota/project.c +0 -0
 			printf(_("%s - project inheritance flag is not set\n"),
 				path);
 	}
Signature · 1 line
2.20.1
#2 lore raw
Quoted 23 lines · Darrick J. Wong
Quoted 14 lines · Achilles Gaikwad

xfs_quota project check results in "project inheritance flag is not set" error
https://bugzilla.redhat.com/show_bug.cgi?id=1663502

---
 quota/project.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
quota/project.c +0 -0
index e4e7a012..8c9be08b 100644

quota/project.c check_project( · line 102

Quoted 4 lines
quota/project.c +1 -0
@@ -99,6 +99,7 @@ check_project(
 {
 	struct fsxattr		fsx;
 	int			fd;
+	int			isdir;

Use bool for boolean values, or...

Quoted 1 line
Quoted 11 lines

quota/project.c check_project( · line 131

Quoted 9 lines
quota/project.c +2 -1
 	if (recurse_depth >= 0 && data->level > recurse_depth)
 		return -1;
@@ -126,7 +127,8 @@ check_project(
 			printf(_("%s - project identifier is not set"
 				 " (inode=%u, tree=%u)\n"),
 				path, fsx.fsx_projid, (unsigned int)prid);
-		if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT))
+		isdir = S_ISDIR(stat->st_mode);
+		if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT) && isdir)

...move the S_ISDIR test directly into the if condition test?

Yup, since isdir is only used once I thought the same thing, TBH.

-Eric

Quoted 12 lines

Otherwise looks fine to me.

--D

Quoted 6 lines
quota/project.c +0 -0
 			printf(_("%s - project inheritance flag is not set\n"),
 				path);
 	}
Signature · 1 line
2.20.1
#3 lore raw

Thanks Darrick and Eric, I'll move the macro into the if condition and send a v2 for this.

Best,
- Achilles

Reviewed-by Brian Foster Reviewed-by on v1 1/1
#4 lore raw
In reply to Achilles Gaikwad
Quoted 1 line · Achilles Gaikwad

xfs_quota project check results in "project inheritance flag is not set" error

Thanks for doing this.

Quoted 1 line

https://bugzilla.redhat.com/show_bug.cgi?id=1663502

As I mentioned in the bug, this started happening after:

commit 9336e3a765b68d4a7fdd8256f393ebce95ecb0a7

Author: Dave Chinner <[email protected]>
Date:   Thu Oct 2 09:18:40 2014 +1000

xfs: project id inheritance is a directory only flag

xfs_set_diflags() allows it to be set on non-directory inodes, and this flags errors in xfs_repair. Further, inode allocation allows the same directory-only flag to be inherited to non-directories. Make sure directory inode flags don't appear on other types of inodes.

This fixes several xfstests scratch fileystem corruption reports (e.g. xfs/050) now that xfstests checks scratch filesystems after test completion.

which is present in v3.18 upstream. i.e. we stopped setting the project inheritance flag on regular files in the kernel, but quotacheck still looks for it in userspace.

It's good to write changelogs that will give full context to future readers, so something like this might be more useful:

===

After kernel commit:

9336e3a7 "xfs: project id inheritance is a directory only flag"

xfs stopped setting the project inheritance flag on regular files, but userspace quota code still checks for it and will now issue the error:

"project inheritance flag is not set"

for every regular file during quotacheck. Fix this by only checking for the flag on directories.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1663502

===

But the change itself is fine, so:

Also, this should really have an xfstest, because it's been broken for a long time, and only just now turned up...

Thanks,
-Eric

Quoted 33 lines

---

 quota/project.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
quota/project.c +3 -1
index e4e7a012..8c9be08b 100644
@@ -99,6 +99,7 @@ check_project(
 {
 	struct fsxattr		fsx;
 	int			fd;
+	int			isdir;
 
 	if (recurse_depth >= 0 && data->level > recurse_depth)
 		return -1;
@@ -126,7 +127,8 @@ check_project(
 			printf(_("%s - project identifier is not set"
 				 " (inode=%u, tree=%u)\n"),
 				path, fsx.fsx_projid, (unsigned int)prid);
-		if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT))
+		isdir = S_ISDIR(stat->st_mode);
+		if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT) && isdir)
 			printf(_("%s - project inheritance flag is not set\n"),
 				path);
 	}