From patchwork Sun Oct 21 16:17:50 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: 10651227 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 18D3514E2 for ; Sun, 21 Oct 2018 16:17:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03A8F287B7 for ; Sun, 21 Oct 2018 16:17:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC31C287C0; Sun, 21 Oct 2018 16:17:57 +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 73C9D287B7 for ; Sun, 21 Oct 2018 16:17:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FFE76B0287; Sun, 21 Oct 2018 12:17:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2B1396B0289; Sun, 21 Oct 2018 12:17:56 -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 156976B028A; Sun, 21 Oct 2018 12:17:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f72.google.com (mail-yw1-f72.google.com [209.85.161.72]) by kanga.kvack.org (Postfix) with ESMTP id CC6AD6B0287 for ; Sun, 21 Oct 2018 12:17:55 -0400 (EDT) Received: by mail-yw1-f72.google.com with SMTP id n205-v6so25616424ywc.16 for ; Sun, 21 Oct 2018 09:17:55 -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=DRngs2At5JP1s8owiOPeqzv/fhzSTrRp8Ej7ddFZwyN0x3hJwoJe9suAuTBSeeRDVe WLkFOwDxT1rkhhwpQQTDLhVyyn2JlWoNndrdGNnbFgzhCWHjEfUAOVUB9legdARqRfvi zMll40GymmLyCQmRzx+mSdKndPgOMbUPoq/efJA43bXbZGbmXg0zLtNzHPrWzxAQkQC1 nQ6qM02WUW1YnrFhpGmmiay6xGe6D8lop28oNV2/1xjMXasufTLVBmceRERwMOOem2C4 PlZuKbjq/mpsAVMwSWs1GMB+D/d/hq0cxULMWgmXBiYeL1Q8pI8wJmT0O22SdWMLNhQO 6pcQ== X-Gm-Message-State: ABuFfogPObDenGY6VbeYrAImUFJS1KnSYxo2UWTYboLPE6tnBV4q9vPQ a8nwJ/fjLSP8Wup2RKlDungHowPvwEL5s5sA81jP8i6JHnSD3HnUIUiZV8FuA3xyoQ4jwCTNJgQ 930HESpHaZkVFNfxWFI7pS+k+kfoMejBBSsKR6Vx6dNokRhzNzwBgqH9DkZrofYpT6w== X-Received: by 2002:a81:4328:: with SMTP id q40-v6mr28792139ywa.187.1540138675544; Sun, 21 Oct 2018 09:17:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV601fiHwTUp9CrlWGsCIO19aruRJF5SS1Ku2fuIl6pwkqKFi8pFq9ygfcRVWVlheKA93HaUI X-Received: by 2002:a81:4328:: with SMTP id q40-v6mr28792111ywa.187.1540138674973; Sun, 21 Oct 2018 09:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138674; cv=none; d=google.com; s=arc-20160816; b=WtDEDXwtD895eiNgKeHY5L7tB5Sg8untVZZCquAahJCugJC4yB9j2RLFopkOSSZpv4 QTfEg7O+HsAy6vFCTu7wi6Ti8ZzxmwnGG55tylCFY77qA5uFVVF2jklKeW87z9oTH5rX bML8zFyg90qn5OTjasA5nDQ5H71laoku1EKzlcdKFq5VUCqH0arsN+68W77QzCcmrkzr 5/NOBXv+0s8KfylzG/uptDZPm1v+lR/ET03vYdgjRmER3w44r5ILFIMCExsXTU2Inm/J zuzS0ETfFrJl9vG4cE3fEiRR+EXVb00lN0nW1IOJfabFmCWgBmkI0yfNHX5Ae3BkNGUC aiTw== 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=nsdJ/Lsc92FYWuBEdiV4x5w+//O0lDulPJgRcwY6eDPOJdyjY/WS7d0KD9+/endpdi VDmCwsZ2WDYAIxS2muIn90U+VfgoJLUrYUJxGCeFlE2hvneI/Z7GrtNmOEj4Oel2tIzq tvxZrBoyY2LQLi5RbdJi6nIQb/2e0TAehjnNoohRtMWel0m10jMnjoJMn2x8ZxmMFf7D waWSYnTdNK8/eGP4eBaQ5Z4x1unEAl4KvFDnFuECeh8sX4rtmeP3t7n1ZU+GmHcr1BSq LHUAao6lznqxY+/xQvEQnnHOkYFuY6vDWK2YmmNu6bYTSEIggYEVgxBxgqeZtO9PiO3G 2dCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=FkLUpJ5Z; spf=pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from aserp2120.oracle.com (aserp2120.oracle.com. [141.146.126.78]) by mx.google.com with ESMTPS id 204-v6si603985ywf.99.2018.10.21.09.17.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:54 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 as permitted sender) client-ip=141.146.126.78; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=FkLUpJ5Z; spf=pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 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 (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9LGGCQA155864; Sun, 21 Oct 2018 16:17: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-2018-07-02; bh=LiozndoqC/TzvqN9AZSX3PUuVQc7boe5NscE8EdW/X4=; b=FkLUpJ5ZlHSQVxxriZvK5EtLw4/gvEgBpaitc1X1xmPGI9EhRSD9If1RF/PctUGEhoOt NK5VYcUjYJJbGvNozecBfeyKs2qFkdH6BxFXhYLln/kgEKniPKm3WEsauLhsuyOGt1t0 Dz1w0BZd/FE2Kfd0QNynAg9LbOlxaDmMCZe8BnVWnSkN8TJ1UuebDj1n7cpzDE/zdj0S 0gvRJ/c6ibSQ+kb1BshomwVeOsQYlUUsSbW4ALSyRDHlhOXW7FFjP5TAMV8S167D7yiG fXZfQ6a+GEN8mBsX2gRkK7MgeUOwlHlYbEhllMxEs1U24hGWpfmaqADE/F+2UCDz9CgA OQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2n7vapjysd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:53 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGHqq4006984 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:52 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGHqw3018953; Sun, 21 Oct 2018 16:17:52 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:52 -0700 Subject: [PATCH 24/28] 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: Sun, 21 Oct 2018 09:17:50 -0700 Message-ID: <154013867045.29026.12266020817835171751.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 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-1810210151 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 Reviewed-by: Dave Chinner --- 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;