Whamcloud - gitweb
Branch: b_new_cmd
authorwangdi <wangdi>
Tue, 15 Aug 2006 11:39:44 +0000 (11:39 +0000)
committerwangdi <wangdi>
Tue, 15 Aug 2006 11:39:44 +0000 (11:39 +0000)
1) some fixes about set flags of inode
2) remove useless mti_ld
3) other small cleanup

lustre/include/md_object.h
lustre/mdd/mdd_handler.c
lustre/mdd/mdd_internal.h
lustre/mdt/mdt_lib.c

index 534985b..1d515c7 100644 (file)
@@ -50,7 +50,8 @@ struct md_object;
 enum ma_valid {
         MA_INODE = (1 << 0),
         MA_LOV   = (1 << 1),
-        MA_COOKIE = (1 << 2)
+        MA_COOKIE = (1 << 2),
+        MA_FLAGS = (1 << 3)
 };
 
 struct md_attr {
@@ -64,13 +65,6 @@ struct md_attr {
         int                     ma_cookie_size;
 };
 
-enum md_attr_flags {
-        MD_ATIME_SET      = 1 << 0,
-        MD_MTIME_SET      = 1 << 1,
-        MD_CTIME_SET      = 1 << 2,
-        MD_ATTR_RAW       = 1 << 3
-};
-
 /* additional parameters for create */
 struct md_create_spec {
         union {
index bf119f4..22c25fb 100644 (file)
@@ -572,6 +572,18 @@ int mdd_attr_set_internal(const struct lu_context *ctxt, struct mdd_object *o,
         return next->do_ops->do_attr_set(ctxt, next, attr, handle);
 }
 
+int mdd_attr_set_internal_locked(const struct lu_context *ctxt, 
+                                 struct mdd_object *o,
+                                 const struct lu_attr *attr, 
+                                 struct thandle *handle)
+{
+        int rc;
+        mdd_lock(ctxt, o, DT_WRITE_LOCK);
+        rc = mdd_attr_set_internal(ctxt, o, attr, handle);
+        mdd_unlock(ctxt, o, DT_WRITE_LOCK);
+        return rc;
+}
+
 static int __mdd_xattr_set(const struct lu_context *ctxt, struct mdd_object *o,
                            const void *buf, int buf_len, const char *name,
                            int fl, struct thandle *handle)
@@ -610,12 +622,20 @@ int mdd_fix_attr(const struct lu_context *ctxt, struct mdd_object *obj,
         if (rc)
                 RETURN(rc);
 
-        if (!(ma->ma_attr_flags & MD_CTIME_SET))
+        if (!(la->la_valid & LA_CTIME)) {
                 la->la_ctime = now;
-        if (!(ma->ma_attr_flags & MD_ATIME_SET))
+                la->la_valid |= LA_CTIME;
+        } else
+                la->la_valid &= ~LA_CTIME;
+
+        if (!(la->la_valid & LA_ATIME)) {
                 la->la_atime = now;
-        if (!(ma->ma_attr_flags & MD_MTIME_SET))
+                la->la_valid |= LA_ATIME;
+        }
+        if (!(la->la_valid & LA_MTIME)) {
                 la->la_mtime = now;
+                la->la_valid |= LA_MTIME;
+        }
 
         /*XXX Check permission */
 #if 0
@@ -731,11 +751,15 @@ static int mdd_attr_set(const struct lu_context *ctxt,
         rc = mdd_fix_attr(ctxt, mdd_obj, ma, la_copy);
         if (rc)
                 GOTO(cleanup, rc);
-        if (la_copy->la_valid) {            /* setattr */
-                mdd_lock(ctxt, mdd_obj, DT_WRITE_LOCK);
-                rc = mdd_attr_set_internal(ctxt, mdd_obj, la_copy, handle);
-                mdd_unlock(ctxt, mdd_obj, DT_WRITE_LOCK);
-
+        
+        if (ma->ma_valid & MA_FLAGS) {
+                la_copy->la_flags = ma->ma_attr_flags;
+                la_copy->la_valid |= LA_FLAGS;
+                rc = mdd_attr_set_internal_locked(ctxt, mdd_obj, la_copy,
+                                                  handle);
+        }else if (la_copy->la_valid) {            /* setattr */
+                rc = mdd_attr_set_internal_locked(ctxt, mdd_obj, la_copy,
+                                                  handle);
                 /* journal chown/chgrp in llog, just like unlink */
                 if (rc == 0 && lmm_size){
                         /*TODO set_attr llog */
index 9de72d8..90ced73 100644 (file)
@@ -56,7 +56,6 @@ struct mdd_thread_info {
         struct lu_fid    mti_fid;
         struct lu_attr    mti_la;
         struct lu_attr    mti_la_for_fix;
-        struct lov_desc  mti_ld;
         struct lov_mds_md mti_lmm;
 };
 
index 28b770b..b56576f 100644 (file)
@@ -125,7 +125,7 @@ int mdt_handle_last_unlink(struct mdt_thread_info *info, struct mdt_object *mo,
 }
 
 static __u64 mdt_attr_valid_xlate(__u64 in, struct mdt_reint_record *rr,
-                                  struct md_attr *ma)
+                                  struct md_attr *ma, __u32 attr_flags)
 {
         __u64 out;
 
@@ -138,34 +138,28 @@ static __u64 mdt_attr_valid_xlate(__u64 in, struct mdt_reint_record *rr,
                 out |= LA_GID;
         if (in & ATTR_SIZE)
                 out |= LA_SIZE;
-        if (in & ATTR_ATIME)
-                out |= LA_ATIME;
-        if (in & ATTR_MTIME)
-                out |= LA_MTIME;
-        if (in & ATTR_CTIME)
-                out |= LA_CTIME;
-        if (in & ATTR_ATTR_FLAG)
-                out |= LA_FLAGS;
 
         if (in & ATTR_FROM_OPEN)
                 rr->rr_flags |= MRF_SETATTR_LOCKED;
 
         if (in & ATTR_ATIME_SET)
-                ma->ma_attr_flags |= MD_ATIME_SET;
+                out |= LA_ATIME;
 
         if (in & ATTR_CTIME_SET)
-                ma->ma_attr_flags |= MD_CTIME_SET;
+                out |= LA_CTIME;
 
         if (in & ATTR_MTIME_SET)
-                ma->ma_attr_flags |= MD_MTIME_SET;
-
-        if (in & ATTR_RAW)
-                ma->ma_attr_flags |= MD_ATTR_RAW;
+                out |= LA_MTIME;
 
+        if (in & ATTR_ATTR_FLAG) {
+                ma->ma_valid |= MA_FLAGS;
+                ma->ma_attr_flags = attr_flags;
+        }
+        /*XXX need ATTR_RAW?*/
         in &= ~(ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|
                 ATTR_ATIME|ATTR_MTIME|ATTR_CTIME|ATTR_FROM_OPEN|
                 ATTR_ATIME_SET|ATTR_CTIME_SET|ATTR_MTIME_SET|
-                ATTR_ATTR_FLAG|ATTR_RAW);
+                ATTR_ATTR_FLAG|ATTR_RAW); 
         if (in != 0)
                 CERROR("Unknown attr bits: %#llx\n", in);
         return out;
@@ -186,12 +180,12 @@ static int mdt_setattr_unpack(struct mdt_thread_info *info)
                 RETURN(-EFAULT);
 
         rr->rr_fid1 = &rec->sa_fid;
-        la->la_valid = mdt_attr_valid_xlate(rec->sa_valid, rr, ma);
+        la->la_valid = mdt_attr_valid_xlate(rec->sa_valid, rr, ma, 
+                                            rec->sa_attr_flags);
         la->la_mode  = rec->sa_mode;
         la->la_uid   = rec->sa_uid;
         la->la_gid   = rec->sa_gid;
         la->la_size  = rec->sa_size;
-        la->la_flags = rec->sa_attr_flags;
         la->la_ctime = rec->sa_ctime;
         la->la_atime = rec->sa_atime;
         la->la_mtime = rec->sa_mtime;