Whamcloud - gitweb
- get also la_flags attr in cmm_mode_get() to track append|immutable flags later
authortappro <tappro>
Mon, 18 Sep 2006 20:59:39 +0000 (20:59 +0000)
committertappro <tappro>
Mon, 18 Sep 2006 20:59:39 +0000 (20:59 +0000)
  in mdd_rename.

lustre/cmm/cmm_object.c
lustre/mdd/mdd_handler.c

index 1929c09..1b88938 100644 (file)
@@ -444,9 +444,11 @@ static int __cmm_mode_get(const struct lu_context *ctx, struct md_device *md,
         
         /* get type from src, can be remote req */
         rc = mo_attr_get(ctx, md_object_next(mo_s), tmp_ma);
-        if (rc == 0 && ma != NULL)
+        if (rc == 0) {
                 ma->ma_attr.la_mode = tmp_ma->ma_attr.la_mode;
-
+                ma->ma_attr.la_flags = tmp_ma->ma_attr.la_flags;
+                ma->ma_attr.la_valid |= LA_MODE | LA_FLAGS;
+        }
         lu_object_put(ctx, &mo_s->mo_lu);
         return rc;
 }
@@ -462,6 +464,7 @@ static int cml_rename(const struct lu_context *ctx, struct md_object *mo_po,
         rc = __cmm_mode_get(ctx, md_obj2dev(mo_po), lf, ma);
         if (rc != 0)
                 RETURN(rc);
+
         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), ma);
@@ -510,11 +513,11 @@ static int cmm_is_subdir(const struct lu_context *ctx, struct md_object *mo,
         int rc;
         ENTRY;
 
-        rc = __cmm_mode_get(ctx, md_obj2dev(mo), fid, NULL);
+        cmi = lu_context_key_get(ctx, &cmm_thread_key);
+        rc = __cmm_mode_get(ctx, md_obj2dev(mo), fid, &cmi->cmi_ma);
         if (rc)
                 RETURN(rc);
 
-        cmi = lu_context_key_get(ctx, &cmm_thread_key);
         if (!S_ISDIR(cmi->cmi_ma.ma_attr.la_mode))
                 RETURN(0);
         
index 1645208..7de92ff 100644 (file)
@@ -1499,7 +1499,11 @@ static int mdd_rename(const struct lu_context *ctxt, struct md_object *src_pobj,
 
         LASSERT(ma->ma_attr.la_mode & S_IFMT);
         is_dir = S_ISDIR(ma->ma_attr.la_mode);
-        
+       
+        if (ma->ma_attr.la_valid & LA_FLAGS &&
+            ma->ma_attr.la_flags & (LUSTRE_APPEND_FL | LUSTRE_IMMUTABLE_FL))
+                RETURN(-EPERM);
+
         if (tobj)
                 mdd_tobj = md2mdd_obj(tobj);