Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp983107ybx; Thu, 31 Oct 2019 04:04:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyJOIsKu+g71gdUc9BPmFtVskmZacdE5CTNGXZwi36E7U9VAdPN83SR1ztf7eiJohdzHDW X-Received: by 2002:a50:950a:: with SMTP id u10mr5349747eda.68.1572519873226; Thu, 31 Oct 2019 04:04:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572519873; cv=none; d=google.com; s=arc-20160816; b=khG/qT6GWFw2ocAHntMX3YGKaWZD4+0Qp6xI7sYntDN4BH5s+uMGBV/X6xksoM6HpD /axJIcj7gu1g+uhEXakLb0dr/CRN4Ev2Br7I1+LscoVql3hOTGXIaib317leEw9wcsIo SG28uV/wgjBPxTzbn6affQuMGZaYb5ph6Xi6SIqQAEn8aa6q4Cx5yHloseGsDuwfc3Ks pPbph0Om7euRkZ+T6VZ0mesYzJ3ocHpdMIZkn3wPz6oV+DnVhgc4VaqGiA4qJlNj8hlU HRbJOHA8Vda63dlBR5PDecp5gfBpi88K6iktBUa+9LVFk1RJIfNnBOyl4x2i9qKvyd/f v1dA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=D+6O7iUMBkZ3sqVRjui7jk+wGVzrqyDNlvlVRTMTN3s=; b=paHmTdsKixZehk4awR9vF22mwQNuzYcHsl1HCqxogtOjUbga9C2onTF0RZbj5GDf0l 0lN7qQz+8vehhv9iREkiwgm3k/nQUgqZZKlP0DnA4qkTfoagc4eVZSQS/XY3Uut5y1/G M0qEXnnz4oZQ4YOS/j7zdNqPu3w3H15pTVi3FM1dTuAf/wWNcqOAT5Bv0Fk/VpHQS5SK 4q0zXn6a1s99/XSPCu+mklStHQj1A8yWK8wSzLC6/JsmaZWEa/VaQOyKQUH88/GAcOyp dqAIfYTsdLdDghfn+8ByaXdacEVqnujmX+z49lG0n+m2tDyTDQRT8kDESVO8Bu6dRWKf 3Qtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=gMHioc8M; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h52si3808555edb.77.2019.10.31.04.04.04; Thu, 31 Oct 2019 04:04:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@yandex-team.ru header.s=default header.b=gMHioc8M; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=openvz.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727419AbfJaLED (ORCPT + 99 others); Thu, 31 Oct 2019 07:04:03 -0400 Received: from forwardcorp1p.mail.yandex.net ([77.88.29.217]:41840 "EHLO forwardcorp1p.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727073AbfJaLEC (ORCPT ); Thu, 31 Oct 2019 07:04:02 -0400 Received: from mxbackcorp1j.mail.yandex.net (mxbackcorp1j.mail.yandex.net [IPv6:2a02:6b8:0:1619::162]) by forwardcorp1p.mail.yandex.net (Yandex) with ESMTP id 26A3F2E1486; Thu, 31 Oct 2019 14:03:59 +0300 (MSK) Received: from sas2-62907d92d1d8.qloud-c.yandex.net (sas2-62907d92d1d8.qloud-c.yandex.net [2a02:6b8:c08:b895:0:640:6290:7d92]) by mxbackcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id GiObEs4vO4-3wiSUIiv; Thu, 31 Oct 2019 14:03:59 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1572519839; bh=D+6O7iUMBkZ3sqVRjui7jk+wGVzrqyDNlvlVRTMTN3s=; h=Message-Id:Date:Subject:To:From:Cc; b=gMHioc8MePvpAfs8uJE0MK0GT5EOkh1wfN+OjtOidy08Pn3dmiPcu61v0RCim1Cnf lMGUV79++VKVn/tH80J1xU4xqxhklACtfx0c7nMO872QXWhk+Gwwg4Cn+KR1LP+jBU kj0IE0N6RotOC9FN99E4D8YWxwDPq7W5DodpNosY= Authentication-Results: mxbackcorp1j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru Received: from 95.108.174.193-red.dhcp.yndx.net (95.108.174.193-red.dhcp.yndx.net [95.108.174.193]) by sas2-62907d92d1d8.qloud-c.yandex.net (nwsmtp/Yandex) with ESMTPSA id q8PWovi3A9-3wV8jBkp; Thu, 31 Oct 2019 14:03:58 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) From: Dmitry Monakhov To: linux-fsdevel@vger.kernel.org Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, jack@suse.cz, tytso@mit.edu, lixi@ddn.com, Dmitry Monakhov , Konstantin Khlebnikov Subject: [PATCH] fs/ext4: get project quota from inode for mangling statfs results Date: Thu, 31 Oct 2019 11:03:48 +0000 Message-Id: <20191031110348.6991-1-dmonakhov@openvz.org> X-Mailer: git-send-email 2.18.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Dmitry Monakhov Right now ext4_statfs_project() does quota lookup by id every time. This is costly operation, especially if there is no inode who hold reference to this dquot. This means that each statfs performs useless ext4_acquire_dquot()/ext4_release_dquot() which serialized on __jbd2_log_wait_for_space() dqget() ->ext4_acquire_dquot -> ext4_journal_start -> __jbd2_log_wait_for_space dqput() -> ext4_release_dquot ->ext4_journal_start ->__jbd2_log_wait_for_space Function ext4_statfs_project() could be moved into generic quota code, it is required for every filesystem which uses generic project quota. Reported-by: Dmitry Monakhov Signed-off-by: Konstantin Khlebnikov --- fs/ext4/super.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 2318e5f..4e8f97d68 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5532,18 +5532,23 @@ static int ext4_remount(struct super_block *sb, int *flags, char *data) } #ifdef CONFIG_QUOTA -static int ext4_statfs_project(struct super_block *sb, - kprojid_t projid, struct kstatfs *buf) +static int ext4_statfs_project(struct inode *inode, struct kstatfs *buf) { - struct kqid qid; + struct super_block *sb = inode->i_sb; struct dquot *dquot; u64 limit; u64 curblock; + int err; + + err = dquot_initialize(inode); + if (err) + return err; + + spin_lock(&inode->i_lock); + dquot = ext4_get_dquots(inode)[PRJQUOTA]; + if (!dquot) + goto out_unlock; - qid = make_kqid_projid(projid); - dquot = dqget(sb, qid); - if (IS_ERR(dquot)) - return PTR_ERR(dquot); spin_lock(&dquot->dq_dqb_lock); limit = (dquot->dq_dqb.dqb_bsoftlimit ? @@ -5569,7 +5574,9 @@ static int ext4_statfs_project(struct super_block *sb, } spin_unlock(&dquot->dq_dqb_lock); - dqput(dquot); +out_unlock: + spin_unlock(&inode->i_lock); + return 0; } #endif @@ -5609,7 +5616,7 @@ static int ext4_statfs(struct dentry *dentry, struct kstatfs *buf) #ifdef CONFIG_QUOTA if (ext4_test_inode_flag(dentry->d_inode, EXT4_INODE_PROJINHERIT) && sb_has_quota_limits_enabled(sb, PRJQUOTA)) - ext4_statfs_project(sb, EXT4_I(dentry->d_inode)->i_projid, buf); + ext4_statfs_project(dentry->d_inode, buf); #endif return 0; } -- 2.7.4