Whamcloud - gitweb
LU-9184 grants: move grant code to the target
[fs/lustre-release.git] / lustre / ofd / lproc_ofd.c
index 52ab770..7609167 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, 2014 Intel Corporation.
+ * Copyright (c) 2012, 2016, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
@@ -81,11 +81,11 @@ LPROC_SEQ_FOPS_RO(ofd_seqs);
 static int ofd_tot_dirty_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
-       struct ofd_device *ofd;
+       struct tg_grants_data *tgd;
 
        LASSERT(obd != NULL);
-       ofd = ofd_dev(obd->obd_lu_dev);
-       seq_printf(m, LPU64"\n", ofd->ofd_tot_dirty);
+       tgd = &obd->u.obt.obt_lut->lut_tgd;
+       seq_printf(m, "%llu\n", tgd->tgd_tot_dirty);
        return 0;
 }
 LPROC_SEQ_FOPS_RO(ofd_tot_dirty);
@@ -102,11 +102,11 @@ LPROC_SEQ_FOPS_RO(ofd_tot_dirty);
 static int ofd_tot_granted_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
-       struct ofd_device *ofd;
+       struct tg_grants_data *tgd;
 
        LASSERT(obd != NULL);
-       ofd = ofd_dev(obd->obd_lu_dev);
-       seq_printf(m, LPU64"\n", ofd->ofd_tot_granted);
+       tgd = &obd->u.obt.obt_lut->lut_tgd;
+       seq_printf(m, "%llu\n", tgd->tgd_tot_granted);
        return 0;
 }
 LPROC_SEQ_FOPS_RO(ofd_tot_granted);
@@ -123,11 +123,11 @@ LPROC_SEQ_FOPS_RO(ofd_tot_granted);
 static int ofd_tot_pending_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
-       struct ofd_device *ofd;
+       struct tg_grants_data *tgd;
 
        LASSERT(obd != NULL);
-       ofd = ofd_dev(obd->obd_lu_dev);
-       seq_printf(m, LPU64"\n", ofd->ofd_tot_pending);
+       tgd = &obd->u.obt.obt_lut->lut_tgd;
+       seq_printf(m, "%llu\n", tgd->tgd_tot_pending);
        return 0;
 }
 LPROC_SEQ_FOPS_RO(ofd_tot_pending);
@@ -147,7 +147,7 @@ static int ofd_grant_precreate_seq_show(struct seq_file *m, void *data)
 
        LASSERT(obd != NULL);
        seq_printf(m, "%ld\n",
-                  obd->obd_self_export->exp_filter_data.fed_grant);
+                  obd->obd_self_export->exp_target_data.ted_grant);
        return 0;
 }
 LPROC_SEQ_FOPS_RO(ofd_grant_precreate);
@@ -525,16 +525,15 @@ ofd_brw_size_seq_write(struct file *file, const char __user *buffer,
        __s64 val;
        int rc;
 
-       rc = lprocfs_str_to_s64(buffer, count, &val);
+       rc = lprocfs_str_with_units_to_s64(buffer, count, &val, 'M');
        if (rc)
                return rc;
 
-       if (val < 0)
+       if (val <= 0)
                return -EINVAL;
 
-       val = val * ONE_MB_BRW_SIZE;
-       if (val <= 0 || val > DT_MAX_BRW_SIZE ||
-           val < (1 << ofd->ofd_blockbits))
+       if (val > DT_MAX_BRW_SIZE ||
+           val < (1 << ofd->ofd_lut.lut_tgd.tgd_blockbits))
                return -ERANGE;
 
        spin_lock(&ofd->ofd_flags_lock);
@@ -637,7 +636,7 @@ LPROC_SEQ_FOPS(ofd_sync_lock_cancel);
 /**
  * Show if grants compatibility mode is disabled.
  *
- * When ofd_grant_compat_disable is set, we don't grant any space to clients
+ * When tgd_grant_compat_disable is set, we don't grant any space to clients
  * not supporting OBD_CONNECT_GRANT_PARAM. Otherwise, space granted to such
  * a client is inflated since it consumes PAGE_SIZE of grant space per
  * block, (i.e. typically 4kB units), but underlaying file system might have
@@ -652,16 +651,16 @@ LPROC_SEQ_FOPS(ofd_sync_lock_cancel);
 static int ofd_grant_compat_disable_seq_show(struct seq_file *m, void *data)
 {
        struct obd_device *obd = m->private;
-       struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+       struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
 
-       seq_printf(m, "%u\n", ofd->ofd_grant_compat_disable);
+       seq_printf(m, "%u\n", tgd->tgd_grant_compat_disable);
        return 0;
 }
 
 /**
  * Change grant compatibility mode.
  *
- * Setting ofd_grant_compat_disable prohibit any space granting to clients
+ * Setting tgd_grant_compat_disable prohibit any space granting to clients
  * not supporting OBD_CONNECT_GRANT_PARAM. See details above.
  *
  * \param[in] file     proc file
@@ -681,7 +680,7 @@ ofd_grant_compat_disable_seq_write(struct file *file,
 {
        struct seq_file *m = file->private_data;
        struct obd_device *obd = m->private;
-       struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
+       struct tg_grants_data *tgd = &obd->u.obt.obt_lut->lut_tgd;
        __s64 val;
        int rc;
 
@@ -692,9 +691,7 @@ ofd_grant_compat_disable_seq_write(struct file *file,
        if (val < 0)
                return -EINVAL;
 
-       spin_lock(&ofd->ofd_flags_lock);
-       ofd->ofd_grant_compat_disable = !!val;
-       spin_unlock(&ofd->ofd_flags_lock);
+       tgd->tgd_grant_compat_disable = !!val;
 
        return count;
 }
@@ -836,7 +833,7 @@ static int ofd_lfsck_verify_pfid_seq_show(struct seq_file *m, void *data)
        struct obd_device *obd = m->private;
        struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev);
 
-       seq_printf(m, "switch: %s\ndetected: "LPU64"\nrepaired: "LPU64"\n",
+       seq_printf(m, "switch: %s\ndetected: %llu\nrepaired: %llu\n",
                   ofd->ofd_lfsck_verify_pfid ? "on" : "off",
                   ofd->ofd_inconsistency_self_detected,
                   ofd->ofd_inconsistency_self_repaired);
@@ -874,6 +871,10 @@ ofd_lfsck_verify_pfid_seq_write(struct file *file, const char __user *buffer,
                return rc;
 
        ofd->ofd_lfsck_verify_pfid = !!val;
+       if (!ofd->ofd_lfsck_verify_pfid) {
+               ofd->ofd_inconsistency_self_detected = 0;
+               ofd->ofd_inconsistency_self_repaired = 0;
+       }
 
        return count;
 }