From 1e83ba2b795df2dd12368618b9128e1c9e7ddb32 Mon Sep 17 00:00:00 2001 From: huanghua Date: Mon, 7 Aug 2006 10:49:53 +0000 Subject: [PATCH] (1) set attribute for newly created object. (2) check S_ISGID for parent directory, and set it for sub-dir also. see sanity test 6g. --- lustre/mdd/mdd_handler.c | 43 ++++++++++++++++++++++++++++++++++++++++--- lustre/mdd/mdd_internal.h | 1 + 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/lustre/mdd/mdd_handler.c b/lustre/mdd/mdd_handler.c index 0e1f301..68a993c 100644 --- a/lustre/mdd/mdd_handler.c +++ b/lustre/mdd/mdd_handler.c @@ -903,10 +903,47 @@ static int __mdd_object_initialize(const struct lu_context *ctxt, struct mdd_object *child, struct md_attr *ma, struct thandle *handle) { - int rc; + struct lu_attr *la = &mdd_ctx_info(ctxt)->mti_la; + struct dt_object *dt_parent = mdd_object_child(parent); + struct dt_object *dt_child = mdd_object_child(child); + int rc; + ENTRY; + + /* FIXME & TODO: valid code need some convertion from Lustre to linux */ + ma->ma_attr.la_valid = ATTR_UID | ATTR_GID | ATTR_ATIME | + ATTR_MTIME | ATTR_CTIME; + + rc = dt_parent->do_ops->do_attr_get(ctxt, dt_parent, la); + if (rc != 0) + RETURN(rc); + if (la->la_mode & S_ISGID) { + CDEBUG(D_ERROR, "Parent "DFID3" is a GID\n", + PFID3(mdo2fid(parent))); + ma->ma_attr.la_gid = la->la_gid; + rc = dt_child->do_ops->do_attr_get(ctxt, dt_child, la); + if (rc != 0) + RETURN(rc); + + if (S_ISDIR(la->la_mode)) { + ma->ma_attr.la_mode = la->la_mode | S_ISGID; + ma->ma_attr.la_valid |= ATTR_MODE; + } + } - rc = 0; + CDEBUG(D_ERROR, "Child "DFID3" has u/gid: %d:%d\n", + PFID3(mdo2fid(child)), ma->ma_attr.la_uid, + ma->ma_attr.la_gid); + rc = dt_child->do_ops->do_attr_set(ctxt, dt_child, &ma->ma_attr,handle); + if (rc != 0) + RETURN(rc); + + ma->ma_attr.la_valid = ATTR_MTIME | ATTR_CTIME; + rc = dt_parent->do_ops->do_attr_set(ctxt, dt_parent, &ma->ma_attr, handle); + if (rc != 0) + RETURN(rc); + if (S_ISDIR(ma->ma_attr.la_mode)) { + /* add . and .. for newly created dir */ __mdd_ref_add(ctxt, child, handle); rc = __mdd_index_insert(ctxt, child, mdo2fid(child), dot, handle); @@ -928,7 +965,7 @@ static int __mdd_object_initialize(const struct lu_context *ctxt, } } } - return rc; + RETURN(rc); } static int mdd_create_data(const struct lu_context *ctxt, diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index 588d79e..b2cfc8f 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -48,6 +48,7 @@ struct mdd_object { struct mdd_thread_info { struct txn_param mti_param; struct lu_fid mti_fid; + struct lu_attr mti_la; struct lov_desc mti_ld; struct lov_mds_md mti_lmm; }; -- 1.8.3.1