From f9340d5eb4c8e74909a1aec206844dc4d0f30ec1 Mon Sep 17 00:00:00 2001 From: Sebastien Buisson Date: Wed, 6 Nov 2019 21:51:55 +0900 Subject: [PATCH] LU-12469 mdd: handle migrate case with SELinux In case a metadata object is created for migration purpose, its security context should not be initialized. The security.selinux xattr will be copied after creation, just like any other xattr, so that the migrated object has the right security context. Lustre-change: https://review.whamcloud.com/36684 Lustre-commit: 8a60fa2e2fcd28c2772d90e76d36430d30b01905 Test-Parameters: clientselinux mdtcount=4 envdefinitions=ONLY=230 testlist=sanity,sanity,sanity,sanity Test-Parameters: clientselinux mdtcount=4 testlist=sanity,recovery-small,sanity-sec Signed-off-by: Sebastien Buisson Change-Id: I0bc274426c003f8081da2f4d1e8e6c12a70b9930 Reviewed-on: https://review.whamcloud.com/37031 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/mdd/mdd_dir.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index bb40c3a..b1915da 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -2324,7 +2324,7 @@ static int mdd_create_object(const struct lu_env *env, struct mdd_object *pobj, struct md_op_spec *spec, struct lu_buf *acl_buf, struct lu_buf *def_acl_buf, struct dt_allocation_hint *hint, - struct thandle *handle) + struct thandle *handle, bool initsecctx) { const struct lu_buf *buf; int rc; @@ -2405,7 +2405,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, @@ -2605,7 +2605,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, hint, handle); + &def_acl_buf, hint, handle, true); if (rc != 0) GOTO(out_stop, rc); @@ -4097,7 +4097,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, hint, - handle); + handle, false); if (rc) RETURN(rc); -- 1.8.3.1