From patchwork Sun Jul 5 22:12:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 11644739 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 9790913B4 for ; Sun, 5 Jul 2020 22:16:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F73A20760 for ; Sun, 5 Jul 2020 22:16:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="B5EeKYV5" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728211AbgGEWQ6 (ORCPT ); Sun, 5 Jul 2020 18:16:58 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:46804 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728103AbgGEWQ5 (ORCPT ); Sun, 5 Jul 2020 18:16:57 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 065MCQkM002047; Sun, 5 Jul 2020 22:14:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2020-01-29; bh=lidaS044Cc+NWc2qYUY7R7falR3heXv5JgnC281HlDk=; b=B5EeKYV5ua+3OA6m/mDLeGnODH7q4APyl+Q/tBVCa0PKoQbeNzlZpOu6KlZs/3U70VtP RGjX8hHQjgAWcD9tu13EdO37bAnmfMN7P0XVxezNfGVR5SrO33SUnFuFlF0S70dJ596K ghw1AjFmTc62jDvD+1xQgdrEmfHKARqVyOkjzC095pzg4tcD0ejTHG/Y8etB7oYZVp8G Z5MCWdiAwaxCl5LLVQu/CZSG8YNB8RDFiYdUCJyCSs8iknhukY8KKXKimEuQ+iu4z9Tj fFXu8M0imsILGSSDNP3YKKSmOmGxbJO0pIjaZ/leqEBYoQgeezej+mi3kbsUyu6ntTdU Dg== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 322h6r3j52-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Sun, 05 Jul 2020 22:14:54 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 065MCrH4102712; Sun, 5 Jul 2020 22:12:53 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userp3020.oracle.com with ESMTP id 3233hqbqwj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 05 Jul 2020 22:12:53 +0000 Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 065MCnuP008829; Sun, 5 Jul 2020 22:12:49 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 05 Jul 2020 15:12:48 -0700 Subject: [PATCH 02/22] xfs: fix inode quota reservation checks From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: Allison Collins , Chandan Babu R , Christoph Hellwig , linux-xfs@vger.kernel.org Date: Sun, 05 Jul 2020 15:12:46 -0700 Message-ID: <159398716693.425236.15439173124100012153.stgit@magnolia> In-Reply-To: <159398715269.425236.15910213189856396341.stgit@magnolia> References: <159398715269.425236.15910213189856396341.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9673 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 phishscore=0 bulkscore=0 malwarescore=0 spamscore=0 suspectscore=1 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007050172 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9673 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 lowpriorityscore=0 suspectscore=1 adultscore=0 mlxscore=0 spamscore=0 impostorscore=0 cotscore=-2147483648 malwarescore=0 mlxlogscore=999 clxscore=1015 bulkscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2007050172 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong xfs_trans_dqresv is the function that we use to make reservations against resource quotas. Each resource contains two counters: the q_core counter, which tracks resources allocated on disk; and the dquot reservation counter, which tracks how much of that resource has either been allocated or reserved by threads that are working on metadata updates. For disk blocks, we compare the proposed reservation counter against the hard and soft limits to decide if we're going to fail the operation. However, for inodes we inexplicably compare against the q_core counter, not the incore reservation count. Since the q_core counter is always lower than the reservation count and we unlock the dquot between reservation and transaction commit, this means that multiple threads can reserve the last inode count before we hit the hard limit, and when they commit, we'll be well over the hard limit. Fix this by checking against the incore inode reservation counter, since we would appear to maintain that correctly (and that's what we report in GETQUOTA). Signed-off-by: Darrick J. Wong Reviewed-by: Allison Collins Reviewed-by: Chandan Babu R Reviewed-by: Christoph Hellwig --- fs/xfs/xfs_trans_dquot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/xfs/xfs_trans_dquot.c b/fs/xfs/xfs_trans_dquot.c index c0f73b82c055..ed0ce8b301b4 100644 --- a/fs/xfs/xfs_trans_dquot.c +++ b/fs/xfs/xfs_trans_dquot.c @@ -647,7 +647,7 @@ xfs_trans_dqresv( } } if (ninos > 0) { - total_count = be64_to_cpu(dqp->q_core.d_icount) + ninos; + total_count = dqp->q_res_icount + ninos; timer = be32_to_cpu(dqp->q_core.d_itimer); warns = be16_to_cpu(dqp->q_core.d_iwarns); warnlimit = defq->iwarnlimit;