From 416e67222b769df490a8be034ef987a596dd8dff Mon Sep 17 00:00:00 2001 From: Andreas Dilger Date: Fri, 8 Nov 2019 02:04:52 -0700 Subject: [PATCH] LU-12036 ofd: add "no_precreate" mount option Add a mount option to disallow object creation on the OST. That allows an OST to be mounted by the administrator without it being immediately available for use by clients/applications. This may be useful if the OST needs to be added to a specific pool first, or if it is being debugged or similar. Mount option can be disabled with the obdfilter.*.no_precreate tunable parameter. Signed-off-by: Andreas Dilger Change-Id: Icdb64a4bdd5a66b0e9e6d483e3113b97d53ebbe5 Reviewed-on: https://review.whamcloud.com/36716 Reviewed-by: Olaf Faaland-LLNL Tested-by: jenkins Tested-by: Maloo Reviewed-by: Lai Siyao Reviewed-by: Oleg Drokin --- lustre/doc/mount.lustre.8 | 13 +++++++++++++ lustre/include/lustre_disk.h | 1 + lustre/obdclass/obd_mount.c | 3 +++ lustre/ofd/ofd_dev.c | 8 +++++++- lustre/ofd/ofd_obd.c | 3 +++ lustre/tests/conf-sanity.sh | 26 ++++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 1 deletion(-) diff --git a/lustre/doc/mount.lustre.8 b/lustre/doc/mount.lustre.8 index 479f826..f2fb607 100644 --- a/lustre/doc/mount.lustre.8 +++ b/lustre/doc/mount.lustre.8 @@ -234,6 +234,19 @@ Enable POSIX Access Control List support for all clients. See the .BR acl (5) manual page. .TP +.BI no_precreate +Do not allow objects to be created on the OST after mounting. This +allows a (potentially newly-formatted) OST to be started without +clients starting to use it immediately. To allow the MDS to create +objects on the OST mount without this option, or run +.BI "lctl set_param obdfilter." fsname -OST nnnn .no_precreate=0 +on the OSS to re-enable object creation. +.BR NOTE : +this does not start the OST read-only, it only disables the +creation of new objects on the OST. This means existing objects +can be read, modified, or deleted, but if the OST is new then it +will not have any such objects. +.TP .BI nosvc Only start the MGC (and MGS, if co-located) for a target service, and not the actual MDS or OSS service. diff --git a/lustre/include/lustre_disk.h b/lustre/include/lustre_disk.h index fc5ae21..a809f4b 100644 --- a/lustre/include/lustre_disk.h +++ b/lustre/include/lustre_disk.h @@ -106,6 +106,7 @@ struct lustre_mount_data { #define LMD_FLG_UPDATE 0x2000 /* update parameters */ #define LMD_FLG_HSM 0x4000 /* Start coordinator */ #define LMD_FLG_DEV_RDONLY 0x8000 /* discard modification quitely */ +#define LMD_FLG_NO_PRECREATE 0x10000 /* do not allow OST object creation */ #define lmd_is_client(x) ((x)->lmd_flags & LMD_FLG_CLIENT) diff --git a/lustre/obdclass/obd_mount.c b/lustre/obdclass/obd_mount.c index 1520148..538efea 100644 --- a/lustre/obdclass/obd_mount.c +++ b/lustre/obdclass/obd_mount.c @@ -1363,6 +1363,9 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd) max_t(int, simple_strtoul(s1 + 19, NULL, 10), time_min); clear++; + } else if (strncmp(s1, "no_precreate", 12) == 0) { + lmd->lmd_flags |= LMD_FLG_NO_PRECREATE; + clear++; } else if (strncmp(s1, "noir", 4) == 0) { lmd->lmd_flags |= LMD_FLG_NOIR; /* test purpose only. */ clear++; diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index dcfeb85..a48efb0 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -180,9 +180,12 @@ static int ofd_stack_init(const struct lu_env *env, } lmd = s2lsi(lmi->lmi_sb)->lsi_lmd; - if (lmd != NULL && lmd->lmd_flags & LMD_FLG_SKIP_LFSCK) + if (lmd && lmd->lmd_flags & LMD_FLG_SKIP_LFSCK) m->ofd_skip_lfsck = 1; + if (lmd && lmd->lmd_flags & LMD_FLG_NO_PRECREATE) + m->ofd_no_precreate = 1; + /* find bottom osd */ OBD_ALLOC(osdname, MTI_NAME_MAXLEN); if (osdname == NULL) @@ -1488,6 +1491,9 @@ static int ofd_create_hdl(struct tgt_session_info *tsi) if (OBD_FAIL_CHECK(OBD_FAIL_OST_EROFS)) RETURN(-EROFS); + if (ofd->ofd_no_precreate) + return -EPERM; + repbody = req_capsule_server_get(tsi->tsi_pill, &RMF_OST_BODY); if (repbody == NULL) RETURN(-ENOMEM); diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index 7240b8f..c59f96b 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -1105,6 +1105,9 @@ static int ofd_echo_create(const struct lu_env *env, struct obd_export *exp, ENTRY; + if (ofd->ofd_no_precreate) + return -EPERM; + ofd_info_init(env, exp); LASSERT(seq == FID_SEQ_ECHO); diff --git a/lustre/tests/conf-sanity.sh b/lustre/tests/conf-sanity.sh index e877c4e..b82f023 100644 --- a/lustre/tests/conf-sanity.sh +++ b/lustre/tests/conf-sanity.sh @@ -8302,6 +8302,32 @@ test_111() { } run_test 111 "Adding large_dir with over 2GB directory" +test_112() { + start_mds || error "MDS start failed" + start_ost || error "OSS start failed" + echo "start ost2 service on $(facet_active_host ost2)" + start ost2 $(ostdevname 2) $(csa_add "$OST_MOUNT_OPTS" -o no_precreate) || + error "start ost2 facet failed" + local val=$(do_facet ost2 \ + "$LCTL get_param -n obdfilter.$FSNAME-OST0001*.no_precreate") + (( $val == 1 )) || error "obdfilter.$FSNAME-OST0001*.no_precreate=$val" + + mount_client $MOUNT || error "mount client failed" + wait_osc_import_state client ost2 FULL + + $LFS setstripe -i 0 $DIR/$tfile.0 || + error "problem creating $tfile.0 on OST0000" + $LFS setstripe -i 1 $DIR/$tfile.1 && $LFS getstripe $DIR/$tfile.1 && + (( $($LFS getstripe -i $DIR/$tfile.1) == 1 )) && + error "allowed to create $tfile.1 on OST0001" + do_facet ost2 $LCTL set_param obdfilter.*.no_precreate=0 + sleep_maxage + $LFS setstripe -i 1 $DIR/$tfile.2 || + error "failed to create $tfile.2 on ost1 facet" + stop_ost2 || error "stop ost2 facet failed" + cleanup +} +run_test 112 "mount OST with nocreate option" cleanup_115() { -- 1.8.3.1