From patchwork Wed Oct 10 00:10:45 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: 10633421 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 1E01516B1 for ; Wed, 10 Oct 2018 00:10:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E48029C92 for ; Wed, 10 Oct 2018 00:10:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0C48129C99; Wed, 10 Oct 2018 00:10:58 +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 A98E829C98 for ; Wed, 10 Oct 2018 00:10:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B08C26B000A; Tue, 9 Oct 2018 20:10:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AB91F6B000C; Tue, 9 Oct 2018 20:10: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 9A93C6B000D; Tue, 9 Oct 2018 20:10:56 -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 5BC0B6B000A for ; Tue, 9 Oct 2018 20:10:56 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id 14-v6so3177673pfk.22 for ; Tue, 09 Oct 2018 17:10:56 -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=89x/kON88z0SWLBhLOQF02OXzgiCMuZXQJYo9kVK6z4=; b=HLKM5wDlmKaElmYZrK1+kqv2ConlgaDgSHPVe6JQ/7fy272/jAwR9YywkY5ONyGn+Y B1sUWRq2mHYulP5ikKJxK+6kWtkVKfbEoRHG5j2UDNB6oSJNoVNQp535mujyFeHGCy/b 9opGLNu51f4262WZacVnIT1zdrPb2yS8kIDK1gkVTaZ4p0lNodjUs1R3J8xUZpcTZbok p424aRg3YvNg4XhFrCAY3yWX1Y4ZK2JvQtw9+Fgd+eiMBOhSysKNnuVPpLiKHDncXRvo 1ea+d8GDAhdAJtDDPm+RpiLRreonK5Weu2sw+FsX/msnhVVCDncCEVdDoLpsoxG5xHw8 aD5A== X-Gm-Message-State: ABuFfoiXQUUh4S7tmDnUEEoyjZpgD8SS6JvmUZYH7c5YromYR78uLo5t VWylDy4JLj0Rj9V8ITw2KKlsAvvTQUG4gAq1mybi8dslUjFzDrngnmaNrF3G5lcE2s7gFNO1nY6 pSRS5U1uwsWyD4KN56MmBRDuV/WHwVo3d6AtzARVqfaRdqrNjreumxx8ggzHu9ebTxg== X-Received: by 2002:a62:6b0a:: with SMTP id g10-v6mr7653168pfc.174.1539130256070; Tue, 09 Oct 2018 17:10:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV61kb+RhiKgcsAqSpKDLJFwI6fcGwdyW7Jj9w/iXfOE0AoE31Q6oYxKKxRBVPubKnejfYP06 X-Received: by 2002:a62:6b0a:: with SMTP id g10-v6mr7653115pfc.174.1539130255404; Tue, 09 Oct 2018 17:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130255; cv=none; d=google.com; s=arc-20160816; b=mFY4VgufNizv2TKv/i8uZHBEeT3RG7xuljE7I7gYFk4qhb99RuDDXBOd2u42Aoa5GG Lr8/RH5KayDanepspRVKQbJcHeG0jxfkf209G2GXGyi+6IxlTu/MnYuX1T3WWRJoh943 9tBrOHrJqPxi1zx+L7wMNP04FO9MknWjJPFtJleSENdoTgG9TiwjW5iMQn4tEWnDClOG VfsWCrn6NtWzl1pHMl1BPEDHsmxpE0TuKbiMhki/iBlrF+iBHX9IQx8OG8iFxWVDkMq5 dYCrXmxkBJLgMWBMLWTmnjiUDavENw+tvtRaArQG/+9jthtkAUR8Pn52vbs3atygX0vl /LZw== 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=89x/kON88z0SWLBhLOQF02OXzgiCMuZXQJYo9kVK6z4=; b=d80VXMiuDBQ8vNDSkcPYMc5oCSif0F0hHCNlVkt4tHKT75cmtrpl+c+y43y+NEY1QL qunXS76HGZFgaZ9BhcsTKMrI88q3/DdVRPTQbuNZXMjjyzQzaMtxkXre/7hnpf2mBlpS o0TCklWnSFHZ/SzQeycOkX9BUiFLnUDiDaxdAk+jDDCqvU2yI7+d4VRf+0byq01/0AUV MojjUp7/1jmkUNN144w9h5ox+kuPbFHtFmp4OAWu+RGdeV10OYO7ZEXhkPs1IIIzTLQu HOeTnTcWSDhYmnvfbZWpMBd8VCFdKeR1FhEOqaNeHwYpkqp/r5K1LtO1XiKqzyGwLOoy B5tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=nfOS5n41; 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 97-v6si22987597plm.290.2018.10.09.17.10.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:10:55 -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=nfOS5n41; 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 w9A08wZ1138901; Wed, 10 Oct 2018 00:10: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=89x/kON88z0SWLBhLOQF02OXzgiCMuZXQJYo9kVK6z4=; b=nfOS5n41uY8VFNV1Dqq86DJ6FjJJDSrNYuZdCYjzRZHTIi1CmUcQsjEtk3TVrh1klc75 In8sMLziz4DbzwtZtLgCpr8JNn+GgXPgwJN7Fy8Ho95jFZN3JfaksPWf170UB50qVbYl 3pjL3W6JIh3S5WuuHOSllQ2l1WBT7ST0qoWGzAnMxMA6H5mGf0VTOV5V49dYJIKHQI/g SB/fEYBMLvxduLDTqa2YExii0U+p26uOYXqtlaM6jGfIdKEEWl0O8EZJX5eFWXtfefFu mLHlG0Gef8Dosk4QDuYXmtDpwqsrIZUyhOdwuGaRm+l8OJ0ragrShZF0YQ+rjgF4pq5d hQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2mxn0q0tfq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:10:54 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0AlUT030521 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:10:47 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0Al7g002699; Wed, 10 Oct 2018 00:10:47 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:10:47 +0000 Subject: [PATCH 01/25] xfs: add a per-xfs trace_printk macro 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: Tue, 09 Oct 2018 17:10:45 -0700 Message-ID: <153913024554.32295.8692450593333636905.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=942 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100000 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 Add a "xfs_tprintk" macro so that developers can use trace_printk to print out arbitrary debugging information with the XFS device name attached to the trace output. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_error.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h index 246d3e989c6c..c3d9546b138c 100644 --- a/fs/xfs/xfs_error.h +++ b/fs/xfs/xfs_error.h @@ -99,4 +99,9 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp); #define XFS_PTAG_SHUTDOWN_LOGERROR 0x00000040 #define XFS_PTAG_FSBLOCK_ZERO 0x00000080 +/* trace printk version of xfs_err and friends */ +#define xfs_tprintk(mp, fmt, args...) \ + trace_printk("dev %d:%d " fmt, MAJOR((mp)->m_super->s_dev), \ + MINOR((mp)->m_super->s_dev), ##args) + #endif /* __XFS_ERROR_H__ */ From patchwork Wed Oct 10 00:10:52 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: 10633423 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 382CE17E3 for ; Wed, 10 Oct 2018 00:11:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 23C8329C7D for ; Wed, 10 Oct 2018 00:11:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1800029C98; Wed, 10 Oct 2018 00:11:01 +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 7447129CA6 for ; Wed, 10 Oct 2018 00:11:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ED91C6B000D; Tue, 9 Oct 2018 20:10:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E8A3E6B000E; Tue, 9 Oct 2018 20:10:58 -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 CB6026B0010; Tue, 9 Oct 2018 20:10:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 8CF8E6B000D for ; Tue, 9 Oct 2018 20:10:58 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id e15-v6so3229494pfi.5 for ; Tue, 09 Oct 2018 17:10:58 -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=Q7WRM8cm5WCpI5pToKQWHyNcuRIx4G5Ru2lJk9SDSnU=; b=TbpE0gIrbRVnsyD9QTUU8L3ZyM0T7g2CG5nu0ula/z0ELf14lzjvdPk4JP+o2hIe/x jSHIulPly18daR3seJhWjmP1PYAfiBDh95lH8GwL6j7yNvLZSiMDm2rUrBcOa8zGKt5C Gxg79UoyoqmrO6qESItcybAZ9NZMEK8q9rThfMCc2K70dEz+jYw9Se6YteqZNr4Diw2n zQYK7CsHk3Fe/dacGQ+o+XkiWERiL+NTLTjxM/C4D2LVcSry81MYB2CKnRB4ECbrbbGP lke4c0OQfLWlkfFyRn1duRezNwJMXSxAKb0/vOPPne62EpNFTVVmjPM3946g/OltHNka n/Cg== X-Gm-Message-State: ABuFfoiUoe5/e7ddd+q9pGqiy3HH8eW54nZAha/V7Q+hUuF9zY29mYl/ tULvW/kUuaYFfOQQ4WLo8wPcxh6rOx6Apvj9ROWhwRJS0p+NxkMVwiYtprPIuicdE3KEyl18P4k HktvGSEDspmUkdvYDFYsfY31jePNGyUh28BcVebPigst6BzjE3iHc7GAi2BZAbUBCaw== X-Received: by 2002:a62:5982:: with SMTP id k2-v6mr21757955pfj.180.1539130258223; Tue, 09 Oct 2018 17:10:58 -0700 (PDT) X-Google-Smtp-Source: ACcGV62AEf7p1Vi84mwDeWBbOEmAndKQjCbN6CFUWPOj/SnUwn/Lcy7gWjnYsTw0+esAKS1fyDwV X-Received: by 2002:a62:5982:: with SMTP id k2-v6mr21757895pfj.180.1539130257341; Tue, 09 Oct 2018 17:10:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130257; cv=none; d=google.com; s=arc-20160816; b=zi6/PVQpgokNovFPGwdB81Xfj3Z8pKLCDa3WMQTZwyOggsmroj2y+ijHQRYPzanWNS qQgZUxnOA2eUNOpXL4RwbtGRDl0CWGhqXXEncFiq8qi0PK7tYFwBUT9l1RYoYMGMHPKz TpcYB83QssnV71yjNzf+s12ZvEYRfeA4Wzr+w1/zvGtGBQv8tvvrTpMQ6Yst2x0jqxcM fN+RPDF0YLPpGDnTurzprW6dEYz5pA4P0UdXLwRAJetqGbXoSybyhnKcS1UIdXu0AUyw /Okn9VuyzVIb8o5DRZgqQiZ/hmgH25dr2DH0Q/r250ole1fwkIizPA86MRhg9eTWWc6H mTrw== 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=Q7WRM8cm5WCpI5pToKQWHyNcuRIx4G5Ru2lJk9SDSnU=; b=SyywrDDUAjCAAhifWBOthin1dikbMjqVAX5uIb/kLJ0Cd+THSh5vRg4NBXsJnMzvKK 2TAZtipu0bPWzZucKUopLzy9Zvyk1L3dLai5put7wznoC1xI6NYOg/4PJH+gtolrTR0O X0xPBa5xDcFAtCJMLqtfAesRo8iOItjTlCMHLLgGRTbSbRcQ7V94M638J4UiUh9ERQ/s kVH5sUATqKP+dc1EVcHNW1ueSoyaNzYNA5JZT0+yyGGwIY4w/sZQmEUACps8JAAP4EyC +wfM4vSqmO4QtbxB7WXA0avU+FPD7STaNbENDu2XK8nX888r8xrJRZWXo+JSrQ3DcbJP dmEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=sbZljqwc; 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 e8-v6si22985957pgh.447.2018.10.09.17.10.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:10:57 -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=sbZljqwc; 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 w9A08wZ2138901; Wed, 10 Oct 2018 00:10:56 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=Q7WRM8cm5WCpI5pToKQWHyNcuRIx4G5Ru2lJk9SDSnU=; b=sbZljqwctBNHKocMq4GyabetJ7oLp3SXgUT4wD8hRMNEvuCJQdSGlayZdRSpM2PK8nKh nleTKcfhSJeTUw7dAsiIq2UFPoLiouVuRmU0p1J1jeEa/wTdrtMkdt53HbOgmT2d9LN5 8VHgeXX5knLQ+IHqs2ikwvNcxkLgYmQYhforYL1HZnOEtvhfExv7xKjAPfpDdHSI6cxJ sh57K0nKKKuVf9g3z6NgjLh+/+HXUqfNFnDqAOF6mQa59EDcRMOD7sGTlrYVqHqXEMFo PP+VtZa4mAOkRz8+CM2BpRwIWl8F4ZgUaRjc1aRwbqdsMNh9L2N9Q9X7c/j9H1rkRgbB iA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mxn0q0tfu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:10:56 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0Atjv008509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:10:55 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0Askv020568; Wed, 10 Oct 2018 00:10:54 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:10:54 +0000 Subject: [PATCH 02/25] xfs: refactor clonerange preparation into a separate helper 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, Dave Chinner , linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Tue, 09 Oct 2018 17:10:52 -0700 Message-ID: <153913025230.32295.8365539801924505278.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100000 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 Refactor all the reflink preparation steps into a separate helper that we'll use to land all the upcoming fixes for insufficient input checks. This rework also moves the invalidation of the destination range to the prep function so that it is done before the range is remapped. This ensures that nobody can access the data in range being remapped until the remap is complete. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/xfs_reflink.c | 101 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 74 insertions(+), 27 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 5289e22cb081..ebd65d3e31f3 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1220,35 +1220,48 @@ xfs_iolock_two_inodes_and_break_layout( return 0; } +/* Unlock both inodes after they've been prepped for a range clone. */ +STATIC void +xfs_reflink_remap_unlock( + struct file *file_in, + struct file *file_out) +{ + struct inode *inode_in = file_inode(file_in); + struct xfs_inode *src = XFS_I(inode_in); + struct inode *inode_out = file_inode(file_out); + struct xfs_inode *dest = XFS_I(inode_out); + bool same_inode = (inode_in == inode_out); + + xfs_iunlock(dest, XFS_MMAPLOCK_EXCL); + if (!same_inode) + xfs_iunlock(src, XFS_MMAPLOCK_SHARED); + inode_unlock(inode_out); + if (!same_inode) + inode_unlock_shared(inode_in); +} + /* - * Link a range of blocks from one file to another. + * Prepare two files for range cloning. Upon a successful return both inodes + * will have the iolock and mmaplock held, the page cache of the out file + * will be truncated, and any leases on the out file will have been broken. + * Returns negative for error, 0 for nothing to do, and 1 for success. */ -int -xfs_reflink_remap_range( +STATIC int +xfs_reflink_remap_prep( struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len, + u64 *len, bool is_dedupe) { struct inode *inode_in = file_inode(file_in); struct xfs_inode *src = XFS_I(inode_in); struct inode *inode_out = file_inode(file_out); struct xfs_inode *dest = XFS_I(inode_out); - struct xfs_mount *mp = src->i_mount; bool same_inode = (inode_in == inode_out); - xfs_fileoff_t sfsbno, dfsbno; - xfs_filblks_t fsblen; - xfs_extlen_t cowextsize; ssize_t ret; - if (!xfs_sb_version_hasreflink(&mp->m_sb)) - return -EOPNOTSUPP; - - if (XFS_FORCED_SHUTDOWN(mp)) - return -EIO; - /* Lock both files against IO */ ret = xfs_iolock_two_inodes_and_break_layout(inode_in, inode_out); if (ret) @@ -1270,7 +1283,7 @@ xfs_reflink_remap_range( goto out_unlock; ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, - &len, is_dedupe); + len, is_dedupe); if (ret <= 0) goto out_unlock; @@ -1279,8 +1292,6 @@ xfs_reflink_remap_range( if (ret) goto out_unlock; - trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); - /* * Clear out post-eof preallocations because we don't have page cache * backing the delayed allocations and they'll never get freed on @@ -1297,6 +1308,51 @@ xfs_reflink_remap_range( if (ret) goto out_unlock; + /* Zap any page cache for the destination file's range. */ + truncate_inode_pages_range(&inode_out->i_data, pos_out, + PAGE_ALIGN(pos_out + *len) - 1); + return 1; +out_unlock: + xfs_reflink_remap_unlock(file_in, file_out); + return ret; +} + +/* + * Link a range of blocks from one file to another. + */ +int +xfs_reflink_remap_range( + struct file *file_in, + loff_t pos_in, + struct file *file_out, + loff_t pos_out, + u64 len, + bool is_dedupe) +{ + struct inode *inode_in = file_inode(file_in); + struct xfs_inode *src = XFS_I(inode_in); + 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; + + if (!xfs_sb_version_hasreflink(&mp->m_sb)) + return -EOPNOTSUPP; + + if (XFS_FORCED_SHUTDOWN(mp)) + return -EIO; + + /* Prepare and then clone file data. */ + ret = xfs_reflink_remap_prep(file_in, pos_in, file_out, pos_out, + &len, is_dedupe); + if (ret <= 0) + return ret; + + 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); @@ -1305,10 +1361,6 @@ xfs_reflink_remap_range( if (ret) goto out_unlock; - /* Zap any page cache for the destination file's range. */ - truncate_inode_pages_range(&inode_out->i_data, pos_out, - PAGE_ALIGN(pos_out + len) - 1); - /* * Carry the cowextsize hint from src to dest if we're sharing the * entire source file to the entire destination file, the source file @@ -1325,12 +1377,7 @@ xfs_reflink_remap_range( is_dedupe); out_unlock: - xfs_iunlock(dest, XFS_MMAPLOCK_EXCL); - if (!same_inode) - xfs_iunlock(src, XFS_MMAPLOCK_SHARED); - inode_unlock(inode_out); - if (!same_inode) - inode_unlock_shared(inode_in); + xfs_reflink_remap_unlock(file_in, file_out); if (ret) trace_xfs_reflink_remap_range_error(dest, ret, _RET_IP_); return ret; From patchwork Wed Oct 10 00:10:59 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: 10633437 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 EB7B946E4 for ; Wed, 10 Oct 2018 00:11:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D9AC829C74 for ; Wed, 10 Oct 2018 00:11:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7F5229C98; Wed, 10 Oct 2018 00:11:07 +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 A8E1E29C98 for ; Wed, 10 Oct 2018 00:11:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6EA316B0010; Tue, 9 Oct 2018 20:11:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 698CD6B0266; Tue, 9 Oct 2018 20:11:05 -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 58B9C6B0269; Tue, 9 Oct 2018 20:11:05 -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 1A34A6B0010 for ; Tue, 9 Oct 2018 20:11:05 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id i189-v6so2542361pge.6 for ; Tue, 09 Oct 2018 17:11:05 -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=cmK57nWF3xCycn+Xe37BmfeUz4DrJ92G4aMskuDnZos=; b=I5M4AY+XTX713HyiXabkTy7mnHuw5ZChaMmSvPZMtMW2K8725lk/TX1hHopMzSGDge bKQYJzEHkSrFhsXF2ETT+OWwzWwOUvlfgedLqM32IcL4QZyFi2cO3GCjWY+dARr42gXp 3Kfh30/eC4vql15UIxhEOfUFg7X4Gs2jlr/nG7hnvtLEzIEKn8IVXM1eZjBWhTuwKE/Z 3JK6qgGy5dccgg4KBbcQmTsvBqw9OaMDAa/WeDMh+Ygidx6894JMQHK/1Z6L/UrFTFaX u5Wd+2iyDCvIQUcPqIjL2VwuYkLNWQi2PoXMY2l6MMGpFXaSV7tnOQtPXri8WOBiZCf8 bxuA== X-Gm-Message-State: ABuFfogQzWpJAMpWEoZkCT6ldWS/9sHuhmXPcnEe1ArDmQlPg4mUkB6h rcdcAvg9UrD84Caxt5nfl/L8bv24H13z2qCK1FqFOyMUvcI3iFakZLYq3/59k3oy+8dvvLsyasD FnKJut8Xh6v64gIvwnPrHiwlDQSL+GDXnHnZHprH5WRPM9dVZ/DqafYQRfVTcfNdjxw== X-Received: by 2002:a62:c2c1:: with SMTP id w62-v6mr11946889pfk.35.1539130264763; Tue, 09 Oct 2018 17:11:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV61rkUV5oH4EsHfYtV9mbIwV278VofhzlthsK9vt5WKOM4voykymqzlPU8kvTQIa4IJ8JKql X-Received: by 2002:a62:c2c1:: with SMTP id w62-v6mr11946842pfk.35.1539130263998; Tue, 09 Oct 2018 17:11:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130263; cv=none; d=google.com; s=arc-20160816; b=Ph/H+Ov3BSlzehzA/Av0qTggVzOBuItfWaROO009Z1EliM5kUsxgMU6vAiRBYHwDab sjzOYXq3y3Lp+hCIcBz+EkJaCrYr7Y6ECanILAwUuona3QIRzLG7fXO0sT6GxwQ/1oeI RyEtK55dqFIkhGx0r+gOuLkYsQo/byQbugcJD3H2FR6jGyyUVY4UqKHTHbwSxVitRCIK uUzIL94whZWPJsp3+JSDDeyA/c7Pu8ETzYcBiLj2kFe7vt1DgprjK9KFeUwESr9dWOne HKbXAawikFUQC7QRvgXlwGWQeyTOAVodYftLU3RSUL0xkY1UXRuEXXjRYJkF5cZQnFIv o4gQ== 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=cmK57nWF3xCycn+Xe37BmfeUz4DrJ92G4aMskuDnZos=; b=c2Mqhg+n7TaRCgV5FBgkK/Tm5achwQfsyIwVW3ALCpbQBRN17JklRGeBNv5xw5dPb+ WBW3aviI9vriV4vIaRtL+6096Ba77Q6gBnxm+dY6b1abyRxx1iBmLKicpOZmCUIOtR79 h3DK/cRkLNAaB+uLZujLexsNC67f9lijUGr5y7preVjftkBxjUVv0XIuCD/CaedTSaLD pPgbT2Rx6SzFPJkMLg2ETxdaYks4lauSvyUzbqrA+7o2L+2jNyPOWOI72PdMj0CRTdkX qDJCYsFYnvIpbKwM5sHjNhp3p/DMm+wMhEEYXu9u1TVT/YrQxhxEd/qgID62rXC81Gn3 Y4/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=RC0YFI13; 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 o5-v6si22612144pgk.300.2018.10.09.17.11.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:11:03 -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=RC0YFI13; 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 w9A08uCI138874; Wed, 10 Oct 2018 00:11:03 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=cmK57nWF3xCycn+Xe37BmfeUz4DrJ92G4aMskuDnZos=; b=RC0YFI13Y+/d5uNT3It/7E/9kaExOdqIDbQoyV3metzGJTox2BQ/zNHz/Iqy1XSr/8Rd gETWBDOyUTEDlNCuMo0xKoA/rpz57qSduOcDRgPFOPjSnRZ+gBKO0WTICbSf74rKkaIk nPCE7QqI+Zwo6grHwFH4od2f71Ncv8KLf401L8Y3soY0x26NYOIqDC8GmrGR2N42sPjS QZK9TmByEa6m0AxOFKLhr1xkn+AZTcTnQEzIefZtsqIFUAxg6QgE9MyHVhkf9Nbu9X6X xPPuhiuNEfqfmh37cnMksE3PZGFjCMPa1+yehhlnDUkVikbmBfY/mHOE4BQp2rUJ31S1 2w== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2mxn0q0tge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:02 +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 w9A0B22o025716 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:02 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0B1ib020601; Wed, 10 Oct 2018 00:11:01 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:11:01 +0000 Subject: [PATCH 03/25] xfs: zero posteof blocks when cloning above eof 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, Zorro Lang , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, Dave Chinner , linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Tue, 09 Oct 2018 17:10:59 -0700 Message-ID: <153913025949.32295.17548471289910846210.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100000 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 When we're reflinking between two files and the destination file range is well beyond the destination file's EOF marker, zero any posteof speculative preallocations in the destination file so that we don't expose stale disk contents. The previous strategy of trying to clear the preallocations does not work if the destination file has the PREALLOC flag set. Uncovered by shared/010. Reported-by: Zorro Lang Bugzilla-id: https://bugzilla.kernel.org/show_bug.cgi?id=201259 Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/xfs_reflink.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index ebd65d3e31f3..cbb359e68a72 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1240,6 +1240,26 @@ xfs_reflink_remap_unlock( inode_unlock_shared(inode_in); } +/* + * If we're reflinking to a point past the destination file's EOF, we must + * zero any speculative post-EOF preallocations that sit between the old EOF + * and the destination file offset. + */ +static int +xfs_reflink_zero_posteof( + struct xfs_inode *ip, + loff_t pos) +{ + loff_t isize = i_size_read(VFS_I(ip)); + + if (pos <= isize) + return 0; + + trace_xfs_zero_eof(ip, isize, pos - isize); + return iomap_zero_range(VFS_I(ip), isize, pos - isize, NULL, + &xfs_iomap_ops); +} + /* * Prepare two files for range cloning. Upon a successful return both inodes * will have the iolock and mmaplock held, the page cache of the out file @@ -1293,15 +1313,12 @@ xfs_reflink_remap_prep( goto out_unlock; /* - * Clear out post-eof preallocations because we don't have page cache - * backing the delayed allocations and they'll never get freed on - * their own. + * Zero existing post-eof speculative preallocations in the destination + * file. */ - if (xfs_can_free_eofblocks(dest, true)) { - ret = xfs_free_eofblocks(dest); - if (ret) - goto out_unlock; - } + ret = xfs_reflink_zero_posteof(dest, pos_out); + if (ret) + goto out_unlock; /* Set flags and remap blocks. */ ret = xfs_reflink_set_inode_flag(src, dest); From patchwork Wed Oct 10 00:11:06 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: 10633457 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 A291717E3 for ; Wed, 10 Oct 2018 00:11:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9215529C8B for ; Wed, 10 Oct 2018 00:11:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 905CB29BED; Wed, 10 Oct 2018 00:11:13 +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 2323529C8A for ; Wed, 10 Oct 2018 00:11:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E67156B0269; Tue, 9 Oct 2018 20:11:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DC7876B026A; Tue, 9 Oct 2018 20:11:11 -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 C67346B026B; Tue, 9 Oct 2018 20:11:11 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 8759B6B0269 for ; Tue, 9 Oct 2018 20:11:11 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id f5-v6so2630943plf.11 for ; Tue, 09 Oct 2018 17:11:11 -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=dLeY25XICiLWqckKMrtV3v59Uk72O343BuPWK8wy/8U=; b=oOn1RgdM8TZQKujpn7N7alaABzsilQojPeCnCt0aenPLCw1/Qa4Ng1gz4ftC+PH4U6 dUxLgnTlk+q5S0vSXb8iqC0bJrJGLf1+/FLtPIm15LSLpCnx8oNoMm5W78507NoPZC4N lhfQWKE4Gm1NSoIKP44uq5d5z5t1oKZ3X8qAOySeXSsg9yfZ8fEKR7C6ae2tX50WDCvQ UTRgBi+WXTA4lL3PuzJhvMpYZCn5WXLIWPwO1N2/JZY/+GV0QvU9ZUfIUQKsoLjo4ubU jiNPhDsFqGfj6tndKzx9yYvxrAqYVIN/1THIS3NsFChjr1lePwTCaiumU/QEJV9DSmgg mlpw== X-Gm-Message-State: ABuFfoie3VT29i7iUtFjTd4Ox+Mg+wNtYXELUi4fqzFySMEizqwr0/i3 CP8cetsmDYGH5U+RJj8Ze5k14p+5XhBZ7/0fwbFFru4mLRTlilfp4QyjSVhUsbV2ONWoVOkLha9 7NYE2aD7WoY1GRfE9uF2W1NWGquU06PiaJG3ybFi3EpYJVtUseEE9nXtbO1xlz/UMbg== X-Received: by 2002:a17:902:bb96:: with SMTP id m22-v6mr30672382pls.117.1539130271227; Tue, 09 Oct 2018 17:11:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV622BF5q4gwLZRDbkzTGoXuTBggj1PYSauro+MCf1iJgHSzgM9l2aqH9dbIB1TrE/p8j9/Or X-Received: by 2002:a17:902:bb96:: with SMTP id m22-v6mr30672344pls.117.1539130270515; Tue, 09 Oct 2018 17:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130270; cv=none; d=google.com; s=arc-20160816; b=E+0fOOfYxx8TZL+grltmU9Sn8ohqhVzBPCadzv5/5JnGczIINDBwLH89Jmr+Xko2BA EG1TSw2AvqJ7BAwzUVZGTX4ZQQ+lSMG7/Ks9NpoL5SJVBzEehC7sDGeibGqZ+y8FkyX2 IwC1vIJO4eE6hXufxWXVpDEUhCWO6xxkofpFqWhnAWnz8nJHk7OC3K5oezPD/lBaigAf kz8xJ0xh9Bzxnf5tCd0nY6kyI7QRBe77iHLVT2ZiDtPaXX84gE008v7+3ctGoSsNM9YK N3GHPe+aa7wQysVSUrF87u+0ZNJnj4fYy5/QaJ5Eel5WY3p7QqKxglR/8kyrdiRhv/64 ZkGg== 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=dLeY25XICiLWqckKMrtV3v59Uk72O343BuPWK8wy/8U=; b=feXqJcc+IXPZHqWQYUGUsIeWu1cFpVcsjqwCiLb656Nh7zOWXAyaxe+pJL1ycnAsUx 5aMKO37IKRvp8bT08DQg4YPIUNdWE/ZogZop1fK9jfcDsdDiNP6HWDFJUjVrOAxO8ShX KF2rUj5kmvvZCXTh8eOH1dO9U4QIthcPFrMDENv/0gGYj+85KK0bCOPvMdoMRYFlMbQn QiJJ9JnZhibyh21zUfIj+vweJCj8/nLfxr+tg7u0cILuaonf6GoJdHT4UX7gdrLd9iOl 0Dm1Guy0VGnanVW6RCCdJwjCzIJMka/VoGB9w7LkTSY54sSTwKydgpNz97dqdCikJQle DqCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=4ROg8HLc; 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 z1-v6si22516285plo.59.2018.10.09.17.11.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:11:10 -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=4ROg8HLc; 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 w9A08q9u119807; Wed, 10 Oct 2018 00:11:09 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=dLeY25XICiLWqckKMrtV3v59Uk72O343BuPWK8wy/8U=; b=4ROg8HLcuay622FiB2cbzs3fYCaZnJhJaTMZVRcW7v8/0zwxlOpwHytxs00L9lzLifjE OamRxAeyzCAxQhCkOCjqXuI7pq8n46HK/tch2QaJhDAHbvbYV+zUzwPpsAxc39jRuaEl 6yodviYMrdbDVtv5EiShuPD9EgsoWsNV5kSxAydV4ahN6x4mbi8hx4aWizmNBynFt4Rd c4l26TMz4xNHg+4SLTwtNElTanXzNNWpATmX8H7Zm/SndmKvswecUPWNezWF2AprL+Wb Q7U77nyhAlJuridLWR6Z0PJTsSp+VTc9KauPB5vyP08G+K94/4kT7AlOnaXce/2aImqR Ig== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2mxmftrvg6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:09 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0B88S031503 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:09 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0B8hu002889; Wed, 10 Oct 2018 00:11:08 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:11:08 +0000 Subject: [PATCH 04/25] xfs: update ctime and remove suid before cloning files 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, Dave Chinner , linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Tue, 09 Oct 2018 17:11:06 -0700 Message-ID: <153913026644.32295.612141018276176517.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100000 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 Before cloning into a file, update the ctime and remove sensitive attributes like suid, just like we'd do for a regular file write. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/xfs_reflink.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index cbb359e68a72..d4feaeba8542 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1264,6 +1264,7 @@ xfs_reflink_zero_posteof( * Prepare two files for range cloning. Upon a successful return both inodes * will have the iolock and mmaplock held, the page cache of the out file * will be truncated, and any leases on the out file will have been broken. + * This function borrows heavily from xfs_file_aio_write_checks. * Returns negative for error, 0 for nothing to do, and 1 for success. */ STATIC int @@ -1328,6 +1329,30 @@ xfs_reflink_remap_prep( /* Zap any page cache for the destination file's range. */ truncate_inode_pages_range(&inode_out->i_data, pos_out, PAGE_ALIGN(pos_out + *len) - 1); + + /* If we're altering the file contents... */ + if (!is_dedupe) { + /* + * ...update the timestamps (which will grab the ilock again + * from xfs_fs_dirty_inode, so we have to call it before we + * take the ilock). + */ + if (!(file_out->f_mode & FMODE_NOCMTIME)) { + ret = file_update_time(file_out); + if (ret) + goto out_unlock; + } + + /* + * ...clear the security bits if the process is not being run + * by root. This keeps people from modifying setuid and setgid + * binaries. + */ + ret = file_remove_privs(file_out); + if (ret) + goto out_unlock; + } + return 1; out_unlock: xfs_reflink_remap_unlock(file_in, file_out); From patchwork Wed Oct 10 00:11: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: 10633469 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 81C6C17E3 for ; Wed, 10 Oct 2018 00:11:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F16229C92 for ; Wed, 10 Oct 2018 00:11:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 633A429C57; Wed, 10 Oct 2018 00:11:26 +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 805A129C83 for ; Wed, 10 Oct 2018 00:11:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7AF996B026B; Tue, 9 Oct 2018 20:11:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 736DA6B026C; Tue, 9 Oct 2018 20:11:24 -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 5B01D6B026D; Tue, 9 Oct 2018 20:11:24 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 183FA6B026B for ; Tue, 9 Oct 2018 20:11:24 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id s7-v6so2556849pgp.3 for ; Tue, 09 Oct 2018 17:11:24 -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=RGh5NtQDTg96POZKHr0ueTCWwKuIbxUzUPcmXpe3PxU=; b=AKRIdG2OVLonjpfgiyvZNaFwUGfa30znDYgI0pNbtktdxp3lgvm6a6hlsJigALLYaN pCycIIv9Ibeixe1ElvRMy7IstmKkWgP+yK7FC7+qNzIe9D7M7uY/jZbHUjQEua616H6w lZi1Auz7RhhUHDkfSlF6i9uunXnvfeEcAz+uDkPZjr4afZ31b1qfd2SabQrBYSbpoubH SbZnOrL20174cv2IT/9Ev1ySsUYp4zU6o+q0JSGvE/L22zbiXtPE2D3VGYfbUDRhp1pt Vwf/EIaW8JILi9aY7t7s+phegUoy+nEyU5ZzVNgRRt1AcAfyQ/ZWlB23cAt5CqxmekqU C9YA== X-Gm-Message-State: ABuFfogfNm3v1KOrra9SllR2oguTaHtIomwOkf5H96ueXk/LK1HxJcwC j7t+xDap1lXwrpA46SqwS8nDpgBsYrPHV2uBigAym5fkcEABkFEEC+sIwzo3nHZTr+MCbnI9770 gXghxnsiYyIjZs7/z5GlCG2N3PmN6p/RvD0leDgWYm3sPlqOxmNbEZEq0mt8FIO9p8A== X-Received: by 2002:a62:c42:: with SMTP id u63-v6mr32545718pfi.43.1539130283745; Tue, 09 Oct 2018 17:11:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV62WWRiqSfQaaMHl2W8Z7zAi5KMQe1qIozsgJsZEDOD8BI6Q0zT4LMn0fdU8nzUZKD/OwjNF X-Received: by 2002:a62:c42:: with SMTP id u63-v6mr32545649pfi.43.1539130282740; Tue, 09 Oct 2018 17:11:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130282; cv=none; d=google.com; s=arc-20160816; b=xycd8UIedEqEeEBq2wkCKLjejhg4cUmyq1PYCX5Ijtbmjf43GHtjGFPfcNp6rlZ98q kMUpMF+NiJdzAYXewP1rX+dDPwiPc6kMH+q9iYW3t3lZVNwqvZ7Nf1EkPLO4RktRhBQ5 bXWz5q6lsW0UiqzszYyZpunubn5r2icp1gKWv5kvvgKpl9cYhARW43trNpq6z1tUACOY Hy0gbfH6joZIt7N50NNIWGLKVgGF27i9qEJYbGEpPHFi7zzv+TJKQr0wJzkVKplno2qR NkWA/9lF4p40qiJMNZQ+1LvMwYYXa0Qc8L8br+lNzvPJzqXSBIJg2qnd2QlJZwmTa1f0 ZN5g== 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=RGh5NtQDTg96POZKHr0ueTCWwKuIbxUzUPcmXpe3PxU=; b=EuJQ3F9AO5MZn6vy5CJ3aCgqV3ZgiYfVK8S1IvVhkBsalKJuzGt+oqY84kKZZMUoTt 2pGM8I+5raJJcVLkFioVgGSdROlsrj2zlyC6ORaTCjkhyjjHOATyZMGVe+MFjQp6URLL zE4w6piDbf3w1iTkAO0jzxOEHrFiJSLSX0OrC7s/f7HRuse31sfMaWlMLpntIBCaBF9z OC0KzYpC6W36MadmoT+RLTM482sIaOYmxck9fanUL9KO3VHLtQflBiO1aMNITPIQV7oL XM6XdNXftBWngpyLwb9ywHXR9eZntBwDODzgB/crzeEJ+nTrruri6mx77Twb4RruXhUR xZeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=VtVanN8D; 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 bc5-v6si22134298plb.24.2018.10.09.17.11.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:11:22 -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=VtVanN8D; 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 w9A090mE083155; Wed, 10 Oct 2018 00:11:21 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=RGh5NtQDTg96POZKHr0ueTCWwKuIbxUzUPcmXpe3PxU=; b=VtVanN8DtXn0kXIvq3J5CXjuC0kdF/yvRSDkI1v2S5AUo1Tzc5hWCl43IFwMXrI8GIiv gF28Pu7SQAaWQtaX+0ud7NepqzZ1WkCzAL4r2EOP4kcA0UzHho3PkDaTIdJVkU/CN/8l RBsAfoLjpEtv7nXYP3X2SvjULbKz0gFemyusUAyI8qFLWzWd/SBoPCfkf6pcivKiDWnn HGBj1oB26x2jHxkRH44TmLXlJA3DZ05FvRCxXHY6ijj8Q5dIbmScMMx0jhNw6tDx/f1R c1Yhg0W2hAraJxiwgiG+8I1hruUjjpgy5qT4E5iJTpxSkSfT3P2x6+nTJRgEgkTd4Y+T xw== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2mxnpr0nyj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:21 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0BFPK031801 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:16 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0BF0Q020726; Wed, 10 Oct 2018 00:11:15 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:11:14 +0000 Subject: [PATCH 05/25] vfs: check file ranges before cloning files 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: Tue, 09 Oct 2018 17:11:13 -0700 Message-ID: <153913027326.32295.7601238218404639876.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100000 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 file range checks from vfs_clone_file_prep into a separate generic_remap_checks function so that all the checks are collected in a central location. This forms the basis for adding more checks from generic_write_checks that will make cloning's input checking more consistent with write input checking. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/ocfs2/refcounttree.c | 2 + fs/read_write.c | 53 +++++++----------------------------- fs/xfs/xfs_reflink.c | 2 + include/linux/fs.h | 9 ++++-- mm/filemap.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 89 insertions(+), 47 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 7a5ee145c733..19e03936c5e1 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4850,7 +4850,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, (OCFS2_I(inode_out)->ip_flags & OCFS2_INODE_SYSTEM_FILE)) goto out_unlock; - ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, + ret = vfs_clone_file_prep(file_in, pos_in, file_out, pos_out, &len, is_dedupe); if (ret <= 0) goto out_unlock; diff --git a/fs/read_write.c b/fs/read_write.c index 8a2737f0d61d..f7b728d4972f 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1717,12 +1717,12 @@ static int clone_verify_area(struct file *file, loff_t pos, u64 len, bool write) * Returns: 0 for "nothing to clone", 1 for "something to clone", or * the usual negative error code. */ -int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, - struct inode *inode_out, loff_t pos_out, - u64 *len, bool is_dedupe) +int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 *len, bool is_dedupe) { - loff_t bs = inode_out->i_sb->s_blocksize; - loff_t blen; + struct inode *inode_in = file_inode(file_in); + struct inode *inode_out = file_inode(file_out); loff_t isize; bool same_inode = (inode_in == inode_out); int ret; @@ -1740,10 +1740,7 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) return -EINVAL; - /* Are we going all the way to the end? */ isize = i_size_read(inode_in); - if (isize == 0) - return 0; /* Zero length dedupe exits immediately; reflink goes to EOF. */ if (*len == 0) { @@ -1754,36 +1751,11 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, *len = isize - pos_in; } - /* Ensure offsets don't wrap and the input is inside i_size */ - if (pos_in + *len < pos_in || pos_out + *len < pos_out || - pos_in + *len > isize) - return -EINVAL; - - /* Don't allow dedupe past EOF in the dest file */ - if (is_dedupe) { - loff_t disize; - - disize = i_size_read(inode_out); - if (pos_out >= disize || pos_out + *len > disize) - return -EINVAL; - } - - /* If we're linking to EOF, continue to the block boundary. */ - if (pos_in + *len == isize) - blen = ALIGN(isize, bs) - pos_in; - else - blen = *len; - - /* Only reflink if we're aligned to block boundaries */ - if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_in + blen, bs) || - !IS_ALIGNED(pos_out, bs) || !IS_ALIGNED(pos_out + blen, bs)) - return -EINVAL; - - /* Don't allow overlapped reflink within the same file */ - if (same_inode) { - if (pos_out + blen > pos_in && pos_out < pos_in + blen) - return -EINVAL; - } + /* Check that we don't violate system file offset limits. */ + ret = generic_remap_checks(file_in, pos_in, file_out, pos_out, len, + is_dedupe); + if (ret) + return ret; /* Wait for the completion of any pending IOs on both files */ inode_dio_wait(inode_in); @@ -1816,7 +1788,7 @@ int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, return 1; } -EXPORT_SYMBOL(vfs_clone_file_prep_inodes); +EXPORT_SYMBOL(vfs_clone_file_prep); int do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 len) @@ -1854,9 +1826,6 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in, if (ret) return ret; - if (pos_in + len > i_size_read(inode_in)) - return -EINVAL; - ret = file_in->f_op->clone_file_range(file_in, pos_in, file_out, pos_out, len); if (!ret) { diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index d4feaeba8542..a4a7b2d9c8a1 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1303,7 +1303,7 @@ xfs_reflink_remap_prep( if (IS_DAX(inode_in) || IS_DAX(inode_out)) goto out_unlock; - ret = vfs_clone_file_prep_inodes(inode_in, pos_in, inode_out, pos_out, + ret = vfs_clone_file_prep(file_in, pos_in, file_out, pos_out, len, is_dedupe); if (ret <= 0) goto out_unlock; diff --git a/include/linux/fs.h b/include/linux/fs.h index 897eae8faee1..ba93a6e7dac4 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1825,9 +1825,9 @@ extern ssize_t vfs_readv(struct file *, const struct iovec __user *, unsigned long, loff_t *, rwf_t); extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, loff_t, size_t, unsigned int); -extern int vfs_clone_file_prep_inodes(struct inode *inode_in, loff_t pos_in, - struct inode *inode_out, loff_t pos_out, - u64 *len, bool is_dedupe); +extern int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 *count, bool is_dedupe); extern int do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 len); extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in, @@ -2967,6 +2967,9 @@ extern int sb_min_blocksize(struct super_block *, int); extern int generic_file_mmap(struct file *, struct vm_area_struct *); extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *); +extern int generic_remap_checks(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + uint64_t *count, bool is_dedupe); extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); diff --git a/mm/filemap.c b/mm/filemap.c index 52517f28e6f4..14041a8468ba 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2974,6 +2974,76 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from) } EXPORT_SYMBOL(generic_write_checks); +/* + * Performs necessary checks before doing a clone. + * + * Can adjust amount of bytes to clone. + * Returns appropriate error code that caller should return or + * zero in case the clone should be allowed. + */ +int generic_remap_checks(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + uint64_t *req_count, bool is_dedupe) +{ + struct inode *inode_in = file_in->f_mapping->host; + struct inode *inode_out = file_out->f_mapping->host; + unsigned long limit = rlimit(RLIMIT_FSIZE); + uint64_t count = *req_count; + uint64_t bcount; + loff_t size_in, size_out; + loff_t bs = inode_out->i_sb->s_blocksize; + + /* The start of both ranges must be aligned to an fs block. */ + if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_out, bs)) + return -EINVAL; + + /* Ensure offsets don't wrap. */ + if (pos_in + count < pos_in || pos_out + count < pos_out) + return -EINVAL; + + size_in = i_size_read(inode_in); + size_out = i_size_read(inode_out); + + /* Dedupe requires both ranges to be within EOF. */ + if (is_dedupe && + (pos_in >= size_in || pos_in + count > size_in || + pos_out >= size_out || pos_out + count > size_out)) + return -EINVAL; + + /* Ensure the infile range is within the infile. */ + if (pos_in >= size_in) + return -EINVAL; + count = min(count, size_in - (uint64_t)pos_in); + + /* + * If the user wanted us to link to the infile's EOF, round up to the + * next block boundary for this check. + * + * Otherwise, make sure the count is also block-aligned, having + * already confirmed the starting offsets' block alignment. + */ + if (pos_in + count == size_in) { + bcount = ALIGN(size_in, bs) - pos_in; + } else { + if (!IS_ALIGNED(count, bs)) + return -EINVAL; + + bcount = count; + } + + /* Don't allow overlapped cloning within the same file. */ + if (inode_in == inode_out && + pos_out + bcount > pos_in && + pos_out < pos_in + bcount) + return -EINVAL; + + /* For now we don't support changing the length. */ + if (*req_count != count) + return -EINVAL; + + return 0; +} + int pagecache_write_begin(struct file *file, struct address_space *mapping, loff_t pos, unsigned len, unsigned flags, struct page **pagep, void **fsdata) From patchwork Wed Oct 10 00:11:20 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: 10633471 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 DC2C016B1 for ; Wed, 10 Oct 2018 00:11:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBDCB29C64 for ; Wed, 10 Oct 2018 00:11:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9CDA29CA1; Wed, 10 Oct 2018 00:11:28 +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 51AC129C64 for ; Wed, 10 Oct 2018 00:11:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 713556B026D; Tue, 9 Oct 2018 20:11:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 69DC06B026E; Tue, 9 Oct 2018 20:11:26 -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 51C816B026F; Tue, 9 Oct 2018 20:11:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 029696B026D for ; Tue, 9 Oct 2018 20:11:26 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id 8-v6so3237783pfr.0 for ; Tue, 09 Oct 2018 17:11:25 -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=UPZ0d5EyyxBIdyb+/QZEk2VIco+d0Uqne8UVSJH846Y=; b=hmVBCh2ltfbUkvcI2RfXxixbn6lcQRr6aVX7BPPx23YCN9XG8DaOo542iKSna9Srdu SZdQrYSP19dhZ8HupOLQw0mlzzKLWSZXUdJY7hhXQRNjKV90yvU4GtE75sj/0tfY7bvB eVvNfJq3LC1T3ki7Tfm89J78h11VQ0EAsGBCVMBdu3kVhcAtB/qZBOnPqSJavJ6AA/9Y LykVsDIOOjdbGDldLKOtZhrhgNRbwnSdaNWnOvTbXD366GWJcqwpLV4v59B/YkaOeop6 WCZpFYAJmO3j1GFqhyk9SSoWQdbzXyW/WoNkfZs/OAanc6TAEUldjhoynKcs3CcyyLqI HiPA== X-Gm-Message-State: ABuFfog4vX/PWA8oojl4QskfzWMFkiCqpgLcu0GhqOxu0cRvLVBshyAl qU8vk19sRpJVy6ztqucaG+PGUXPpZMZDByoGnwKeUQOfDgmRAC2acEe1q8kEHoo4st8Im1AzqSq UUvCjdQGdjlOwSHu8h7iHo1EEkKkJ6/yC1tsdKuKvKrkHsG2FGhSDvvFJu9IUvPelvw== X-Received: by 2002:a62:4ec9:: with SMTP id c192-v6mr32139868pfb.221.1539130285672; Tue, 09 Oct 2018 17:11:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV62nsCUMLiZyOMaf2EYSFPqfgsGN1ncd7yki0LAs8fjhPMolzpFRDtvwOzdyZKWjiEIgNMIw X-Received: by 2002:a62:4ec9:: with SMTP id c192-v6mr32139814pfb.221.1539130284746; Tue, 09 Oct 2018 17:11:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130284; cv=none; d=google.com; s=arc-20160816; b=P8BdM/xhcwPC4B5aHkcO6cRhyA4tVAYx4hWdZgRmHihILFS+s7y2KtoIqwtp2LyQku YvDMjILG3QCZXg+QqLoPekq1ZBn822wVHayRp792C14cH5c2/pooX4YQo4QcUQLsgeUm TlUc5Esgaj+zaBfowNx98Z4JYtjC4if04/a22kJC1KoKvwOy5t7bdJhYjOnsJy2aYby/ SZWBEgULFyBfWkbWMfYVYKh2QOyemkrBqtc7mvS8YcLneJb9AJSh6HacaiiX0BcPbhX8 YrRkWMFSvFTvr1vBDptdUJXrHh1q6h5Lw2YoFiwl+Wy63/ZZ/s6gSq/aMaNr3GtVqYzd Vw9w== 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=UPZ0d5EyyxBIdyb+/QZEk2VIco+d0Uqne8UVSJH846Y=; b=HYLYrtjzviVCs/G6ZT6Vo46+/eAUdA4UNwd4kKIzRTjzWZeFO41vQslQTMjTmTA6D4 MivqzdA18dDpnVktxjAiBo7Xo/2HlylfjUBtX8k6Z4oa9d2L/IYeOIsMjZ8z6PChFns8 g7FnmEzmChpca8T3qzJ2qbfL6PupM/006vYEilFExKCgb2RT/hCzoqNqPCoqCGWQdOYm +IDy7xwpteOo129D0MyjT0S0pmB/wA/aaAylPqIaWHSPYBpoIPIFWx0BQLjc+l1EzbNt c2a+hn8vo+R1F52uhqGBezxZF5Sq53pYHmCdAIZIjOHpe5d63+nmhCv3jP1vUSRVDYLh XoKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=zijFNAT9; 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 f9-v6si25660578plm.126.2018.10.09.17.11.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:11:24 -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=zijFNAT9; 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 w9A08ekx138543; Wed, 10 Oct 2018 00:11:23 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=UPZ0d5EyyxBIdyb+/QZEk2VIco+d0Uqne8UVSJH846Y=; b=zijFNAT9z+gw/MI8d1eVXf3jMsCTgjhryhyCdeq6HhqEzQ1EtXkYHagwhAVTNqJJkaJo R9ZE0JZiE0Oa9smd0U066iCUML432vrYFnjzYfCnsHQQ2Fluq1zANB0SuT8talkjS/l4 AFwIV8HLs5vBTY3V1YHgZjNfCfU1t6OqLbqHEtwrd6k+ccJbluWbQblZSFU6KORkLLfW jm4l9tdM+OSKrpky4EitobilSWcztg/PUhzQuPrteT8r3d+SjXkkgDXXr6KS1ZmuFuXP EA5ILI/AeOFLm4ZtxS/FQAvuiHvAo1X5y5+WkhJnAOYg9RlqNDQsbSSuDg16hhMqOU9x Ew== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2mxn0q0tgx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:23 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0BMFB023816 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:23 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0BMw9020784; Wed, 10 Oct 2018 00:11:22 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:11:21 +0000 Subject: [PATCH 06/25] vfs: strengthen checking of file range inputs to generic_remap_checks 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: Tue, 09 Oct 2018 17:11:20 -0700 Message-ID: <153913028015.32295.15993665528948323051.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100000 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 File range remapping, if allowed to run past the destination file's EOF, is an optimization on a regular file write. Regular file writes that extend the file length are subject to various constraints which are not checked by range cloning. This is a correctness problem because we're never allowed to touch ranges that the page cache can't support (s_maxbytes); we're not supposed to deal with large offsets (MAX_NON_LFS) if O_LARGEFILE isn't set; and we must obey resource limits (RLIMIT_FSIZE). Therefore, add these checks to the new generic_remap_checks function so that we curtail unexpected behavior. Signed-off-by: Darrick J. Wong --- mm/filemap.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/mm/filemap.c b/mm/filemap.c index 14041a8468ba..59056bd9c58a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2974,6 +2974,27 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from) } EXPORT_SYMBOL(generic_write_checks); +static int +generic_remap_check_limits(struct file *file, loff_t pos, uint64_t *count) +{ + struct inode *inode = file->f_mapping->host; + + /* Don't exceed the LFS limits. */ + if (unlikely(pos + *count > MAX_NON_LFS && + !(file->f_flags & O_LARGEFILE))) { + if (pos >= MAX_NON_LFS) + return -EFBIG; + *count = min(*count, MAX_NON_LFS - (uint64_t)pos); + } + + /* Don't operate on ranges the page cache doesn't support. */ + if (unlikely(pos >= inode->i_sb->s_maxbytes)) + return -EFBIG; + + *count = min(*count, inode->i_sb->s_maxbytes - (uint64_t)pos); + return 0; +} + /* * Performs necessary checks before doing a clone. * @@ -2992,6 +3013,7 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, uint64_t bcount; loff_t size_in, size_out; loff_t bs = inode_out->i_sb->s_blocksize; + int ret; /* The start of both ranges must be aligned to an fs block. */ if (!IS_ALIGNED(pos_in, bs) || !IS_ALIGNED(pos_out, bs)) @@ -3015,6 +3037,23 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, return -EINVAL; count = min(count, size_in - (uint64_t)pos_in); + /* Don't exceed RLMIT_FSIZE in the file we're writing into. */ + if (limit != RLIM_INFINITY) { + if (pos_out >= limit) { + send_sig(SIGXFSZ, current, 0); + return -EFBIG; + } + count = min(count, limit - (uint64_t)pos_out); + } + + ret = generic_remap_check_limits(file_in, pos_in, &count); + if (ret) + return ret; + + ret = generic_remap_check_limits(file_out, pos_out, &count); + if (ret) + return ret; + /* * If the user wanted us to link to the infile's EOF, round up to the * next block boundary for this check. From patchwork Wed Oct 10 00:11:27 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: 10633495 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 33BEB17E3 for ; Wed, 10 Oct 2018 00:11:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2127229BED for ; Wed, 10 Oct 2018 00:11:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F31529CA1; Wed, 10 Oct 2018 00:11:39 +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 ADC4729BED for ; Wed, 10 Oct 2018 00:11:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A20DB6B026F; Tue, 9 Oct 2018 20:11:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9A70E6B0270; Tue, 9 Oct 2018 20:11:37 -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 848F56B0271; Tue, 9 Oct 2018 20:11:37 -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 41F086B026F for ; Tue, 9 Oct 2018 20:11:37 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id i76-v6so3227242pfk.14 for ; Tue, 09 Oct 2018 17:11:37 -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=wh5HxGg/bRAL9efUSGh+2qdh0v0M5Mja7JnBFsFMIMQ=; b=oLvD5SDoKE6ZXIOCeS83vo4y0g+564YhOnB9ja2bZSoTCGPgHnxqbt2YlmiCz5l2Sm rCxRUpflqECRmh0emhnfOEdlAPaUyzuE8zAce0NgQNhV5Ww0/qB2M5EneuaW7X3bn+QZ mAyDpwujxjToHvu8/dzQgXTdzLhil1LkSkvPqFg2LMVC/fC5I3J8DB14134bMC1NooVu 89i4ET58bDtaY93L91l1cxP4vixFEtAX2d9lnl0v4I+vD/6oHrwdNzjTZqlq+OGPsAa6 nRIMc228AjQRabIIKHaeidLPq68pJ6TtyxhiS1AYj9/dQEaKmAfKaqeLPxq44P580Gaq tNdA== X-Gm-Message-State: ABuFfojIZhkt1HW0Fj0CLGBXtBe36uwldrPHItApSEurn5ckRzJhIiR+ /uXIuxWp38VOA+rLw4Sdnz/d1hoVoxMAYCVzRsHX59ldg3Olwn1gBp8MlBVHZvlqjDP6nEBj2qY VxLI8q/ygja4oBm36s34o2G0PlUGE22vwtZsEhidG6LvwDZKYiDW83+IRHVyKhwbNGA== X-Received: by 2002:aa7:880d:: with SMTP id c13-v6mr17913564pfo.251.1539130296949; Tue, 09 Oct 2018 17:11:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV61hZKLpvLPggaiFh8DpMFQlXjsbzQuAUPwuT8SS7BxCOwbkFQVLqL5xw5/v9RYAC2nkCVHb X-Received: by 2002:aa7:880d:: with SMTP id c13-v6mr17913515pfo.251.1539130296283; Tue, 09 Oct 2018 17:11:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130296; cv=none; d=google.com; s=arc-20160816; b=MhwP+RGPRSgRjwVTtEyV7oZdQFOj0YkI4sXcriPomun4xJKC3cDn3VClN31av/Wo+j M2H8GFKUa4E1Bi6OkPiC1YVmGf0+FrWd655De0q4Y5p4r7HOujZZqxuloM2HHIKLb3pC t0V12o8Z5uKMAf4Hpmf3OL2y3e18xHoL03TF2jNLCedA3krwAS+ZWd8nhXuKaGBprRJz o82UM/ToRMrTvx3Qdbmc5SNmXYVF4iylmcQ3TFerA6JRZgHUm4LCiNdl4V3if9G49wXL 3aA7AXNiEsoDyov5yI2O4wifzmGVVE3KCRWWLq1SogmB9vxK+lFbqx5vzP8sjWdDoZVf z18g== 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=wh5HxGg/bRAL9efUSGh+2qdh0v0M5Mja7JnBFsFMIMQ=; b=v04B1Cf5UswcJbXzQO2brn6M9y30/h5hzovSfRI5XJG/iyFvzYWP8xSEfqLo5FWTz3 KqtOFnpVeAiZJzPgs2WXWQ72kmUvNtKxoL2QVK9QBvyuorZhl9+TKF6gIBALmRU7U0Bk npXIi7zzvqZBKRyVpZYUgSHfiZYlzm+ie9ckiYKZ42c9Xf2nKtveXhB2pGT7OBQvvTJQ vhnoBCVwsLbOp155m1HYPMtbcSBNvqUpMT+8RC8zyYlsG/MOiy7C37GV8OjUuf9ZOK4O 8Dj5Nmky+T72KRRvbnB4S7QkDmp4PLt+vaGLpzSJ2OjNWqSL2QbhcWt9bxezXJj+mdF0 gX3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="tvvi/USr"; 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 x186-v6si24643467pfx.19.2018.10.09.17.11.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:11:36 -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="tvvi/USr"; 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 w9A08pp2119795; Wed, 10 Oct 2018 00:11:35 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=wh5HxGg/bRAL9efUSGh+2qdh0v0M5Mja7JnBFsFMIMQ=; b=tvvi/USrB+UZhF1IqRPQW03XnX5YXlupLYSoDIJmEVbQW50dZu/gkDL9pBzj3hKmXzI3 NjnJ0sAQyVqELWbjSH5H48gNDd4qRyTHYnMqFwJ2H1fXwBltN5194xWACxT964HxDZUC /4B1SAp2SNTtyo1YpO0QoWSPeCLr/Xb8UFKa3faLJ8mV5Zkf8lVtCZudD8GoM0BYD2SZ 8a1d+L9LcR2WPFYnEKHli6oBxEQUxsBYxG9ABemqtIMD9lnqLuKLWbF63pc7HWyR9HDx YvDr3MqnNMsg6YLDQIr/qYCcmToZC/zj63xiD/lGBRuCFnjHA2JnBKy8T/NOHT3k1OER yQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2mxmftrvgh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:35 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0BYIO009889 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:34 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0BXDK003326; Wed, 10 Oct 2018 00:11:33 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:11:33 +0000 Subject: [PATCH 07/25] vfs: skip zero-length dedupe requests 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: Tue, 09 Oct 2018 17:11:27 -0700 Message-ID: <153913028716.32295.15849395030883190383.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=725 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100000 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 Don't bother calling the filesystem for a zero-length dedupe request; we can return zero and exit. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/read_write.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index f7b728d4972f..3ff90b3315fb 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1975,6 +1975,11 @@ int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, if (!dst_file->f_op->dedupe_file_range) goto out_drop_write; + if (len == 0) { + ret = 0; + goto out_drop_write; + } + ret = dst_file->f_op->dedupe_file_range(src_file, src_pos, dst_file, dst_pos, len); out_drop_write: From patchwork Wed Oct 10 00:11:38 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: 10633513 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 0FF3717E3 for ; Wed, 10 Oct 2018 00:11:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F0A8629CAE for ; Wed, 10 Oct 2018 00:11:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2AEC29CA1; Wed, 10 Oct 2018 00:11:47 +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 98DE629CC8 for ; Wed, 10 Oct 2018 00:11:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DA8C6B0271; Tue, 9 Oct 2018 20:11:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5609C6B0272; Tue, 9 Oct 2018 20:11:45 -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 3DD586B0273; Tue, 9 Oct 2018 20:11:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id DD5B56B0271 for ; Tue, 9 Oct 2018 20:11:44 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id e3-v6so2661622pld.13 for ; Tue, 09 Oct 2018 17:11:44 -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=AU74YTTFPhR2Y/iS4WoohVsmFzvsfdLDAMsxgxo34cc=; b=ht4UsdHd7zcFQ/tNynzMc9ErIDCXg2xUAfuajvd8lWsUqc0VbKf35UliY0/PXG9D2p LODoS5AGNYuwRE1AMJvy7ycJeknaz0zb6UVRC0Zw2zMxlpXT/+2YeeJ2mwpPsCrYzK0b 1hZit4su/1nwjVtCA1zo6SZypxuAVtsZI7P9iAi6Qmld6WF2sd9eNf3i9SPqh35bJRGZ qTbW/u/PJsB9Uv2XbhPgARrgYQ2IqwtydphgY0Itcx4hc6kHlqJjOFdiwPnKhGG875rs 0XlIs2Kz/SCRrNJPhUoLdUt1LXV2y0PtHeePsVjpLFG73SgpJVShe+iutt8WxrKnh6ak 0QJw== X-Gm-Message-State: ABuFfoi/y1okRiPFwAUZVvUCAyLBi6ZIVr038EdXQ89H9jXKUdg9RrY3 i9N5xLoox/A9Jw1s2JTtUXP++QJ1OC8hdXTE3nBjsmUfT+d+GeSqD4rvFi8WfB/uRJTdd/g3xee VLOYsj1Y7OR2qgYObxnMSO1VEZk/7t/6vDhS01JpBQYOyn1shUorRywBH/K1WDGEIIA== X-Received: by 2002:a62:6c4:: with SMTP id 187-v6mr31828026pfg.109.1539130304516; Tue, 09 Oct 2018 17:11:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV60qm2P6ubi0QWdmkP5GEdvBVsyHqX9OH2jIMmUTRZzDZhacLzQtzOq5ZgCEzafdeHoOvUju X-Received: by 2002:a62:6c4:: with SMTP id 187-v6mr31827926pfg.109.1539130303121; Tue, 09 Oct 2018 17:11:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130303; cv=none; d=google.com; s=arc-20160816; b=vv695ziDHinMNuXCyB5L5oYiguddKM7hbjMp6RMUmEDxhjIAK9SNI4ho/TUuhScxqX efM/rYntVrw0QWEm0M0DNAh/8Tq+DwBnF+F1vb9XXRi6BWRxUVp2psVZDy4zgs8NsZf3 4QzB5tABir3wc3T7CkHrKnYxnAHpps7SQHnNb4en0z0hWgLbT0xgvhLsVPu8vy2EfmTJ TDYXZMeQgmYHG/2S0g++c9fnRnVDC79pY/JrzfMIq52X0HRz1SIpJ0odKSiUpjQz35pn St76y1G9Grm8dSKDp9buPvNDdRjQxfMvya8zRiaVHWfhVoOgwXwCbDSEaXWzUhGJzkA9 rNWA== 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=AU74YTTFPhR2Y/iS4WoohVsmFzvsfdLDAMsxgxo34cc=; b=JO2O9y11zRwmbyMBsf7Unc4fj+TRN0OFRwFSngvZk27lQwwC1UbR7SWPdHYZEcbyRp OtP8qdA21pO6olBwp2ilSzSGOQT1gM2etiLUZ1kup5Ac9BCBu74+y6IMsPH/iKPVTCbm Vw7CuvrKplP+DZMXBFHT9beuHiD8HL6WAsP6+J2yIPb6D/yXj+5jnwxCc50yLBDZfNP4 Nex9CKLZu/C2NeZPVzAll14ZFhY8G/TKdgOFeWuB1hKdlaM7DRel12roqRSB4/05jYVQ gOMM+QAAXfNfkki9a1OeqaN2eVa/dYYqt9vl1lZEsGCdILZPigpshLENgDqD58nk+pWW pT0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="tT/Wdlhu"; 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 p126-v6si23925518pfb.77.2018.10.09.17.11.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:11:43 -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="tT/Wdlhu"; 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 w9A08vij083132; Wed, 10 Oct 2018 00:11:42 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=AU74YTTFPhR2Y/iS4WoohVsmFzvsfdLDAMsxgxo34cc=; b=tT/WdlhuIjTfB9j5jrUAx42dEjaqPzsCK8L9uM0WeMBBszJj+4lV1ev9vjug0iLlGqSg JihNVbiBiZDnlsirBxqFMPfLS11FMvV1HGt4RmGEHQDBXQpB56m69mH0+yUOp9h3hqc4 MuhW5RM+IIZu5zVBCgCvTYK+Z4dWYBEs5IrMsCP7yxB9yxmaqUFuLWmIIDNScE3YPnr9 AcPFjO1i7PNHTEkiYSTc1YlElzlMZVCEgS5QDOrssYiUXHMIHlvbkMW67SqUsMS9yPu3 UUhRUGWbz6KKwzfSk4AvU8qP4f0LkTf7hY7NRDUbHqjswi118gjB1z+ST6lvPsCtyC/p 6g== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2mxnpr0p0n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:42 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0Bev7032466 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:41 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0BeFm016009; Wed, 10 Oct 2018 00:11:40 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:11:40 +0000 Subject: [PATCH 08/25] vfs: combine the clone and dedupe into a single remap_file_range 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: Tue, 09 Oct 2018 17:11:38 -0700 Message-ID: <153913029885.32295.7399525233513945673.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100000 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 Combine the clone_file_range and dedupe_file_range operations into a single remap_file_range file operation dispatch since they're fundamentally the same operation. The differences between the two can be made in the prep functions. Signed-off-by: Darrick J. Wong --- Documentation/filesystems/vfs.txt | 12 ++++------- fs/btrfs/ctree.h | 8 +++---- fs/btrfs/file.c | 3 +-- fs/btrfs/ioctl.c | 42 ++++++++++++++++++------------------- fs/cifs/cifsfs.c | 22 +++++++++++-------- fs/nfs/nfs4file.c | 10 ++++++--- fs/ocfs2/file.c | 23 +++++--------------- fs/overlayfs/file.c | 27 ++++++++++++------------ fs/read_write.c | 18 ++++++++-------- fs/xfs/xfs_file.c | 22 ++++--------------- include/linux/fs.h | 13 ++++++++--- 11 files changed, 92 insertions(+), 108 deletions(-) diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index a6c6a8af48a2..120fd72c87be 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -883,8 +883,9 @@ struct file_operations { unsigned (*mmap_capabilities)(struct file *); #endif ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, loff_t, size_t, unsigned int); - int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, u64); - int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t, u64); + int (*remap_file_range)(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 len, unsigned int flags); int (*fadvise)(struct file *, loff_t, loff_t, int); }; @@ -960,11 +961,8 @@ otherwise noted. copy_file_range: called by the copy_file_range(2) system call. - clone_file_range: called by the ioctl(2) system call for FICLONERANGE and - FICLONE commands. - - dedupe_file_range: called by the ioctl(2) system call for FIDEDUPERANGE - command. + remap_file_range: called by the ioctl(2) system call for FICLONERANGE and + FICLONE and FIDEDUPERANGE commands to remap file ranges. fadvise: possibly called by the fadvise64() system call. diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 2cddfe7806a4..a79783a713f0 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3218,9 +3218,6 @@ void btrfs_get_block_group_info(struct list_head *groups_list, struct btrfs_ioctl_space_info *space); void btrfs_update_ioctl_balance_args(struct btrfs_fs_info *fs_info, struct btrfs_ioctl_balance_args *bargs); -int btrfs_dedupe_file_range(struct file *src_file, loff_t src_loff, - struct file *dst_file, loff_t dst_loff, - u64 olen); /* file.c */ int __init btrfs_auto_defrag_init(void); @@ -3250,8 +3247,9 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages, size_t num_pages, loff_t pos, size_t write_bytes, struct extent_state **cached); int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end); -int btrfs_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len); +int btrfs_remap_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, u64 len, + unsigned int flags); /* tree-defrag.c */ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 2be00e873e92..9a963f061393 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -3269,8 +3269,7 @@ const struct file_operations btrfs_file_operations = { #ifdef CONFIG_COMPAT .compat_ioctl = btrfs_compat_ioctl, #endif - .clone_file_range = btrfs_clone_file_range, - .dedupe_file_range = btrfs_dedupe_file_range, + .remap_file_range = btrfs_remap_file_range, }; void __cold btrfs_auto_defrag_exit(void) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index d60b6caf09e8..e22b294fa25b 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3627,26 +3627,6 @@ static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen, return ret; } -int btrfs_dedupe_file_range(struct file *src_file, loff_t src_loff, - struct file *dst_file, loff_t dst_loff, - u64 olen) -{ - struct inode *src = file_inode(src_file); - struct inode *dst = file_inode(dst_file); - u64 bs = BTRFS_I(src)->root->fs_info->sb->s_blocksize; - - if (WARN_ON_ONCE(bs < PAGE_SIZE)) { - /* - * Btrfs does not support blocksize < page_size. As a - * result, btrfs_cmp_data() won't correctly handle - * this situation without an update. - */ - return -EINVAL; - } - - return btrfs_extent_same(src, src_loff, olen, dst, dst_loff); -} - static int clone_finish_inode_update(struct btrfs_trans_handle *trans, struct inode *inode, u64 endoff, @@ -4348,9 +4328,27 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src, return ret; } -int btrfs_clone_file_range(struct file *src_file, loff_t off, - struct file *dst_file, loff_t destoff, u64 len) +int btrfs_remap_file_range(struct file *src_file, loff_t off, + struct file *dst_file, loff_t destoff, u64 len, + unsigned int flags) { + if (flags & RFR_IDENTICAL_DATA) { + struct inode *src = file_inode(src_file); + struct inode *dst = file_inode(dst_file); + u64 bs = BTRFS_I(src)->root->fs_info->sb->s_blocksize; + + if (WARN_ON_ONCE(bs < PAGE_SIZE)) { + /* + * Btrfs does not support blocksize < page_size. As a + * result, btrfs_cmp_data() won't correctly handle + * this situation without an update. + */ + return -EINVAL; + } + + return btrfs_extent_same(src, off, len, dst, destoff); + } + return btrfs_clone_files(dst_file, src_file, off, len, destoff); } diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 7065426b3280..bf971fd7cab2 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -975,8 +975,9 @@ const struct inode_operations cifs_symlink_inode_ops = { .listxattr = cifs_listxattr, }; -static int cifs_clone_file_range(struct file *src_file, loff_t off, - struct file *dst_file, loff_t destoff, u64 len) +static int cifs_remap_file_range(struct file *src_file, loff_t off, + struct file *dst_file, loff_t destoff, u64 len, + unsigned int flags) { struct inode *src_inode = file_inode(src_file); struct inode *target_inode = file_inode(dst_file); @@ -986,6 +987,9 @@ static int cifs_clone_file_range(struct file *src_file, loff_t off, unsigned int xid; int rc; + if (flags & RFR_IDENTICAL_DATA) + return -EOPNOTSUPP; + cifs_dbg(FYI, "clone range\n"); xid = get_xid(); @@ -1134,7 +1138,7 @@ const struct file_operations cifs_file_ops = { .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .setlease = cifs_setlease, .fallocate = cifs_fallocate, }; @@ -1153,7 +1157,7 @@ const struct file_operations cifs_file_strict_ops = { .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .setlease = cifs_setlease, .fallocate = cifs_fallocate, }; @@ -1172,7 +1176,7 @@ const struct file_operations cifs_file_direct_ops = { .splice_write = iter_file_splice_write, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .llseek = cifs_llseek, .setlease = cifs_setlease, .fallocate = cifs_fallocate, @@ -1191,7 +1195,7 @@ const struct file_operations cifs_file_nobrl_ops = { .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .setlease = cifs_setlease, .fallocate = cifs_fallocate, }; @@ -1209,7 +1213,7 @@ const struct file_operations cifs_file_strict_nobrl_ops = { .llseek = cifs_llseek, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .setlease = cifs_setlease, .fallocate = cifs_fallocate, }; @@ -1227,7 +1231,7 @@ const struct file_operations cifs_file_direct_nobrl_ops = { .splice_write = iter_file_splice_write, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .llseek = cifs_llseek, .setlease = cifs_setlease, .fallocate = cifs_fallocate, @@ -1239,7 +1243,7 @@ const struct file_operations cifs_dir_ops = { .read = generic_read_dir, .unlocked_ioctl = cifs_ioctl, .copy_file_range = cifs_copy_file_range, - .clone_file_range = cifs_clone_file_range, + .remap_file_range = cifs_remap_file_range, .llseek = generic_file_llseek, .fsync = cifs_dir_fsync, }; diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index 4288a6ecaf75..a93aa225c454 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -180,8 +180,9 @@ static long nfs42_fallocate(struct file *filep, int mode, loff_t offset, loff_t return nfs42_proc_allocate(filep, offset, len); } -static int nfs42_clone_file_range(struct file *src_file, loff_t src_off, - struct file *dst_file, loff_t dst_off, u64 count) +static int nfs42_remap_file_range(struct file *src_file, loff_t src_off, + struct file *dst_file, loff_t dst_off, u64 count, + unsigned int flags) { struct inode *dst_inode = file_inode(dst_file); struct nfs_server *server = NFS_SERVER(dst_inode); @@ -190,6 +191,9 @@ static int nfs42_clone_file_range(struct file *src_file, loff_t src_off, bool same_inode = false; int ret; + if (flags & RFR_IDENTICAL_DATA) + return -EOPNOTSUPP; + /* check alignment w.r.t. clone_blksize */ ret = -EINVAL; if (bs) { @@ -262,7 +266,7 @@ const struct file_operations nfs4_file_operations = { .copy_file_range = nfs4_copy_file_range, .llseek = nfs4_file_llseek, .fallocate = nfs42_fallocate, - .clone_file_range = nfs42_clone_file_range, + .remap_file_range = nfs42_remap_file_range, #else .llseek = nfs_file_llseek, #endif diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 9fa35cb6f6e0..5da278edf189 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2527,24 +2527,15 @@ static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int whence) return offset; } -static int ocfs2_file_clone_range(struct file *file_in, +static int ocfs2_remap_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len) + u64 len, + unsigned int flags) { return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, false); -} - -static int ocfs2_file_dedupe_range(struct file *file_in, - loff_t pos_in, - struct file *file_out, - loff_t pos_out, - u64 len) -{ - return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, true); + len, flags & RFR_IDENTICAL_DATA); } const struct inode_operations ocfs2_file_iops = { @@ -2586,8 +2577,7 @@ const struct file_operations ocfs2_fops = { .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = ocfs2_fallocate, - .clone_file_range = ocfs2_file_clone_range, - .dedupe_file_range = ocfs2_file_dedupe_range, + .remap_file_range = ocfs2_remap_file_range, }; const struct file_operations ocfs2_dops = { @@ -2633,8 +2623,7 @@ const struct file_operations ocfs2_fops_no_plocks = { .splice_read = generic_file_splice_read, .splice_write = iter_file_splice_write, .fallocate = ocfs2_fallocate, - .clone_file_range = ocfs2_file_clone_range, - .dedupe_file_range = ocfs2_file_dedupe_range, + .remap_file_range = ocfs2_remap_file_range, }; const struct file_operations ocfs2_dops_no_plocks = { diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 986313da0c88..693bd0620a81 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -489,26 +489,28 @@ static ssize_t ovl_copy_file_range(struct file *file_in, loff_t pos_in, OVL_COPY); } -static int ovl_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len) +static int ovl_remap_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 len, unsigned int flags) { - return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, 0, - OVL_CLONE); -} + enum ovl_copyop op; + + if (flags & RFR_IDENTICAL_DATA) + op = OVL_DEDUPE; + else + op = OVL_CLONE; -static int ovl_dedupe_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len) -{ /* * Don't copy up because of a dedupe request, this wouldn't make sense * most of the time (data would be duplicated instead of deduplicated). */ - if (!ovl_inode_upper(file_inode(file_in)) || - !ovl_inode_upper(file_inode(file_out))) + if (op == OVL_DEDUPE && + (!ovl_inode_upper(file_inode(file_in)) || + !ovl_inode_upper(file_inode(file_out)))) return -EPERM; return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, 0, - OVL_DEDUPE); + op); } const struct file_operations ovl_file_operations = { @@ -525,6 +527,5 @@ const struct file_operations ovl_file_operations = { .compat_ioctl = ovl_compat_ioctl, .copy_file_range = ovl_copy_file_range, - .clone_file_range = ovl_clone_file_range, - .dedupe_file_range = ovl_dedupe_file_range, + .remap_file_range = ovl_remap_file_range, }; diff --git a/fs/read_write.c b/fs/read_write.c index 3ff90b3315fb..a33c8503f12e 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1588,9 +1588,9 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, * Try cloning first, this is supported by more file systems, and * more efficient if both clone and copy are supported (e.g. NFS). */ - if (file_in->f_op->clone_file_range) { - ret = file_in->f_op->clone_file_range(file_in, pos_in, - file_out, pos_out, len); + if (file_in->f_op->remap_file_range) { + ret = file_in->f_op->remap_file_range(file_in, pos_in, + file_out, pos_out, len, 0); if (ret == 0) { ret = len; goto done; @@ -1815,7 +1815,7 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in, (file_out->f_flags & O_APPEND)) return -EBADF; - if (!file_in->f_op->clone_file_range) + if (!file_in->f_op->remap_file_range) return -EOPNOTSUPP; ret = clone_verify_area(file_in, pos_in, len, false); @@ -1826,8 +1826,8 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in, if (ret) return ret; - ret = file_in->f_op->clone_file_range(file_in, pos_in, - file_out, pos_out, len); + ret = file_in->f_op->remap_file_range(file_in, pos_in, + file_out, pos_out, len, 0); if (!ret) { fsnotify_access(file_in); fsnotify_modify(file_out); @@ -1972,7 +1972,7 @@ int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, goto out_drop_write; ret = -EINVAL; - if (!dst_file->f_op->dedupe_file_range) + if (!dst_file->f_op->remap_file_range) goto out_drop_write; if (len == 0) { @@ -1980,8 +1980,8 @@ int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, goto out_drop_write; } - ret = dst_file->f_op->dedupe_file_range(src_file, src_pos, - dst_file, dst_pos, len); + ret = dst_file->f_op->remap_file_range(src_file, src_pos, dst_file, + dst_pos, len, RFR_IDENTICAL_DATA); out_drop_write: mnt_drop_write_file(dst_file); diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 61a5ad2600e8..74ad73231ea4 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -920,27 +920,16 @@ xfs_file_fallocate( } STATIC int -xfs_file_clone_range( +xfs_file_remap_range( struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len) + u64 len, + unsigned int flags) { return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, false); -} - -STATIC int -xfs_file_dedupe_range( - struct file *file_in, - loff_t pos_in, - struct file *file_out, - loff_t pos_out, - u64 len) -{ - return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, true); + len, flags & RFR_IDENTICAL_DATA); } STATIC int @@ -1175,8 +1164,7 @@ const struct file_operations xfs_file_operations = { .fsync = xfs_file_fsync, .get_unmapped_area = thp_get_unmapped_area, .fallocate = xfs_file_fallocate, - .clone_file_range = xfs_file_clone_range, - .dedupe_file_range = xfs_file_dedupe_range, + .remap_file_range = xfs_file_remap_range, }; const struct file_operations xfs_dir_file_operations = { diff --git a/include/linux/fs.h b/include/linux/fs.h index ba93a6e7dac4..6fedfe4fb5ef 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1721,6 +1721,12 @@ struct block_device_operations; #define NOMMU_VMFLAGS \ (NOMMU_MAP_READ | NOMMU_MAP_WRITE | NOMMU_MAP_EXEC) +/* + * These flags control the behavior of the remap_file_range function pointer. + * + * RFR_IDENTICAL_DATA: only remap if contents identical (i.e. deduplicate) + */ +#define RFR_IDENTICAL_DATA (1 << 0) struct iov_iter; @@ -1759,10 +1765,9 @@ struct file_operations { #endif ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, loff_t, size_t, unsigned int); - int (*clone_file_range)(struct file *, loff_t, struct file *, loff_t, - u64); - int (*dedupe_file_range)(struct file *, loff_t, struct file *, loff_t, - u64); + int (*remap_file_range)(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 len, unsigned int flags); int (*fadvise)(struct file *, loff_t, loff_t, int); } __randomize_layout; From patchwork Wed Oct 10 00:11:45 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: 10633531 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 CD1C517E3 for ; Wed, 10 Oct 2018 00:11:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BC50F29CD7 for ; Wed, 10 Oct 2018 00:11:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA9A429CDB; Wed, 10 Oct 2018 00:11:53 +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 37A9629CC9 for ; Wed, 10 Oct 2018 00:11:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F27F26B0273; Tue, 9 Oct 2018 20:11:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EB0CD6B0274; Tue, 9 Oct 2018 20:11:51 -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 D52B46B0275; Tue, 9 Oct 2018 20:11:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 8E0976B0273 for ; Tue, 9 Oct 2018 20:11:51 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id f59-v6so2658828plb.5 for ; Tue, 09 Oct 2018 17:11:51 -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=MFRIwz6CBqFVERKzCNBTAbGcC1anU5teARhXCpG9dhQ=; b=EuvNOO770FJaV47bs25ZcXZEQ0ecbJrCQdmKMWIHjgnR6Yeh/i0Uwep31abhp2i1SE 2JYScaQX3FkkR9rrXKEVzBbrlCAJSswtWNQNnv0ZhlYyUJERNtfG03SeYTee1cZBmkfU oEp2wTnV4RKDvOpCfrIJ95cxT5TihXaALkxzmCvgc+i80XcFciJ2aIFFer+d8FNQ3FCC mr//m6kqCYXjIjRBri3ceCtqX6G0uDdEtZ186TgFpC9KGvJbkJZ9s50IHecOTkjnE1YO 1anissjCCCjG9DbbcQ1QCbRBpFwYCOs6GIxtsN9G4HLvss4exP3oXi4EHzlwOR60sPx1 veWw== X-Gm-Message-State: ABuFfogFruaTLb1UOatj8l5VoBo2etDRtCFac88507Uf5KMS+6XakVxd qnjE370ASRrORpSvrz2V2QJNtZkQNcSqBaD098hvD8eAJL2jmobf+/WBI1co7fpl0KZRmiEUmIE oUKuMOpMM/B1z3/ZCtrEja9534hP8vyFdWzDJTZztUUAOCbX/kvjABp6QZFMZmKOXWg== X-Received: by 2002:a62:70c7:: with SMTP id l190-v6mr31978209pfc.186.1539130311158; Tue, 09 Oct 2018 17:11:51 -0700 (PDT) X-Google-Smtp-Source: ACcGV60th2ddkwPxX99/9qk3RnLf/Ty8Ohsj9K3OTCaSgjDaZ0Svf0H+sjVbrVhEH7pyVNPnZVhv X-Received: by 2002:a62:70c7:: with SMTP id l190-v6mr31978146pfc.186.1539130310375; Tue, 09 Oct 2018 17:11:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130310; cv=none; d=google.com; s=arc-20160816; b=pBLmsS7uQGNrLR0eShACOwwvl0Tod9fOMwrhw//WhX6zsqm9H8jX9rj6Pc7RoPn2TZ H0oS3sXewtd7fzhb+Zo2kfxorscGF1QNQQiydZ+JfLvDeBEloxblMnHb1gciin93FowK iWk+ocTc97scFQRcQO9U7qZPtn33FJgH4zhssdeM41uQDPDG0MWscZoODzIzl5EhQPEF dVpQFEUT0y/cHj6uIeZ+DLG2rai7GkJwFEJc0p1kOTj6DXEDxAb9l8wu1COpogVKH5C1 /FfYtOacGnIvp3QHt4CHDBB2TnyfkqEkLmWjPGiNJHcfXUj56/KNCdGypThuQkCEK59l A0vw== 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=MFRIwz6CBqFVERKzCNBTAbGcC1anU5teARhXCpG9dhQ=; b=qIsUHNNw5JO5qn7kQW6LFUmX8219X8j1sxwqxI1LQTTPTTLwCywCKaS2T/B464O3Bv zaVuO9SbigbIOpD19jShU/z7eXoDtA17fCwxCCLMUv/S5MWAB7LThNmZwR8ysrpCsuSA WWck7Jr/4qqOeLYDy6K3E4pHc3bvviI83nR5DgAiMj4fCK/4JDI5Gsp+F1aj4vCy4T1z 7YfSLO++u1rHVN/upu7aMtANaInuLu3FKZB91KQ6Swis5vYWbCSUvsHrV65LM0Rw4dXh 2anwIy31fatnU7a6hCFqDYJUTCLeY8P051vRcP4Tc5gmyVhQB+3vhIn09Cd9Uu683TKr yFvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=3UbwYI6o; 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 x1-v6si19082805plb.132.2018.10.09.17.11.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:11:50 -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=3UbwYI6o; 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 w9A08Z06138530; Wed, 10 Oct 2018 00:11:49 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=MFRIwz6CBqFVERKzCNBTAbGcC1anU5teARhXCpG9dhQ=; b=3UbwYI6o8zuAm1YHNg4j48vh8tw6hhgMDh2mod00P5l18lD+iIErI+hNvaWVN1TvtZyM S9Exu7FsQvCNPXzShBzsJbtxAqRIceiWCO+8K3WpgmWtcI7apLpXfKzyJSgTndHJWrK/ CMp9R/I1d1tk8f/t7wPC8R2h6sQS5GdYcPwMPo7ecc9gXc3KBPVXNH/NJvrw1bRCrV1l 3oyFb0jFqBhxsEjKVS9xR8irJSNa9r0SJczzImMCeH0KhS+ePOJ1bmCvqfLWberEHPVc KXnn1rKiSbn0uF6Wf7zyIW8UUPYGHQRDEyF6muwVyeBr1kdBuN51qfYn3szujmGDar4V xg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2mxn0q0tj1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:49 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0Bm5q032650 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:11:48 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0BlMu020940; Wed, 10 Oct 2018 00:11:47 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:11:47 +0000 Subject: [PATCH 09/25] vfs: rename vfs_clone_file_prep to be more descriptive 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: Tue, 09 Oct 2018 17:11:45 -0700 Message-ID: <153913030578.32295.3542082209724064016.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=782 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100000 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 The vfs_clone_file_prep is a generic function to be called by filesystem implementations only. Rename the prefix to generic_ and make it more clear that it applies to remap operations, not just clones. Signed-off-by: Darrick J. Wong --- fs/ocfs2/refcounttree.c | 2 +- fs/read_write.c | 8 ++++---- fs/xfs/xfs_reflink.c | 2 +- include/linux/fs.h | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 19e03936c5e1..36c56dfbe485 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4850,7 +4850,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, (OCFS2_I(inode_out)->ip_flags & OCFS2_INODE_SYSTEM_FILE)) goto out_unlock; - ret = vfs_clone_file_prep(file_in, pos_in, file_out, pos_out, + ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, &len, is_dedupe); if (ret <= 0) goto out_unlock; diff --git a/fs/read_write.c b/fs/read_write.c index a33c8503f12e..4ea81ea7d78d 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1717,9 +1717,9 @@ static int clone_verify_area(struct file *file, loff_t pos, u64 len, bool write) * Returns: 0 for "nothing to clone", 1 for "something to clone", or * the usual negative error code. */ -int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, - u64 *len, bool is_dedupe) +int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 *len, bool is_dedupe) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); @@ -1788,7 +1788,7 @@ int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, return 1; } -EXPORT_SYMBOL(vfs_clone_file_prep); +EXPORT_SYMBOL(generic_remap_file_range_prep); int do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 len) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index a4a7b2d9c8a1..4cf1e52efbff 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1303,7 +1303,7 @@ xfs_reflink_remap_prep( if (IS_DAX(inode_in) || IS_DAX(inode_out)) goto out_unlock; - ret = vfs_clone_file_prep(file_in, pos_in, file_out, pos_out, + ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, len, is_dedupe); if (ret <= 0) goto out_unlock; diff --git a/include/linux/fs.h b/include/linux/fs.h index 6fedfe4fb5ef..d8f90bdd34e2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1830,9 +1830,9 @@ extern ssize_t vfs_readv(struct file *, const struct iovec __user *, unsigned long, loff_t *, rwf_t); extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, loff_t, size_t, unsigned int); -extern int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, - u64 *count, bool is_dedupe); +extern int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + u64 *count, bool is_dedupe); extern int do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 len); extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in, From patchwork Wed Oct 10 00:11:52 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: 10633645 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 284CB17E3 for ; Wed, 10 Oct 2018 00:14:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17307284C9 for ; Wed, 10 Oct 2018 00:14:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B15028F95; Wed, 10 Oct 2018 00:14:14 +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 9DC32284C9 for ; Wed, 10 Oct 2018 00:14:13 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 477C36B0285; Tue, 9 Oct 2018 20:14:12 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 401076B0286; Tue, 9 Oct 2018 20:14:12 -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 2C8846B0287; Tue, 9 Oct 2018 20:14:12 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id D8A506B0285 for ; Tue, 9 Oct 2018 20:14:11 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id o18-v6so2529686pgv.14 for ; Tue, 09 Oct 2018 17:14:11 -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=qoHfXTGN73w1yOvbXxBgoMbXWKug5+dBd9AX7FAJxDk=; b=kk6rgv/Sx8DwyoEZji1sgW907VOc1u9cBjjM4mn9m3LX/gQrrqI2eWSDN3SsCHi6oL FRsVvCL07/qw0Tpj/zeiyt0f4GFBTGu7krTOQZwNPbXv7PscdJoF/B/Nmv0pvHbZYp/Z rqaooRF1ESilefoj+jC0tj1+yDrQCZz/TMhFPXysVXtMB+MV1a4NRhafj7+48gl863g6 Nm5fHgDkZ184y63kT/Y4o1YL1u12v3vW2nAQgYRAzSt/iRzIEVVcOeceHtheMgdoyMVe Yz9LFIXuBEdYH3wKeE9WIZ9UdqRcHL51HSpVk7Vn64S6DCJJhAdVK9yL9k8jU9l4bohi ZL+g== X-Gm-Message-State: ABuFfohN6pMlq2QGMkoEoKV2dydrfSI8/cBCjC6mPSSN5eIGVI8vSLvo pxkBbRqCtsc5Ij/Ul//9bI+vJps+xNF9HHDHcUn0cD3BHrqsKeHclWI2pwHv3KaqSC2VE+xb5Eu oY6X/TEBFrVGiLG6YhYxfQ/JM5v07NVtItJIDl7TQCg/rDVIXjoGklqjeTVTZygYoLA== X-Received: by 2002:a17:902:3064:: with SMTP id u91-v6mr30315813plb.176.1539130451497; Tue, 09 Oct 2018 17:14:11 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Am9xP7bJ9uAlUMDPkDZQEov/5f0G5EEmQ/bHPPm4DgxQ2zn26An+dCBtgjiokLri73inT X-Received: by 2002:a17:902:3064:: with SMTP id u91-v6mr30315771plb.176.1539130450860; Tue, 09 Oct 2018 17:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130450; cv=none; d=google.com; s=arc-20160816; b=b5Cc8d6T3MFejYetgOMuqD/r8oAfPaXy5aiUwuhGVhuh+wfMg6D8ShyMpW+PtACrZ9 KgDU5pnTWml4kl79NSUaRsF7dkd+i7jWyES5a7qPSfNRDzSKwn9cEg5RyWe2Ksddl/TM 9xTi68poSX1vhceEJ1+c6ZOB27Z2QDYYTuDpqEqgsq8NHQ9NIs9WfR9YTqzy/XFg/VkL EFec9izoJVFNYGTDlfgFVIGnwPf3/Tus41UjHnACK+uyhJcWau3jM2PkzijlRVVXLZmU Bdr+xEUcvdqP1ZYsmvTd63hqp29e5TrkY7REQCu55HEU7lwdOxrfIS4eImpk62CReHNr E9zA== 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=qoHfXTGN73w1yOvbXxBgoMbXWKug5+dBd9AX7FAJxDk=; b=uqWN5Qjedw3NmPB9WTtNWHI91ISHchgqgxJja22lh2atlvl5h4iWL4x2WkZX/ACNXB d8mfp6OycqvyrXgfhdxmrFiZ2v9wdmVM80ExJeBBW6uZ5yhLV5tjX9Qmt8dricOsZA09 EYIUP6WwyhPRImwEdf2HJb78SJOSjsxZgtm/1rfuA0QHyG8td+UuAt1qL/wZDrC7TPTl o2xUKkcIqeWuqKnb/sk0Ej5iJ2xMej+R6vHJPlLZsSSqlnLNO+IFnJQKfP5v0ncfx/e0 UEPahJXBIwsFZoHm441g/EK40sxWJpNrGpNf4hlzm18+E6EgT/FMUmyKO5SomyQHW9YB 3z8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="JnVcx/7I"; 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 d11-v6si20296135pgg.91.2018.10.09.17.14.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:14:10 -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="JnVcx/7I"; 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 w9A0Dh8s086475; Wed, 10 Oct 2018 00:14:10 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=qoHfXTGN73w1yOvbXxBgoMbXWKug5+dBd9AX7FAJxDk=; b=JnVcx/7IBOgzjbUMaZ0SRGU0eV6V6tVYy9v1BMhcDeQA00pDS3ijQ6u/9QgCPpWKY9Rz VDgWJcG8P1MQfLbKBR4qkmEl05PZeIP7bN2BCmCWbgA7fChng1Kpf9g74Zu3R29EYsow s8vlNPVTuQKwy1c7le2KWmZVvbCWCk5NFotmPNi2CZ5tzWf+GuIDuftdrWvZv8MHAvt0 B2pt4kB/NSiIc0B6IkCp8Lqkb0yJMx88TVUJ53uFdzLS9R5zsaYh+GmgFgoXCERrNT52 AB/zA+pM5jYSXpbv1nUD1JjFee2Q2UZl8sUS0DuK9AHkyhdhRCjo1jzQgpXTW7f+nMLu jg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2mxnpr0p88-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:10 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0E9aV031137 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:09 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0DKTr017179; Wed, 10 Oct 2018 00:13:26 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:12:49 +0000 Subject: [PATCH 10/25] vfs: rename clone_verify_area to remap_verify_area 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: Tue, 09 Oct 2018 17:11:52 -0700 Message-ID: <153913031261.32295.9177776550062804985.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=706 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 we use clone_verify_area for both clone and dedupe range checks, rename the function to make it clear that it's for both. Signed-off-by: Darrick J. Wong --- fs/read_write.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 4ea81ea7d78d..b4acfb45d916 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1686,7 +1686,7 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, return ret; } -static int clone_verify_area(struct file *file, loff_t pos, u64 len, bool write) +static int remap_verify_area(struct file *file, loff_t pos, u64 len, bool write) { struct inode *inode = file_inode(file); @@ -1818,11 +1818,11 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in, if (!file_in->f_op->remap_file_range) return -EOPNOTSUPP; - ret = clone_verify_area(file_in, pos_in, len, false); + ret = remap_verify_area(file_in, pos_in, len, false); if (ret) return ret; - ret = clone_verify_area(file_out, pos_out, len, true); + ret = remap_verify_area(file_out, pos_out, len, true); if (ret) return ret; @@ -1955,7 +1955,7 @@ int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, if (ret) return ret; - ret = clone_verify_area(dst_file, dst_pos, len, true); + ret = remap_verify_area(dst_file, dst_pos, len, true); if (ret < 0) goto out_drop_write; @@ -2017,7 +2017,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) if (!S_ISREG(src->i_mode)) goto out; - ret = clone_verify_area(file, off, len, false); + ret = remap_verify_area(file, off, len, false); if (ret < 0) goto out; ret = 0; From patchwork Wed Oct 10 00:13:06 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: 10633549 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 4295816B1 for ; Wed, 10 Oct 2018 00:13:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D880284C9 for ; Wed, 10 Oct 2018 00:13:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1DE6228C31; Wed, 10 Oct 2018 00:13:19 +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 853C2284C9 for ; Wed, 10 Oct 2018 00:13:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8E7186B0277; Tue, 9 Oct 2018 20:13:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 86D7D6B0278; Tue, 9 Oct 2018 20:13:17 -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 710F76B0279; Tue, 9 Oct 2018 20:13:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 2C0096B0277 for ; Tue, 9 Oct 2018 20:13:17 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id 8-v6so3240686pfr.0 for ; Tue, 09 Oct 2018 17:13:17 -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=Nl7YIofRRChjcrmNR29R1ufLWDq1ojIHa7FYh4XBYYI=; b=TWMg8YrLGgNxW9EufO/I+rvNKnkRBsY1TyHXWh8D8u7lEIbTDDY8zUnoUy2NWk8yJT 41LTiJWr0co4nk98eqIYmAiypikFJRxl1523JacSDeO2ooowXcMMHEe3M1Ugy70rP1sp K9Bpguzp3RcB5Adhi9WUx2eqxC9DYhelK0c7yQRD8qhk8YBf0uAQ6IxTDDqj8e4A/iiJ xQ7hT+HtZa6KWrkjY/lTvdAKLb4NT8RsoJkwC3ZTWetlHwW9ni6KieFTqWjI98BDS4P3 iafOBvqiqjNx6JdynxefIGyNeu5may3u2iAwdXCsfcloPAsG1qkXY6TRzNKU2CfPs4IT tjXg== X-Gm-Message-State: ABuFfoh9t2eBx1WG3SMwLQZZ+CykBBq1zzSqS7KSAANv8YvcFj7WqbdR YGg6vwddoDblqwKPp0s8E3F5g2W1DcKJgPj1h3i/mgclenmbA+YY7uIEyLTohN8EGkiqBEWd2tk IkMoSkAcVYGcLniFZdSF9lUskpvUaVYJBiYyM9nGgD9BdP8ITvbN3dOBKki+Cwj4L7Q== X-Received: by 2002:a62:b604:: with SMTP id j4-v6mr32394732pff.199.1539130396799; Tue, 09 Oct 2018 17:13:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV62TqMkubpKRQ3pCtgdweR7k87Q4/qGWAYWLIxFz+8OyfI1PR5gomkTl/z51w/iDEp2C+Vs9 X-Received: by 2002:a62:b604:: with SMTP id j4-v6mr32394685pff.199.1539130395978; Tue, 09 Oct 2018 17:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130395; cv=none; d=google.com; s=arc-20160816; b=iUWMWmxjI2UL748elebZQ+x73ws0HoEAGbKx4bJqqmGC00HLaW3OqGhOXapJzVrCw+ /111EirjYrphf2EW9P4q0g6bnwF19A2EHGPjFjb8oZ+G0DMe5adjP3AAU8ur6Nx4dRww IlJvVIdHLInWYVJn20T/H7aW3npwyZkcydZHOP/MumG32mhKxAo31/SRW5tmXyjTHk8y MKsyWul4FiLIxzqrHhtwCVqOs6Zg9g+m6ax4p+y3c4a/cCjLXKCNCMBYn+RIVjsX+nzW VrdwyS8TIwae7Vyv3x48b61GfSK/Hz9jSeGLt34EBLKQOZsZIYYSnOAfPPT+V+KBN6uF aeyQ== 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=Nl7YIofRRChjcrmNR29R1ufLWDq1ojIHa7FYh4XBYYI=; b=f4FLNj/wPEX67ugfTe4mLRPiaivSsgQLA05sJm0Bcj20dup5ytrO+rAV2ebY6H9dvo dU0kv9PoKGVi3Ag3dNuB55HP4AkJJg/uRi3v1uQJhIRYfwPjMV+omNuqSUubPgWGItSA 1ans1Si4RTcNf1ddN8g/VqtY+EOggNLDBDWVkXm4070Fx612r01ud+waUgvVYCBToYSf 70gjrkSq9o+ikyKj49yOz2/EnuZw601Fm13RMaDw4ts5HayF8XdhU7tHHCXuU/+72wEW b/8/dLTnXarXrEj9wuvG/bh3FBwx6PqnSIygYryWwlTEY0tcodIDhnE4yszhc9efaHMk ZGjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Jr1HMN44; 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 k9-v6si23537429pfg.57.2018.10.09.17.13.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:13:15 -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=Jr1HMN44; 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 w9A08bwF083047; Wed, 10 Oct 2018 00:13:15 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=Nl7YIofRRChjcrmNR29R1ufLWDq1ojIHa7FYh4XBYYI=; b=Jr1HMN44d0gF/DymgWS2ST5eID/yTRT++1jMdP95477AjHkR2NpINGiZtch+SJSqvPRG ZNcz1Vte3xMbO+zwgu/Ng3ni4okCFXEpvOMDs2ZKM25myCmGk1pUX8CvicCphOJ+hUlU eoaEDlGnmRvUUprKYGBv30jcQQihlQ7KEzm55qXi5vZXM5nJQSxbyAqhSjjkXjSso30z +XDtVtWnLce+cYiNoOvJa35l4LUuNSiNfMT20MPuL17niqKoHwNk8yhJHgPxav+FvvNb vrg3gNmX0vVh2TK7agJzETkL/d/NfnLmPP9nKbq0Ky5qsAkhDV0F2L1Eiy1HoBaYmazx hA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2mxnpr0p5y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:15 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0D9Mi013369 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:09 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0D8GO003654; Wed, 10 Oct 2018 00:13:08 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:13:08 +0000 Subject: [PATCH 11/25] vfs: create generic_remap_file_range_touch to update inode metadata 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: Tue, 09 Oct 2018 17:13:06 -0700 Message-ID: <153913038664.32295.8625558259109244112.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100000 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 Create a new VFS helper to handle inode metadata updates when remapping into a file. If the operation can possibly alter the file contents, we must update the ctime and mtime and remove security privileges, just like we do for regular file writes. Wire up ocfs2 to ensure consistent behavior. Signed-off-by: Darrick J. Wong --- fs/ocfs2/refcounttree.c | 8 ++++++++ fs/read_write.c | 24 ++++++++++++++++++++++++ fs/xfs/xfs_reflink.c | 29 +++++++---------------------- include/linux/fs.h | 1 + 4 files changed, 40 insertions(+), 22 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 36c56dfbe485..ee1ed11379b3 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4855,6 +4855,14 @@ int ocfs2_reflink_remap_range(struct file *file_in, if (ret <= 0) goto out_unlock; + /* + * Update inode timestamps and remove security privileges before we + * take the ilock. + */ + ret = generic_remap_file_range_touch(file_out, is_dedupe); + if (ret) + goto out_unlock; + /* Lock out changes to the allocation maps and remap. */ down_write(&OCFS2_I(inode_in)->ip_alloc_sem); if (!same_inode) diff --git a/fs/read_write.c b/fs/read_write.c index b4acfb45d916..020bb7fdf431 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1790,6 +1790,30 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, } EXPORT_SYMBOL(generic_remap_file_range_prep); +/* Update inode timestamps and remove security privileges when remapping. */ +int generic_remap_file_range_touch(struct file *file, bool is_dedupe) +{ + int ret; + + /* If can't alter the file contents, we're done. */ + if (is_dedupe) + return 0; + + /* Update the timestamps, since we can alter file contents. */ + if (!(file->f_mode & FMODE_NOCMTIME)) { + ret = file_update_time(file); + if (ret) + return ret; + } + + /* + * Clear the security bits if the process is not being run by root. + * This keeps people from modifying setuid and setgid binaries. + */ + return file_remove_privs(file); +} +EXPORT_SYMBOL(generic_remap_file_range_touch); + int do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 len) { diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 4cf1e52efbff..0d67b2d0b3d4 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1330,28 +1330,13 @@ xfs_reflink_remap_prep( truncate_inode_pages_range(&inode_out->i_data, pos_out, PAGE_ALIGN(pos_out + *len) - 1); - /* If we're altering the file contents... */ - if (!is_dedupe) { - /* - * ...update the timestamps (which will grab the ilock again - * from xfs_fs_dirty_inode, so we have to call it before we - * take the ilock). - */ - if (!(file_out->f_mode & FMODE_NOCMTIME)) { - ret = file_update_time(file_out); - if (ret) - goto out_unlock; - } - - /* - * ...clear the security bits if the process is not being run - * by root. This keeps people from modifying setuid and setgid - * binaries. - */ - ret = file_remove_privs(file_out); - if (ret) - goto out_unlock; - } + /* + * Update inode timestamps and remove security privileges before we + * take the ilock. + */ + ret = generic_remap_file_range_touch(file_out, is_dedupe); + if (ret) + goto out_unlock; return 1; out_unlock: diff --git a/include/linux/fs.h b/include/linux/fs.h index d8f90bdd34e2..661b9ef32d2b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1833,6 +1833,7 @@ extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, extern int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 *count, bool is_dedupe); +extern int generic_remap_file_range_touch(struct file *file, bool is_dedupe); extern int do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 len); extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in, From patchwork Wed Oct 10 00:13:15 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: 10633561 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 0B11817E3 for ; Wed, 10 Oct 2018 00:13:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB5F0284C9 for ; Wed, 10 Oct 2018 00:13:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DF11028C31; Wed, 10 Oct 2018 00:13:22 +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 14F14284C9 for ; Wed, 10 Oct 2018 00:13:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9FA0D6B0279; Tue, 9 Oct 2018 20:13:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 97F8B6B027A; Tue, 9 Oct 2018 20:13:20 -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 7FBAA6B027B; Tue, 9 Oct 2018 20:13:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 3533A6B0279 for ; Tue, 9 Oct 2018 20:13:20 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id f4-v6so3240763pff.2 for ; Tue, 09 Oct 2018 17:13:20 -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=neB4kQpFJgnl2vzLhhe4wDul9sX90AxeByw/6GBvuH8=; b=NZV5E7n0rygnuT9ad1pinscZXyprpp/bW5NRNhkBS0PwaUijiGSMWLZ1HFuVAm7Zxe 0CmR/UGB3gx1za++J9t52DWf5Qa825Mpfot8Vukj6foqjjY9MH/rEEF+8jaFNFN6C8hC 9LsB2gM/bOxEokSwO8etEwS1hnwiX+fWpKNsXn1q0bpHp4x5gFFJnXQNy7SecgRGVMr7 XzZ5EwcrgXgcT5CWz7uR4R2rGvzzPepRb62s4ZcoVAp9GgZAUOKqV+sHt9lhRJg+ITqv 2Sgtcl8h1VuACjQ90IAcvCuK+1iWbpU2QwLcM+o6mAfrpY+lGa+fZ2qIBqoHLq7pbzeb TtBg== X-Gm-Message-State: ABuFfoiL/vll3hX7xoR+RDj9qklXKsdPhGmJWTMnZ0iMS/VVwdDJmtg3 /law8Fmh6sEX5SF/ab5Np8wak41Q6qJoNA/N2o2L1exwWbgQgjYPUjGq0pHZPCIpDg3auioHlAs WavMNO4aq/EpxAYU27VwZmKouVhClxN+V9Lf/JUEhWnwPpSGTDtTPtFMmsDrCfrxHWQ== X-Received: by 2002:a63:ac56:: with SMTP id z22-v6mr27799412pgn.444.1539130399825; Tue, 09 Oct 2018 17:13:19 -0700 (PDT) X-Google-Smtp-Source: ACcGV62rziKrVRtr/c1qV5ActcnYj+Wg3iwVxc4rNXgXA671gp0gdBAebO9jRbdjXzJJRYGroLah X-Received: by 2002:a63:ac56:: with SMTP id z22-v6mr27799342pgn.444.1539130398806; Tue, 09 Oct 2018 17:13:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130398; cv=none; d=google.com; s=arc-20160816; b=mkGzWLmTKlJqqmiMj5ObhhBfHbyZbtN8yD0MfK++RgYK0C32HBw8xR883WAGn1GQt+ 0JtgPFpmGUtFvJsj1pSvKy+iqIpxNt0aKmP4WFRD/eIYL3u80tLNwBTOsIuUuqOmnaBQ QN+LEbNN5t7eM+ydTLvsZkiz7ZNudAMBv2UI3ZNdPXOZ9/8WBn3e1dVR3fiik2eBcXrG 3jUrXn78/XTS9Az5z8J4P18Z2dLE+B1yvxWT6eUnu+/SHJe9ddueiWOtLrdZA+A3ofjL MiwI1BbPyy+6lY4RFc1LGr6u2eey9hdRgSbHS8maTUQxseiBY7BHK3iLVMzA4frz0JNb kVYg== 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=neB4kQpFJgnl2vzLhhe4wDul9sX90AxeByw/6GBvuH8=; b=M/dlftuCE99zZZ4lwxH1AxMGfY1cmkkHnNORtUw1UYo8wXtsaUhY3Y0CHhrLlnib2U KQW5/maV+LSus4elOR6WLxDNn1fSZHv/wThiYXv2+A9PhBFfpbQDqp/ARgjqTE7R0E8q NOBY4V7/ifAvYw4aJ6ah+K55+DJe8eKRofU6jKFeq0JhUpyWXAOzi5u4E00pDN+QIXHf D0L0aw6ouMNl5V9H9b+89i1BZyEDEi1A7mCqoM/CNLZVSJ2xeBTyCbxJUbtcDuIQAp7t hxdKB9BVHKs/DHzC/vpdIeGr2stQJq6MuFXBTixzD8LEeYlCVLJmGY1oZA1oP1jkv/PH 7zqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=kTu3TOIy; 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 w18-v6si5814963pfg.70.2018.10.09.17.13.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:13: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=kTu3TOIy; 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 w9A08irK119775; Wed, 10 Oct 2018 00:13:18 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=neB4kQpFJgnl2vzLhhe4wDul9sX90AxeByw/6GBvuH8=; b=kTu3TOIyPNzDLWrJ2HB1cStUwxbF5jCW2hd7eAVLBPGm253NlxZPTKmXlGMc0ujVW5m9 RzczClO3Zrj/qfvYc0k89LoUA8xOuEaOvypP3Vyx5R/5FNTD2XAuKxBDur2skYzVyb91 CPJ/sxVAOTSf7Rd/O6ri5qix46X9ZHVjUYTakWPoC1YC4+QyHSHdhpgvZLeetyz8PTds CeGdrx0k6UJhj+3ECh7E0ypNt5YAbhFDElYgssjfHHOHf0wHptM9OB3QgmsjU8oQwly1 1iPJR73j3b8wwURfpPy5QXr20kFbeCmV11LwIb5p5Ap4WpB97k+CGlmtQE5JM3Mgo6Hl CQ== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2mxmftrvnw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:18 +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 w9A0DGan003420 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:17 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0DG62005491; Wed, 10 Oct 2018 00:13:16 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:13:16 +0000 Subject: [PATCH 12/25] vfs: pass remap flags to generic_remap_file_range_prep 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: Tue, 09 Oct 2018 17:13:15 -0700 Message-ID: <153913039499.32295.9599862851836900251.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100000 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 Plumb the remap flags through the filesystem from the vfs function dispatcher all the way to the prep function to prepare for behavior changes in subsequent patches. Signed-off-by: Darrick J. Wong --- fs/ocfs2/file.c | 2 +- fs/ocfs2/refcounttree.c | 6 +++--- fs/ocfs2/refcounttree.h | 2 +- fs/read_write.c | 10 ++++++---- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_reflink.c | 15 ++++++++------- fs/xfs/xfs_reflink.h | 3 ++- include/linux/fs.h | 5 +++-- 8 files changed, 25 insertions(+), 20 deletions(-) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 5da278edf189..ca41e69c8e68 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2535,7 +2535,7 @@ static int ocfs2_remap_file_range(struct file *file_in, unsigned int flags) { return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, flags & RFR_IDENTICAL_DATA); + len, flags); } const struct inode_operations ocfs2_file_iops = { diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index ee1ed11379b3..270a5b1919f6 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4825,7 +4825,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, struct file *file_out, loff_t pos_out, u64 len, - bool is_dedupe) + unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); @@ -4851,7 +4851,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, goto out_unlock; ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, - &len, is_dedupe); + &len, remap_flags); if (ret <= 0) goto out_unlock; @@ -4859,7 +4859,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, * Update inode timestamps and remove security privileges before we * take the ilock. */ - ret = generic_remap_file_range_touch(file_out, is_dedupe); + ret = generic_remap_file_range_touch(file_out, remap_flags); if (ret) goto out_unlock; diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h index 4af55bf4b35b..d2c5f526edff 100644 --- a/fs/ocfs2/refcounttree.h +++ b/fs/ocfs2/refcounttree.h @@ -120,6 +120,6 @@ int ocfs2_reflink_remap_range(struct file *file_in, struct file *file_out, loff_t pos_out, u64 len, - bool is_dedupe); + unsigned int remap_flags); #endif /* OCFS2_REFCOUNTTREE_H */ diff --git a/fs/read_write.c b/fs/read_write.c index 020bb7fdf431..47174785a94f 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1712,18 +1712,20 @@ static int remap_verify_area(struct file *file, loff_t pos, u64 len, bool write) /* * Check that the two inodes are eligible for cloning, the ranges make * sense, and then flush all dirty data. Caller must ensure that the - * inodes have been locked against any other modifications. + * inodes have been locked against any other modifications. This function + * takes RFR_* flags in remap_flags. * * Returns: 0 for "nothing to clone", 1 for "something to clone", or * the usual negative error code. */ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 *len, bool is_dedupe) + u64 *len, unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); loff_t isize; + bool is_dedupe = (remap_flags & RFR_IDENTICAL_DATA); bool same_inode = (inode_in == inode_out); int ret; @@ -1791,12 +1793,12 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, EXPORT_SYMBOL(generic_remap_file_range_prep); /* Update inode timestamps and remove security privileges when remapping. */ -int generic_remap_file_range_touch(struct file *file, bool is_dedupe) +int generic_remap_file_range_touch(struct file *file, unsigned int remap_flags) { int ret; /* If can't alter the file contents, we're done. */ - if (is_dedupe) + if (remap_flags & RFR_IDENTICAL_DATA) return 0; /* Update the timestamps, since we can alter file contents. */ diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 74ad73231ea4..4c0ae1efb63f 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -929,7 +929,7 @@ xfs_file_remap_range( unsigned int flags) { return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, flags & RFR_IDENTICAL_DATA); + len, flags); } STATIC int diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 0d67b2d0b3d4..4f5e3923d9c2 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -921,10 +921,11 @@ xfs_reflink_update_dest( struct xfs_inode *dest, xfs_off_t newlen, xfs_extlen_t cowextsize, - bool is_dedupe) + unsigned int remap_flags) { struct xfs_mount *mp = dest->i_mount; struct xfs_trans *tp; + bool is_dedupe = (remap_flags & RFR_IDENTICAL_DATA); int error; if (is_dedupe && newlen <= i_size_read(VFS_I(dest)) && cowextsize == 0) @@ -1274,7 +1275,7 @@ xfs_reflink_remap_prep( struct file *file_out, loff_t pos_out, u64 *len, - bool is_dedupe) + unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct xfs_inode *src = XFS_I(inode_in); @@ -1304,7 +1305,7 @@ xfs_reflink_remap_prep( goto out_unlock; ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, - len, is_dedupe); + len, remap_flags); if (ret <= 0) goto out_unlock; @@ -1334,7 +1335,7 @@ xfs_reflink_remap_prep( * Update inode timestamps and remove security privileges before we * take the ilock. */ - ret = generic_remap_file_range_touch(file_out, is_dedupe); + ret = generic_remap_file_range_touch(file_out, remap_flags); if (ret) goto out_unlock; @@ -1354,7 +1355,7 @@ xfs_reflink_remap_range( struct file *file_out, loff_t pos_out, u64 len, - bool is_dedupe) + unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct xfs_inode *src = XFS_I(inode_in); @@ -1374,7 +1375,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, is_dedupe); + &len, remap_flags); if (ret <= 0) return ret; @@ -1401,7 +1402,7 @@ xfs_reflink_remap_range( cowextsize = src->i_d.di_cowextsize; ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize, - is_dedupe); + remap_flags); out_unlock: xfs_reflink_remap_unlock(file_in, file_out); diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index c585ad9552b2..6f82d628bf17 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -28,7 +28,8 @@ extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset, xfs_off_t count); extern int xfs_reflink_recover_cow(struct xfs_mount *mp); extern int xfs_reflink_remap_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len, bool is_dedupe); + struct file *file_out, loff_t pos_out, u64 len, + unsigned int remap_flags); extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp, struct xfs_inode *ip, bool *has_shared); extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip, diff --git a/include/linux/fs.h b/include/linux/fs.h index 661b9ef32d2b..0d9bdef0b4ea 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1832,8 +1832,9 @@ extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, loff_t, size_t, unsigned int); extern int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 *count, bool is_dedupe); -extern int generic_remap_file_range_touch(struct file *file, bool is_dedupe); + u64 *count, unsigned int remap_flags); +extern int generic_remap_file_range_touch(struct file *file, + unsigned int remap_flags); extern int do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, u64 len); extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in, From patchwork Wed Oct 10 00:13:21 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: 10633575 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 076AE16B1 for ; Wed, 10 Oct 2018 00:13:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8EAD284C9 for ; Wed, 10 Oct 2018 00:13:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD11C28C31; Wed, 10 Oct 2018 00:13:32 +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 738FB284C9 for ; Wed, 10 Oct 2018 00:13:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 676B06B027B; Tue, 9 Oct 2018 20:13:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5FC876B027C; Tue, 9 Oct 2018 20:13:31 -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 49EA86B027D; Tue, 9 Oct 2018 20:13:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 1D5186B027B for ; Tue, 9 Oct 2018 20:13:31 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id f5-v6so2633668plf.11 for ; Tue, 09 Oct 2018 17:13:31 -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=siIUmV5fQSYq9VGDzNEOdlZpC7I3EvWwNg8/jXArbuQ=; b=XmarlmSm+W+jW57FnceqXy8lMKIxwk/W2G2tbhJXfqFs04nhloNJjhtpp9Pv/S8Qva R5re36zV4VyBvmBfkW5ErTRZxAMtMJGITj39Gln/w1l0GdOzJ9r0izo8cYPB3U5JLg/c lYW/zkgGdcL+M19gRtms1UEzBZIMqj3qiMjcrDDmraK5g2PFTviGyfRuuaj3aWAgV9Xv kyKqb7CbmOQosNKBhYuCMFBvkrwvB99FFBwIXpVLF6XVYTljgR9Q1eTOoH5zu1/UzSEI xdQpXtbFWzZHql6O65G0f09DkFWxNLCzehvwoRhKo8893rcCgsjI0uy+UZAlSQAy4p9Z nRtQ== X-Gm-Message-State: ABuFfog5auc6CoIyL0G62USrz7B/RsysHyy0AasixrxPdaV4udDLUtvJ J7D8R8dPxpv15dFsKqxw6c8xpVJGfBeYvCEXbtvz2ZXqWYtLtWsA5BPKewPq2URgdmXv2rjFXvK IzVWD0NXBU+jujobAouwITubMXEYR908K+AYkaxEtRDDALqJWAAFsyMnP1+SrmdM4YA== X-Received: by 2002:a63:4a64:: with SMTP id j36-v6mr27641415pgl.168.1539130410790; Tue, 09 Oct 2018 17:13:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV62VfMTfJMR9SBtAqb7aokYNxpoK2Wsdm+XpjtDXVk9Sg3Kr4CPS1V7pYu5F4AlwrYuRRd9K X-Received: by 2002:a63:4a64:: with SMTP id j36-v6mr27641376pgl.168.1539130409997; Tue, 09 Oct 2018 17:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130409; cv=none; d=google.com; s=arc-20160816; b=a82OzfqG/gDxYv5+Uj19qo4XpW/W2f2Qf39gCncxI5/oEFR8nndPm/u/9/hnXiPRDT yjlhIJH5dkiNh3gE/rAQ+5j5KFbsxtOjS7bMP2vR6NzsClgnwqwtALolChXgmpWqaiHO UEiHUs66N8kn6+0qMJ0qSdyot6//WGBMcbvOznFvfVVt0nQ0hwlvTZmN9BRgQ5mRBdZy 81xZokPBs4tII0gId+cyHxrsPU8LetGt6wQcngO0YiziqH+kqArxVmY9nudvrgejk2QJ dU1Ok+o1AfCHm+beY0sIMa8pu9F+wWg3VVXW1m220a+A0HK1hwJ4lvliijX+x+ueJO/x lrLw== 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=siIUmV5fQSYq9VGDzNEOdlZpC7I3EvWwNg8/jXArbuQ=; b=VaE+iske8ZlZsVZquBVrLhwqaFR8uJGrpmb7m8fzKOuuQdOGRPQr2LC2fPfGUrQNv3 WlxJmipQuKVw7f6jr4sInDv1l8gnpi/OkyYUk/gS9RUuQJ0WVmpCIaYsYb1ldjt92Ufr ojtNpkxwnymXC7WTbRWWmSkCWEH20EUqKG+ZEeeKCvtpig4pqPFaYt0HUzgsFjoixkQa VrZxFURscEIWhih53NdMTRrW7cwaxmsz634T6aw7Q70sy7juBYlcNoM5+TnBUEbGZd1N hOlljLImwhvwp8fgTHX/kDiojKQCODUMprP7d+gK7bVzyiN+71hmCjYXLnaPxUS1OAJY nC2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=dRBvfBl1; 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 u3-v6si22169284plz.353.2018.10.09.17.13.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:13:29 -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=dRBvfBl1; 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 w9A08vFt138883; Wed, 10 Oct 2018 00:13:29 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=siIUmV5fQSYq9VGDzNEOdlZpC7I3EvWwNg8/jXArbuQ=; b=dRBvfBl1duBd6ke/4HZcKCI0CAd8OrFE5vllDJGRh+zxmVeSjhZx/RcBBwTgbNKO+7sQ s1cdllzAyQWME/ChQe4xPnl1+jgJWB1Q8RlXJU8TgNcXYI8LgJPzZKMcYIgEN/TESzxi uDrdaAFO1LAVNMWeeu4mdznlvhv65Tfih6ATVmoKwimKSI7yVsro8NUVStfzjdwDhqI9 u6GS/xnXStYAxK4Md6qYAQZYjQvs3YVXYUNyoAy9jYi9OhsI4cm3z/9EXF8LXXXuW6+W 72J5sC2W5t6aTi7vk0oGu+8HJtHaGtRyQYdTKs940BCneaBFMwo3ljkeW8uJKeWuC6HF CQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2mxn0q0tqe-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:29 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0DN7u028744 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:23 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0DNN8017378; Wed, 10 Oct 2018 00:13:23 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:13:23 +0000 Subject: [PATCH 13/25] vfs: pass remap flags to generic_remap_checks 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: Tue, 09 Oct 2018 17:13:21 -0700 Message-ID: <153913040183.32295.16281682485157170773.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=416 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100000 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 Pass the same remap flags to generic_remap_checks for consistency. Signed-off-by: Darrick J. Wong --- fs/read_write.c | 2 +- include/linux/fs.h | 2 +- mm/filemap.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 47174785a94f..917934770b08 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1755,7 +1755,7 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, /* Check that we don't violate system file offset limits. */ ret = generic_remap_checks(file_in, pos_in, file_out, pos_out, len, - is_dedupe); + remap_flags); if (ret) return ret; diff --git a/include/linux/fs.h b/include/linux/fs.h index 0d9bdef0b4ea..56167b10cbad 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2976,7 +2976,7 @@ extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *); extern int generic_remap_checks(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - uint64_t *count, bool is_dedupe); + uint64_t *count, unsigned int remap_flags); extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); diff --git a/mm/filemap.c b/mm/filemap.c index 59056bd9c58a..e099c8880863 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3004,7 +3004,7 @@ generic_remap_check_limits(struct file *file, loff_t pos, uint64_t *count) */ int generic_remap_checks(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - uint64_t *req_count, bool is_dedupe) + uint64_t *req_count, unsigned int remap_flags) { struct inode *inode_in = file_in->f_mapping->host; struct inode *inode_out = file_out->f_mapping->host; @@ -3027,7 +3027,7 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, size_out = i_size_read(inode_out); /* Dedupe requires both ranges to be within EOF. */ - if (is_dedupe && + if ((remap_flags & RFR_IDENTICAL_DATA) && (pos_in >= size_in || pos_in + count > size_in || pos_out >= size_out || pos_out + count > size_out)) return -EINVAL; From patchwork Wed Oct 10 00:13:28 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: 10633591 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 34A2317E3 for ; Wed, 10 Oct 2018 00:13:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 21738284C9 for ; Wed, 10 Oct 2018 00:13:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1521328CC1; Wed, 10 Oct 2018 00:13:40 +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 ACEEA284C9 for ; Wed, 10 Oct 2018 00:13:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 676E16B027D; Tue, 9 Oct 2018 20:13:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5FC7F6B027F; Tue, 9 Oct 2018 20:13:37 -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 450486B0280; Tue, 9 Oct 2018 20:13:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id E0A4C6B027D for ; Tue, 9 Oct 2018 20:13:36 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id r16-v6so2507060pgv.17 for ; Tue, 09 Oct 2018 17:13: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=HHBh8l5r6O0h57NJQ1oRoHOqXqZvHTEGqs/FZtmUu+U=; b=LmzamGqiIFlY+3wM63BMRa2ZRAVo1LALrcb+BuU04ypBSGQR35ffuc3NSTftGqf63z y1kW9egb2tpE/WhJJAjXc2dUweIFnNoPt6ksIwGbIKioAxdLUerXjIHyk6nO8ejHhO4P bObfHZ+5kuz7qESsV7tuoCG0uCqvOvXqtr+z1/KVNEwiIcqRrkGbmzNwEX569f86BJ4A hVtN4W672yPQpbWPGGK/mr/sQ/jLkwhfVDnDDZuo85VHFQlqo+QH29y8uHrmVn7O1Hou QjPLu4Rfj5uAq8KbiV+1M9htlIg/e5XrFQKlCAPiLIJj8zbdZb8f57KSqzzPn4FNGe5k w0BQ== X-Gm-Message-State: ABuFfoj6wvsX2MVABc/Io6H+sbhFbErZh7Ly2Esxw4U+ALb1owHgwvz3 nqh28RkZ9S7hEbLRntcxMLw1Q9QuCNe40vkbXOP7xsmARRjTSdhslbYfqPVVp1z1PXXvHHloIGz l2opdGyouz+zQl7IEQQlltJWAn8gD4sm1rzCYyWgslmaZWro/JIL1M42ZFoRQv7pqIQ== X-Received: by 2002:a62:4bd2:: with SMTP id d79-v6mr32259877pfj.38.1539130416548; Tue, 09 Oct 2018 17:13:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV61zdUZth2K4N0aeidRyVU+ureOk54si8TV14qVv3l73CXX3qUX0MmBg7Kx9/DbDI+bsBpVM X-Received: by 2002:a62:4bd2:: with SMTP id d79-v6mr32259754pfj.38.1539130414905; Tue, 09 Oct 2018 17:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130414; cv=none; d=google.com; s=arc-20160816; b=AXQ95pbtNoZFw2Q3S1Iv8Ak/WLBObEUT0DwyIjFmsbSh1sUSXdJR4ZFWTNLySwKxxz 21wqXMqP73ACPyAtJUt/S+XmOX+6gUEk95K3pIaEWo69E8VB9zOZSezMb0dfQHlDx7HQ ExOExF4aXP2VadTglngLfhgPnGnKlBzSOaAUczurjJ0uquIFZ4xtDIP023euByur1JVL TrB9ym87k82VWmM3qzkJHqa3otu9vHOo3CuaFhlNWgEGPi7LL5CVLHre0eXXqwWP3kuz FTCr+kayi29PffIvSPM6SpLpwyRuEFVpXpicsmSliS5aRGO/4bo/130hhAH9d38O7TxZ 8wMw== 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=HHBh8l5r6O0h57NJQ1oRoHOqXqZvHTEGqs/FZtmUu+U=; b=ZrpTsGHpCYR3Z2J0dCfsqZ1P+V6BBQa8n+ezy7c3fToWNqQoboBDOEgv7Q4Ff7gnFl FgGSi1VN8tQajsiHiBm2HINwRDecxOQML8Xpj6iCERvX2SLvUkc8/atnLixnNOelFEuH O1tlSuMnN7F5B8nUCEzOPGM7sYwCA7VNqkPt1hcxbXqvtfO0C1ScUyarnSm0TiEXZf2k Nm3AjufDAvopDSLAAeJp+GYL75+IBCxKZJxzZXUJQcZyBSIiqiCNicMSGW8VuloKQGEf 2MMfZpA8hyf6VSt7WNsvsiwjLPp5jvA9NfLO2/MpdazMoAeprfL/SkvLWmnsX+4y7pgu 35cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=WYxPZUH0; 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 u1-v6si21314523pgj.430.2018.10.09.17.13.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:13:34 -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=WYxPZUH0; 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 w9A08ukO138872; Wed, 10 Oct 2018 00:13: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=HHBh8l5r6O0h57NJQ1oRoHOqXqZvHTEGqs/FZtmUu+U=; b=WYxPZUH0DI8yyo+KdCwKyO+LZnqaxjObc8zUkxgyfswTGl+UC1ASaM23+KhfjybEsz3s dXcf26GWB5GluK2DFO4q5P49tg7CG/kJMpbpAWMUmna8Aey6wYU6Cm82spZvzXjZ/kIk 6jRDS1EHy+EVZaic2dX8iIF3PDeRuU8f//+907Y/vWlTvfI8mvOlx8saCJuLG7zO0kjO cKgicQRtDhnguO1ajWdOaXeX/Z6tCS2xO/9wG3wv/DIWVs3ivvxbDAYw9v6u3oye2qzI /uducoEnU3csTRzma+jkZ3BYhTDsaK9BFW4AC+C6AcYjA+41zJthz/NUXxTzitU+Z7dw ug== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2mxn0q0tqh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:33 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0DWZp003990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:32 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0DVkd003866; Wed, 10 Oct 2018 00:13:32 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:13:31 +0000 Subject: [PATCH 14/25] vfs: make remap_file_range functions take and return bytes completed 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: Tue, 09 Oct 2018 17:13:28 -0700 Message-ID: <153913040858.32295.9474188640729118153.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 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-1810100000 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 Change the remap_file_range functions to take a number of bytes to operate upon and return the number of bytes they operated on. This is a requirement for allowing fs implementations to return short clone/dedupe results to the user, which will enable us to obey resource limits in a graceful manner. A subsequent patch will enable copy_file_range to signal to the ->clone_file_range implementation that it can handle a short length, which will be returned in the function's return value. Neither clone ioctl can take advantage of this, alas. Signed-off-by: Darrick J. Wong --- fs/btrfs/ctree.h | 6 +++--- fs/btrfs/ioctl.c | 13 ++++++++---- fs/cifs/cifsfs.c | 6 +++--- fs/ioctl.c | 10 +++++++++- fs/nfs/nfs4file.c | 6 +++--- fs/nfsd/vfs.c | 8 ++++++-- fs/ocfs2/file.c | 16 ++++++++------- fs/ocfs2/refcounttree.c | 2 +- fs/ocfs2/refcounttree.h | 2 +- fs/overlayfs/copy_up.c | 5 +++-- fs/overlayfs/file.c | 12 ++++++------ fs/read_write.c | 49 ++++++++++++++++++++++++++--------------------- fs/xfs/xfs_file.c | 11 +++++++---- fs/xfs/xfs_reflink.c | 4 ++-- fs/xfs/xfs_reflink.h | 2 +- include/linux/fs.h | 27 ++++++++++++++------------ mm/filemap.c | 8 ++++---- 17 files changed, 107 insertions(+), 80 deletions(-) diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index a79783a713f0..d09af171d185 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h @@ -3247,9 +3247,9 @@ int btrfs_dirty_pages(struct inode *inode, struct page **pages, size_t num_pages, loff_t pos, size_t write_bytes, struct extent_state **cached); int btrfs_fdatawrite_range(struct inode *inode, loff_t start, loff_t end); -int btrfs_remap_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len, - unsigned int flags); +loff_t btrfs_remap_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int flags); /* tree-defrag.c */ int btrfs_defrag_leaves(struct btrfs_trans_handle *trans, diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index e22b294fa25b..3488bc90e5eb 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -4328,10 +4328,12 @@ static noinline int btrfs_clone_files(struct file *file, struct file *file_src, return ret; } -int btrfs_remap_file_range(struct file *src_file, loff_t off, - struct file *dst_file, loff_t destoff, u64 len, +loff_t btrfs_remap_file_range(struct file *src_file, loff_t off, + struct file *dst_file, loff_t destoff, loff_t len, unsigned int flags) { + int ret; + if (flags & RFR_IDENTICAL_DATA) { struct inode *src = file_inode(src_file); struct inode *dst = file_inode(dst_file); @@ -4346,10 +4348,11 @@ int btrfs_remap_file_range(struct file *src_file, loff_t off, return -EINVAL; } - return btrfs_extent_same(src, off, len, dst, destoff); + ret = btrfs_extent_same(src, off, len, dst, destoff); + } else { + ret = btrfs_clone_files(dst_file, src_file, off, len, destoff); } - - return btrfs_clone_files(dst_file, src_file, off, len, destoff); + return ret < 0 ? ret : len; } static long btrfs_ioctl_default_subvol(struct file *file, void __user *argp) diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index bf971fd7cab2..c6ea368ea920 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -975,8 +975,8 @@ const struct inode_operations cifs_symlink_inode_ops = { .listxattr = cifs_listxattr, }; -static int cifs_remap_file_range(struct file *src_file, loff_t off, - struct file *dst_file, loff_t destoff, u64 len, +static loff_t cifs_remap_file_range(struct file *src_file, loff_t off, + struct file *dst_file, loff_t destoff, loff_t len, unsigned int flags) { struct inode *src_inode = file_inode(src_file); @@ -1029,7 +1029,7 @@ static int cifs_remap_file_range(struct file *src_file, loff_t off, unlock_two_nondirectories(src_inode, target_inode); out: free_xid(xid); - return rc; + return rc < 0 ? rc : len; } ssize_t cifs_file_copychunk_range(unsigned int xid, diff --git a/fs/ioctl.c b/fs/ioctl.c index 2005529af560..72537b68c272 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -223,6 +223,7 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, u64 off, u64 olen, u64 destoff) { struct fd src_file = fdget(srcfd); + loff_t cloned; int ret; if (!src_file.file) @@ -230,7 +231,14 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, ret = -EXDEV; if (src_file.file->f_path.mnt != dst_file->f_path.mnt) goto fdput; - ret = vfs_clone_file_range(src_file.file, off, dst_file, destoff, olen); + cloned = vfs_clone_file_range(src_file.file, off, dst_file, destoff, + olen); + if (cloned < 0) + ret = cloned; + else if (olen && cloned != olen) + ret = -EINVAL; + else + ret = 0; fdput: fdput(src_file); return ret; diff --git a/fs/nfs/nfs4file.c b/fs/nfs/nfs4file.c index a93aa225c454..0c56d1acac18 100644 --- a/fs/nfs/nfs4file.c +++ b/fs/nfs/nfs4file.c @@ -180,8 +180,8 @@ static long nfs42_fallocate(struct file *filep, int mode, loff_t offset, loff_t return nfs42_proc_allocate(filep, offset, len); } -static int nfs42_remap_file_range(struct file *src_file, loff_t src_off, - struct file *dst_file, loff_t dst_off, u64 count, +static loff_t nfs42_remap_file_range(struct file *src_file, loff_t src_off, + struct file *dst_file, loff_t dst_off, loff_t count, unsigned int flags) { struct inode *dst_inode = file_inode(dst_file); @@ -244,7 +244,7 @@ static int nfs42_remap_file_range(struct file *src_file, loff_t src_off, inode_unlock(src_inode); } out: - return ret; + return ret < 0 ? ret : count; } #endif /* CONFIG_NFS_V4_2 */ diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index b53e76391e52..ac6cb6101cbe 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -541,8 +541,12 @@ __be32 nfsd4_set_nfs4_label(struct svc_rqst *rqstp, struct svc_fh *fhp, __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst, u64 dst_pos, u64 count) { - return nfserrno(vfs_clone_file_range(src, src_pos, dst, dst_pos, - count)); + loff_t cloned; + + cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count); + if (count && cloned != count) + cloned = -EINVAL; + return nfserrno(cloned < 0 ? cloned : 0); } ssize_t nfsd_copy_file_range(struct file *src, u64 src_pos, struct file *dst, diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index ca41e69c8e68..c018605ac279 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2527,15 +2527,15 @@ static loff_t ocfs2_file_llseek(struct file *file, loff_t offset, int whence) return offset; } -static int ocfs2_remap_file_range(struct file *file_in, - loff_t pos_in, - struct file *file_out, - loff_t pos_out, - u64 len, - unsigned int flags) +static loff_t ocfs2_remap_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int flags) { - return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, flags); + int ret; + + ret = ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, + len, flags); + return ret < 0 ? ret : len; } const struct inode_operations ocfs2_file_iops = { diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 270a5b1919f6..a3df118bf3b9 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4824,7 +4824,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len, + loff_t len, unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h index d2c5f526edff..eb65c1d0843c 100644 --- a/fs/ocfs2/refcounttree.h +++ b/fs/ocfs2/refcounttree.h @@ -119,7 +119,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len, + loff_t len, unsigned int remap_flags); #endif /* OCFS2_REFCOUNTTREE_H */ diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index 1cc797a08a5b..c2b53509e7f1 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -125,6 +125,7 @@ static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len) struct file *new_file; loff_t old_pos = 0; loff_t new_pos = 0; + loff_t cloned; int error = 0; if (len == 0) @@ -141,8 +142,8 @@ static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len) } /* Try to use clone_file_range to clone up within the same fs */ - error = do_clone_file_range(old_file, 0, new_file, 0, len); - if (!error) + cloned = do_clone_file_range(old_file, 0, new_file, 0, len); + if (cloned == len) goto out; /* Couldn't clone, so now we try to copy the data */ error = 0; diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 693bd0620a81..c8c890c22898 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -434,14 +434,14 @@ enum ovl_copyop { OVL_DEDUPE, }; -static ssize_t ovl_copyfile(struct file *file_in, loff_t pos_in, +static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len, unsigned int flags, enum ovl_copyop op) + loff_t len, unsigned int flags, enum ovl_copyop op) { struct inode *inode_out = file_inode(file_out); struct fd real_in, real_out; const struct cred *old_cred; - ssize_t ret; + loff_t ret; ret = ovl_real_fdget(file_out, &real_out); if (ret) @@ -489,9 +489,9 @@ static ssize_t ovl_copy_file_range(struct file *file_in, loff_t pos_in, OVL_COPY); } -static int ovl_remap_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, - u64 len, unsigned int flags) +static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int flags) { enum ovl_copyop op; diff --git a/fs/read_write.c b/fs/read_write.c index 917934770b08..f43b0620afd4 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1589,10 +1589,13 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, * more efficient if both clone and copy are supported (e.g. NFS). */ if (file_in->f_op->remap_file_range) { - ret = file_in->f_op->remap_file_range(file_in, pos_in, - file_out, pos_out, len, 0); - if (ret == 0) { - ret = len; + s64 cloned; + + cloned = file_in->f_op->remap_file_range(file_in, pos_in, + file_out, pos_out, + min_t(loff_t, MAX_RW_COUNT, len), 0); + if (cloned >= 0) { + ret = cloned; goto done; } } @@ -1686,11 +1689,12 @@ SYSCALL_DEFINE6(copy_file_range, int, fd_in, loff_t __user *, off_in, return ret; } -static int remap_verify_area(struct file *file, loff_t pos, u64 len, bool write) +static int remap_verify_area(struct file *file, loff_t pos, loff_t len, + bool write) { struct inode *inode = file_inode(file); - if (unlikely(pos < 0)) + if (unlikely(pos < 0 || len < 0)) return -EINVAL; if (unlikely((loff_t) (pos + len) < 0)) @@ -1720,7 +1724,7 @@ static int remap_verify_area(struct file *file, loff_t pos, u64 len, bool write) */ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 *len, unsigned int remap_flags) + loff_t *len, unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); @@ -1816,12 +1820,12 @@ int generic_remap_file_range_touch(struct file *file, unsigned int remap_flags) } EXPORT_SYMBOL(generic_remap_file_range_touch); -int do_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len) +loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, loff_t len) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); - int ret; + loff_t ret; if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) return -EISDIR; @@ -1854,19 +1858,19 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in, ret = file_in->f_op->remap_file_range(file_in, pos_in, file_out, pos_out, len, 0); - if (!ret) { - fsnotify_access(file_in); - fsnotify_modify(file_out); - } + if (ret < 0) + return ret; + fsnotify_access(file_in); + fsnotify_modify(file_out); return ret; } EXPORT_SYMBOL(do_clone_file_range); -int vfs_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len) +loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, loff_t len) { - int ret; + loff_t ret; file_start_write(file_out); ret = do_clone_file_range(file_in, pos_in, file_out, pos_out, len); @@ -1972,10 +1976,11 @@ int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, } EXPORT_SYMBOL(vfs_dedupe_file_range_compare); -int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, - struct file *dst_file, loff_t dst_pos, u64 len) +loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, + struct file *dst_file, loff_t dst_pos, + loff_t len) { - s64 ret; + loff_t ret; ret = mnt_want_write_file(dst_file); if (ret) @@ -2024,7 +2029,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) int i; int ret; u16 count = same->dest_count; - int deduped; + loff_t deduped; if (!(file->f_mode & FMODE_READ)) return -EINVAL; @@ -2081,7 +2086,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) else if (deduped < 0) info->status = deduped; else - info->bytes_deduped = len; + info->bytes_deduped = deduped; next_fdput: fdput(dst_fd); diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 4c0ae1efb63f..6f4205846451 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -919,17 +919,20 @@ xfs_file_fallocate( return error; } -STATIC int +STATIC loff_t xfs_file_remap_range( struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len, + loff_t len, unsigned int flags) { - return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, flags); + int ret; + + ret = xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, + len, false); + return ret < 0 ? ret : len; } STATIC int diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 4f5e3923d9c2..ec09e2783afe 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1274,7 +1274,7 @@ xfs_reflink_remap_prep( loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 *len, + loff_t *len, unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); @@ -1354,7 +1354,7 @@ xfs_reflink_remap_range( loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 len, + loff_t len, unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index 6f82d628bf17..c3c46c276fe1 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -28,7 +28,7 @@ extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset, xfs_off_t count); extern int xfs_reflink_recover_cow(struct xfs_mount *mp); extern int xfs_reflink_remap_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len, + struct file *file_out, loff_t pos_out, loff_t len, unsigned int remap_flags); extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp, struct xfs_inode *ip, bool *has_shared); diff --git a/include/linux/fs.h b/include/linux/fs.h index 56167b10cbad..1ee09152ecd5 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1765,9 +1765,9 @@ struct file_operations { #endif ssize_t (*copy_file_range)(struct file *, loff_t, struct file *, loff_t, size_t, unsigned int); - int (*remap_file_range)(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, - u64 len, unsigned int flags); + loff_t (*remap_file_range)(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int flags); int (*fadvise)(struct file *, loff_t, loff_t, int); } __randomize_layout; @@ -1832,21 +1832,24 @@ extern ssize_t vfs_copy_file_range(struct file *, loff_t , struct file *, loff_t, size_t, unsigned int); extern int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - u64 *count, unsigned int remap_flags); + loff_t *count, + unsigned int remap_flags); extern int generic_remap_file_range_touch(struct file *file, unsigned int remap_flags); -extern int do_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len); -extern int vfs_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, u64 len); +extern loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + loff_t len); +extern loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, + struct file *file_out, loff_t pos_out, + loff_t len); extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, struct inode *dest, loff_t destoff, loff_t len, bool *is_same); extern int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same); -extern int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, - struct file *dst_file, loff_t dst_pos, - u64 len); +extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, + struct file *dst_file, loff_t dst_pos, + loff_t len); struct super_operations { @@ -2976,7 +2979,7 @@ extern int generic_file_readonly_mmap(struct file *, struct vm_area_struct *); extern ssize_t generic_write_checks(struct kiocb *, struct iov_iter *); extern int generic_remap_checks(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - uint64_t *count, unsigned int remap_flags); + loff_t *count, unsigned int remap_flags); extern ssize_t generic_file_read_iter(struct kiocb *, struct iov_iter *); extern ssize_t __generic_file_write_iter(struct kiocb *, struct iov_iter *); extern ssize_t generic_file_write_iter(struct kiocb *, struct iov_iter *); diff --git a/mm/filemap.c b/mm/filemap.c index e099c8880863..2522737483de 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2975,7 +2975,7 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from) EXPORT_SYMBOL(generic_write_checks); static int -generic_remap_check_limits(struct file *file, loff_t pos, uint64_t *count) +generic_remap_check_limits(struct file *file, loff_t pos, loff_t *count) { struct inode *inode = file->f_mapping->host; @@ -2984,14 +2984,14 @@ generic_remap_check_limits(struct file *file, loff_t pos, uint64_t *count) !(file->f_flags & O_LARGEFILE))) { if (pos >= MAX_NON_LFS) return -EFBIG; - *count = min(*count, MAX_NON_LFS - (uint64_t)pos); + *count = min(*count, (loff_t)MAX_NON_LFS - pos); } /* Don't operate on ranges the page cache doesn't support. */ if (unlikely(pos >= inode->i_sb->s_maxbytes)) return -EFBIG; - *count = min(*count, inode->i_sb->s_maxbytes - (uint64_t)pos); + *count = min(*count, inode->i_sb->s_maxbytes - pos); return 0; } @@ -3004,7 +3004,7 @@ generic_remap_check_limits(struct file *file, loff_t pos, uint64_t *count) */ int generic_remap_checks(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - uint64_t *req_count, unsigned int remap_flags) + loff_t *req_count, unsigned int remap_flags) { struct inode *inode_in = file_in->f_mapping->host; struct inode *inode_out = file_out->f_mapping->host; From patchwork Wed Oct 10 00:13:36 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: 10633603 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 5A32B16B1 for ; Wed, 10 Oct 2018 00:13:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48889284C9 for ; Wed, 10 Oct 2018 00:13:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C30928F95; Wed, 10 Oct 2018 00:13:51 +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 9CC7D284C9 for ; Wed, 10 Oct 2018 00:13:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 69D7F6B027F; Tue, 9 Oct 2018 20:13:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 623E66B0280; Tue, 9 Oct 2018 20:13:49 -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 4C5F26B0281; Tue, 9 Oct 2018 20:13:49 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by kanga.kvack.org (Postfix) with ESMTP id 047696B027F for ; Tue, 9 Oct 2018 20:13:49 -0400 (EDT) Received: by mail-pl1-f199.google.com with SMTP id t1-v6so2629531plz.17 for ; Tue, 09 Oct 2018 17:13:48 -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=2a8tPT5hwhOD+Vvn8K7DjoifReMioKzeW8UFY3QjLpA=; b=P/YQlM0zBKzZCKNmo/NUmCxM2Wsz0+Zw5Mwl06F/+a3zbi90rcXfogb9d2zcYeKHtT K5q8mZ9ru3Y2VOnBxaguLFhQlzght2FWqLyryYm8N0xxpMJXd9RIyCRgEqQUvI4tL3F3 JT31CyT6J+MSWMxMc9p9peQXUb6em9QNU7mSORxSjazQAl+dIgpoYyrMpNNdRrUcrYZ2 73Z48HCY45l4kcD6bVn1qOhNmJcmZcLJZAlqnmgm9R3D5ZxcSmf5BG7bA8q+Pm3GM4wQ NKVdhld0YOAK06ycDoPNNlTE1KkJFy1pGThnqT8tTeQKArjYPFtzDgJrIpr/fEfLBX5a kFJA== X-Gm-Message-State: ABuFfoiQQ9701HEFb4jtbpYV8zOACGVReIQ1Z+mUtOMviDrwOPQHjpaO p5sPIyP4EwsVusxVl4HBnFvTWVQ+hOf0lrSi4iizU6YfPmEMeTrG1mC2VPQdjjO+zLFv4QCIJJw D1vL/sdHzF1AqxB3CXifLyUBMLkmQfN0/vDX7n8GnvNn3XE79K8ZLZueQ8BbTNNbonA== X-Received: by 2002:a62:ca4d:: with SMTP id n74-v6mr27471442pfg.10.1539130428670; Tue, 09 Oct 2018 17:13:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV63yHekv+Ob7Itkmw/3beISFRfm7kNDNKly/HuDpoSg/mHWhAqYUaXLVladSO1AAhNuw/ZZC X-Received: by 2002:a62:ca4d:: with SMTP id n74-v6mr27471390pfg.10.1539130427769; Tue, 09 Oct 2018 17:13:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130427; cv=none; d=google.com; s=arc-20160816; b=afFuQ8LTdoMgRvH2vFUHF+P/krBTgeKmM8WiVgAkvd9x1qu34/1W/WYJw+cz5Lq6NG IfkhGfJmGK/lve7caIly52WmIBIMYLEDnA58ht4bWThCraYlIS4BKQQ0q4G65RCFhHki 63xoVpTij+FuDcIUIzxTufw1P4iDN63uzrRC4gkaGbYrKuL7FPEn/XBs4hhjikm8MZld bDK4kRe7yjTH9gZsgyR5KX9xqcuNyGJu/sR9fkW7nErGSQ7gH64Xs5f2r1HxxL03rJYy ccOR2cZY6tyXWhSqAUogICYN/n0ornBMjJD1/V/6irIIG6EqecsvQ8s4QUzLcbLcGbxQ 1SLw== 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=2a8tPT5hwhOD+Vvn8K7DjoifReMioKzeW8UFY3QjLpA=; b=ha87f7bd4/aSu2F1pP6MHCBCJrmGxWegZDl1SHcH3quhyk3YWCsxXo7JzhPnCYS/jW 2sSnC847GGtZXiQSygiV6lzN84FqJoz3IG+oLHn67IT+P9CpX6KN01LCOXz1BdsrsnDm OwD6wKl29+rXbWQeAl3z3m4/G2c837/IgQOuZbIZfrHlQ+HaHf1xiCuhVEMMH+SAk2LG F+161T5JzRIpGShVO64OXz3sAcM0VPyUJbIz+IENKmVmBZY4QEGDr61kdJsF2MU6+l8R 1XjoqBFPWPSgaZy433DgH0Sg5qUY2F0PoQ5HGaL5xzyxoBMSYYPAiRho++RpX1BpxgzC vWFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ltB5n4q8; 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 u5-v6si21512620pgm.268.2018.10.09.17.13.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:13:47 -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=ltB5n4q8; 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 w9A0DltO123163; Wed, 10 Oct 2018 00:13:47 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=2a8tPT5hwhOD+Vvn8K7DjoifReMioKzeW8UFY3QjLpA=; b=ltB5n4q8FqZUZZ9tFTMAhvHyRhJqxH+//6ARrNXx1zeV084XjrkvqI7+YncAaVrJ7C8Y f2QK/6wu6OnkWlnWQR8AMn4EoBPzRtiDjVCZhSeDkM2VdDUBw/i54BypCWI8w7HUa1ml yI4eiMCpYR1DCRmhFzH5IgnB0R3D+Bc59APrhLaC9CLQSUQMXn8G32OLsoXuKt8qegaw ESbcIdPF4yOSJ/YqmwI9xuK1KBmyKJCK3jiHKVgc1oRg3NgSCo0DDQz0/IIFFLzSKkn1 5AtKvaG3Vt1WWT99f7PzynaUZ/WznBAqwUT6vJd22UaaGDpc2oH7xCEC5yS3/RzQiEFD Ug== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2mxmftrvq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:46 +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 w9A0DjdZ004368 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:46 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0Djq4005684; Wed, 10 Oct 2018 00:13:45 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:13:45 +0000 Subject: [PATCH 15/25] vfs: plumb RFR_* remap flags through the vfs clone functions 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: Tue, 09 Oct 2018 17:13:36 -0700 Message-ID: <153913041692.32295.9928643841686525236.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=539 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 Plumb a remap_flags argument through the {do,vfs}_clone_file_range functions so that clone can take advantage of it. Signed-off-by: Darrick J. Wong --- fs/ioctl.c | 2 +- fs/nfsd/vfs.c | 2 +- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/file.c | 4 ++-- fs/read_write.c | 13 +++++++++---- include/linux/fs.h | 4 ++-- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/fs/ioctl.c b/fs/ioctl.c index 72537b68c272..505275ec5596 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -232,7 +232,7 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, if (src_file.file->f_path.mnt != dst_file->f_path.mnt) goto fdput; cloned = vfs_clone_file_range(src_file.file, off, dst_file, destoff, - olen); + olen, 0); if (cloned < 0) ret = cloned; else if (olen && cloned != olen) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index ac6cb6101cbe..726fc5b2b27a 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -543,7 +543,7 @@ __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst, { loff_t cloned; - cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count); + cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count, 0); if (count && cloned != count) cloned = -EINVAL; return nfserrno(cloned < 0 ? cloned : 0); diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index c2b53509e7f1..bf60a3386c11 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -142,7 +142,7 @@ static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len) } /* Try to use clone_file_range to clone up within the same fs */ - cloned = do_clone_file_range(old_file, 0, new_file, 0, len); + cloned = do_clone_file_range(old_file, 0, new_file, 0, len, 0); if (cloned == len) goto out; /* Couldn't clone, so now we try to copy the data */ diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index c8c890c22898..8b22035af4d7 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -462,7 +462,7 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, case OVL_CLONE: ret = vfs_clone_file_range(real_in.file, pos_in, - real_out.file, pos_out, len); + real_out.file, pos_out, len, flags); break; case OVL_DEDUPE: @@ -509,7 +509,7 @@ static loff_t ovl_remap_file_range(struct file *file_in, loff_t pos_in, !ovl_inode_upper(file_inode(file_out)))) return -EPERM; - return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, 0, + return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, flags, op); } diff --git a/fs/read_write.c b/fs/read_write.c index f43b0620afd4..cf81d1f68b69 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1821,12 +1821,15 @@ int generic_remap_file_range_touch(struct file *file, unsigned int remap_flags) EXPORT_SYMBOL(generic_remap_file_range_touch); loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, loff_t len) + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); loff_t ret; + WARN_ON_ONCE(remap_flags); + if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) return -EISDIR; if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode)) @@ -1857,7 +1860,7 @@ loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, return ret; ret = file_in->f_op->remap_file_range(file_in, pos_in, - file_out, pos_out, len, 0); + file_out, pos_out, len, remap_flags); if (ret < 0) return ret; @@ -1868,12 +1871,14 @@ loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, EXPORT_SYMBOL(do_clone_file_range); loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, loff_t len) + struct file *file_out, loff_t pos_out, + loff_t len, unsigned int remap_flags) { loff_t ret; file_start_write(file_out); - ret = do_clone_file_range(file_in, pos_in, file_out, pos_out, len); + ret = do_clone_file_range(file_in, pos_in, file_out, pos_out, len, + remap_flags); file_end_write(file_out); return ret; diff --git a/include/linux/fs.h b/include/linux/fs.h index 1ee09152ecd5..21f947b20f37 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1838,10 +1838,10 @@ extern int generic_remap_file_range_touch(struct file *file, unsigned int remap_flags); extern loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - loff_t len); + loff_t len, unsigned int remap_flags); extern loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, - loff_t len); + loff_t len, unsigned int remap_flags); extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, struct inode *dest, loff_t destoff, loff_t len, bool *is_same); From patchwork Wed Oct 10 00:13: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: 10633617 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 76AEE16B1 for ; Wed, 10 Oct 2018 00:13:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 64DB1284C9 for ; Wed, 10 Oct 2018 00:13:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5936A28F95; Wed, 10 Oct 2018 00:13: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 D5964284C9 for ; Wed, 10 Oct 2018 00:13:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A438C6B0281; Tue, 9 Oct 2018 20:13:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9F3C36B0282; Tue, 9 Oct 2018 20:13:55 -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 894866B0283; Tue, 9 Oct 2018 20:13:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 4325C6B0281 for ; Tue, 9 Oct 2018 20:13:55 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id r67-v6so3210187pfd.21 for ; Tue, 09 Oct 2018 17:13: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=Zy8BSFKM2bFSbax5Kg0akKWQ9LnNLVMQpUtsJ7wkExk=; b=lKZCAipT5TUSv8uCxzEycSZGeH50vwgJU3v0yE6r17cJOY4/kAifBuEdbBtgpKDCPT hug2T8xJ8deMkmAuFj5ifcUxq+Z0gxmQohJJd9YqyMcDocmoZWXdAcFtp+U8Rnagyc4v vJ1Jfn1JM4alxF+yQwDiD/2c/vTEIa6MxVSyfNEYoS0X+2G3F5phfkmU1yULD4pLuTCu P+taUHM/y01d4Rnu37PREb5pKDOB455KLzn4VMq6bKg2tMm/qw4VggsRsm9R16CiZSdW 6DxKxsmao822K+gEMrQO3v88Taq8Dx3xTL6bFb2PCaSX33cdOImkgGTEMq18H0WvEieS hLAg== X-Gm-Message-State: ABuFfoibnCkMOIYAHEkjKxS/RMf7eALw84jmL5zeNmeJe54Ww58BebCy lNLLwjYntQpch5GS/zf61kMMIODkDNtnrVLHe7QJiR7itt2WxkunzUFxzeyfDVDMrNBa1MwxTGt ulSIrWsDwxn3Vyt+Yp2z4gC4q5keXsZwbsTivnC++F1bi41WDSA6M6a+AWC12hI/F0w== X-Received: by 2002:aa7:814f:: with SMTP id d15-v6mr32570525pfn.78.1539130434949; Tue, 09 Oct 2018 17:13:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV60qVkXOR/pF34PPBJVpOHRdPJrTiNhGpk1tz1ZlzSI/K91BcF1Qu7NJMvcV5oTxWhJX8ANn X-Received: by 2002:aa7:814f:: with SMTP id d15-v6mr32570459pfn.78.1539130434133; Tue, 09 Oct 2018 17:13:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130434; cv=none; d=google.com; s=arc-20160816; b=rAccQPxLavSTUgxDk+pcO5gHycNaWCwi8nKCD2Zgqnx7cs8NrH0fnCPWmhd9Btjnpl x9a8YtjWx6mYzSnfJifjNucPCIrKysnA/fu07xpyYNoc5OMSlH0JBcVsc0N4QcPd61/y IHpn4O8zbDHOqGCjcjem1NxECUVSXPufflNmgGEg01BQa4xLVtPjFkc4Pke8h/mfFSdi zqYGtCeYRPPUdsWHmT8LCRJfk4Vg4v5VSGSgcJzW5rb6Nt21wcA72ee/i0BZ8tKcmrdM jVbANyDTRVyV4YS3H9K98u8s3N2Aq+A3zywjlQM4/ClSnxJPEotaXYlT3N9nWgFo8OTK hBVw== 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=Zy8BSFKM2bFSbax5Kg0akKWQ9LnNLVMQpUtsJ7wkExk=; b=eoZWKvAyHb6VQDCO8J01maQxkRPbF7CLScMUgXA8pAut5epnO2ZHjTDKNSjFPHePJ5 iDB7Co0LrCXoMjWWqsCILpoimo9ou3NQsjXj3nHYTQ8WfbdpkvuQuag8Slg9yDnDTDgt LZ8YGgwRzjvWX61kDPyuWXoDcSUwIbVRTzcrVz8ct1Zva31w3j78OOGy5urWKFHWMJ6P TTZZZEZnE/S/6EwXPzsCGQQbM3twMo4mS0WouOag+lfv5qiibWyQDw95AakUTvn1Vrlz Gn7xqRloA2znv8EEBkt8tsYSiRzDdyq0SogELnUdtB8+Advw0fGMX/DXFSL0ZYRSMnWn POvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=UmE8KBk2; 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 r68-v6si24609917pfk.151.2018.10.09.17.13.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:13:54 -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=UmE8KBk2; 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 w9A0DhqS123156; Wed, 10 Oct 2018 00:13:53 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=Zy8BSFKM2bFSbax5Kg0akKWQ9LnNLVMQpUtsJ7wkExk=; b=UmE8KBk2gPAUmdnUxRBfFjgtMB2acZrPVwvN+5lluOkBtAPiva1ro+tkKKQhL7O/6MFR jRQrFxD90D0V8B9ctEm5pabgZtjOo6gPk3Fq0Ypve5Bs3aINcS4LsGecBy85A1Rcn9Ii MAPsXpl97yCyb77Jpp8NcJB5qRD4moCoccboyDdqmBVvAcWjXWWHn0e/NCrwD8oonnTq dn+DKIEFZ7MXVZJrtUrfBSibt+ONDDR3d5nOkV3p97za+DF9heRx6HgONJMIkcgLq3AY MKZKq5fdfGClwY4W0gzf1lBA1gndBYgEwc/9D7MspQvLLY5TYVvjlaBWCBGJnZvqXUXF Qw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2mxmftrvqf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:53 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0DqXb029932 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:52 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0DqEA017741; Wed, 10 Oct 2018 00:13:52 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:13:52 +0000 Subject: [PATCH 16/25] vfs: plumb RFR_* remap flags through the vfs dedupe functions 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: Tue, 09 Oct 2018 17:13:50 -0700 Message-ID: <153913043056.32295.889586450104360207.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=470 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 Plumb a remap_flags argument through the vfs_dedupe_file_range_one functions so that dedupe can take advantage of it. Signed-off-by: Darrick J. Wong --- fs/overlayfs/file.c | 3 ++- fs/read_write.c | 9 ++++++--- include/linux/fs.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index 8b22035af4d7..8b804e86ed4d 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -467,7 +467,8 @@ static loff_t ovl_copyfile(struct file *file_in, loff_t pos_in, case OVL_DEDUPE: ret = vfs_dedupe_file_range_one(real_in.file, pos_in, - real_out.file, pos_out, len); + real_out.file, pos_out, len, + flags); break; } revert_creds(old_cred); diff --git a/fs/read_write.c b/fs/read_write.c index cf81d1f68b69..479eb810c8e6 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1983,10 +1983,12 @@ EXPORT_SYMBOL(vfs_dedupe_file_range_compare); loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, struct file *dst_file, loff_t dst_pos, - loff_t len) + loff_t len, unsigned int remap_flags) { loff_t ret; + WARN_ON_ONCE(remap_flags & ~(RFR_IDENTICAL_DATA)); + ret = mnt_want_write_file(dst_file); if (ret) return ret; @@ -2017,7 +2019,7 @@ loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, } ret = dst_file->f_op->remap_file_range(src_file, src_pos, dst_file, - dst_pos, len, RFR_IDENTICAL_DATA); + dst_pos, len, remap_flags | RFR_IDENTICAL_DATA); out_drop_write: mnt_drop_write_file(dst_file); @@ -2085,7 +2087,8 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) } deduped = vfs_dedupe_file_range_one(file, off, dst_file, - info->dest_offset, len); + info->dest_offset, len, + 0); if (deduped == -EBADE) info->status = FILE_DEDUPE_RANGE_DIFFERS; else if (deduped < 0) diff --git a/include/linux/fs.h b/include/linux/fs.h index 21f947b20f37..5c1bf1c35bc6 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1849,7 +1849,7 @@ extern int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same); extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, struct file *dst_file, loff_t dst_pos, - loff_t len); + loff_t len, unsigned int remap_flags); struct super_operations { From patchwork Wed Oct 10 00:13:57 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: 10633633 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 C7C3846E4 for ; Wed, 10 Oct 2018 00:14:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B69E1284C9 for ; Wed, 10 Oct 2018 00:14:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA86128F95; Wed, 10 Oct 2018 00:14:09 +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 1845F28ED7 for ; Wed, 10 Oct 2018 00:14:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1431B6B0283; Tue, 9 Oct 2018 20:14:08 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0F4716B0284; Tue, 9 Oct 2018 20:14:08 -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 EFC556B0285; Tue, 9 Oct 2018 20:14:07 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id ABDBD6B0283 for ; Tue, 9 Oct 2018 20:14:07 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id z28-v6so3093609pff.4 for ; Tue, 09 Oct 2018 17:14:07 -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=sepu+uz6Ad3Fwupju4VHtusxEpK/OgdYrTXJ06uLL6w=; b=UB7iMAxRg8e8npWPaE+7CGwHEST+pUuT6ULbx506FaPLHqG9rHVE7GstEBi5Xf5TxO LWG/pprlKvS8dnW15Pdd98kM8CtCnE4UBdxbZvgUD2Nio2xNscgxxhf4dKzngISvnzxT 8FbXARsNDboKjZSrLRPOTVd+cVD4dSGn/ABXWEBImG8+WzULOC/CmcvPDZhjOx7HnQCA flSyfyLxeEm1tnYLssbg6OpOFPIa7BMNYtGB4zv+Q4JnCIDYmcLK06tVgHscMZ5wbx3D uGzBN2pfUYkdi0TRMqikQlOUfmAIJbl8m5S3yG7We3caR6ASfoG/I3841kd0/DHm0Zo9 h+tA== X-Gm-Message-State: ABuFfohBz61BN0mYUAQH7tII3SA2H+R8e9D0eeyOilj4xNHyt6WA6+el 7VqKIhm+xl/aQURWIxxq/f21aDFFjYGj63QNIEVEyUuuUpb59NpEaRq1dfXTeCIHQuilHEwc01S CCilsEZmHXmBOwa4nM0bXCsozfcCaFJwok3OvNKlcddCeK74se9KGnDeS7iTpyR000A== X-Received: by 2002:a65:45c9:: with SMTP id m9-v6mr22348892pgr.212.1539130447360; Tue, 09 Oct 2018 17:14:07 -0700 (PDT) X-Google-Smtp-Source: ACcGV63LH05HgTMHbHkcCdsphCgEYedApwH2yXZ33k0NyNJBeSEMa5b/+q9vSUon5JEglUjmDi/z X-Received: by 2002:a65:45c9:: with SMTP id m9-v6mr22348849pgr.212.1539130446635; Tue, 09 Oct 2018 17:14:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130446; cv=none; d=google.com; s=arc-20160816; b=eaLfpFRv9riUviA6pDYngoLDbhg78/HKMJ9AinuUea9O4/X5XaCeU9zUGjcCO693SR o/Gtbui34JWwI3Kf3P2CasX0PZN2u620tEtPyAKbt/6UfjrVdeSYmblVBIEhgfq3iaOS /CTPIogW7t4V4RNI0RKd7vye7I/DoEgeTTXHz1ARoO94jo7J8QMc1JlF8eXOjaSciohd ZineMKXEH3SLgWgS8l6Bi5iI11ih6Y6ZN89c2iTjhecd/RvthYLmxDY7HYcoZ9iT1s55 yw3LZblL6I7GQcam79pnv/AfG7QPdr8Fa3nm86kmgZE8fx76hNVqTQCR8fzZMrxD3YT5 Sdcw== 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=sepu+uz6Ad3Fwupju4VHtusxEpK/OgdYrTXJ06uLL6w=; b=Gyi+omtrPQkEIYtyFTNVjYelsF2WhNyUJO/i1YeLo0PTI2WanBWqH+pFw3b2KAx5vv KgNpKu+ZvWrKyCC2zPMrk349HFCaPRB3z1ovsdGZej9L3UomLc5uhBHtG+sjMy35MpGu eCBR4b61ppAoP5ZiOCquBodxyKVZKaZUF3mQjCw7i3yDMoiJQC1mMALAtT8OVv895I/k XWHcbAcm9DIZll433kMqsNF3kV7WtuD3wd/3JjdFQpmsm6sr9EqZkuhEQqNVBQiAOs1D L+SLI13zM2AEvLCs267CXZs+VGuiDLaP2RzmgR8VJkIzooWKRgT6ru9wsCk+srds/TO/ fkSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=g80Y82tn; 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 d31-v6si24205256pla.256.2018.10.09.17.14.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:14:06 -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=g80Y82tn; 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 w9A0E5VP086629; Wed, 10 Oct 2018 00:14:05 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=sepu+uz6Ad3Fwupju4VHtusxEpK/OgdYrTXJ06uLL6w=; b=g80Y82tnglyS3C3gvVf1T0r1qR9ba0nGUPhubTvNBWbNICNUsu4O4PiAtk+NFBLn/SPO AiTQWqdNgP6milUUFPYQYt1MKnIIkY9BaKa9KISZM3LCqNLHiNC6Eh7Sk3PRCI3EnAHv 1C0ekLnwfk1oRpVCsFoc89kbiBAgzWzybuaKw3ketP9mKB2OdzGpacRZHtl6AoU7Mw6G eGZmeuIRWBO7HwVNFNgsuKaeq4DgBujkqtsoZl+A2HjAFkElAApgcJsFkZtZS5iQGXS/ 8ghkcwKquPkj+TVOhLFexOt1IetX+GChmdnCASlogLUbBn1MKbd2KYvv3Ni/bYJm2S8r Ow== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2mxnpr0p7y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:05 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0Dxod004803 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:13:59 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0Dxr3003971; Wed, 10 Oct 2018 00:13:59 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:13:59 +0000 Subject: [PATCH 17/25] vfs: make remapping to source file eof more explicit 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: Tue, 09 Oct 2018 17:13:57 -0700 Message-ID: <153913043746.32295.17463515265798256890.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=577 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 Create a RFR_TO_SRC_EOF flag to explicitly declare that the caller wants the remap implementation to remap to the end of the source file, once the files are locked. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/ioctl.c | 3 ++- fs/nfsd/vfs.c | 3 ++- fs/read_write.c | 13 +++++++------ include/linux/fs.h | 2 ++ 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/fs/ioctl.c b/fs/ioctl.c index 505275ec5596..7fec997abd2f 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -224,6 +224,7 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, { struct fd src_file = fdget(srcfd); loff_t cloned; + unsigned int flags = olen == 0 ? RFR_TO_SRC_EOF : 0; int ret; if (!src_file.file) @@ -232,7 +233,7 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, if (src_file.file->f_path.mnt != dst_file->f_path.mnt) goto fdput; cloned = vfs_clone_file_range(src_file.file, off, dst_file, destoff, - olen, 0); + olen, flags); if (cloned < 0) ret = cloned; else if (olen && cloned != olen) diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 726fc5b2b27a..d1f2ae08adf6 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -542,8 +542,9 @@ __be32 nfsd4_clone_file_range(struct file *src, u64 src_pos, struct file *dst, u64 dst_pos, u64 count) { loff_t cloned; + unsigned int flags = count == 0 ? RFR_TO_SRC_EOF : 0; - cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count, 0); + cloned = vfs_clone_file_range(src, src_pos, dst, dst_pos, count, flags); if (count && cloned != count) cloned = -EINVAL; return nfserrno(cloned < 0 ? cloned : 0); diff --git a/fs/read_write.c b/fs/read_write.c index 479eb810c8e6..a628fd9a47cf 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1748,11 +1748,12 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, isize = i_size_read(inode_in); - /* Zero length dedupe exits immediately; reflink goes to EOF. */ - if (*len == 0) { - if (is_dedupe || pos_in == isize) - return 0; - if (pos_in > isize) + /* + * If the caller asked to go all the way to the end of the source file, + * set *len now that we have the file locked. + */ + if (remap_flags & RFR_TO_SRC_EOF) { + if (pos_in >= isize) return -EINVAL; *len = isize - pos_in; } @@ -1828,7 +1829,7 @@ loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, struct inode *inode_out = file_inode(file_out); loff_t ret; - WARN_ON_ONCE(remap_flags); + WARN_ON_ONCE(remap_flags & ~(RFR_TO_SRC_EOF)); if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode)) return -EISDIR; diff --git a/include/linux/fs.h b/include/linux/fs.h index 5c1bf1c35bc6..9f90dcd4df3b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1725,8 +1725,10 @@ struct block_device_operations; * These flags control the behavior of the remap_file_range function pointer. * * RFR_IDENTICAL_DATA: only remap if contents identical (i.e. deduplicate) + * RFR_TO_SRC_EOF: remap to the end of the source file */ #define RFR_IDENTICAL_DATA (1 << 0) +#define RFR_TO_SRC_EOF (1 << 1) struct iov_iter; From patchwork Wed Oct 10 00:14:04 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: 10633659 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 67B6916B1 for ; Wed, 10 Oct 2018 00:14:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55F39284C9 for ; Wed, 10 Oct 2018 00:14:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3E93728F95; Wed, 10 Oct 2018 00:14: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 BCFB9284C9 for ; Wed, 10 Oct 2018 00:14:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 191176B0287; Tue, 9 Oct 2018 20:14:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 141D86B0288; Tue, 9 Oct 2018 20:14:16 -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 00A516B0289; Tue, 9 Oct 2018 20:14:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id AFFCA6B0287 for ; Tue, 9 Oct 2018 20:14:15 -0400 (EDT) Received: by mail-pl1-f197.google.com with SMTP id b23-v6so2634955pls.8 for ; Tue, 09 Oct 2018 17:14: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=Nn9zgG7G0RlSFSy0VLmRndBF9S+1SvCJgEndO9+GibM=; b=OjNSyogL6D/7EV4/rnPHYWYcYU5AoqFq9Pq8TOMU0AGwRE9Vs7qHPVfv15rIqbcMkl S65o3zbRsSxccfSsV7KnSLzQ3Hd9pan/t/DDZRmE4nPL9AEq2fo10cOrPmYE2p4szClu AX2ASSHBgGO/WfMCc4FqBUPqhFD9M+eWhMHHdGPotvcEJcmeO7JCGgU9hFSJ8Ei6EcQ3 FePz+jir1FX3PaZ8JuVeVmC8wL64yhyMXyzm0gguTE4wGdlkQA8IWtmyGzakTTBlZuy8 Hw9hWnJMQTVr31qo06CO7lFG362csy+dGejMeL520hVy0LIaQg4kLv/tZS/3r6EpnYSy QPrg== X-Gm-Message-State: ABuFfoiiwymbRUuWcM/7YqjAB8DZub9l43oCm3ebM3/cDikFgq65ieAj dd1fkM8QyQ/eDenETM6mm+eJEfvEcZGC4DmuILyXFkildsuOY2kWg53Fi9BMTAIXZ9hv7Z30qRw mooev/jIyir4+xAMVM1jFGzB6HCKVTVSGWxCgPe61c3Lb0aJGsjpB4KlkZCkiW78X6w== X-Received: by 2002:a62:3047:: with SMTP id w68-v6mr7837712pfw.19.1539130455393; Tue, 09 Oct 2018 17:14:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV62QUJpC6eciYqBB/8JAiP+CH1iYCfDNd1jr/XGB4GdCYaSix11Cjt9qoG0Yp1/UbkDPmGIV X-Received: by 2002:a62:3047:: with SMTP id w68-v6mr7837665pfw.19.1539130454671; Tue, 09 Oct 2018 17:14:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130454; cv=none; d=google.com; s=arc-20160816; b=SozqBBciirNjCu5IqpY1TgV5jg/Pu8MyoSumTuWLbFlqibAY7lRb2INrdCvs0ysseF 7ehd0hkEUP+jkBL6qIw9xHNBmKe3+nyrMZvuG11WtBZ5nkzHrf9TYg4eZ/0yCghSfQUV WwFu5C+fXM9GZ4xCAJBb/4H37LOXrgqUHzWQbX5kuTj7Gt46ezROYLUB3xrC6op781Gk ky9sMHhSXq4jpROnNW+6StPQblx4KyA8VfFcBeyXrGiU1p+eT72jJw8WV/1pJgHPP0Hz SIEf6Z5QY72jtmjmEX9cdKv1tjvVA4pQb8qwga7GPyFLu5Av5qWPDi7f7QlCMB66+pE1 7VpA== 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=Nn9zgG7G0RlSFSy0VLmRndBF9S+1SvCJgEndO9+GibM=; b=CxlGafD3YZes7HFb35QEwdDby1PHLOV1aYlQx8ksM8kr2LuFwGTaVfNcdinC4g5dQ+ veZZ/EXXRtMhIEoT2nZJOAQ/8WbO/dF2edQ27D4ZQUy+p04ATEc7wBaFMaoelldGDOse jYkfL6KgMA3y/3snu07gju1XseLcFi12c2RqHzHATETaJMaNCoEESah6P8a2TKnABE9a qkZhZfAS/BDVt/GL88OSmzLDMX0ZmoismQy2AehHkXjOaZNGDQSs0AN8qBRaYpBFZQhE b2sz0jdkedxjVANZYU2kLG2F7rO7YWnA+lfK4JrnSrMEdkvMQpZ54MQ0sIrA4hvN0HeY qOEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=2eDQHC6W; 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 b127-v6si22140174pga.153.2018.10.09.17.14.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:14: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=2eDQHC6W; 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 w9A0EDxM086695; Wed, 10 Oct 2018 00:14: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=Nn9zgG7G0RlSFSy0VLmRndBF9S+1SvCJgEndO9+GibM=; b=2eDQHC6WJ553rjahcYxaCchlOIZC2rsx002DnL+bErYIlutVXMEJPwUYWKR035gC1hTZ 7J0ZhaDWpqg99hxravevj4NxQ/IleUd0yvHkdP14aJCff2HSgCc6I5l63KbCUR2NUH0r S0uU9UdpgYNIQyjaC/qCb/bFOeMtbTV9zuxZdbRhL89ZjAl61gmNPHVMHzyaleYoli3T BnEoXWc9mXsUSsVpa+W24QzqouzA+yuBX0cTZ+Q0mtBR8m+SLBBzrogEXzVROwR9FIBM S7ApEHPqtFJiwbvj9x2Kuie3THLJv2mC1Z+jacGDkKTS0UfF4PKEkDuFqbRcLDRRjtxg sQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2mxnpr0p8k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:13 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0E6Bc032377 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:07 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0E6fg004026; Wed, 10 Oct 2018 00:14:06 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:14:05 +0000 Subject: [PATCH 18/25] vfs: enable remap callers that can handle short operations 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: Tue, 09 Oct 2018 17:14:04 -0700 Message-ID: <153913044431.32295.9717425324455762449.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=860 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 Plumb in a remap flag that enables the filesystem remap handler to shorten remapping requests for callers that can handle it. Now copy_file_range can report partial success (in case we run up against alignment problems, resource limits, etc.). Signed-off-by: Darrick J. Wong --- fs/read_write.c | 3 ++- include/linux/fs.h | 2 ++ mm/filemap.c | 16 ++++++++++++---- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index a628fd9a47cf..8ed0aed81649 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1593,7 +1593,8 @@ ssize_t vfs_copy_file_range(struct file *file_in, loff_t pos_in, cloned = file_in->f_op->remap_file_range(file_in, pos_in, file_out, pos_out, - min_t(loff_t, MAX_RW_COUNT, len), 0); + min_t(loff_t, MAX_RW_COUNT, len), + RFR_CAN_SHORTEN); if (cloned >= 0) { ret = cloned; goto done; diff --git a/include/linux/fs.h b/include/linux/fs.h index 9f90dcd4df3b..e0494d719ebc 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1726,9 +1726,11 @@ struct block_device_operations; * * RFR_IDENTICAL_DATA: only remap if contents identical (i.e. deduplicate) * RFR_TO_SRC_EOF: remap to the end of the source file + * RFR_CAN_SHORTEN: caller can handle a shortened request */ #define RFR_IDENTICAL_DATA (1 << 0) #define RFR_TO_SRC_EOF (1 << 1) +#define RFR_CAN_SHORTEN (1 << 2) struct iov_iter; diff --git a/mm/filemap.c b/mm/filemap.c index 2522737483de..2179d0204ee6 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3064,8 +3064,12 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, if (pos_in + count == size_in) { bcount = ALIGN(size_in, bs) - pos_in; } else { - if (!IS_ALIGNED(count, bs)) - return -EINVAL; + if (!IS_ALIGNED(count, bs)) { + if (remap_flags & RFR_CAN_SHORTEN) + count = ALIGN_DOWN(count, bs); + else + return -EINVAL; + } bcount = count; } @@ -3076,10 +3080,14 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, pos_out < pos_in + bcount) return -EINVAL; - /* For now we don't support changing the length. */ - if (*req_count != count) + /* + * We shortened the request but the caller can't deal with that, so + * bounce the request back to userspace. + */ + if (*req_count != count && !(remap_flags & RFR_CAN_SHORTEN)) return -EINVAL; + *req_count = count; return 0; } From patchwork Wed Oct 10 00:14:11 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: 10633669 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 E949616B1 for ; Wed, 10 Oct 2018 00:14:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB28C284C9 for ; Wed, 10 Oct 2018 00:14:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF63F28FE7; Wed, 10 Oct 2018 00:14:21 +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=unavailable 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 1D3DA284C9 for ; Wed, 10 Oct 2018 00:14:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 068666B0289; Tue, 9 Oct 2018 20:14:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E3A1C6B028B; Tue, 9 Oct 2018 20:14:17 -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 C67276B028A; Tue, 9 Oct 2018 20:14:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 747EF6B0288 for ; Tue, 9 Oct 2018 20:14:17 -0400 (EDT) Received: by mail-pl1-f200.google.com with SMTP id 43-v6so2667546ple.19 for ; Tue, 09 Oct 2018 17:14:17 -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=qfspqRNHCaOaTIBE4rkWnm0h3QBJGde2tP1fYMCNyPE=; b=c5B2DahSP3n4rTy9rs80SY6Yrv5tkTWwMVZKbEUQQpmNtmrmFoyU6cDIPTw2AeS8YM XAgJgOBcQ4PvpY8AQ0JJCfNvGOmSkAYnEvjnKTTckKE3HcY34WHqDBMcH0mCH2mAFn0O rQG9QdUEHgio1BwYhG5og9DliI9AdtTTBtZUg6xqqZE82bkIAC4C9IbcRG6B0s+77eLw eVrFdA1UPiFHeC+7+AhCTHxZEz9JB7aBlVixK7650ft64CiBsNKjYhJ3n0uODaEFCL3B /69WpPKctZk8FSdpxxKbCUALZvahyG5pFkLMWtPWYMBCMQniLukE1o1VV2m4R3Cc6Tgr jGxA== X-Gm-Message-State: ABuFfoiWfMo5jc11D3tRew7khT21/sAePF2kjFwlXG9kpVzTsrm3XcF9 62icMPWRcWFvbLfYhhwhkx6xHNkn2T878Kl2mBHYNsf3UyO7Ohm4qb+TBRrEvYxlvBe9ErbOJlb OxlulNZmyDgX9bWPzTzkQIky+Uf3Ugoq6q8rBda/1S4JwwmqFpItHDiU7oFzgvFaWZQ== X-Received: by 2002:a63:214d:: with SMTP id s13-v6mr27708128pgm.148.1539130456674; Tue, 09 Oct 2018 17:14:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV61zMHvCxrqJ5IbE9VICfsVL/R5TagCxWiitXBoEwFMOgP+oIvh+NBhNMb2tvSTnlKyJXJL5 X-Received: by 2002:a63:214d:: with SMTP id s13-v6mr27708089pgm.148.1539130455867; Tue, 09 Oct 2018 17:14:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130455; cv=none; d=google.com; s=arc-20160816; b=ShoQ5lllfsI6TFLTsBc+qB1yc4InmNBiFq7OD48BN+QvXX80900wwroGpEfEXDL9nO xBQlBkj4MxUNFxeNvZwbL2fbVpgiKGd5yeSQ0McZd7aimQPMFgf1+96u7SXT67MnrCDb Y3PbNBpBJ8bdOyXqz3Z7HoqbuwByD/ARB0K6PQji1xuG2z8IgCswr4DgJVqh/0oedZwj m3dQcINdBEDCHFVrdAynxhNmqVV4XtpAnk5Qogcy4KWyehWfhQ6obwHaZd0DkqJUuo4e Vt6ovW0P+DpiXAjvITnx/EYBbFV5CL+jZeVKXOogXiyYUaaaY22Cbx5wSeQiaDN4lC/W 50kQ== 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=qfspqRNHCaOaTIBE4rkWnm0h3QBJGde2tP1fYMCNyPE=; b=PoMXR5ZrZNQS1E6qkqE+rpfpEUt0PZeqatVRSNhsTCmQWddKZOUef8+X7f+liDL3g7 YXjYOFJXB1g65XalefKHv6WBtZgE2yu2NGZA6KzP9n51MvEkRgGA68pHr3I3eGmekfYV jwwr8prilFEBSwXLjGZ13t5zFpZ6e5Lg/rYuNuQfLvWR8pzguGkrwOorvCqT2TgefV9X XevWXnVL6Bw9Uz5spoB7ehe3JS2DbYyWePAkYsRuhx2z8ho2ReWdr7wr8IDoLaBgR8Y7 QC7zbqN4LtoEsD14KDqPZTwZzp6GlS/IdjiV1LpuSU0uvGeOKIjOjCU7NCY/Wh04zVW8 PZ/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=t2ITIMkC; 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 u192-v6si21419299pgu.449.2018.10.09.17.14.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:14:15 -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=t2ITIMkC; 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 w9A0Df3O123119; Wed, 10 Oct 2018 00:14:15 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=qfspqRNHCaOaTIBE4rkWnm0h3QBJGde2tP1fYMCNyPE=; b=t2ITIMkCFMzrTPnnp6mVgDbqDBECcdE15lUZHVgSxYMxZuVCnMS0tTj4i26V5YHsfD0J L2IOj8cYrJs2mrH2hiCSs3nojXUDRPJCaobzsU4pJjn7d4vYLyLtDb9Je2Wz82LLdEDO HoWIKh6vAmJLHXK2TGYg4NGS5FXO+Cb/CJy0Ln4yk+c9GZacRMC0Fg4DxFYVICJvH9nH qr9tYkFB8sb1WXU/uGiuolQ39GxMXVc1pmOsD906fm9949OrEV4FOByrM0/hTBnPOKea 1iCjg7izNpFtdg3iQTRVz6MyxHHVPGI9icaQpKZ52LwRotKt15sD28WUl890/dmIO0uT kA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2mxmftrvs0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:14 +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 w9A0EDdB032636 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:14 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0ECSo021892; Wed, 10 Oct 2018 00:14:13 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:14:12 +0000 Subject: [PATCH 19/25] vfs: hide file range comparison function 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: Tue, 09 Oct 2018 17:14:11 -0700 Message-ID: <153913045111.32295.15783645423071362029.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=632 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 There are no callers of vfs_dedupe_file_range_compare, so we might as well make it a static helper and remove the export. Signed-off-by: Darrick J. Wong --- fs/read_write.c | 191 ++++++++++++++++++++++++++-------------------------- include/linux/fs.h | 3 - 2 files changed, 95 insertions(+), 99 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 8ed0aed81649..57627202bd50 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1714,6 +1714,101 @@ static int remap_verify_area(struct file *file, loff_t pos, loff_t len, return security_file_permission(file, write ? MAY_WRITE : MAY_READ); } +/* + * Read a page's worth of file data into the page cache. Return the page + * locked. + */ +static struct page *vfs_dedupe_get_page(struct inode *inode, loff_t offset) +{ + struct address_space *mapping; + struct page *page; + pgoff_t n; + + n = offset >> PAGE_SHIFT; + mapping = inode->i_mapping; + page = read_mapping_page(mapping, n, NULL); + if (IS_ERR(page)) + return page; + if (!PageUptodate(page)) { + put_page(page); + return ERR_PTR(-EIO); + } + lock_page(page); + return page; +} + +/* + * Compare extents of two files to see if they are the same. + * Caller must have locked both inodes to prevent write races. + */ +static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, + struct inode *dest, loff_t destoff, + loff_t len, bool *is_same) +{ + loff_t src_poff; + loff_t dest_poff; + void *src_addr; + void *dest_addr; + struct page *src_page; + struct page *dest_page; + loff_t cmp_len; + bool same; + int error; + + error = -EINVAL; + same = true; + while (len) { + src_poff = srcoff & (PAGE_SIZE - 1); + dest_poff = destoff & (PAGE_SIZE - 1); + cmp_len = min(PAGE_SIZE - src_poff, + PAGE_SIZE - dest_poff); + cmp_len = min(cmp_len, len); + if (cmp_len <= 0) + goto out_error; + + src_page = vfs_dedupe_get_page(src, srcoff); + if (IS_ERR(src_page)) { + error = PTR_ERR(src_page); + goto out_error; + } + dest_page = vfs_dedupe_get_page(dest, destoff); + if (IS_ERR(dest_page)) { + error = PTR_ERR(dest_page); + unlock_page(src_page); + put_page(src_page); + goto out_error; + } + src_addr = kmap_atomic(src_page); + dest_addr = kmap_atomic(dest_page); + + flush_dcache_page(src_page); + flush_dcache_page(dest_page); + + if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len)) + same = false; + + kunmap_atomic(dest_addr); + kunmap_atomic(src_addr); + unlock_page(dest_page); + unlock_page(src_page); + put_page(dest_page); + put_page(src_page); + + if (!same) + break; + + srcoff += cmp_len; + destoff += cmp_len; + len -= cmp_len; + } + + *is_same = same; + return 0; + +out_error: + return error; +} + /* * Check that the two inodes are eligible for cloning, the ranges make * sense, and then flush all dirty data. Caller must ensure that the @@ -1887,102 +1982,6 @@ loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, } EXPORT_SYMBOL(vfs_clone_file_range); -/* - * Read a page's worth of file data into the page cache. Return the page - * locked. - */ -static struct page *vfs_dedupe_get_page(struct inode *inode, loff_t offset) -{ - struct address_space *mapping; - struct page *page; - pgoff_t n; - - n = offset >> PAGE_SHIFT; - mapping = inode->i_mapping; - page = read_mapping_page(mapping, n, NULL); - if (IS_ERR(page)) - return page; - if (!PageUptodate(page)) { - put_page(page); - return ERR_PTR(-EIO); - } - lock_page(page); - return page; -} - -/* - * Compare extents of two files to see if they are the same. - * Caller must have locked both inodes to prevent write races. - */ -int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, - struct inode *dest, loff_t destoff, - loff_t len, bool *is_same) -{ - loff_t src_poff; - loff_t dest_poff; - void *src_addr; - void *dest_addr; - struct page *src_page; - struct page *dest_page; - loff_t cmp_len; - bool same; - int error; - - error = -EINVAL; - same = true; - while (len) { - src_poff = srcoff & (PAGE_SIZE - 1); - dest_poff = destoff & (PAGE_SIZE - 1); - cmp_len = min(PAGE_SIZE - src_poff, - PAGE_SIZE - dest_poff); - cmp_len = min(cmp_len, len); - if (cmp_len <= 0) - goto out_error; - - src_page = vfs_dedupe_get_page(src, srcoff); - if (IS_ERR(src_page)) { - error = PTR_ERR(src_page); - goto out_error; - } - dest_page = vfs_dedupe_get_page(dest, destoff); - if (IS_ERR(dest_page)) { - error = PTR_ERR(dest_page); - unlock_page(src_page); - put_page(src_page); - goto out_error; - } - src_addr = kmap_atomic(src_page); - dest_addr = kmap_atomic(dest_page); - - flush_dcache_page(src_page); - flush_dcache_page(dest_page); - - if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len)) - same = false; - - kunmap_atomic(dest_addr); - kunmap_atomic(src_addr); - unlock_page(dest_page); - unlock_page(src_page); - put_page(dest_page); - put_page(src_page); - - if (!same) - break; - - srcoff += cmp_len; - destoff += cmp_len; - len -= cmp_len; - } - - *is_same = same; - return 0; - -out_error: - return error; -} -EXPORT_SYMBOL(vfs_dedupe_file_range_compare); - loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, struct file *dst_file, loff_t dst_pos, loff_t len, unsigned int remap_flags) diff --git a/include/linux/fs.h b/include/linux/fs.h index e0494d719ebc..9c53276979bb 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1846,9 +1846,6 @@ extern loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, extern loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, loff_t len, unsigned int remap_flags); -extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, - struct inode *dest, loff_t destoff, - loff_t len, bool *is_same); extern int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same); extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, From patchwork Wed Oct 10 00:14:17 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: 10633687 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 F1C7B16B1 for ; Wed, 10 Oct 2018 00:14:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0654284C9 for ; Wed, 10 Oct 2018 00:14:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D3ECB28F95; Wed, 10 Oct 2018 00:14:29 +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 40B70284C9 for ; Wed, 10 Oct 2018 00:14:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E16036B028B; Tue, 9 Oct 2018 20:14:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DC4AF6B028C; Tue, 9 Oct 2018 20:14:27 -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 C650F6B028D; Tue, 9 Oct 2018 20:14:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 7E5086B028B for ; Tue, 9 Oct 2018 20:14:27 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id i76-v6so3231966pfk.14 for ; Tue, 09 Oct 2018 17:14:27 -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=izu6oMi2WH3dJKrh0/K4DYA0ov4dLCE6r3c64m1rEY8=; b=at6Mg+mMA2rVvRZzjqvoxAbrva5WEOsDxKhjzbyTFv+9ZYi71cwLAIqzkvdOyZfXzm thMYtcJCkYmWOgaqOnoXrq8+JlSowHDTrPWnANZL9Opkj0v2+QKSENK0HE5Uy/5WiJWd EkqHbTxadPxWZvNXbHZo59QGVHmv1tTI689JMc7mzHTFUQc5BmsLLlPQFoNWOzRg/EQc FLobzhZs4FCaEF22+iqRD3ybPHfZsPvPgAW7qHNy3LOEIXOtK2J8J1Efxzj8RQM7OmZB mQCdRPheXEG2Vug+LtLdOOr/o93x1XBL7VjR1sS7HolkBwmTbVL3Glr8NTcOU5L1/Z9o kqgA== X-Gm-Message-State: ABuFfogikr+Y8fqRwvULaXRpL3bmVT+2LQhkkQ3q3UmDLQzjoI40NmyU CixusNHbX7LW4eL3Tquu+sOSdsQrHFqDqPGNAX7rveYOabeYs7bVwVRD3k6LEEjY8qnnqI+LFVF Diq22Q3k/C/og2C6oz7POeuGQcTfLt7GY1iqbNAudZd4dyk+uFg8pM4xRo289VQwkJA== X-Received: by 2002:a65:62d5:: with SMTP id m21-v6mr28118332pgv.243.1539130467174; Tue, 09 Oct 2018 17:14:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ee/lIZvkBsbCf8rPiEt+cn68FSTVRxo+FHxsH5T6CLJDWYtX95q8ei6JcsHJz0z+jUwNK X-Received: by 2002:a65:62d5:: with SMTP id m21-v6mr28118284pgv.243.1539130466322; Tue, 09 Oct 2018 17:14:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130466; cv=none; d=google.com; s=arc-20160816; b=L+gmfY2lBAEQtWUWEl0IKSDsLJKZu4KZrxmd4WJ1Dry1G4vGZ/fG86j4uBNdNaBQ+E lB4GvmywR2E2mrmOdlZmxd++McabdKXSNXuUNqBiu7NvIdHJm/yn6JrNul7E+ueDa0W6 uXoSzcIicAnIb0C0npU5C4bm/JHZmcr6AvtjCW1bUL25AadiLzBOsPuNBvug6koMrmjA opa7lqGOWmKwJQzgcFTR4dKkfHwOjAqS2kwTfhbgSFqYCvzimhWNP3TlqBAdT5lwT5Wj 1qoU6NhVEzZpnbY4bNloyhBgMEur5Eb7zce1nVBgOmmJ9Y4NwmnJPb77WXlBcx8wkENq pj+g== 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=izu6oMi2WH3dJKrh0/K4DYA0ov4dLCE6r3c64m1rEY8=; b=HIrkxAVIaRFq1kYBLlCHWueChpV+b2des++STwXkRd61wtZ9JT1p57fo1qZhMI3I5C bXyTQWw8VpEDDle6DRhWO3KuL+9O3i4IFnJnkYOKUoiI3FFZ0YoDqrdcRtGykxoKhjrE +Nyl4GiLS6rSg3R+xdiT2zGK+hzSUinLgo2NHxtmzmvkZ/sN1TzTeywbDwqgC/Y4DVsv AcI9JT7ctfvRBrZycXUl0rtAbn8Z44FMLzFI3PYLMgksohgg0C5QoJZH0JSMcZAYRS9b TXv3EHT71xFs1bHIngHzfTt+n3nsU3DUIhSbVFPKFnXrg4ew/HXdCQdy9PXYCKghKk6D 1RBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=hiaqHpxK; 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 v33-v6si21882685pga.450.2018.10.09.17.14.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:14:26 -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=hiaqHpxK; 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 w9A0E25O123304; Wed, 10 Oct 2018 00:14:25 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=izu6oMi2WH3dJKrh0/K4DYA0ov4dLCE6r3c64m1rEY8=; b=hiaqHpxKLXDkHyzghXC0JxNwAbk3XrhUDLnIx0m3srSfpW+iXlo38SIKxa5CBCEM4KlN oe0Fuwjk1h60oOMf3b7Vs5SWqxdwTGsOeCPW+LhR4K5mNhtzHGE8Mti4gdbtFahJtjOJ y3bg5MPn4Ev+FZDcTNC8MZ3T8Vbk9UCjVNJ4F2tvqEVSCBewblGiNQ6NM6iw1ZD7cjhf xhX+LAEWgiZtpOuxNhzMsl3naMHO31mpgtAGQLUB5fW70OEl6OOG89w3DR71x/l2h840 pFMPVSTcUL22IybzVVZTw67V6mexwTNfDUxGhFSOO1baUmpz9UJA7lMZWJZUpvOHt/Af zA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2mxmftrvss-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:25 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0EJtd031498 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:19 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0EJPb017991; Wed, 10 Oct 2018 00:14:19 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:14:19 +0000 Subject: [PATCH 20/25] vfs: implement opportunistic short dedupe 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: Tue, 09 Oct 2018 17:14:17 -0700 Message-ID: <153913045787.32295.7018909865132108315.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=982 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 For a given dedupe request, the bytes_deduped field in the control structure tells userspace if we managed to deduplicate some, but not all of, the requested regions starting from the file offsets supplied. However, due to sloppy coding, the current dedupe code returns FILE_DEDUPE_RANGE_DIFFERS if any part of the range is different. Fix this so that we can actually support partial request completion. Signed-off-by: Darrick J. Wong --- fs/read_write.c | 59 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 57627202bd50..8be3c3add030 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1737,13 +1737,26 @@ static struct page *vfs_dedupe_get_page(struct inode *inode, loff_t offset) return page; } +static unsigned int vfs_dedupe_memcmp(const char *s1, const char *s2, + unsigned int len) +{ + const char *orig_s1; + + for (orig_s1 = s1; len > 0; s1++, s2++, len--) + if (*s1 != *s2) + break; + + return s1 - orig_s1; +} + /* * Compare extents of two files to see if they are the same. * Caller must have locked both inodes to prevent write races. */ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, struct inode *dest, loff_t destoff, - loff_t len, bool *is_same) + loff_t *req_len, + unsigned int remap_flags) { loff_t src_poff; loff_t dest_poff; @@ -1751,8 +1764,11 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, void *dest_addr; struct page *src_page; struct page *dest_page; - loff_t cmp_len; + loff_t len = *req_len; + loff_t same_len = 0; bool same; + unsigned int cmp_len; + unsigned int cmp_same; int error; error = -EINVAL; @@ -1762,7 +1778,7 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, dest_poff = destoff & (PAGE_SIZE - 1); cmp_len = min(PAGE_SIZE - src_poff, PAGE_SIZE - dest_poff); - cmp_len = min(cmp_len, len); + cmp_len = min_t(loff_t, cmp_len, len); if (cmp_len <= 0) goto out_error; @@ -1784,7 +1800,10 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, flush_dcache_page(src_page); flush_dcache_page(dest_page); - if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len)) + cmp_same = vfs_dedupe_memcmp(src_addr + src_poff, + dest_addr + dest_poff, cmp_len); + same_len += cmp_same; + if (cmp_same != cmp_len) same = false; kunmap_atomic(dest_addr); @@ -1802,7 +1821,17 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, len -= cmp_len; } - *is_same = same; + /* + * If less than the whole range matched, we have to back down to the + * nearest block boundary. + */ + if (*req_len != same_len) { + if (!(remap_flags & RFR_CAN_SHORTEN)) + return -EINVAL; + + *req_len = ALIGN_DOWN(same_len, dest->i_sb->s_blocksize); + } + return 0; out_error: @@ -1879,13 +1908,11 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, * Check that the extents are the same. */ if (is_dedupe) { - bool is_same = false; - ret = vfs_dedupe_file_range_compare(inode_in, pos_in, - inode_out, pos_out, *len, &is_same); + inode_out, pos_out, len, remap_flags); if (ret) return ret; - if (!is_same) + if (*len == 0) return -EBADE; } @@ -1988,7 +2015,7 @@ loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, { loff_t ret; - WARN_ON_ONCE(remap_flags & ~(RFR_IDENTICAL_DATA)); + WARN_ON_ONCE(remap_flags & ~(RFR_IDENTICAL_DATA | RFR_CAN_SHORTEN)); ret = mnt_want_write_file(dst_file); if (ret) @@ -2037,6 +2064,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) int i; int ret; u16 count = same->dest_count; + unsigned int remap_flags = 0; loff_t deduped; if (!(file->f_mode & FMODE_READ)) @@ -2073,6 +2101,15 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) same->info[i].status = FILE_DEDUPE_RANGE_SAME; } + /* + * We can't allow the dedupe implementation to shorten the request if + * there are multiple dedupe candidates because each candidate might + * shorten the request by a different amount due to EOF and allocation + * block size mismatches. + */ + if (count == 1) + remap_flags |= RFR_CAN_SHORTEN; + for (i = 0, info = same->info; i < count; i++, info++) { struct fd dst_fd = fdget(info->dest_fd); struct file *dst_file = dst_fd.file; @@ -2089,7 +2126,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same) deduped = vfs_dedupe_file_range_one(file, off, dst_file, info->dest_offset, len, - 0); + remap_flags); if (deduped == -EBADE) info->status = FILE_DEDUPE_RANGE_DIFFERS; else if (deduped < 0) From patchwork Wed Oct 10 00:14:24 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: 10633697 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 13F0C5CAF for ; Wed, 10 Oct 2018 00:14:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0327028FA5 for ; Wed, 10 Oct 2018 00:14:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBE1E28F95; Wed, 10 Oct 2018 00:14:32 +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 8D16A28FE7 for ; Wed, 10 Oct 2018 00:14:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6ED7C6B028D; Tue, 9 Oct 2018 20:14:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 623536B028E; Tue, 9 Oct 2018 20:14:30 -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 49F5A6B028F; Tue, 9 Oct 2018 20:14:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 030876B028D for ; Tue, 9 Oct 2018 20:14:30 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id n81-v6so3201409pfi.20 for ; Tue, 09 Oct 2018 17:14:29 -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=dIxJEPGoGcvBJJu/MvYn4xLmNP7rYi1FOse/8BNxuhM=; b=PayRx8OK75ABouKsKnUZvYi/e3c7ke7Mg8QRcY/1qfMOtWEqW4WMbRZ28a46CE0cwq UvwrrLt9zM9sg5QQfvdzwPZpvHC2FAhxi3EQ0msdq+uavB6D6BDHWrRDqfOBJJEapD7X 6ZiwAgsGrhqyy5uaQPN3eGkdCOFgc6DmKcX6ssn2SIFKwGQFsJK2R/8pBDgBFIzMDLP3 ThioZ03SUN5I5/Xvie1TwxE0Xj1BvpQU/xkm+NPeL/iREiNDX83D1wSTdOUjuvnLHkr8 N9ndioMW8nuomA58yVXjS9i+YVhzzHgDGvYdWh8nBB+PcxRYoHIsDPnxNsO2Hb2xuf1L uhOg== X-Gm-Message-State: ABuFfogYOJ4G43Ew1ENVCDZe8MCgY02XTngA/Gc72HGwFUXWNmX7DSme dZVQ80u76XsEtzq5p1/tzehB2WyrjQCyDxQHMKog5gOGELeVy3y+RIo3YM/qr64vsixOilG6tSn F2LpMDmqMOKUmEZyrzjk4U6W1z3WyVGUsr4VZRE8BsTC9V0nNvNrt1dwNOu/uHi3hhw== X-Received: by 2002:a17:902:d01:: with SMTP id 1-v6mr31208514plu.88.1539130469687; Tue, 09 Oct 2018 17:14:29 -0700 (PDT) X-Google-Smtp-Source: ACcGV608HQPBM2qRxCw2yhBPe5I5PXbKPkKPl/nlmMdbmkkJZFXMDFNLhiEZTILJ8V7FKHkv0Lly X-Received: by 2002:a17:902:d01:: with SMTP id 1-v6mr31208490plu.88.1539130469128; Tue, 09 Oct 2018 17:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130469; cv=none; d=google.com; s=arc-20160816; b=zfPS+2hT0tp+IH+A4gtOYyhtI4qjsLHwlZaq5zgzSaNbbDTWfDD61vXjsvHY7I9zkS V4F3WYDSUA3T/tGq2YeeoUwIgQ7E4V2kADrx35AK6rAuOoPc9Itlq35rLMPpY+eNcVF8 TpF7x474dH6opSmLlbDZ6tRccr7IC7ZVtRUvUJOS9w3FTepkKaAaHC52C35TIOw8AHvN jB90Uw4KwPCbPvm6IM4wz4F0wKqSX3RyKfsucNfK9pDPKoxAiWgUsUnodFKre3Q5SS9R wObCHyniw/DLZiXV0wKClLbPLueliiFBEU9jBt6s0lyOSsHR2VKwrtcK81GPE1uj6sPy ZqZw== 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=dIxJEPGoGcvBJJu/MvYn4xLmNP7rYi1FOse/8BNxuhM=; b=FmdXR8ZQ5M62cGLU2F62Rdj/f4nIgxOIr2iw9Gd0CwdUwNkGAe15UgoSpMn84818FV k28+iw5Xrqk9+3h2CDF9cj4+CaEzIhOqByanhazrCV/mu0MnwSBUv4ejT5gH5rnZ6Ec3 LP3VJCzyI/Fa627kZXCAkYd679A2Ar22/r58JKmofQe7xj7EgZfpIGvxWEMt8DXFmzrn L4rW38916ivB0tdPdt2Vvrsa1mEur0ggCe+oERMaH5FHJpp+t395+BzXIyNk47OSgB+y 0WyAY4wqo2LwzR+zzcY45b7v7bVib1ueE81rdXvMxIr9FsbZQb96M/WNYyiV0LrVtY6b MGqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="m6/DWy2J"; 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 a15-v6si22635039plm.216.2018.10.09.17.14.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:14:29 -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="m6/DWy2J"; 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 w9A0DduV141873; Wed, 10 Oct 2018 00:14:28 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=dIxJEPGoGcvBJJu/MvYn4xLmNP7rYi1FOse/8BNxuhM=; b=m6/DWy2JYP34yF2sN/7OOy2mlIFl0E/btCWrbcKqPuBa3anUDHZINMahnTMTwQeb1WjP 0ACpWRrGPbps6hlVyJUJPTGLvouwslGl8eUv9vboKMBkACZ/LDWHxkiq0ZBmCLcHUDLF 8FV56ha+UtSRGNfGnRUkPVzQw5k7wEosue48V+dQ+luSZ9lW2BdclQZ2dWUpGBi9aikt 8s0msKvCQ2cWoelmXZJilouF94fv7FhiP8X6JGeEspzVVKo+XiTXxkYkM4JJe6rkSUYC z1+Isxkp2uYujpd8LFNvGYODG1cWt3DBUowxFBbF7rZYdwN7uh8xF3emxqLXNcXvlTIF OA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2mxn0q0ttp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:28 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0ERc9006021 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:27 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0EQGI004266; Wed, 10 Oct 2018 00:14:26 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:14:26 +0000 Subject: [PATCH 21/25] ocfs2: truncate page cache for clone destination file before remapping 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: Tue, 09 Oct 2018 17:14:24 -0700 Message-ID: <153913046462.32295.3245494254410288586.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=784 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 When cloning blocks into another file, truncate the page cache before we start remapping blocks so that concurrent reads wait for us to finish. Signed-off-by: Darrick J. Wong --- fs/ocfs2/refcounttree.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index a3df118bf3b9..851ba3ae7ce8 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4869,14 +4869,12 @@ int ocfs2_reflink_remap_range(struct file *file_in, down_write_nested(&OCFS2_I(inode_out)->ip_alloc_sem, SINGLE_DEPTH_NESTING); - ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, - out_bh, pos_out, len); - /* Zap any page cache for the destination file's range. */ - if (!ret) - truncate_inode_pages_range(&inode_out->i_data, pos_out, - PAGE_ALIGN(pos_out + len) - 1); + truncate_inode_pages_range(&inode_out->i_data, pos_out, + PAGE_ALIGN(pos_out + len) - 1); + ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, + out_bh, pos_out, len); up_write(&OCFS2_I(inode_in)->ip_alloc_sem); if (!same_inode) up_write(&OCFS2_I(inode_out)->ip_alloc_sem); From patchwork Wed Oct 10 00:14:31 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: 10633715 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 31FE516B1 for ; Wed, 10 Oct 2018 00:14:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E539284C9 for ; Wed, 10 Oct 2018 00:14:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FA8028F95; Wed, 10 Oct 2018 00:14:39 +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 99458284C9 for ; Wed, 10 Oct 2018 00:14:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7ADE6B028F; Tue, 9 Oct 2018 20:14:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D33D96B0290; Tue, 9 Oct 2018 20:14: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 BC9156B0291; Tue, 9 Oct 2018 20:14:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 77A556B028F for ; Tue, 9 Oct 2018 20:14:36 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id i76-v6so3232233pfk.14 for ; Tue, 09 Oct 2018 17:14: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=Icc+JrsLPRZVtCMs/wn62urfmv9Yq+ib7pEnkq7mY+Y=; b=ObGh4nAIditTZgkkjl7VIo0pMSka93y96Bbqi5DO4nFEc3jEx7FjKoLGIuEHRNLF+K u++XJZ3U+SeusfWHvM+d+PdB5phTnD+SRCa/2o/+Jxu+kpKnVZETcQrJnMwWsNZwHyQ0 oHB6hwTW68odOJuwVAvNJ+9P09iGsC3lyPAr9ZJUXM+qVw7+6tChesXYHulX+ElhVkgr z1be8KixT6CE1pb1mE7K6s7LD56wsxaMnjJ0edRkYcFvc1ptcCeClk4gW98fZUi5riLh FRRzFMjRz5OoOy4zq0+D0wmTWhz8YcPJQTU6e56LhiawzY59PSJ+kYtPjsM8yfpBoOd9 fcTw== X-Gm-Message-State: ABuFfojfSry+RHNARqMm8wu1mOigUT3A2cZp83pbFGVCVTjeS1rfN462 9JGDFmCrx1N3U5FDCRBdR5V6J+Nn7Wn4Z9s02IluIcpNFOEitLSzakxJgGLxYWdEKFmVw+MFNJD PbGCaieYJjhJPl4vpU+5rfJd/DwaJyM4Oz2ttJZ8A37d13DnPhkoES+92eMRNlo2SKQ== X-Received: by 2002:a17:902:f01:: with SMTP id 1-v6mr30790846ply.8.1539130476176; Tue, 09 Oct 2018 17:14:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Wsfhm3N6A2kpOgcP4XPAPRdXbF2HgYxbGBeBWLz2p1A/XyJ9pf7g3uIPWGU02ak0AyMys X-Received: by 2002:a17:902:f01:: with SMTP id 1-v6mr30790806ply.8.1539130475579; Tue, 09 Oct 2018 17:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130475; cv=none; d=google.com; s=arc-20160816; b=txxY4Qj0bLAACG5GZ/HeKic4iOLZVFrm7gq65Cs7tdBDUeUb69PzkQY6tNbeKeLRxs 8ZOYlSRYiKPawuGcv4SETBZoGnNmWfFumQM7RL+hnpQt2x0VPcn9eT3lYuGIj5kupQcD 4xztK7zPIm8CV729dNVxSICxR27cNZY2ZVpsDBabr9SBCp/XsddhWaTnpeJ+Mrq3rDuS sRBXDpv547CXuBBz3X1CFgl5kwACaaxM/0kPizpksIfovmCcjz8XgcGy23zU90KZNscf p3G/JAdEP0Iv2Kk9lkbY2BgXi2YvHLRTCgDz6c72bAt3oN/SWLUFjd9Rw8c7u4hrBq14 Jt1A== 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=Icc+JrsLPRZVtCMs/wn62urfmv9Yq+ib7pEnkq7mY+Y=; b=XFGsa0PXaCYO3d7fcSQyvbhN9HAytqDmhKw6d+ZvORbJoY28JiRATWM25ynav59wxj v8XUzvVjXuM5LPhQYsacpI3sFDmTM9c6Ia7t9axGJt+j+M0f1NM3vVGE+siUiVBCoWH2 lZOX4pc+LMqK73/rljsyEb4LlXAa18f3izTzVz+LTJFQhdIL5MqHj+0Qxp6FKA83ZZlw i5/6/4y2FFKA3k6z1KqWOdAVvjE9dJRKQgOUNCpKipLg0g9CsGDUyBGGn3QLIaHZ0aNN DxlERJyYaiSDaeb9bTMYc1xAyKeNnXMDDTqYS+PQUYePLRvwqAvvdx8YcGqqHppyAu8R TOKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="sj0/q1R+"; 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 l9-v6si23208097pfi.179.2018.10.09.17.14.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:14:35 -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="sj0/q1R+"; 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 w9A0DqkA086521; Wed, 10 Oct 2018 00:14: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=Icc+JrsLPRZVtCMs/wn62urfmv9Yq+ib7pEnkq7mY+Y=; b=sj0/q1R+kRa+FPhQ+pFYjxffHMcLA+Cllcu/sqI5DIyAK3T5Br7rj5K5cWgnRpW8bEzb f6wk8ICnAAU71CNsjeJq7h3TXJb+JFLtG2VuULDBtS4ATeJMFkMxWyjrwyKDUGRi7R9L 909vQpoOuPiE1DFrP5UTdg+BKjBy/BozIgVP3+tRzMYVee49ZpB10x9RDeyRcHB2Wy2H 6qrZ1yJLFiXnND4K6FGLot55pOUu6Iig2I8ldDJ/DxpAG1Fm7lenleNgVc8xgFNWdXul CIzvVIuheeVAJkPBsgcbR1/Y9xfwkJeGqBX15K9iKt3+241VrpY9eH2/syPLQEww+Qec ag== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2mxnpr0pa0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:34 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0EYB4016267 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:34 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0EXwY022053; Wed, 10 Oct 2018 00:14:33 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:14:32 +0000 Subject: [PATCH 22/25] ocfs2: fix pagecache truncation prior to reflink 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: Tue, 09 Oct 2018 17:14:31 -0700 Message-ID: <153913047133.32295.149030337934464712.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=902 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 Prior to remapping blocks, it is necessary to remove pages from the destination file's page cache. Unfortunately, the truncation is not aggressive enough -- if page size > block size, we'll end up zeroing subpage blocks instead of removing them. So, round the start offset down and the end offset up. Signed-off-by: Darrick J. Wong --- fs/ocfs2/refcounttree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 851ba3ae7ce8..b9e0418a1974 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4870,8 +4870,9 @@ int ocfs2_reflink_remap_range(struct file *file_in, SINGLE_DEPTH_NESTING); /* Zap any page cache for the destination file's range. */ - truncate_inode_pages_range(&inode_out->i_data, pos_out, - PAGE_ALIGN(pos_out + len) - 1); + truncate_inode_pages_range(&inode_out->i_data, + round_down(pos_out, PAGE_SIZE), + round_up(pos_out + len, PAGE_SIZE) - 1); ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, out_bh, pos_out, len); From patchwork Wed Oct 10 00:14:38 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: 10633731 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 6A80C46E4 for ; Wed, 10 Oct 2018 00:14:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58DB5284C9 for ; Wed, 10 Oct 2018 00:14:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D33228F95; Wed, 10 Oct 2018 00:14:51 +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 A0CB1284C9 for ; Wed, 10 Oct 2018 00:14:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D7796B0290; Tue, 9 Oct 2018 20:14:49 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 586186B0292; Tue, 9 Oct 2018 20:14:49 -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 428846B0293; Tue, 9 Oct 2018 20:14:49 -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 F0BB96B0290 for ; Tue, 9 Oct 2018 20:14:48 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id m4-v6so2527159pgv.15 for ; Tue, 09 Oct 2018 17:14:48 -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=2SPLconiP404eMyxOC1aqgVLtNw28oHCs3852mPqKig=; b=F91xltHXD44uCNx0ljPrCpaSa2n0OSWoyEiH5VY8BxoO05M886Y/aY64Hl6fAnw2pB Zdmja2vnMeGJhnf8BjvcI8jOcf4Msj3s3tB+QrdSCD6Y66BkuMOaugQvGd2rliOlSTo+ +IiPak7+z4DuOJ26hJtBcWZeZWCP+qOXxCuqgNL1bqx8V/qheMjCT81O1j0AnJeurign x2IR6Xuuty5EqCRJN2AsWBaRq+NdlobR3sD691Ks5O1yaoZhwOeIGz9f7iwPgy9x9UbE FjU18ONqNy7axen3rKFoIjm5PoUdCaA1Eq3677w90MLDml4W3nWpxjN1agv7g6UfRtgQ EC9g== X-Gm-Message-State: ABuFfohLDnJY2GbQpWCdzPUUtmFYPq1tsZBXp+2CNvBrHflYd2lZIZm8 oFINtfhwAQTv4Tx8yizJBL/G+xIieLjmnN9HFWL4yt5LPFAGFfFsxifd8yongoJ+9n/sqCbijj9 zEp1lvK3UWA8Z5cMtELH9Pb2uZIQw+M2ajt71GnzUoR1jqwuqori+bFdTNW9882WtGA== X-Received: by 2002:a62:f58a:: with SMTP id b10-v6mr32767109pfm.253.1539130488657; Tue, 09 Oct 2018 17:14:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV63YNtverVKtX/AfWgIMzcBBi9I0Mlh105Dl/vS0yKtgqG41j6tSe3eVsSnN/F/CH1kfpFuz X-Received: by 2002:a62:f58a:: with SMTP id b10-v6mr32767047pfm.253.1539130487817; Tue, 09 Oct 2018 17:14:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130487; cv=none; d=google.com; s=arc-20160816; b=ru5ziNrpcUvoLJC5ovLMK+lfqjmje1g3TpFzyIHL04gF3QlxTe8kxqSOqj43lEdIwy S1oyyDu3o55HqASAzZ5eAgwD0Gmj2LE0Awy5lqZg/tfasMGxUIC3WZfNowTdcwxQ5omz oz9kUxun5Yyc0GhBcT8UHCt9sFlY4noUr5+WxXfioTbRuWAzt86wm55T+oVSp/T5fobS 6Ue0TwrXu4CoZAizk2Px0k6W6pNf3kIG9kpRywWzSVCio29Nf3H+pRjf24M/tUnbTQfh jRRc5/ayUoelWn2eOPIVRmt557FgdtKgfd05x+rptXQ76G5AQffj/63uS1o1d/s46tLz Rufw== 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=2SPLconiP404eMyxOC1aqgVLtNw28oHCs3852mPqKig=; b=NsZArvW+JL3QRhEAHL+6PqRoCPCC5K/h3H67CDTAREi21xa7qwj1EtZ3fjfdraL4yo VjWhELRBcv7j8YapF+Mbv5Qrc3TqwT+ARjtXE2jyLHM1Vfu+I5rsok24vRIW/1YPl/G+ z2pdm5xBkaW1H5B6xOqsO6IKXDzHyMTvgogxwhd6mJxNSOI+c7og78xf6G9HQ2Ur5AvL AOMQpqNAbmsVII9ke2eTvqQ8giHE23Tul7KUh8E34KAszIOc2K6kQNh+YQpUBKdZ0O6i wZStn28J/mmbguZV+l6fwF9XK+AR4PzWyDWtw89YsfDQghVSQoBr2AegVtGIf7edOclu 02rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=fjyHKehC; 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 bh1-v6si3820953plb.298.2018.10.09.17.14.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:14:47 -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=fjyHKehC; 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 w9A0EUKh142532; Wed, 10 Oct 2018 00:14:46 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=2SPLconiP404eMyxOC1aqgVLtNw28oHCs3852mPqKig=; b=fjyHKehCadbODG8jnKRM2yKLnLSJUOS61xhwlmTLz6wJYcQS4ysxiAOK66FwbhUIhE5w 2gwBGlq2bZD/BeNr3SQuE9qfczhozt9iHgHrbsIbCOTkuUSSKvW5ZBKhDRw8Ao/XdBpy z4myZ/Tm7sxKdU3g33vHy9OZpD1nz8dbSMsOrScWeKPwjg02x05ezGfCXh64tMTruSWt h9e1A6Zmw9Ef6e5dQ51oJJenC0KA/fH0sd005hmZ2LrL18/MC+CJhGVp72lL66kjQ58E eJuZycmOJUYuTTKW1FoCUF6Um5suBQbdSC7/eVmZbSgOAfLxLBsDktFFcrrS60Oy0uTK aQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mxn0q0tuy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:46 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0Ee5G016528 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:40 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0EeQO022091; Wed, 10 Oct 2018 00:14:40 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:14:39 +0000 Subject: [PATCH 23/25] ocfs2: support partial clone range and dedupe range 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: Tue, 09 Oct 2018 17:14:38 -0700 Message-ID: <153913047816.32295.8382474896892471244.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 Change the ocfs2 remap code to allow for returning partial results. Signed-off-by: Darrick J. Wong --- fs/ocfs2/file.c | 7 +---- fs/ocfs2/refcounttree.c | 73 ++++++++++++++++++++++++++--------------------- fs/ocfs2/refcounttree.h | 12 ++++---- 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index c018605ac279..f9e65ff89a8a 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2531,11 +2531,8 @@ static loff_t ocfs2_remap_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, loff_t len, unsigned int flags) { - int ret; - - ret = ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, flags); - return ret < 0 ? ret : len; + return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, + len, flags); } const struct inode_operations ocfs2_file_iops = { diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index b9e0418a1974..4eacdd703874 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4507,14 +4507,14 @@ static int ocfs2_reflink_update_dest(struct inode *dest, } /* Remap the range pos_in:len in s_inode to pos_out:len in t_inode. */ -static int ocfs2_reflink_remap_extent(struct inode *s_inode, - struct buffer_head *s_bh, - loff_t pos_in, - struct inode *t_inode, - struct buffer_head *t_bh, - loff_t pos_out, - loff_t len, - struct ocfs2_cached_dealloc_ctxt *dealloc) +static loff_t ocfs2_reflink_remap_extent(struct inode *s_inode, + struct buffer_head *s_bh, + loff_t pos_in, + struct inode *t_inode, + struct buffer_head *t_bh, + loff_t pos_out, + loff_t len, + struct ocfs2_cached_dealloc_ctxt *dealloc) { struct ocfs2_extent_tree s_et; struct ocfs2_extent_tree t_et; @@ -4522,6 +4522,7 @@ static int ocfs2_reflink_remap_extent(struct inode *s_inode, struct buffer_head *ref_root_bh = NULL; struct ocfs2_refcount_tree *ref_tree; struct ocfs2_super *osb; + loff_t remapped = 0; loff_t pstart, plen; u32 p_cluster, num_clusters, slast, spos, tpos; unsigned int ext_flags; @@ -4605,30 +4606,32 @@ static int ocfs2_reflink_remap_extent(struct inode *s_inode, next_loop: spos += num_clusters; tpos += num_clusters; + remapped += ocfs2_clusters_to_bytes(t_inode->i_sb, + num_clusters); } -out: - return ret; + return remapped; out_unlock_refcount: ocfs2_unlock_refcount_tree(osb, ref_tree, 1); brelse(ref_root_bh); - return ret; +out: + return remapped > 0 ? remapped : ret; } /* Set up refcount tree and remap s_inode to t_inode. */ -static int ocfs2_reflink_remap_blocks(struct inode *s_inode, - struct buffer_head *s_bh, - loff_t pos_in, - struct inode *t_inode, - struct buffer_head *t_bh, - loff_t pos_out, - loff_t len) +static loff_t ocfs2_reflink_remap_blocks(struct inode *s_inode, + struct buffer_head *s_bh, + loff_t pos_in, + struct inode *t_inode, + struct buffer_head *t_bh, + loff_t pos_out, + loff_t len) { struct ocfs2_cached_dealloc_ctxt dealloc; struct ocfs2_super *osb; struct ocfs2_dinode *dis; struct ocfs2_dinode *dit; - int ret; + loff_t ret; osb = OCFS2_SB(s_inode->i_sb); dis = (struct ocfs2_dinode *)s_bh->b_data; @@ -4700,7 +4703,7 @@ static int ocfs2_reflink_remap_blocks(struct inode *s_inode, /* Actually remap extents now. */ ret = ocfs2_reflink_remap_extent(s_inode, s_bh, pos_in, t_inode, t_bh, pos_out, len, &dealloc); - if (ret) { + if (ret < 0) { mlog_errno(ret); goto out; } @@ -4820,18 +4823,19 @@ static void ocfs2_reflink_inodes_unlock(struct inode *s_inode, } /* Link a range of blocks from one file to another. */ -int ocfs2_reflink_remap_range(struct file *file_in, - loff_t pos_in, - struct file *file_out, - loff_t pos_out, - loff_t len, - unsigned int remap_flags) +loff_t ocfs2_reflink_remap_range(struct file *file_in, + loff_t pos_in, + struct file *file_out, + loff_t pos_out, + loff_t len, + unsigned int remap_flags) { struct inode *inode_in = file_inode(file_in); struct inode *inode_out = file_inode(file_out); struct ocfs2_super *osb = OCFS2_SB(inode_in->i_sb); struct buffer_head *in_bh = NULL, *out_bh = NULL; bool same_inode = (inode_in == inode_out); + loff_t remapped = 0; ssize_t ret; if (!ocfs2_refcount_tree(osb)) @@ -4855,6 +4859,11 @@ int ocfs2_reflink_remap_range(struct file *file_in, if (ret <= 0) goto out_unlock; + if (len == 0) { + ret = 0; + goto out_unlock; + } + /* * Update inode timestamps and remove security privileges before we * take the ilock. @@ -4874,12 +4883,13 @@ int ocfs2_reflink_remap_range(struct file *file_in, round_down(pos_out, PAGE_SIZE), round_up(pos_out + len, PAGE_SIZE) - 1); - ret = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, inode_out, - out_bh, pos_out, len); + remapped = ocfs2_reflink_remap_blocks(inode_in, in_bh, pos_in, + inode_out, out_bh, pos_out, len); up_write(&OCFS2_I(inode_in)->ip_alloc_sem); if (!same_inode) up_write(&OCFS2_I(inode_out)->ip_alloc_sem); - if (ret) { + if (remapped < 0) { + ret = remapped; mlog_errno(ret); goto out_unlock; } @@ -4897,10 +4907,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, goto out_unlock; } - ocfs2_reflink_inodes_unlock(inode_in, in_bh, inode_out, out_bh); - return 0; - out_unlock: ocfs2_reflink_inodes_unlock(inode_in, in_bh, inode_out, out_bh); - return ret; + return remapped > 0 ? remapped : ret; } diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h index eb65c1d0843c..9e64daba395d 100644 --- a/fs/ocfs2/refcounttree.h +++ b/fs/ocfs2/refcounttree.h @@ -115,11 +115,11 @@ int ocfs2_reflink_ioctl(struct inode *inode, const char __user *oldname, const char __user *newname, bool preserve); -int ocfs2_reflink_remap_range(struct file *file_in, - loff_t pos_in, - struct file *file_out, - loff_t pos_out, - loff_t len, - unsigned int remap_flags); +loff_t ocfs2_reflink_remap_range(struct file *file_in, + loff_t pos_in, + struct file *file_out, + loff_t pos_out, + loff_t len, + unsigned int remap_flags); #endif /* OCFS2_REFCOUNTTREE_H */ From patchwork Wed Oct 10 00:14:45 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: 10633735 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 E0FE846E4 for ; Wed, 10 Oct 2018 00:14:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CFBDC284C9 for ; Wed, 10 Oct 2018 00:14:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3B3E28FE7; Wed, 10 Oct 2018 00:14:53 +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 68CAC28F95 for ; Wed, 10 Oct 2018 00:14:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7673B6B0292; Tue, 9 Oct 2018 20:14:50 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6BFC56B0294; Tue, 9 Oct 2018 20:14:50 -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 450DF6B0295; Tue, 9 Oct 2018 20:14:50 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by kanga.kvack.org (Postfix) with ESMTP id 02A626B0292 for ; Tue, 9 Oct 2018 20:14:50 -0400 (EDT) Received: by mail-pl1-f198.google.com with SMTP id w18-v6so2676336plp.3 for ; Tue, 09 Oct 2018 17:14:49 -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=cfF3N75h3lxZbqAALtDnQMXfh3h0NJ+K2oVFMPxgqNM=; b=VpU4729KFdbANaG4QTPIpe8IJI3LHDGQKPdqAh/4gbNwTCapIlbx3bi40PuJ72c8F5 xxW9KUSwoqYoT9x8O+p0DNr2JLmfjlM3W4L9AyPWWX2bMS11dqPxbw8kjzrMt3GE4LFX 9JdItGQ1wbU4OoakwJNJrjr+5cHEs0mqxsvk/3Bag2pn/7B2/yrAMZ/ngxpC5IkGuS69 h5zT72xc73usStqketaKXKZWHnt7qw1Hb2FuMoJ2bZE/HQODsURHMwZIzFdaxrhx4age IQNAuE4gIzOkD6brwWOlBhfBn0B2CLV7Nd5Dv/XNiot3OvJUGaF5kKN9mLUDx6L3JN80 MnJQ== X-Gm-Message-State: ABuFfoh/bZnQAL517NTcmhhTzr0HhX1goK3qyFRPWGetN8f1w79Kqw08 Mit1r0AOF3nGC6th9idWTi0oSG1hxwgOX25RBfy6PqieVF/ZmKkyV6WtR3AB8qvokRenWjwlPt/ ouVnA3L8RNZ9e6ivFPgVeBBddHD2JinxBCHMcJvSUJCg9atfIkX9RG0yHIOULLb9O9A== X-Received: by 2002:a63:ea43:: with SMTP id l3-v6mr27834546pgk.427.1539130489666; Tue, 09 Oct 2018 17:14:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV62cV0WDb/17KPA/k+jr88MJdzxbfEBvr+QYpMHy72p5C0Zp4U6oUcLSQ/ck5GHjRS/gpVtR X-Received: by 2002:a63:ea43:: with SMTP id l3-v6mr27834519pgk.427.1539130489114; Tue, 09 Oct 2018 17:14:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130489; cv=none; d=google.com; s=arc-20160816; b=Xn5iEWimyGQszXKorvtM0v9SAnDMFlBEaDK1VvNBVndPpxCm2znxedmNCuKQNaNcEF 0FbqOqrqcnVTpyYdhBcIR5UUirRH+jdjkg3tm/2IdFqGYAlarmNs+kQun1MTEnPHQ1DP j75+Q0LhU/tQ825xTdK9uUk4+goSiF0AQsTbldCcSfUyNAn0h0DRObRIkVF9XMU7iVck InH5YMSV4tSQ2hROUxxRWmzOXJ3o9kfon3Iw7i754gF7dJmnwNOXuP2W4UzD/Mlm7TE4 dzUkYLG45VujzfuRP6G0MyZp1F5d+l3EsE5xYcQAorRtBFHqPcqxTVGS8McxoM7rO7Yd IzOA== 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=cfF3N75h3lxZbqAALtDnQMXfh3h0NJ+K2oVFMPxgqNM=; b=Mz+R9k7w4jL6dcZqgVFvMf/rJVqxXvmoTjw1QsGZZA3+jP74COfy1xgLn1m9m61ZYk eoub9V582EmayVsnhJt/4L5gtoOsA0uY/zxALnxJlrIkETicQrpqXZkZx6pbmHepTQs2 GQLPsHs6Qp+y6ySVrp8GgAs3+vwxhSB6N0QJUbbodEC2u4E5dwb0nIdJLpoFQngZbq3o ubU89QuCl95W0boXheeZ0hABQC8jj16k4DSi0T9CgdlVDxJxctOGAyfIUInzPI7Nzvpc z1+r/ZvlVzhOo55eHqU7fLl9yR4SyCWjwSAqOuywqNLmnYcK0vAAY7k/3MPzH44mj+pZ bOFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=1eaks0kI; 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 g16-v6si18836101pgi.329.2018.10.09.17.14.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:14:49 -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=1eaks0kI; 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 w9A0E2G4123299; Wed, 10 Oct 2018 00:14:48 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=cfF3N75h3lxZbqAALtDnQMXfh3h0NJ+K2oVFMPxgqNM=; b=1eaks0kIJfxw2JXtKkfWiqTh+Gl2LR+tWeEWHnEg4GCd4DnEOvme5zIkKV8W4bsGvDay VQXLxtscuWkUqX9Xkg6Guzxm1dtKo6HlvbR/uat2zVHIsAXI8Vg0BsqWjywaeciTJD7H S8SZdtD2TkOZJl8/xzQNFmFW4R+tE3R24IqhtENT3T6DkrbCUdpVJW0YYyd9mMhAYxHk PXoH/3DzheuC9d+vnEgdat6Wr2YJom8KnmsxfO3vx4tWIHfAf9u6OSapJrPEDnlZyO2u 7Nj0SNhYUtuKp0jMwdAICoknacdyyhiGhuSRcQ07boUQ+8u9UBsU15OtcuVE+CzdI2ox kQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2mxmftrvu3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:48 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0ElQr016709 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:47 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9A0EkIA022134; Wed, 10 Oct 2018 00:14:47 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:14:46 +0000 Subject: [PATCH 24/25] xfs: fix pagecache truncation prior to reflink 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: Tue, 09 Oct 2018 17:14:45 -0700 Message-ID: <153913048498.32295.11135506483495360686.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=773 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 Prior to remapping blocks, it is necessary to remove pages from the destination file's page cache. Unfortunately, the truncation is not aggressive enough -- if page size > block size, we'll end up zeroing subpage blocks instead of removing them. So, round the start offset down and the end offset up. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_reflink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index ec09e2783afe..0f4678920240 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1328,8 +1328,9 @@ xfs_reflink_remap_prep( goto out_unlock; /* Zap any page cache for the destination file's range. */ - truncate_inode_pages_range(&inode_out->i_data, pos_out, - PAGE_ALIGN(pos_out + *len) - 1); + truncate_inode_pages_range(&inode_out->i_data, + round_down(pos_out, PAGE_SIZE), + round_up(pos_out + *len, PAGE_SIZE) - 1); /* * Update inode timestamps and remove security privileges before we From patchwork Wed Oct 10 00:14:52 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: 10633753 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 7BE3546E4 for ; Wed, 10 Oct 2018 00:14:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69BA6284C9 for ; Wed, 10 Oct 2018 00:14:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5D99228FA5; Wed, 10 Oct 2018 00:14:59 +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 C7BF028F95 for ; Wed, 10 Oct 2018 00:14:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 564A06B0294; Tue, 9 Oct 2018 20:14:57 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 512046B0296; Tue, 9 Oct 2018 20:14:57 -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 403246B0297; Tue, 9 Oct 2018 20:14:57 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id F21896B0294 for ; Tue, 9 Oct 2018 20:14:56 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id z12-v6so3208311pfl.17 for ; Tue, 09 Oct 2018 17:14:56 -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=f7AqhFJetFEwQ5b/c717/4+wkcz+RzMOOXOAxSGyAlM=; b=BI5FTX3PKMUkCx+EJqa12Lmrv74BC4tSKAttN2DD6+TSthNjChBsGyNULuh3SZ+MQk E+H5sEwHfe89Rkbpsvj72h0KqceQmerHA3k8mTk1E0oBRCQdWfco5/EX5reZQ3Q8CJ+l 2YjcO77oH4XsRRpx98Dier9wRA0V/aTGiNwmqY9/X1W0VxcWIaV08MgksOtWE/Mfa0P0 S6PTIeY3jsJcs9alZUDvhQp9q4iU34DITwv6neAejKI+DzeTYWLNN9sMynQ3x1qn09eR DJ52z66Dlc6E+O9H5o+NYJvVWPkd9FMZy+spICTjkt9/pci9Z1nJtGq29nqy8IgqL5me Hggw== X-Gm-Message-State: ABuFfoh29cPAI/Dvf5iTOQItlxoRDF/1S4AyKYbHfBBPxM3VfsT/MZKj K55Qr/pLFMYIDNHXQrmUt8fLNIo1GdW2cE0hHZL3elFzvtncXjvRilELvG5ri/4fnMjKo7OX/HW uh+bIZBmcTHgJADY3T1an4a115rXUIhVreGJIbJX08WasjzF+fkIHLLXTdXlvGYOVtQ== X-Received: by 2002:a62:6dc3:: with SMTP id i186-v6mr22128924pfc.218.1539130496602; Tue, 09 Oct 2018 17:14:56 -0700 (PDT) X-Google-Smtp-Source: ACcGV632SizcSAI7OSmOgw4MDYqyXs8o35acpg3udkeLnmt/KjpuXE08ES0clN3Bou9SZiZi9po+ X-Received: by 2002:a62:6dc3:: with SMTP id i186-v6mr22128874pfc.218.1539130495775; Tue, 09 Oct 2018 17:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539130495; cv=none; d=google.com; s=arc-20160816; b=Bo+0pmmeD13YSeIkFoTC1F1Dfzec10F3CHXOtYzOeai9CAouPeT055Ts1bDuxYwJqs Xk29cW8MI8ROaUTlFmt/SKEVX6gYKdLwkKS8//2+bf4uiY6n4nVNzpNQuY4X+m4dgDcE eUiZzUOeLXPWY4FzlaX3k6A6DSaviM9UmjfVBgZXlmewlZBr8K/p7dPC4GwYUabeglzc ErdNu+yLaagIFc9AasAzRl95AKssvPqsAY34oTbeFbTqWfv6jQ0HRxYXt7lMRWedgFYK 93L8mWgL+NA+ihxsC/A2AYKd3OPpEAro2hHscbUDwn7hSXLbTAMlSzZo71pvff2LUqEh o3RQ== 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=f7AqhFJetFEwQ5b/c717/4+wkcz+RzMOOXOAxSGyAlM=; b=Fn9HnH6IvTscdjZM8m1M+BH16o25b9BQmb13eaj6NOL/06242O0hAQdgmAe8GcooWR KLP9iCLo1ASpJtNL2HC+Be7lokoHRn+Ds7uIXDPK/zROIvornrncIbVYqIjPo9DP9u5e 1haXaL6fsSr05ePIiUGeZqxAhDe+cJoPDjj6fkPO3/1tEroHGqf4PqNLUskQUvFSx7iY FxvNp7CLXosdn80uYUqZARn+YZhtH9QT1ArAmjOoVB+rvhxTpU66AoK/KesKLhQ6ITzH iyN5aBRF7MMOhd/piqYoLrD8twlUNKi9w9jT2551peg+MDDAmCRvOrQojhrm3yDWjSM2 QQFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=mmHPzpKY; 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 k2-v6si20251131pgo.32.2018.10.09.17.14.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Oct 2018 17:14:55 -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=mmHPzpKY; 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 w9A0DfJi123123; Wed, 10 Oct 2018 00:14:55 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=f7AqhFJetFEwQ5b/c717/4+wkcz+RzMOOXOAxSGyAlM=; b=mmHPzpKYU83v7qFtgpn9PPGXpW31Tq8Rh0Iwnrz7fupE0p5gTJMjuM33co2UPCHgmbjr KmsWkiLB/g+nQyU+kurFux60elfgIc3CephqzQ4WfHdjueVRQKyCaXhnjsWZnz6Pf2HY mMTElm7hFNVlhH4cGyDYcK7Y22ZhJcAYDxAwShK9h2DDJN9jy4IxY14pC8rOcNgkEfFO 8i3TTw+mN19Bh4G8UUppaYPdby2vvyq0XAZPP1mnDwm9rFECBpNeytuAhF2Fnrjkr9tV 6HXjSJF0NRuUhPS3ePXe5yjtDFy27wr2/JWzJoDzbULV2yo9vgR5qivGnyTDwxUOUjX5 +w== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2mxmftrvua-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:55 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0Es5e006907 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 10 Oct 2018 00:14:54 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9A0ErHZ004470; Wed, 10 Oct 2018 00:14:53 GMT Received: from localhost (/10.159.249.114) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 10 Oct 2018 00:14:53 +0000 Subject: [PATCH 25/25] xfs: support returning partial reflink results 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: Tue, 09 Oct 2018 17:14:52 -0700 Message-ID: <153913049195.32295.13614911442275409372.stgit@magnolia> In-Reply-To: <153913023835.32295.13962696655740190941.stgit@magnolia> References: <153913023835.32295.13962696655740190941.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9041 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=882 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810100001 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 Back when the XFS reflink code only supported clone_file_range, we were only able to return zero or negative error codes to userspace. However, now that copy_file_range (which returns bytes copied) can use XFS' clone_file_range, we have the opportunity to return partial results. For example, if userspace sends a 1GB clone request and we run out of space halfway through, we at least can tell userspace that we completed 512M of that request like a regular write. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_file.c | 7 ++----- fs/xfs/xfs_reflink.c | 19 ++++++++++++++----- fs/xfs/xfs_reflink.h | 2 +- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 6f4205846451..a15057be1994 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -928,11 +928,8 @@ xfs_file_remap_range( loff_t len, unsigned int flags) { - int ret; - - ret = xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, false); - return ret < 0 ? ret : len; + return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, + len, flags); } STATIC int diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 0f4678920240..b33107a35330 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1123,6 +1123,7 @@ xfs_reflink_remap_blocks( struct xfs_inode *dest, xfs_fileoff_t destoff, xfs_filblks_t len, + xfs_filblks_t *remapped, xfs_off_t new_isize) { struct xfs_bmbt_irec imap; @@ -1130,6 +1131,7 @@ xfs_reflink_remap_blocks( int error = 0; xfs_filblks_t range_len; + *remapped = 0; /* drange = (destoff, destoff + len); srange = (srcoff, srcoff + len) */ while (len) { uint lock_mode; @@ -1168,6 +1170,7 @@ xfs_reflink_remap_blocks( srcoff += range_len; destoff += range_len; len -= range_len; + *remapped += range_len; } return 0; @@ -1349,7 +1352,7 @@ xfs_reflink_remap_prep( /* * Link a range of blocks from one file to another. */ -int +loff_t xfs_reflink_remap_range( struct file *file_in, loff_t pos_in, @@ -1364,9 +1367,9 @@ xfs_reflink_remap_range( 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_filblks_t fsblen, remapped = 0; xfs_extlen_t cowextsize; - ssize_t ret; + int ret; if (!xfs_sb_version_hasreflink(&mp->m_sb)) return -EOPNOTSUPP; @@ -1382,11 +1385,17 @@ xfs_reflink_remap_range( trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); + if (len == 0) { + ret = 0; + goto out_unlock; + } + 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); + &remapped, pos_out + len); + remapped = min_t(int64_t, len, XFS_FSB_TO_B(mp, remapped)); if (ret) goto out_unlock; @@ -1409,7 +1418,7 @@ xfs_reflink_remap_range( xfs_reflink_remap_unlock(file_in, file_out); if (ret) trace_xfs_reflink_remap_range_error(dest, ret, _RET_IP_); - return ret; + return remapped > 0 ? remapped : ret; } /* diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index c3c46c276fe1..cbc26ff79a8f 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -27,7 +27,7 @@ extern int xfs_reflink_cancel_cow_range(struct xfs_inode *ip, xfs_off_t offset, extern int xfs_reflink_end_cow(struct xfs_inode *ip, xfs_off_t offset, xfs_off_t count); extern int xfs_reflink_recover_cow(struct xfs_mount *mp); -extern int xfs_reflink_remap_range(struct file *file_in, loff_t pos_in, +extern loff_t xfs_reflink_remap_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, loff_t len, unsigned int remap_flags); extern int xfs_reflink_inode_has_shared_extents(struct xfs_trans *tp,