+
+/**
+ * Show lbug_on_grant_miscount mode.
+ *
+ * @kobj kobject embedded in obd_device
+ * @attr unused
+ * @buf buf used by sysfs to print out data
+ *
+ * Return: string length of @buf output on success
+ */
+ssize_t lbug_on_grant_miscount_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
+{
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
+ struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
+
+ return scnprintf(buf, PAGE_SIZE, "%u\n",
+ tgd->tgd_lbug_on_grant_miscount);
+}
+EXPORT_SYMBOL(lbug_on_grant_miscount_show);
+
+/**
+ * Change lbug on grant miscount mode.
+ *
+ * Setting tgd_lbug_on_grant_miscount to 1 makes tgt_alloc_grant() to
+ * LBUG on apparently wrong ted->ted_grant
+ *
+ * @kobj kobject embedded in obd_device
+ * @attr unused
+ * @buffer string which represents mode
+ * 1: use LBUG on grant miscount
+ * 0: use CERROR on grant miscount
+ * @count @buffer length
+ *
+ * Return: @count on success
+ * negative number on error
+ */
+ssize_t lbug_on_grant_miscount_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);
+ struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
+ bool val;
+ int rc;
+
+ rc = kstrtobool(buffer, &val);
+ if (rc)
+ return rc;
+
+ tgd->tgd_lbug_on_grant_miscount = val;
+
+ return count;
+}
+EXPORT_SYMBOL(lbug_on_grant_miscount_store);