[PATCH] xfs_quota: XFS_XFLAG_PROJINHERIT is only for dirs

Eric Sandeen
2012-10-12T16:18:24Z

xfs_quota has long set XFS_XFLAG_PROJINHERIT on all files,
and tested for presence on all files. However, Dave's semi-recent
xfs_repair update is now flagging this as an error:

bd5683f xfs_repair: validate inode di_flags field

if (flags & (XFS_DIFLAG_RTINHERIT |
XFS_DIFLAG_EXTSZINHERIT |
XFS_DIFLAG_PROJINHERIT |
XFS_DIFLAG_NOSYMLINKS)) {
/* must be a directory */
if (di_mode && !S_ISDIR(di_mode)) {
do_warn(_(
"directory flags set on non-directory inode %llu"),
lino);

In tests 050, 107, 134, 244, 261 and 287, inserting a _check_scratch_fs
will cause them to fail due to repair finding these errors.

On the one hand, quota has set this flag everywhere for many years. On
the other hand, an *INHERIT flag makes no sense on a non-dir. So I think
the right way to go is to tell quota to stop setting (and checking for)
the flag unconditionally, and do it only for S_ISDIR.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---

note: A little unsure of the new check in check_project. Should we just
leave that to repair?

diff --git a/quota/project.c b/quota/project.c
index a2c7046..7042015 100644
--- a/quota/project.c
+++ b/quota/project.c
@@ -126,8 +126,11 @@ 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 & XFS_XFLAG_PROJINHERIT))
- printf(_("%s - project inheritance flag is not set\n"),
+ if (S_ISDIR(stat->st_mode) && !(fsx.fsx_xflags & XFS_XFLAG_PROJINHERIT))
+ printf(_("%s - project inheritance flag is not set on dir\n"),
+ path);
+ if (!S_ISDIR(stat->st_mode) && (fsx.fsx_xflags & XFS_XFLAG_PROJINHERIT))
+ printf(_("%s - project inheritance flag is set on non-dir\n"),
path);
}
if (fd != -1)
@@ -219,7 +222,8 @@ setup_project(
}

fsx.fsx_projid = prid;
- fsx.fsx_xflags |= XFS_XFLAG_PROJINHERIT;
+ if (S_ISDIR(stat->st_mode))
+ fsx.fsx_xflags |= XFS_XFLAG_PROJINHERIT;
if (xfsctl(path, fd, XFS_IOC_FSSETXATTR, &fsx) < 0) {
exitcode = 1;
fprintf(stderr, _("%s: cannot set project on %s: %s\n"),