@@ -303,7 +303,9 @@ struct obd_import {
/* import has tried to connect with server */
imp_connect_tried:1,
/* connected but not FULL yet */
- imp_connected:1;
+ imp_connected:1,
+ /* grant shrink disabled */
+ imp_grant_shrink_disabled:1;
u32 imp_connect_op;
u32 imp_idle_timeout;
@@ -695,18 +695,17 @@ static ssize_t grant_shrink_show(struct kobject *kobj, struct attribute *attr,
{
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;
+ struct obd_import *imp;
ssize_t len;
len = lprocfs_climp_check(obd);
if (len)
return len;
- ocd = &cli->cl_import->imp_connect_data;
-
+ imp = obd->u.cli.cl_import;
len = snprintf(buf, PAGE_SIZE, "%d\n",
- !!OCD_HAS_FLAG(ocd, GRANT_SHRINK));
+ !imp->imp_grant_shrink_disabled &&
+ OCD_HAS_FLAG(&imp->imp_connect_data, GRANT_SHRINK));
up_read(&obd->u.cli.cl_sem);
return len;
@@ -717,8 +716,7 @@ static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr,
{
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;
+ struct obd_import *imp;
bool val;
int rc;
@@ -733,22 +731,10 @@ static ssize_t grant_shrink_store(struct kobject *kobj, struct attribute *attr,
if (rc)
return rc;
- 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;
- }
+ imp = dev->u.cli.cl_import;
+ spin_lock(&imp->imp_lock);
+ imp->imp_grant_shrink_disabled = !val;
+ spin_unlock(&imp->imp_lock);
up_read(&dev->u.cli.cl_sem);
@@ -844,8 +844,8 @@ static int osc_should_shrink_grant(struct client_obd *client)
if (!client->cl_import)
return 0;
- if ((client->cl_import->imp_connect_data.ocd_connect_flags &
- OBD_CONNECT_GRANT_SHRINK) == 0)
+ if (!OCD_HAS_FLAG(&client->cl_import->imp_connect_data, GRANT_SHRINK) ||
+ client->cl_import->imp_grant_shrink_disabled)
return 0;
if (ktime_get_seconds() >= next_shrink - 5) {