Whamcloud - gitweb
LU-12383 utils: only check project inherit bit for dir 76/35076/2
authorWang Shilong <wshilong@ddn.com>
Thu, 6 Jun 2019 02:36:39 +0000 (10:36 +0800)
committerOleg Drokin <green@whamcloud.com>
Sun, 16 Jun 2019 03:31:54 +0000 (03:31 +0000)
Currently, ZFS won't set inherit bit on regular files, but
ext4 always set it, it doesn't make sense for regular files
have this bit, but own it won't do any harm as well.

To make test happy and give a consistent view on users,
let's fix project check only complain erros for Direcotry.

Test-Parameters: trivial testlist=sanity-quota
Change-Id: I194f3ed9d6ded69313a683995295ab8c07b4fb3a
Signed-off-by: Wang Shilong <wshilong@ddn.com>
Reviewed-on: https://review.whamcloud.com/35076
Tested-by: Jenkins
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Nathaniel Clark <nclark@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-quota.sh
lustre/utils/lfs_project.c

index ee01ef1..a7cf361 100755 (executable)
@@ -2910,8 +2910,8 @@ test_54() {
        #clear project but with kept projid
        change_project -rCk $DIR/$tdir
        proj_count1=$(lfs project -rcp $TSTPRJID $DIR/$tdir | wc -l)
        #clear project but with kept projid
        change_project -rCk $DIR/$tdir
        proj_count1=$(lfs project -rcp $TSTPRJID $DIR/$tdir | wc -l)
-       [ $proj_count1 -eq $proj_count ] ||
-                       error "c3: expected $proj_count got $proj_count1"
+       [ $proj_count1 -eq 1 ] ||
+                       error "c3: expected 1 got $proj_count1"
 
        #verify projid untouched.
        proj_count1=$(lfs project -r $DIR/$tdir | grep -c $TSTPRJID)
 
        #verify projid untouched.
        proj_count1=$(lfs project -r $DIR/$tdir | grep -c $TSTPRJID)
index 8d3ee2f..55caae5 100644 (file)
@@ -90,12 +90,12 @@ static const char *mode_to_type(mode_t mode)
        return "unknown";
 }
 
        return "unknown";
 }
 
-static int project_get_xattr(const char *pathname, struct fsxattr *fsx)
+static int project_get_xattr(const char *pathname, struct fsxattr *fsx,
+                            struct stat *st)
 {
        int ret, fd;
 {
        int ret, fd;
-       struct stat st;
 
 
-       ret = lstat(pathname, &st);
+       ret = lstat(pathname, st);
        if (ret) {
                fprintf(stderr, "%s: failed to stat '%s': %s\n",
                        progname, pathname, strerror(errno));
        if (ret) {
                fprintf(stderr, "%s: failed to stat '%s': %s\n",
                        progname, pathname, strerror(errno));
@@ -103,10 +103,10 @@ static int project_get_xattr(const char *pathname, struct fsxattr *fsx)
        }
 
        /* currently, only file and dir supported */
        }
 
        /* currently, only file and dir supported */
-       if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode)) {
+       if (!S_ISREG(st->st_mode) && !S_ISDIR(st->st_mode)) {
                errno = ENOTSUP;
                fprintf(stderr, "%s: unable to get xattr for %s '%s': %s\n",
                errno = ENOTSUP;
                fprintf(stderr, "%s: unable to get xattr for %s '%s': %s\n",
-                               progname, mode_to_type(st.st_mode), pathname,
+                               progname, mode_to_type(st->st_mode), pathname,
                                strerror(errno));
                return -errno;
        }
                                strerror(errno));
                return -errno;
        }
@@ -133,8 +133,9 @@ project_check_one(const char *pathname, struct project_handle_control *phc)
 {
        struct fsxattr fsx;
        int ret;
 {
        struct fsxattr fsx;
        int ret;
+       struct stat st;
 
 
-       ret = project_get_xattr(pathname, &fsx);
+       ret = project_get_xattr(pathname, &fsx, &st);
        if (ret < 0)
                return ret;
 
        if (ret < 0)
                return ret;
 
@@ -144,7 +145,8 @@ project_check_one(const char *pathname, struct project_handle_control *phc)
                phc->projid = fsx.fsx_projid;
        }
 
                phc->projid = fsx.fsx_projid;
        }
 
-       if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT)) {
+       if (!(fsx.fsx_xflags & FS_XFLAG_PROJINHERIT) &&
+           S_ISDIR(st.st_mode)) {
                if (!phc->newline) {
                        printf("%s%c", pathname, '\0');
                        goto out;
                if (!phc->newline) {
                        printf("%s%c", pathname, '\0');
                        goto out;
@@ -170,9 +172,10 @@ static int
 project_list_one(const char *pathname, struct project_handle_control *phc)
 {
        struct fsxattr fsx;
 project_list_one(const char *pathname, struct project_handle_control *phc)
 {
        struct fsxattr fsx;
+       struct stat st;
        int ret;
 
        int ret;
 
-       ret = project_get_xattr(pathname, &fsx);
+       ret = project_get_xattr(pathname, &fsx, &st);
        if (ret < 0)
                return ret;
 
        if (ret < 0)
                return ret;
 
@@ -188,9 +191,10 @@ static int
 project_set_one(const char *pathname, struct project_handle_control *phc)
 {
        struct fsxattr fsx;
 project_set_one(const char *pathname, struct project_handle_control *phc)
 {
        struct fsxattr fsx;
+       struct stat st;
        int fd, ret = 0;
 
        int fd, ret = 0;
 
-       fd = project_get_xattr(pathname, &fsx);
+       fd = project_get_xattr(pathname, &fsx, &st);
        if (fd < 0)
                return fd;
 
        if (fd < 0)
                return fd;
 
@@ -216,9 +220,10 @@ static int
 project_clear_one(const char *pathname, struct project_handle_control *phc)
 {
        struct fsxattr fsx;
 project_clear_one(const char *pathname, struct project_handle_control *phc)
 {
        struct fsxattr fsx;
+       struct stat st;
        int ret = 0, fd;
 
        int ret = 0, fd;
 
-       fd = project_get_xattr(pathname, &fsx);
+       fd = project_get_xattr(pathname, &fsx, &st);
        if (fd < 0)
                return fd;
 
        if (fd < 0)
                return fd;