Whamcloud - gitweb
- add cmm_thread_info key to the context,
authortappro <tappro>
Fri, 15 Sep 2006 16:13:01 +0000 (16:13 +0000)
committertappro <tappro>
Fri, 15 Sep 2006 16:13:01 +0000 (16:13 +0000)
- fix sgid issue with cros-ref case (sanity 6g)
- fix NULL md_attr while cml_rename()

lustre/cmm/cmm_device.c
lustre/cmm/cmm_internal.h
lustre/cmm/cmm_object.c

index 2f9f6f0..c482ce7 100644 (file)
@@ -302,14 +302,40 @@ static void cmm_device_free(const struct lu_context *ctx, struct lu_device *d)
         OBD_FREE_PTR(m);
 }
 
+/* context key constructor/destructor */
+static void *cmm_thread_init(const struct lu_context *ctx,
+                             struct lu_context_key *key)
+{
+        struct cmm_thread_info *info;
+
+        CLASSERT(CFS_PAGE_SIZE >= sizeof *info);
+        OBD_ALLOC_PTR(info);
+        if (info == NULL)
+                info = ERR_PTR(-ENOMEM);
+        return info;
+}
+
+static void cmm_thread_fini(const struct lu_context *ctx,
+                            struct lu_context_key *key, void *data)
+{
+        struct cmm_thread_info *info = data;
+        OBD_FREE_PTR(info);
+}
+
+struct lu_context_key cmm_thread_key = {
+        .lct_tags = LCT_MD_THREAD,
+        .lct_init = cmm_thread_init,
+        .lct_fini = cmm_thread_fini
+};
+
 static int cmm_type_init(struct lu_device_type *t)
 {
-        return 0;
+        return lu_context_key_register(&cmm_thread_key);
 }
 
 static void cmm_type_fini(struct lu_device_type *t)
 {
-        return;
+        lu_context_key_degister(&cmm_thread_key);
 }
 
 static int cmm_device_init(const struct lu_context *ctx,
index 3274ed2..740daea 100644 (file)
@@ -91,6 +91,10 @@ struct cmr_object {
         mdsno_t           cmo_num;
 };
 
+struct cmm_thread_info {
+        struct md_attr  cmi_ma;
+};
+
 static inline struct cmm_device *cmm_obj2dev(struct cmm_object *c)
 {
         return (md2cmm_dev(md_obj2dev(&c->cmo_obj)));
index 455bb27..ccbc23b 100644 (file)
@@ -36,6 +36,8 @@
 #include "cmm_internal.h"
 #include "mdc_internal.h"
 
+extern struct lu_context_key cmm_thread_key;
+
 static int cmm_fld_lookup(struct cmm_device *cm,
                           const struct lu_fid *fid, mdsno_t *mds,
                           const struct lu_context *ctx)
@@ -415,7 +417,7 @@ static int cml_rename(const struct lu_context *ctx, struct md_object *mo_po,
 
         if (mo_t && lu_object_exists(&mo_t->mo_lu) < 0) {
                 /* mo_t is remote object and there is RPC to unlink it */
-                rc = mo_ref_del(ctx, md_object_next(mo_t), NULL);
+                rc = mo_ref_del(ctx, md_object_next(mo_t), ma);
                 if (rc)
                         RETURN(rc);
                 mo_t = NULL;
@@ -665,12 +667,27 @@ static int cmr_create(const struct lu_context *ctx, struct md_object *mo_p,
                       const struct md_create_spec *spec,
                       struct md_attr *ma)
 {
+        struct cmm_thread_info *cmi;
+        struct md_attr *tmp_ma;
         int rc;
 
         ENTRY;
-
-        //XXX: make sure that MDT checks name isn't exist
-
+        /* check the SGID attr */
+        cmi = lu_context_key_get(ctx, &cmm_thread_key);
+        LASSERT(cmi);
+        tmp_ma = &cmi->cmi_ma;
+        tmp_ma->ma_need = MA_INODE;
+        rc = mo_attr_get(ctx, md_object_next(mo_p), tmp_ma);
+        if (rc)
+                RETURN(rc);
+        
+        if (tmp_ma->ma_attr.la_mode & S_ISGID) {
+                ma->ma_attr.la_gid = tmp_ma->ma_attr.la_gid;
+                if (S_ISDIR(ma->ma_attr.la_mode)) {
+                        ma->ma_attr.la_mode |= S_ISGID;
+                        ma->ma_attr.la_valid |= LA_MODE;
+                }
+        }
         /* remote object creation and local name insert */
         rc = mo_object_create(ctx, md_object_next(mo_c), spec, ma);
         if (rc == 0) {