From patchwork Wed Oct 17 22:47:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10646473 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 EA0AF15E2 for ; Wed, 17 Oct 2018 22:47:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB4ED288C7 for ; Wed, 17 Oct 2018 22:47:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEBBB288E4; Wed, 17 Oct 2018 22:47:23 +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=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 585B9288C7 for ; Wed, 17 Oct 2018 22:47:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37A936B0293; Wed, 17 Oct 2018 18:47:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 329106B0295; Wed, 17 Oct 2018 18:47:22 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21A706B0296; Wed, 17 Oct 2018 18:47:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id D0D276B0293 for ; Wed, 17 Oct 2018 18:47:21 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id n23-v6so28015570pfk.23 for ; Wed, 17 Oct 2018 15:47:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=LiozndoqC/TzvqN9AZSX3PUuVQc7boe5NscE8EdW/X4=; b=pWwS0l1l7Co9k/LXDK4pjeDDUF7rUspzQ5+lN6I+5McxLyBl6AQW8qTbfKvbIqhF63 N+G1rEYPza8UC6INkJucT1cFLccWSREVxiJlmslA/LECPdE5+F14eL+Ya3avJVcspDfq 78gSq0DbyLruX4DjcY2y+FLGI9yqNEKUg6aPis6B64qqYPnCqv1RqlDziQ5UMsSSb7Gg HQPIoqAg0UW3deEmX85tnsLiolHyUOkVVVAvq1BhBIBKiIJ8GOJLkSavf1AyIAaa3oU6 AnEKs6clfDRvcAP/HnfwN69qze2Us6uqnpuVyuqHKZ4D5dprdcOaYMsNF796dnxdPdFr JXsA== X-Gm-Message-State: ABuFfojZI7EgntPsPMc98qGMibdJ/+yFzyvgqk9OqwyNUJVt5xy3WQjq 1bZWjAhE6LspRclJ/SttvZ2/qfJH8F9Jh/H6g+zY0a15do3Dbfxl36laC1Fkxepm/B/XbPVS9C+ VG8uUQ62Yc784xqfGIQxqKyUeTTs+d5yoDoUZHzeNApU8o96xxuStUo2UmH/i2MhjdA== X-Received: by 2002:a63:4904:: with SMTP id w4-v6mr26101005pga.303.1539816441531; Wed, 17 Oct 2018 15:47:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV623XLnj2CW5KgEC2FjhRhLdzq7QDD5fOZ58IuLgpIjmAR5dLQVzEElkbJAQRS6sejoTsq2Z X-Received: by 2002:a63:4904:: with SMTP id w4-v6mr26100980pga.303.1539816440956; Wed, 17 Oct 2018 15:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816440; cv=none; d=google.com; s=arc-20160816; b=rC6yJQ0av1AHwsnfig0YwXi+0uakKo0dfXYVvGN2lCOG92lg08/7/fNRsgXhZLqU7/ lbP3YlJsx4swR9Y/Z+S55/b3fjQPBcpPPwisvVowrSUhzQl3aLzbsXgzeDvjjfTLLmfJ rlQwdI12YgkwzUePLlGW/eAF9TMA9Dqt0p3FsKRaVijZwWJWskw83erBKXl+0z+od0vA wZ8Fl3H0PiKH8raNvjer6V6BtkS3oKmZo18XgynarAV9BvnaWYxX5p22mfzpei6x1aBU PkUBzovgeAlNIRu0G+DENqskJbtP8XhLQnU/bNEP7//2pqc7EluAPjT0cFU/AHxmwne8 PXsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=LiozndoqC/TzvqN9AZSX3PUuVQc7boe5NscE8EdW/X4=; b=Id5gMJbATpWT+eSD88aQLSm7wFHfBbBSO1KZW0JPi2JFZyoxyrRs2FKslox/Eta1ti f8AwyiYNeNmMDRDtgZ1404Or6x7Vj7XqhtsNjt6PGY7/5v1IBbQvtGN0F/Aw7gN2uk3+ EuZTjY2wWwu+yRwLcRuDVSAnZKEjNjWM4dT6JCN4tof03MOkHyqFz8Wj4tmUibih5tQd 3p3Xd+wlvvgueJAgW/99pBJzYkg556sDTIIp4OzRjZoU/bKqhB7Xez83CtdNEypcENYb 2bK5PRPM8V7Ca8qAJkiHt++tSPqk1/HEzaR1lP5lYoHg3qWEVeeDhbZ0c8N2Bd++5xBz Gw1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=q4NysuBL; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2130.oracle.com (userp2130.oracle.com. [156.151.31.86]) by mx.google.com with ESMTPS id 94-v6si19943188pla.11.2018.10.17.15.47.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:47:20 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) client-ip=156.151.31.86; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=q4NysuBL; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com 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 w9HMiGVl040211; Wed, 17 Oct 2018 22:47:20 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=LiozndoqC/TzvqN9AZSX3PUuVQc7boe5NscE8EdW/X4=; b=q4NysuBLWlyn5Azt58kZ18x53W7uwDuEmMqu1CDI5KXa+AWrw+CeiYqw3+cYFXUzQwd9 oBqKgi6yAHhBEp+hZYU3Yc7nM0219K3ra0hekc4VijOKpbOujxXFwoXbVsrTwf8ckQ6Q 7RtWE5pCzdKO9Xz201SEMNDLXkryVXkaMac/K/+xEY4034riBKPEniLJecgnkMi8/rs4 rGNILnjfCf56jRKr5v2X8xC7LChch+h3BL2JX9RQ0l0dZfnKGdx4O3X0EuhlNDiwUGVK VG48MTZp75WfXupTPSpNFfm0a6IGSfwp5AopBqjaJ0ZN3CmzWHZx7g2BBWpKg46EIGnH yQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n384ua071-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:20 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMlFA2008571 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:16 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMlF9p031923; Wed, 17 Oct 2018 22:47:15 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:47:14 -0700 Subject: [PATCH 25/29] xfs: clean up xfs_reflink_remap_blocks call site From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: sandeen@redhat.com, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Wed, 17 Oct 2018 15:47:13 -0700 Message-ID: <153981643329.5568.5878961664707094374.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Move the offset <-> blocks unit conversions into xfs_reflink_remap_blocks to make the call site less ugly. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_reflink.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index e8e86646bb4b..79dec457f7fb 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1119,16 +1119,23 @@ xfs_reflink_remap_extent( STATIC int xfs_reflink_remap_blocks( struct xfs_inode *src, - xfs_fileoff_t srcoff, + loff_t pos_in, struct xfs_inode *dest, - xfs_fileoff_t destoff, - xfs_filblks_t len, - xfs_off_t new_isize) + loff_t pos_out, + loff_t remap_len) { struct xfs_bmbt_irec imap; + xfs_fileoff_t srcoff; + xfs_fileoff_t destoff; + xfs_filblks_t len; + xfs_filblks_t range_len; + xfs_off_t new_isize = pos_out + remap_len; int nimaps; int error = 0; - xfs_filblks_t range_len; + + destoff = XFS_B_TO_FSBT(src->i_mount, pos_out); + srcoff = XFS_B_TO_FSBT(src->i_mount, pos_in); + len = XFS_B_TO_FSB(src->i_mount, remap_len); /* drange = (destoff, destoff + len); srange = (srcoff, srcoff + len) */ while (len) { @@ -1143,7 +1150,7 @@ xfs_reflink_remap_blocks( error = xfs_bmapi_read(src, srcoff, len, &imap, &nimaps, 0); xfs_iunlock(src, lock_mode); if (error) - goto err; + break; ASSERT(nimaps == 1); trace_xfs_reflink_remap_imap(src, srcoff, len, XFS_IO_OVERWRITE, @@ -1157,11 +1164,11 @@ xfs_reflink_remap_blocks( error = xfs_reflink_remap_extent(dest, &imap, destoff, new_isize); if (error) - goto err; + break; if (fatal_signal_pending(current)) { error = -EINTR; - goto err; + break; } /* Advance drange/srange */ @@ -1170,10 +1177,8 @@ xfs_reflink_remap_blocks( len -= range_len; } - return 0; - -err: - trace_xfs_reflink_remap_blocks_error(dest, error, _RET_IP_); + if (error) + trace_xfs_reflink_remap_blocks_error(dest, error, _RET_IP_); return error; } @@ -1396,8 +1401,6 @@ xfs_reflink_remap_range( struct inode *inode_out = file_inode(file_out); struct xfs_inode *dest = XFS_I(inode_out); struct xfs_mount *mp = src->i_mount; - xfs_fileoff_t sfsbno, dfsbno; - xfs_filblks_t fsblen; xfs_extlen_t cowextsize; ssize_t ret; @@ -1415,11 +1418,7 @@ xfs_reflink_remap_range( trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); - dfsbno = XFS_B_TO_FSBT(mp, pos_out); - sfsbno = XFS_B_TO_FSBT(mp, pos_in); - fsblen = XFS_B_TO_FSB(mp, len); - ret = xfs_reflink_remap_blocks(src, sfsbno, dest, dfsbno, fsblen, - pos_out + len); + ret = xfs_reflink_remap_blocks(src, pos_in, dest, pos_out, len); if (ret) goto out_unlock;