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;
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));
char *filename;
int namelen = 0;
int lumlen = 0;
+ umode_t mode;
int len;
int rc;
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);
}
run_test 33d "openfile with 444 modes and malformed flags under remote dir"
+test_33e() {
+ [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+
+ mkdir $DIR/$tdir
+
+ $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
+ $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
+ mkdir $DIR/$tdir/local_dir
+
+ local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
+ local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
+ local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
+
+ [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
+ error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
+
+ rmdir $DIR/$tdir/* || error "rmdir failed"
+
+ umask 777
+ $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
+ $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
+ mkdir $DIR/$tdir/local_dir
+
+ s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
+ s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
+ l_mode=$(stat -c%f $DIR/$tdir/local_dir)
+
+ [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
+ error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
+
+ rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
+
+ umask 000
+ $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
+ $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
+ mkdir $DIR/$tdir/local_dir
+
+ s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
+ s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
+ l_mode=$(stat -c%f $DIR/$tdir/local_dir)
+
+ [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
+ error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
+}
+run_test 33e "mkdir and striped directory should have same mode"
+
TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
test_34a() {
rm -f $DIR/f34
}
run_test 238 "Verify linkea consistency"
+cleanup_test_300() {
+ trap 0
+ umask $SAVE_UMASK
+}
test_striped_dir() {
local mdt_index=$1
local stripe_count
local stripe_index
mkdir -p $DIR/$tdir
- $LFS setdirstripe -i $mdt_index -c 2 -t all_char $DIR/$tdir/striped_dir ||
+
+ SAVE_UMASK=$(umask)
+ trap cleanup_test_300 RETURN EXIT
+
+ $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
+ $DIR/$tdir/striped_dir ||
error "set striped dir error"
+ local mode=$(stat -c%a $DIR/$tdir/striped_dir)
+ [ "$mode" = "755" ] || error "expect 755 got $mode"
+
stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
if [ "$stripe_count" != "2" ]; then
error "stripe_count is $stripe_count, expect 2"
rmdir $DIR/$tdir/striped_dir ||
error "rmdir striped dir error"
+
+ cleanup_test_300
+
true
}
char *stripe_offset_opt = NULL;
char *stripe_count_opt = NULL;
char *stripe_hash_opt = NULL;
+ char *mode_opt = NULL;
int default_stripe = 0;
+ mode_t mode = S_IRWXU | S_IRWXG | S_IRWXO;
+ mode_t previous_mode = 0;
struct option long_opts[] = {
{"count", required_argument, 0, 'c'},
{"index", required_argument, 0, 'i'},
+ {"mode", required_argument, 0, 'm'},
{"hash-type", required_argument, 0, 't'},
- {"default_stripe", required_argument, 0, 'D'},
+ {"default_stripe", no_argument, 0, 'D'},
{0, 0, 0, 0}
};
optind = 0;
- while ((c = getopt_long(argc, argv, "c:Di:t:", long_opts, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "c:Di:m:t:", long_opts,
+ NULL)) >= 0) {
switch (c) {
case 0:
/* Long options. */
case 'i':
stripe_offset_opt = optarg;
break;
+ case 'm':
+ mode_opt = optarg;
+ break;
case 't':
stripe_hash_opt = optarg;
break;
}
}
+ if (mode_opt != NULL) {
+ mode = strtoul(mode_opt, &end, 8);
+ if (*end != '\0') {
+ fprintf(stderr, "error: %s: bad mode '%s'\n",
+ argv[0], mode_opt);
+ return CMD_HELP;
+ }
+ previous_mode = umask(0);
+ }
+
if (stripe_hash_opt == NULL ||
strcmp(stripe_hash_opt, LMV_HASH_NAME_FNV_1A_64) == 0) {
hash_type = LMV_HASH_TYPE_FNV_1A_64;
stripe_offset, stripe_count,
hash_type, NULL);
} else {
- result = llapi_dir_create_pool(dname, 0, stripe_offset,
+ result = llapi_dir_create_pool(dname, mode,
+ stripe_offset,
stripe_count, hash_type,
NULL);
}
dname = argv[++optind];
} while (dname != NULL);
+ if (mode_opt != NULL)
+ umask(previous_mode);
+
return result;
}
return rc;
}
-int llapi_dir_create_pool(const char *name, int flags, int stripe_offset,
+int llapi_dir_create_pool(const char *name, int mode, int stripe_offset,
int stripe_count, int stripe_pattern,
const char *pool_name)
{
data.ioc_inllen1 = strlen(filename) + 1;
data.ioc_inlbuf2 = (char *)&lmu;
data.ioc_inllen2 = sizeof(struct lmv_user_md);
+ data.ioc_type = mode;
rc = obd_ioctl_pack(&data, &buf, sizeof(rawbuf));
if (rc) {
llapi_error(LLAPI_MSG_ERROR, rc,