From: Vladimir Saveliev Date: Mon, 13 Dec 2021 15:11:58 +0000 (+0300) Subject: LU-14542 obd: tunable for sanity grant check X-Git-Tag: 2.14.57~64 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=refs%2Fchanges%2F28%2F42128%2F7;p=fs%2Flustre-release.git LU-14542 obd: tunable for sanity grant check 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 HPE-bug-id: LUS-9827 Reviewed-on: https://review.whamcloud.com/42128 Reviewed-by: Andreas Dilger Reviewed-by: Alexander Boyko Tested-by: jenkins Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lprocfs_status.h b/lustre/include/lprocfs_status.h index d622f8c..9b2ba94 100644 --- a/lustre/include/lprocfs_status.h +++ b/lustre/include/lprocfs_status.h @@ -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, diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 9ebd53f..971b9fc 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -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 */ diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index c6445fb..e90d528 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -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, diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 29fc4cb..2553a2e 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -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); diff --git a/lustre/obdclass/lprocfs_status_server.c b/lustre/obdclass/lprocfs_status_server.c index a912ba6..a3ddaa9 100644 --- a/lustre/obdclass/lprocfs_status_server.c +++ b/lustre/obdclass/lprocfs_status_server.c @@ -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; diff --git a/lustre/ofd/lproc_ofd.c b/lustre/ofd/lproc_ofd.c index acff6b9..db81351 100644 --- a/lustre/ofd/lproc_ofd.c +++ b/lustre/ofd/lproc_ofd.c @@ -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, diff --git a/lustre/target/tgt_grant.c b/lustre/target/tgt_grant.c index 37d1ba8..ac1757e 100644 --- a/lustre/target/tgt_grant.c +++ b/lustre/target/tgt_grant.c @@ -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;