From patchwork Tue Oct 16 03:20:14 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: 10642943 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 606CF18BC for ; Tue, 16 Oct 2018 03:20:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D94128F69 for ; Tue, 16 Oct 2018 03:20:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4200A29AD5; Tue, 16 Oct 2018 03:20: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 BF2D228F69 for ; Tue, 16 Oct 2018 03:20:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B6BB46B0284; Mon, 15 Oct 2018 23:20:19 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B44986B0286; Mon, 15 Oct 2018 23:20:19 -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 A0E886B0287; Mon, 15 Oct 2018 23:20:19 -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 5493D6B0284 for ; Mon, 15 Oct 2018 23:20:19 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id 17-v6so15981948pgs.18 for ; Mon, 15 Oct 2018 20:20:19 -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=abN8AwQSn2h//7+1QLn+2XgmD6/XEIQ+bkobomWt214=; b=OsREW+qvmDinO8Q7Ksl8d3zloXhrk6xfI7JMnrdIoSdYFJzBuuVaYyDvLUMc6CUnVv m2T6avzgeUuxhG+ZPNaJGS1h9eqQeejkMB655UG66wye7EhqEPQVXoT3VRnXSq9b0Ij2 XkVbxupTzbTXF4PxtQzReK/82nfMnyYeJHhs+B4QOneEzI4WdbFoL+JLIWnpF8mJFNaU 94NwPNZPjL+WAxd7kA09qK0fetee83VyAxaqPdsirgIVI5uFnPVv8Iqz70mU/vHFmmPO FtC5x6I3crfnGGnvBAyeZV6zPqtPnuGh+won1OU8BRjK3FwFEfARNiU3IYRqM5HWtWd8 EaHg== X-Gm-Message-State: ABuFfoicaldF3mAhSszfM8yCtQhHdoAwMxVHEDXkjaZpJPK39I4KR0ne YIlWXpLheHSBNs3k8vP7B7hhTWFe5yalum7pJs4mDvNq3FMED3sRu2oZGSN/Yr+FNUqKKly96RO 96pNhGKNeg4xCeln6JI+Nkuj+eGeWM+BCFzXSj//98Lp2uUlzTcSmmJ31dwZMWl4sww== X-Received: by 2002:a62:c2c1:: with SMTP id w62-v6mr20056504pfk.35.1539660019019; Mon, 15 Oct 2018 20:20:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV63fBhYg+uDe4LDqwgYxIjmCiKZy/tzPSw1+Em8OV4cvJCY6gE6UVg3DA2Jcayo7RhErG2jB X-Received: by 2002:a62:c2c1:: with SMTP id w62-v6mr20056474pfk.35.1539660018278; Mon, 15 Oct 2018 20:20:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539660018; cv=none; d=google.com; s=arc-20160816; b=Aa7xIRO2deMZt224J62Bu5ohuD3oERL2G9nq430hTjjsfcMet6MEwGXipkUmUmdrZ2 EoRXe1rtNeDCNm/6ize+gNgZ0o/WInHkHL0SLZnc5+mdyO4PwKBbs2FWvZdPJ55jppft sYEKd8U6wmdzGKuoupJrdN68kXZkyv/oFL5JnlL3RSGpIciuxn2mZF14/NRRluD5QxGT 8uIS9AqksJFkSVkhneNJHYjVQqYyuwXmCO6t3/t07OGG1FqUTq3kFL7PQouJrsEPQRd6 HpCSolh4kH90ocd+PeCasSywamHa18dvXr2fzZbj3xM9BsXfSEGwPUyERwhUV9RyVoKr aiGw== 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=abN8AwQSn2h//7+1QLn+2XgmD6/XEIQ+bkobomWt214=; b=PO38fGKCugJRSzh6JByZNbgDh6fku+HkkD//6F32VEHBYAE3Hn30QDb5vJmbJNAaNe Sk/W58tjy6u1cL+TboX/2yAxdGufHIzCaHnF0QcI1mt1otoSdTTZtHjr3rfRKo9qUe5S bCyRqk00ZdNreVrR6Lr94AgwxYG6YXh260Q4eL9J7852BqOcHaPvLSTxzZdB7XNNAjdq zfbbt5enapha/uMLOpESJeR3Ita7U6tqQAge23WRZSVe7LEA7mDaiRtB1WkOHCLZNhEN Vc9ZwFeXh0EWvsd8u1GutefQv8mf6Ip2RedJUXdkoYoipFb3MZgEING5aRc6LxGvWJe0 4e4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=4F3Pha7h; 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 l4-v6si12652639pgf.344.2018.10.15.20.20.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 20:20:18 -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=4F3Pha7h; 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 w9G3J3t3051349; Tue, 16 Oct 2018 03:20:17 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=abN8AwQSn2h//7+1QLn+2XgmD6/XEIQ+bkobomWt214=; b=4F3Pha7hMa3VhAthE5Z860g/br/Gi8WnzbTAtKS1wN0FITMrzGjzdkvXtkHntann4wrH qxpzeXa8cgweJ4IcmcGSTb+HNaUYUiNgqgC0+QI5wF0bZAE7aq0AcS82Fz6x/Uktpr+n oVJ2CmvQbJIkGTm007MCGEQ2XaM81n+pOPcpjRYfXjxSHQCTJIBamYzTtn8ybbnCtFEI m9zfkQ8JyBQ5penywEO/CdbnM5iWuzCWSDYTOaeciwPvoU9T1KnAO2aXj7e5JWXuc0cw j4+92AP3J77xDHpjsCIXyACVLuQKfWqsYSPntcZs0+1yN32BrU8RiSN66aXS11Ylssbo hA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2n384tx29c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Oct 2018 03:20:17 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9G3KGQF004814 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Oct 2018 03:20:16 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9G3KGAa010715; Tue, 16 Oct 2018 03:20:16 GMT Received: from localhost (/10.159.227.150) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 15 Oct 2018 20:20:16 -0700 Subject: [PATCH 19/26] 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, ocfs2-devel@oss.oracle.com Date: Mon, 15 Oct 2018 20:20:14 -0700 Message-ID: <153966001458.3607.5940191707393894977.stgit@magnolia> In-Reply-To: <153965939489.1256.7400115244528045860.stgit@magnolia> References: <153965939489.1256.7400115244528045860.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9047 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=851 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810160028 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 450e038e8617..37a7d3fe35d8 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1872,8 +1872,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, @@ -1954,7 +1954,7 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, if (ret) 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);