From 9a0a864112550047ae7236c7a904dc7a9955880e Mon Sep 17 00:00:00 2001 From: Alex Zhuravlev Date: Tue, 18 Jun 2019 13:18:27 +0400 Subject: [PATCH] LU-12516 mdd: support for volatile creation in .lustre this is useful to enable striping manipulation by FIDs. Change-Id: I4d5b1b13acdfef21ac46bf3557e9ab6d5ccc796b Signed-off-by: Alex Zhuravlev Reviewed-on: https://review.whamcloud.com/35258 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Patrick Farrell Reviewed-by: Oleg Drokin --- lustre/mdd/mdd_device.c | 14 +++++++++++++- lustre/mdd/mdd_dir.c | 2 +- lustre/mdt/mdt_open.c | 9 ++++++--- lustre/tests/multiop.c | 6 +++++- lustre/tests/sanity.sh | 35 +++++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 6 deletions(-) diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index 7c88545..1a9a8e6 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -839,9 +839,21 @@ static int mdd_dummy_unlink(const struct lu_env *env, 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 diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index 3a24e21..325fb19 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -2511,7 +2511,7 @@ stop: * \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) { diff --git a/lustre/mdt/mdt_open.c b/lustre/mdt/mdt_open.c index eb43f79..b7c5691 100644 --- a/lustre/mdt/mdt_open.c +++ b/lustre/mdt/mdt_open.c @@ -1408,8 +1408,10 @@ again: 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", @@ -1487,7 +1489,8 @@ again: 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 */ diff --git a/lustre/tests/multiop.c b/lustre/tests/multiop.c index c361ae2..d40c33ad 100644 --- a/lustre/tests/multiop.c +++ b/lustre/tests/multiop.c @@ -407,6 +407,7 @@ int main(int argc, char **argv) fd, rc); else printf(DFID"\n", PFID(&fid)); + fflush(stdout); break; case 'G': gid = atoi(commands+1); @@ -631,7 +632,10 @@ int main(int argc, char **argv) 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); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index e8a3700..1b7f3e3 100644 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -14485,6 +14485,41 @@ test_185() { # LU-2441 } 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) ] && -- 1.8.3.1