From patchwork Sat Sep 26 13:14:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixu Xia X-Patchwork-Id: 11801435 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 144EF112E for ; Sat, 26 Sep 2020 13:14:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA6D5206FC for ; Sat, 26 Sep 2020 13:14:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="H9lcqYn4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726305AbgIZNOl (ORCPT ); Sat, 26 Sep 2020 09:14:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbgIZNOl (ORCPT ); Sat, 26 Sep 2020 09:14:41 -0400 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57095C0613CE for ; Sat, 26 Sep 2020 06:14:41 -0700 (PDT) Received: by mail-pf1-x443.google.com with SMTP id k13so5636818pfg.1 for ; Sat, 26 Sep 2020 06:14:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eMEw8aj1+EZZQz39IsZVFuuk1cuV37KYytSO8uCLZCw=; b=H9lcqYn4Q6SSjAQ+YmKcNHipiGskt9HswBP0IZu53MkXcWWdMkCZFF00jMgp/+tZ9B GBWPHcfEfGleoUmyYrx1KQ1Vig0Vl1e3pDQDTJT2SFYb1/QN3WJJ/OWOe0ozJpSYcC5m 22F2+4i2cDay/YAM8/HJ5ZxG1IJT57ySwODShjV4Esegw2St7rjOUqxpl1Ze8n3OP3f3 yGy8iUTHnEDznVe6WoCgT2iJxVXjdxiSQ0yLxn30GM++7ZVR03qbuGSOVh38n8RZQo7P Hrxo4Vhgvr+3A4ykjToh87ZuyHyK1kRUFnN2f6h/yd0adzPF8uB71GYU4TimtHlbLhTg OYZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eMEw8aj1+EZZQz39IsZVFuuk1cuV37KYytSO8uCLZCw=; b=hO7Ggvh4LGxk3NC+TGvAzBkwKDTQIza7VPdi+aYeUNuO2JUSCpGR8PjgNTwL8ZIfXD oZFT0WGqDD1KARUoXaE98IohMuH0C4fhiNEu/fEYZu2Q2vZJOYhUwBdWpepCoK215Xvg Kzy+devJwLjk74NVQHPUSot7QBLKnuS1aMgw1LHwYZU39bn0IG7J2UDo++6krPJsp4H7 u9FO1jKGCxSh6OHRlKWf6T+aWPBA9XoMcG3whVz+kaW/NWR9CVeIlYPbLs+EmTbDJPQD XZWOdF+UF6P8zvRA4kFYcOwqJ5lVmbFpHg9rLounHOgGeu60IDzxMbYlGdJUnn15vT5q bBmg== X-Gm-Message-State: AOAM5323ASCnojJiHbXcfxP3Y4maziQDmLuGVQwzUsI1+3VkVc/9Ysej WBuGClsamzOnX26aWr2BEzUQunx4/w== X-Google-Smtp-Source: ABdhPJwsdYFcWPc/Loj8kjnwaQGITPnNYc3IfWkla3OBGTOP5fiwilfgal6TQXp0NQJMEcaBufAoew== X-Received: by 2002:a62:7b94:0:b029:142:2501:35e4 with SMTP id w142-20020a627b940000b0290142250135e4mr3656982pfc.68.1601126080541; Sat, 26 Sep 2020 06:14:40 -0700 (PDT) Received: from he-cluster.localdomain (67.216.221.250.16clouds.com. [67.216.221.250]) by smtp.gmail.com with ESMTPSA id h12sm5623846pfo.68.2020.09.26.06.14.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Sep 2020 06:14:39 -0700 (PDT) From: xiakaixu1987@gmail.com X-Google-Original-From: kaixuxia@tencent.com To: linux-xfs@vger.kernel.org Cc: darrick.wong@oracle.com, Kaixu Xia Subject: [PATCH v2 1/4] xfs: do the ASSERT for the arguments O_{u,g,p}dqpp Date: Sat, 26 Sep 2020 21:14:30 +0800 Message-Id: <1601126073-32453-2-git-send-email-kaixuxia@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1601126073-32453-1-git-send-email-kaixuxia@tencent.com> References: <1601126073-32453-1-git-send-email-kaixuxia@tencent.com> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Kaixu Xia If we pass in XFS_QMOPT_{U,G,P}QUOTA flags and different uid/gid/prid than them currently associated with the inode, the arguments O_{u,g,p}dqpp shouldn't be NULL, so add the ASSERT for them. Signed-off-by: Kaixu Xia Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_qm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c index 44509decb4cd..b2a9abee8b2b 100644 --- a/fs/xfs/xfs_qm.c +++ b/fs/xfs/xfs_qm.c @@ -1662,6 +1662,7 @@ xfs_qm_vop_dqalloc( } if ((flags & XFS_QMOPT_UQUOTA) && XFS_IS_UQUOTA_ON(mp)) { + ASSERT(O_udqpp); if (!uid_eq(inode->i_uid, uid)) { /* * What we need is the dquot that has this uid, and @@ -1695,6 +1696,7 @@ xfs_qm_vop_dqalloc( } } if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) { + ASSERT(O_gdqpp); if (!gid_eq(inode->i_gid, gid)) { xfs_iunlock(ip, lockflags); error = xfs_qm_dqget(mp, from_kgid(user_ns, gid), @@ -1712,6 +1714,7 @@ xfs_qm_vop_dqalloc( } } if ((flags & XFS_QMOPT_PQUOTA) && XFS_IS_PQUOTA_ON(mp)) { + ASSERT(O_pdqpp); if (ip->i_d.di_projid != prid) { xfs_iunlock(ip, lockflags); error = xfs_qm_dqget(mp, prid, From patchwork Sat Sep 26 13:14:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixu Xia X-Patchwork-Id: 11801437 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 19FC5112E for ; Sat, 26 Sep 2020 13:14:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3019221ED for ; Sat, 26 Sep 2020 13:14:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fhGLGtaK" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728504AbgIZNOm (ORCPT ); Sat, 26 Sep 2020 09:14:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbgIZNOm (ORCPT ); Sat, 26 Sep 2020 09:14:42 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5DF2FC0613CE for ; Sat, 26 Sep 2020 06:14:42 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id d19so858746pld.0 for ; Sat, 26 Sep 2020 06:14:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lztcMcUrUT/A5IBGuQdOsap/0bbfc8yh28EwhZCb9xk=; b=fhGLGtaKpd4Ox+fMicXr2OKN9rR6fcEow9A+xD2tDuDzxzQcaHAl0zoo5ElgKL6Gtg aeKoSlE5qn8b5PbgeDPvpQcj6cQL9e0sW8VaGdet8CJUOKg+WhuQVtPH/fgJCdef86mV azs/TTbkPnNgTJa3kHGWbNNDAmtk4ultkK+xDz5meU5CBbg1WaE4CL3aEFczJgX9j4Ud Y4qqVyTW/yVliennYynkQnRHj1y8t75H84WuV9kBk6le7Asq5kVggBDo+3Vc6Y/tD5e8 l9TKIGU1kKLDI3rCWoRve1wkfH+lNvNsbqYUkTtKli0ZXg09F82+ZPSJPiG2WYfDAxWD meOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lztcMcUrUT/A5IBGuQdOsap/0bbfc8yh28EwhZCb9xk=; b=RTzpUEjKMNbSeCVi/ytIAYr6jFA0D1dPuI4xWfATVGCVjzMfjJ4hdgPvXzMOSEjcaP +5RUUkAQsdwdrkARUY7P63Bar8iRBjgZk/Dmr65Nvw7AN7nAnOr777JD2h2xdS/E+zMC pbT0QlQNlkbmtH9CTspo6nLsK3Boy8aAvUaWLzrd5iN6cL3sYYEaCGWJxs8X/MSRGj+2 dFBvdZXcfD5vKgOBVC7MvnOsZqZD8dvUzpve+CWBcn9eJDhwgI+DVRoy1cQvskVl9U7j 7jkGCk8JVADPW2jUPug0f7I45xFTo4icSpfCJUaLt00TPaL6luU1CV9NSZbrr9Lg1FEp 8U6Q== X-Gm-Message-State: AOAM530zaqp4OjjbMZTPiDWvivY/yIQgLXzvOQSsWOd2nEmO9pXn5lU9 Pl5/y4UunKjDIeefF27bUmAUt5G7oQ== X-Google-Smtp-Source: ABdhPJwTNibMxDglALmLGT36hDevAy/8nhdypLFq891MfCphdyClbugtrh1nCbhi49+epsTF7F0X/g== X-Received: by 2002:a17:90a:ea09:: with SMTP id w9mr1906871pjy.203.1601126081654; Sat, 26 Sep 2020 06:14:41 -0700 (PDT) Received: from he-cluster.localdomain (67.216.221.250.16clouds.com. [67.216.221.250]) by smtp.gmail.com with ESMTPSA id h12sm5623846pfo.68.2020.09.26.06.14.40 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Sep 2020 06:14:40 -0700 (PDT) From: xiakaixu1987@gmail.com X-Google-Original-From: kaixuxia@tencent.com To: linux-xfs@vger.kernel.org Cc: darrick.wong@oracle.com, Kaixu Xia Subject: [PATCH v2 2/4] xfs: fix the indent in xfs_trans_mod_dquot Date: Sat, 26 Sep 2020 21:14:31 +0800 Message-Id: <1601126073-32453-3-git-send-email-kaixuxia@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1601126073-32453-1-git-send-email-kaixuxia@tencent.com> References: <1601126073-32453-1-git-send-email-kaixuxia@tencent.com> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Kaixu Xia The formatting is strange in xfs_trans_mod_dquot, so do a reindent. Signed-off-by: Kaixu Xia Reviewed-by: Darrick J. Wong --- fs/xfs/xfs_trans_dquot.c | 43 ++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index 133fc6fc3edd..fe45b0c3970c 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -221,36 +221,27 @@ xfs_trans_mod_dquot( } switch (field) { - - /* - * regular disk blk reservation - */ - case XFS_TRANS_DQ_RES_BLKS: + /* regular disk blk reservation */ + case XFS_TRANS_DQ_RES_BLKS: qtrx->qt_blk_res += delta; break; - /* - * inode reservation - */ - case XFS_TRANS_DQ_RES_INOS: + /* inode reservation */ + case XFS_TRANS_DQ_RES_INOS: qtrx->qt_ino_res += delta; break; - /* - * disk blocks used. - */ - case XFS_TRANS_DQ_BCOUNT: + /* disk blocks used. */ + case XFS_TRANS_DQ_BCOUNT: qtrx->qt_bcount_delta += delta; break; - case XFS_TRANS_DQ_DELBCOUNT: + case XFS_TRANS_DQ_DELBCOUNT: qtrx->qt_delbcnt_delta += delta; break; - /* - * Inode Count - */ - case XFS_TRANS_DQ_ICOUNT: + /* Inode Count */ + case XFS_TRANS_DQ_ICOUNT: if (qtrx->qt_ino_res && delta > 0) { qtrx->qt_ino_res_used += delta; ASSERT(qtrx->qt_ino_res >= qtrx->qt_ino_res_used); @@ -258,17 +249,13 @@ xfs_trans_mod_dquot( qtrx->qt_icount_delta += delta; break; - /* - * rtblk reservation - */ - case XFS_TRANS_DQ_RES_RTBLKS: + /* rtblk reservation */ + case XFS_TRANS_DQ_RES_RTBLKS: qtrx->qt_rtblk_res += delta; break; - /* - * rtblk count - */ - case XFS_TRANS_DQ_RTBCOUNT: + /* rtblk count */ + case XFS_TRANS_DQ_RTBCOUNT: if (qtrx->qt_rtblk_res && delta > 0) { qtrx->qt_rtblk_res_used += delta; ASSERT(qtrx->qt_rtblk_res >= qtrx->qt_rtblk_res_used); @@ -276,11 +263,11 @@ xfs_trans_mod_dquot( qtrx->qt_rtbcount_delta += delta; break; - case XFS_TRANS_DQ_DELRTBCOUNT: + case XFS_TRANS_DQ_DELRTBCOUNT: qtrx->qt_delrtb_delta += delta; break; - default: + default: ASSERT(0); } From patchwork Sat Sep 26 13:14:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixu Xia X-Patchwork-Id: 11801439 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 48C75139F for ; Sat, 26 Sep 2020 13:14:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D3F3221ED for ; Sat, 26 Sep 2020 13:14:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cbROmBjQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728459AbgIZNOn (ORCPT ); Sat, 26 Sep 2020 09:14:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbgIZNOn (ORCPT ); Sat, 26 Sep 2020 09:14:43 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7625FC0613CE for ; Sat, 26 Sep 2020 06:14:43 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id e18so1054447pgd.4 for ; Sat, 26 Sep 2020 06:14:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KxcKg3VySvM8efbu+IA8UFaZWWcbttZAkakShYT41Uc=; b=cbROmBjQij0cQ2HXFAdbz33Bb3Ox0FwXuivkZ9IrVthSgaR77VxCagNG1UDgmvi6Kb metdYwMsZXDgB+6i4NiQy+jp7xH4tV7vZcTrwhwuqxKPOOWOmkja4otwumZs1/Ui/HpR XNs/t/3LyFCFEArIxq+x1TQr6C5qJSrOWLz/Y3apqCu/OTQBB2x9O3Mi+C3oA7qVmEvo ZGDU1zzR9T+isOhPNYxojLIdDEm7Z9Htc4In8BbwJ6Z7ZIkORHwnxv+ByejxAJg3Eoqu LrhmhlOL2z/SiBn6wmZPWyTIsEZSern5BUhwtRM8xfl3yXUvonxBocm4ZSH2zEq0fdWl idPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KxcKg3VySvM8efbu+IA8UFaZWWcbttZAkakShYT41Uc=; b=flr79U/06juyUR3mTiliwq/Col7OGbVHBVqgex0FhPwCkqP2JNbq0vT+PrtflfxNKV 4KwXQYmqt5noQF4OveOhT2rSQS/tyB45JfB7UAlcHt7eW2s3Tth1/QfgUtR8OrsePjRR SmJs6TdkHqNLrTF+73Mw9vK/M60WLi6pWPN2y/A8gGgF1zfIZZ7MNyBLFn1q3gstb27Y Z22Jz0ioAq67vA+zuGH5aLI+2iH25XiCC90exyYXl3Vt6Qh51lpiQUYGeGLj7Yb3xPqi PJkgCQ4O7RV/isuwDrXaBaUELR1t/qQE08tlZStYCO4FFhRckpYJmEQeEUXKet+VuSZq qM+A== X-Gm-Message-State: AOAM533SDr4nsmpZiMXMmlkFuH8aWoxUW0eMbK4muqxuoTa01xwC+DLf /mLXUiiFi/vgGZJ43+xccIYwBpuCyQ== X-Google-Smtp-Source: ABdhPJxlbaN/g2g28p062ehbQfjGPq81ILV7ou9R45MLzTgm60gNVm7v6mRSfxmJrT6bjmi8KNsQHg== X-Received: by 2002:a62:b40c:0:b029:142:6a8f:c2f8 with SMTP id h12-20020a62b40c0000b02901426a8fc2f8mr3021494pfn.32.1601126082649; Sat, 26 Sep 2020 06:14:42 -0700 (PDT) Received: from he-cluster.localdomain (67.216.221.250.16clouds.com. [67.216.221.250]) by smtp.gmail.com with ESMTPSA id h12sm5623846pfo.68.2020.09.26.06.14.41 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Sep 2020 06:14:42 -0700 (PDT) From: xiakaixu1987@gmail.com X-Google-Original-From: kaixuxia@tencent.com To: linux-xfs@vger.kernel.org Cc: darrick.wong@oracle.com, Kaixu Xia Subject: [PATCH v2 3/4] xfs: check tp->t_dqinfo value instead of the XFS_TRANS_DQ_DIRTY flag Date: Sat, 26 Sep 2020 21:14:32 +0800 Message-Id: <1601126073-32453-4-git-send-email-kaixuxia@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1601126073-32453-1-git-send-email-kaixuxia@tencent.com> References: <1601126073-32453-1-git-send-email-kaixuxia@tencent.com> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Kaixu Xia Nowadays the only things that the XFS_TRANS_DQ_DIRTY flag seems to do are indicates the tp->t_dqinfo->dqs[XFS_QM_TRANS_{USR,GRP,PRJ}] values changed and check in xfs_trans_apply_dquot_deltas() and the unreserve variant xfs_trans_unreserve_and_mod_dquots(). Actually, we also can use the tp->t_dqinfo value instead of the XFS_TRANS_DQ_DIRTY flag, that is to say, we allocate the new tp->t_dqinfo only when the qtrx values changed, so the tp->t_dqinfo value isn't NULL equals the XFS_TRANS_DQ_DIRTY flag is set, we only need to check if tp->t_dqinfo == NULL in xfs_trans_apply_dquot_deltas() and its unreserve variant to determine whether lock all of the dquots and join them to the transaction. Signed-off-by: Kaixu Xia --- fs/xfs/libxfs/xfs_shared.h | 1 - fs/xfs/xfs_inode.c | 8 +------- fs/xfs/xfs_trans_dquot.c | 20 ++------------------ 3 files changed, 3 insertions(+), 26 deletions(-) diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h index c795ae47b3c9..8c61a461bf7b 100644 --- a/fs/xfs/libxfs/xfs_shared.h +++ b/fs/xfs/libxfs/xfs_shared.h @@ -62,7 +62,6 @@ void xfs_log_get_max_trans_res(struct xfs_mount *mp, #define XFS_TRANS_SB_DIRTY 0x02 /* superblock is modified */ #define XFS_TRANS_PERM_LOG_RES 0x04 /* xact took a permanent log res */ #define XFS_TRANS_SYNC 0x08 /* make commit synchronous */ -#define XFS_TRANS_DQ_DIRTY 0x10 /* at least one dquot in trx dirty */ #define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */ #define XFS_TRANS_NO_WRITECOUNT 0x40 /* do not elevate SB writecount */ #define XFS_TRANS_RES_FDBLKS 0x80 /* reserve newly freed blocks */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index 49624973eecc..9108eed0ea45 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -941,7 +941,6 @@ xfs_dir_ialloc( xfs_buf_t *ialloc_context = NULL; int code; void *dqinfo; - uint tflags; tp = *tpp; ASSERT(tp->t_flags & XFS_TRANS_PERM_LOG_RES); @@ -1000,12 +999,9 @@ xfs_dir_ialloc( * and attach it to the next transaction. */ dqinfo = NULL; - tflags = 0; if (tp->t_dqinfo) { dqinfo = (void *)tp->t_dqinfo; tp->t_dqinfo = NULL; - tflags = tp->t_flags & XFS_TRANS_DQ_DIRTY; - tp->t_flags &= ~(XFS_TRANS_DQ_DIRTY); } code = xfs_trans_roll(&tp); @@ -1013,10 +1009,8 @@ xfs_dir_ialloc( /* * Re-attach the quota info that we detached from prev trx. */ - if (dqinfo) { + if (dqinfo) tp->t_dqinfo = dqinfo; - tp->t_flags |= tflags; - } if (code) { xfs_buf_relse(ialloc_context); diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index fe45b0c3970c..0ebfd7930382 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -84,13 +84,6 @@ xfs_trans_dup_dqinfo( xfs_trans_alloc_dqinfo(ntp); - /* - * Because the quota blk reservation is carried forward, - * it is also necessary to carry forward the DQ_DIRTY flag. - */ - if (otp->t_flags & XFS_TRANS_DQ_DIRTY) - ntp->t_flags |= XFS_TRANS_DQ_DIRTY; - for (j = 0; j < XFS_QM_TRANS_DQTYPES; j++) { oqa = otp->t_dqinfo->dqs[j]; nqa = ntp->t_dqinfo->dqs[j]; @@ -143,9 +136,6 @@ xfs_trans_mod_dquot_byino( xfs_is_quota_inode(&mp->m_sb, ip->i_ino)) return; - if (tp->t_dqinfo == NULL) - xfs_trans_alloc_dqinfo(tp); - if (XFS_IS_UQUOTA_ON(mp) && ip->i_udquot) (void) xfs_trans_mod_dquot(tp, ip->i_udquot, field, delta); if (XFS_IS_GQUOTA_ON(mp) && ip->i_gdquot) @@ -273,8 +263,6 @@ xfs_trans_mod_dquot( if (delta) trace_xfs_trans_mod_dquot_after(qtrx); - - tp->t_flags |= XFS_TRANS_DQ_DIRTY; } @@ -351,7 +339,7 @@ xfs_trans_apply_dquot_deltas( int64_t totalbdelta; int64_t totalrtbdelta; - if (!(tp->t_flags & XFS_TRANS_DQ_DIRTY)) + if (!tp->t_dqinfo) return; ASSERT(tp->t_dqinfo); @@ -493,7 +481,7 @@ xfs_trans_unreserve_and_mod_dquots( struct xfs_dqtrx *qtrx, *qa; bool locked; - if (!tp->t_dqinfo || !(tp->t_flags & XFS_TRANS_DQ_DIRTY)) + if (!tp->t_dqinfo) return; for (j = 0; j < XFS_QM_TRANS_DQTYPES; j++) { @@ -698,7 +686,6 @@ xfs_trans_dqresv( * because we don't have the luxury of a transaction envelope then. */ if (tp) { - ASSERT(tp->t_dqinfo); ASSERT(flags & XFS_QMOPT_RESBLK_MASK); if (nblks != 0) xfs_trans_mod_dquot(tp, dqp, @@ -752,9 +739,6 @@ xfs_trans_reserve_quota_bydquots( if (!XFS_IS_QUOTA_RUNNING(mp) || !XFS_IS_QUOTA_ON(mp)) return 0; - if (tp && tp->t_dqinfo == NULL) - xfs_trans_alloc_dqinfo(tp); - ASSERT(flags & XFS_QMOPT_RESBLK_MASK); if (udqp) { From patchwork Sat Sep 26 13:14:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kaixu Xia X-Patchwork-Id: 11801441 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 30D8D139F for ; Sat, 26 Sep 2020 13:14:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15F41221EA for ; Sat, 26 Sep 2020 13:14:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="t93uRqqI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728612AbgIZNOo (ORCPT ); Sat, 26 Sep 2020 09:14:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726183AbgIZNOo (ORCPT ); Sat, 26 Sep 2020 09:14:44 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C22FC0613CE for ; Sat, 26 Sep 2020 06:14:44 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id a9so965321pjg.1 for ; Sat, 26 Sep 2020 06:14:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=O5+4pxfm0rIlhTIAygdUSVKVo6uA95EQBJHjeRSVM6Q=; b=t93uRqqIHl8MK/04nceO+wcvNi7ikQeXBLo+32Mprfg8tzcwvAf2skK3A9ogMHBxNS 1MIJpreN+PIMJ8DRejNIVVRdCuduK28isLm1Htrt3TKEvhMQqQIGVJekIQOo2Moe7Hn/ yRohdJPkLmvbdU66t85lyHDL5TTw/6reFnbQp23FJ+IvCJbLuIaFIcUYgWBmePTTbK1Q 1v/9oa0Qz5nHTTrdnchf87ff5asZ+syjdu8SoDJ+5d/CreyclLEDjbAtNJlqsoJJm5I1 FDsr0/k/HD34FoDMRCl+8jJNpPaP1iNxvl4OC7tkAGiB9/Pf5dKBcNrLScink5O16G9S MFXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=O5+4pxfm0rIlhTIAygdUSVKVo6uA95EQBJHjeRSVM6Q=; b=bhnSgKvoqf4v53SRclFhTa6RibcV0HdrN0Lz0L/+wk+/0fZvU6INkui09stD6IeHGF gTz1hXCaUFXXaiF/zMURvfGcooYiBdGJbCKlyzUkAx78hpTZlZrWPdLiOcfcNur3PBLp MYpOTmM71VG2QUlDAHgoKSGzORjsFXMutFFScL4Sw+h49T83WyBDC14bWKA7tWWJ1Ops lA6ZUQvlK3Ql+aCJ8nRR3Aq3dQCpouXFFO8YAvzcUmgDgK0vxkn3/T1Khx8vqP0C0yBH /wwb7k1+Nete/NZxmNPpwAYxl1sE2nkuMQGFDYJQ5CWPJ0zkiiPlHgp5CfNUFiBhDbvp aDLQ== X-Gm-Message-State: AOAM5303bE5AzZLKFeD8LYNsi+SZCqDi6EdFAwHvstr+ht+SoeVcF1wI FzWbSsxnHFsgeFBnaNEVWlEFdM+Czw== X-Google-Smtp-Source: ABdhPJzCT5DKQJgzDFfz5LRF7d6vxEu/wVPaRiy8Nu6W46bZisYcY61m4EKm1cLOiwVcBem9anqGMA== X-Received: by 2002:a17:902:8494:b029:d2:63a3:5e87 with SMTP id c20-20020a1709028494b02900d263a35e87mr3818760plo.40.1601126083769; Sat, 26 Sep 2020 06:14:43 -0700 (PDT) Received: from he-cluster.localdomain (67.216.221.250.16clouds.com. [67.216.221.250]) by smtp.gmail.com with ESMTPSA id h12sm5623846pfo.68.2020.09.26.06.14.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Sep 2020 06:14:43 -0700 (PDT) From: xiakaixu1987@gmail.com X-Google-Original-From: kaixuxia@tencent.com To: linux-xfs@vger.kernel.org Cc: darrick.wong@oracle.com, Kaixu Xia Subject: [PATCH v2 4/4] xfs: directly return if the delta equal to zero Date: Sat, 26 Sep 2020 21:14:33 +0800 Message-Id: <1601126073-32453-5-git-send-email-kaixuxia@tencent.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1601126073-32453-1-git-send-email-kaixuxia@tencent.com> References: <1601126073-32453-1-git-send-email-kaixuxia@tencent.com> Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Kaixu Xia The xfs_trans_mod_dquot() function will allocate new tp->t_dqinfo if it is NULL and make the changes in the tp->t_dqinfo->dqs[XFS_QM_TRANS_{USR,GRP,PRJ}]. Nowadays seems none of the callers want to join the dquots to the transaction and push them to device when the delta is zero. Actually, most of time the caller would check the delta and go on only when the delta value is not zero, so we should bail out when it is zero. Signed-off-by: Kaixu Xia --- fs/xfs/xfs_trans_dquot.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index 0ebfd7930382..3e37501791bf 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -194,6 +194,9 @@ xfs_trans_mod_dquot( ASSERT(XFS_IS_QUOTA_RUNNING(tp->t_mountp)); qtrx = NULL; + if (!delta) + return; + if (tp->t_dqinfo == NULL) xfs_trans_alloc_dqinfo(tp); /* @@ -205,10 +208,8 @@ xfs_trans_mod_dquot( if (qtrx->qt_dquot == NULL) qtrx->qt_dquot = dqp; - if (delta) { - trace_xfs_trans_mod_dquot_before(qtrx); - trace_xfs_trans_mod_dquot(tp, dqp, field, delta); - } + trace_xfs_trans_mod_dquot_before(qtrx); + trace_xfs_trans_mod_dquot(tp, dqp, field, delta); switch (field) { /* regular disk blk reservation */ @@ -261,8 +262,7 @@ xfs_trans_mod_dquot( ASSERT(0); } - if (delta) - trace_xfs_trans_mod_dquot_after(qtrx); + trace_xfs_trans_mod_dquot_after(qtrx); }