From patchwork Thu Feb 27 21:11:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11410055 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 DE1A617E0 for ; Thu, 27 Feb 2020 21:29:04 +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 C6E86246A1 for ; Thu, 27 Feb 2020 21:29:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C6E86246A1 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 276A93493A9; Thu, 27 Feb 2020 13:25:10 -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 A1F1321FAE5 for ; Thu, 27 Feb 2020 13:19:27 -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 00F0C2C56; Thu, 27 Feb 2020 16:18:16 -0500 (EST) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id F3CAC468; Thu, 27 Feb 2020 16:18:15 -0500 (EST) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Thu, 27 Feb 2020 16:11:36 -0500 Message-Id: <1582838290-17243-229-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 228/622] lustre: llite: limit statfs ffree if less than OST ffree 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: Andreas Dilger If the OSTs report fewer total free objects than the MDTs, then use the free files count reported by the OSTs, since it represents the minimum number of files that can be created in the filesystem (creating more may be possible, but this depends on other factors). This has always been what ll_statfs_internal() reports, but the statfs aggregation via the MDT missed this step in lod_statfs(). Fix a minor defect in sanity test_418() that would let it loop forever until the test was killed due to timeout if the "df -i" and "lfs df -i" output did not converge. Fixes: 41a201a04c0f ("lustre: protocol: MDT as a statfs proxy") WC-bug-id: https://jira.whamcloud.com/browse/LU-11721 Lustre-commit: a829595add80 ("LU-11721 lod: limit statfs ffree if less than OST ffree") Signed-off-by: Andreas Dilger Reviewed-on: https://review.whamcloud.com/34167 Reviewed-by: Jian Yu Reviewed-by: Nikitas Angelinas Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/include/obd_class.h | 5 +++-- fs/lustre/llite/llite_lib.c | 22 +++++++++++----------- fs/lustre/lmv/lmv_obd.c | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/fs/lustre/include/obd_class.h b/fs/lustre/include/obd_class.h index 434bb79..6a4b6a5 100644 --- a/fs/lustre/include/obd_class.h +++ b/fs/lustre/include/obd_class.h @@ -898,8 +898,9 @@ static inline int obd_statfs_async(struct obd_export *exp, obd = exp->exp_obd; if (!obd->obd_type || !obd->obd_type->typ_dt_ops->statfs) { - CERROR("%s: no %s operation\n", obd->obd_name, __func__); - return -EOPNOTSUPP; + rc = -EOPNOTSUPP; + CERROR("%s: no statfs operation: rc = %d\n", obd->obd_name, rc); + return rc; } CDEBUG(D_SUPER, "%s: age %lld, max_age %lld\n", diff --git a/fs/lustre/llite/llite_lib.c b/fs/lustre/llite/llite_lib.c index 84fc54d..4d41981a 100644 --- a/fs/lustre/llite/llite_lib.c +++ b/fs/lustre/llite/llite_lib.c @@ -1723,17 +1723,15 @@ int ll_setattr(struct dentry *de, struct iattr *attr) int ll_statfs_internal(struct ll_sb_info *sbi, struct obd_statfs *osfs, u32 flags) { - struct obd_statfs obd_osfs; + struct obd_statfs obd_osfs = { 0 }; time64_t max_age; int rc; max_age = ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS; rc = obd_statfs(NULL, sbi->ll_md_exp, osfs, max_age, flags); - if (rc) { - CERROR("md_statfs fails: rc = %d\n", rc); + if (rc) return rc; - } osfs->os_type = LL_SUPER_MAGIC; @@ -1749,8 +1747,9 @@ int ll_statfs_internal(struct ll_sb_info *sbi, struct obd_statfs *osfs, rc = obd_statfs(NULL, sbi->ll_dt_exp, &obd_osfs, max_age, flags); if (rc) { - CERROR("obd_statfs fails: rc = %d\n", rc); - return rc; + /* Possibly a filesystem with no OSTs. Report MDT totals. */ + rc = 0; + goto out; } CDEBUG(D_SUPER, "OSC blocks %llu/%llu objects %llu/%llu\n", @@ -1762,13 +1761,14 @@ int ll_statfs_internal(struct ll_sb_info *sbi, struct obd_statfs *osfs, osfs->os_bfree = obd_osfs.os_bfree; osfs->os_bavail = obd_osfs.os_bavail; - /* If we don't have as many objects free on the OST as inodes - * on the MDS, we reduce the total number of inodes to - * compensate, so that the "inodes in use" number is correct. + /* If we have _some_ OSTs, but don't have as many free objects on the + * OSTs as inodes on the MDTs, reduce the reported number of inodes + * to compensate, so that the "inodes in use" number is correct. + * This should be kept in sync with lod_statfs() behaviour. */ - if (obd_osfs.os_ffree < osfs->os_ffree) { + if (obd_osfs.os_files && obd_osfs.os_ffree < osfs->os_ffree) { osfs->os_files = (osfs->os_files - osfs->os_ffree) + - obd_osfs.os_ffree; + obd_osfs.os_ffree; osfs->os_ffree = obd_osfs.os_ffree; } diff --git a/fs/lustre/lmv/lmv_obd.c b/fs/lustre/lmv/lmv_obd.c index 0685925..6ad100c 100644 --- a/fs/lustre/lmv/lmv_obd.c +++ b/fs/lustre/lmv/lmv_obd.c @@ -1402,8 +1402,8 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, rc = obd_statfs(env, lmv->tgts[idx]->ltd_exp, temp, max_age, flags); if (rc) { - CERROR("can't stat MDS #%d (%s), error %d\n", i, - lmv->tgts[idx]->ltd_exp->exp_obd->obd_name, + CERROR("%s: can't stat MDS #%d: rc = %d\n", + lmv->tgts[idx]->ltd_exp->exp_obd->obd_name, i, rc); goto out_free_temp; }