From patchwork Tue Apr 11 11:10:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 9674949 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CDCAC600CB for ; Tue, 11 Apr 2017 11:10:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B78D4284F4 for ; Tue, 11 Apr 2017 11:10:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC77A2851F; Tue, 11 Apr 2017 11:10:38 +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=-5.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_WEB, T_DKIM_INVALID 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 44024284F4 for ; Tue, 11 Apr 2017 11:10:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752719AbdDKLKh (ORCPT ); Tue, 11 Apr 2017 07:10:37 -0400 Received: from bombadil.infradead.org ([65.50.211.133]:55635 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752069AbdDKLKh (ORCPT ); Tue, 11 Apr 2017 07:10:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:To:From:Sender:Reply-To:Cc:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3j6OG3xi7tlYSbRqTiRPjME4T3nIUdspqQTkQVwdfnc=; b=d0Ig9wuyoCoFOXT355qlkWKyp OKSeEO2WSeR4K0JcDLTvV3k/WEFyefccHXcJ51fjSx10aPXHMzRb1g2Rr++GcRpZHIoWvqgcRTIvf mBXxnO5WN8lAplI8WQbPOavn0zdVi4aR3o6kByX6hHTTuxs/n56pWNxdRsj41Jfva6cDwSYX4WCl7 I89U4TX1vpsncjnvNSSsUYaOAAvR0vF3POmVB1CuHPhbU+5hqeIouhcBKau9ITjtTeWWeMDtAqVAs BOxITxYC4o78vX2EBJ6OXHa4iyTjlZrB5ShXsx2wORZnwAkZsexhWLz+xxgxZDj2u1mbTTeL/Rf0P 54r+c/fkQ==; Received: from 212095007090.public.telering.at ([212.95.7.90] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.87 #1 (Red Hat Linux)) id 1cxtgy-0004pd-7v for linux-xfs@vger.kernel.org; Tue, 11 Apr 2017 11:10:36 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Subject: [PATCH 5/6] xfs: remove xfs_bmap_remap_alloc Date: Tue, 11 Apr 2017 13:10:10 +0200 Message-Id: <20170411111011.9437-6-hch@lst.de> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170411111011.9437-1-hch@lst.de> References: <20170411111011.9437-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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 The main thing that xfs_bmap_remap_alloc does is fixing the AGFL, similar to what we do in the space allocator. But the reflink code doesn't touch the allocation btree unlike the normal space allocator, so we couldn't care less about the state of the AGFL. So remove xfs_bmap_remap_alloc and just handle the di_nblocks update in the caller. Signed-off-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- fs/xfs/libxfs/xfs_bmap.c | 60 ++---------------------------------------------- fs/xfs/xfs_trace.h | 25 -------------------- 2 files changed, 2 insertions(+), 83 deletions(-) diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index faf7cb0a28f9..414cfa91af01 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c @@ -3856,61 +3856,6 @@ xfs_bmap_btalloc( } /* - * For a remap operation, just "allocate" an extent at the address that the - * caller passed in, and ensure that the AGFL is the right size. The caller - * will then map the "allocated" extent into the file somewhere. - */ -STATIC int -xfs_bmap_remap_alloc( - struct xfs_trans *tp, - struct xfs_inode *ip, - xfs_fsblock_t startblock, - xfs_extlen_t length) -{ - struct xfs_mount *mp = tp->t_mountp; - struct xfs_alloc_arg args; - int error; - - /* - * validate that the block number is legal - the enables us to detect - * and handle a silent filesystem corruption rather than crashing. - */ - memset(&args, 0, sizeof(struct xfs_alloc_arg)); - args.tp = tp; - args.mp = mp; - args.agno = XFS_FSB_TO_AGNO(mp, startblock); - args.agbno = XFS_FSB_TO_AGBNO(mp, startblock); - - if (args.agno >= mp->m_sb.sb_agcount || - args.agbno >= mp->m_sb.sb_agblocks) - return -EFSCORRUPTED; - - /* "Allocate" the extent from the range we passed in. */ - trace_xfs_bmap_remap_alloc(ip, startblock, length); - - ip->i_d.di_nblocks += length; - xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); - - /* Fix the freelist, like a real allocator does. */ - args.datatype = XFS_ALLOC_USERDATA | XFS_ALLOC_NOBUSY; - args.pag = xfs_perag_get(mp, args.agno); - ASSERT(args.pag); - - /* - * The freelist fixing code will decline the allocation if - * the size and shape of the free space doesn't allow for - * allocating the extent and updating all the metadata that - * happens during an allocation. We're remapping, not - * allocating, so skip that check by pretending to be freeing. - */ - error = xfs_alloc_fix_freelist(&args, XFS_ALLOC_FLAG_FREEING); - xfs_perag_put(args.pag); - if (error) - trace_xfs_bmap_remap_alloc_error(ip, error, _RET_IP_); - return error; -} - -/* * xfs_bmap_alloc is called by xfs_bmapi to allocate an extent for a file. * It figures out where to ask the underlying allocator to put the new extent. */ @@ -4806,9 +4751,8 @@ xfs_bmapi_remap( ASSERT(got.br_startoff - bno >= len); } - error = xfs_bmap_remap_alloc(tp, ip, startblock, len); - if (error) - goto error0; + ip->i_d.di_nblocks += len; + xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE); if (ifp->if_flags & XFS_IFBROOT) { cur = xfs_bmbt_init_cursor(mp, tp, ip, XFS_DATA_FORK); diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 4f96dc953fbe..cba10daf8391 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h @@ -3003,31 +3003,6 @@ DEFINE_EVENT(xfs_inode_error_class, name, \ unsigned long caller_ip), \ TP_ARGS(ip, error, caller_ip)) -/* reflink allocator */ -TRACE_EVENT(xfs_bmap_remap_alloc, - TP_PROTO(struct xfs_inode *ip, xfs_fsblock_t fsbno, - xfs_extlen_t len), - TP_ARGS(ip, fsbno, len), - TP_STRUCT__entry( - __field(dev_t, dev) - __field(xfs_ino_t, ino) - __field(xfs_fsblock_t, fsbno) - __field(xfs_extlen_t, len) - ), - TP_fast_assign( - __entry->dev = VFS_I(ip)->i_sb->s_dev; - __entry->ino = ip->i_ino; - __entry->fsbno = fsbno; - __entry->len = len; - ), - TP_printk("dev %d:%d ino 0x%llx fsbno 0x%llx len %x", - MAJOR(__entry->dev), MINOR(__entry->dev), - __entry->ino, - __entry->fsbno, - __entry->len) -); -DEFINE_INODE_ERROR_EVENT(xfs_bmap_remap_alloc_error); - /* reflink tracepoint classes */ /* two-file io tracepoint class */