From patchwork Sun Oct 21 16:17:09 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: 10651153 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 478DF13A9 for ; Sun, 21 Oct 2018 16:17:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33C83287BE for ; Sun, 21 Oct 2018 16:17:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2844F287C2; Sun, 21 Oct 2018 16:17:18 +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 B0867287BE for ; Sun, 21 Oct 2018 16:17:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE97B6B027C; Sun, 21 Oct 2018 12:17:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EC3776B027E; Sun, 21 Oct 2018 12:17:15 -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 D140C6B027F; Sun, 21 Oct 2018 12:17:15 -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 A45496B027C for ; Sun, 21 Oct 2018 12:17:15 -0400 (EDT) Received: by mail-yw1-f72.google.com with SMTP id h38-v6so25645371ywk.20 for ; Sun, 21 Oct 2018 09:17:15 -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=PtbbxwTjXdScxvEIP7J5Bsu/YS8R4QVzqlODOI7VeGvCBGzEEwyPbBvQjBUbcwxUrb 72PLsH/XQUlYkJMfYmJQICRQAJuA8VVMADOBn0HHEEix+yff7TtYpWQn7lkn7lLfEyzm 55UuYmTDM+jt0n2fQ74uj4jAvDyUjCPCcm25/W+gVA+0tnDl+qZX3nClmHvD7ddW8BpT 8e4DO4ldOlwdDV8jtS/prmbuHZbJVMBuNlUyCmLRpkcly6IKr1gUxUjjKSrEGoK8F2+D tQQ52RTydxnSIti2LHzC+irpRLjPe2n5WVh/YIJFqFtF7Ga6hEIfYxtqEfW00XEPxPYq MKQg== X-Gm-Message-State: ABuFfog/BCcB0FJkQ/aVPbD34yTW/NXOE7LwN6BCDkaqhSvXRpA5cXq8 CBiloVIs+GXrCAFvhAp4tCOqNpKoxnpsBT8QnqG5sOs8NUILOX4d64Wciux4FtrjRdWzGZkqgp2 9O5wf5s7M+0gCPSDT+nOhPlEgyQjuWAcWVrBk9mg3B7jUGzX8FGk18Q8l0zf0Wvui+w== X-Received: by 2002:a25:2c44:: with SMTP id s65-v6mr8190172ybs.472.1540138635424; Sun, 21 Oct 2018 09:17:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV62fgfJstmHSOegBgKILe5op9RSCJRwrVgNwurSQyJ/8w/WwhyCvphW6ySxnhxT5POlvpyPg X-Received: by 2002:a25:2c44:: with SMTP id s65-v6mr8190113ybs.472.1540138634317; Sun, 21 Oct 2018 09:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138634; cv=none; d=google.com; s=arc-20160816; b=Q03DiAj+vOiTeiDxpJnv+C5yjOE4Uy5yDgg32q4TsRkvPugTxwpBKL/N+uhoXSZBiy YXt0GZxD4UkHnUDGpEg9Hrl0xLZEoO+fWrK81zdoUCv8Lybb9ScVZWRr7T2FQunhXeNG hoDspVgs33KSlUK/B+GhBN2Fh/TeIPdB+DCSSW68w4BVXxLs6rDjJqHpn9624yHfRN1U YtsaJVjVodT84XUe8eUxNUo2EGqmRk9b4U3/NeoZHhNN0SIi3VqLR97dW71VTHXvU+4k oZvsOx+D4Ot+66if/VvNeXkDW0ibNCZjR6hiFPglcvmRjJS/ZG5k3PXD49j11EuCvS2K valw== 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=0YYp3fwb1ceEjQdhWOwh7ZprZzb646QF/Ye2jUsGRHqbisCzl87fXXfvugfjmQJ6S+ 4eqAHDoJ+VhPga06ZDA4Me+Xan14melhWnqclXyofLfYFwmWepHpjwAXYWvHjbD68IIm qG5SxwvwwimlWxjon09gjzWYL5h8HkXq5THfnOpRxXnFBsbw+7QA/tooQKmsLgFyrQG+ V1JeUvOPYWdmdOkpl33FCxXB2vR2o94pVaaXouSrNv4ncm0eZlcZgaRhKrwTNtBgV6Fd xgBui/35/dp0IiDbqDv4lpXcuTxua/IU+Ul4p2o6SEWXoYCwn3KRyg4dXge2mEeIvgOM 7GMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Ci372zLd; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id q5-v6si14736076ywj.32.2018.10.21.09.17.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:14 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Ci372zLd; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 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 (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9LGDwSl106540; Sun, 21 Oct 2018 16:17:13 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=Ci372zLd/zDuX20WsEMatrVemjJBmWvfmWAVw3fGsomqTRphZkyBH4vr5R1srJIGkyYT Do9VZ15gmExU4LQaIZKAuJraOAD52rtt4ZrTRemLeOUE4Z3JKweSsbadLWnFw5bDkv+X m1bWKEoXPjnkrnEDRo8xA4DRPrXTouuAsOGX/cfsjGLBrA2JBw1EHTMKTecdO3KdXix9 ZX7kcxSbCpF1f+jmGfK+SwjJTwyjfAwmpf6jfIO6xt+46YX+7zco6IULR7Be2y25dK7S I/G+x/xF1lVJ/iJMO4bpStU8d05PoyNlnpRF/+gwJP1Er4HsnYt0nttN1Jb/jMOf6JAS oA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2n7w0qaxkm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:13 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGHC4l010087 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17: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 w9LGHBuj019294; Sun, 21 Oct 2018 16:17:11 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:11 -0700 Subject: [PATCH 18/28] 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: Sun, 21 Oct 2018 09:17:09 -0700 Message-ID: <154013862952.29026.12371941728048413604.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=872 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 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);