Whamcloud - gitweb
LU-12036 ofd: add "no_precreate" mount option 16/36716/9
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 8 Nov 2019 09:04:52 +0000 (02:04 -0700)
committerOleg Drokin <green@whamcloud.com>
Fri, 3 Jan 2020 00:09:20 +0000 (00:09 +0000)
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 <adilger@whamcloud.com>
Change-Id: Icdb64a4bdd5a66b0e9e6d483e3113b97d53ebbe5
Reviewed-on: https://review.whamcloud.com/36716
Reviewed-by: Olaf Faaland-LLNL <faaland1@llnl.gov>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/doc/mount.lustre.8
lustre/include/lustre_disk.h
lustre/obdclass/obd_mount.c
lustre/ofd/ofd_dev.c
lustre/ofd/ofd_obd.c
lustre/tests/conf-sanity.sh

index 479f826..f2fb607 100644 (file)
@@ -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.
index fc5ae21..a809f4b 100644 (file)
@@ -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)
 
index 1520148..538efea 100644 (file)
@@ -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++;
index dcfeb85..a48efb0 100644 (file)
@@ -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);
index 7240b8f..c59f96b 100644 (file)
@@ -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);
index e877c4e..b82f023 100644 (file)
@@ -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()
 {