From: James Simmons <jsimmons@infradead.org>
To: Andreas Dilger <adilger@whamcloud.com>,
Oleg Drokin <green@whamcloud.com>, NeilBrown <neilb@suse.de>
Cc: Lustre Development List <lustre-devel@lists.lustre.org>
Subject: [lustre-devel] [PATCH 02/15] lustre: mdc: add support for grant shrink
Date: Mon, 8 Nov 2021 10:07:30 -0500 [thread overview]
Message-ID: <1636384063-13838-3-git-send-email-jsimmons@infradead.org> (raw)
In-Reply-To: <1636384063-13838-1-git-send-email-jsimmons@infradead.org>
From: Alex Zhuravlev <bzzz@whamcloud.com>
just re-use existing mechanism used in OSC
WC-bug-id: https://jira.whamcloud.com/browse/LU-15010
Lustre-commit: 6e116213e3fd7d726 ("LU-15010 mdc: add support for grant shrink")
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/44956
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
fs/lustre/include/lustre_osc.h | 2 +
fs/lustre/llite/llite_lib.c | 1 +
fs/lustre/mdc/lproc_mdc.c | 106 +++++++++++++++++++++++++++++++++++++++++
fs/lustre/osc/osc_request.c | 2 +
4 files changed, 111 insertions(+)
diff --git a/fs/lustre/include/lustre_osc.h b/fs/lustre/include/lustre_osc.h
index cdc9aae..49a5e3b 100644
--- a/fs/lustre/include/lustre_osc.h
+++ b/fs/lustre/include/lustre_osc.h
@@ -680,6 +680,8 @@ int osc_punch_send(struct obd_export *exp, struct obdo *oa,
obd_enqueue_update_f upcall, void *cookie);
int osc_fallocate_base(struct obd_export *exp, struct obdo *oa,
obd_enqueue_update_f upcall, void *cookie, int mode);
+void osc_update_next_shrink(struct client_obd *cli);
+void osc_schedule_grant_work(void);
/* osc_io.c */
int osc_io_submit(const struct lu_env *env, const struct cl_io_slice *ios,
diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c
index abd470a..51823b5 100644
--- a/fs/lustre/llite/llite_lib.c
+++ b/fs/lustre/llite/llite_lib.c
@@ -303,6 +303,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt)
OBD_CONNECT_SUBTREE |
OBD_CONNECT_MULTIMODRPCS |
OBD_CONNECT_GRANT_PARAM |
+ OBD_CONNECT_GRANT_SHRINK |
OBD_CONNECT_SHORTIO | OBD_CONNECT_FLAGS2;
data->ocd_connect_flags2 = OBD_CONNECT2_DIR_MIGRATE |
diff --git a/fs/lustre/mdc/lproc_mdc.c b/fs/lustre/mdc/lproc_mdc.c
index d13a6b7..87beb1b 100644
--- a/fs/lustre/mdc/lproc_mdc.c
+++ b/fs/lustre/mdc/lproc_mdc.c
@@ -606,6 +606,108 @@ static ssize_t mdc_dom_min_repsize_seq_write(struct file *file,
{ NULL }
};
+static ssize_t cur_lost_grant_bytes_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;
+
+ return scnprintf(buf, PAGE_SIZE, "%lu\n", cli->cl_lost_grant);
+}
+LUSTRE_RO_ATTR(cur_lost_grant_bytes);
+
+static ssize_t cur_dirty_grant_bytes_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;
+
+ return scnprintf(buf, PAGE_SIZE, "%lu\n", cli->cl_dirty_grant);
+}
+LUSTRE_RO_ATTR(cur_dirty_grant_bytes);
+
+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 obd_import *imp;
+ ssize_t len;
+
+ with_imp_locked(obd, imp, len)
+ len = scnprintf(buf, PAGE_SIZE, "%d\n",
+ !imp->imp_grant_shrink_disabled &&
+ OCD_HAS_FLAG(&imp->imp_connect_data,
+ GRANT_SHRINK));
+
+ return len;
+}
+
+static ssize_t grant_shrink_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 obd_import *imp;
+ bool val;
+ int rc;
+
+ if (!obd)
+ return 0;
+
+ rc = kstrtobool(buffer, &val);
+ if (rc)
+ return rc;
+
+ with_imp_locked(obd, imp, rc) {
+ spin_lock(&imp->imp_lock);
+ imp->imp_grant_shrink_disabled = !val;
+ spin_unlock(&imp->imp_lock);
+ }
+
+ return rc ?: count;
+}
+LUSTRE_RW_ATTR(grant_shrink);
+
+static ssize_t grant_shrink_interval_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
+{
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kset.kobj);
+
+ return sprintf(buf, "%lld\n", obd->u.cli.cl_grant_shrink_interval);
+}
+
+static ssize_t grant_shrink_interval_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);
+ unsigned int val;
+ int rc;
+
+ rc = kstrtouint(buffer, 0, &val);
+ if (rc)
+ return rc;
+
+ if (val == 0)
+ return -ERANGE;
+
+ obd->u.cli.cl_grant_shrink_interval = val;
+ osc_update_next_shrink(&obd->u.cli);
+ osc_schedule_grant_work();
+
+ return count;
+}
+LUSTRE_RW_ATTR(grant_shrink_interval);
+
static struct attribute *mdc_attrs[] = {
&lustre_attr_active.attr,
&lustre_attr_checksums.attr,
@@ -616,6 +718,10 @@ static ssize_t mdc_dom_min_repsize_seq_write(struct file *file,
&lustre_attr_mds_conn_uuid.attr,
&lustre_attr_conn_uuid.attr,
&lustre_attr_ping.attr,
+ &lustre_attr_grant_shrink.attr,
+ &lustre_attr_grant_shrink_interval.attr,
+ &lustre_attr_cur_lost_grant_bytes.attr,
+ &lustre_attr_cur_dirty_grant_bytes.attr,
NULL,
};
diff --git a/fs/lustre/osc/osc_request.c b/fs/lustre/osc/osc_request.c
index 22b7e5e..cf79808 100644
--- a/fs/lustre/osc/osc_request.c
+++ b/fs/lustre/osc/osc_request.c
@@ -770,6 +770,7 @@ void osc_update_next_shrink(struct client_obd *cli)
CDEBUG(D_CACHE, "next time %lld to shrink grant\n",
cli->cl_next_shrink_grant);
}
+EXPORT_SYMBOL(osc_update_next_shrink);
static void __osc_update_grant(struct client_obd *cli, u64 grant)
{
@@ -980,6 +981,7 @@ void osc_schedule_grant_work(void)
cancel_delayed_work_sync(&work);
schedule_work(&work.work);
}
+EXPORT_SYMBOL(osc_schedule_grant_work);
/**
* Start grant thread for returing grant to server for idle clients.
--
1.8.3.1
_______________________________________________
lustre-devel mailing list
lustre-devel@lists.lustre.org
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
next prev parent reply other threads:[~2021-11-08 15:07 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-08 15:07 [lustre-devel] [PATCH 00/15] lustre: update to OpenSFS tree Nov 8, 2021 James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 01/15] lustre: sec: keep encryption context in xattr cache James Simmons
2021-11-08 15:07 ` James Simmons [this message]
2021-11-08 15:07 ` [lustre-devel] [PATCH 03/15] lnet: Fix reference leak in lnet_parse James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 04/15] lnet: socklnd: lock ksnc_tx_queue list processing James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 05/15] lustre: ptlrpc: align function names with param names James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 06/15] lnet: don't retry allocating router buffers James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 07/15] lustre: ptlrpc: recalc timer on EINPROGRESS reply James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 08/15] lustre: obdclass: add start time to stats files James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 09/15] lustre: dne: dir migrate in QOS mode James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 10/15] lustre: lov: fix error handling in lov_new_pool James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 11/15] lustre: vfs: set_nlink() is not race-safe James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 12/15] lustre: ptlrpc: remove LASSERT in nrs_polices debugfs handler James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 13/15] lnet: socklnd: default conns_per_peer to 0 James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 14/15] lnet: don't use hops to determine the route state James Simmons
2021-11-08 15:07 ` [lustre-devel] [PATCH 15/15] lustre: lmv: update default LMV upon any change James Simmons
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1636384063-13838-3-git-send-email-jsimmons@infradead.org \
--to=jsimmons@infradead.org \
--cc=adilger@whamcloud.com \
--cc=green@whamcloud.com \
--cc=lustre-devel@lists.lustre.org \
--cc=neilb@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).