Whamcloud - gitweb
LU-10776 osc: Do not request more than 2GiB grant
[fs/lustre-release.git] / lustre / target / tgt_grant.c
index 355a092..8465052 100644 (file)
@@ -23,7 +23,7 @@
  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
  *
- * Copyright (c) 2012, 2016, Intel Corporation.
+ * Copyright (c) 2012, 2017, Intel Corporation.
  */
 /*
  * lustre/target/tgt_grant.c
@@ -280,14 +280,14 @@ EXPORT_SYMBOL(tgt_grant_sanity_check);
  * \retval             negative value on error
  */
 int tgt_statfs_internal(const struct lu_env *env, struct lu_target *lut,
-                       struct obd_statfs *osfs, __u64 max_age, int *from_cache)
+                       struct obd_statfs *osfs, time64_t max_age, int *from_cache)
 {
        struct tg_grants_data *tgd = &lut->lut_tgd;
        int rc = 0;
        ENTRY;
 
        spin_lock(&tgd->tgd_osfs_lock);
-       if (cfs_time_before_64(tgd->tgd_osfs_age, max_age) || max_age == 0) {
+       if (tgd->tgd_osfs_age < max_age || max_age == 0) {
                u64 unstable;
 
                /* statfs data are too old, get up-to-date one.
@@ -344,7 +344,7 @@ int tgt_statfs_internal(const struct lu_env *env, struct lu_target *lut,
 
                /* finally udpate cached statfs data */
                tgd->tgd_osfs = *osfs;
-               tgd->tgd_osfs_age = cfs_time_current_64();
+               tgd->tgd_osfs_age = ktime_get_seconds();
 
                tgd->tgd_statfs_inflight--; /* stop tracking */
                if (tgd->tgd_statfs_inflight == 0)
@@ -390,13 +390,13 @@ static void tgt_grant_statfs(const struct lu_env *env, struct obd_export *exp,
        struct tg_grants_data   *tgd = &lut->lut_tgd;
        struct tgt_thread_info  *tti;
        struct obd_statfs       *osfs;
-       __u64                    max_age;
-       int                      rc;
+       time64_t max_age;
+       int rc;
 
        if (force)
                max_age = 0; /* get fresh statfs data */
        else
-               max_age = cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS);
+               max_age = ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS;
 
        tti = tgt_th_info(env);
        osfs = &tti->tti_u.osfs;
@@ -894,9 +894,10 @@ static long tgt_grant_alloc(struct obd_export *exp, u64 curgrant,
             tgd->tgd_grant_compat_disable) || left == 0 || exp->exp_failed)
                RETURN(0);
 
-       if (want > 0x7fffffff) {
-               CERROR("%s: client %s/%p requesting > 2GB grant %llu\n",
-                      obd->obd_name, exp->exp_client_uuid.uuid, exp, want);
+       if (want > OBD_MAX_GRANT) {
+               CERROR("%s: client %s/%p requesting > max (%lu), %llu\n",
+                      obd->obd_name, exp->exp_client_uuid.uuid, exp,
+                      OBD_MAX_GRANT, want);
                RETURN(0);
        }
 
@@ -1629,17 +1630,14 @@ ssize_t tgt_grant_compat_disable_seq_write(struct file *file,
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
        struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
-       __s64 val;
+       bool val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = kstrtobool_from_user(buffer, count, &val);
        if (rc)
                return rc;
 
-       if (val < 0)
-               return -EINVAL;
-
-       tgd->tgd_grant_compat_disable = !!val;
+       tgd->tgd_grant_compat_disable = val;
 
        return count;
 }