Whamcloud - gitweb
LU-1187 mdt: Only create remote dir on MDT0
[fs/lustre-release.git] / lustre / mdd / mdd_dir.c
index b69327d..0e893c9 100644 (file)
@@ -1315,21 +1315,12 @@ static int mdd_create_data(const struct lu_env *env, struct md_object *pobj,
               spec->u.sp_ea.eadata, spec->u.sp_ea.eadatalen,
               spec->sp_cr_flags, spec->no_create);
 
-       if (spec->no_create) {
-               /* replay case */
+       if (spec->no_create || spec->sp_cr_flags & MDS_OPEN_HAS_EA) {
+               /* replay case or lfs setstripe */
                buf = mdd_buf_get_const(env, spec->u.sp_ea.eadata,
                                        spec->u.sp_ea.eadatalen);
-       } else  if (!(spec->sp_cr_flags & MDS_OPEN_HAS_OBJS)) {
-               if (spec->sp_cr_flags & MDS_OPEN_HAS_EA) {
-                       /* lfs setstripe */
-                       buf = mdd_buf_get_const(env, spec->u.sp_ea.eadata,
-                                               spec->u.sp_ea.eadatalen);
-               } else {
-                       buf = &LU_BUF_NULL;
-               }
        } else {
-               /* MDS_OPEN_HAS_OBJS is not used anymore ? */
-               LBUG();
+               buf = &LU_BUF_NULL;
        }
 
        rc = dt_declare_xattr_set(env, mdd_object_child(son), buf,
@@ -1406,7 +1397,16 @@ int mdd_declare_object_initialize(const struct lu_env *env,
 {
         int rc;
 
+       /*
+        * inode mode has been set in creation time, and it's based on umask,
+        * la_mode and acl, don't set here again! (which will go wrong
+        * because below function doesn't consider umask).
+        * I'd suggest set all object attributes in creation time, see above.
+        */
+       LASSERT(attr->la_valid & (LA_MODE | LA_TYPE));
+       attr->la_valid &= ~(LA_MODE | LA_TYPE);
        rc = mdo_declare_attr_set(env, child, attr, handle);
+       attr->la_valid |= LA_MODE | LA_TYPE;
        if (rc == 0 && S_ISDIR(attr->la_mode)) {
                rc = mdo_declare_index_insert(env, child, mdo2fid(child),
                                              dot, handle);
@@ -1442,11 +1442,11 @@ int mdd_object_initialize(const struct lu_env *env, const struct lu_fid *pfid,
         * because below function doesn't consider umask).
         * I'd suggest set all object attributes in creation time, see above.
         */
-       LASSERT(attr->la_valid & LA_MODE);
-       attr->la_valid &= ~LA_MODE;
+       LASSERT(attr->la_valid & (LA_MODE | LA_TYPE));
+       attr->la_valid &= ~(LA_MODE | LA_TYPE);
        rc = mdd_attr_set_internal(env, child, attr, handle, 0);
        /* arguments are supposed to stay the same */
-       attr->la_valid |= LA_MODE;
+       attr->la_valid |= LA_MODE | LA_TYPE;
        if (rc != 0)
                RETURN(rc);
 
@@ -1488,7 +1488,7 @@ static int mdd_create_sanity_check(const struct lu_env *env,
         if (mdd_is_dead_obj(obj))
                 RETURN(-ENOENT);
 
-        /*
+       /*
          * In some cases this lookup is not needed - we know before if name
          * exists or not because MDT performs lookup for it.
          * name length check is done in lookup.