From patchwork Tue Jan 1 02:20:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10745689 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 91FD91822 for ; Tue, 1 Jan 2019 02:20:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8456F28824 for ; Tue, 1 Jan 2019 02:20:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7891228C9E; Tue, 1 Jan 2019 02:20:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B85B28C9D for ; Tue, 1 Jan 2019 02:20:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728253AbfAACUT (ORCPT ); Mon, 31 Dec 2018 21:20:19 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:43438 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728189AbfAACUT (ORCPT ); Mon, 31 Dec 2018 21:20:19 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x012EBvI018775 for ; Tue, 1 Jan 2019 02:20:18 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-2018-07-02; bh=u0uCu91ClWyOWO9T3wa1UkvIJ84MRIQxaOGlFB/onDA=; b=2TyIJKyGaOo03XszsnoACkw4vGGNXHowgOb0Lt3lfr+0npsiztZ5MZjEXqsNQT+L0n33 mlyLS7/Io+pRdVaRVKM6bFbI0msU0QBwYQXZeslLitiwv11wquacHFqzzWGyPMCryw6K O0RTECK2PXoUvCdgMVV+aGwey/V1v9TKPmyrSOKTvDQJMva/78ua3WiiOCSYj8OfSt4h s+7k7ckh41UontUO1VK+znI1K0X4HeyD1ofmUcvOD3BHRh9jCOkMg7I6LJglRtnL0GCh F8R06Q2/QAveJlLKVOImpl6ZreLjb1cW2Ad/myhfSN1jEFnhCUBekIhJUmpPaArot8Tr Hw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2pp0btp79n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 01 Jan 2019 02:20:18 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x012KCxj026015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 1 Jan 2019 02:20:12 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x012KCis001780 for ; Tue, 1 Jan 2019 02:20:12 GMT Received: from localhost (/10.159.150.85) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 31 Dec 2018 18:20:12 -0800 Subject: [PATCH 11/22] xfs: refactor special inode roll out of xfs_dir_ialloc From: "Darrick J. Wong" To: darrick.wong@oracle.com Cc: linux-xfs@vger.kernel.org Date: Mon, 31 Dec 2018 18:20:10 -0800 Message-ID: <154630921076.18437.14193766050551378677.stgit@magnolia> In-Reply-To: <154630914104.18437.15354380637179830566.stgit@magnolia> References: <154630914104.18437.15354380637179830566.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9123 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901010019 Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong In xfs_dir_ialloc, we roll the transaction if we had to allocate a new inode chunk and before we actually initialize the inode. In the kernel this requires us to detach the transaction's quota charge information from the ichunk allocation transaction and to attach it the ialloc transaction because we don't charge quota for inode chunks. This doesn't exist in the userspace side of things, so pop it out into a separately called function. Signed-off-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_inode_util.h | 6 ++++ fs/xfs/xfs_inode.c | 66 ++++++++++++++++++++++++---------------- 2 files changed, 46 insertions(+), 26 deletions(-) diff --git a/fs/xfs/libxfs/xfs_inode_util.h b/fs/xfs/libxfs/xfs_inode_util.h index 5a1d98d1546d..ee274d74b8d4 100644 --- a/fs/xfs/libxfs/xfs_inode_util.h +++ b/fs/xfs/libxfs/xfs_inode_util.h @@ -82,6 +82,12 @@ struct xfs_ialloc_ops { /* Do any final setup needed before we return the inode. */ void (*setup)(struct xfs_inode *ip); + + /* + * Roll the transaction between allocating a new ichunk and + * initializing a new inode core. + */ + int (*ichunk_roll)(struct xfs_trans **tpp); }; /* The libxfs client must provide this symbol. */ diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c index e6fda8777fe1..82de92bc84b9 100644 --- a/fs/xfs/xfs_inode.c +++ b/fs/xfs/xfs_inode.c @@ -647,10 +647,49 @@ xfs_ialloc_platform_init( VFS_I(ip)->i_ctime = tv; } +/* + * Roll the transaction after allocating an inode chunk and before allocating + * the actual inode, moving the quota charge information to the second + * transaction. + */ +static int +xfs_dir_ialloc_roll( + struct xfs_trans **tpp) +{ + struct xfs_dquot_acct *dqinfo = NULL; + unsigned int tflags = 0; + int error; + + /* + * We want the quota changes to be associated with the next + * transaction, NOT this one. So, detach the dqinfo from this + * and attach it to the next transaction. + */ + if ((*tpp)->t_dqinfo) { + dqinfo = (*tpp)->t_dqinfo; + (*tpp)->t_dqinfo = NULL; + tflags = (*tpp)->t_flags & XFS_TRANS_DQ_DIRTY; + (*tpp)->t_flags &= ~(XFS_TRANS_DQ_DIRTY); + } + + error = xfs_trans_roll(tpp); + + /* + * Re-attach the quota info that we detached from prev trx. + */ + if (dqinfo) { + (*tpp)->t_dqinfo = dqinfo; + (*tpp)->t_flags |= tflags; + } + + return error; +} + const struct xfs_ialloc_ops xfs_default_ialloc_ops = { .iget = xfs_ialloc_iget, .platform_init = xfs_ialloc_platform_init, .setup = xfs_setup_inode, + .ichunk_roll = xfs_dir_ialloc_roll, }; /* @@ -672,8 +711,6 @@ xfs_dir_ialloc( struct xfs_trans *tp; struct xfs_inode *ip; struct xfs_buf *ialloc_context = NULL; - void *dqinfo; - uint tflags; int code; tp = *tpp; @@ -726,30 +763,7 @@ xfs_dir_ialloc( */ xfs_trans_bhold(tp, ialloc_context); - /* - * We want the quota changes to be associated with the next - * transaction, NOT this one. So, detach the dqinfo from this - * 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); - - /* - * Re-attach the quota info that we detached from prev trx. - */ - if (dqinfo) { - tp->t_dqinfo = dqinfo; - tp->t_flags |= tflags; - } - + code = args->ops->ichunk_roll(&tp); if (code) { xfs_buf_relse(ialloc_context); *tpp = tp;