Whamcloud - gitweb
LU-12469 mdd: handle migrate case with SELinux
[fs/lustre-release.git] / lustre / mdd / mdd_dir.c
index f074f23..89f7f74 100644 (file)
@@ -234,6 +234,9 @@ static inline int mdd_parent_fid(const struct lu_env *env,
        if (rc != 0)
                GOTO(lookup, rc);
 
+       /* the obj is not locked, don't cache attributes */
+       mdd_invalidate(env, &obj->mod_obj);
+
        LASSERT(ldata.ld_leh != NULL);
        /* Directory should only have 1 parent */
        if (ldata.ld_leh->leh_reccount > 1)
@@ -2335,7 +2338,7 @@ static int mdd_create_object(const struct lu_env *env, struct mdd_object *pobj,
                             struct lu_buf *def_acl_buf,
                             struct lu_buf *hsm_buf,
                             struct dt_allocation_hint *hint,
-                            struct thandle *handle)
+                            struct thandle *handle, bool initsecctx)
 {
        const struct lu_buf *buf;
        int rc;
@@ -2429,7 +2432,7 @@ static int mdd_create_object(const struct lu_env *env, struct mdd_object *pobj,
                        GOTO(err_initlized, rc = -EFAULT);
        }
 
-       if (spec->sp_cr_file_secctx_name != NULL) {
+       if (initsecctx && spec->sp_cr_file_secctx_name != NULL) {
                buf = mdd_buf_get_const(env, spec->sp_cr_file_secctx,
                                        spec->sp_cr_file_secctx_size);
                rc = mdo_xattr_set(env, son, buf, spec->sp_cr_file_secctx_name,
@@ -2639,7 +2642,7 @@ int mdd_create(const struct lu_env *env, struct md_object *pobj,
                GOTO(out_stop, rc);
 
        rc = mdd_create_object(env, mdd_pobj, son, attr, spec, &acl_buf,
-                              &def_acl_buf, &hsm_buf, hint, handle);
+                              &def_acl_buf, &hsm_buf, hint, handle, true);
        if (rc != 0)
                GOTO(out_stop, rc);
 
@@ -3605,6 +3608,7 @@ static int mdd_iterate_xattrs(const struct lu_env *env,
                        GOTO(out, rc);
 
                cbxbuf = xbuf;
+               cbxbuf.lb_len = xsize;
 repeat:
                rc = cb(env, tobj, &cbxbuf, xname, 0, handle);
                if (unlikely(rc == -ENOSPC &&
@@ -4136,7 +4140,7 @@ static int mdd_migrate_create(const struct lu_env *env,
        attr->la_valid &= ~LA_NLINK;
 
        rc = mdd_create_object(env, tpobj, tobj, attr, spec, NULL, NULL, NULL,
-                              hint, handle);
+                              hint, handle, false);
        if (rc)
                RETURN(rc);