Whamcloud - gitweb
LU-14542 obd: tunable for sanity grant check 28/42128/7
authorVladimir Saveliev <vlaidimir.saveliev@hpe.com>
Mon, 13 Dec 2021 15:11:58 +0000 (18:11 +0300)
committerOleg Drokin <green@whamcloud.com>
Thu, 6 Jan 2022 22:01:28 +0000 (22:01 +0000)
Control on sanity grant check via lctl set_param
*.*.grant_check_threshold is added.  0 is to unconditionally turn
grant checking on.
By default, as before, grant check gets turned off when number of
exports is more than 100.

Change-Id: Ib2505da74f6e3d541bce5def3e90597eda232c58
Signed-off-by: Vladimir Saveliev <vlaidimir.saveliev@hpe.com>
HPE-bug-id: LUS-9827
Reviewed-on: https://review.whamcloud.com/42128
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alexander Boyko <alexander.boyko@hpe.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/include/lprocfs_status.h
lustre/include/obd.h
lustre/mdt/mdt_lproc.c
lustre/obdclass/genops.c
lustre/obdclass/lprocfs_status_server.c
lustre/ofd/lproc_ofd.c
lustre/target/tgt_grant.c

index d622f8c..9b2ba94 100644 (file)
@@ -601,6 +601,11 @@ extern int lprocfs_connect_flags_seq_show(struct seq_file *m, void *data);
 #ifdef HAVE_SERVER_SUPPORT
 ssize_t num_exports_show(struct kobject *kobj, struct attribute *attr,
                         char *buf);
+ssize_t grant_check_threshold_show(struct kobject *kobj,
+                                  struct attribute *attr, char *buf);
+ssize_t grant_check_threshold_store(struct kobject *kobj,
+                                   struct attribute *attr,
+                                   const char *buffer, size_t count);
 #endif
 struct adaptive_timeout;
 extern int lprocfs_at_hist_helper(struct seq_file *m,
index 9ebd53f..971b9fc 100644 (file)
@@ -660,6 +660,7 @@ struct obd_device {
        struct list_head        obd_lwp_list;
        atomic_t                obd_refcount;
        int                     obd_num_exports;
+       int                     obd_grant_check_threshold;
        spinlock_t              obd_nid_lock;
        struct ldlm_namespace  *obd_namespace;
        struct ptlrpc_client    obd_ldlm_client; /* XXX OST/MDS only */
index c6445fb..e90d528 100644 (file)
@@ -1381,6 +1381,7 @@ LUSTRE_RW_ATTR(grant_compat_disable);
 LUSTRE_RO_ATTR(instance);
 
 LUSTRE_RO_ATTR(num_exports);
+LUSTRE_RW_ATTR(grant_check_threshold);
 
 static struct attribute *mdt_attrs[] = {
        &lustre_attr_tot_dirty.attr,
@@ -1392,6 +1393,7 @@ static struct attribute *mdt_attrs[] = {
        &lustre_attr_recovery_time_soft.attr,
        &lustre_attr_ir_factor.attr,
        &lustre_attr_num_exports.attr,
+       &lustre_attr_grant_check_threshold.attr,
        &lustre_attr_identity_expire.attr,
        &lustre_attr_identity_acquire_expire.attr,
        &lustre_attr_identity_upcall.attr,
index 29fc4cb..2553a2e 100644 (file)
@@ -377,6 +377,8 @@ struct obd_device *class_newdev(const char *type_name, const char *name,
        newdev->obd_pool_slv = 0;
 
        INIT_LIST_HEAD(&newdev->obd_exports);
+       newdev->obd_num_exports = 0;
+       newdev->obd_grant_check_threshold = 100;
        INIT_LIST_HEAD(&newdev->obd_unlinked_exports);
        INIT_LIST_HEAD(&newdev->obd_delayed_exports);
        INIT_LIST_HEAD(&newdev->obd_exports_timed);
index a912ba6..a3ddaa9 100644 (file)
@@ -154,6 +154,37 @@ ssize_t num_exports_show(struct kobject *kobj, struct attribute *attr,
 }
 EXPORT_SYMBOL(num_exports_show);
 
+ssize_t grant_check_threshold_show(struct kobject *kobj, struct attribute *attr,
+                                  char *buf)
+{
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
+
+       return scnprintf(buf, PAGE_SIZE, "%d\n",
+                        obd->obd_grant_check_threshold);
+}
+EXPORT_SYMBOL(grant_check_threshold_show);
+
+ssize_t grant_check_threshold_store(struct kobject *kobj,
+                                   struct attribute *attr,
+                                   const char *buffer, size_t count)
+{
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
+       int val;
+       int rc;
+
+       rc = kstrtoint(buffer, 10, &val);
+       if (rc)
+               return rc;
+
+       if (val < 0)
+               return -EINVAL;
+       obd->obd_grant_check_threshold = val;
+       return count;
+}
+EXPORT_SYMBOL(grant_check_threshold_store);
+
 static int obd_export_flags2str(struct obd_export *exp, struct seq_file *m)
 {
        bool first = true;
index acff6b9..db81351 100644 (file)
@@ -1024,6 +1024,7 @@ LUSTRE_RW_ATTR(grant_compat_disable);
 LUSTRE_RO_ATTR(instance);
 
 LUSTRE_RO_ATTR(num_exports);
+LUSTRE_RW_ATTR(grant_check_threshold);
 
 struct lprocfs_vars lprocfs_ofd_obd_vars[] = {
        { .name =       "last_id",
@@ -1100,6 +1101,7 @@ static struct attribute *ofd_attrs[] = {
        &lustre_attr_recovery_time_soft.attr,
        &lustre_attr_ir_factor.attr,
        &lustre_attr_num_exports.attr,
+       &lustre_attr_grant_check_threshold.attr,
        &lustre_attr_seqs_allocated.attr,
        &lustre_attr_grant_precreate.attr,
        &lustre_attr_precreate_batch.attr,
index 37d1ba8..ac1757e 100644 (file)
@@ -176,7 +176,7 @@ static int tgt_check_export_grants(struct obd_export *exp, u64 *dirty,
  * argument. LBUG is only called in case of serious counter corruption (i.e.
  * value larger than the device size).
  * Those sanity checks can be pretty expensive and are disabled if the OBD
- * device has more than 100 connected exports.
+ * device has more than 100 connected exports by default.
  *
  * \param[in] obd      OBD device for which grant accounting should be
  *                     verified
@@ -200,9 +200,14 @@ void tgt_grant_sanity_check(struct obd_device *obd, const char *func)
        if (list_empty(&obd->obd_exports))
                return;
 
-       /* We don't want to do this for large machines that do lots of
-        * mounts or unmounts.  It burns... */
-       if (obd->obd_num_exports > 100)
+       /*
+        * We don't want to do this for large machines that do lots of
+        * mounts or unmounts.  It burns...
+        * Use set_param to change obd_grant_check_threshold, which
+        * is 100 by default, 0 to always check grants
+        */
+       if (obd->obd_num_exports > obd->obd_grant_check_threshold &&
+           obd->obd_grant_check_threshold)
                return;
 
        maxsize = tgd->tgd_osfs.os_blocks << tgd->tgd_blockbits;