Whamcloud - gitweb
LU-8708 osc: enable/disable OSC grant shrink 03/23203/18
authorBobi Jam <bobijam@whamcloud.com>
Mon, 17 Oct 2016 09:50:41 +0000 (17:50 +0800)
committerOleg Drokin <green@whamcloud.com>
Sat, 1 Sep 2018 03:28:43 +0000 (03:28 +0000)
Add an OSC proc interface to enable/disable client's grant shrink
feature.

lctl get_param osc.*.grant_shrink
lctl set_param osc.*.grant_shrink={0,1}

Change-Id: I7974b3bf1c4f9c294dd0d4871d09b1a2e45a8d78
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/23203
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osc/lproc_osc.c

index ba87e17..463c179 100644 (file)
@@ -675,6 +675,66 @@ static ssize_t idle_connect_store(struct kobject *kobj, struct attribute *attr,
 }
 LUSTRE_WO_ATTR(idle_connect);
 
+static ssize_t grant_shrink_show(struct kobject *kobj, struct attribute *attr,
+                                char *buf)
+{
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
+       struct client_obd *cli = &obd->u.cli;
+       struct obd_connect_data *ocd;
+       ssize_t len;
+
+       LPROCFS_CLIMP_CHECK(obd);
+       ocd = &cli->cl_import->imp_connect_data;
+
+       len = snprintf(buf, PAGE_SIZE, "%d\n",
+                      !!OCD_HAS_FLAG(ocd, GRANT_SHRINK));
+       LPROCFS_CLIMP_EXIT(obd);
+
+       return len;
+}
+
+static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr,
+                                 const char *buffer, size_t count)
+{
+       struct obd_device *dev = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
+       struct client_obd *cli = &dev->u.cli;
+       struct obd_connect_data *ocd;
+       bool val;
+       int rc;
+
+       if (dev == NULL)
+               return 0;
+
+       rc = kstrtobool(buffer, &val);
+       if (rc)
+               return rc;
+
+       LPROCFS_CLIMP_CHECK(dev);
+       ocd = &cli->cl_import->imp_connect_data;
+
+       if (!val) {
+               if (OCD_HAS_FLAG(ocd, GRANT_SHRINK))
+                       ocd->ocd_connect_flags &= ~OBD_CONNECT_GRANT_SHRINK;
+       } else {
+               /**
+                * server replied obd_connect_data is always bigger, so
+                * client's imp_connect_flags_orig are always supported
+                * by the server
+                */
+               if (!OCD_HAS_FLAG(ocd, GRANT_SHRINK) &&
+                   cli->cl_import->imp_connect_flags_orig &
+                   OBD_CONNECT_GRANT_SHRINK)
+                       ocd->ocd_connect_flags |= OBD_CONNECT_GRANT_SHRINK;
+       }
+
+       LPROCFS_CLIMP_EXIT(dev);
+
+       return count;
+}
+LUSTRE_RW_ATTR(grant_shrink);
+
 LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
 LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
 LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
@@ -893,6 +953,7 @@ static struct attribute *osc_attrs[] = {
        &lustre_attr_ping.attr,
        &lustre_attr_idle_timeout.attr,
        &lustre_attr_idle_connect.attr,
+       &lustre_attr_grant_shrink.attr,
        NULL,
 };