Whamcloud - gitweb
LU-5296 lod: don't skip attr_set for osp objects 89/10989/4
authorNiu Yawei <yawei.niu@intel.com>
Fri, 4 Jul 2014 07:34:59 +0000 (03:34 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Thu, 10 Jul 2014 14:51:14 +0000 (14:51 +0000)
lod_attr_set() uses dt_object_exists() to check whether an osp
object (for OST object) is existing, which is incorrect for non-dir
object, and can lead to chown/chgrp being skipped on OST object.

The lsr_valid handling in osp_sync_add_rec() was got a problem in
commit 80f90fcde73e because it stored all of the passed attr flags
in struct llog_setattr64_rec, even though there are only fields for
storing the UID and GID.  Since the time stamps do not need to be
propagated to the OSTs (the MDT values are good enough), this is
not a problem.  Also, osp_sync_add_rec stored LA_UID/LA_GID flags
on disk, but they are not part of lustre_idl.h or lustre_disk.h and
are not guaranteed to be constant over time.  Instead, use the flags
OBD_MD_FLUID/OBD_MD_FLGID that are in lustre_idl.h.

Re-enable sanity-quota.sh test_34 so that this is actually tested.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
Change-Id: I245e59141324b34071c9eb188dedbf615052f19d
Reviewed-on: http://review.whamcloud.com/10989
Tested-by: Jenkins
Reviewed-by: Alex Zhuravlev <alexey.zhuravlev@intel.com>
Reviewed-by: wangdi <di.wang@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lod/lod_object.c
lustre/osp/osp_sync.c
lustre/tests/sanity-quota.sh

index 1892e3b..2ea9025 100644 (file)
@@ -1149,16 +1149,16 @@ static int lod_attr_set(const struct lu_env *env,
         */
        LASSERT(lo->ldo_stripe);
        for (i = 0; i < lo->ldo_stripenr; i++) {
         */
        LASSERT(lo->ldo_stripe);
        for (i = 0; i < lo->ldo_stripenr; i++) {
-               if (likely(lo->ldo_stripe[i] != NULL)) {
-                       if (dt_object_exists(lo->ldo_stripe[i]) == 0)
-                               continue;
-
-                       rc = dt_attr_set(env, lo->ldo_stripe[i], attr,
-                                        handle, capa);
-                       if (rc != 0) {
-                               CERROR("failed declaration: %d\n", rc);
-                               break;
-                       }
+               if (unlikely(lo->ldo_stripe[i] == NULL))
+                       continue;
+               if (S_ISDIR(dt->do_lu.lo_header->loh_attr) &&
+                   (dt_object_exists(lo->ldo_stripe[i]) == 0))
+                       continue;
+
+               rc = dt_attr_set(env, lo->ldo_stripe[i], attr, handle, capa);
+               if (rc != 0) {
+                       CERROR("failed declaration: %d\n", rc);
+                       break;
                }
        }
 
                }
        }
 
index 8713ff0..8bbd938 100644 (file)
@@ -237,7 +237,9 @@ static int osp_sync_add_rec(const struct lu_env *env, struct osp_device *d,
                LASSERT(attr);
                osi->osi_setattr.lsr_uid = attr->la_uid;
                osi->osi_setattr.lsr_gid = attr->la_gid;
                LASSERT(attr);
                osi->osi_setattr.lsr_uid = attr->la_uid;
                osi->osi_setattr.lsr_gid = attr->la_gid;
-               osi->osi_setattr.lsr_valid = attr->la_valid;
+               osi->osi_setattr.lsr_valid =
+                       ((attr->la_valid & LA_UID) ? OBD_MD_FLUID : 0) |
+                       ((attr->la_valid & LA_GID) ? OBD_MD_FLGID : 0);
                break;
        default:
                LBUG();
                break;
        default:
                LBUG();
@@ -483,8 +485,9 @@ static int osp_sync_new_setattr_job(struct osp_device *d,
        ENTRY;
        LASSERT(h->lrh_type == MDS_SETATTR64_REC);
 
        ENTRY;
        LASSERT(h->lrh_type == MDS_SETATTR64_REC);
 
-       /* lsr_valid can only be 0 or LA_UID/GID set */
-       if ((rec->lsr_valid & ~(LA_UID | LA_GID)) != 0) {
+       /* lsr_valid can only be 0 or have OBD_MD_{FLUID,FLGID} set,
+        * so no bits other than these should be set. */
+       if ((rec->lsr_valid & ~(OBD_MD_FLUID | OBD_MD_FLGID)) != 0) {
                CERROR("%s: invalid setattr record, lsr_valid:"LPU64"\n",
                       d->opd_obd->obd_name, rec->lsr_valid);
                /* return 0 so that sync thread can continue processing
                CERROR("%s: invalid setattr record, lsr_valid:"LPU64"\n",
                       d->opd_obd->obd_name, rec->lsr_valid);
                /* return 0 so that sync thread can continue processing
@@ -504,14 +507,10 @@ static int osp_sync_new_setattr_job(struct osp_device *d,
        body->oa.o_valid = OBD_MD_FLGROUP | OBD_MD_FLID;
        /* old setattr record (prior 2.6.0) doesn't have 'valid' stored,
         * we assume that both UID and GID are valid in that case. */
        body->oa.o_valid = OBD_MD_FLGROUP | OBD_MD_FLID;
        /* old setattr record (prior 2.6.0) doesn't have 'valid' stored,
         * we assume that both UID and GID are valid in that case. */
-       if (rec->lsr_valid == 0) {
+       if (rec->lsr_valid == 0)
                body->oa.o_valid |= (OBD_MD_FLUID | OBD_MD_FLGID);
                body->oa.o_valid |= (OBD_MD_FLUID | OBD_MD_FLGID);
-       } else {
-               if (rec->lsr_valid & LA_UID)
-                       body->oa.o_valid |= OBD_MD_FLUID;
-               if (rec->lsr_valid & LA_GID)
-                       body->oa.o_valid |= OBD_MD_FLGID;
-       }
+       else
+               body->oa.o_valid |= rec->lsr_valid;
 
        osp_sync_send_new_rpc(d, req);
        RETURN(1);
 
        osp_sync_send_new_rpc(d, req);
        RETURN(1);
index 4de4a04..9e3ded1 100644 (file)
@@ -50,9 +50,6 @@ if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
        skip "e2fsprogs doesn't support quota" && exit 0
 fi
 
        skip "e2fsprogs doesn't support quota" && exit 0
 fi
 
-# bug number for skipped test: LU-4515
-ALWAYS_EXCEPT="$ALWAYS_EXCEPT  34"
-
 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
 # bug number for skipped test:        LU-2872 LU-2836 LU-2836 LU-2059
        ALWAYS_EXCEPT="$ALWAYS_EXCEPT 1       3       6       7d"
 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
 # bug number for skipped test:        LU-2872 LU-2836 LU-2836 LU-2059
        ALWAYS_EXCEPT="$ALWAYS_EXCEPT 1       3       6       7d"