From patchwork Sun Oct 21 16:15:10 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: 10650935 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 B694213A9 for ; Sun, 21 Oct 2018 16:15:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4510287BE for ; Sun, 21 Oct 2018 16:15:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98211287C2; Sun, 21 Oct 2018 16:15: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 C5C5B287BE for ; Sun, 21 Oct 2018 16:15:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8CE606B0006; Sun, 21 Oct 2018 12:15:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 87ECD6B0007; Sun, 21 Oct 2018 12:15: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 76E3B6B0008; Sun, 21 Oct 2018 12:15:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by kanga.kvack.org (Postfix) with ESMTP id 448CC6B0006 for ; Sun, 21 Oct 2018 12:15:16 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id r3-v6so7226034ybo.7 for ; Sun, 21 Oct 2018 09:15:16 -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=L870gkqD6S3aDKdn3eAOJVgjX5eONlTDEgfFmDNElAY=; b=EsNGMCbvKoNvgUBRoLiO5NT8w4tCRyw3Aoe8lkfG3CHaQLEQZJ5Qjq/avYLYMGnbni yOo66IsQvIvG3FShl8fx56b19Ce9MXe7P+2BY9phXWHGWBSZ+tigr+B+yfipE7OheTrx b54qfUSHIaH98/J7XTQokAmFDlPUxDOB5M204k50olJnP0zSLMHKfwtzxzRuRNpGDlb2 IrcIbbozNz95PNpIn2TrP40IqUH6NPXMRsvs+0A6sjJe0GW+J3FfBRjrqmEJe7Q7F5fe P/5TcYyJoi0cv0i44iJkC3xNu8hxtpgjMIG80NYnecSroG07XDKZpYxPWROGEK4TG3rL XNDA== X-Gm-Message-State: ABuFfoizcsZc05lGjEd7R7TZc8PiDtsIKJYBZwopScQIENe/9/ONLPGM r8o44cKLb7pHUKK+1hfmW09A0Pfq4jtpWNeBfJrkbFAhdSEI3IQSQDy6s0yMKA7WCg6wdxExBwe +TX2Nz0pFI94AheqEQhCW7/DRwMc6vY1JwooHUl0xBeTNfciTPBDSRIlR0lq5Kh8/zA== X-Received: by 2002:a0d:fec6:: with SMTP id o189-v6mr30439169ywf.237.1540138515924; Sun, 21 Oct 2018 09:15:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV60iKTlHxnQ1abMgojOmyEC1KbApTOIShg+NTXIyRfd77IcafUeh+jw3MJ1LHiquLvoqMjGY X-Received: by 2002:a0d:fec6:: with SMTP id o189-v6mr30439136ywf.237.1540138515437; Sun, 21 Oct 2018 09:15:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138515; cv=none; d=google.com; s=arc-20160816; b=JJBVsLrJZXkwiVI91PfG5fqmgXJakbztL+lm05zRT+/4cSEOiM6Uoztn8fZOv+73Pd wUHBwiV3SO2tTensh11GRvgBSY8lkWtuXM5j27yIkZaZCyH4Q3hr7EChxMFWzRXhyadY W7FZ+pQV/qan9OPwMDjL8Rd4Bnto2sgG3sa/KDe+ZmrnjNXL6cCCy6w1GWN+Bwg/gM4F nx9/zKFo/LcJPQZxZfb64uEbW7X+haRqfLgDvJ4Wa9hwbxvXEAv83hpJNdvr87ecxeJR SRAg3F4eCh93xkVAXGLqalJzbep4b/s1e/72JGKDe+0t4lA0xoQ913dsExS2hhqBkggq TaHQ== 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=L870gkqD6S3aDKdn3eAOJVgjX5eONlTDEgfFmDNElAY=; b=TXq6FSVuHGzaEQy31WNc5rqpsuutQc5aTtRSXrDfcP0dMx3gy+gFYbTd5LDcW7eLBr DhX8L1TXgk62ISAqrTBYQ/Dz1AnKisxigkMxjVLUJ10XUruw2Sa3/cJP02DfCZxAI/6a B0KX/MPGLzM22EP2D3CvraNqeoVhfvs+u+YBoGliqVtrjY201T/YZ8QTbjOukZpyNyy1 qZNbqt1ZcZZxNxaVA257RRfRnoDlprEa7AHA/ooEwNVW+CelckUJ71KENW2KztBLzL9u r+Dysg1YKQ4rc9ACzhXgmfWBDhhT9j+sRNONyMBvvHCMv/DMwZmPlssfKitr4y7jG0Ll reIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=zRXwM+gX; 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 w74-v6si802563ywg.432.2018.10.21.09.15.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:15: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=zRXwM+gX; 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 w9LGFE3x107476; Sun, 21 Oct 2018 16:15:14 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=L870gkqD6S3aDKdn3eAOJVgjX5eONlTDEgfFmDNElAY=; b=zRXwM+gXg1ltSBXj2ba24XE/7MNBfcl2iy2/AnB1A7J7PTLR3wa/XCM/GpM9UlljtFQ5 Xu37m49IvoWmj8YoQDOJ/dpXgUTf0Hd8iDlFI1DgMxnfntSM4wW4nXIavqycEcBOF9A3 wah7i0+j32IB7ePjjtVy1RK7Pl3Z1yVspmh+d9NjLfRX3w4Fpk7NUhpg8jx6bJCV6EAg JDDsvpIDNFLQgOX17PF2pG67GmN+NWJ9/tbZ9GUQFSy5AIhsLjp/2xUY2iu+VtQxgluN fQi8FoNya//JohDJEFDzVaaR6RnBb/Q6/gODGCITszu+oBtu1XaNAV+bEuWdmsEZXX1I 3Q== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2n7w0qaxgp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:14 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGFCU7010579 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:13 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGFBCA020980; Sun, 21 Oct 2018 16:15:12 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:15:11 -0700 Subject: [PATCH 01/28] vfs: vfs_clone_file_prep_inodes should return EINVAL for a clone from beyond 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, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:15:10 -0700 Message-ID: <154013851007.29026.6847850518000401463.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=772 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong vfs_clone_file_prep_inodes cannot return 0 if it is asked to remap from a zero byte file because that's what btrfs does. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/read_write.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index 8a2737f0d61d..260797b01851 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -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) { From patchwork Sun Oct 21 16:15: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: 10650959 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 2C1E514E2 for ; Sun, 21 Oct 2018 16:15:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 16F88287BE for ; Sun, 21 Oct 2018 16:15:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B04F287C6; Sun, 21 Oct 2018 16:15:36 +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 428D1287BE for ; Sun, 21 Oct 2018 16:15:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6DDFC6B000C; Sun, 21 Oct 2018 12:15:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5E9226B000D; Sun, 21 Oct 2018 12:15:29 -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 489826B000E; Sun, 21 Oct 2018 12:15:29 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f72.google.com (mail-yw1-f72.google.com [209.85.161.72]) by kanga.kvack.org (Postfix) with ESMTP id 1B74B6B000C for ; Sun, 21 Oct 2018 12:15:29 -0400 (EDT) Received: by mail-yw1-f72.google.com with SMTP id n205-v6so25613060ywc.16 for ; Sun, 21 Oct 2018 09:15: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=zrdKK22K4yPwdg97C40ayFoftWNqhnfImZiJAlzmShI=; b=hG7J8He458zB5tUL3VnyD4CccTo4eGTywmIBxfIu86WEFrRHwAvJWvmZklS5Q2+h9X qBvDAEjv8HOB6FLlHMj33yV1sc7MgwRlL+05w+1g3iOZjxbxtdD3GMZ5ASMmA875/7lL V78U/j+DNg/GXGk1rIMtHNjUu/mTgutM9tzAWeiWKvuoCCSjX/4YJhdMKQ1As77ImbVC 0NjvsCwiXwlwdiQ9fW/EA+MDIcb1C/0lRSrgHI5b0FRQ/2+y3GJhAXIjFe015A37ZsTp 6qcTGjyXHHrE9nqvKE6Wf8rbDJ7rACN0+lueRejwAgQYFCw7fxZtjKlLRGRrR3bpOyXe nkXg== X-Gm-Message-State: ABuFfoi8JFSOkUuW5Mfp0u/dUXM3Xemh83w+ZJkSkKM2qfd0EB2XbIQI yrs+33ClKKc1bGxZk/fSrY7yzXTIG1Yj9BT2a2SUaTHnvT1CZkDa3vA7y66D0Xav1XDBlqTB9rT eLGyjw+d/HjQAQolHGjKtQ6vMJPHnyJTwNySNeZfS0aWx+iJF316i61NNrAWxaC9bfw== X-Received: by 2002:a81:8044:: with SMTP id q65-v6mr28977208ywf.196.1540138528766; Sun, 21 Oct 2018 09:15:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV60T2+uUuNsHT+JgGKfiwxn0AQUNjtUUTnS+TLLFtB8mrUrzG1K7xcavIIKEI5da+zv12AtI X-Received: by 2002:a81:8044:: with SMTP id q65-v6mr28977154ywf.196.1540138527811; Sun, 21 Oct 2018 09:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138527; cv=none; d=google.com; s=arc-20160816; b=c0O+YW1QNQMaGEo/oQrpB5op2+ZF5IzOI2ei6KmkJu6NQbbaxAcoCC54sRikg+Eoce aN5T5uA4snKSDEATKXxUFfPF5G3fjc93H1bCadCIridbMennK5dW5YclWHnyBMxqg5C8 CBuyW2CoDcCulDq2uFUL8llN1PG8zN7CGzVxpx4XVnjL0MkBLCXNVMWLoXDZM99wcc/W 1TL1KvI3eMzvz/DvRO8hI00HhTfNz5Xuk+YZXFMMn4Nm8xaBsBY1R13z3LcspBYqkRY/ rfQPmFvsDhHnQPufEsKZOhv1xVax7oTCSOkOv2rwWS1ma1dc/vbC+A4Db80CPUuZzHmC oHrg== 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=zrdKK22K4yPwdg97C40ayFoftWNqhnfImZiJAlzmShI=; b=bstQJbZhJqoiPA6Ef58ETtdqFsK/PZ8hCUy+Q8sui4EMGKHOAfhfmYzeD1LR4nDG6Q L3XX0mwPKyhqX9vFnkR5lE76hy/qdHF5O/DgP86AFj9v1K57SbYAglF9Dt7kXiYfDKsX By0eZKWrBIrbPnfd1poRTFfQohwJJ5jKs7q3JIZJWJTtpn86t62WjVdZHqT+LzgEVmYd DYeWqg+LbFovAz0QkuS65cSo9iMF7hA4N01tdkgda1ge6ggUV6pKAy618P6lgnJBLcra 0N0D/zCv4gazknT4d6oJn50msYVuqjKryq6RG407r3+nHaVeKzrQNT5Kziq0LBGZ4j2j 1zSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=TXtf7tjI; 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 e133-v6si6116719ybh.147.2018.10.21.09.15.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:15:27 -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=TXtf7tjI; 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 w9LGFP2u107520; Sun, 21 Oct 2018 16:15: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=zrdKK22K4yPwdg97C40ayFoftWNqhnfImZiJAlzmShI=; b=TXtf7tjImPPPMnmRMisYtzSEhJlDl0OcCOA8HdRd4+IgH7b9xiEed47N7N31qp6Ek8mv J7lIPGfjOGgG0cp2ziSGSKQTBofG+1aOlL/kieuxp3h0hZK7QV3TDK4WNPiGBFAfnjdI /HSDYaFejtPNUuYe9Ppp1G44Lp/XZYqy/YmGz3j2gJnbo48hAtx2JGZiMZ4OhhY9svZz vpPNekbk9A4ZwFHh3G9GznK1fsQaADQiF5X/MMXj234BeTjyLO3jg32fRlXegrcIrXsH HmAZMU+EfV7GjqrAiExJwcrmnmqmW/dpFnlmSB/2RUl/SzgjNG36ugACXxQHze0Zl/Mf nQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2n7w0qaxgw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:25 +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 w9LGFJq2003345 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:20 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGFICK024064; Sun, 21 Oct 2018 16:15:18 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:15:18 -0700 Subject: [PATCH 02/28] 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:15:17 -0700 Message-ID: <154013851690.29026.15431841657334599562.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=993 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Move the 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 Reviewed-by: Amir Goldstein --- fs/ocfs2/refcounttree.c | 2 + fs/read_write.c | 55 +++++++++---------------------------- fs/xfs/xfs_reflink.c | 2 + include/linux/fs.h | 9 ++++-- mm/filemap.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 90 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 260797b01851..d6e8e242a15f 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1717,13 +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; - loff_t isize; + struct inode *inode_in = file_inode(file_in); + struct inode *inode_out = file_inode(file_out); bool same_inode = (inode_in == inode_out); int ret; @@ -1740,10 +1739,10 @@ 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; - isize = i_size_read(inode_in); - /* Zero length dedupe exits immediately; reflink goes to EOF. */ if (*len == 0) { + loff_t isize = i_size_read(inode_in); + if (is_dedupe || pos_in == isize) return 0; if (pos_in > isize) @@ -1751,36 +1750,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); @@ -1813,7 +1787,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) @@ -1851,9 +1825,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 42ea7bab9144..281d5f53f2ec 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1326,7 +1326,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..47e6bfd45a91 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2974,6 +2974,75 @@ 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; + 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 Sun Oct 21 16:15:23 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: 10650947 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 0101C14E2 for ; Sun, 21 Oct 2018 16:15:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E36BA287BE for ; Sun, 21 Oct 2018 16:15:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7285287C6; Sun, 21 Oct 2018 16:15: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 7E290287BE for ; Sun, 21 Oct 2018 16:15:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DF126B0008; Sun, 21 Oct 2018 12:15:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 98F0B6B000C; Sun, 21 Oct 2018 12:15:28 -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 87D936B000D; Sun, 21 Oct 2018 12:15:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f69.google.com (mail-yw1-f69.google.com [209.85.161.69]) by kanga.kvack.org (Postfix) with ESMTP id 5B36D6B0008 for ; Sun, 21 Oct 2018 12:15:28 -0400 (EDT) Received: by mail-yw1-f69.google.com with SMTP id 191-v6so25608012ywg.10 for ; Sun, 21 Oct 2018 09:15:28 -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=6r7g0KcDO4x0ZJm4RBSdxfhsKMbYQWElnIgn2PkV3NQ=; b=gPJyGuW8qt9S/+xqj3LNfJFKG4tltpbVkAltYu/d0eo0a33HGqF9971dGVaz1ITfEa WiKNISBjNISxvXXM4znl+R9AIUcWttWrmh5dvwJOvvlp0x0OZEQ8aBsrrO+8E9gEEQxk Ht/fGiR/JyAnTmdHN4N7c68x0y5L00DCcCAMh/k95GXqXRbnaMCAxaVXcbg8t30m8JTb j6GGy0UAN1UL7u06j3qvcng678Z5FcN/bDtW3OoFmBYvrwGx92QMLUr9jmTfKf6ojgHx RoxGhqdTmB9wkc8Sx2dKO3F9RqzYOPNBjBZGU472GqzDck+gzxJPww6Fcn1v+yY2dhzW lptg== X-Gm-Message-State: ABuFfogJRe72wPm4OB1kTaaLluRGwvRG7iCVxsn6MIJM3kp7aUnZmWF1 zdZQObRkphbWxgnLSfwDtJ9MiFsrXC2ZrxHIw+gcTwIoKrjBiXe8f4o/MPVKEOZQPvT1HTANnf0 meewpQn7eXdZ07wJ0cfjypxm92Y3liWykDFBALAxh09hPepLnYjKEriDd5kBOzIUTsw== X-Received: by 2002:a25:a489:: with SMTP id g9-v6mr29419922ybi.276.1540138528105; Sun, 21 Oct 2018 09:15:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV60AVoYGtPeRAIL5BsKbETZRvX3xw3wvMHw8UIIfHEemZ9dZa18M9atHT965pDNp6EVjnd1K X-Received: by 2002:a25:a489:: with SMTP id g9-v6mr29419893ybi.276.1540138527578; Sun, 21 Oct 2018 09:15:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138527; cv=none; d=google.com; s=arc-20160816; b=lwSpcxhiRCpkUBYpF3kuOo+JSHKRNu+W0G/XXEadxkC3z81iXQng4NrZdctV3T4P87 DQVTAi0JGw4QwbzLJfU/lgjnLkX9l8WQaJavwbs+sRFdbe5h65r+d1APD2AvhyWPW5GP y7ypIBNZgVu+yEeNYNOJIZ0s1LK/rTt1xY546G5YEiGYkcJNYwHxjJaMZKmQaep8WaSk 3UeQGTwPX/Ws9Z3QplEywY/AoqGDuH7SOkQFKFc1iwa5JMkiy2uFPoQJsv4kvq57npbl NAyjHS79PzCtE2dMXkFS5sV//KV2wXotRboHHgXGjrIf9rOPA6oLg/pk0Pc/VcdbrgyC +0UQ== 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=6r7g0KcDO4x0ZJm4RBSdxfhsKMbYQWElnIgn2PkV3NQ=; b=r166V4QxDOwh52vhlZb3dojZ/TUsh5PKFbTfZhHK+8eTJyZhGSvTk3lgzhaOlFbO+J XI24w68w0zOkXq72l5PqeHduq1wmzqIe0BRDD84Wq1/5P2FXLGaapqFfxUUpzWfvL92h HGTZPTgIASF214fdOF5lWrVbhpGMH44SRn927IDTJ8vkx+2PLXBh7at1JtSDfD08F0aU nPp8vSwvmj6qeEh6+IHApXogNobvVpY9rYwtr3GCh5ZZrPw8bSQDq+yFeNshQGEewsY1 dTVtbVTihRnhiMFCuwhjIgW3tHPuYgs7//W9MSGrWTtAu7OJb6pKCmI5b4Q/n4ZySO4I uSeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=G4f0diKn; 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 i18-v6si1741687ywc.151.2018.10.21.09.15.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:15:27 -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=G4f0diKn; 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 w9LGEDTG154828; Sun, 21 Oct 2018 16:15:26 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=6r7g0KcDO4x0ZJm4RBSdxfhsKMbYQWElnIgn2PkV3NQ=; b=G4f0diKnSZMc5xbAUGZ7NohePK4ZGjNPNIJDHxsAvb5azkZKg4DFCdiSJJ9RhGBNfp+c VOFTqhfHvBHm7lOP9wXHJaFBJCkJv7XwG0RXL55JrfMQJtEvskTmMZyP+BTzhfvKq4+l rf3lyiVpxmUxzYk7m1L50bcSkSFGvD6XoBWRZA0AUz4H+XxYSKVRolB6so2ps+KB0NIU ZaYuNHHPWYoM9jM4RiVcoKQMgRjIsB72OmNHhRy5IyhYV7ivGpw2FgCTAjf0JxHvQh/s 3xAxOT+CWaf1XOa8nAqH5BOn/gJqxVX0jtuSTaFF+2VcJqUtqLxgXkzPJcHu7ewJsAdJ Vg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2n7vapjynj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:26 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGFPbA007826 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:25 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGFPJ5018013; Sun, 21 Oct 2018 16:15:25 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:15:25 -0700 Subject: [PATCH 03/28] vfs: exit early from zero length remap 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, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:15:23 -0700 Message-ID: <154013852390.29026.2594942938207791308.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=703 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong If a remap caller asks us to remap to the source file's EOF and the source file length leaves us with a zero byte request, exit early. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/read_write.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index d6e8e242a15f..2456da3f8a41 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1748,6 +1748,8 @@ int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, if (pos_in > isize) return -EINVAL; *len = isize - pos_in; + if (*len == 0) + return 0; } /* Check that we don't violate system file offset limits. */ From patchwork Sun Oct 21 16:15:30 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: 10650981 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 BC02514E2 for ; Sun, 21 Oct 2018 16:15:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A93ED287BE for ; Sun, 21 Oct 2018 16:15:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D79C287C6; Sun, 21 Oct 2018 16:15: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 E897B287C0 for ; Sun, 21 Oct 2018 16:15:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B184C6B000D; Sun, 21 Oct 2018 12:15:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AC6C56B000E; Sun, 21 Oct 2018 12:15: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 9DD546B0010; Sun, 21 Oct 2018 12:15:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f72.google.com (mail-yw1-f72.google.com [209.85.161.72]) by kanga.kvack.org (Postfix) with ESMTP id 6EDE86B000D for ; Sun, 21 Oct 2018 12:15:37 -0400 (EDT) Received: by mail-yw1-f72.google.com with SMTP id b70-v6so25749245ywh.3 for ; Sun, 21 Oct 2018 09:15: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=6U76j76igW5rHxBV4yEGa3iiO2lOb5rXvTc2z3yca+w=; b=XW2PQZdqUmJ9iJtmyEppk9667EabJVeXAFa51a9pS6dDNJ4iBc/zLH8bRaRAWRcrGf iFGfbUkEzuh/3T4KkQctCbZCTOgUOLzJEvL/gvjxy6a/qDpYd0iBqse5aBtmvx2sg4m5 nX97EHx0FK/Vgsg6f2MjSn7lKkV6iOYNfSiqO/wPw6nlWJxqSWZsMTZDYfxNKCFeD9OD ouw5vz80K8kfeNhRJDwmKJzBWRXeINyfpEpucK2pL1TewEJm4Lo5NscbjkJuga28PM+q 8bixYB4YEQBwI9Oed6o8WGLrBXvF3PgheWzPgxtkC2+vCaLoHTeiZU4T/LKIll/KXGpT p1Jw== X-Gm-Message-State: ABuFfohqJRj78MyM7nmLtMeKu9KC7NVYhopU5tJB8DI8dDM8stWS/Rwv vkeYXzHUpFSTtin4SWic9R6L6vhAaMQIKTaO7myCdAtJNouhec6pOTUF0JI/cJPtLsmP3qFckX0 lxcOWHwgOqgG7JLUh8F+bFjavuID1xELMzKbrzjkfYLVUmyIoI2KFckfyCUj3HzXi9g== X-Received: by 2002:a25:854e:: with SMTP id f14-v6mr19718541ybn.105.1540138537169; Sun, 21 Oct 2018 09:15:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV62npDXCG9ZMOJE897EEipTOiNhrihTZtkr5SadftJGtbsz9JhdBoDG7xZrWmoDxkY+nDSmr X-Received: by 2002:a25:854e:: with SMTP id f14-v6mr19718496ybn.105.1540138536375; Sun, 21 Oct 2018 09:15:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138536; cv=none; d=google.com; s=arc-20160816; b=0T3nUGlqVwKzmc70twV5pSic8/IjdP7TF/yXgBrnowGJe/BL85QmsJPC7idtM6Q/9p 24MH+05mpEL/Dt6MxeaSieAUS5UJLlxTQa3i00rgaHwIBVW1DSkAB1uR0A1sKS4bz9u6 enh1D7Pmm9s81phlsLV9BwUNWfFWgwsdse56hdeVM0qrlWV5V/oaDO6B4HpwOh10Uf4O Gcw/PQpya/ooLXDt7wIpQfp4b5z1fyam8w9Zw3POR1j0GOYZ5ldjl93tQHFYVwNEOD6g s6FzYcYF+CUIXrYfrV3fg8TgCiEsKlkfhF4XAiDBd5Y++r43ajfhnHukidGntteeTTCg yRIA== 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=6U76j76igW5rHxBV4yEGa3iiO2lOb5rXvTc2z3yca+w=; b=OkhAzLr6pvD8VfiY0YJBNoZXFbPljhKFEVLCsDCC7isyg226INXZ/MZkADy6wFtqW6 hqSrPhDJwyq9HMfzfzb4baa8PRGv2bNJaclYvnqrv3ERBMl3yMnm+4Wm1zjc/mNlS+DR D7qo14JvVmDf3hYTqFXzadmcgmmHsMADMMvidGZDSQaMkHavHQONkZA3kJ/iMRm8Gs9+ htW1G3RcClJ+A5lwCxlqBTaWm4HZMljr6Pb29CePjQnr9+t7Dt3Ag3YDt2mIN+VUKsJS oeVg3wwQW4zVzRIkK++0yH9m7R+vlhAGOHxwM+XCKO3Ae7Hsvwi4sqxRwYxvZQt/Y0F/ bKCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=sJiwqeH4; 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 131-v6si12902646ybk.15.2018.10.21.09.15.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:15:36 -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=sJiwqeH4; 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 w9LGEbqS106972; Sun, 21 Oct 2018 16:15: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=6U76j76igW5rHxBV4yEGa3iiO2lOb5rXvTc2z3yca+w=; b=sJiwqeH4X6gEw0lXCFlzzmk9BQSeC7DC/DPG2XKYEwNDCJumhFYBrMWydRzex27pMbjV 33x0Ux4eT4dk//SgW5BAuGHL0SzHb7Ieb3cx/7m8nngYpjO0Mh1Lc9K4he4z3SDfbPec 4+PgsJ1Hp8eOiOStSKoxD18Hfg0FDZwpMqKYzQfyB3okDiBLJbjGAXINPSCQ9+1yaw50 DOgko2nCl5xsn7L+luOOeqzn/eC1QrxE0hpbwEsTFBthjnOhFv2XBEaHZpnCJj1FsT5A sWMnIlyLSlOrI3NnZUEEfW4PlLGqKBA68JxwtgQVxMnNbp7ZA6SrL5OPF+rtaHBZCyV/ 7Q== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2n7w0qaxh1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15: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 w9LGFXqi003693 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:33 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 w9LGFWng018862; Sun, 21 Oct 2018 16:15:33 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:15:32 -0700 Subject: [PATCH 04/28] 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:15:30 -0700 Message-ID: <154013853068.29026.16132846055457280127.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Reviewed-by: Amir Goldstein Reviewed-by: Christoph Hellwig --- mm/filemap.c | 84 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 52 insertions(+), 32 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 47e6bfd45a91..84b7301e41a0 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2915,6 +2915,42 @@ struct page *read_cache_page_gfp(struct address_space *mapping, } EXPORT_SYMBOL(read_cache_page_gfp); +/* + * Don't operate on ranges the page cache doesn't support, and don't exceed the + * LFS limits. If pos is under the limit it becomes a short access. If it + * exceeds the limit we return -EFBIG. + */ +static int generic_access_check_limits(struct file *file, loff_t pos, + loff_t *count) +{ + struct inode *inode = file->f_mapping->host; + loff_t max_size = inode->i_sb->s_maxbytes; + + if (!(file->f_flags & O_LARGEFILE)) + max_size = MAX_NON_LFS; + + if (unlikely(pos >= max_size)) + return -EFBIG; + *count = min(*count, max_size - pos); + return 0; +} + +static int generic_write_check_limits(struct file *file, loff_t pos, + loff_t *count) +{ + loff_t limit = rlimit(RLIMIT_FSIZE); + + if (limit != RLIM_INFINITY) { + if (pos >= limit) { + send_sig(SIGXFSZ, current, 0); + return -EFBIG; + } + *count = min(*count, limit - pos); + } + + return generic_access_check_limits(file, pos, count); +} + /* * Performs necessary checks before doing a write * @@ -2926,8 +2962,8 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from) { struct file *file = iocb->ki_filp; struct inode *inode = file->f_mapping->host; - unsigned long limit = rlimit(RLIMIT_FSIZE); - loff_t pos; + loff_t count; + int ret; if (!iov_iter_count(from)) return 0; @@ -2936,40 +2972,15 @@ inline ssize_t generic_write_checks(struct kiocb *iocb, struct iov_iter *from) if (iocb->ki_flags & IOCB_APPEND) iocb->ki_pos = i_size_read(inode); - pos = iocb->ki_pos; - if ((iocb->ki_flags & IOCB_NOWAIT) && !(iocb->ki_flags & IOCB_DIRECT)) return -EINVAL; - if (limit != RLIM_INFINITY) { - if (iocb->ki_pos >= limit) { - send_sig(SIGXFSZ, current, 0); - return -EFBIG; - } - iov_iter_truncate(from, limit - (unsigned long)pos); - } - - /* - * LFS rule - */ - if (unlikely(pos + iov_iter_count(from) > MAX_NON_LFS && - !(file->f_flags & O_LARGEFILE))) { - if (pos >= MAX_NON_LFS) - return -EFBIG; - iov_iter_truncate(from, MAX_NON_LFS - (unsigned long)pos); - } - - /* - * Are we about to exceed the fs block limit ? - * - * If we have written data it becomes a short write. If we have - * exceeded without writing data we send a signal and return EFBIG. - * Linus frestrict idea will clean these up nicely.. - */ - if (unlikely(pos >= inode->i_sb->s_maxbytes)) - return -EFBIG; + count = iov_iter_count(from); + ret = generic_write_check_limits(file, iocb->ki_pos, &count); + if (ret) + return ret; - iov_iter_truncate(from, inode->i_sb->s_maxbytes - pos); + iov_iter_truncate(from, count); return iov_iter_count(from); } EXPORT_SYMBOL(generic_write_checks); @@ -2991,6 +3002,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)) @@ -3014,6 +3026,14 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, return -EINVAL; count = min(count, size_in - (uint64_t)pos_in); + ret = generic_access_check_limits(file_in, pos_in, &count); + if (ret) + return ret; + + ret = generic_write_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 Sun Oct 21 16:15:37 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: 10650993 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 01D8313A9 for ; Sun, 21 Oct 2018 16:15:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E3CC1287BE for ; Sun, 21 Oct 2018 16:15:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D7D2F287C2; Sun, 21 Oct 2018 16:15:45 +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 5CCBA287BE for ; Sun, 21 Oct 2018 16:15:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5251F6B000E; Sun, 21 Oct 2018 12:15:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4FB326B0010; Sun, 21 Oct 2018 12:15:44 -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 3C3216B0266; Sun, 21 Oct 2018 12:15:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by kanga.kvack.org (Postfix) with ESMTP id 1015B6B000E for ; Sun, 21 Oct 2018 12:15:44 -0400 (EDT) Received: by mail-yb1-f200.google.com with SMTP id c6-v6so23253544ybm.10 for ; Sun, 21 Oct 2018 09:15: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=SHexZ7j4NahuPkzJw7xdjRTs2Ez8K2Od8tzKdBj+sBY=; b=mcYkV6e/WqZ91fO+VtIM8X4ohbRFPYkPeFT7qejQzevrKCi2aeFxkJAWFUwb9tilNF Sa34ve9bFL7GSK83q0If64xwDRe5qpK12sf7u/wwsbPQhIY23nSS6GOCl45BDWEYarAi /w+P82a4Ehwutyx9PytyZB/X/3HuL2QrhOrtUueKW8ptX9xvXredttRgxbxX7qaWDvNI aLsnuz+M2Bo5wOfvd5LpVj/hpkz4Bc0qKy2possg5sgTd1kJUS/D4XJFGsuJ/cDEHpWy VkkAjVk2tmsIrkMSr4FlVsgkqro6JysmzCncz/P0id6VPrPhaXmPXYPwVjSIz1NSnOL1 PDdw== X-Gm-Message-State: ABuFfogDEmqW/mTo6Bn5NPiN/noPIjMlkCQBGBxKzMasW9isBZuH/QyG VuNmwBVHoRwrrWtTEHfHDjDA3wNX+uae7F//KGxpw0iL1mEvkvcM8g1rHjgMe2nwTfc1lCfX+DA uykLNsKZ18smvayw8nYxmZ7/6Z5OEkH8hB4Mj18/c1EqgWUohx7uNS+lpYPaMkHF4ag== X-Received: by 2002:a25:ade5:: with SMTP id d37-v6mr15761586ybe.483.1540138543749; Sun, 21 Oct 2018 09:15:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV60fYj9ypYrWbyOfDuc0hwN9vFc9c0yOPIs7KSTZyigeniV1IHdLV+lXDM94lcWpIzCG4U/Q X-Received: by 2002:a25:ade5:: with SMTP id d37-v6mr15761547ybe.483.1540138543042; Sun, 21 Oct 2018 09:15:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138543; cv=none; d=google.com; s=arc-20160816; b=lYQT1Pvfc9CGRJPe0FTvQAMrAOdxBiboaSoxKSWwD/z8HZr/ETY/qe/KpEEhL8CQGD +J/n6+okqgxH8pnC3EIkKFCb0CLQs5bAPJtbE4cBR6xKbabD6HaGEUj7cqZTjlmZlIW5 eTbflDunBAsBUqivpYDcQ+6EybvxLAihxL3kG0f3GiPFwoQFdJ9jMZ+CiVIrHuxyElu0 1/+DzkYRz+YRa639uNgmw8YYWbO1c+o4HIZziX58uVd0j+jlXqN2jGhZVkonA/iKivwV ip2TljWREojZiwglRcQzUpLKy5zFLJBC0GVC0IiGhQVwVOtgSdONNKxBPy6BtF2ma+5n uNuA== 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=SHexZ7j4NahuPkzJw7xdjRTs2Ez8K2Od8tzKdBj+sBY=; b=xb+AHxJgXyo98NvR0h0p4wSMwf36rlKYPCe+RXwq8L/7668mRmQ58mXkcIosvhsDTY 1IYfOchGW/RXeVsjQBrbe6S3K8GYv+0Au4B7MMeYDMVkjNifdJ6A0bfjhG/X/plw+PQb 8CUCmJZbbSSD/BDtDgwU5OPieNo9DUd/MGmPqFY1Xn+F7i+/o49z01kLjA57nfPMzDCj cab4mmSMi1l9deO/aV5Yj9u81zEF6S3eyZn2liMmgx+rcv6Jkv2FdPhgChrrlAD6mwmD Be9wWLxdbqWrFJ1uX+9Wxm/KTuQMAyTc85bPcGUt17FRfcYcX+zHKlPl1mUkumPOYpHM vrYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="hMI/grNS"; 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 g9-v6si2511560ybi.174.2018.10.21.09.15.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:15:42 -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="hMI/grNS"; 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 w9LGEViE106955; Sun, 21 Oct 2018 16:15: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=SHexZ7j4NahuPkzJw7xdjRTs2Ez8K2Od8tzKdBj+sBY=; b=hMI/grNS2O9UcylFxo7zNSIRyAyGodsx6RE06/3DCrd+aTxvroP7sa2CkXcbK/OdFYh7 vwSxFAwjQWBKcod5Hun76y6wwtLB3Tz0WcCR4Gxde49GKFCJEGul6mmc9AVyXUKELfvT 48Gm5JWoEAta77dJQRZi+3YILYHzDcdhIyFORlB+HUuLJdIhCZMCdx5nHjM7mPNh/UUI Pae2Bpw7MfRuLYJXQ7dwChEOmAECK3KKYoeC6Cazl77g2L1jexOXL79NoFos2EIMEoux KY0YrdB1kH0v92qV05waorrjRWAvExJMMb07b8mmPTW8iD2V2Q7juYZgpirQKWKdXPlA qg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2n7w0qaxhc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:42 +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 w9LGFerV008090 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:41 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGFe89018874; Sun, 21 Oct 2018 16:15:40 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:15:39 -0700 Subject: [PATCH 05/28] vfs: avoid problematic remapping requests into partial EOF block From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: sandeen@redhat.com, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:15:37 -0700 Message-ID: <154013853780.29026.5441191187672186537.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=785 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong A deduplication data corruption is exposed in XFS and btrfs. It is caused by extending the block match range to include the partial EOF block, but then allowing unknown data beyond EOF to be considered a "match" to data in the destination file because the comparison is only made to the end of the source file. This corrupts the destination file when the source extent is shared with it. The VFS remapping prep functions only support whole block dedupe, but we still need to appear to support whole file dedupe correctly. Hence if the dedupe request includes the last block of the souce file, don't include it in the actual dedupe operation. If the rest of the range dedupes successfully, then reject the entire request. A subsequent patch will enable us to shorten dedupe requests correctly. When reflinking sub-file ranges, a data corruption can occur when the source file range includes a partial EOF block. This shares the unknown data beyond EOF into the second file at a position inside EOF, exposing stale data in the second file. If the reflink request includes the last block of the souce file, only proceed with the reflink operation if it lands at or past the destination file's current EOF. If it lands within the destination file EOF, reject the entire request with -EINVAL and make the caller go the hard way. A subsequent patch will enable us to shorten reflink requests correctly. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/read_write.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index 2456da3f8a41..0f0a6efdd502 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1708,6 +1708,34 @@ static int clone_verify_area(struct file *file, loff_t pos, u64 len, bool write) return security_file_permission(file, write ? MAY_WRITE : MAY_READ); } +/* + * Ensure that we don't remap a partial EOF block in the middle of something + * else. Assume that the offsets have already been checked for block + * alignment. + * + * For deduplication we always scale down to the previous block because we + * can't meaningfully compare post-EOF contents. + * + * For clone we only link a partial EOF block above the destination file's EOF. + */ +static int generic_remap_check_len(struct inode *inode_in, + struct inode *inode_out, + loff_t pos_out, + u64 *len, + bool is_dedupe) +{ + u64 blkmask = i_blocksize(inode_in) - 1; + + if ((*len & blkmask) == 0) + return 0; + + if (is_dedupe) + *len &= ~blkmask; + else if (pos_out + *len < i_size_read(inode_out)) + return -EINVAL; + + return 0; +} /* * Check that the two inodes are eligible for cloning, the ranges make @@ -1787,6 +1815,11 @@ int vfs_clone_file_prep(struct file *file_in, loff_t pos_in, return -EBADE; } + ret = generic_remap_check_len(inode_in, inode_out, pos_out, len, + is_dedupe); + if (ret) + return ret; + return 1; } EXPORT_SYMBOL(vfs_clone_file_prep); From patchwork Sun Oct 21 16:15:44 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: 10651005 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 AA36413A9 for ; Sun, 21 Oct 2018 16:16:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9911C287C7 for ; Sun, 21 Oct 2018 16:16:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8CF58287CC; Sun, 21 Oct 2018 16:16:02 +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 4F7B5287C7 for ; Sun, 21 Oct 2018 16:16:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7224D6B0269; Sun, 21 Oct 2018 12:15:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6A9206B026A; Sun, 21 Oct 2018 12:15: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 549246B026B; Sun, 21 Oct 2018 12:15:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by kanga.kvack.org (Postfix) with ESMTP id 044B46B0269 for ; Sun, 21 Oct 2018 12:15:58 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id z8-v6so22924584ybo.17 for ; Sun, 21 Oct 2018 09:15:57 -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=DsB/GfHe8rY/6K9TRDqJFG41++LpUZSoAdzvXmeEYVk=; b=BjFy4yVdYWO2p/xb/1EIcbnvJDDFQvUTi01+BaR9vc2LZPWYxeMVr4VC9nCE4zXOGE x2oUx2gx/M3fAEPBlFJVTe4P6c2U9a9HuxLt2nvYnC2CxBj30rE/EvXhw53+6M6UGs0X FJKTcEnHW57YoSjzKXP4pUzxbqgPiVpkav8gq1NFm9WJfjdYSqCjHsuWVWtVhOxy97uQ nHb4BltOidlEa0MXn5K3x0rOIOFAG5HsbmZxH7E+7d2RFb88eVNOX6ooMdkJyXwUUuiM F6pcLKTa7oS/EdBcjv+f8/3b7pxdKqSv7AMj8YfXOY4H+FdnxfldXrMF9e3w/vv8oZWb Sw1A== X-Gm-Message-State: ABuFfoitD8k1q0Dl6CUynMVVbiSAETNATNA2qyvlMepofh75LDPIiP/+ OURx3DPGWH6U9HfshAyHY59bXhRPCF/1ClFgm3hrlNF5Sdkk1L6AosGvDip97+UEtKm7fc22Z1s 4ARfdCca+O7iGH2YU1NXQ0L51GVzFCN6wim76us++vFu6dxO1CrBWBCuXOvqVKc3+YA== X-Received: by 2002:a25:c0c8:: with SMTP id c191-v6mr19323652ybf.429.1540138557762; Sun, 21 Oct 2018 09:15:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV60p/KwKzEU+hiH2bJY+x0LNSw6uL9s9ljHKVyF/jn0CPbG7R3gS1Y7ZBKd7M9QYYSotIIkF X-Received: by 2002:a25:c0c8:: with SMTP id c191-v6mr19323620ybf.429.1540138557223; Sun, 21 Oct 2018 09:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138557; cv=none; d=google.com; s=arc-20160816; b=NnVoj0lBA6hqn12vJtis7EKJqqUvlNBTx3qwOFbLvh6aeGslxRnXZ4UcyvLEC1JFhs ScmgmEaM9mHxI2ed97YEuczhqVBHAw7FzNMdys/S8vEzGSMxjYTMb7pMWbsrqwUqvdwd XXH3flLmozDgwWjEbmTpN7Gf9x3gqp27wlLf4xiqc567KIRE/xRFgdc6lofUAH4J4gU3 DnJt1OHmI6vxCR2/BH+iUC6KOlKOhCPHi6l9/BoLGue7oBJmDdJ+2h+kPRWqQr74nNTu xGVXDSjYY4Pnb1wSyvPy1ueL0UTxDFzvom3aq0FWjeBvqr2ynGQDo7tpn5bKmcBjf67l Yg/A== 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=DsB/GfHe8rY/6K9TRDqJFG41++LpUZSoAdzvXmeEYVk=; b=mxVodsvHyDafdyLJtMCQCYOu9wBLRDBTbYfyKPFW3hMaupVL+xcs1QJ4TeLyZqpyeJ VBSg2aQrp5see+ID1xRvfb+pvTOnxc1Sb+EsEyc3KlHTmzuIJP+sJKJT/7M6squZBG96 K3OmHU3i+KF/SdSZXOC/6c+KmYEW/KH6StMv5ekwF1OBfPnWvw2YaMzp3LSQ/CVPuwGm JziEzfKOKI5Jv1ik4jeXG5xICORpjDY56ft+vqgyDQBYteezE4v7zMIfMO0FOBdusx/5 592Dhk888BPGS9+UOKL3hIrfgE96MHqtaxboBgYu3By8jxkCfPeqekOwJSeCqPQbv1ZE /AqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=E1OEI7d8; 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 j66-v6si13879206ywe.442.2018.10.21.09.15.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:15: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=E1OEI7d8; 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 w9LGEwQi155209; Sun, 21 Oct 2018 16:15: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=DsB/GfHe8rY/6K9TRDqJFG41++LpUZSoAdzvXmeEYVk=; b=E1OEI7d84CbIJscvXHDCDdpVPa2MBX+GXImkaOWtQFOayB2Txw8gd31Ny7x2N8NfSq5t 1ifIujoBu42x82czxOFmGO37JKvrpM4Zh4VDOgM7PH2tagytftxSQ2HmhSt40PGB92ne 9dlF0OTWNXegJzcI5/01NyBmhZAU/TRTOM8UehzfGomwA7AC1SdpQVwwnYpygcGi3ism mbFx/XOYwXvHbLjY1UZNTor8jd/4HudRjD4GN6OiidArQJ2yF860gy9r2W5mRmlOntjC BKogkNDwDVQAXL1pntCy9fA6ljbjIDLxHqycKz2bscGBBvCaIZbzLV+GDnl15nTL+PKQ eQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2n7vapjypa-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:54 +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 w9LGFl2G004097 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:47 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 w9LGFkXR018894; Sun, 21 Oct 2018 16:15:47 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:15:46 -0700 Subject: [PATCH 06/28] 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:15:44 -0700 Message-ID: <154013854491.29026.1645091969567859095.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=750 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Reviewed-by: Amir Goldstein --- fs/read_write.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/read_write.c b/fs/read_write.c index 0f0a6efdd502..f5395d8da741 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -2009,6 +2009,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 Sun Oct 21 16:15:51 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: 10650995 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 B922213A9 for ; Sun, 21 Oct 2018 16:15:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A432B287C2 for ; Sun, 21 Oct 2018 16:15:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9573D287C7; Sun, 21 Oct 2018 16:15: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 13C93287C2 for ; Sun, 21 Oct 2018 16:15:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 23F5E6B0266; Sun, 21 Oct 2018 12:15:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2151D6B026A; Sun, 21 Oct 2018 12:15: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 0B5846B026B; Sun, 21 Oct 2018 12:15:58 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by kanga.kvack.org (Postfix) with ESMTP id D37806B0266 for ; Sun, 21 Oct 2018 12:15:57 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id f2-v6so5926846ybo.1 for ; Sun, 21 Oct 2018 09:15:57 -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=EVBOjpjVeZ0uqv5Ytj51D02SOvbvYZvIxgFPH2/97ks=; b=seak5tXm0tQHJfqjATSRl+xIpqQtsLwAxMHcSJ7D5+TpeS2XnYNy+RUrE2gaYLL/lL MDX2hRxyMyOsztkK+9h7HFMUfcAF9j2TIuDfHnUCz1V6zavGIZLdlkPBIe+CigR1HaWv yAVWg8eA0eeXpmIKF+VcMOPFgdmsKK98ylft+BkDnoCZ+GARoZEgiaFyfmbydAk8KV20 X9/KDxkTZ1UjtZSg6h11g8iOZ1mjQiBExWmtfPxPxcmM7yYnz4jBNo06K30WvqpHLIvF YS6gnsZwY9TrDuJL6B22ch7W9xWP0odCY6rygApzIhBDXXqzSpnNtV7hrEowKaZBg/SN cVPw== X-Gm-Message-State: ABuFfogmOu3cBHq4U67OQbxMXSzg/xZM3IVM2od9CpTUyC58q+EaTYik Xkl1VnPuoUhk85AwjPsdoy2xmtqF6BqpqE4LSLpyNLmLnIJ4/cbaSlye7OM4P3S9U10WMLgud2E tmWvZZ7ucBIOb7wP2vyc8Xtvc4u2nFxFHm7FCuaJse8YoBQpy3QnDk1XieKiEShB3Qw== X-Received: by 2002:a81:2cc3:: with SMTP id s186-v6mr30263246yws.168.1540138557584; Sun, 21 Oct 2018 09:15:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV61P5IJSrmurUMVwFuAynUJXv6Xg8DHaiEGIY1bz1AsaJwLeK3x92iCwF+oX5y+NyP1I+hLN X-Received: by 2002:a81:2cc3:: with SMTP id s186-v6mr30263211yws.168.1540138556964; Sun, 21 Oct 2018 09:15:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138556; cv=none; d=google.com; s=arc-20160816; b=fPli+Sq3h+lvfpsNGUXQ8EzOOyM6qmTeRitioyL35pvQaz5twi2VlkqwRzR55BkKrU M3CE7UMt18DA+XjNnAmLcPTlMX325FXkFyvZ1+4HIHd1fJtpe4jzZqbkwyKaKBLSu/6l Fo5phwsK6v5cnm1ekPLeyeaf79b2oO0h1HOx0Bicfv62HAzBXpmbDJJTm1SEqOiy90+c sij04kDxZINHeaZZHkQ46Q52T6X/1BZiodRBQAoIKQ8uWoWjXch34zCrGmNITcbWdkFl bxe24cOWCdh6JKT27fIptrKk9YugOpVyzTKHJ2cuybCIaEPtTzC1BoZ9wVd2U9rbf1Lt 3/Ag== 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=EVBOjpjVeZ0uqv5Ytj51D02SOvbvYZvIxgFPH2/97ks=; b=Ivgo03G/Ntk/pr9Cl+27yc/ISH9/cQSCtTDsDtixg6HD4kgCyj74rV1aTWZrxtOGzT ghfzizA7/cp8cuFbs47OU50an3Pegcts+9XEgz+f0OYAL00R3occzC4ZOBe5SwmAQz/I XWawlURbFGaAHYpSuK2epERUwPFjfU4EMTSyNjnHk4I0fCLT+tEZ2FIHadL5Ker9e+QY D+1ebuxhcRrTtF0wBGzbgShJp6CTh4IBoalj2+2UWSm8eUt0ngxsNTztgGCOdGAeuuZU vFpCTNHGuZ5iGtCsKjWtdV1b3iPDloXEctO7SXR6X0srcFtYz5bHzqwOjtdtaYLRowZe LUyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=jjp1goek; 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 s9-v6si13765631ybg.344.2018.10.21.09.15.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:15:56 -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=jjp1goek; 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 w9LGF9ta107440; Sun, 21 Oct 2018 16:15: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=EVBOjpjVeZ0uqv5Ytj51D02SOvbvYZvIxgFPH2/97ks=; b=jjp1goekmyibL+yh4EIs0el4hgqZmgMDX+/wChkYo/K9cm7WquwmJgKwfHIu8KZNQP+9 fSqI3Q0Psh7ss+Aoi85vg/nUvSAMsWldca5tCYMSLRQlzxX6Am2VkwHP0oG5SqREzDas ig1m5jdGSeWeWKyBINPywcrKc7E5LHBxekFvv1yYmtDjvcNfU9caXVF8Zojo6DGvZBc8 Cl1vud0+Ur3U6NDpMoOMnBdXyZvnmPIMkdNJ+0ILZkF09hmvzAeX1kD2uQnegDyigJ+l EK8OUSgjOeGHueXL5IQR0xKYrqWoORNh1s7R0KhTypvGYcZS6QZfHwZeDsIrBFWuOCFd nw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2n7w0qaxhj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:54 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGFrr6011457 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:15:53 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGFrC4024250; Sun, 21 Oct 2018 16:15:53 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:15:53 -0700 Subject: [PATCH 07/28] 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:15:51 -0700 Message-ID: <154013855179.29026.12300431992865619414.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=749 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Reviewed-by: Amir Goldstein --- 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 f5395d8da741..aca75a97a695 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1745,9 +1745,9 @@ static int generic_remap_check_len(struct inode *inode_in, * 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); @@ -1822,7 +1822,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 281d5f53f2ec..a7757a128a78 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1326,7 +1326,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 ba93a6e7dac4..55729e1c2e75 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(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 Sun Oct 21 16:15:58 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: 10651019 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 3328F13A9 for ; Sun, 21 Oct 2018 16:16:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20F94287BE for ; Sun, 21 Oct 2018 16:16:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 15898287C2; Sun, 21 Oct 2018 16:16:08 +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 A7C45287BE for ; Sun, 21 Oct 2018 16:16:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 71F616B026A; Sun, 21 Oct 2018 12:16:06 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6CF286B026B; Sun, 21 Oct 2018 12:16:06 -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 5BE786B026C; Sun, 21 Oct 2018 12:16:06 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f70.google.com (mail-yw1-f70.google.com [209.85.161.70]) by kanga.kvack.org (Postfix) with ESMTP id 2B13E6B026B for ; Sun, 21 Oct 2018 12:16:06 -0400 (EDT) Received: by mail-yw1-f70.google.com with SMTP id d23-v6so25303243ywd.8 for ; Sun, 21 Oct 2018 09:16:06 -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=lbgR3wOuOLZGLL8/c8R4UCc54EWHiKBjm/iFOf5M+sk=; b=LWpex+3F7Kde0OCiK80C5g+h+l4qaqTKiRWiL1nHMZHNpTdremdS1aNUfEtr46oD6F NluyNo+dDTCgLegHG+DwCA5jksWlxC1aUmnURkpvvoV+v5YlS4cXnt9qZBrU7i4IfHBv eqvOxhOK723m+fOIQ5Pb6wYJ7JbsZBW+VHskqtry9XThisObuSW3aXJTsVaQfulAwepO if1mnE5lFI3YN6L8vjOiHWBxN37ECpLN6Q0IJkBKwgyvDEGF3ozT8x4EVwAUQAAsSQan vzXR9Mw1+N1mT3BsN8tv591S621779es/bJ+zV4e1KzQING1knNoTPrKBhLztFmcoSPV s4BQ== X-Gm-Message-State: ABuFfog7eO82YFaTVtUK9Gf1VyTXYQZ5CN7mOAFRPJ6fXZZAjrk4z3V9 fNtOAr1NL0vU2CFdhXWK781jiEi6y8/dOiS2swLCi0kAV7Qp9KIdnH65UBx8uP/mGQzWRmTC3gu y5XNFP4xq4SutWC1YyB9pDKINuevkcdZfR6nm0p6TnRQSa4MIgz6nfquJHQvX6eBJvA== X-Received: by 2002:a81:53c1:: with SMTP id h184-v6mr29851747ywb.101.1540138565872; Sun, 21 Oct 2018 09:16:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV62SpcOoH8nl7SnXFHBK+qZZ7B3hIrhk9rBzN/aguj1hdYWdKGNvLXuToSziLzLYbrBvxF7m X-Received: by 2002:a81:53c1:: with SMTP id h184-v6mr29851710ywb.101.1540138565352; Sun, 21 Oct 2018 09:16:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138565; cv=none; d=google.com; s=arc-20160816; b=q9pANm51BLy29gi3UwBA7L8vPSEOPfuMCEv01A85L+YHwfw1bqlKuWHFg1lkAnvsRY KPauMeHd5v4SuGRFuZpqo9cnZouyTDBvwrhSQrFoOHqNAsPrz9obYL215SmOYvXhwf2g O6tbSLJ2a4o9U+3lENiYWw3YFWWZ/R2ghhSw4+YMpl4kD3EsZKekbvjqH+fyYD4M4DxA 7K9teqLckGzMa481NzUTtpqshscQbOaUhbWzhdy0pfLZhLhKETBOPq6HtA7bFBMSeyne hYabRee4Vt/nrqzzxCJuUixuOXUHyt5d/Q0sD6VdsSuQ6dJoaTzeIZ/DGFPWfqlWLNin MCEg== 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=lbgR3wOuOLZGLL8/c8R4UCc54EWHiKBjm/iFOf5M+sk=; b=Xk7TbYL4jr5m3j9B4ATcFF3lB5OzAwA1Yluv4FRWZWCPJ1/OiAX6YOWlwLgqprnAhY fxf1k93uhZwjYUHf2Onf7no1IGHGr2bdj9TnFSj+GS26b2StUxhGfjc6zFjQKIOtzV7Y wM3YTedRTmknwExLsBntgh7VkicS2nfqGLRMeHq7ULSgywcishJMRJWzVzbTPWsNLPUa wpxrIfTTeFl0Pwb7v6TDMIYTJfxtWqxRM/ApaoS/sm84yXAV/H3HzMuDE43TTkaKB6Hr 7+c2fSKhuDZkzkvwIJgiqU7GjT89n6j7AR0HjU7cE8KRhiaExGXD0AafDnUAKI5r1kRM M+MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=n6L7avtx; 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 o26-v6si13920675ybj.34.2018.10.21.09.16.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:16:05 -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=n6L7avtx; 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 w9LGE650154818; Sun, 21 Oct 2018 16:16:02 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=lbgR3wOuOLZGLL8/c8R4UCc54EWHiKBjm/iFOf5M+sk=; b=n6L7avtxPHSrZRUnsbJm+xUBs9dbvUZW8h8rDvfvIbXNC+YAJJimK8Lc+4n2NdxoaD6X a5de+M4HczsI+FTbTY8ADlMmmFf9LBfsJ47PVUBxqGl7wt42x/N7+cWibXLLpZN1ZHw0 EEyKV83b/5/ip2rtFyHNZmzKSf3jv3JYegQcMPSI2u5RqE6fJvW0cA4HZEu0S5eOFMbN 1khxwhvPjHoKFAkPdQZ4kNy5wZ+/TeCJwST+MuxBZ7MXSik3bVvc4jwCX+sjjpHO2Len vU36WlKLepmSUQr7Ai/dKlFocBQVXAwGu4VtpRa0o6CBG9TfWoPpSwZavJ6V4ZqwqWfW Mg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2n7vapjypd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:02 +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 w9LGG1ri025777 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:01 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 w9LGG0oR018910; Sun, 21 Oct 2018 16:16:00 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:16:00 -0700 Subject: [PATCH 08/28] 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:15:58 -0700 Message-ID: <154013855860.29026.18117400241937143769.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=706 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Since 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 Reviewed-by: Amir Goldstein --- 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 aca75a97a695..734c5661fb69 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); @@ -1852,11 +1852,11 @@ int do_clone_file_range(struct file *file_in, loff_t pos_in, if (!file_in->f_op->clone_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; @@ -1989,7 +1989,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; @@ -2051,7 +2051,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 Sun Oct 21 16:16:05 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: 10651031 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 B034413A9 for ; Sun, 21 Oct 2018 16:16:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B8AE287BE for ; Sun, 21 Oct 2018 16:16:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F35A287C0; Sun, 21 Oct 2018 16:16:17 +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 33A0E287C7 for ; Sun, 21 Oct 2018 16:16:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 043816B026B; Sun, 21 Oct 2018 12:16:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F341F6B026C; Sun, 21 Oct 2018 12:16:14 -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 E23E26B026D; Sun, 21 Oct 2018 12:16:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f70.google.com (mail-yw1-f70.google.com [209.85.161.70]) by kanga.kvack.org (Postfix) with ESMTP id AE0A26B026B for ; Sun, 21 Oct 2018 12:16:14 -0400 (EDT) Received: by mail-yw1-f70.google.com with SMTP id b70-v6so25750192ywh.3 for ; Sun, 21 Oct 2018 09:16:14 -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=AcDM3TmjzAQAbXYilZuJKFzJc8bMhi0F4OAile4MRPA=; b=pbjLBpbyKrThdHab6zyvdtUi42llkqXwFiMtDwAPTp7CB9XfpChm7wbFVn0cWIN8NP EED3CX94WyZgfStgko5tfDsuglWICR7K5cbw1e6plqWed/dkvwgaWbVetNVNf+heeUqN g/wy3lgAgF4UsJNqcs3UtsxiKty47pXwGoGFLbA4+31VkvdPJtCwBfNa9liIvMhQI3+I 8gplPCF1F2CexMwOPcK9RRXIqQAP8EwnBAEQkkDJ4VAlG58qzWdXBG2AAjG7uaDV31Mf yMAvagizPrNZ+zyz3SflykZEH/WXOMEk35Ah/gDKz12BJQY9EsdDATqI7/nlCYPg0pRg JsyQ== X-Gm-Message-State: ABuFfogcJOcWnJqSwffLq4XygD5AmCba8ffp3xuE3ea8bqQrqIMImEi7 +ssuej4MPiN48JudePKcytq3P/sWpkoGhpviI+vWceOdOZSKuUff8p2OQBOY4jO3mlAIIEC27xX hRCXULbvVwtaW5ppJz3AHQJNu/HqgvQFPBPAoNLOTIgQyvhm1piZxg6RaYjkXJqhFWw== X-Received: by 2002:a25:1c83:: with SMTP id c125-v6mr28439066ybc.93.1540138574381; Sun, 21 Oct 2018 09:16:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV60O6KBk+0eIm+y6v5KC4pVl/VtxNaovpbNvqcOYi2dBcTJNrRzCUnff2JGcWIoFswdKii00 X-Received: by 2002:a25:1c83:: with SMTP id c125-v6mr28438981ybc.93.1540138572865; Sun, 21 Oct 2018 09:16:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138572; cv=none; d=google.com; s=arc-20160816; b=nK3514sy/5Sqkuv1TYGIPAmx2X8OrWFwqcgtzmiXguDHjlvIL/ERBgSeRUaeq2+ll0 YIJKJjF/ofG9A7JjMeYkMZvgutNrQWPyu/wbiX/Jj9EM5lgs83xfRl53pzPRLgMn/WHg npgg8DOANrwAUGyBAHnIx71rzRnlfbR4aXcpqIVUJOdixdb+ESWdJNsBmrtA4viKVVxF 6jWZFtdkZa8zgqxa0OMqQKoWuxxHb4O2CI3c5YASbEFV8mGs7n7is5xY5PQktcejEMF6 iJF+/C3GWx5Np0XwZlxZdUGkITFj1+6FFc24s/FtQyeuiFU1i3RAkd3PIczEIdAcMw0c /qDw== 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=AcDM3TmjzAQAbXYilZuJKFzJc8bMhi0F4OAile4MRPA=; b=Fiu5qSkjFGDkiG5LaMZAOMRmetUfj0d/Tdkor0IccIbiVW+cqo7Xc2uBwP5dy+v9cu POATPLy4FzFZCjp5mkeSmmIsoMOGkisysJFRLPy+scqD9QSqseYUP8lK43PfWTeIqYHs MKHK+Ui7S4tugaeN6iEfaY/yLHYFu4QQNbeVZeGYfFf5VGMg1So1AXS10CBMufu7FzgF 96hU5LZbK1Cu/U7/Z17TZ8nLVJcZcMIktXxdqJFpynL7un69vg48XHBMsjRPtWIINgTZ ghEZETUL/UsO22JCGyGTft5ezc/XcS4efvUj5QymQBZIo1Ny8ID882Dna9kxngp3+e0i YCrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=gSTL07OE; 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 205-v6si12911540yby.184.2018.10.21.09.16.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:16:12 -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=gSTL07OE; 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 w9LGEaX2154211; Sun, 21 Oct 2018 16:16: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=AcDM3TmjzAQAbXYilZuJKFzJc8bMhi0F4OAile4MRPA=; b=gSTL07OEnsNwlticUjIaSQjUNdoDB2K74zBdXbYQqNm6LV09L7WAgwEQTI/JDI215D4O g1pd5ADSDx0xd7jwbgdtfAHGHzTNTUyfbXMJggHKNwEQvyjreqI3daJcMTgr8ZOwOUUF tliOzeu7rNpdPyLPmGDoh7wpiZDAQwodlAQd4EvYFA7j5LyZ/3gP9Ilw/BkktquO8RXm zP1stgtFRbtIqODieOsiveBzuHBrysgVCDsexodB8OnaA/oITBdrVe+lxu3fVqm/QSS5 N6dxScN/v5S624C109OpY9aqSpHsdnfDu1xpT73Q1soRz3jrHFcnrRrpF/mUtfUhEuDg 3Q== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2n7ustu1sp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:10 +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 w9LGG8ta008837 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:09 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 w9LGG83X021153; Sun, 21 Oct 2018 16:16:08 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:16:07 -0700 Subject: [PATCH 09/28] 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:16:05 -0700 Message-ID: <154013856577.29026.16107144417454863537.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Reviewed-by: Amir Goldstein Reviewed-by: Christoph Hellwig --- Documentation/filesystems/porting | 5 ++++ Documentation/filesystems/vfs.txt | 20 +++++++++++----- fs/btrfs/ctree.h | 8 ++----- fs/btrfs/file.c | 3 +- fs/btrfs/ioctl.c | 45 +++++++++++++++++++------------------ fs/cifs/cifsfs.c | 22 +++++++++++------- fs/nfs/nfs4file.c | 10 ++++++-- fs/ocfs2/file.c | 24 +++++++------------- fs/overlayfs/file.c | 30 ++++++++++++++----------- fs/read_write.c | 18 +++++++-------- fs/xfs/xfs_file.c | 23 ++++++------------- include/linux/fs.h | 25 +++++++++++++++++---- 12 files changed, 127 insertions(+), 106 deletions(-) diff --git a/Documentation/filesystems/porting b/Documentation/filesystems/porting index 7b7b845c490a..e6d4466268dd 100644 --- a/Documentation/filesystems/porting +++ b/Documentation/filesystems/porting @@ -622,3 +622,8 @@ in your dentry operations instead. alloc_file_clone(file, flags, ops) does not affect any caller's references. On success you get a new struct file sharing the mount/dentry with the original, on failure - ERR_PTR(). +-- +[mandatory] + ->clone_file_range() and ->dedupe_file_range have been replaced with + ->remap_file_range(). See Documentation/filesystems/vfs.txt for more + information. diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index a6c6a8af48a2..6f5babfee27b 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 remap_flags); int (*fadvise)(struct file *, loff_t, loff_t, int); }; @@ -960,11 +961,16 @@ 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. An + implementation should remap len bytes at pos_in of the source file into + the dest file at pos_out. Implementations must handle callers passing + in len == 0; this means "remap to the end of the source file". The + return value should be zero if all bytes were remapped, or the usual + negative error code if the remapping did not succeed completely. + The remap_flags parameter accepts REMAP_FILE_* flags. If + REMAP_FILE_DEDUP is set then the implementation must only remap if the + requested file ranges have identical contents. fadvise: possibly called by the fadvise64() system call. diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 2cddfe7806a4..124a05662fc2 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 remap_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..bfd99c66723e 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,30 @@ 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 remap_flags) { + if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) + return -EINVAL; + + if (remap_flags & REMAP_FILE_DEDUP) { + 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..e8144d0dcde2 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 remap_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 (remap_flags & ~REMAP_FILE_ADVISORY) + return -EINVAL; + 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..ae5780ce41dc 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 remap_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 (remap_flags & ~REMAP_FILE_ADVISORY) + return -EINVAL; + /* 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..0b757a24567c 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2527,24 +2527,18 @@ 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 remap_flags) { - return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, false); -} + if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) + return -EINVAL; -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, remap_flags & REMAP_FILE_DEDUP); } const struct inode_operations ocfs2_file_iops = { @@ -2586,8 +2580,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 +2626,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..fffb36fd5920 100644 --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -489,26 +489,31 @@ 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 remap_flags) { - return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, 0, - OVL_CLONE); -} + enum ovl_copyop op; + + if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) + return -EINVAL; + + if (remap_flags & REMAP_FILE_DEDUP) + 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 +530,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 734c5661fb69..766bdcb381f3 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; @@ -1849,7 +1849,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 = remap_verify_area(file_in, pos_in, len, false); @@ -1860,8 +1860,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); @@ -2006,7 +2006,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) { @@ -2014,8 +2014,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, REMAP_FILE_DEDUP); 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..2ad94d508f80 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -920,27 +920,19 @@ 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 remap_flags) { - return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, false); -} + if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) + return -EINVAL; -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, remap_flags & REMAP_FILE_DEDUP); } STATIC int @@ -1175,8 +1167,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 55729e1c2e75..888cef35c7d7 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1721,6 +1721,24 @@ 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. + * If it is called with len == 0 that means "remap to end of source file". + * See Documentation/filesystems/vfs.txt for more details about this call. + * + * REMAP_FILE_DEDUP: only remap if contents identical (i.e. deduplicate) + */ +#define REMAP_FILE_DEDUP (1 << 0) + +/* + * These flags signal that the caller is ok with altering various aspects of + * the behavior of the remap operation. The changes must be made by the + * implementation; the vfs remap helper functions can take advantage of them. + * Flags in this category exist to preserve the quirky behavior of the hoisted + * btrfs clone/dedupe ioctls. + * There are no flags yet, but subsequent commits will add some. + */ +#define REMAP_FILE_ADVISORY (0) struct iov_iter; @@ -1759,10 +1777,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 remap_flags); int (*fadvise)(struct file *, loff_t, loff_t, int); } __randomize_layout; From patchwork Sun Oct 21 16:16: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: 10651045 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 7F91613A9 for ; Sun, 21 Oct 2018 16:16:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 68C5B287BE for ; Sun, 21 Oct 2018 16:16:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C57D287C2; Sun, 21 Oct 2018 16:16:27 +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 7C518287BE for ; Sun, 21 Oct 2018 16:16:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 634A36B026C; Sun, 21 Oct 2018 12:16:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5E5116B026D; Sun, 21 Oct 2018 12:16:25 -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 4D55F6B026E; Sun, 21 Oct 2018 12:16:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by kanga.kvack.org (Postfix) with ESMTP id 18D076B026C for ; Sun, 21 Oct 2018 12:16:25 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id r3-v6so7227603ybo.7 for ; Sun, 21 Oct 2018 09:16: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=YES+b1E1OUbVKGgJYtK0FVRugzyHm2bJctiptn3YOO8=; b=PTwazDzTGq6n4cZKgThU4SKAKTLQMfEz9c0I+XtRdwcH1xfm19rcGVkSFZG97/OdTx PbjLllMWJM5JGm6oB/baHTJEkoax0JvFA1iXWmV0fjxQ6sh9t38hdWkaxV3RjHVZSpgZ hzPpLyLIWMJNYMc0mRQY0aPrWSrBly2+8nBwCmIJY3xL+WFF2GB2htTei8wfdD9KUFeL 1UnL3DBWR3aWFQ7eSYdoEKTBqjO5HXOwRvpP+T9u8SVbOBR68rhWtP3FxdokqvA7TdAe wRTb4wsab9SIchXe16sbyArgCHhkQy2hFX2txi3a5QorCqi5NsZLqScpMkaattqY6d6G Ty+g== X-Gm-Message-State: ABuFfoiDHhIBFnm5ho4ggwcfkXRlFTgZd3NcXuEguCJ+j7Yz1C4GsLkX 1tqZSgLjOMzC9n+g+dXz6cP5dTI1fkcL78CM+bgGN7kDpChEX7/fC6704L2erZT0eZH5R0VdvG5 6N0TfByW/1M8MI5UCvGbwgULLsUOYZ4FBpSw1DJcBTg9c4D8xm/2iP3kLiAXhIktEpA== X-Received: by 2002:a81:590b:: with SMTP id n11-v6mr4632210ywb.359.1540138584778; Sun, 21 Oct 2018 09:16:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV625YNqkawU+Kyf5rcQzXUbCjkXE8LwhlMV4o+mqJZnDrXv+sxz4PnAOzd+1G4bk5W62BQO7 X-Received: by 2002:a81:590b:: with SMTP id n11-v6mr4632160ywb.359.1540138583952; Sun, 21 Oct 2018 09:16:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138583; cv=none; d=google.com; s=arc-20160816; b=He/I+A07VDF8eMQKXmMq0oMaM9KQPXDMeO5yDZ2xGf21Hlan5Ps0UK/qeL8h+c76Ky BkWqDhnHm+VtVAEoR/arbH+8p+Z8klm6OAd6CTUxtBd4zuaceG47+i2Shik6zqrUNDhO jq+XnRYhkqnOaYMS+a07H/+i2oJ5zb6AN2fwA84bySlp5Tj6L027ILBPsqD1jd0FG9Y3 EjuexHTGHEg+7xbrgJxZbE0lLdiHVvPOJ7WvIPKGPVHFuBq/gTZTnJr+Xd0SzR+01nJD 590KqY+gNqutlvpIBq6nTMyLu1hBSAyw6eU5z6gbHBN4MPVlquoD9y0qvvjve4JMSgmO 3aow== 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=YES+b1E1OUbVKGgJYtK0FVRugzyHm2bJctiptn3YOO8=; b=HiOLfIg5uMWVpykOO6Nur4MsdkLhATtzYpbav/c8SPgAd2UTeTq4vrQZvBlrxpFtvJ kkgNtrkHqRH1TI2EiGsoXbO35jUIvEhMsqlGWmbOs1rLInWbSCV/glydp5dt5TUCGHQT zyO2PXQxOUBpZ6DPJkpub0NLRz61MRkIOizpm8/MJq0Te5UXwJf/p17IHxGPj/RioPg+ 30bNwxAssOgZb+AMJ8SK916dfUp/8Z5nhLW0PmnxlCDYFeHaKn+qo6FujihGhOPx1r7h V6+spaNhX1kBS3EFYtx2FCRVWirnDcDgW9rpi2FzV0WlicgUsot8TPsxN8FVeeJe1Eyc OxXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=NDxDrxgc; 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 x127-v6si2587508ywg.359.2018.10.21.09.16.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:16:23 -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=NDxDrxgc; 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 w9LGFTEI155732; Sun, 21 Oct 2018 16:16: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=YES+b1E1OUbVKGgJYtK0FVRugzyHm2bJctiptn3YOO8=; b=NDxDrxgc8O8iv3G6KH0DvBNL2bnjf7lQwJXLV4KIIjLdkhblwr/ViGUoG01o69aMJFCs 4c2v+NXaNx9AkI/LhGBN/84o/suRYEEd8g/0Eo3Cf1VsNarnhlax9PDdDSTFphePToGy CoPRhoWGZdqOaOd2+ecN1h0ZQNtZx+fXIxUXb6hpUhJtSL3PlH9gqSDgMCQR/Qf4z9/9 jvuQHx5Krr5YrSERv3pp3Nj4Nk/HmAFvqovZBt3nFHBhzET3dP2eJWjIQOcF2MhEyVXe Pf1jnI5+SdTTqo5IyA0AJT1nF/8azq9JBoOC58ZEZnDrmMFoh1WT4EwABTERl3W+HfHM aA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2n7vapjypy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:21 +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 w9LGGFPF008933 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:16 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGGFfU021229; Sun, 21 Oct 2018 16:16:15 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:16:14 -0700 Subject: [PATCH 10/28] 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:16:13 -0700 Message-ID: <154013857305.29026.15904890974200543869.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Reviewed-by: Amir Goldstein Reviewed-by: Christoph Hellwig --- fs/ocfs2/file.c | 2 +- fs/ocfs2/refcounttree.c | 4 ++-- fs/ocfs2/refcounttree.h | 2 +- fs/read_write.c | 14 +++++++------- fs/xfs/xfs_file.c | 2 +- fs/xfs/xfs_reflink.c | 21 +++++++++++---------- fs/xfs/xfs_reflink.h | 3 ++- include/linux/fs.h | 2 +- 8 files changed, 26 insertions(+), 24 deletions(-) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 0b757a24567c..9809b0e5746f 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2538,7 +2538,7 @@ static int ocfs2_remap_file_range(struct file *file_in, return -EINVAL; return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, remap_flags & REMAP_FILE_DEDUP); + len, remap_flags); } const struct inode_operations ocfs2_file_iops = { diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 36c56dfbe485..df9781567ec0 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; 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 766bdcb381f3..201381689284 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1722,14 +1722,14 @@ static int generic_remap_check_len(struct inode *inode_in, struct inode *inode_out, loff_t pos_out, u64 *len, - bool is_dedupe) + unsigned int remap_flags) { u64 blkmask = i_blocksize(inode_in) - 1; if ((*len & blkmask) == 0) return 0; - if (is_dedupe) + if (remap_flags & REMAP_FILE_DEDUP) *len &= ~blkmask; else if (pos_out + *len < i_size_read(inode_out)) return -EINVAL; @@ -1747,7 +1747,7 @@ static int generic_remap_check_len(struct inode *inode_in, */ 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); @@ -1771,7 +1771,7 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, if (*len == 0) { loff_t isize = i_size_read(inode_in); - if (is_dedupe || pos_in == isize) + if ((remap_flags & REMAP_FILE_DEDUP) || pos_in == isize) return 0; if (pos_in > isize) return -EINVAL; @@ -1782,7 +1782,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 & REMAP_FILE_DEDUP)); if (ret) return ret; @@ -1804,7 +1804,7 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, /* * Check that the extents are the same. */ - if (is_dedupe) { + if (remap_flags & REMAP_FILE_DEDUP) { bool is_same = false; ret = vfs_dedupe_file_range_compare(inode_in, pos_in, @@ -1816,7 +1816,7 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, } ret = generic_remap_check_len(inode_in, inode_out, pos_out, len, - is_dedupe); + remap_flags); if (ret) return ret; diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 2ad94d508f80..20314eb4677a 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -932,7 +932,7 @@ xfs_file_remap_range( return -EINVAL; return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, remap_flags & REMAP_FILE_DEDUP); + len, remap_flags); } STATIC int diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index a7757a128a78..29aab196ce7e 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -921,13 +921,14 @@ 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; int error; - if (is_dedupe && newlen <= i_size_read(VFS_I(dest)) && cowextsize == 0) + if ((remap_flags & REMAP_FILE_DEDUP) && + newlen <= i_size_read(VFS_I(dest)) && cowextsize == 0) return 0; error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp); @@ -948,7 +949,7 @@ xfs_reflink_update_dest( dest->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE; } - if (!is_dedupe) { + if (!(remap_flags & REMAP_FILE_DEDUP)) { xfs_trans_ichgtime(tp, dest, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); } @@ -1296,7 +1297,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); @@ -1327,7 +1328,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; @@ -1336,7 +1337,7 @@ xfs_reflink_remap_prep( * from the source file so we don't try to dedupe the partial * EOF block. */ - if (is_dedupe) { + if (remap_flags & REMAP_FILE_DEDUP) { *len &= ~blkmask; } else if (*len & blkmask) { /* @@ -1372,7 +1373,7 @@ xfs_reflink_remap_prep( PAGE_ALIGN(pos_out + *len) - 1); /* If we're altering the file contents... */ - if (!is_dedupe) { + if (!(remap_flags & REMAP_FILE_DEDUP)) { /* * ...update the timestamps (which will grab the ilock again * from xfs_fs_dirty_inode, so we have to call it before we @@ -1410,7 +1411,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); @@ -1430,7 +1431,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; @@ -1457,7 +1458,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 888cef35c7d7..631c28ce1436 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1844,7 +1844,7 @@ 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); + u64 *count, 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 Sun Oct 21 16:16: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: 10651047 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 C84F213A9 for ; Sun, 21 Oct 2018 16:16:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7261287BE for ; Sun, 21 Oct 2018 16:16:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB672287C6; Sun, 21 Oct 2018 16:16: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 30442287BE for ; Sun, 21 Oct 2018 16:16:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 578846B026D; Sun, 21 Oct 2018 12:16:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4FE1A6B026E; Sun, 21 Oct 2018 12:16: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 3C8166B026F; Sun, 21 Oct 2018 12:16:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f72.google.com (mail-yw1-f72.google.com [209.85.161.72]) by kanga.kvack.org (Postfix) with ESMTP id 018246B026E for ; Sun, 21 Oct 2018 12:16:26 -0400 (EDT) Received: by mail-yw1-f72.google.com with SMTP id b76-v6so25265646ywb.11 for ; Sun, 21 Oct 2018 09:16: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=Ax8fPC441txtB/zxSXAjFoiXirNOr5aJSks+n5W5dVk=; b=QmwSUlJ0EguQC37tNS5DvIS8KgpBAXTHITH+0fbV/adIjIHXHeo6PSkbE4s3oQScHR WL/ZCFGhcrJNhVbAUrSfTqp9N7JZ5M/sBz4nxW1siFjs/B2Z6wtnEuQu168KEdD8A1tw w/hh5vsz164vujiHvaVuc20vkBAoYMM5CC521ucnEULGS45+AD2NTgRZKYKMkT+Ttk5d iOUaoXcbK5umxojXdAdbQhVzoTnzCsPPjJ9saHQ28wcU+QQgZeJtgMaxwxhFSdWyHzAb bsnjF+D+dOtPtWp7Dah1XWmSLszfatMZlCDYCK0tzYB47YWF8Tku9q4k5CHi4CM+EHyO so8g== X-Gm-Message-State: ABuFfojRrPL3uzKWPCSsIQ5rlucq6+hfrrnOXVKkDpk6y1vksQaD1dXz tDTdtsFbh8ds8JOjjgCY4B0bQEomCLafwNUB64/uRiJBPy1/A7s0IvL31fdT0XvH6YYTfHiT/wF 5oQNATHlbKJucwTaL+w4IxIDJuaWwahXJXKSQl6ueMU6IO6EOdOzPbjCHEuz2P0nnnA== X-Received: by 2002:a0d:f546:: with SMTP id e67-v6mr29112332ywf.304.1540138585746; Sun, 21 Oct 2018 09:16:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV60WeufayksAgzWw/95kWpksbYXmYjBBPCEARaF77RjADZKSk/D/G8EkId6rMZYs4n768IXd X-Received: by 2002:a0d:f546:: with SMTP id e67-v6mr29112286ywf.304.1540138584935; Sun, 21 Oct 2018 09:16:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138584; cv=none; d=google.com; s=arc-20160816; b=axI7DVGpB7u0kFLR2Q6oWWplIG5rWM+aUYepnfEplhctQ8h7CRjbYnWlFBrgRBlo5Z PH8QNRyMZOOV72+aYDofXDRarpm9q/YAVtf5dOga9pmrbyhi5nfErWq1DEeHbluHPAh7 ChuiAhgb8SRMioUOS9lI3lx9cfikOVZrKRzV2AEbXeCLJ7fwCJ2gCWfhMab2IlHjo/fV Yya5JaN+sQYZGv95i5KCwjvngJUVVb6k0ltJtDeN+Ti5XkFeNV78AukxXp52xuH7p0uP ayouZw0oi9KJZmP68evcqHtg4iDwhkjvtJGsa07793GmJNIFl6CVGJOCgwkyFLqPbpL6 WWLA== 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=Ax8fPC441txtB/zxSXAjFoiXirNOr5aJSks+n5W5dVk=; b=jPuVQ2a7TH5sf8NOIR6qW83nEk+BZ2Eyp5AsxKgZUhef449yJQHxu+u678r44bE2sr G4+vrzVofiuU6QHCjWZ53gAox7uBU7TsvG9m6OVSAXmsMZNyeSgV3sFUCQ02f5HhryTi 0rK4mwecaZ6mj71Z0fY8Q2Qh/Nq9PPRORzyxvxVyjevif3107Sd82sAMUTslp8nkkXJn oiAWQgZRwt364K1APbyYbv0DVHtt9THG03AxWBXUzrnB3nRsLJpghNaOiAGa+mvs1iMu qr9AT9RBCqRHTamcihTFTDfLJdKPr6ZkA+77MElVZES1UQpCCkrPXe3eSs3u4jnhWMF6 0c1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=DcOx2GaI; 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 132-v6si13927131yww.36.2018.10.21.09.16.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:16:24 -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=DcOx2GaI; 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 w9LGEObc106939; Sun, 21 Oct 2018 16:16: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=Ax8fPC441txtB/zxSXAjFoiXirNOr5aJSks+n5W5dVk=; b=DcOx2GaIHgIOYJ7VwcXw4w7scujVFYT6o5xi8DKxadeahhNbgLe+mCcQMd1+49vrgsGv cYDylEHPay8idamCKSkuqRZ2RjC9JsQeOSWssUj9E38KQm0f5Y+nfBjgAdNNxVPD3ZRC 3JpjUK422zcaF7UCNCYF3itqMLWj+Z8gttuspY71p4tbGMEL8AusOT7Upebyj/H0EiqP i1793+TbFsKDrNQN39oqyqmiDq5ts0naMf2JQI0b2rQhnsuQNOkb5xh2BA5jzGbc5M6P pTebBU+qkjiHGRt28szyEfXUKwHq4VJ15Gy2SVLFOBAwnzFDktmPBudqTe4rBmd+DHnp pw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2n7w0qaxjd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:23 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGGMWO009030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:22 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGGLH5018384; Sun, 21 Oct 2018 16:16:21 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:16:21 -0700 Subject: [PATCH 11/28] 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:16:20 -0700 Message-ID: <154013858003.29026.16188863826706349189.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=506 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Pass the same remap flags to generic_remap_checks for consistency. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein Reviewed-by: Christoph Hellwig --- 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 201381689284..ebcbfc4f2907 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1782,7 +1782,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, - (remap_flags & REMAP_FILE_DEDUP)); + remap_flags); if (ret) return ret; diff --git a/include/linux/fs.h b/include/linux/fs.h index 631c28ce1436..c5435ca81132 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2986,7 +2986,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 84b7301e41a0..410dc58f7b16 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2994,7 +2994,7 @@ EXPORT_SYMBOL(generic_write_checks); */ 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; @@ -3016,7 +3016,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 & REMAP_FILE_DEDUP) && (pos_in >= size_in || pos_in + count > size_in || pos_out >= size_out || pos_out + count > size_out)) return -EINVAL; From patchwork Sun Oct 21 16:16:26 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: 10651061 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 3B53714E2 for ; Sun, 21 Oct 2018 16:16:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28C26287BE for ; Sun, 21 Oct 2018 16:16:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C35A287C2; Sun, 21 Oct 2018 16:16:35 +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 9C6CB287BE for ; Sun, 21 Oct 2018 16:16:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76DEB6B0008; Sun, 21 Oct 2018 12:16:33 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 744C16B0271; Sun, 21 Oct 2018 12:16:33 -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 6361F6B0272; Sun, 21 Oct 2018 12:16:33 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f71.google.com (mail-yw1-f71.google.com [209.85.161.71]) by kanga.kvack.org (Postfix) with ESMTP id 309466B0008 for ; Sun, 21 Oct 2018 12:16:33 -0400 (EDT) Received: by mail-yw1-f71.google.com with SMTP id c67-v6so25778646ywh.13 for ; Sun, 21 Oct 2018 09:16:33 -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=JKTdos3g9sr+caRIKtd3XTJY6SNyMhNBCwtE8oUJnVs=; b=ukymqy/ykonK0atl5AKpz4PmbaW3MQXNK4UTcNTPbXgIhe1MJtXxs469s41faPzRQT mkgDJ/1RrHo1Rn01UZfIO6J0PeNi0dTW7T1+1KtrUc+NId7SjTmf65WUL/QpTiyEktKs uGpxNjEjDRtxhHtlOguzttKI99FVl+aLjJqhyV6A+oVoW5A2JyfCqmeULIZn4qf5tYZm HocjGu8FONK5vSNGhee8saT6kproYznjv7xBgeeChx9Gv7wv2qi4BAOrCnLqwGyxmoOt Euu5z4jhvJEPyI4bQNP4dYuxZhW4XSLLGBIGFY1UTtPbEYLdaMwlKKoHarw31rTn0hil +z5Q== X-Gm-Message-State: ABuFfojnt0wc86h+SVjHRiG1xBFBzs0/5UMbNj03ktLmc0aogiBD5GX6 mEfgapa1aM7KKHmsZUchSLMoP116IhxpShB0JeR0qMHNwr/kt3VnIkIkkMRNx3UtTiTiKYAAn07 Wlm5HvtKfmqRdEPOamz6cSNxJbbLIMCto/gKYebRntB/+ND0pmuhd6pUBJmhV22SX2A== X-Received: by 2002:a25:6b4e:: with SMTP id o14-v6mr8560969ybm.158.1540138592942; Sun, 21 Oct 2018 09:16:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV60LzOMEFDXl/Q5CmecgDWGKqn2LzAimRNd6FoUHzFxS5jnNpaDFMZ4CwLn3Eet8zj81Qv2Y X-Received: by 2002:a25:6b4e:: with SMTP id o14-v6mr8560935ybm.158.1540138592341; Sun, 21 Oct 2018 09:16:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138592; cv=none; d=google.com; s=arc-20160816; b=gNDBRgAOIJVorNSUhVUVey264aS7dMR8Yx5HIfmFy5TFtmVRRopszgOvp+EHGr5Dk4 wp4KGqrLoQgZFrDiGc7o/81MGl+HDTiAv7gzyVKsSLQXTO1EKRCP1hAJ9hvqOu1tjqCk 7+ePHCazArCuhZDXmqy2uasT2DkpibUFQFNAW6omTb312S4BeVCjwWl7jDw0O+oe7QdG L6gD/58Pl1mauCpDqzCnTjRbnDzprokCF+xF9v1uzmqhGhnnsd9Yw2dDaSGBWDEh81FV sS6VPA/fZj9VM4bY5AyieEcwmFjwCeUbY3N3v0gfsBnNSyeJogcxod2eyDZ6vCZYVytl 4EXA== 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=JKTdos3g9sr+caRIKtd3XTJY6SNyMhNBCwtE8oUJnVs=; b=mylW4snwitdflotZuCITAMzpW0It1LymFuiZcdlUi9UUCJHl+mYTyalsfzDcvsoF1d O+Gag8zzp47x2Ncf2Ju5qy04GdP6E4XqVKi4+HGyb5B/E+T8v/e5vhGOZe2KnvJTd1tV 4eox6nP1kCn2Clk/Ssx0FyxE1zrUDegqCJdYqV1R0MsQsfKCJuXzwhRTK+vIvJaNpsLR fCEcYpKNhwKZ6b2VY04XBSlPIFP5eMYi5krLx95gLts4+ZRK72zBQUfcXzZzyXYtyqa5 Nx1LhJAyTiWAexsABjBXd2uiWkturGsVRckncgP7vlbiqscVl2Jex2wVvJhUEoWvtREr kpzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Q2DkFSC0; 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 w6-v6si13273203ybl.150.2018.10.21.09.16.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:16:32 -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=Q2DkFSC0; 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 w9LGEsJL154505; Sun, 21 Oct 2018 16:16:30 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=JKTdos3g9sr+caRIKtd3XTJY6SNyMhNBCwtE8oUJnVs=; b=Q2DkFSC0hVVLtFHZpR+NYqXPbdkwGDg/Tm0SAy7SQGYYAerjF3rwxSMbHBGk6f/+fmLg diVl5wWmoc6UWkzxYJcCIvHrsLSWW85B9HR7MbjL/ZqlKaDt4gjeAYLcKsYnsImJoA2a Nyy0+7t1hPmGfVaf1ymDHgbv/0P8Myj/GWTDr6pZsC+EKoGL6LUQXop+RMw4SL+NUE/S GHhjluXW8LJYlyV9/GSXx3Dk1kMbfy1buNJn+elYsELswpcRsmfqrPcBho1BIYVhdB4H 1o1jw1OQBqFdMrUS3etymkCQhJNbgsd0lRV71NucMpG6kKftH12mbIQ1P59PBB5B3mGr /A== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2n7ustu1t6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:30 +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 w9LGGTvU026218 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:29 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGGSEZ021255; Sun, 21 Oct 2018 16:16:28 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:16:28 -0700 Subject: [PATCH 12/28] vfs: remap helper should update destination 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:16:26 -0700 Message-ID: <154013858694.29026.18365355055791584652.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=867 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Extend generic_remap_file_range_prep 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. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- fs/read_write.c | 19 +++++++++++++++++++ fs/xfs/xfs_reflink.c | 23 ----------------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index ebcbfc4f2907..b61bd3fc7154 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1820,6 +1820,25 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, if (ret) return ret; + /* If can't alter the file contents, we're done. */ + if (!(remap_flags & REMAP_FILE_DEDUP)) { + /* Update the timestamps, since we can alter file contents. */ + if (!(file_out->f_mode & FMODE_NOCMTIME)) { + ret = file_update_time(file_out); + 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. + */ + ret = file_remove_privs(file_out); + if (ret) + return ret; + } + return 1; } EXPORT_SYMBOL(generic_remap_file_range_prep); diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 29aab196ce7e..2d7dd8b28d7c 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1372,29 +1372,6 @@ 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 (!(remap_flags & REMAP_FILE_DEDUP)) { - /* - * ...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 Sun Oct 21 16:16:33 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: 10651093 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 37EA713A9 for ; Sun, 21 Oct 2018 16:16:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EC67287BE for ; Sun, 21 Oct 2018 16:16:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 13110287C6; Sun, 21 Oct 2018 16:16:46 +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 A9E21287BE for ; Sun, 21 Oct 2018 16:16:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 599276B0270; Sun, 21 Oct 2018 12:16:43 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5486A6B0271; Sun, 21 Oct 2018 12:16:43 -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 412596B0272; Sun, 21 Oct 2018 12:16:43 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f70.google.com (mail-yw1-f70.google.com [209.85.161.70]) by kanga.kvack.org (Postfix) with ESMTP id 0B88C6B0270 for ; Sun, 21 Oct 2018 12:16:43 -0400 (EDT) Received: by mail-yw1-f70.google.com with SMTP id j69-v6so495634ywb.19 for ; Sun, 21 Oct 2018 09:16:43 -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=/GmEYjUu/zG/fDUDxFQ+l8ztuRa7zS2Vh5bnpkE6nkQ=; b=qIb2LEQnfN3NEJOU3h4kRx9YVswCk9mqw16ROAHRQoO2blw0HTpsMa2MMNCGdUk3m1 ddUYkWQONGw6405HC2ai6ZEJR+6KzF0NMumtXdwsa52FnFKn3NN0DITddh83Nf+BfaG2 t1buz7nKfGb7xjj9FyDJrSby+g61E7nFp6IIDY/CuPl8+mtwFDIOTrtx67HksHNHib7J 9J8F63wYo1OTQZXgOXJwx293XZMSGIP8DrpCVE+r6Wpjphvy3CaF8IUn8eyjopsbUeGR 1VoJjFpN//MohAZt/Vw8n0JqTnjpgbctRfEkjr7EfiN+sQJRLX/B2Z4OVptaKDaoJj3n 6L4w== X-Gm-Message-State: ABuFfohVSxCFsuJTWhnw3O1xBvr1eyWn3jIlVSo8bWDEbUQhcI3LTQ4v Jxbk/0JWRpB+08/53908Vcs0tlZP+wfzFavtt7DneboGMr5+KYpMDf+GHonY32JIBILEbSfBjJ4 IBWLyWGrr2KWkQ8kZ4NJmgIYZXUMl4nIpGuMBJW8oD5PWltqFBpyi0/+c8UHhjMq8Eg== X-Received: by 2002:a25:200b:: with SMTP id g11-v6mr29865844ybg.390.1540138602728; Sun, 21 Oct 2018 09:16:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV61ml20Mleva+MO0OhFpnlZZAwViq34qECoPaWWINqjo8wheu4WlLQO9WxpceRZtIdc/B9Ag X-Received: by 2002:a25:200b:: with SMTP id g11-v6mr29865754ybg.390.1540138601200; Sun, 21 Oct 2018 09:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138601; cv=none; d=google.com; s=arc-20160816; b=lxg7/ZRHrN49Tza9wKO9B44OxTejiWD8sj0RE4DS6tRqgOZ9cHFiXP2Ru1vyrgjDTH kOiGhRMV2X/wCTzWWreEOiM54Yy8O6UGdVy01IDY8y2jovt7BwagsFsWs/6yi/OQ32dM mJT4PcsaoGdhv7eziZ+PtX/O0oIzkD5iuxCrDdIT0gZYcFHgG7BorL9bOhDQOHHH3UNk SQ1zYOlFxxqzTAgg/xkJKy+NVmU/NE3b/aDaNH1CzqccoxFfU5E7UCljMTTYueWEJ4sW 9r5YwfgdkXjZd1lPPz7MKErkp9deL5wdH+hgLW/ux7ocpGK9n0pnhZ+RrHb3QGH+dgUz 5yoA== 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=/GmEYjUu/zG/fDUDxFQ+l8ztuRa7zS2Vh5bnpkE6nkQ=; b=fKzqVWavFyPiLakXu5Yz/hULR88nT/9CNSg7XDXL18XpCzgH1gs+9j55i4raYCl++n XB95ETn/I3OPYz6VuwCYHL5wH32A3MbXW+eUfJvhaFNDiGnt9vImTi+kb9lQCXlKkuKR Q4pOhYY0/NV0eDBliu0OLURNSUOFlty0/Xqm+uAIwlWQOzOof31zkYHdbT6poTeUotxD P5lYXDEppe7YuwqnTbkG5fMAEYZZ7T9PZBbXAoDU7IavwMyTTxGqy5vqiE3Tn6ZXT5UN 4abFlgmL58BleOWt32IDHN3nr/sVKOcFIn8P7WqG532JDUe0su+LrGViUmJRVwTgp7/Y 3LtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=majh78wZ; 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 y18-v6si4525638ywd.79.2018.10.21.09.16.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:16:41 -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=majh78wZ; 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 w9LGGCQ9155864; Sun, 21 Oct 2018 16:16:39 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=/GmEYjUu/zG/fDUDxFQ+l8ztuRa7zS2Vh5bnpkE6nkQ=; b=majh78wZsFPOtf7wFVzGbJV345QORAdTIdWKrAYdG3/SQoyd9v+9kgin/QVaK3KjmHc3 iH+Q/jKGZBkccyll/d64PrAUS8zdQngX8zeGLUql/GJ3YMZvXDJn/3R5zng2zU+Vaios Ud8er2teCCvSz31rKmxiwvLhCz6afHLJcu6mSMzq7BiOga9MgNwaqE1nTAXIA3frOKNN U3BNyEkQsPd1VqVAcww3rwhKS/JOnFoKYg/cmwpc3D3wClnHnJ5SFO0NJ5q+w7OH7E6M L3x3aiZQcop4EUfxeIi6rtAH+Sl4d6o5RX4uZXFz5WHDXQEG6u1A1lkNUSuEihrkr0Qm 7Q== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2n7vapjyqj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:38 +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 w9LGGbxL009407 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:38 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGGbd0019145; Sun, 21 Oct 2018 16:16:37 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:16:36 -0700 Subject: [PATCH 13/28] 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:16:33 -0700 Message-ID: <154013859374.29026.1521928064568511378.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=871 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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. For now the short return is not implemented anywhere so the behavior won't change -- either copy_file_range manages to clone the entire range or it tries an alternative. Neither clone ioctl can take advantage of this, alas. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- Documentation/filesystems/vfs.txt | 10 ++++---- 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 | 6 ++--- fs/overlayfs/file.c | 12 +++++---- fs/read_write.c | 49 ++++++++++++++++++++----------------- fs/xfs/xfs_file.c | 9 +++++-- fs/xfs/xfs_reflink.c | 4 ++- fs/xfs/xfs_reflink.h | 2 +- include/linux/fs.h | 27 +++++++++++--------- mm/filemap.c | 2 +- 18 files changed, 108 insertions(+), 82 deletions(-) diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 6f5babfee27b..1bd2919deaca 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -883,9 +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 (*remap_file_range)(struct file *file_in, loff_t pos_in, - struct file *file_out, loff_t pos_out, - u64 len, unsigned int remap_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 remap_flags); int (*fadvise)(struct file *, loff_t, loff_t, int); }; @@ -966,8 +966,8 @@ otherwise noted. implementation should remap len bytes at pos_in of the source file into the dest file at pos_out. Implementations must handle callers passing in len == 0; this means "remap to the end of the source file". The - return value should be zero if all bytes were remapped, or the usual - negative error code if the remapping did not succeed completely. + return value should the number of bytes remapped, or the usual + negative error code if errors occurred before any bytes were remapped. The remap_flags parameter accepts REMAP_FILE_* flags. If REMAP_FILE_DEDUP is set then the implementation must only remap if the requested file ranges have identical contents. diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 124a05662fc2..771a961d77ad 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 remap_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 remap_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 bfd99c66723e..b0c513e10977 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 remap_flags) { + int ret; + if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) return -EINVAL; @@ -4349,10 +4351,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 e8144d0dcde2..5ca71c6c8be2 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 remap_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 ae5780ce41dc..46d691ba04bc 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 remap_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 9809b0e5746f..fbaeafe44b5f 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2527,18 +2527,18 @@ 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 remap_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 remap_flags) { + int ret; + if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) return -EINVAL; - return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, remap_flags); + ret = ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, + len, remap_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 df9781567ec0..6a42c04ac0ab 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..8750b7235516 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,11 +142,10 @@ 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; /* FIXME: copy up sparse files efficiently */ while (len) { diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c index fffb36fd5920..6c3fec6168e9 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 remap_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 remap_flags) { enum ovl_copyop op; diff --git a/fs/read_write.c b/fs/read_write.c index b61bd3fc7154..356641afa487 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; + loff_t 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)) @@ -1721,7 +1725,7 @@ static int remap_verify_area(struct file *file, loff_t pos, u64 len, bool write) static int generic_remap_check_len(struct inode *inode_in, struct inode *inode_out, loff_t pos_out, - u64 *len, + loff_t *len, unsigned int remap_flags) { u64 blkmask = i_blocksize(inode_in) - 1; @@ -1747,7 +1751,7 @@ static int generic_remap_check_len(struct inode *inode_in, */ 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); @@ -1843,12 +1847,12 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, } 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) +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; @@ -1881,19 +1885,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); @@ -1999,10 +2003,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) @@ -2051,7 +2056,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; diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 20314eb4677a..38fde4e11714 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -919,20 +919,23 @@ 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 remap_flags) { + int ret; + if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) return -EINVAL; - return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, + ret = xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, len, remap_flags); + return ret < 0 ? ret : len; } STATIC int diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 2d7dd8b28d7c..3dbe5fb7e9c0 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1296,7 +1296,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); @@ -1387,7 +1387,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 c5435ca81132..c72d8c3c065a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1777,9 +1777,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 remap_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 remap_flags); int (*fadvise)(struct file *, loff_t, loff_t, int); } __randomize_layout; @@ -1844,19 +1844,22 @@ 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); -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); + loff_t *count, + 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); +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 { @@ -2986,7 +2989,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 410dc58f7b16..e9091d731f84 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2994,7 +2994,7 @@ EXPORT_SYMBOL(generic_write_checks); */ 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 Sun Oct 21 16:16:42 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: 10651107 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 DA021174E for ; Sun, 21 Oct 2018 16:16:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7429287BE for ; Sun, 21 Oct 2018 16:16:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6EE7287C2; Sun, 21 Oct 2018 16:16:50 +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 1F68C287BE for ; Sun, 21 Oct 2018 16:16:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BDBB76B0271; Sun, 21 Oct 2018 12:16:48 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B8C686B0272; Sun, 21 Oct 2018 12:16:48 -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 A79976B0273; Sun, 21 Oct 2018 12:16:48 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by kanga.kvack.org (Postfix) with ESMTP id 7AAD56B0271 for ; Sun, 21 Oct 2018 12:16:48 -0400 (EDT) Received: by mail-yb1-f200.google.com with SMTP id y131-v6so2464572yby.13 for ; Sun, 21 Oct 2018 09:16: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=xA3xAo7jyFFTMAx8OZ0C35llgz82vC0GqmJcW4Cw9ZU=; b=p05rplTw1RmWl9wXn6H6ImKHJYZI9arQHTYY452k2etPmlm6BEtSYIgWAyCqgP5Xht Hws1ylzyNi65A6Quw3oHnA9lVuURiYoAruNr25YPyxkQH2iRTP6/ynrhTY2tK3dttCKw NAikcbCgt0K0LZDgGUtKOgWBaGQr5CorQmBIhTusuoubrD6hC13l1+l+8aHfLipoiNNg jmmWkXHtXu1h1R14KUKjmDSPKRuT7ldlv5pS8EhH0k1F66Pud5FXgKezwuksG7BseuNV EZLlCG6adIWCmApHk27tIJKWxuxWYaAVOAMZPMwW6bvk7f8UzQupjjxZyd0i6iKKjfYQ XfaA== X-Gm-Message-State: ABuFfojjN3tYkXrFDhk33RTNhriCrM9bQcTvUPoiw5aJKMy8evCKLhGI 3qs3djTwQTm2ZbTMneT8uwkCpR4Vcuqjs7Po6ugDakOe1AlxJPB1SXUSaIXoqTKqX/h24TarJ33 mnD0VpUfGrkHa4dg1qLRiLegZ/wcL5VHw8cbZVwGB4PlbFzaRzTxQimYSLm/7KyN8xg== X-Received: by 2002:a25:6c45:: with SMTP id h66-v6mr28702479ybc.112.1540138608238; Sun, 21 Oct 2018 09:16:48 -0700 (PDT) X-Google-Smtp-Source: ACcGV63GiYSdNemvyBusBnku54rkDdmI9136lvJGja+udPZoj0KkQZU6ZW0MmXsneTsIGD3/8OKH X-Received: by 2002:a25:6c45:: with SMTP id h66-v6mr28702442ybc.112.1540138607485; Sun, 21 Oct 2018 09:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138607; cv=none; d=google.com; s=arc-20160816; b=Z8PHw+p8mWET4OOhPEun6bagnkAMrQnRyOElSDPHH7xeLfRoqL9PO1ws+r5MOPq8CN 8gmlKMjn+9dMG2UAMNa3aCj6YF8fYCuMmsmTPmtb6MS7nXvXt/AO+QycPSfuH80TRqMe xPtWyX3A7WHwxxP5IOm65tzOZWtnzBcIhTMoX1EVbQo1FtSogc2zthw4ap1O47SDmlTR 334XeFN+jLfOH9YoP4hgTLayU7wVYRWbxDOqwwpWFfKk5yy+0WeyhGNXBw433iIMmE0C A5xYG1uY1sG1ZcSdgdHJS2V23x8abXesW51ebWNhu06bO1Bq/lNVMMDE3wDc2FCiR8qp PHFQ== 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=xA3xAo7jyFFTMAx8OZ0C35llgz82vC0GqmJcW4Cw9ZU=; b=lJUwfqPEEVFW2muIoK34+GLLPvnayfWOy7X3kniEQOsOhsbZzyZljgsmwZY7EGrnve DhozQ2XEoaLiwyhbsjg4RAu2b6TL+7tN9tu+A5IJ31LagET1GjTVSnUmKkGUktGvZfvF +QGb0ME4Xq7nPwLnn9UTXmrjhlmZRyKsjerH5wepH7l80NMVIqM9WSFtnwHRFIQ8rftO 0u75Ocr9lJURaOLxW4XtT9jsgszaSCpK3ywGIKKDy3Y9Vavsb8Dp+V/kHMLCpZV4w1SL qfPrWSC3Qxqbstb2XQRxsZgxwEsfv/BalLmwxwvZ5lO+q9z3YiGle4+99UOh+1RY7Ar3 W01w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=m3ZIrCz+; 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 d81-v6si13619031ywc.464.2018.10.21.09.16.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:16: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=m3ZIrCz+; 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 w9LGEt1E154508; Sun, 21 Oct 2018 16:16:45 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=xA3xAo7jyFFTMAx8OZ0C35llgz82vC0GqmJcW4Cw9ZU=; b=m3ZIrCz+sxUcG096jHpXpUkU6oa9kP4XZ7lc/0AZ7o4w2XckMRTX8su7m0CivjX0FTcu xXSYyXtK+rMEgnqRzWl922zJADwA6Xaqbko/ohWxIm1l7U9JNI2WI83UGYcBiwPUVLMo oNXSYV8+3Bu09ywflEF2iFk9tGZzvoVh5exL2sxYCPbJiJlsIb4P1fdVSCobXmlIB/Qa AIGmFxSr8vuidwkdUuJ6yyjjvGKW192SQn1H5BNbpKzlex1ywqmj/+Il3Vbe0HMf7b93 5yniV15Q0It6usMJSV1k0PQm6IVHJmmT0hnyfFiAicCbYCC+I43rSYjtvpyvCWzIdGVL iA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2n7ustu1tk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:45 +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 w9LGGiTw005675 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:44 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGGiPM019165; Sun, 21 Oct 2018 16:16:44 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:16:43 -0700 Subject: [PATCH 14/28] vfs: plumb 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:16:42 -0700 Message-ID: <154013860216.29026.8102541414755320141.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=581 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Reviewed-by: Amir Goldstein --- fs/ioctl.c | 2 +- fs/nfsd/vfs.c | 2 +- fs/overlayfs/copy_up.c | 2 +- fs/overlayfs/file.c | 6 +++--- fs/read_write.c | 13 +++++++++---- include/linux/fs.h | 4 ++-- 6 files changed, 17 insertions(+), 12 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 8750b7235516..5f82fece64a0 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 6c3fec6168e9..0393815c8971 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: @@ -512,8 +512,8 @@ 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, - op); + return ovl_copyfile(file_in, pos_in, file_out, pos_out, len, + remap_flags, op); } const struct file_operations ovl_file_operations = { diff --git a/fs/read_write.c b/fs/read_write.c index 356641afa487..0d1ac1b9bc22 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1848,12 +1848,15 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, EXPORT_SYMBOL(generic_remap_file_range_prep); 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)) @@ -1884,7 +1887,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; @@ -1895,12 +1898,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 c72d8c3c065a..1c5e55d2a67d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1848,10 +1848,10 @@ extern int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, 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 Sun Oct 21 16:16:49 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: 10651121 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 2FBD014E2 for ; Sun, 21 Oct 2018 16:16:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1BD74287BE for ; Sun, 21 Oct 2018 16:16:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10283287C6; Sun, 21 Oct 2018 16:16: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 8C921287BE for ; Sun, 21 Oct 2018 16:16:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 610A46B0273; Sun, 21 Oct 2018 12:16:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5BD526B0274; Sun, 21 Oct 2018 12:16: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 487126B0275; Sun, 21 Oct 2018 12:16:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f200.google.com (mail-yb1-f200.google.com [209.85.219.200]) by kanga.kvack.org (Postfix) with ESMTP id 1BE586B0273 for ; Sun, 21 Oct 2018 12:16:56 -0400 (EDT) Received: by mail-yb1-f200.google.com with SMTP id f8-v6so22946064ybn.22 for ; Sun, 21 Oct 2018 09:16: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=pC8nJW77l6kqdRNb3rj5XcaGF3voO6grLSxCXMDgfF0=; b=oQfydjCrWbE3NY65gHf9s4JZB2Gfl54MBJ0hX43KhSRNeEPrvz+CVsFZ2bgQkCLbY1 tD6nkAZMSmlwIbGJTlF4Q9UepGnBVJH0QfkzTwfrWvGKDZ+gvIkMEK5506aSG03xTH0S N91ojF2puuFP/0oAeU/A+Dpa1xCvSCkUKzM7hBR2rSL1DrUKLAE4MNxyHZh11IFWqrDt V4LEP3tAFZyZjJy7bcEm1b6WBREFME96QBCo4t+5rR6kMB4wmEBmVrylnQhcBJT40UIo HF9UbMOJCi3HdltIUk88ep6wSFgHnNUpCLTUU1i+kHcOLTtAO/VMs/S4lQjSCIQyZmtI ywuw== X-Gm-Message-State: ABuFfogAwLaipacq2etB5FBAx2f6N+0yi86YDxsRcyZCvgTR4bjx2Ljp /v20hRrBn4Bx350rw4R9YcnHnrGKZc1tPGZxwcKZXLS3md02P1uv7XdMkcHewtf6iDqdUraxvWg 5FmlOkLgi3Vw3E9eeOti31pqUBxeT1YSdX1I/k8CNs6tLontFOequO7/+mixEbwqXwg== X-Received: by 2002:a25:e713:: with SMTP id e19-v6mr12660908ybh.449.1540138615873; Sun, 21 Oct 2018 09:16:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV62+9lodqBNRaRrPlOxfFoF4Pw5//P+24QwO3X06X+wHFbCz+zXG9yIO5EgVQIxEpxoJZYBh X-Received: by 2002:a25:e713:: with SMTP id e19-v6mr12660871ybh.449.1540138615155; Sun, 21 Oct 2018 09:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138615; cv=none; d=google.com; s=arc-20160816; b=aeRIA5dvwmmBcQ9EIayMdxJfgc/CkK+iWnkg8Wg8I6/x4lYPG1SU++/bN92h1h4yVb rTaFSQNBLKGFa4ZFeVr+zTj5iJ8dv1fuGNH93ihiIaFYuYU2A+vhnVnGp/G8sXRDpSH0 5B8aYSyYzzlKq0j7KQ4Uxyn7B8P0djM+UVHS523whwgIzP8Ic0F0fk1edXtG/Vo4MEis LHelzySaT2FOXfDUbc3Ck+8MQEqVEOF10x7aXnWo8vyV/1qCJ+K6/5NJUq01lAV6srv+ 3Vcpof/ivB0wHd9UHencm3OGKL2ukwH9VDZjDwH5hNTL5tqMxzVZYYTaLtHa70ZuTkxf hpUw== 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=pC8nJW77l6kqdRNb3rj5XcaGF3voO6grLSxCXMDgfF0=; b=v4yECuDl95/ZjHSJvraTrdXnRfry6h9zOqas7rBIy4W9uLz+K/U1E+NbNlpznME70L Hl+BRIyvkKvOO9pKeAhswHS4a/ACGepoXWViw6Z/HSnEGGKMnpcAWUnUrv44Aj88ri7n CMRLekGb8GkMPTyA990BYN8deoZAclhjdX0y1CdliR/78zrG3htiFPUTK616DG3nBrzu 8BrMS2PixTmEjN7uti2ki1+olLs0roCEF7xbINdIlLH/seWORK3w/UE+dPadrMKFW9oO bURBAnaxNgxeqr9oKJC9K3gO89djSQmqbJCnygACxfiZgzIG7nzZHTYGRi2vweiHbsXg ydWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=N5YLm8oA; 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 h63-v6si13991032ywh.193.2018.10.21.09.16.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:16: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=N5YLm8oA; 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 w9LGF4D4155377; Sun, 21 Oct 2018 16:16:52 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=pC8nJW77l6kqdRNb3rj5XcaGF3voO6grLSxCXMDgfF0=; b=N5YLm8oAdXTZUxPUhI2dgJs4g8oK1tP34saHlI7ZcL6zBFzTUrs9szXJIertH4aNlA8P 2nmvGtFEHHZQ11I8F1VwNccpBMAYITG++vHBT+Gy62K8Y01QNJX4xEF8cAgJVhtp1/g0 OIbMJLlrys3owlVvcUYBJ9EvBGJYb+YsBRcVwJ/y+BgvuCUHCcdHURmiUtO9uuG8Xugn LrMgzitbsHUazyytJjMuoLFgoMMIeyQOAo24WiEPs6b9t16nY4vKhGaQIHIqsTij2S2c lTLZacJgG5vVDU8Yx1RPT5imPriW2ZtFaWPGB0Vk7iFxycFaQ7USfgbqlDMhXyT+C5Kk jg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2n7vapjyrb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:52 +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 w9LGGpBq026699 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:51 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGGo0A019171; Sun, 21 Oct 2018 16:16:51 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:16:50 -0700 Subject: [PATCH 15/28] vfs: plumb 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:16:49 -0700 Message-ID: <154013860893.29026.11185987776641893367.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=522 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Reviewed-by: Amir Goldstein --- 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 0393815c8971..84dd957efa24 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 0d1ac1b9bc22..ea30666013b0 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -2010,10 +2010,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 & ~(REMAP_FILE_DEDUP)); + ret = mnt_want_write_file(dst_file); if (ret) return ret; @@ -2044,7 +2046,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, REMAP_FILE_DEDUP); + dst_pos, len, remap_flags | REMAP_FILE_DEDUP); out_drop_write: mnt_drop_write_file(dst_file); @@ -2112,7 +2114,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 1c5e55d2a67d..544ab5083b48 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1859,7 +1859,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 Sun Oct 21 16:16:55 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: 10651135 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 8170714E2 for ; Sun, 21 Oct 2018 16:17:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EDCB287BE for ; Sun, 21 Oct 2018 16:17:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6327F287C2; Sun, 21 Oct 2018 16:17:05 +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 BA843287BE for ; Sun, 21 Oct 2018 16:17:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 969596B0276; Sun, 21 Oct 2018 12:17:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 91A416B0277; Sun, 21 Oct 2018 12:17:03 -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 7E2136B0278; Sun, 21 Oct 2018 12:17:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f71.google.com (mail-yw1-f71.google.com [209.85.161.71]) by kanga.kvack.org (Postfix) with ESMTP id 51A6F6B0276 for ; Sun, 21 Oct 2018 12:17:03 -0400 (EDT) Received: by mail-yw1-f71.google.com with SMTP id h186-v6so2052760ywd.18 for ; Sun, 21 Oct 2018 09:17:03 -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=Tr6EshQsxOzbBBn5mCvIhaKvT953YPy/0dHgMvFh9q4=; b=ekfOX6GA0hNS1nBAyQI+Yf9kW4bY7yoPUohRun4Hw/Bz3uRL16kw3u/Q6Tmxq2A0zk fkDnS7WnvwLQ4cJaXljHlH88y3o4/K/OSqFkjzRyTwIeiuK4OtG50PELYFJ6YPHzVtdl rLA6QgnkyVwRlsl/W0NnHj/3dIssPK7rxgG7Ed4E3n5I/l5ehup5E+WEnSsYy8FiC0fi iLqi8P1fGQgC2GFQTRRwi67rpMxDxDOp4vNDMQVlyPMXQ47CWlGOUNy7d3L+F9JsaI1Q EE81IN8Iwz7/+dF5/BdqPs4zOT866MUqUKuwdTi+GfWYbSExgkaDM6H172JxJcjMSjCc M3Cg== X-Gm-Message-State: AGRZ1gJDxU4ztk8jJvlmw/Ti+GR4nj5Xtzl27Z5kKdfZnP82Iuf8QRTO jQ73pldTj5Xav+DKdiYqJC+/Xp0RPgdogGrhTMXE9MaLoFXJywQhtcQoiU0vOR8SPS4X+j7D/mk J9qZKeAP29NeejYLTWiLV26YHtU8T8cpzIc6HXmu7HyfdVRFL+di0L7tmtTW+5cCH0Q== X-Received: by 2002:a25:9c87:: with SMTP id y7-v6mr4312857ybo.13.1540138623060; Sun, 21 Oct 2018 09:17:03 -0700 (PDT) X-Google-Smtp-Source: AJdET5fHPbl9ArHmSQmSb/nQIVSdFqmLtzipzoj8LlACQKVgddnRBadX15q9+i/SrBDNUEPyGwbD X-Received: by 2002:a25:9c87:: with SMTP id y7-v6mr4312808ybo.13.1540138622279; Sun, 21 Oct 2018 09:17:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138622; cv=none; d=google.com; s=arc-20160816; b=nm8wxUfDRTm9uKFrnyfUfu/fU5lRoDsEJWiSOrj/GlzVRfNJ72m11XpHz2SiPfJ/nN ej8+6WxMR2megzC/D3V0WctHbJNbW+nIMn8FxR9gBuiJGb3eTFgpFyqBKmD1Xn16a+0p DSokzyg4u3qwT+80fxdJ95AllbgScTR3sFmAgPpMNM/mebj1yBbJROxA11liJO0DebMq qtlsVBe750Gc2ArbEdap/Rt7jjYW0itZjjeh+VzIqAefVTyFE3AadGzhHG7RX4xJrVjy 3Ml4NABJ8SLoPPQRz5MkUpU9thsL2du/slPLm8QVa0ENbYxhjQQ7eOffAuX34MZiH32A vk0w== 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=Tr6EshQsxOzbBBn5mCvIhaKvT953YPy/0dHgMvFh9q4=; b=R+or0ulUlhLOn3UQ37XzeZw9Dbh1cGdljRr9wz56Xx7iKxsSvUlSqsG7GMUZPDA7cd e00CwLpuB4zd0k4SeUiFryfWSHEKwOsBFHPm29nFyk9DvzhWN2DGc0o23R+XpMVx0FiW tZLy/c3aHTDVHbOLNCde9cdZRsXj3RTpv1WXNMkiPCXJ08CbSt/eD+bIFb+lqGt/paBY H5CZGZhqrB004429nQCCDr7wzIhfKOdR//OGmteG77G6HKMNcfcfkpU5jnJQPUFNgF20 JBj2pLjG48TJYSvPGOLy+Xech6s73Lb4uHu9cNwxDJvfmg53jWeacDHcm1hmt7DZJqRI /ndA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Q98qxZ3n; 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 h129-v6si14332544ywb.428.2018.10.21.09.17.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:02 -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=Q98qxZ3n; 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 w9LGE276154815; Sun, 21 Oct 2018 16:17:00 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=Tr6EshQsxOzbBBn5mCvIhaKvT953YPy/0dHgMvFh9q4=; b=Q98qxZ3neieJv3J3cs2XPbWOvcXhLJKXeNpgZCBxOx22q770V7OVZ54D45h6X2ZPDwbz WgvZ/30zQurCheMHXr8w0EfyLjtO/oAl/9ZfcVPzus+aMn2H4qvI3vJXbjW+4nbTAC1v QqXgW0E6Fo4sMTzDZZ4UvvNpVMBm7bBcHGmAzap9WAnUaQO+STEEVvcfXD+vXrmzMKAS aq0GSTpRm7tLbYqIH2kGU+cbSRdZdzX26jvtWFMTGJzo7FEFMP5JkwIZh4C1vOwXtGyX yveqz7oQ/QE6j08TtBLTffc/ZnlSENeaL9xS06Llth1zq5u7HsxfhsxbOTPcziAaf6Ck Sw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2n7vapjyrk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:00 +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 w9LGGwYJ005994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:16:58 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGGvO0021301; Sun, 21 Oct 2018 16:16:57 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:16:57 -0700 Subject: [PATCH 16/28] 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:16:55 -0700 Message-ID: <154013861584.29026.5158930020192209258.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=759 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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.). We also enable CAN_SHORTEN for fideduperange to maintain existing userspace-visible behavior where xfs/btrfs shorten the dedupe range to avoid stale post-eof data exposure. Signed-off-by: Darrick J. Wong Reviewed-by: Amir Goldstein --- Documentation/filesystems/vfs.txt | 4 +++- fs/read_write.c | 28 ++++++++++++++++++++-------- include/linux/fs.h | 5 +++-- mm/filemap.c | 11 +++++++---- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index 1bd2919deaca..5f71a252e2e0 100644 --- a/Documentation/filesystems/vfs.txt +++ b/Documentation/filesystems/vfs.txt @@ -970,7 +970,9 @@ otherwise noted. negative error code if errors occurred before any bytes were remapped. The remap_flags parameter accepts REMAP_FILE_* flags. If REMAP_FILE_DEDUP is set then the implementation must only remap if the - requested file ranges have identical contents. + requested file ranges have identical contents. If REMAP_CAN_SHORTEN is + set, the caller is ok with the implementation shortening the request + length to satisfy alignment or EOF requirements (or any other reason). fadvise: possibly called by the fadvise64() system call. diff --git a/fs/read_write.c b/fs/read_write.c index ea30666013b0..c0bcc1a20650 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), + REMAP_FILE_CAN_SHORTEN); if (cloned > 0) { ret = cloned; goto done; @@ -1721,6 +1722,8 @@ static int remap_verify_area(struct file *file, loff_t pos, loff_t len, * can't meaningfully compare post-EOF contents. * * For clone we only link a partial EOF block above the destination file's EOF. + * + * Shorten the request if possible. */ static int generic_remap_check_len(struct inode *inode_in, struct inode *inode_out, @@ -1729,16 +1732,24 @@ static int generic_remap_check_len(struct inode *inode_in, unsigned int remap_flags) { u64 blkmask = i_blocksize(inode_in) - 1; + loff_t new_len = *len; if ((*len & blkmask) == 0) return 0; - if (remap_flags & REMAP_FILE_DEDUP) - *len &= ~blkmask; - else if (pos_out + *len < i_size_read(inode_out)) - return -EINVAL; + if ((remap_flags & REMAP_FILE_DEDUP) || + pos_out + *len < i_size_read(inode_out)) + new_len &= ~blkmask; - return 0; + if (new_len == *len) + return 0; + + if (remap_flags & REMAP_FILE_CAN_SHORTEN) { + *len = new_len; + return 0; + } + + return (remap_flags & REMAP_FILE_DEDUP) ? -EBADE : -EINVAL; } /* @@ -2014,7 +2025,8 @@ loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, { loff_t ret; - WARN_ON_ONCE(remap_flags & ~(REMAP_FILE_DEDUP)); + WARN_ON_ONCE(remap_flags & ~(REMAP_FILE_DEDUP | + REMAP_FILE_CAN_SHORTEN)); ret = mnt_want_write_file(dst_file); if (ret) @@ -2115,7 +2127,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_FILE_CAN_SHORTEN); 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 544ab5083b48..34c22d695011 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1727,8 +1727,10 @@ struct block_device_operations; * See Documentation/filesystems/vfs.txt for more details about this call. * * REMAP_FILE_DEDUP: only remap if contents identical (i.e. deduplicate) + * REMAP_FILE_CAN_SHORTEN: caller can handle a shortened request */ #define REMAP_FILE_DEDUP (1 << 0) +#define REMAP_FILE_CAN_SHORTEN (1 << 1) /* * These flags signal that the caller is ok with altering various aspects of @@ -1736,9 +1738,8 @@ struct block_device_operations; * implementation; the vfs remap helper functions can take advantage of them. * Flags in this category exist to preserve the quirky behavior of the hoisted * btrfs clone/dedupe ioctls. - * There are no flags yet, but subsequent commits will add some. */ -#define REMAP_FILE_ADVISORY (0) +#define REMAP_FILE_ADVISORY (REMAP_FILE_CAN_SHORTEN) struct iov_iter; diff --git a/mm/filemap.c b/mm/filemap.c index e9091d731f84..1775d4ad3317 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3045,8 +3045,7 @@ int generic_remap_checks(struct file *file_in, loff_t pos_in, bcount = ALIGN(size_in, bs) - pos_in; } else { if (!IS_ALIGNED(count, bs)) - return -EINVAL; - + count = ALIGN_DOWN(count, bs); bcount = count; } @@ -3056,10 +3055,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 & REMAP_FILE_CAN_SHORTEN)) return -EINVAL; + *req_count = count; return 0; } From patchwork Sun Oct 21 16:17:02 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: 10651151 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 4068714E2 for ; Sun, 21 Oct 2018 16:17:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2DA78287BE for ; Sun, 21 Oct 2018 16:17:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 22085287C6; Sun, 21 Oct 2018 16:17:16 +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 49BFD287C2 for ; Sun, 21 Oct 2018 16:17:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F01F6B027B; Sun, 21 Oct 2018 12:17:14 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1C6206B027C; Sun, 21 Oct 2018 12:17:14 -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 08D586B027D; Sun, 21 Oct 2018 12:17:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by kanga.kvack.org (Postfix) with ESMTP id D0BBD6B027B for ; Sun, 21 Oct 2018 12:17:13 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id s7-v6so1210203ybp.15 for ; Sun, 21 Oct 2018 09:17:13 -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=GRemaJYZtZ/0EvXQ39fgMVri7M34w7UuM2Qe8+dF1M8=; b=RKlGRdAX1tJ2wZ8flDMpUNZKX08/QJPjAB9JPjpfIA0G2G4PtT+TH5y5/1CMiWkvz5 YrFjjMPWZKzi+AGV402im9bWqqSUucDB+oKBjYuUIplgbLNSfYdUM09vWVIXI5663ime euTGJqCe+2tZlXDb7o12oiK4dw2umWR1FnWMtZ669xoMm7UsYtsW0DcPQhdfy1xGV3FD vSpq6eMGKG4ztbO4kxbJ6kFiueOyu22fOkO1dW+++aXjx130aYoiLf4jrXwMqrhxaUB3 UvE3523qOJvFyhUg8cmkyeN0xXMmpq2IrbQj6sV++Dekp4Cg3ygwFMYxswLBuYuH9WF7 fpLA== X-Gm-Message-State: ABuFfojMAMYcbN9vo7+93oKCm7YzKjY/eesRTX3S7zoyOUwzeZtutvW0 oWCznDRjUFBXR5NrbzmgdsOq9c+CfGZDIzntEFr3hcga7flaR23qYInU5dK/CU6ZP+dMIppy4FH AoDAFo2VRCgq6L/wsTER0h/zsiPzYt7xgTsKjrkZa5bdQO4p/lHsqRR1V3q24Sb/j2w== X-Received: by 2002:a81:d88:: with SMTP id 130-v6mr29439210ywn.184.1540138633568; Sun, 21 Oct 2018 09:17:13 -0700 (PDT) X-Google-Smtp-Source: ACcGV62Xwap0CiT30BBd9EJy8IRqkhbCbzYUrkdA77Zc5DgZX4CV4Lxm+d82Lr1VXQ5MsOHlk0gI X-Received: by 2002:a81:d88:: with SMTP id 130-v6mr29439167ywn.184.1540138632818; Sun, 21 Oct 2018 09:17:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138632; cv=none; d=google.com; s=arc-20160816; b=vzXmb56Z8qZCPP36I/dr51X7pahp60l52Q0B/35LQW0OfI2ORk1AwLGGf4NReZjTzd TZ6U9eszw6S8lHmkCjgo0KqjkspqK+9BTEb7QNK2aq03HpNIdiec7LaPwkUa4wXkGdsT iwPPw3OZDWDntNxrpU0L1zmWF17PAg6768cDEYylfstpoTuIx+WNu99fa4T5+OqrP2jO Hkgof2jqzf+6hGpTxN4pvYoqwJYJkQBOTAK8hx1h0q4AYoXAjF8SmnXUqacQU5z3UbBy +JDZ0iI77+hOVwNx+pwYSijhNIPNk6C688MaDDTtF2piGVnoXlnNyGlkyGtQ6bmdEMZP ce5A== 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=GRemaJYZtZ/0EvXQ39fgMVri7M34w7UuM2Qe8+dF1M8=; b=rtz+LwO7JKsCcabPzSZLInDlW+dr3MjKlA7JkmLo5wueM0F5cuBwY5nGfoHCxmU4hQ VGS58C0T1Z5RYe8ASt5LeAbuhUSz/4LXhnzudeRonJlt6pB1Dd2Mq8QLzHzn6u8SJeWh J8dbL5SmHNNMx0OMPD4m9G6HDQu0We16NE64BiinQnmeuVAygEvRzKtLthZgapybZgJZ KO1nQqlC+BzVj4apMpHSfCA4YoaAqjvCiznr3YzS+WloqRosxgIGUgwCVu8hh5IvI80M ESHGX0AQ7v2gucdctRQYGEJi0ydudODS1UNoSInFNOjV9AQVp32HxEAJAbi9ws45c2Ta sbbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=tqZ0KXwx; 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 p15-v6si13534960ybc.133.2018.10.21.09.17.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:12 -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=tqZ0KXwx; 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 w9LGEeZE155152; Sun, 21 Oct 2018 16:17:11 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=GRemaJYZtZ/0EvXQ39fgMVri7M34w7UuM2Qe8+dF1M8=; b=tqZ0KXwxlZOcyc4jGQ0h7zHr0h0LbZtr7aWpdq3jSJYFwqj0Pw2AhG2EQKCu082kqXIm KRTZ6rw6wjT9soSRP2n1yoNeQsY3BlmnjmMazk09IJif1sJ+arRJVcraTzq9TK2YN3Vn Zvh6zyVClv9cgGHfzTDYPSwraQxMxKcvQ2fEX7FTXNLTCC3fQgb9rRR97BocuKCEfQTj 5gBEEBqH0e91xkhw68XmX/CgYSUCj0k247kXQURXGGylEbkpeCKesqK8cYQ7dPjafRQM AyVRl7xqhqcSCE/ILyDpaELzSWCEvUh2xvn0FgkefVgvtUXSxYe/rmgjcuNsnjlQUS1S ZA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2n7vapjyrq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:11 +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 w9LGH58p013336 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:05 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGH4r2019187; Sun, 21 Oct 2018 16:17:04 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:04 -0700 Subject: [PATCH 17/28] 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, Amir Goldstein , linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:17:02 -0700 Message-ID: <154013862267.29026.2582062504282772214.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=636 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Reviewed-by: Amir Goldstein Reviewed-by: Christoph Hellwig --- fs/read_write.c | 187 +++++++++++++++++++++++++--------------------------- include/linux/fs.h | 3 - 2 files changed, 91 insertions(+), 99 deletions(-) diff --git a/fs/read_write.c b/fs/read_write.c index c0bcc1a20650..e4d295d0d236 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1752,6 +1752,97 @@ static int generic_remap_check_len(struct inode *inode_in, return (remap_flags & REMAP_FILE_DEDUP) ? -EBADE : -EINVAL; } +/* + * 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 page *page; + + page = read_mapping_page(inode->i_mapping, offset >> PAGE_SHIFT, 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 @@ -1923,102 +2014,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 34c22d695011..346036a84f18 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1853,9 +1853,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 Sun Oct 21 16:17:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10651153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 478DF13A9 for ; Sun, 21 Oct 2018 16:17:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33C83287BE for ; Sun, 21 Oct 2018 16:17:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2844F287C2; Sun, 21 Oct 2018 16:17:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0867287BE for ; Sun, 21 Oct 2018 16:17:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EE97B6B027C; Sun, 21 Oct 2018 12:17:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EC3776B027E; Sun, 21 Oct 2018 12:17:15 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D140C6B027F; Sun, 21 Oct 2018 12:17:15 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f72.google.com (mail-yw1-f72.google.com [209.85.161.72]) by kanga.kvack.org (Postfix) with ESMTP id A45496B027C for ; Sun, 21 Oct 2018 12:17:15 -0400 (EDT) Received: by mail-yw1-f72.google.com with SMTP id h38-v6so25645371ywk.20 for ; Sun, 21 Oct 2018 09:17:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=A4sDFXPvAlL63/6+A19QlnFZhnOxuaNlawZcJx8i2yQ=; b=PtbbxwTjXdScxvEIP7J5Bsu/YS8R4QVzqlODOI7VeGvCBGzEEwyPbBvQjBUbcwxUrb 72PLsH/XQUlYkJMfYmJQICRQAJuA8VVMADOBn0HHEEix+yff7TtYpWQn7lkn7lLfEyzm 55UuYmTDM+jt0n2fQ74uj4jAvDyUjCPCcm25/W+gVA+0tnDl+qZX3nClmHvD7ddW8BpT 8e4DO4ldOlwdDV8jtS/prmbuHZbJVMBuNlUyCmLRpkcly6IKr1gUxUjjKSrEGoK8F2+D tQQ52RTydxnSIti2LHzC+irpRLjPe2n5WVh/YIJFqFtF7Ga6hEIfYxtqEfW00XEPxPYq MKQg== X-Gm-Message-State: ABuFfog/BCcB0FJkQ/aVPbD34yTW/NXOE7LwN6BCDkaqhSvXRpA5cXq8 CBiloVIs+GXrCAFvhAp4tCOqNpKoxnpsBT8QnqG5sOs8NUILOX4d64Wciux4FtrjRdWzGZkqgp2 9O5wf5s7M+0gCPSDT+nOhPlEgyQjuWAcWVrBk9mg3B7jUGzX8FGk18Q8l0zf0Wvui+w== X-Received: by 2002:a25:2c44:: with SMTP id s65-v6mr8190172ybs.472.1540138635424; Sun, 21 Oct 2018 09:17:15 -0700 (PDT) X-Google-Smtp-Source: ACcGV62fgfJstmHSOegBgKILe5op9RSCJRwrVgNwurSQyJ/8w/WwhyCvphW6ySxnhxT5POlvpyPg X-Received: by 2002:a25:2c44:: with SMTP id s65-v6mr8190113ybs.472.1540138634317; Sun, 21 Oct 2018 09:17:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138634; cv=none; d=google.com; s=arc-20160816; b=Q03DiAj+vOiTeiDxpJnv+C5yjOE4Uy5yDgg32q4TsRkvPugTxwpBKL/N+uhoXSZBiy YXt0GZxD4UkHnUDGpEg9Hrl0xLZEoO+fWrK81zdoUCv8Lybb9ScVZWRr7T2FQunhXeNG hoDspVgs33KSlUK/B+GhBN2Fh/TeIPdB+DCSSW68w4BVXxLs6rDjJqHpn9624yHfRN1U YtsaJVjVodT84XUe8eUxNUo2EGqmRk9b4U3/NeoZHhNN0SIi3VqLR97dW71VTHXvU+4k oZvsOx+D4Ot+66if/VvNeXkDW0ibNCZjR6hiFPglcvmRjJS/ZG5k3PXD49j11EuCvS2K valw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=A4sDFXPvAlL63/6+A19QlnFZhnOxuaNlawZcJx8i2yQ=; b=0YYp3fwb1ceEjQdhWOwh7ZprZzb646QF/Ye2jUsGRHqbisCzl87fXXfvugfjmQJ6S+ 4eqAHDoJ+VhPga06ZDA4Me+Xan14melhWnqclXyofLfYFwmWepHpjwAXYWvHjbD68IIm qG5SxwvwwimlWxjon09gjzWYL5h8HkXq5THfnOpRxXnFBsbw+7QA/tooQKmsLgFyrQG+ V1JeUvOPYWdmdOkpl33FCxXB2vR2o94pVaaXouSrNv4ncm0eZlcZgaRhKrwTNtBgV6Fd xgBui/35/dp0IiDbqDv4lpXcuTxua/IU+Ul4p2o6SEWXoYCwn3KRyg4dXge2mEeIvgOM 7GMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Ci372zLd; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2120.oracle.com (userp2120.oracle.com. [156.151.31.85]) by mx.google.com with ESMTPS id q5-v6si14736076ywj.32.2018.10.21.09.17.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:14 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Ci372zLd; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9LGDwSl106540; Sun, 21 Oct 2018 16:17:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=A4sDFXPvAlL63/6+A19QlnFZhnOxuaNlawZcJx8i2yQ=; b=Ci372zLd/zDuX20WsEMatrVemjJBmWvfmWAVw3fGsomqTRphZkyBH4vr5R1srJIGkyYT Do9VZ15gmExU4LQaIZKAuJraOAD52rtt4ZrTRemLeOUE4Z3JKweSsbadLWnFw5bDkv+X m1bWKEoXPjnkrnEDRo8xA4DRPrXTouuAsOGX/cfsjGLBrA2JBw1EHTMKTecdO3KdXix9 ZX7kcxSbCpF1f+jmGfK+SwjJTwyjfAwmpf6jfIO6xt+46YX+7zco6IULR7Be2y25dK7S I/G+x/xF1lVJ/iJMO4bpStU8d05PoyNlnpRF/+gwJP1Er4HsnYt0nttN1Jb/jMOf6JAS oA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2n7w0qaxkm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:13 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGHC4l010087 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:12 GMT Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGHBuj019294; Sun, 21 Oct 2018 16:17:11 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:11 -0700 Subject: [PATCH 18/28] vfs: clean up generic_remap_file_range_prep return value From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: sandeen@redhat.com, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:17:09 -0700 Message-ID: <154013862952.29026.12371941728048413604.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=872 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Since the remap prep function can update the length of the remap request, we can change this function to return the usual return status instead of the odd behavior it has now. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/ocfs2/refcounttree.c | 2 +- fs/read_write.c | 6 +++--- fs/xfs/xfs_reflink.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 6a42c04ac0ab..46bbd315c39f 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4852,7 +4852,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, &len, remap_flags); - if (ret <= 0) + if (ret < 0 || len == 0) goto out_unlock; /* Lock out changes to the allocation maps and remap. */ diff --git a/fs/read_write.c b/fs/read_write.c index e4d295d0d236..6b40a43edf18 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1848,8 +1848,8 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, * sense, and then flush all dirty data. Caller must ensure that the * inodes have been locked against any other modifications. * - * Returns: 0 for "nothing to clone", 1 for "something to clone", or - * the usual negative error code. + * If there's an error, then the usual negative error code is returned. + * Otherwise returns 0 with *len set to the request length. */ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, @@ -1945,7 +1945,7 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, return ret; } - return 1; + return 0; } EXPORT_SYMBOL(generic_remap_file_range_prep); diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 3dbe5fb7e9c0..9b1ea42c81d1 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1329,7 +1329,7 @@ xfs_reflink_remap_prep( ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, len, remap_flags); - if (ret <= 0) + if (ret < 0 || *len == 0) goto out_unlock; /* @@ -1409,7 +1409,7 @@ xfs_reflink_remap_range( /* Prepare and then clone file data. */ ret = xfs_reflink_remap_prep(file_in, pos_in, file_out, pos_out, &len, remap_flags); - if (ret <= 0) + if (ret < 0 || len == 0) return ret; trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); From patchwork Sun Oct 21 16:17:16 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: 10651157 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 AFE2C13A9 for ; Sun, 21 Oct 2018 16:17:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EB07287BE for ; Sun, 21 Oct 2018 16:17:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 930BB287C0; Sun, 21 Oct 2018 16:17:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 338F8287CB for ; Sun, 21 Oct 2018 16:17:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08E486B027E; Sun, 21 Oct 2018 12:17:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 03F626B0280; Sun, 21 Oct 2018 12:17:21 -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 E6F3E6B0281; Sun, 21 Oct 2018 12:17:21 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by kanga.kvack.org (Postfix) with ESMTP id B7D646B027E for ; Sun, 21 Oct 2018 12:17:21 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id p18-v6so23371308ybe.0 for ; Sun, 21 Oct 2018 09:17:21 -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=PyBPAavOIq55658ZH1Sj+FtMrq4d/FyfXvZlBhg5/0I=; b=n/fgOyYNjNtGZW7ntX6Q+RH6z9u3VePu/mzDnc/8aQVCxztJNQzSJ+k/e8JSEstz2i 77WTcvl9ZqrMPb2t/s8rwRu38sxnK9bZ2CHgfEeBiNCrRcKlxhAHhL3Xgw0AkANzzA8s TuhtcnX4BULjq/CQbV23lVsoF6vA7cu/0mnntstzqjYArpMUTbco9VqBJ2iGUCqVlXEw WfEW9nKkdlqLdlBvBGW9qwJG+rSog7phDzUcWELsW27DlTMVxTZZje8KkZ/N0rrcaCWk nRhuwg3UCrsPMU+bWs65Mf62EexzDHs8Hvu9hUAtWyQi01tk4J252aun5yNUvxwTXv1o iWxw== X-Gm-Message-State: ABuFfoiRDSmtJLtkIue2OBxcMUKndnDn09T2MABYMwD/48emzS50TrzK /QHBni0E6fLtjaaDjZyq47sEUy47SaqfW3Qj01QSQ7NKZVLvoryTPHl1rtJOALRuiq5Ei1Ed6OY tdGJRt/LM/gOfEvEGmcG+f0bqSolyEfN1SJhCRh6UJXz6T+yy6KyylghwLoWB3iYQGw== X-Received: by 2002:a25:a349:: with SMTP id d67-v6mr28406483ybi.479.1540138641518; Sun, 21 Oct 2018 09:17:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV60VJ6hKH6siopggp75dW7GY6tqw5ZOoY4NEVl6NGnetCkL7qTsX3/XvAPOm5icDbPCNQ5P/ X-Received: by 2002:a25:a349:: with SMTP id d67-v6mr28406457ybi.479.1540138640985; Sun, 21 Oct 2018 09:17:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138640; cv=none; d=google.com; s=arc-20160816; b=gmQEdqbgLPR/p5jpcpblelLZmEhwVrumZUQuhdF5Fxo+Aaz7nCaXGmKv0Jcu+Y40JD 7EXuh3dF4Y05UAv1pSNrk8CP+GGFNRQMJVasvsCU4STe0a1+YeLunpPgmYF6kJNzsh2N YdvN58/dXUIKNjpKreCV+wgLX+bLb2qVaOs+KlX/x3JQzRk4kRxlId12aiC5mhB93KNN PVBs0IXsTiNH0lcMHLcPTNOte/oBYZ3TTyM/oU+bu4NOcuSZENe8Y82uzF110bz7cefJ u4/gYmcf8/dkdtbaaEVbzUXUY/4nutwHsCZB3ZsiIKECXU2/a2Gj3VWUiqgBldn1+tMa ThYA== 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=PyBPAavOIq55658ZH1Sj+FtMrq4d/FyfXvZlBhg5/0I=; b=sD/CM77M4aPp/PkZ2h19/qWSVMWqt+zgkwP9zZy+j12yF8CRSCOkVa0AUjKv2y8HtV UCoLsXQbBPtnn6lQcg8FPPsfivNJB03Vj2qVe1hQpxPr2U+YwCnvABzL+0PfOCWjbiIE NdUPwfczKzM3d2tUKPkDb/s89BiRPNzkh1VJUC2ryGgwewl8KtJQ6Sg3ycVd41AcUF/O RPlztyZqHI/c+6W8OBeB+SMCZ96NLGLGSD93rOXr1pxleRXB3vXODyk9wSdOASO4cfS9 dAzR3UdEyre0OtUgqbSy7IHBc50xbA3mw8M1g7giqmx1xHsPu/gxOFecYTkS2NXS6G41 x9mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=YGb4AKbE; 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 126-v6si13727092yby.29.2018.10.21.09.17.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:20 -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=YGb4AKbE; 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 w9LGEaSZ154207; Sun, 21 Oct 2018 16:17:20 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=PyBPAavOIq55658ZH1Sj+FtMrq4d/FyfXvZlBhg5/0I=; b=YGb4AKbENQy21KfMqY1cHXftzd2QbfPHoYtmOfvP3KbPY3cX4AqiUD1EedUX4l/2tFSO IGZF9AGH7ogIdORPIrLuuJCDkxMKOGiOHqLBTojkcKLBlSl1bTdGot0wq06iTp4FpZwn /cLrXMCGn3bVD61b3KYsA0Owr1UNEKjohuIuG19lSsZp+Zu5QFXTprXx3CfeXUokDSs4 CDozA7CBTc+0aBUTd19Iv5V0a1AAJ2TBov3wEunJvglCGWVXZWewhkJV52lsefqVZ1Fh u38v/XqYf1+sCMrZswWZ3ew9pqbmVl0dDLC6bxu6XV/jtpwU3Odw1ZP/AgUsqwNRZdOG SQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n7ustu1ur-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:20 +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 w9LGHI8t013658 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:19 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGHIW1019313; Sun, 21 Oct 2018 16:17:18 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:17 -0700 Subject: [PATCH 19/28] 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: Sun, 21 Oct 2018 09:17:16 -0700 Message-ID: <154013863631.29026.17663976179167255577.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=802 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 46bbd315c39f..2a5c96bc9677 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4861,14 +4861,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 Sun Oct 21 16:17:23 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: 10651171 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 9841713A9 for ; Sun, 21 Oct 2018 16:17:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85F80287C0 for ; Sun, 21 Oct 2018 16:17:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AA7B287C6; Sun, 21 Oct 2018 16:17:30 +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 1F4A2287C0 for ; Sun, 21 Oct 2018 16:17:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 019386B026B; Sun, 21 Oct 2018 12:17:29 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F0B786B0280; Sun, 21 Oct 2018 12:17:28 -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 DFAAD6B0282; Sun, 21 Oct 2018 12:17:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) by kanga.kvack.org (Postfix) with ESMTP id B34006B026B for ; Sun, 21 Oct 2018 12:17:28 -0400 (EDT) Received: by mail-yb1-f199.google.com with SMTP id t15-v6so23324583ybl.20 for ; Sun, 21 Oct 2018 09:17:28 -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=HOYBOBGpflqwSaMT4PmSGK8TNSkXTGNQVQO8YcwuUKs=; b=AR4Nja+OltyQOCo75E00RidsdeyoeWH+oP/HeEUungw/CwGvH4dzQuNYCSBYASdlq4 h3lghUwGLOzajPh7Xh78E/xVZmeBcqeqanDdYHigD3pfuKxAfQ5jqzLIdvZb4r2y35ER O9/F3+UB3ZoyTs/aWhKun4dnK2/lL9CgpKvpjVzgFHP4o/N9CqObRC2vXrDGC8XVzEql YcM6jkOi39j19ZqmEn+YbHBBpnZ8tlBG4MFeXG9SHaBGh0sfTbaDfFPHX0O5CJ64MNqx cBXJPtbP4rDUM9Gr3IS4+zRbVTibb1L1ETEvR0p/1mvAPt8llXUtCLQlIi1WOi46JJK8 aMPw== X-Gm-Message-State: ABuFfoj1KoDwY137JVRIklRwJPniFIfPXOlcrOJiNik8n6Wh9kBz2IJg SSpgdGt1ycnEPKQCKRpwkA/Ces0BqpZ1H3I9E3wxs30ubJrqCQNGg8gRmI5ztB4vT8orNfqyyXu i6FuNtskrNkKIipgNeoBTl5SyHSamvdArAK2GXubNL6dNz4KzpRoroNRxVSVDHE8qvg== X-Received: by 2002:a81:8496:: with SMTP id u144-v6mr7316881ywf.266.1540138648472; Sun, 21 Oct 2018 09:17:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV60WHtL4XW1LibIp48ri8uiuxxp/5rT8zTLgAiKexQEdt6xGtOa5U2zLEXwXA8I1kxd5j0ao X-Received: by 2002:a81:8496:: with SMTP id u144-v6mr7316845ywf.266.1540138647842; Sun, 21 Oct 2018 09:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138647; cv=none; d=google.com; s=arc-20160816; b=ZydKfQE55yDMkbM7cWX2oEtvRnAfozEUw0PUleSSIZ4c5R9y3xxFHdxRW7OnruyYvK AXbbTOrIlqjKMC3NDsbmYCjkWEG+AuScMZ3RAoCd3DRL2G3TRHJghMZTqJOlTVuMBMcG tytzy3sMr/OkPPhsOwpxP7KU8YgX9d7fbuABBpLhzQ3OgpUlYm/PuCu9WSNUOp68S6bb DZtZ9lmx+dISHWP0wsguQbrJoOlLLNLnmjLX0noMyunPPBaIq4mxMIEQ7I30vgMK2zDL gT5/FkfLoU86iMpJuPQWL+E2LXHTqEwFc29NPHJvfNzr9gyP0cHtjzqPy2rNWFyZuwCi cihA== 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=HOYBOBGpflqwSaMT4PmSGK8TNSkXTGNQVQO8YcwuUKs=; b=iWH0TjRj3Q0KSxr0Y83Rf6L98YoIDmIYIdov8I6ylTNb52oJav9RB3c99a4exfqoey /OBPNBt9mQSwxhHet+1wdbJQOTZH/he7kWo91LtBGTdHhJxKjfWXwaZOe8Aus3U6n4j+ A6xYxKdbFl0z0uK3/02VVgL8XCQ8g+qtKmYJ+3yZpl8fRmHanbolFKENREIf+81ZoYk0 sFt15sQK3r31ehML6tTf081oncVfDVuK77/fT0qE9Bvh4v+wTXtOcLSKEDeO9CBWA6R4 oxUUU9g9FnhmS2wWk7VmBzkseVxH42+cUUly2Ct6hIoIQbnRqCJwTigNWF6F3FvmMDlq fgOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=y+bPOH5J; 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 g4-v6si13621803ybk.217.2018.10.21.09.17.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:27 -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=y+bPOH5J; 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 w9LGEAp8154117; Sun, 21 Oct 2018 16:17:26 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=HOYBOBGpflqwSaMT4PmSGK8TNSkXTGNQVQO8YcwuUKs=; b=y+bPOH5Jlh5LNEGhbJmYsOyxQDiK7M67f/w0weuAQdVJ0kvnOMIZTP2oEq3dnAVPXfRm +FEgR/y79TeF0ffGvpNCc+MCWpryKgx/PRBoIZgkp+uaUHSUhhG6mc4bUxP0e8qjcafZ gPBJBewGd3fDmHyIgCwD0ij+DI7me5/JMZrV1pyZuNjc3e1JJsDtPy0xedsE/1jYRBYQ 42kX0aHiSLDsHGUoHAQvwcoBn+JiwVraxzdzFZ2YpCP9weRgkj1IitZ9OGDoQSEt2IuT JaH/hZ1BSs6A65Kl3tTXAPykG2psbERykRnxR0eSAmurWIfaVgoGRXJZTS95m7/1g+m7 YQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2n7ustu1uw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:26 +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 w9LGHPaO010274 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:25 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGHOAK019421; Sun, 21 Oct 2018 16:17:25 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:24 -0700 Subject: [PATCH 20/28] 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: Sun, 21 Oct 2018 09:17:23 -0700 Message-ID: <154013864305.29026.1507854884363595736.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 to page boundaries. We already wrote all the dirty data so the larger range should be fine. 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 2a5c96bc9677..7c709229e108 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4862,8 +4862,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 Sun Oct 21 16:17:29 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: 10651185 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 BD03713A9 for ; Sun, 21 Oct 2018 16:17:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A7407287BE for ; Sun, 21 Oct 2018 16:17:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98D09287C2; Sun, 21 Oct 2018 16:17:41 +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 E8D46287BE for ; Sun, 21 Oct 2018 16:17:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E998D6B0280; Sun, 21 Oct 2018 12:17:39 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E47EC6B0283; Sun, 21 Oct 2018 12:17:39 -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 D37DF6B0284; Sun, 21 Oct 2018 12:17:39 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by kanga.kvack.org (Postfix) with ESMTP id A46966B0280 for ; Sun, 21 Oct 2018 12:17:39 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id s17-v6so23240197ybg.21 for ; Sun, 21 Oct 2018 09:17:39 -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=6J/QYq4s6QFaJLMu3nSz4IUXRy/yndbu5A+K+2UxqS4=; b=Rsi8EHm0m+SYeX1waOxoKBvBsgQt0TXl9bCCYQ9DVEhtiU5en/X5EA5pGdGsT4ObAO 7HQXWtglJqg0HqpSRGdChXhTbdGqU8FfOdU60v/Hijt13pqIRLbYOUlZvGSckRL9XvXo 00aDqd3Itcuohor3kjCI3L3Ecu+sA8W9GP1fS5hVzHeBOOeVlYpgS4I/vliaYi3wGLbX cqcwk34fYxqhYxF2OMgL9ZxRRHlbDDHigzgJYCPfDZoClBjrGuvCpHeimONo3Y7Az5im cteWR4dti3++loVP1IWPSV0oSVzZIXKMMmy7sJnJgHIbX4Lf1xtXP9cDOBWJcjNE3Aci 744Q== X-Gm-Message-State: ABuFfohw6CYbtqdalIXVmb7rO3T8nJLvCCLwEeJg7d/HpbJv+zVnC7rz 2EslfMPdKNem7UyDMKM3i1qaf/SLavHRiLvhheYcLN4IBMRsjTP1Qf4SJbTY6BwGsqaZraaLDKl QcTrK525WzBuiVbfb96jJ+9uEwm4uSLBem99lJxb2nmVAxp8w8LrXrEcMxRW/GsWgrg== X-Received: by 2002:a81:54d5:: with SMTP id i204-v6mr744232ywb.87.1540138659404; Sun, 21 Oct 2018 09:17:39 -0700 (PDT) X-Google-Smtp-Source: ACcGV61PNy+K7PPALnikJPUl0I8ftlDok/+mr5wxM5URXb/TFbbGzls7oncE5hR1X7LdgOLye1aO X-Received: by 2002:a81:54d5:: with SMTP id i204-v6mr744178ywb.87.1540138658506; Sun, 21 Oct 2018 09:17:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138658; cv=none; d=google.com; s=arc-20160816; b=gWp8jFLKPqUQuWVCp3p9EXwdtxUICWknXMdAUzwn+S+G2v0ifFBQ0DoPQ+WI5RFUOX muwB0liWPimdktgaN0dfZvf5DoZh5sG7ooAOlCol8W4RWuaqvcdCLQ2LCbyUkDmTgL8j UzuucYjQtVjLkzOBiNwHADXIUQnMMvOsIpzMAOE7EtbXfe+urkOlqo5tsUjE7EjZpqGS Yr1lk1F5p8AZ6o3htzcdqNZzDAl/VIxnSA5GfgLERk5asrrMpbrGqGiFt8rQwM/CuV4t YBPaKlwNatmRvnQsUhUC/zA/AxGrqJNRw8UtMdHxlL8mU9NQj7sh6WJMuwsj/mubR0Ri Wj0Q== 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=6J/QYq4s6QFaJLMu3nSz4IUXRy/yndbu5A+K+2UxqS4=; b=iIdBn43nJpXvZFiQ9XTItPhTV7dl/AcQICUf+NbD9klhlt8ra4PaPejclprttyN9HA lCwsMFZkqDnwEsCc5qnNciC7Afifi63a0Ui+8YeJ0AEHTs4Wq/9PeoC0DI9eQEU2SNQZ ppN05xIPjwN4hpYijUTYBlo22hza/lYWJ64C9lLR+XWdKXIugxITFe4xlDxiB+0zvNEG +qHge9LWlhJ+vWHel7aegL7XdshmH4NOswBlUhEfeda5iR5FQgYj4aFqIF2swcp5h051 QGI09iHHWmW0P5f58/tv7zsQ3Snc7T0kIfW06wgfaDGeUFfNLrcuReQOUL76pNNr40rn e2XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=UG8rI8Ry; 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 a62-v6si14408621ywc.58.2018.10.21.09.17.38 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:38 -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=UG8rI8Ry; 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 w9LGEsJN154505; Sun, 21 Oct 2018 16:17:37 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=6J/QYq4s6QFaJLMu3nSz4IUXRy/yndbu5A+K+2UxqS4=; b=UG8rI8RyRiz8WYAQJrdxCYEs9a6fAE0i6yxW7wxwuSTaBUn6MCwZh8n/lvrIixXkmlrD D5WTNhmlfxbe1Px0/qIJPHnh7UJSLCzDHor4l/eRBhVeLCEBYepcbUfAnTvvR8gx4h8a A0ppfOP1wy2QTOasAg2UjPvYP0XZvWtMt/I+QmuDnjRZFPpbHyzNgIx5rFNg5BW1jKZo bhOaHx0Qo4Cifww+kuRPVHX75DnwGQvJS3qq3MMLb/BQ67tfWjq9OM2rqbFd7YCcuXQ9 jFnL0jriUen0eIZXjA2QJIupSVzSJt/lDIQy/H1VaLcZM2HLZr4X4AS9+Te42lHzqb6K uQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2n7ustu1v4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:37 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGHVFN010467 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:31 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 w9LGHVPj024829; Sun, 21 Oct 2018 16:17:31 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:31 -0700 Subject: [PATCH 21/28] 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: Sun, 21 Oct 2018 09:17:29 -0700 Message-ID: <154013864979.29026.12312692222579341730.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 | 72 +++++++++++++++++++++++++---------------------- fs/ocfs2/refcounttree.h | 12 ++++---- 3 files changed, 46 insertions(+), 45 deletions(-) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index fbaeafe44b5f..8125c5ccf821 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2531,14 +2531,11 @@ 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 remap_flags) { - int ret; - if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) return -EINVAL; - ret = ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, remap_flags); - return ret < 0 ? ret : len; + return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, + len, remap_flags); } const struct inode_operations ocfs2_file_iops = { diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 7c709229e108..c7409578657b 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,8 +4522,9 @@ 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_bytes = 0; loff_t pstart, plen; - u32 p_cluster, num_clusters, slast, spos, tpos; + u32 p_cluster, num_clusters, slast, spos, tpos, remapped_clus = 0; unsigned int ext_flags; int ret = 0; @@ -4605,30 +4606,34 @@ static int ocfs2_reflink_remap_extent(struct inode *s_inode, next_loop: spos += num_clusters; tpos += num_clusters; + remapped_clus += num_clusters; } -out: - return ret; + goto out; out_unlock_refcount: ocfs2_unlock_refcount_tree(osb, ref_tree, 1); brelse(ref_root_bh); - return ret; +out: + remapped_bytes = ocfs2_clusters_to_bytes(t_inode->i_sb, remapped_clus); + remapped_bytes = min_t(loff_t, len, remapped_bytes); + + return remapped_bytes > 0 ? remapped_bytes : 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 +4705,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 +4825,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)) @@ -4866,12 +4872,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; } @@ -4889,10 +4896,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 Sun Oct 21 16:17: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: 10651191 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 94CA013A9 for ; Sun, 21 Oct 2018 16:17:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 821C9287C0 for ; Sun, 21 Oct 2018 16:17:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 756F8287C2; Sun, 21 Oct 2018 16:17:44 +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 A1746287C6 for ; Sun, 21 Oct 2018 16:17:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 179726B0283; Sun, 21 Oct 2018 12:17:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 12C886B0285; Sun, 21 Oct 2018 12:17:42 -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 F38266B0286; Sun, 21 Oct 2018 12:17:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by kanga.kvack.org (Postfix) with ESMTP id B96256B0283 for ; Sun, 21 Oct 2018 12:17:41 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id c8-v6so4937591ybs.2 for ; Sun, 21 Oct 2018 09:17:41 -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=yAZ/1PPkeVRlAU93kCg6O9O78UCd/8KO5hoqJKQC2Ek=; b=G8J2X32EN+Hdh2UfNoVlWmHYTO4iqnjsnsS7Jkf+K/IVdwh/a6A16yF930MWWovnod gPlLppv9XiMPE8wxW+brXoayf+65IOZHOx8WcfXZDrEDJh/Kndw+Cwi+PrOAm9ODgqfr TNW8UOShPeeDBsIZP3JBMjBSnfc0PbPpvxdF6S4zqhjJlh3cWk55cp7HKMEa2HAKBybF ejkptOshX6BDVY4lCYzMJh8FHLnmy0L7ZHiNVWyACcdDrurKkZReWys25F6jsoqujDcK hP3vUaWhU8SoaBlZl+LazxUqhHJUr2pMr0mOArENCDYwXmPPYSsE+tRAKAx8d/vL9Cok I0kw== X-Gm-Message-State: ABuFfohnheM1RIxQuSK4bwPSQMJX5zfrruBPn2COuiKxacbHCq3fcn5b 8SbbLexGjiNSfN/LamXYH+cQ9sJpwThaDhl4GK+rWOU3q5Vuv85PJhGC+QjUInlwpeZtNDkNWgM 9qOfff5Hxl93DyNXbx3lyEsq9s1IGBVV+ht6qilYqACL/VQUbxyPqLM+hIudnk/kIeg== X-Received: by 2002:a81:6d84:: with SMTP id i126-v6mr3895657ywc.215.1540138661507; Sun, 21 Oct 2018 09:17:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV62HxOr2q4FzjZDmQ1ysGqe1GQA7bODSrDYcSi2g4d1Bf+trvw764X4fqs0FB4TuNQFy1tax X-Received: by 2002:a81:6d84:: with SMTP id i126-v6mr3895597ywc.215.1540138660540; Sun, 21 Oct 2018 09:17:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138660; cv=none; d=google.com; s=arc-20160816; b=VH1I31Y9Sz7zxsHqf0XJoNV06mPUChRGnzBcoz6KNeRzQXpGzEXJHb6Dd9p12KIQ0X 5j05WcMKICozI3mWBVB6duuO3Qm9W/Lvjt5ir5xsQd8CukCxyurGH51l5hYlNGTSbLju SGZCPKwzwLtr6Q/qE8mPMweI6m1flBL6ZzXoyv9uohLfNcHed7YLs5AY974iFoh+lk2o 2rqovzgmr7ZdBlqogwQ0cIEpBPXiWujd0djUznRBS8+LVmF0I+7WW6podclK212hbTq1 oG5X8gWKDcOQzMYXWf/2niSUsJ6o4AJpmTeU7EfUxtrd53ssZFRBckXSDBw/3JQMgwsa opRw== 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=yAZ/1PPkeVRlAU93kCg6O9O78UCd/8KO5hoqJKQC2Ek=; b=oab8kl0aE/1q6jUm1jQxXcwVc14wV6U0KZtg2bLnu2mSSHBjcJJe3FPJGoV3teKE2Y /YVaED9KdFewnao6m05fKleeBUGMjDEqvXSozXQj5eQ0/bM4nmJSOvyWR9GJ9mZGE0x1 dM1Ef0DB3/9e0FSo8N4P3IA33tarqNASi1XKoxUO8skMroDO6hCKQVJnlHt9015oNI5P nqhQygj8GGx6+hDeKhg3jK8W9pr5sV/IPfGtMjDP1L2Vp/Lc0frfR78ZxRS/6ohtxAzq VMRpdVCrTS8nl5KvxG6W3kd2vwJECHhbEOyEvPHuugFuEkcTC/pk2k7G2BrehsOUxBmT TMMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=yagSBMWY; 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 n126-v6si6051974ywe.31.2018.10.21.09.17.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:40 -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=yagSBMWY; 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 w9LGEsJO154505; Sun, 21 Oct 2018 16:17:39 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=yAZ/1PPkeVRlAU93kCg6O9O78UCd/8KO5hoqJKQC2Ek=; b=yagSBMWYuvghMIqDYBJYaE6H6wiVG1maa0ILSahktUrXCAVGFzF7z3Nqu++roa+fCV5j hGZ+Ydqx6YJT9iohkXp+Ecco4aEAH5AorPqg3NRg6p9h0GCXba4vOM6BVt3GfQ1bwPuU KEiUfs8aveaXFDwmLUSeaO1av1gTy+rbDAuGXP32Mfw5RgLixtdYzGZAfzsN47y0V1fy vhJVrFSiB/ld1+rj1gxRGdpjSqHrjECvMi064pjwYfBDusiegL7SxJKIOhKEaKh1jP+q aIWcT0cZTk0tF8xPBg4094KAdh7NpdqXWDSiPRRvGU7si0kPT0xn2B8vqJ5aJdQXRo75 UQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n7ustu1v6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:39 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGHckK014091 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:38 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGHc1Z024863; Sun, 21 Oct 2018 16:17:38 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:38 -0700 Subject: [PATCH 22/28] ocfs2: remove ocfs2_reflink_remap_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: Sun, 21 Oct 2018 09:17:36 -0700 Message-ID: <154013865665.29026.16826908431108353571.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Since ocfs2_remap_file_range is a thin shell around ocfs2_remap_remap_range, move everything from the latter into the former. Signed-off-by: Darrick J. Wong --- fs/ocfs2/file.c | 68 +++++++++++++++++++++++++++- fs/ocfs2/refcounttree.c | 113 +++++++---------------------------------------- fs/ocfs2/refcounttree.h | 24 +++++++--- 3 files changed, 102 insertions(+), 103 deletions(-) diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c index 8125c5ccf821..fe570824b991 100644 --- a/fs/ocfs2/file.c +++ b/fs/ocfs2/file.c @@ -2531,11 +2531,75 @@ 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 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 (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) return -EINVAL; + if (!ocfs2_refcount_tree(osb)) + return -EOPNOTSUPP; + if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) + return -EROFS; - return ocfs2_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, remap_flags); + /* Lock both files against IO */ + ret = ocfs2_reflink_inodes_lock(inode_in, &in_bh, inode_out, &out_bh); + if (ret) + return ret; + + /* Check file eligibility and prepare for block sharing. */ + ret = -EINVAL; + if ((OCFS2_I(inode_in)->ip_flags & OCFS2_INODE_SYSTEM_FILE) || + (OCFS2_I(inode_out)->ip_flags & OCFS2_INODE_SYSTEM_FILE)) + goto out_unlock; + + ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, + &len, remap_flags); + if (ret < 0 || len == 0) + goto out_unlock; + + /* Lock out changes to the allocation maps and remap. */ + down_write(&OCFS2_I(inode_in)->ip_alloc_sem); + if (!same_inode) + down_write_nested(&OCFS2_I(inode_out)->ip_alloc_sem, + SINGLE_DEPTH_NESTING); + + /* Zap any page cache for the destination file's range. */ + truncate_inode_pages_range(&inode_out->i_data, + round_down(pos_out, PAGE_SIZE), + round_up(pos_out + len, PAGE_SIZE) - 1); + + 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 (remapped < 0) { + ret = remapped; + mlog_errno(ret); + goto out_unlock; + } + + /* + * Empty the extent map so that we may get the right extent + * record from the disk. + */ + ocfs2_extent_map_trunc(inode_in, 0); + ocfs2_extent_map_trunc(inode_out, 0); + + ret = ocfs2_reflink_update_dest(inode_out, out_bh, pos_out + len); + if (ret) { + mlog_errno(ret); + goto out_unlock; + } + +out_unlock: + ocfs2_reflink_inodes_unlock(inode_in, in_bh, inode_out, out_bh); + return remapped > 0 ? remapped : ret; } const struct inode_operations ocfs2_file_iops = { diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index c7409578657b..dc66b80585ec 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4468,9 +4468,9 @@ int ocfs2_reflink_ioctl(struct inode *inode, } /* Update destination inode size, if necessary. */ -static int ocfs2_reflink_update_dest(struct inode *dest, - struct buffer_head *d_bh, - loff_t newlen) +int ocfs2_reflink_update_dest(struct inode *dest, + struct buffer_head *d_bh, + loff_t newlen) { handle_t *handle; int ret; @@ -4621,13 +4621,13 @@ static loff_t ocfs2_reflink_remap_extent(struct inode *s_inode, } /* Set up refcount tree and remap s_inode to t_inode. */ -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) +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; @@ -4720,10 +4720,10 @@ static loff_t ocfs2_reflink_remap_blocks(struct inode *s_inode, } /* Lock an inode and grab a bh pointing to the inode. */ -static int ocfs2_reflink_inodes_lock(struct inode *s_inode, - struct buffer_head **bh1, - struct inode *t_inode, - struct buffer_head **bh2) +int ocfs2_reflink_inodes_lock(struct inode *s_inode, + struct buffer_head **bh1, + struct inode *t_inode, + struct buffer_head **bh2) { struct inode *inode1; struct inode *inode2; @@ -4808,10 +4808,10 @@ static int ocfs2_reflink_inodes_lock(struct inode *s_inode, } /* Unlock both inodes and release buffers. */ -static void ocfs2_reflink_inodes_unlock(struct inode *s_inode, - struct buffer_head *s_bh, - struct inode *t_inode, - struct buffer_head *t_bh) +void ocfs2_reflink_inodes_unlock(struct inode *s_inode, + struct buffer_head *s_bh, + struct inode *t_inode, + struct buffer_head *t_bh) { ocfs2_inode_unlock(s_inode, 1); ocfs2_rw_unlock(s_inode, 1); @@ -4823,80 +4823,3 @@ static void ocfs2_reflink_inodes_unlock(struct inode *s_inode, } unlock_two_nondirectories(s_inode, t_inode); } - -/* Link a range of blocks from one file to another. */ -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)) - return -EOPNOTSUPP; - if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb)) - return -EROFS; - - /* Lock both files against IO */ - ret = ocfs2_reflink_inodes_lock(inode_in, &in_bh, inode_out, &out_bh); - if (ret) - return ret; - - /* Check file eligibility and prepare for block sharing. */ - ret = -EINVAL; - if ((OCFS2_I(inode_in)->ip_flags & OCFS2_INODE_SYSTEM_FILE) || - (OCFS2_I(inode_out)->ip_flags & OCFS2_INODE_SYSTEM_FILE)) - goto out_unlock; - - ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, - &len, remap_flags); - if (ret < 0 || len == 0) - goto out_unlock; - - /* Lock out changes to the allocation maps and remap. */ - down_write(&OCFS2_I(inode_in)->ip_alloc_sem); - if (!same_inode) - down_write_nested(&OCFS2_I(inode_out)->ip_alloc_sem, - SINGLE_DEPTH_NESTING); - - /* Zap any page cache for the destination file's range. */ - truncate_inode_pages_range(&inode_out->i_data, - round_down(pos_out, PAGE_SIZE), - round_up(pos_out + len, PAGE_SIZE) - 1); - - 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 (remapped < 0) { - ret = remapped; - mlog_errno(ret); - goto out_unlock; - } - - /* - * Empty the extent map so that we may get the right extent - * record from the disk. - */ - ocfs2_extent_map_trunc(inode_in, 0); - ocfs2_extent_map_trunc(inode_out, 0); - - ret = ocfs2_reflink_update_dest(inode_out, out_bh, pos_out + len); - if (ret) { - mlog_errno(ret); - goto out_unlock; - } - -out_unlock: - ocfs2_reflink_inodes_unlock(inode_in, in_bh, inode_out, out_bh); - return remapped > 0 ? remapped : ret; -} diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h index 9e64daba395d..e9e862be4a1e 100644 --- a/fs/ocfs2/refcounttree.h +++ b/fs/ocfs2/refcounttree.h @@ -115,11 +115,23 @@ int ocfs2_reflink_ioctl(struct inode *inode, const char __user *oldname, const char __user *newname, bool preserve); -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); +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); +int ocfs2_reflink_inodes_lock(struct inode *s_inode, + struct buffer_head **bh1, + struct inode *t_inode, + struct buffer_head **bh2); +void ocfs2_reflink_inodes_unlock(struct inode *s_inode, + struct buffer_head *s_bh, + struct inode *t_inode, + struct buffer_head *t_bh); +int ocfs2_reflink_update_dest(struct inode *dest, + struct buffer_head *d_bh, + loff_t newlen); #endif /* OCFS2_REFCOUNTTREE_H */ From patchwork Sun Oct 21 16:17:43 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: 10651221 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 2B4AE14E2 for ; Sun, 21 Oct 2018 16:17:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 19E44287C0 for ; Sun, 21 Oct 2018 16:17:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0DAD0287C6; Sun, 21 Oct 2018 16:17:55 +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 8BF00287C9 for ; Sun, 21 Oct 2018 16:17:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 87F4C6B0285; Sun, 21 Oct 2018 12:17:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 82F046B0287; Sun, 21 Oct 2018 12:17:53 -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 6F7816B0288; Sun, 21 Oct 2018 12:17:53 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f198.google.com (mail-yb1-f198.google.com [209.85.219.198]) by kanga.kvack.org (Postfix) with ESMTP id 34DDE6B0285 for ; Sun, 21 Oct 2018 12:17:53 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id y131-v6so2465946yby.13 for ; Sun, 21 Oct 2018 09:17:53 -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=5749FIFK93ihy3lPNOQ7wkYeCVTZYvwQHKIL7IXrY6w=; b=Yc/49dRK1U+1ahZw09x2PMDoVrH5/pIvs9ss8OFBbqOqxR4Wmw4En/s/6DMqwFwP7F wAB/hI7B7ixdpS3dD5FWKf6mgIG+X8pwoLNN8b41U49UxYTJooJhwIA3IsNibADKrCEL 7xRvS9Kn4su3Wro73b6ecZhwDeii3m4e4TltlIRMlPRWb0c9tmlRqUEwjCFlmsIojjCC PdjGl1i9eRUp6mTN8bqUXFyvE9QlsBHvD01ptip2uFumAb6z5T/Tkz/I8Xgj9oMOvBlJ s+sCS3VF14X8Z8esEY3gHgT76+d5nf4h5bM/M6BHikg77TOGGQIOX5m3xnf6Ji3H4GO7 SKVQ== X-Gm-Message-State: ABuFfogpj99bsLBoC2WT22UqeWl76uDK/mdBQ9fPRutYVB4lFDyphSWX sI0tk6ERn5p4He6DtwOq4oF2XPWyWjPUxoxie8+5bVZubdWK1pOXE2Bnhl5Ywj2uZsl9vSuoPCY fdXqb6NdJu9eZ0Bou9rl8jveU0qIlGPWIEXGGOyC4es3rNvZ4iCFwizNP/taCbUOuYQ== X-Received: by 2002:a25:820d:: with SMTP id q13-v6mr15209808ybk.171.1540138672982; Sun, 21 Oct 2018 09:17:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV63aZFCQcqRL/ECpnmK0XC/4s/HZ2wD9fcgoZre1i/JnTDkei5MQRII0U4gT/uErN7UISQ1V X-Received: by 2002:a25:820d:: with SMTP id q13-v6mr15209783ybk.171.1540138672443; Sun, 21 Oct 2018 09:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138672; cv=none; d=google.com; s=arc-20160816; b=oCWz/hHUr6en4LHNeLVFmKg8z39riym4mGVGB3hWIqzHsPECJgmx8jatwdCAmaibFP YYRKbR66I2ca73gEd15Sm49T7ZkTBR7iR8FkgsavnONlx0+Xyl7NfYhoXUYdCcM8UKdv wrvp5RgETo95EmY5uefat58/SCbAeNDrCXblGDjxx96z92lFKnKVAKut93v+F7AKne1P V3PlCUnt7lboNJRiATi99yNwZK26VzhZ1gILhLqTTtk/aasXbFwg9CXG+v0B/7gRWXr+ HqJEKrKgmaVO46qZhJHmNIEgbZ3e/jY0QoVPg29cQryYJxMFYK+R+4VdAcfZ2TFCldW1 da5Q== 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=5749FIFK93ihy3lPNOQ7wkYeCVTZYvwQHKIL7IXrY6w=; b=zVXwPsvz107hgWZBBrzt/gTJCOx7EamfxzCTEsNImVGN14RKDGlWXyH1nQeh7Iq/Au 3jINqFIJiLWjaP4tsNeyuOLP9gspoMAifogIaeewqhgDsWexGdRQC7zjjdc8IWG5qER8 QBYudCKlZYj4qGk7WtMfBaxT/a7KIJww7I3mYG0mIDtJtOBdDWuNcFLKf2ZkIEvI+ZYt LyH+Bm7COW6WjMuqQGG8kYrLcDv4WB+zeZvVHFvdXfWZ2d/3JS0xW1TyNVHhdQuJuoc6 F9zW9zAIEy5QEfeUiYdhiYIZrlO+Xk8xAut5X3PKV8LMcoiSmU70X8HsG27HSnN/kjPg AK/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=24DUBrAG; 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 w189-v6si10960755ybg.176.2018.10.21.09.17.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:52 -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=24DUBrAG; 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 w9LGE2Nq154085; Sun, 21 Oct 2018 16:17:51 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=5749FIFK93ihy3lPNOQ7wkYeCVTZYvwQHKIL7IXrY6w=; b=24DUBrAGkrS2J7UxUA0/AFMP2niht/l+UPTNWVEE060bjG0GnWg2p395m+ArKTBUx7y8 8Pf3F/xyVSSzU2K8Rs3RJpTOWwy6IixapcY4hhlmyvjqel0igTNgBDVwKp+ZUt0yvJ8i Bbe5zJXWBRnIIPVOE3yW0zP6AdK7hqDVDb5GNSkFmAcJ5Hxu4lonIwT+3e19/K+RnO9l zNykhLIuplLOLFXg/FjypYE1/l+DuckhLJl0kowR2EvKqP3tt7swvyXKJPGgvNXdKcsi MxjkHcDic0D1podKczKFJNoUbEBagCkE1VgGJGj+v5eGx+VggQ+TQuRS1OiwnXxdNHUl 5A== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2n7ustu1v9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:51 +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 w9LGHjFo027541 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:45 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 w9LGHjwD024877; Sun, 21 Oct 2018 16:17:45 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:45 -0700 Subject: [PATCH 23/28] 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, Dave Chinner , linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:17:43 -0700 Message-ID: <154013866350.29026.11722237862126200267.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=952 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 to page boundaries. We already wrote all the dirty data so the larger range shouldn't be a problem. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Reviewed-by: Christoph Hellwig --- 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 9b1ea42c81d1..e8e86646bb4b 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1369,8 +1369,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); return 1; out_unlock: From patchwork Sun Oct 21 16:17:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10651227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 18D3514E2 for ; Sun, 21 Oct 2018 16:17:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03A8F287B7 for ; Sun, 21 Oct 2018 16:17:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC31C287C0; Sun, 21 Oct 2018 16:17:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73C9D287B7 for ; Sun, 21 Oct 2018 16:17:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2FFE76B0287; Sun, 21 Oct 2018 12:17:56 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2B1396B0289; Sun, 21 Oct 2018 12:17:56 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 156976B028A; Sun, 21 Oct 2018 12:17:56 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f72.google.com (mail-yw1-f72.google.com [209.85.161.72]) by kanga.kvack.org (Postfix) with ESMTP id CC6AD6B0287 for ; Sun, 21 Oct 2018 12:17:55 -0400 (EDT) Received: by mail-yw1-f72.google.com with SMTP id n205-v6so25616424ywc.16 for ; Sun, 21 Oct 2018 09:17:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=LiozndoqC/TzvqN9AZSX3PUuVQc7boe5NscE8EdW/X4=; b=DRngs2At5JP1s8owiOPeqzv/fhzSTrRp8Ej7ddFZwyN0x3hJwoJe9suAuTBSeeRDVe WLkFOwDxT1rkhhwpQQTDLhVyyn2JlWoNndrdGNnbFgzhCWHjEfUAOVUB9legdARqRfvi zMll40GymmLyCQmRzx+mSdKndPgOMbUPoq/efJA43bXbZGbmXg0zLtNzHPrWzxAQkQC1 nQ6qM02WUW1YnrFhpGmmiay6xGe6D8lop28oNV2/1xjMXasufTLVBmceRERwMOOem2C4 PlZuKbjq/mpsAVMwSWs1GMB+D/d/hq0cxULMWgmXBiYeL1Q8pI8wJmT0O22SdWMLNhQO 6pcQ== X-Gm-Message-State: ABuFfogPObDenGY6VbeYrAImUFJS1KnSYxo2UWTYboLPE6tnBV4q9vPQ a8nwJ/fjLSP8Wup2RKlDungHowPvwEL5s5sA81jP8i6JHnSD3HnUIUiZV8FuA3xyoQ4jwCTNJgQ 930HESpHaZkVFNfxWFI7pS+k+kfoMejBBSsKR6Vx6dNokRhzNzwBgqH9DkZrofYpT6w== X-Received: by 2002:a81:4328:: with SMTP id q40-v6mr28792139ywa.187.1540138675544; Sun, 21 Oct 2018 09:17:55 -0700 (PDT) X-Google-Smtp-Source: ACcGV601fiHwTUp9CrlWGsCIO19aruRJF5SS1Ku2fuIl6pwkqKFi8pFq9ygfcRVWVlheKA93HaUI X-Received: by 2002:a81:4328:: with SMTP id q40-v6mr28792111ywa.187.1540138674973; Sun, 21 Oct 2018 09:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138674; cv=none; d=google.com; s=arc-20160816; b=WtDEDXwtD895eiNgKeHY5L7tB5Sg8untVZZCquAahJCugJC4yB9j2RLFopkOSSZpv4 QTfEg7O+HsAy6vFCTu7wi6Ti8ZzxmwnGG55tylCFY77qA5uFVVF2jklKeW87z9oTH5rX bML8zFyg90qn5OTjasA5nDQ5H71laoku1EKzlcdKFq5VUCqH0arsN+68W77QzCcmrkzr 5/NOBXv+0s8KfylzG/uptDZPm1v+lR/ET03vYdgjRmER3w44r5ILFIMCExsXTU2Inm/J zuzS0ETfFrJl9vG4cE3fEiRR+EXVb00lN0nW1IOJfabFmCWgBmkI0yfNHX5Ae3BkNGUC aiTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=LiozndoqC/TzvqN9AZSX3PUuVQc7boe5NscE8EdW/X4=; b=nsdJ/Lsc92FYWuBEdiV4x5w+//O0lDulPJgRcwY6eDPOJdyjY/WS7d0KD9+/endpdi VDmCwsZ2WDYAIxS2muIn90U+VfgoJLUrYUJxGCeFlE2hvneI/Z7GrtNmOEj4Oel2tIzq tvxZrBoyY2LQLi5RbdJi6nIQb/2e0TAehjnNoohRtMWel0m10jMnjoJMn2x8ZxmMFf7D waWSYnTdNK8/eGP4eBaQ5Z4x1unEAl4KvFDnFuECeh8sX4rtmeP3t7n1ZU+GmHcr1BSq LHUAao6lznqxY+/xQvEQnnHOkYFuY6vDWK2YmmNu6bYTSEIggYEVgxBxgqeZtO9PiO3G 2dCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=FkLUpJ5Z; spf=pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from aserp2120.oracle.com (aserp2120.oracle.com. [141.146.126.78]) by mx.google.com with ESMTPS id 204-v6si603985ywf.99.2018.10.21.09.17.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:17:54 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 as permitted sender) client-ip=141.146.126.78; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=FkLUpJ5Z; spf=pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9LGGCQA155864; Sun, 21 Oct 2018 16:17:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=LiozndoqC/TzvqN9AZSX3PUuVQc7boe5NscE8EdW/X4=; b=FkLUpJ5ZlHSQVxxriZvK5EtLw4/gvEgBpaitc1X1xmPGI9EhRSD9If1RF/PctUGEhoOt NK5VYcUjYJJbGvNozecBfeyKs2qFkdH6BxFXhYLln/kgEKniPKm3WEsauLhsuyOGt1t0 Dz1w0BZd/FE2Kfd0QNynAg9LbOlxaDmMCZe8BnVWnSkN8TJ1UuebDj1n7cpzDE/zdj0S 0gvRJ/c6ibSQ+kb1BshomwVeOsQYlUUsSbW4ALSyRDHlhOXW7FFjP5TAMV8S167D7yiG fXZfQ6a+GEN8mBsX2gRkK7MgeUOwlHlYbEhllMxEs1U24hGWpfmaqADE/F+2UCDz9CgA OQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2n7vapjysd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:53 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGHqq4006984 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:52 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGHqw3018953; Sun, 21 Oct 2018 16:17:52 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:52 -0700 Subject: [PATCH 24/28] xfs: clean up xfs_reflink_remap_blocks call site From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: sandeen@redhat.com, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:17:50 -0700 Message-ID: <154013867045.29026.12266020817835171751.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Move the offset <-> blocks unit conversions into xfs_reflink_remap_blocks to make the call site less ugly. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/xfs_reflink.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index e8e86646bb4b..79dec457f7fb 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1119,16 +1119,23 @@ xfs_reflink_remap_extent( STATIC int xfs_reflink_remap_blocks( struct xfs_inode *src, - xfs_fileoff_t srcoff, + loff_t pos_in, struct xfs_inode *dest, - xfs_fileoff_t destoff, - xfs_filblks_t len, - xfs_off_t new_isize) + loff_t pos_out, + loff_t remap_len) { struct xfs_bmbt_irec imap; + xfs_fileoff_t srcoff; + xfs_fileoff_t destoff; + xfs_filblks_t len; + xfs_filblks_t range_len; + xfs_off_t new_isize = pos_out + remap_len; int nimaps; int error = 0; - xfs_filblks_t range_len; + + destoff = XFS_B_TO_FSBT(src->i_mount, pos_out); + srcoff = XFS_B_TO_FSBT(src->i_mount, pos_in); + len = XFS_B_TO_FSB(src->i_mount, remap_len); /* drange = (destoff, destoff + len); srange = (srcoff, srcoff + len) */ while (len) { @@ -1143,7 +1150,7 @@ xfs_reflink_remap_blocks( error = xfs_bmapi_read(src, srcoff, len, &imap, &nimaps, 0); xfs_iunlock(src, lock_mode); if (error) - goto err; + break; ASSERT(nimaps == 1); trace_xfs_reflink_remap_imap(src, srcoff, len, XFS_IO_OVERWRITE, @@ -1157,11 +1164,11 @@ xfs_reflink_remap_blocks( error = xfs_reflink_remap_extent(dest, &imap, destoff, new_isize); if (error) - goto err; + break; if (fatal_signal_pending(current)) { error = -EINTR; - goto err; + break; } /* Advance drange/srange */ @@ -1170,10 +1177,8 @@ xfs_reflink_remap_blocks( len -= range_len; } - return 0; - -err: - trace_xfs_reflink_remap_blocks_error(dest, error, _RET_IP_); + if (error) + trace_xfs_reflink_remap_blocks_error(dest, error, _RET_IP_); return error; } @@ -1396,8 +1401,6 @@ xfs_reflink_remap_range( struct inode *inode_out = file_inode(file_out); struct xfs_inode *dest = XFS_I(inode_out); struct xfs_mount *mp = src->i_mount; - xfs_fileoff_t sfsbno, dfsbno; - xfs_filblks_t fsblen; xfs_extlen_t cowextsize; ssize_t ret; @@ -1415,11 +1418,7 @@ xfs_reflink_remap_range( trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); - dfsbno = XFS_B_TO_FSBT(mp, pos_out); - sfsbno = XFS_B_TO_FSBT(mp, pos_in); - fsblen = XFS_B_TO_FSB(mp, len); - ret = xfs_reflink_remap_blocks(src, sfsbno, dest, dfsbno, fsblen, - pos_out + len); + ret = xfs_reflink_remap_blocks(src, pos_in, dest, pos_out, len); if (ret) goto out_unlock; From patchwork Sun Oct 21 16:17: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: 10651239 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 71A5313A9 for ; Sun, 21 Oct 2018 16:18:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6017B287B7 for ; Sun, 21 Oct 2018 16:18:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54883287C6; Sun, 21 Oct 2018 16:18: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 C36B5287B7 for ; Sun, 21 Oct 2018 16:18:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AF2A86B0289; Sun, 21 Oct 2018 12:18:07 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id AA0026B028B; Sun, 21 Oct 2018 12:18:07 -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 918B86B028C; Sun, 21 Oct 2018 12:18:07 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by kanga.kvack.org (Postfix) with ESMTP id 5BDE06B0289 for ; Sun, 21 Oct 2018 12:18:07 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id h10-v6so4627112ybc.14 for ; Sun, 21 Oct 2018 09:18: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=jBhmb/N7l//SEdkHcVUE3iIqA8iaNxSFon2zX2S1w8g=; b=nuKxOvx+akuLGnQJDI34Ie6h9sbCVLkKriw5Ben1sYDHN9I2kSt6lTWq+tytHbPtbG nAHOcvT/DYQt8FYhB2pGLCr/BS4JLAsS5/6TMkZ7swQjRgO7oOe3jGXDruI/cSfTqu8D 66n8lJl+nRu6mBvcD2Iv/WGFXokiQaUciip8sTZK0oZoyZ+TDLNzaNR22nrkQsKROmID KxfwSIT+WNUNzEIctSqdntzjKpo8E/m1YoCmQOmScdc24LtgB2e+wY7DTIlNxmwXVbp+ oYrMDWkTW9YR73fJhpnwDMdYq9PEoKsafAjL5Bhpj7y4hUAvi5RvQSg/cdNHchEY6o3b EnBg== X-Gm-Message-State: ABuFfoiwgyrAaYYa+QdS68m3O26EeDqTR9u/751HTA3yWpDS6U1B+bW0 JZ89VoSl28uQxXLOcednEtuNpeAmt8nI1HWfZFexUvkWEkjVkqXsGta/o5UZfDVug+ZKnG03XU5 OvIjmGjDPSyHixB8WrHHAxMvCSjR+4xNXO7Mt/yUCgBwYdYhRyk804wUkROoaskw/mQ== X-Received: by 2002:a81:39c5:: with SMTP id g188-v6mr29187587ywa.408.1540138687096; Sun, 21 Oct 2018 09:18:07 -0700 (PDT) X-Google-Smtp-Source: ACcGV60v9LgsAsuJE0MhsbEtucGv6CsCm47ijoSd0nrIfPM7PmBA+s2lkRioiyLnBxxT5paKOfQA X-Received: by 2002:a81:39c5:: with SMTP id g188-v6mr29187539ywa.408.1540138686378; Sun, 21 Oct 2018 09:18:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138686; cv=none; d=google.com; s=arc-20160816; b=Xa9F4Haibf6CEa+3cC/EbLpLwkEy9W3FPQdzHFEkCIDUSmLPJ5kmMa/1YSXTF2SG4R PMAYBq8IR+QYbBDdfnIaGa5NsMm1cd5sa09p8kdGkHEEqNh6jtBPpliMPM9MPGTNddW/ Wbx1+eK/9DB7IE06/cbpQyXmd6tCDtmC8OzTmABwXb12/1OacWwkrv3p3JcBfcIoRNIm wov69zr+uJfx+DZY1z13eflPUaa/7QrgvZ1uhDREyyiupkgesgh9m9TzpcBDnCyJ4vCe lrm89xImunjExraP03ka+fZIdkugqOELfoyFTZZAqol1qp0vACZh3oC3wafEgJhWl271 K+OQ== 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=jBhmb/N7l//SEdkHcVUE3iIqA8iaNxSFon2zX2S1w8g=; b=J+s2ZYrhYURpDQ3BxNFVBmipEbeS+tcJTV8FALOSjX6QNwYbKE2ALMnHnoAxtMyBF+ fhuUm9lJ1rCg0smM/BTJbWBtSyqtEXAoCsNfmFCfVIPqF8qI4tgd0s8To6o3E++X9Dxh /ws61ZtCLJOMWR3Oio9YSW+9PaakSYWgeZlJkzFU03oWJq8LJjmFxZ6E1356WJ8wp+eL 4jtvsjKk2OsYaRw+fGXpIGvGUe0rgjaenZhNhxPHK59lG5sMUpVXotpDjrDmVWRBou4e FhRWIV6S0JX9rreQOclrmKu7WV1hjQ1neVork2PjihloYW7tKZ9NHfAl73G5tARUzV2k xNog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=rFr3O4uU; 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 186-v6si9545696ybb.447.2018.10.21.09.18.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:18:06 -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=rFr3O4uU; 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 w9LGEMks155132; Sun, 21 Oct 2018 16:18: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=jBhmb/N7l//SEdkHcVUE3iIqA8iaNxSFon2zX2S1w8g=; b=rFr3O4uUYl5F957T+le4lmrP2or8osZt8RblSUTrVCcXiX1cYVK10JKixDPDfftzv6lB Q6NokYaIYMmqRHrHxlL4RKVQP4kMCwTI4lOFemGVdb2pGN8mMVuVLxb6kDxkZy+3La2i 7OTI4cY7zI+oncaChJfyIzAmXaPIvMoR2WVXjUei134KgMeJd5PAAeF1zsqkiqVrZs0W 7tzB7WdOpc0NvpOCCYGdscvhHNb/JGoz7+AKF/LqAmO9LfcwP9ecprvMqsnzA9Y8p+Iy 9gfHJyUMGfcWZIH0QIR/+o0WItl8H9/RHep7/2IIAI7UHwNuCEZda8HuG+TEc4yiqSmj vA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2n7vapjysm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:18:05 +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 w9LGHxPG007062 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:17:59 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGHxSA024891; Sun, 21 Oct 2018 16:17:59 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:17:58 -0700 Subject: [PATCH 25/28] 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: Sun, 21 Oct 2018 09:17:57 -0700 Message-ID: <154013867727.29026.14417615066515846065.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=856 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Reviewed-by: Dave Chinner --- fs/xfs/xfs_file.c | 5 +---- fs/xfs/xfs_reflink.c | 17 ++++++++++++----- fs/xfs/xfs_reflink.h | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 38fde4e11714..7d42ab8fe6e1 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -928,14 +928,11 @@ xfs_file_remap_range( loff_t len, unsigned int remap_flags) { - int ret; - if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) return -EINVAL; - ret = xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, + return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, len, remap_flags); - return ret < 0 ? ret : len; } STATIC int diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 79dec457f7fb..4abb2aea8f31 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1122,13 +1122,15 @@ xfs_reflink_remap_blocks( loff_t pos_in, struct xfs_inode *dest, loff_t pos_out, - loff_t remap_len) + loff_t remap_len, + loff_t *remapped) { struct xfs_bmbt_irec imap; xfs_fileoff_t srcoff; xfs_fileoff_t destoff; xfs_filblks_t len; xfs_filblks_t range_len; + xfs_filblks_t remapped_len = 0; xfs_off_t new_isize = pos_out + remap_len; int nimaps; int error = 0; @@ -1175,10 +1177,13 @@ xfs_reflink_remap_blocks( srcoff += range_len; destoff += range_len; len -= range_len; + remapped_len += range_len; } if (error) trace_xfs_reflink_remap_blocks_error(dest, error, _RET_IP_); + *remapped = min_t(loff_t, remap_len, + XFS_FSB_TO_B(src->i_mount, remapped_len)); return error; } @@ -1387,7 +1392,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, @@ -1401,8 +1406,9 @@ xfs_reflink_remap_range( struct inode *inode_out = file_inode(file_out); struct xfs_inode *dest = XFS_I(inode_out); struct xfs_mount *mp = src->i_mount; + loff_t remapped = 0; xfs_extlen_t cowextsize; - ssize_t ret; + int ret; if (!xfs_sb_version_hasreflink(&mp->m_sb)) return -EOPNOTSUPP; @@ -1418,7 +1424,8 @@ xfs_reflink_remap_range( trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); - ret = xfs_reflink_remap_blocks(src, pos_in, dest, pos_out, len); + ret = xfs_reflink_remap_blocks(src, pos_in, dest, pos_out, len, + &remapped); if (ret) goto out_unlock; @@ -1441,7 +1448,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, From patchwork Sun Oct 21 16:18: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: 10651243 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 D892C13A9 for ; Sun, 21 Oct 2018 16:18:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C58B7287B7 for ; Sun, 21 Oct 2018 16:18:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B962E287C7; Sun, 21 Oct 2018 16:18:11 +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 5AED1287C0 for ; Sun, 21 Oct 2018 16:18:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 48A116B028B; Sun, 21 Oct 2018 12:18:09 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3EAF16B028D; Sun, 21 Oct 2018 12:18:09 -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 23DB76B028E; Sun, 21 Oct 2018 12:18:09 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f199.google.com (mail-yb1-f199.google.com [209.85.219.199]) by kanga.kvack.org (Postfix) with ESMTP id E00486B028B for ; Sun, 21 Oct 2018 12:18:08 -0400 (EDT) Received: by mail-yb1-f199.google.com with SMTP id f8-v6so22947441ybn.22 for ; Sun, 21 Oct 2018 09:18:08 -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=jZPaIA2I61+2o/Blz6OYutRXgyd1ozFk3SQt5++KfCo=; b=jD1huVOebjZXcE42MwTFPVQuy0b5euVU8DuGtSKy6wJv20G9B2Ox94O5vTJjtZxRQX 0tEE30yP93SQQrXhAx0A+Qv/NxwhDwve+vWNpzwXh6TbH6KKZ3j1FchFq/I2x6KQ0TwN mzcAsy9xdS4rlak7JlZIomHaipZf3OmtppqVyE6RXPCyxqowFB5LySK+O3Ay8sRlLzH2 i4O2ADbCjT4u5JXMfWE7ewQrQj7wL9CddwTV7d83U2M8LBJepaKcHBGpitltrzX6W3Ds gXl7R27YcT81I6hn8BGf5tu2aHJZ84HC3Hsd8mBi66iSsEShrraveUbCRf5t4Qmqtfnp XP3Q== X-Gm-Message-State: ABuFfohRjuLwtD+1FJ3UubZ1xLPW0lS9IByxpz7G0RJ/mM/mccPVqRLH T5EDXXOPUKT1ac8aKaSWTT2bj4V++nWllUX04FuQfpwIKMcHmVscRuq5HkLl8r76WbiWih5Muxh IZpp2o/6PTIaHylFcIlaRr44yP7MHQIWEEQ4hOPh1qXjhI91LAFVZ7e8TsMhsdJ09aw== X-Received: by 2002:a25:2488:: with SMTP id k130-v6mr18805060ybk.311.1540138688679; Sun, 21 Oct 2018 09:18:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV61+k/wswrkq3zjN4u0IFporIYMoAFld2J6c173sxQIeMoiDLCVc91OD0t+tpJWu5KucogkA X-Received: by 2002:a25:2488:: with SMTP id k130-v6mr18805026ybk.311.1540138688031; Sun, 21 Oct 2018 09:18:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138688; cv=none; d=google.com; s=arc-20160816; b=lOlJIB2WolE/M0kTNr0RFLYuiJbF5Mdyn7HU2orxALo3MllCz9o/yzE4DeLEPc+a9Y f3+Yb/qI4mYzelBNTdTl1dVJUyjziSQE44weXkFP2szeV5+piFxFkWhBcpFpj++AwsSn m9ZPOS4o0H5bzUBcRTKuJ7gRDY4IA5pIrpT9gkxsdj+5Yr6WcYjHfaTg2v/f3PtSWdvD IIgaz54MKSyj76wvaoBUyT8yP2KmxgasL43J+VE2LDvboBzDo+cd1tQpGzcNhDC4aXC2 xym8TnOSgpIelt8WlAP2Tt2Wyy5TXsQYYq4bmeXFtGqvXSpH/Q+bKPZQA29hAosbFsrm vL6g== 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=jZPaIA2I61+2o/Blz6OYutRXgyd1ozFk3SQt5++KfCo=; b=sx1OOaYtUCpNWbW1YxMagEtcm5rr8WyGrC0OmQmIMvtdZqoUkdRxrGFeIzZteyEwWb SWfd8SLxaiLckPSdP8WdqGG4TnZuxz73Iq5CE6+737MZk/ivTVxTGJNSpS7nip+yJnSH QCYJoennAUd94E3rY05piJFZo2X3TJb9acXE1R37YmnfZ07p4l7xddp9cfYvl8U/6mK8 +/e7VBhvWzzd9+/zo6dwcOvcyLLqJ6lbgcqIM8QanLC9ChCCpdRejT4fq78MNaSjneht BMiIutHeCw42WEFzy0HLKeLsYimmYMoU28B2Ukf1ZUHeHvncoCs+OKW9DSnuDDOHdzLA BxBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="NSGYgg/o"; 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 p25-v6si13350638ybj.295.2018.10.21.09.18.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:18:07 -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="NSGYgg/o"; 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 w9LGF3DN155374; Sun, 21 Oct 2018 16:18:07 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=jZPaIA2I61+2o/Blz6OYutRXgyd1ozFk3SQt5++KfCo=; b=NSGYgg/otcR4G6dS5NR+JWv/XOrstKKjYhWITEdiqmfQzax1xvLustf1TH6iz/Pg6RLB TCBPP/Yv4EmG+cRL1y/SuklDDau/Z/+0LfaftJVGDTqMjfKFC8b82VG9CahErOvU1oPX wwvksMdkyEd4B9UnuQ/ZrQtBGWpii1HD+kzVTFvS7v/3fJWMLX/BjV5Dh8IR6S+kjnVb 4syLhtd1QU54kU//12AAqdQHndbGq9rpcOkfFwvasXm29dxRkFCgzkZQ1+nrEc4d83O9 8/i2U3Vv8EAYfdEdSuKw7/1swAnXj8yopimp6HvFVZEWHg7pn35Xx/hNiJf5fzdqfK6o sg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2n7vapjysn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:18:07 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGI6ma011272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:18:06 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGI6wA025010; Sun, 21 Oct 2018 16:18:06 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:18:05 -0700 Subject: [PATCH 26/28] xfs: remove redundant remap partial EOF block 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, Dave Chinner , linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:18:04 -0700 Message-ID: <154013868417.29026.5852711121957107278.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Now that we've moved the partial EOF block checks to the VFS helpers, we can remove the redundant functionality from XFS. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/xfs_reflink.c | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 4abb2aea8f31..bccc66316cc4 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1314,7 +1314,6 @@ xfs_reflink_remap_prep( struct inode *inode_out = file_inode(file_out); struct xfs_inode *dest = XFS_I(inode_out); bool same_inode = (inode_in == inode_out); - u64 blkmask = i_blocksize(inode_in) - 1; ssize_t ret; /* Lock both files against IO */ @@ -1342,24 +1341,6 @@ xfs_reflink_remap_prep( if (ret < 0 || *len == 0) goto out_unlock; - /* - * If the dedupe data matches, chop off the partial EOF block - * from the source file so we don't try to dedupe the partial - * EOF block. - */ - if (remap_flags & REMAP_FILE_DEDUP) { - *len &= ~blkmask; - } else if (*len & blkmask) { - /* - * The user is attempting to share a partial EOF block, - * if it's inside the destination EOF then reject it. - */ - if (pos_out + *len < i_size_read(inode_out)) { - ret = -EINVAL; - goto out_unlock; - } - } - /* Attach dquots to dest inode before changing block map */ ret = xfs_qm_dqattach(dest); if (ret) From patchwork Sun Oct 21 16:18: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: 10651269 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 982F314E2 for ; Sun, 21 Oct 2018 16:18:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83E442624B for ; Sun, 21 Oct 2018 16:18:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76F74281D2; Sun, 21 Oct 2018 16:18: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 C6C972624B for ; Sun, 21 Oct 2018 16:18:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA1966B028D; Sun, 21 Oct 2018 12:18:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A4F826B028F; Sun, 21 Oct 2018 12:18: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 918FF6B0290; Sun, 21 Oct 2018 12:18:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) by kanga.kvack.org (Postfix) with ESMTP id 5D0C96B028D for ; Sun, 21 Oct 2018 12:18:20 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id u42-v6so23375886ybi.3 for ; Sun, 21 Oct 2018 09:18: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=16P3zwKvrT99XdZtAWDX1lXYkN0QjMaraaBIuWhVyNg=; b=UqWKi8kNkjEsDhrU+IzYb+Vp8IL+XNZEcdB/NFVzIuEEJTVYp7Dt29EaucMj+xzclm 93o++iWpMRvH1wAQryJSRqN3ujKnzjAgAO54Q1RbeUfDhWDrCfjsw6KP+pKdeTu2jfvW dJZX9ReGBma7Nk8FWrM8ZE6boawDEbWChugS3YKV9QQy7ebWJmxvhbZHl4RDfrOqG8YH d55Sn4oQIjiNoSikupgyzjdLKSq1UQY39ev9NkTB8t+/SA+YLV1GRR/Eti/suwfq6del UkNj1OCweWWs3LLAgHC8WA4umVlY7go79ov+zSQmuljNLJP1D1YSaXJRvvtXDhVnFTtz YHRQ== X-Gm-Message-State: ABuFfogJz7wCjBl/azMUc5zWFFPaPkCLkzCSIEW8jqDgMwn0rUBNWEJZ UkQohuaUYyXhVNrdE9UlluS0wQ+EDCJpJHZWO+Josqv+3NZOrCKywg3T1XN4xKFRjZQEh36TRNA Gk+yyDsL5LpMt8Nn/Ixu9iK/KhLeRp1ON8F4LDY+IAYrZRI5s/dWCkzymLzsE2dovVw== X-Received: by 2002:a81:698b:: with SMTP id e133-v6mr26140927ywc.271.1540138700103; Sun, 21 Oct 2018 09:18:20 -0700 (PDT) X-Google-Smtp-Source: ACcGV61EHs0dIIVqik+hnFgS0b3xSotBgdOXu0UFXqW2yfRmFZF/WMFHm7Lc5R0kYkmR13u7jVJy X-Received: by 2002:a81:698b:: with SMTP id e133-v6mr26140877ywc.271.1540138699302; Sun, 21 Oct 2018 09:18:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138699; cv=none; d=google.com; s=arc-20160816; b=iqt22KEpJT3yC4JAnYC5prWy8cd17A522Ug89cdm0WePAKeHbkqa4G+/LrRTTtvZE6 vsNPSmcwpGYdOpFdc+dAEoQlwp9Nq2dJgnp/ZZLMUShWc5KO1R0aB9CAny0W9bNf7qUl 6sw4VewhoPS0YP5utbtpdUg4Oq1Jgu3KoXRhu0uSSQwztNrVZLcMv1euGaLx0o/eJicn 1dMezb6UZYRyovqEIHHjHlnNn62qSzF0cBiokRs/OeHQl9DzjJ+vnGCmd4aFkvl/Kkth UQXzVqgReyqVDJDG4s+yztxQCnz7gEi4qGBKtkkl7qr0VqQfq6PS5BLGgoWK8uLPw2FP 1zLQ== 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=16P3zwKvrT99XdZtAWDX1lXYkN0QjMaraaBIuWhVyNg=; b=JJCyXRv9fGoBmDOyiFASGqwSVW8Otfd5n5da0SjqFDMcRn+Dh7ac/5qqEAZ+gPvj11 O7UuQ3l9KZEVIKWPA57sYL4tSjI5Wo+XYHkc4U/fxzhPbxoSyFFq1NWq6yW3rTlRQ/ij YZfCaGZeNqBWOzDV0bQirx6hSpPrqQ5QJ50tY0qcFU7oNL5TIY81zKHgv1rd1Ni0RvXh Yx+qcdLX+2GGex6VQEmDgqS/aVw4TGeFr7pWunLIisPjrz54BwgFfQlENhnyCb3P7gPS Qj4XCRykEHMVf4IRzRdH7pfXSDu0t6uEO9j7DBBWVEggMF/jDgvDMzmJHTpo9kbJV0SG mSrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ROd2ev+m; 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 63-v6si11130969ybm.25.2018.10.21.09.18.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:18:19 -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=ROd2ev+m; 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 w9LGDwbr154742; Sun, 21 Oct 2018 16:18: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=16P3zwKvrT99XdZtAWDX1lXYkN0QjMaraaBIuWhVyNg=; b=ROd2ev+mZxl75lWILLTzcCuKZO2mY+XCRSmQFqyFIc+2vbDpwWKKRUKXu4D97V1IJFVU FUFpejsn3vWbH6KC0DS2DNApwu66BCJPKo2rs+ZFg6A4QSA178l3kQOmqrAgPyOdBnE1 FV2n0QP+Xz322smHUV49IWSUIz8mqp+3UT11NhJpcXbHbeYfwNpMKePT9AJveHL+hfxB R/qWRZOyPdPOG95Tiix8j4G3p8cnjB9p5FRnsQ2JvFuAy5QTgOg8K3SDj0CqAX6Vs2Gd CMMgbhmbbxNyly2RSGuFprZB1wAxwOqEWeUUjcQ5jnY/kYiPvDimrMwW1fiV5MStVi9J bg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2n7vapjysu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:18:18 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9LGICh8011342 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:18:12 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9LGICQU019126; Sun, 21 Oct 2018 16:18:12 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:18:12 -0700 Subject: [PATCH 27/28] xfs: remove xfs_reflink_remap_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: Sun, 21 Oct 2018 09:18:11 -0700 Message-ID: <154013869100.29026.7543087084546497731.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Since xfs_file_remap_range is a thin wrapper, move the contents of xfs_reflink_remap_range into the shell. This cuts down on the vfs calls being made from internal xfs code. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/xfs_file.c | 65 ++++++++++++++++++++++++++++++++++++++++------ fs/xfs/xfs_reflink.c | 70 +++----------------------------------------------- fs/xfs/xfs_reflink.h | 10 +++++++ 3 files changed, 70 insertions(+), 75 deletions(-) diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c index 7d42ab8fe6e1..53c9ab8fb777 100644 --- a/fs/xfs/xfs_file.c +++ b/fs/xfs/xfs_file.c @@ -919,20 +919,67 @@ xfs_file_fallocate( return error; } -STATIC loff_t + +loff_t xfs_file_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 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 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; + loff_t remapped = 0; + xfs_extlen_t cowextsize; + int ret; + if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY)) return -EINVAL; - return xfs_reflink_remap_range(file_in, pos_in, file_out, pos_out, - len, remap_flags); + 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, remap_flags); + if (ret < 0 || len == 0) + return ret; + + trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); + + ret = xfs_reflink_remap_blocks(src, pos_in, dest, pos_out, len, + &remapped); + if (ret) + goto out_unlock; + + /* + * Carry the cowextsize hint from src to dest if we're sharing the + * entire source file to the entire destination file, the source file + * has a cowextsize hint, and the destination file does not. + */ + cowextsize = 0; + if (pos_in == 0 && len == i_size_read(inode_in) && + (src->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) && + pos_out == 0 && len >= i_size_read(inode_out) && + !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)) + cowextsize = src->i_d.di_cowextsize; + + ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize, + remap_flags); + +out_unlock: + xfs_reflink_remap_unlock(file_in, file_out); + if (ret) + trace_xfs_reflink_remap_range_error(dest, ret, _RET_IP_); + return remapped > 0 ? remapped : ret; } STATIC int diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index bccc66316cc4..84f372f7ea04 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -916,7 +916,7 @@ xfs_reflink_set_inode_flag( /* * Update destination inode size & cowextsize hint, if necessary. */ -STATIC int +int xfs_reflink_update_dest( struct xfs_inode *dest, xfs_off_t newlen, @@ -1116,7 +1116,7 @@ xfs_reflink_remap_extent( /* * Iteratively remap one file's extents (and holes) to another's. */ -STATIC int +int xfs_reflink_remap_blocks( struct xfs_inode *src, loff_t pos_in, @@ -1232,7 +1232,7 @@ xfs_iolock_two_inodes_and_break_layout( } /* Unlock both inodes after they've been prepped for a range clone. */ -STATIC void +void xfs_reflink_remap_unlock( struct file *file_in, struct file *file_out) @@ -1300,7 +1300,7 @@ xfs_reflink_zero_posteof( * stale data in the destination file. Hence we reject these clone attempts with * -EINVAL in this case. */ -STATIC int +int xfs_reflink_remap_prep( struct file *file_in, loff_t pos_in, @@ -1370,68 +1370,6 @@ xfs_reflink_remap_prep( return ret; } -/* - * Link a range of blocks from one file to another. - */ -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) -{ - 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; - loff_t remapped = 0; - xfs_extlen_t cowextsize; - int 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, remap_flags); - if (ret < 0 || len == 0) - return ret; - - trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); - - ret = xfs_reflink_remap_blocks(src, pos_in, dest, pos_out, len, - &remapped); - if (ret) - goto out_unlock; - - /* - * Carry the cowextsize hint from src to dest if we're sharing the - * entire source file to the entire destination file, the source file - * has a cowextsize hint, and the destination file does not. - */ - cowextsize = 0; - if (pos_in == 0 && len == i_size_read(inode_in) && - (src->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE) && - pos_out == 0 && len >= i_size_read(inode_out) && - !(dest->i_d.di_flags2 & XFS_DIFLAG2_COWEXTSIZE)) - cowextsize = src->i_d.di_cowextsize; - - ret = xfs_reflink_update_dest(dest, pos_out + len, cowextsize, - remap_flags); - -out_unlock: - xfs_reflink_remap_unlock(file_in, file_out); - if (ret) - trace_xfs_reflink_remap_range_error(dest, ret, _RET_IP_); - return remapped > 0 ? remapped : ret; -} - /* * The user wants to preemptively CoW all shared blocks in this file, * which enables us to turn off the reflink flag. Iterate all diff --git a/fs/xfs/xfs_reflink.h b/fs/xfs/xfs_reflink.h index cbc26ff79a8f..28a84edda889 100644 --- a/fs/xfs/xfs_reflink.h +++ b/fs/xfs/xfs_reflink.h @@ -36,5 +36,15 @@ extern int xfs_reflink_clear_inode_flag(struct xfs_inode *ip, struct xfs_trans **tpp); extern int xfs_reflink_unshare(struct xfs_inode *ip, xfs_off_t offset, xfs_off_t len); +extern int xfs_reflink_remap_prep(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_remap_blocks(struct xfs_inode *src, loff_t pos_in, + struct xfs_inode *dest, loff_t pos_out, loff_t remap_len, + loff_t *remapped); +extern int xfs_reflink_update_dest(struct xfs_inode *dest, xfs_off_t newlen, + xfs_extlen_t cowextsize, unsigned int remap_flags); +extern void xfs_reflink_remap_unlock(struct file *file_in, + struct file *file_out); #endif /* __XFS_REFLINK_H */ From patchwork Sun Oct 21 16:18: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: 10651283 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 5326D13A9 for ; Sun, 21 Oct 2018 16:18:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41317281D2 for ; Sun, 21 Oct 2018 16:18:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 351792832D; Sun, 21 Oct 2018 16:18: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 C381A281D2 for ; Sun, 21 Oct 2018 16:18:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB2076B028F; Sun, 21 Oct 2018 12:18:27 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B3C5F6B0291; Sun, 21 Oct 2018 12:18: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 A03B56B0292; Sun, 21 Oct 2018 12:18:27 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-yw1-f71.google.com (mail-yw1-f71.google.com [209.85.161.71]) by kanga.kvack.org (Postfix) with ESMTP id 6D1946B028F for ; Sun, 21 Oct 2018 12:18:27 -0400 (EDT) Received: by mail-yw1-f71.google.com with SMTP id n143-v6so25632140ywd.6 for ; Sun, 21 Oct 2018 09:18: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=jIAzzc18fmqpZ/u/wL5JmiNfFJR+FqDbUB467dFODYU=; b=nwPwnqgPqoJL9dS9r4fIKQasq+mrcUpb75T2+tbX1HzZI8iwH8pyY5Y5x8sbKr4xIq LpZ+k+ZwzZXIy27UlwVl1B5P+VZFKcMxJ8o6NEmduRXxA6tSQ/R+XPImPgX27a/kcXZK Iyqct0PVBmYYMq4w6vFngOtI81jTFD2hsxWcwWH4yPPzVLtWfntIzWjdveD22/Uk4eB/ Q5gE7LLSTR96EpDSFSWU064AQBXsy2+X8TfQABnGYn6r+OSTvgjK+NShGndf/4FEBc6a xTUtRAysw2RVzHBE/25UFDcYereW+0BvOEbczGf9EXf9CHJeIsUSJXz7pygLlSdJdv2a OKoA== X-Gm-Message-State: ABuFfoiPQL3PIHHbN2VbTZWg+HWKEFzXrS57FF0bUzE7jAX99SGxxbjc y3sXtSax/ockNsQzqbPQ8BbhiXp+d7a9gtx6UIu/C9XEqyVrV0kc/u4Tsnx/X94cDRZygwxE8Ou IS8l9QTbpaV9QLZ6FrkUa+TOjKQOPkGkWwxkuavpP50sMCeWz/IoINWED7TneInrb6A== X-Received: by 2002:a25:ef07:: with SMTP id g7-v6mr29573965ybd.417.1540138707207; Sun, 21 Oct 2018 09:18:27 -0700 (PDT) X-Google-Smtp-Source: ACcGV62B98E/YQcwqV2k6v1npcLixttBptraLlM31sOrW0pbQ62kx+M+m4nOtoO9BJ/rOyufSiZI X-Received: by 2002:a25:ef07:: with SMTP id g7-v6mr29573930ybd.417.1540138706587; Sun, 21 Oct 2018 09:18:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540138706; cv=none; d=google.com; s=arc-20160816; b=gK3FQgLuW4BtXvyyCnU9bhhTpmUu1cS8fZrllhqIt2DdOlK7/f4J+8WWuD7BBqvlqb fjpgXrratjnxruFhcwYW9Wn5XmfaMGUdj+Tu1tMo3sLwgshzY2FBrLz5y3N6z27oCxHI Cv1BDDo5ysBl402OCzdOiQ4Ey4N7cD6amX8sUBd1hm23UNMDc4fKQel68PxEENhE+gUZ N9blkQrYmC1iskogrQhgUic5dwPdI3gq4nN4bK787F0v8ihKRNyjaqJj3WGsOXQ9qUp2 Df4t2PRs7Qxbj9dcfpmKjyS/jhv0XmZDzBYBj3k28/FcCHrbSJGeq+LS2PQJvsUKmUaH yk0w== 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=jIAzzc18fmqpZ/u/wL5JmiNfFJR+FqDbUB467dFODYU=; b=tf7vMgWb1+zMwGW+tLJcjHWN35N3VUBczMwpqmJBYCVS0kYIzThJ/u+RUD4y9NJ1lm M3xY1xLRYEgZhAd2DcRPChjmKaJqLsULW0sqYI5HsRMoN6q3kmpSNsLZeDNVCAYC2aki 3HZEVgO47iceivhkb1oSULCVGFa6tsuVVVkx2T6GKIo9EomKrBwYpJR9M0tb/LVKVzgz AWZe25bG2Cn+tPIKvSrjyYO0TH6kt8ze99AWOjfTvrdwcRy9CmXwoGkBaqgvf8KpyWlX PNViuIDX3u9Ze3QS5D5lESE9cIRUXz4OWBndzX59f7pt+o2vakC5lrYSj9u0ZnBKUZtS JrfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=4REOEMUD; 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 r15-v6si4109218ybm.475.2018.10.21.09.18.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 21 Oct 2018 09:18: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=4REOEMUD; 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 w9LGIPFo156709; Sun, 21 Oct 2018 16:18: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=jIAzzc18fmqpZ/u/wL5JmiNfFJR+FqDbUB467dFODYU=; b=4REOEMUDeeSpvzDWeIXkcCH2Uv4rSr9wNZqHRv+7to1W8Dyk1u3Znxq2m/Be4hDpZqIu B2wUk+QxWiScMJcKQBNoOeypUBFU/oxfiHYJp5S2eglmoPLQdN7+EdlpcB6jU+jbI3F+ /axs7CTxnxWBNMCm5eP8JfhSOWedODmFfXTsEAmft2yFh6ZTCEOV7t9Jpk+413m2vSZJ zj/15Z03uX1oigBQLgkYnpdsDrX6TClci0mWfMMTmQrVHIfa15R4cIS9p9F3XCVnaF13 A1tohZrvVYghD3n2z+7jhj49BfPnH/4DIPPDpGEc0p3/yr6W+5sQokXEG3K4kPFgkVL1 Cw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2n7ustu1w3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:18:25 +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 w9LGIOpQ007643 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 21 Oct 2018 16:18:24 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 w9LGIOUu021851; Sun, 21 Oct 2018 16:18:24 GMT Received: from localhost (/10.159.225.70) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 21 Oct 2018 09:18:24 -0700 Subject: [PATCH 28/28] xfs: remove [cm]time update from reflink calls From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: sandeen@redhat.com, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Sun, 21 Oct 2018 09:18:17 -0700 Message-ID: <154013869780.29026.674362788764806472.stgit@magnolia> In-Reply-To: <154013850285.29026.16168387526580596209.stgit@magnolia> References: <154013850285.29026.16168387526580596209.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9053 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=862 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810210151 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Now that the vfs remap helper dirties the inode [cm]time for us, xfs no longer needs to do that on its own. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/xfs_reflink.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 84f372f7ea04..e72218477bf2 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -927,8 +927,7 @@ xfs_reflink_update_dest( struct xfs_trans *tp; int error; - if ((remap_flags & REMAP_FILE_DEDUP) && - newlen <= i_size_read(VFS_I(dest)) && cowextsize == 0) + if (newlen <= i_size_read(VFS_I(dest)) && cowextsize == 0) return 0; error = xfs_trans_alloc(mp, &M_RES(mp)->tr_ichange, 0, 0, 0, &tp); @@ -949,10 +948,6 @@ xfs_reflink_update_dest( dest->i_d.di_flags2 |= XFS_DIFLAG2_COWEXTSIZE; } - if (!(remap_flags & REMAP_FILE_DEDUP)) { - xfs_trans_ichgtime(tp, dest, - XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG); - } xfs_trans_log_inode(tp, dest, XFS_ILOG_CORE); error = xfs_trans_commit(tp);