From patchwork Wed Oct 17 22:46:25 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: 10646399 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 BB8FC15E2 for ; Wed, 17 Oct 2018 22:46:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC657288C7 for ; Wed, 17 Oct 2018 22:46:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A079B288E4; Wed, 17 Oct 2018 22:46: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=-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 213B4288C7 for ; Wed, 17 Oct 2018 22:46:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F11D16B0289; Wed, 17 Oct 2018 18:46:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EC1CB6B028B; Wed, 17 Oct 2018 18:46:36 -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 DB2F36B028C; Wed, 17 Oct 2018 18:46:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 99D106B0289 for ; Wed, 17 Oct 2018 18:46:36 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id r134-v6so16196613pgr.19 for ; Wed, 17 Oct 2018 15:46:36 -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=A4sDFXPvAlL63/6+A19QlnFZhnOxuaNlawZcJx8i2yQ=; b=qwIWxk5ILQeX6vWa4k2KxeC3u83uT01QTgbR9cgltdbXeM12Gp0NAduKh0j1A/t6+1 mNwISq5ybFUyVOHvYJzkKxQQf7SapnNOQ1X8dMtyjSj3q/XIreiub6er0ixkcb0az1np n5txZc8Rx+Vsme8Xylr5wth/+XDARDhIe8rPH/OUAyDSakX5Ph9j9GmntdaFUyak8KaH lIZ6/vGxkzfpR7JCPnwXZNUZdWFvBSsrEt+/kX1e+KBWIEz4obGlvn9j7Rd23PFGPiG8 j1qIaYTtQHdDbOKg7U/7Ycm7Fo1Hh8TgvIf8DbnnIuFoZYNlkp1xK7+MiVp9GN1CIOAA xXEg== X-Gm-Message-State: ABuFfogswd3D/HDXfTxMU44pvX/hzF/E3fNqZmcOe4JDCAWVECUJuSDA KNUxQl2KPLApfiAYKdH3J3HzkZZskfuWKvpK/USb9Uv/DPBkH29/Ms23THMjaaz3JY0UvBHNhTK HeYrRTpioYjHDgFZ8jO+VnjVAxPHfLg/CLFsEXSokjrxKeHQcZSZt+p6V9h6I2NyGYw== X-Received: by 2002:a62:c68e:: with SMTP id x14-v6mr20370400pfk.151.1539816396301; Wed, 17 Oct 2018 15:46:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV60ZBK5L83MigueskVLOm+YEiEdBYHDxgBdptizKjUe9p6dFnEpiZlGVEB25cLz0LJUYMZ90 X-Received: by 2002:a62:c68e:: with SMTP id x14-v6mr20370368pfk.151.1539816395568; Wed, 17 Oct 2018 15:46:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816395; cv=none; d=google.com; s=arc-20160816; b=KhbQVyXmOIWI6/jGZ1Eb8ziP91DWwoooyyxSdaFAH0iNN0XM9UCW5xxR92HjVXcuJt rYb1rUkDvg1yu1T1XNt41WETWke9YerNY5Lc4oNfvpCyw2VU2tF8ovTvNLOWs/SkbSpJ gb/Bbv303dF8gqWCfyjWp14m151P0jTcYh1OU4yISbrWMMhujUFIBQm8C1x9zYQj2Uwd SZijAsCwRXKu2DEITyRWTg+I1m1Q1YmunGfeV50CyNkiXpYTvclVW5+8wgWkEUOPWCfb EPag2qhvVpI6OXZfy5DsrsgbiRvsqEAnP02fzOD6oGg+q98h8KgTRHeJ9AKUKmIYLX8u gYEA== 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=A4sDFXPvAlL63/6+A19QlnFZhnOxuaNlawZcJx8i2yQ=; b=wayzeiu3+MGfw9/0hf6/M5YRzwcoBFQAFC4frTK5ryChH6eVSnVwvqlLJyFEY3m+4g fI9zAvRCvn4VLDrdMsSI6b1tuTZKapOT/XcI0Bky370YZbp07jlUrJVlwYow7jIrFFvy +S/BiCzH8ATMmjgD4ZYuXxUQVNRhlRRyNeKqwGDRvtF7Pa4yNx0JtDvXVJmp6qCKQdfa VRlE6fF2tk9EQNqNPjM/qBnI6TQDlcAZW6H2CZA7aS/xv2t6pifyblQHX1oUdDIZ8Y5A Etwm4zqfLiohR+hc5E0gpFFDQrukos0PYFqhdgafWQsmlu+4z5J2TDBcl2bXKygGdSf0 g6tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=gZ9KvyJJ; 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 q4-v6si19315872pgh.563.2018.10.17.15.46.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46:35 -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=gZ9KvyJJ; 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 w9HMj6WV040876; Wed, 17 Oct 2018 22:46:34 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=A4sDFXPvAlL63/6+A19QlnFZhnOxuaNlawZcJx8i2yQ=; b=gZ9KvyJJ1+cu6bic06h6RtbOYxLaLl1r+a40zZbTayaXYoxYWgL57FzRpduD2TeVIJNT GN1B2Zf7FkxTtvqpfpXaj22VPsugJ32Z5GLWlZM1xLOq03inLljzWLunzT5CGAUQhpt8 2gCIJO9rDjqgIL4B87oDyM6Qlla41PDjERKJTz3cAZbfcmhPQrmctnNYEtqQtr4nLXDR bvIMO3hg4BdD4RUZcu3+yoHreUsYSew4N4IOWtbKNLXczkCt2Wp7bE38G85++t/mQCIu Q8bKz0n1MjiaW7cMu0YaBYIyhc3xa0JfE54Lzh9Q477Wlwccrtvg9ryG6LPwK8CL1eav lQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2n384ua03t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:34 +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 w9HMkRHl014954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:28 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMkRuf032168; Wed, 17 Oct 2018 22:46:27 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:27 -0700 Subject: [PATCH 18/29] vfs: clean up generic_remap_file_range_prep return value 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, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Wed, 17 Oct 2018 15:46:25 -0700 Message-ID: <153981638588.5568.15494557106783144592.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=873 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 Since the remap prep function can update the length of the remap request, we can change this function to return the usual return status instead of the odd behavior it has now. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/ocfs2/refcounttree.c | 2 +- fs/read_write.c | 6 +++--- fs/xfs/xfs_reflink.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 6a42c04ac0ab..46bbd315c39f 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4852,7 +4852,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, &len, remap_flags); - if (ret <= 0) + if (ret < 0 || len == 0) goto out_unlock; /* Lock out changes to the allocation maps and remap. */ diff --git a/fs/read_write.c b/fs/read_write.c index e4d295d0d236..6b40a43edf18 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1848,8 +1848,8 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, * sense, and then flush all dirty data. Caller must ensure that the * inodes have been locked against any other modifications. * - * Returns: 0 for "nothing to clone", 1 for "something to clone", or - * the usual negative error code. + * If there's an error, then the usual negative error code is returned. + * Otherwise returns 0 with *len set to the request length. */ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, @@ -1945,7 +1945,7 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, return ret; } - return 1; + return 0; } EXPORT_SYMBOL(generic_remap_file_range_prep); diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 3dbe5fb7e9c0..9b1ea42c81d1 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1329,7 +1329,7 @@ xfs_reflink_remap_prep( ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, len, remap_flags); - if (ret <= 0) + if (ret < 0 || *len == 0) goto out_unlock; /* @@ -1409,7 +1409,7 @@ xfs_reflink_remap_range( /* Prepare and then clone file data. */ ret = xfs_reflink_remap_prep(file_in, pos_in, file_out, pos_out, &len, remap_flags); - if (ret <= 0) + if (ret < 0 || len == 0) return ret; trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out);