this is useful to enable striping manipulation by FIDs.
Change-Id: I4d5b1b13acdfef21ac46bf3557e9ab6d5ccc796b
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/35258
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Patrick Farrell <pfarrell@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
return -EPERM;
}
+int mdd_create(const struct lu_env *env, struct md_object *pobj,
+ const struct lu_name *lname, struct md_object *child,
+ struct md_op_spec *spec, struct md_attr *ma);
+static int mdd_obf_create(const struct lu_env *env, struct md_object *pobj,
+ const struct lu_name *lname, struct md_object *child,
+ struct md_op_spec *spec, struct md_attr *ma)
+{
+ if (spec->sp_cr_flags & MDS_OPEN_VOLATILE)
+ return mdd_create(env, pobj, lname, child, spec, ma);
+ RETURN(-EPERM);
+}
+
static struct md_dir_operations mdd_obf_dir_ops = {
.mdo_lookup = obf_lookup,
- .mdo_create = mdd_dummy_create,
+ .mdo_create = mdd_obf_create,
.mdo_rename = mdd_dummy_rename,
.mdo_link = mdd_dummy_link,
.mdo_unlink = mdd_dummy_unlink
* \retval 0 on success
* \retval negative errno on failure
*/
-static int mdd_create(const struct lu_env *env, struct md_object *pobj,
+int mdd_create(const struct lu_env *env, struct md_object *pobj,
const struct lu_name *lname, struct md_object *child,
struct md_op_spec *spec, struct md_attr *ma)
{
fid_zero(child_fid);
- result = mdo_lookup(info->mti_env, mdt_object_child(parent),
- &rr->rr_name, child_fid, &info->mti_spec);
+ result = -ENOENT;
+ if ((open_flags & MDS_OPEN_VOLATILE) == 0)
+ result = mdo_lookup(info->mti_env, mdt_object_child(parent),
+ &rr->rr_name, child_fid, &info->mti_spec);
LASSERTF(ergo(result == 0, fid_is_sane(child_fid)),
"looking for "DFID"/"DNAME", found FID = "DFID"\n",
if (result == -ENOENT) {
/* Create under OBF and .lustre is not permitted */
- if (!fid_is_md_operative(rr->rr_fid1))
+ if (!fid_is_md_operative(rr->rr_fid1) &&
+ (open_flags & MDS_OPEN_VOLATILE) == 0)
GOTO(out_child, result = -EPERM);
/* save versions in reply */
fd, rc);
else
printf(DFID"\n", PFID(&fid));
+ fflush(stdout);
break;
case 'G':
gid = atoi(commands+1);
case 'V':
len = get_flags(commands + 1, &flags);
commands += len;
- fd = llapi_create_volatile(fname, flags);
+ len = -1; /* mdt index */
+ if (commands[1] >= '0' && commands[1] <= '9')
+ len = atoi(commands+1);
+ fd = llapi_create_volatile_idx(fname, len, flags);
if (fd < 0) {
perror("llapi_create_volatile");
exit(fd);
}
run_test 185 "Volatile file support"
+function create_check_volatile() {
+ local idx=$1
+ local tgt
+
+ $MULTIOP $MOUNT/.lustre/fid V${idx}Fw4096_c >&/tmp/${tfile}.fid &
+ local PID=$!
+ sleep 1
+ local FID=$(cat /tmp/${tfile}.fid)
+ [ "$FID" == "" ] && error "can't get FID for volatile"
+ $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID || error "can't stat $FID"
+ tgt=$($LFS getstripe -m $MOUNT/.lustre/fid/$FID)
+ [ "$tgt" != "$idx" ] && error "wrong MDS $tgt, expected $idx"
+ kill -USR1 $PID
+ wait
+ sleep 1
+ cancel_lru_locks mdc # flush opencache
+ $CHECKSTAT -t file $MOUNT/.lustre/fid/$FID && error "can stat $FID"
+ return 0
+}
+
+test_185a(){
+ # LU-12516 - volatile creation via .lustre
+ [[ $MDS1_VERSION -ge $(version_code 2.12.55) ]] ||
+ skip "Need MDS version at least 2.3.55"
+
+ create_check_volatile 0
+ [ $MDSCOUNT -lt 2 ] && return 0
+
+ # DNE case
+ create_check_volatile 1
+
+ return 0
+}
+run_test 185a "Volatile file creation in .lustre/fid/"
+
test_187a() {
remote_mds_nodsh && skip "remote MDS with nodsh"
[ $MDS1_VERSION -lt $(version_code 2.3.0) ] &&