From patchwork Thu Feb 27 21:09:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11409861 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 11D3B138D for ; Thu, 27 Feb 2020 21:24:17 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EEBB5246A0 for ; Thu, 27 Feb 2020 21:24:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EEBB5246A0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 50D9821FF8D; Thu, 27 Feb 2020 13:22:05 -0800 (PST) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp3.ccs.ornl.gov (smtp3.ccs.ornl.gov [160.91.203.39]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id C606221FAFB for ; Thu, 27 Feb 2020 13:18:47 -0800 (PST) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp3.ccs.ornl.gov (Postfix) with ESMTP id 723751026; Thu, 27 Feb 2020 16:18:14 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 6F79046A; Thu, 27 Feb 2020 16:18:14 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:09:30 -0500 Message-Id: <1582838290-17243-103-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> References: <1582838290-17243-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 102/622] lustre: osc: enable/disable OSC grant shrink X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Bobi Jam Add an OSC sysfs interface to enable/disable client's grant shrink feature. lctl get_param osc.*.grant_shrink lctl set_param osc.*.grant_shrink={0,1} WC-bug-id: https://jira.whamcloud.com/browse/LU-8708 Lustre-commit: 3e070e30a98d ("LU-8708 osc: enable/disable OSC grant shrink") Signed-off-by: Bobi Jam Reviewed-on: https://review.whamcloud.com/23203 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/osc/lproc_osc.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/fs/lustre/osc/lproc_osc.c b/fs/lustre/osc/lproc_osc.c index efb4998..16de266 100644 --- a/fs/lustre/osc/lproc_osc.c +++ b/fs/lustre/osc/lproc_osc.c @@ -674,6 +674,72 @@ 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; + + len = lprocfs_climp_check(obd); + if (len) + return len; + + ocd = &cli->cl_import->imp_connect_data; + + len = snprintf(buf, PAGE_SIZE, "%d\n", + !!OCD_HAS_FLAG(ocd, GRANT_SHRINK)); + up_read(&obd->u.cli.cl_sem); + + 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) + return 0; + + rc = kstrtobool(buffer, &val); + if (rc) + return rc; + + rc = lprocfs_climp_check(dev); + 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; + } + + up_read(&dev->u.cli.cl_sem); + + 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); @@ -889,6 +955,7 @@ void lproc_osc_attach_seqstat(struct obd_device *dev) &lustre_attr_ping.attr, &lustre_attr_idle_timeout.attr, &lustre_attr_idle_connect.attr, + &lustre_attr_grant_shrink.attr, NULL, };