Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3445072imm; Tue, 29 May 2018 07:23:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqJDoSntZ1sjGx/LMoMXSFOTd37YvNRTGv1Xz8kUX1ALxrrco3ab+oIxvmEeBx5z2dkRsqH X-Received: by 2002:a63:86c8:: with SMTP id x191-v6mr13730313pgd.2.1527603797670; Tue, 29 May 2018 07:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527603797; cv=none; d=google.com; s=arc-20160816; b=euAuU8DE4hB5oVsNGF2uyxZCr+sun1qoyIaC/MYHJA+tq9H1N18bcn2scnTJfdyRJW 3T8jq43mTuQgWcaSJAS7TVbXVxA9Bnx7MToEVkWp2qgAM7L2R/s48KjfUim1ptOdB8rl qR+54S1SZVbkn2ZYCD31q1NcvbtWbfW2R5cBU18Ev+AOgxu6HHGI+dbHjkZYdlmcl5YF Zep1TbUMiFTmgSqB08Gj81u0ycffTewUk0ViqaHAypU+0khJS/rCsXy4Hr3hZ65zbXbg 2eL75IUM2ZxL+ClkYmA/6DDCYG602AMg3V1XVlc6tIssSSsjBpOKPq/r48UtxiHkYPhZ EHGg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=3Dd9hbhahd+G/PVOiUlJkq4jMF0hA5k+BaKMUqwsBws=; b=KQUNQnS4EokXMNwTPOoJ0AruJQ8wYx7LkdtsJ0TkwgWEionxxVOcpzfILjt0xhKnvP 1xyfnGTTkA5KRODZVL0UUYAVufZYfdO0MUQQ/wXPWwn08+4qkebfqUbEHiWEu+ntn+VV WsPc0OYBT+zKHPAUiYW5VTPPPu/ajh23r89c6Itq/s5XdfjupUxSZQbmdAPJipAxTQ6B k1bGHX1x+pAiiVmUxlSCHhJ/F+Pe3ABU8jCSyyb07d82Gy97KPfyTvGkCoq6uGO5nxC7 FxyI1pG0XTlnXUpZJ+hC5jq1p5zwVMf5jILpttd/UpQZFQonQsXMUqnVbg/3fUToaHVB tlzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 82-v6si8348726pgh.144.2018.05.29.07.23.03; Tue, 29 May 2018 07:23:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935062AbeE2OWE (ORCPT + 99 others); Tue, 29 May 2018 10:22:04 -0400 Received: from smtp4.ccs.ornl.gov ([160.91.203.40]:38132 "EHLO smtp4.ccs.ornl.gov" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934304AbeE2OV6 (ORCPT ); Tue, 29 May 2018 10:21:58 -0400 Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id CB511100527A; Tue, 29 May 2018 10:21:49 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id C8A59BF; Tue, 29 May 2018 10:21:49 -0400 (EDT) From: James Simmons To: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Andreas Dilger , Oleg Drokin , NeilBrown Cc: Linux Kernel Mailing List , Lustre Development List , Andrew Perepechko , James Simmons Subject: [PATCH v2 5/6] staging: lustre: mdc: excessive memory consumption by the xattr cache Date: Tue, 29 May 2018 10:21:44 -0400 Message-Id: <1527603705-30450-6-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1527603705-30450-1-git-send-email-jsimmons@infradead.org> References: <1527603705-30450-1-git-send-email-jsimmons@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Perepechko The refill operation of the xattr cache does not know the reply size in advance, so it makes a guess based on the maxeasize value returned by the MDS. In practice, it allocates 16 KiB for the common case and 4 MiB for the large xattr case. However, a typical reply is just a few hundred bytes. If we follow the conservative approach, we can prepare a single memory page for the reply. It is large enough for any reasonable xattr set and, at the same time, it does not require multiple page memory reclaim, which can be costly. If, for a specific file, the reply is larger than a single page, the client is prepared to handle that and will fall back to non-cached xattr code. Indeed, if this happens often and xattrs are often used to store large values, it makes sense to disable the xattr cache at all since it wasn't designed for such [mis]use. Signed-off-by: Andrew Perepechko Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9417 Reviewed-on: https://review.whamcloud.com/26887 Reviewed-by: Fan Yong Reviewed-by: Ben Evans Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- Changelog: v1) Initial patch v2) rebased patch. No changes drivers/staging/lustre/lustre/mdc/mdc_locks.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c index 65a5341..a8aa0fa 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c @@ -315,6 +315,10 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req, return req; } +#define GA_DEFAULT_EA_NAME_LEN 20 +#define GA_DEFAULT_EA_VAL_LEN 250 +#define GA_DEFAULT_EA_NUM 10 + static struct ptlrpc_request * mdc_intent_getxattr_pack(struct obd_export *exp, struct lookup_intent *it, @@ -323,7 +327,6 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req, struct ptlrpc_request *req; struct ldlm_intent *lit; int rc, count = 0; - u32 maxdata; LIST_HEAD(cancels); req = ptlrpc_request_alloc(class_exp2cliimp(exp), @@ -341,20 +344,20 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req, lit = req_capsule_client_get(&req->rq_pill, &RMF_LDLM_INTENT); lit->opc = IT_GETXATTR; - maxdata = class_exp2cliimp(exp)->imp_connect_data.ocd_max_easize; - /* pack the intended request */ - mdc_pack_body(req, &op_data->op_fid1, op_data->op_valid, maxdata, -1, - 0); + mdc_pack_body(req, &op_data->op_fid1, op_data->op_valid, + GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM, -1, 0); - req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_SERVER, maxdata); + req_capsule_set_size(&req->rq_pill, &RMF_EADATA, RCL_SERVER, + GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM); - req_capsule_set_size(&req->rq_pill, &RMF_EAVALS, RCL_SERVER, maxdata); + req_capsule_set_size(&req->rq_pill, &RMF_EAVALS, RCL_SERVER, + GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM); - req_capsule_set_size(&req->rq_pill, &RMF_EAVALS_LENS, - RCL_SERVER, maxdata); + req_capsule_set_size(&req->rq_pill, &RMF_EAVALS_LENS, RCL_SERVER, + sizeof(u32) * GA_DEFAULT_EA_NUM); - req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, maxdata); + req_capsule_set_size(&req->rq_pill, &RMF_ACL, RCL_SERVER, 0); ptlrpc_request_set_replen(req); -- 1.8.3.1