Whamcloud - gitweb
LU-4929 llite: use the correct mode for striped directory
[fs/lustre-release.git] / lustre / llite / dir.c
index 22c4a42..5a5079a 100644 (file)
@@ -399,13 +399,23 @@ static int ll_send_mgc_param(struct obd_export *mgc, char *string)
         return rc;
 }
 
-static int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump,
-                              const char *filename)
+/**
+ * Create striped directory with specified stripe(@lump)
+ *
+ * param[in]parent     the parent of the directory.
+ * param[in]lump       the specified stripes.
+ * param[in]dirname    the name of the directory.
+ * param[in]mode       the specified mode of the directory.
+ *
+ * retval              =0 if striped directory is being created successfully.
+ *                      <0 if the creation is failed.
+ */
+static int ll_dir_setdirstripe(struct inode *parent, struct lmv_user_md *lump,
+                              const char *dirname, umode_t mode)
 {
        struct ptlrpc_request *request = NULL;
        struct md_op_data *op_data;
-       struct ll_sb_info *sbi = ll_i2sbi(dir);
-       int mode;
+       struct ll_sb_info *sbi = ll_i2sbi(parent);
        int err;
        ENTRY;
 
@@ -414,15 +424,17 @@ static int ll_dir_setdirstripe(struct inode *dir, struct lmv_user_md *lump,
 
        CDEBUG(D_VFSTRACE, "VFS Op:inode="DFID"(%p) name %s"
               "stripe_offset %d, stripe_count: %u\n",
-              PFID(ll_inode2fid(dir)), dir, filename,
+              PFID(ll_inode2fid(parent)), parent, dirname,
               (int)lump->lum_stripe_offset, lump->lum_stripe_count);
 
        if (lump->lum_magic != cpu_to_le32(LMV_USER_MAGIC))
                lustre_swab_lmv_user_md(lump);
 
-       mode = (0755 & (S_IRWXUGO|S_ISVTX) & ~current->fs->umask) | S_IFDIR;
-       op_data = ll_prep_md_op_data(NULL, dir, NULL, filename,
-                                    strlen(filename), mode, LUSTRE_OPC_MKDIR,
+       if (!IS_POSIXACL(parent) || !exp_connect_umask(ll_i2mdexp(parent)))
+               mode &= ~current_umask();
+       mode = (mode & (S_IRWXUGO | S_ISVTX)) | S_IFDIR;
+       op_data = ll_prep_md_op_data(NULL, parent, NULL, dirname,
+                                    strlen(dirname), mode, LUSTRE_OPC_MKDIR,
                                     lump);
        if (IS_ERR(op_data))
                GOTO(err_exit, err = PTR_ERR(op_data));
@@ -1097,6 +1109,7 @@ out_free:
                char            *filename;
                int              namelen = 0;
                int              lumlen = 0;
+               umode_t          mode;
                int              len;
                int              rc;
 
@@ -1126,11 +1139,12 @@ out_free:
                        GOTO(lmv_out_free, rc = -EINVAL);
                }
 
-               /**
-                * ll_dir_setdirstripe will be used to set dir stripe
-                *  mdc_create--->mdt_reint_create (with dirstripe)
-                */
-               rc = ll_dir_setdirstripe(inode, lum, filename);
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 9, 50, 0)
+               mode = data->ioc_type != 0 ? data->ioc_type : S_IRWXUGO;
+#else
+               mode = data->ioc_type;
+#endif
+               rc = ll_dir_setdirstripe(inode, lum, filename, mode);
 lmv_out_free:
                obd_ioctl_freedata(buf, len);
                RETURN(rc);