From patchwork Wed Oct 17 22:44:22 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: 10646159 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 10CF71508 for ; Wed, 17 Oct 2018 22:44:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01945288CA for ; Wed, 17 Oct 2018 22:44:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6A41288C7; Wed, 17 Oct 2018 22:44:34 +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 C38E2288C7 for ; Wed, 17 Oct 2018 22:44:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EC63C6B026B; Wed, 17 Oct 2018 18:44:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id E75946B026C; Wed, 17 Oct 2018 18:44:32 -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 D18896B026D; Wed, 17 Oct 2018 18:44:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 8EDD56B026B for ; Wed, 17 Oct 2018 18:44:32 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id l1-v6so28101709pfb.7 for ; Wed, 17 Oct 2018 15:44:32 -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=fySikyIyhHbJuiv59mUgzxXs3yHiJDqwW0Ex2fXz5W1KNqEvWzSPFQ+i9hT3JCKk4R W+nz9ME2CiXVr4YkGloRGWBy72YIBcRLXiZ44iceHQPkUh4KYP1Zd99sMeItOcioyOIn KyyZyJ4mzO6p5BXKLGkwCof3xsQPprV0p6l/T5CZaKcAiu+SnOBbgX3LEYmS9s6zXjbA Fy9Y4CdfWQZeQC4Vkok7XzKG90Ix/Sj+UIXdI8EmPDjvNergZgjKw5tF2rPmqD0Qkr3t A8a6HVdncuULOS1LamCfH58cS7wyAMnkxoJkmawpl2voRHT/xqx9wcj3n35VYxWzf8k0 3fTw== X-Gm-Message-State: ABuFfogOhBdiGsQpLdWWlr3kLJHFIc7rf1h/D7dcI9oP2Jf+pp9Y3LSb W6GoTg2WZ5R4PzHeOc1YZ0B3vYToU7hH/6zdl1F8Rvcb5vMC1cTF4WDq3DSNYzpdqWAr+LjxyTY 1BfDmuWRPKaJqJPCqEiCf3NtoV6HfVLPGpcxl0MGmQux3ra0L2UJyWgbdLEAkjsBpbA== X-Received: by 2002:a17:902:7785:: with SMTP id o5-v6mr26897032pll.200.1539816272146; Wed, 17 Oct 2018 15:44:32 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Zx/0tkPxbhJ0x4sJ5DcAwEPveg4bX5lqB+ztHOEKLTL2MTywfjtEBONQZSLjhcZpYRh6y X-Received: by 2002:a17:902:7785:: with SMTP id o5-v6mr26897012pll.200.1539816271528; Wed, 17 Oct 2018 15:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816271; cv=none; d=google.com; s=arc-20160816; b=cMdGFMlqaWYaOrSuqpYF191nf06nLCfHictUrZnsbVQLpFqaqGzDNKsIsONuekmejL kava5goEPJeT2SNyjmX0xvWJpM7HN8f+m8bZs6mEZX98NpoTzigcw+BePyNaBdL97N8Q khvhI9ki51IwlnS3cAe4tlyN/WbGQTcTG5d2OENSzM1XJa6O1PaKEDaaxuqzSxFSR8kx S7ugsl9GPjbe0h3yoGOtKyPVqW/3p8bM6I3P1EBSO0M0gPT95moKxp/iUjLWcM3tN3Bo M55/EPU1DVepmKDPXOcNZvtX0/tc24e+MXsfY0A1qnAnlP85nzXcyUD1575FH+z1F9qf Jhpg== 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=KVg2E8MyusLR16nOnoPEWT6mJBhKNcUX9TTtiEpos1hrtUASxfJjuGvz9Px/8eJ4hT y/ymoKyQ9gAYVK18DoEiOvBlvf2loBb5e3E1YrQGcLvCwKoM1MjE6zlFHpFz26csD8dT u7Jjnn28lf0qoxyl5uFLDE3Qs30jOjYcbB0SeyAjiCOQ0UUf6urvUYQXMe/RvD0Vc0ch nI8NWm6sNjgj1Lk8q+1QwYzxUY0ytqR8SkacuT5QdBAITXgCYSpiKHASHQkN+0r+hF0s tg1m2uxleOcb6FPhUtJ7GcqocNPqQt/1RiyREoUNcE0fvrGPkEfR2gWhbQ3NI8/K3jSv pFzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=RArLYJOY; 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 q13-v6si18334990pgq.526.2018.10.17.15.44.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:44:31 -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=RArLYJOY; 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 w9HMiG8f189458; Wed, 17 Oct 2018 22:44: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=L870gkqD6S3aDKdn3eAOJVgjX5eONlTDEgfFmDNElAY=; b=RArLYJOYiIMZxhxHnyzcY3Md1C87caBShM3lmFw4onOS4VzfdDv4ZGywN+P9wPFRduIX ue9wgrfPhwWcr6wubJZQB+zkEyQHIrj05yfDDXfgbMfFQnPIpJ8NZNDdpSdmssaV40H8 TZ28H0IyMvYayGDZtMx6gSz84JPOjXhuVhUXAnv75CTgcRxTyFaAekoVLWXRUgiyQWzy uGliU/tn+JlNwQqq7OJM/TUV7qqA0Y6v6M2eOiN1XTOL7IIL2d7q0upsaaD8rFveFmbh y6HKp4gLg4hV1vd1QHEIco4ex/HWWU8D16NgoD4Ct0aQz8FGn3P0C44bLGlgbMMdRLLf gA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2n39brhnyj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:44:30 +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 w9HMiORQ031959 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:44:24 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMiOIN014426; Wed, 17 Oct 2018 22:44:24 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:44:23 -0700 Subject: [PATCH 01/29] 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: Wed, 17 Oct 2018 15:44:22 -0700 Message-ID: <153981626223.5568.3466392756612301245.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=775 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Wed Oct 17 22:44: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: 10646161 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 3A0C91508 for ; Wed, 17 Oct 2018 22:44:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 283D3288CA for ; Wed, 17 Oct 2018 22:44:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 18DAD288E4; Wed, 17 Oct 2018 22:44: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 43E5A288C7 for ; Wed, 17 Oct 2018 22:44:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5778C6B026D; Wed, 17 Oct 2018 18:44:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 500D56B026E; Wed, 17 Oct 2018 18:44: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 3A1A36B026F; Wed, 17 Oct 2018 18:44:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id E7CE96B026D for ; Wed, 17 Oct 2018 18:44:36 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id y73-v6so14511345pfi.16 for ; Wed, 17 Oct 2018 15:44:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=zrdKK22K4yPwdg97C40ayFoftWNqhnfImZiJAlzmShI=; b=G21M8l65LP92ZxULJBWeV3FUOggu6JN9n7ShkZpYulGHR7kt2haWKMzZ5JAPwH22bq jyLhsGiTJxvL9BY6rrlG4BlFWjT/En5JDQzbFEbTvV1lHVd5asd5/T/IjpjipoZh46m2 N+YwlsE+iuSbCdozUZaa12t0dhztwgR+2nw43ZM9YKScq1PFNowyhahTq8QAweDetbzs YbxUlTpVvlnW54leicAAtfjR6F/etXoFoSVgYY4z/yZGch+ksUs/ojBXRCjD9xpGSXoO os+Td2mhKD6NRnJ3KThrVKLEtxBsk3P/FWrU96ejH3H5qX5IWpikFqhg2klpkMYRvJld cyJQ== X-Gm-Message-State: ABuFfohF0Wd13bMjFqwkKUoVfH/CJ91lN3SOE4NaPIR1Q/bl3TC3xxT/ daPcLQ7BwujYt/EASfzQ+hXxvXIM7IZaY2HmhvhTTx3aTcB+ikDH3M9ZmyF5ZYeG9P/A3n/lJC3 aL6sXEXqCF8FHE27y8MaEuZT6kzskjnQpC+72J1EmMLdzct/pqx3QPf6F/HWNVMjDYA== X-Received: by 2002:a63:4243:: with SMTP id p64-v6mr26553087pga.127.1539816276588; Wed, 17 Oct 2018 15:44:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV63TJo5gpkBNT8LL0qv5eal+cn2+1cAabNHHLJhIYaoeI+GZsubovgyRV03sAKAZsBZQfvyh X-Received: by 2002:a63:4243:: with SMTP id p64-v6mr26553046pga.127.1539816275426; Wed, 17 Oct 2018 15:44:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816275; cv=none; d=google.com; s=arc-20160816; b=dmDHKiRCAHRQWqVOyvQb+Wv4zODVN4Avq2eeP6pUbLgag8JbMwpB0tgGFG0tItEE9r A2RmG2Qnt2QxdyDbELKSbfglqLuMvHApT0mOm08nZKt1jo7MjUc0UK7zdjCbJe1OaE01 E5X0v5IrfRIBWBuL2H5JMkN4L5B6KhoaN1GKTBZS3oUjJn3ADHHSOJCCr6BMzULzIkGd bICSGHh+k8w3DGqi7m1GYnN2krog8WuTix+ivZ37ja/8Om427NBK88v/+wItUz0KoKu4 pS0XzfjA6LXL4k8Y3MVqJXrflFsvWlriRJiPfGzECg/W/KKpLUcoNxnKLTV/5Brruvcq y5qw== 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=qLxkFkt0k49YozhhUvW49gDSqzunM3ZiCBgqK4sfe06FQe8yTZwR8Qp1QxarjIIVnu csc23RzcvYEQ3HVUrE7JcraSdi+YBjHdsIPuQ7sGKrty5cTbrtC4P4eoBCbKfWapY559 q7QryERKbgroxiM9vD1fFdVLI8NxWYxX/r2DoB3/asjpMNE38RuHZygUDqk3g62B+hkd J+1apzppHmMLHf83w4z7QCmEHHdR0ojswp5f2v9RjlVXRikB5jHy4bBTzk6gdny1Fiex HvhVIPqHpJ7OcuGeNkvU9BqElab1U/yAIGEeuceDrbzS2wH6mDbjBKjpBbtq1OznLDfK 15dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="eh/TJyQG"; 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 y2-v6si17726847pfn.26.2018.10.17.15.44.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:44:35 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="eh/TJyQG"; 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 w9HMi6BT189420; Wed, 17 Oct 2018 22:44:33 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=eh/TJyQGKztv8ZP65FBmHjCDilD69ISTZH1w2WYwMWljEsvAR3xqhnlYDq9m8kCGNqBh k5GKKwJWtJY1j3+O9muk1ORD/7b7isDahLg3KpWQ1ud/51FxzXzTU4I5rFERkefKshdF aUn4kga26aNbHhFuisE2EWpvSkGRUzatj7B5/ljKveO1B8ntYq4/vi3PqYdEd3bplszi gV8pJpvDgVqbXdqtaMTJ6JAWWSoIDbPoBKNIP0/S5d4nU+SPMEjx/PcKJvTvI7vHja9t uBTuAd0M+QSPwfdfokUYD3byxJYRfIleMLXetLPjT06Xg16E0jpvobvVyF+sSbzbogNd Cw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2n39brhnyu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:44:33 +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 w9HMiViu005601 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:44:32 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 w9HMiVVf028280; Wed, 17 Oct 2018 22:44:31 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:44:30 -0700 Subject: [PATCH 02/29] 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: Wed, 17 Oct 2018 15:44:29 -0700 Message-ID: <153981626908.5568.2941448247165011813.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=987 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Wed Oct 17 22:44: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: 10646175 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 25A3B15E2 for ; Wed, 17 Oct 2018 22:44:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14583288C7 for ; Wed, 17 Oct 2018 22:44:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 08361288FD; Wed, 17 Oct 2018 22:44:43 +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 9A71E288C7 for ; Wed, 17 Oct 2018 22:44:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A5CE56B026F; Wed, 17 Oct 2018 18:44:41 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 9E5076B0270; Wed, 17 Oct 2018 18:44:41 -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 85B2B6B0271; Wed, 17 Oct 2018 18:44:41 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by kanga.kvack.org (Postfix) with ESMTP id 447766B026F for ; Wed, 17 Oct 2018 18:44:41 -0400 (EDT) Received: by mail-pf1-f200.google.com with SMTP id h76-v6so28297987pfd.10 for ; Wed, 17 Oct 2018 15:44: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=6r7g0KcDO4x0ZJm4RBSdxfhsKMbYQWElnIgn2PkV3NQ=; b=kJWd6ibpwE2VAMC+AEQEionVyRIwWirhTN/0zK09Bkq168Z/vSY7CytBTMmYG/mWwf +FjNGPDbOwIlOsG3GA4CbnFRldbZ/tqLmrAx81m/MEphvd4M3u29eswJud6jXqDZ8GHq tf6O50lx6d0xahFKykrZQJ1CfVFMUmGw+Z2DoWJ3LfTTONUKWrLBgg5ojecoZ0jlLDJW nd27aqAl7ikXNjpm8P0EIo2vUyGMXnJs+h+FPlEZPX65Pf137OcM+b9bavI1q4nBJ8mL bx5VWWz6+hovBxNIcCjcicIxIzjny+9PvfaeNYhiXU0/crDfNH1/W1JtbMt0Nvdp0mg+ rweg== X-Gm-Message-State: ABuFfoiSCmMjnoqM2CSalmVvHy+JI5i7BzCNzyPeL/KWoNw+2jNNbffc o9X2o6RhPxQZg/iYQvsRgS5GuZIKkMO09xQYE6vVljetmkpkWZcwMxr51u4RchYTHcfnxhRiXXZ K0DjpeJcWxPDoGNIEEEcWXVORiX58PRRlFpv6MQZGT3J0fHnp5WLfKPuHup2ePOYY2w== X-Received: by 2002:aa7:83cb:: with SMTP id j11-v6mr28187125pfn.91.1539816280961; Wed, 17 Oct 2018 15:44:40 -0700 (PDT) X-Google-Smtp-Source: ACcGV610Obz/yc+cCIHIyJSabtWF6yMSdMzLsmrp254hqUmrLe9YPMcoldYWDWg38+eA7bGi9ecI X-Received: by 2002:aa7:83cb:: with SMTP id j11-v6mr28187095pfn.91.1539816280277; Wed, 17 Oct 2018 15:44:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816280; cv=none; d=google.com; s=arc-20160816; b=fIT2n2KoZIPG2mgE8l5yX6xox7yLTyojmPfFyNkMpMg+oSVNCGfxQVdWcUN2aumhce KHxlzpACVQHL6zQ/iBCIeVLGHMLZ5/SXGT9wzhA3f33BgrOzDbNhffeBzRmHY5F6HGCV 3QWkpkarOvE3Z8aX0cKDiYW0EWh4t51MFUJhbr/Zm8dEl5u3iRgViWjrRwiuUBbUgfhf fxazkdJXu30V1AbvhRqMSIsWNuEgBl6UQCsjMB/tfkUmE8YPVEfmRi6FVUvhHcxliQcF vJ9yYJsmIMf/RKV2dY7aMZ5cEfO0JPRVkm54uMasXq8Nz+aFC4k3ymC8m3Tyq7Pz1Ewh 7wZg== 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=OFTgrqVxfJLhMcNR/mFvJTpYrl3YhEg0Xk0JQNEEuaLPlx1dpsx6xMkBMHsCLW5aTI d6DThaabrYCuBeKQ0dVxaePBGMjrmf3Oqx1BWHTdBtx++FLwwIoeXJeiz9vSRQLwasSb hMhFvhVilGgharsggVD/RrLdDBh0+1a9kzbGowKnbZ16HZ9eRwXfNh9pZaThjnHyNOZR KZ9OkiTQM3fyGbdtbsFjFgeLDv2ooIUON7k0hj+33+Dxj1UwfmgdzkczbceMYUvs7p+o QVk0wSoKbqcDNb9UzT/WQ4CLLtSkDyPLd4r+oUjXdt7TsBH+W+4irZPD6erX4sEg7vaQ yqfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=FNGNbPNz; 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 c1-v6si19125447pld.107.2018.10.17.15.44.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:44:40 -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=FNGNbPNz; 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 w9HMi1fu189345; Wed, 17 Oct 2018 22:44: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=6r7g0KcDO4x0ZJm4RBSdxfhsKMbYQWElnIgn2PkV3NQ=; b=FNGNbPNzL+PSO3MkE92LNJ6BtsRlRfm0F4OuajFlHs2UrqEJwp2HmmIoaIZWJJfsNp1I LzerlI9NsrQ2ZLEtWN2TDu5V3H1XIQkRj9vgTUQ/fQ+m/6MkyJyiS56ugsuWffnE3jvk NKzTHh05uhSDAwwLjvbLhSiBN6Ac4EfIEEvRGqEi4iQ6Q9Hw23krKFnpeCu6hGTAnFTt uq1G4AzgJj5E/TdA8YVxXCL3jPBZvl9DixrhHbd6TlS41penHakBxmDS8wMA4026fItr znrg4P5iRxvW/6zleC9GA+AkNmcNg1pr7/FBzVI0zhtzqLvO96PB8r6PuFD+Ew6Z6PXb Tg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2n39brhnyy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:44:39 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMiccJ008088 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:44:38 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMib1w031348; Wed, 17 Oct 2018 22:44:37 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:44:37 -0700 Subject: [PATCH 03/29] 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: Wed, 17 Oct 2018 15:44:36 -0700 Message-ID: <153981627600.5568.16857314567554014035.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=710 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Wed Oct 17 22:44: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: 10646199 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 D26111508 for ; Wed, 17 Oct 2018 22:44:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C25CE288C7 for ; Wed, 17 Oct 2018 22:44:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4149288E4; Wed, 17 Oct 2018 22:44: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 5D24F288C7 for ; Wed, 17 Oct 2018 22:44:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 773C36B0270; Wed, 17 Oct 2018 18:44:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 74A436B0271; Wed, 17 Oct 2018 18:44:55 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EB5F6B0272; Wed, 17 Oct 2018 18:44:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 1D5D66B0270 for ; Wed, 17 Oct 2018 18:44:55 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id b7-v6so21232805pgt.10 for ; Wed, 17 Oct 2018 15:44: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=5eu3BWWTXWnKtqnmkgUDN4s2jZ2fNj7azSAvuPl2YO0=; b=kNWbhCXfARku9goijMGXWELyP+CVqyk6sBNIXw7Nxp8eZSJIMDPxnrps6k8Wi2pnE1 PtgUdZAmhToPxUuJdH7UxG+Zxqhh4kiUtXRzfWQYHCpcvHYkq9ziHOWsXAUde4NrgmpM 06XLk57RtO2DcNgQ6LXX/Kacsc6bY/lxkuCuYNFpK3zyHCF3yvF5MdIo2iN+ff/O3g4S 11E6aGHN7DfL5GwX7W9uiTymC5hR/wruDU8AmWG5KrW+X3LvGwhWTWF/4JZeFfXjnvmG Yah39IIvAWNZ22nr2YKx4MsetahvNCekMZpC7MaZLkCPR1+FQuQ3bv+hBIRLL1YYrgqt GMQw== X-Gm-Message-State: ABuFfoigL/20LVRJVFP7FfZWOMckkeoIO5+gc4OUvee7OpZz8bKyTZFH gK4YOFxANmXd9ieTX8MEN6rWvHZXakjjUZlR9BTqeXEiJON6mosbRlTTLngKuc0fQwcbj/lRb8T dxwmkOgex6loV2zkTKQIMgdEdVopNFQ5DUqBtHNehwke7JTH/OpMBNwmdV8G+NLkkAw== X-Received: by 2002:a62:1316:: with SMTP id b22-v6mr28215287pfj.37.1539816294770; Wed, 17 Oct 2018 15:44:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV616CwUqmDMZuwS4Ofi/oXyWbjiutFy6jThqjazDvUJSCGr+2mzBQorkZHEMcYrvKMHukEBD X-Received: by 2002:a62:1316:: with SMTP id b22-v6mr28215249pfj.37.1539816293917; Wed, 17 Oct 2018 15:44:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816293; cv=none; d=google.com; s=arc-20160816; b=h1eI0HxBWdUaliK+9phkGjQzidsHaLw04v0lH/N4HpD4eWrTAbhdZO7vLh5NF1RvHm /iWf5A1yIjMs3+6QLeZYw+xxe9maYohgcEIdRtRO1OR2g7DHm3+0ZreUy1QUi/xur4Xi HH84/y7xIMv+iu4jaW6iw89sUSyG1sjthyhMa2JRP90J2YlueweATCWeeG886ihLzvCU 0zKZ/Hjz1BapfTkbW27VOeddlJcYSnyp2Bw9k9OSXc80Cvt4NsAxk5gWWLlghVbgqWmf IDgXA6dcelqobIstHlh3dkRZ/mMniXovsLcRMtEuD38lBnHuUwhw+7ewit38UP1Oj0Xn ndrg== 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=5eu3BWWTXWnKtqnmkgUDN4s2jZ2fNj7azSAvuPl2YO0=; b=hTxkD+JTILgoINKD0+Lz2iHmH8fBNX5yCgpsj2JoMHteyX15+jjgsHzsWrjhtN6UQn QXz/COlyy9iSwhiguyzgKgvkfI4EoTFFPy4lPcr2aBDsIVrOkMZ2KdCoA1pjp603H+0D Gv4MD44V6AGuhlGsHiQz6Exoqja8eBXFAUsZ+hPVHNJ2FziupzDuUu4r/ZWpe+3mzTFI qq572YSimGS5giW/FlWFaEoxqH+MRTVPPyn7lI9q4Da0MttApMmTWFy+WihiCWNhnyHe 2s7KpAxRM8g6o60kI1niOYWgICW5d31LzaKX8Horw/wGf8t7G2ABs3WU3rzghaZFQLm0 y0/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=WwmaTn1d; 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 m61-v6si18599501plb.311.2018.10.17.15.44.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:44:53 -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=WwmaTn1d; 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 w9HMiHlm040228; Wed, 17 Oct 2018 22:44: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=5eu3BWWTXWnKtqnmkgUDN4s2jZ2fNj7azSAvuPl2YO0=; b=WwmaTn1d7wGPgulLsq+MVrQhXeA947jg3AohXBhAWClsPsbg503CWg9tiKUkqc6lRJbG FP05fT60N2rsWL3m2CGUQ1ck4/sJJZe71MEe0H2jYmBjGmWaAU9ukXbAnwK9MshO7RB6 noWZ3jBzlenYvhuYtzj/OsLYGuU1FuRifZgWseIpo9/ouUnEgpZwwqZMw+zQdHE0QV7d CSWR8VIJ3wUiblCd612X2NgsYC3dn+7d5y+YydC0dY6zlLh8lQMyWeiteY5x4iT5asoi VqgyPdU6CdtP6s3TtCFoJbzV3S6z5CTVqRRjT66LE8K58MpuY26OlfFRb4WXiJFL0CvS nw== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n384u9yvq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:44:51 +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 w9HMijOV000463 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:44:46 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 w9HMiiBR030974; Wed, 17 Oct 2018 22:44:45 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:44:44 -0700 Subject: [PATCH 04/29] 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: Wed, 17 Oct 2018 15:44:43 -0700 Message-ID: <153981628292.5568.2466587869276881561.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 | 91 ++++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 32 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 47e6bfd45a91..08ad210fee49 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2915,6 +2915,49 @@ struct page *read_cache_page_gfp(struct address_space *mapping, } EXPORT_SYMBOL(read_cache_page_gfp); +static int generic_access_check_limits(struct file *file, loff_t pos, + loff_t *count) +{ + struct inode *inode = file->f_mapping->host; + + /* Don't exceed the LFS limits. */ + if (unlikely(pos + *count > MAX_NON_LFS && + !(file->f_flags & O_LARGEFILE))) { + if (pos >= MAX_NON_LFS) + return -EFBIG; + *count = min(*count, (loff_t)MAX_NON_LFS - pos); + } + + /* + * Don't operate on ranges the page cache doesn't support. + * + * 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 = min(*count, inode->i_sb->s_maxbytes - pos); + return 0; +} + +static int generic_write_check_limits(struct file *file, loff_t pos, + loff_t *count) +{ + unsigned long limit = rlimit(RLIMIT_FSIZE); + + if (limit != RLIM_INFINITY) { + if (pos >= limit) { + send_sig(SIGXFSZ, current, 0); + return -EFBIG; + } + *count = min(*count, (loff_t)limit - pos); + } + + return generic_access_check_limits(file, pos, count); +} + /* * Performs necessary checks before doing a write * @@ -2926,8 +2969,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 +2979,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); - } + count = iov_iter_count(from); + ret = generic_write_check_limits(file, iocb->ki_pos, &count); + if (ret) + return ret; - /* - * 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; - - 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 +3009,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 +3033,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 Wed Oct 17 22:44: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: 10646209 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 822C23C13 for ; Wed, 17 Oct 2018 22:45:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 73B99288CA for ; Wed, 17 Oct 2018 22:45:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67F90288E7; Wed, 17 Oct 2018 22:45:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DCCF5288CA for ; Wed, 17 Oct 2018 22:45:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E29EF6B0271; Wed, 17 Oct 2018 18:44:59 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DD8FB6B0272; Wed, 17 Oct 2018 18:44:59 -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 C7CE76B0273; Wed, 17 Oct 2018 18:44:59 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 837F96B0271 for ; Wed, 17 Oct 2018 18:44:59 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id w15-v6so21249696pge.2 for ; Wed, 17 Oct 2018 15:44:59 -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=rW+gp22IhHzspMW0AKXeo+WrpQdjrufuQxy9gG9BDqsZjes2KalT4GRvZ0rCTGiKGt JERvEJ202cEkgf4P6KKKO2IVaXJUyWYiE0AAc5b1nd2tNciu4V4c6dbEej6ITBiPT3Vp DYUp/fZjXvW3g7oluM8ryxg1fu4X+dK1ytvspz/hphr9lQzSigw40oCaw/Yp0uMepx/Q BmR+td5wq/X79FobjG/YSXVwQ8vX/Q6871t3W+VzHen8btNX/HNmlJL6PaDqzuVQ68aB bOtvHwS04WUV8Gz6ZAoq12V61qzOFl7OYzi6zdBj0/7HMj8QGO7EhzwMFoYsgqniajEW fohQ== X-Gm-Message-State: ABuFfoidc6L+dhRWZ1BAvLham3bdOsoNQXLOOYnrpxLtAjKQSwFPgmmk 3N6PEpUFFbSEZsRQDjdXXBzJnq3okauJO8Pc27CNgD/5++ZpuK0sBUMIeyx3E5Og4j6cQoj9Kxu fh9LMXdI9IcjhQxzZpvtJfPyzRFxWhcjGO+hnBt+L9FEbEln77ibkG9eO1gh1RCEAlg== X-Received: by 2002:a63:5949:: with SMTP id j9-v6mr26259842pgm.210.1539816299192; Wed, 17 Oct 2018 15:44:59 -0700 (PDT) X-Google-Smtp-Source: ACcGV63iHxzvWgFkw7BUwll76gDVL7G0DR20Pveh2mu8minGf9zDQSCXKMD1BqRVIscDsAShCrXj X-Received: by 2002:a63:5949:: with SMTP id j9-v6mr26259810pgm.210.1539816298447; Wed, 17 Oct 2018 15:44:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816298; cv=none; d=google.com; s=arc-20160816; b=yZ3FqqDMnm1vhjxxqUb1Zlz+/AisJ7llM5J/OQHx8u5pP7eMXkuTKAHVNnagBCQoMR pwU0VGNLCe3mEqEP7rPNlFjBzCc1mXUUWptBI9YTEqQZtr8Gq8BLav7rMkOjrphMpbuH 3S/P8PLBI1muSh6wC+parIST8ClfyoSD+nWOf/k/HzyW0UIxSEIYO2x7ZV9rcqYBBEUN TNQ93Is25vgEVXVLa+7EyuDKQ6yB0NuWEGhXYnoQqHijYLnVtRFI9XEGA3kAZMUA3gd5 7CBmhLoSgx2eTbv5Nek6Ja8dQyyd15/+2HwrDRkydH7z1Cww8Xmxx1o265kTgTucj0mn pW1g== 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=K/pEiSZ8CaFjTK8deHX5h5SWiaQ/WM5/EmNr7tEjU0rUeNLEZ1toei17fh2vjuppN4 PfsvtfxQa8zI3sC2i0LAI6VB9K6GYjNiXrQfFDJLPq6bA9JZCa0H3zSm3iobIjx12m0O aJ2IlpgOqgNRYAkpfcHniieKHHrDnG9TdwtOE3MaWKyRooEcKWCp+/Ud1UDC8JqWVmOp JseR/7QUZ/MLjwVVFYU3BL2AnotHn9ieTAU6+Zl/NqIQPTq1NEwrJOGqdcsBjMXjNJgC OJzFHDr/f4RpI4iXTo6vJ0RqTuyuz6/Egqh+HpNAbdVz0h4QIm7NqX/sWelx2yD+ZYaN 4N7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=lOoM4rN5; 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 a8-v6si18377894pgm.331.2018.10.17.15.44.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:44:58 -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=lOoM4rN5; 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 w9HMiWfv040580; Wed, 17 Oct 2018 22:44:57 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=lOoM4rN589fci7BOye8ix6pMQcE6KdksRa2Vti6deEuen1Gw4n8qbt90Dpykir13UikE LKy3fXLal5Oldz0ztrMCIx3hSA9wgL/A0oPB18ZjhQ9DTLTDfRbJ66hiOJb5cQzYoq8l /g9lLpHY4vaneJprNdEgdprWh2iY7yKUD8Amvvt4r/FmTUQRg7vWhLCGjbKeigCawI+q 5gRXmV4TZrORc1B+8GFG4s9GqVUDUS8h42Y5IHYYiAImaXhCtzcJqZ3+pz+hAqXPPwN9 Yb1fSGyI4LLWy4uTdzBeDFGpsSxzs+U423q3a1s8/zutvjeJkSgTin5kIberMNti//4v Tg== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n384u9yw1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:44:57 +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 w9HMip3x000659 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:44:51 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMipBk014640; Wed, 17 Oct 2018 22:44:51 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:44:51 -0700 Subject: [PATCH 05/29] 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: Wed, 17 Oct 2018 15:44:49 -0700 Message-ID: <153981628984.5568.13713064343145585532.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=793 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Wed Oct 17 22:44:56 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: 10646213 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 CAEEC15E2 for ; Wed, 17 Oct 2018 22:45:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB820288C7 for ; Wed, 17 Oct 2018 22:45:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC9DC288E7; Wed, 17 Oct 2018 22:45:04 +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 5068A288C7 for ; Wed, 17 Oct 2018 22:45:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 17FA26B0272; Wed, 17 Oct 2018 18:45:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 0E2AD6B0273; Wed, 17 Oct 2018 18:45: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 EC4D36B0274; Wed, 17 Oct 2018 18:45:02 -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 BA9AC6B0273 for ; Wed, 17 Oct 2018 18:45:02 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id y40-v6so15942825ybi.2 for ; Wed, 17 Oct 2018 15:45:02 -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=KdM3/fz1PvjVHA34XCNZor2wNp8vf8NxUQdBjs2vBT4Em/n5os81AJLDrmZWEVuhMc 9qeSulrcZhsAF7W2p2Jzdknh4h3GQWwReDoM2uSeMaO8+rv+41xS/RuqMP9Y32iMZZB1 1dvW7NOHUXMNspXgDwClG7DTxabPm9r4Yth4z/+EmE4/9O0sOMxMJ8BBZBHOL17CeIDQ MdPr6YFfJTmcCC6tdS28Ef8Tp2Bl23Q/c36B2bfIjLomC6Eu07Y7d30eAUw1YopudIbL sIeqCRQvbNIo6vSr+23OrnAyb0vuYQpqe715sY6220/zMf9d0oIzhYdKZYcUXsY+E561 gXBg== X-Gm-Message-State: ABuFfog/KyLXqesrvkSH2lGTfvq4ZB5VwctnwK1zXxHivPk6RxpxpNuy ZnD/0yjeiKyXYE7B7MIPPolo/igDQfzkl6a5g/o/yhxD7k52CpHebeEPuvc5iy7Ss6CwHifWQZF Mh2/lVfzLko9fhgZ+LHdbuq6gBQ9cRWWRXggbt3DIwgL00ztsit+car/TMPuA2cqFLA== X-Received: by 2002:a5b:7c2:: with SMTP id t2-v6mr1755977ybq.212.1539816302425; Wed, 17 Oct 2018 15:45:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV60Sr/rk7d5duzBybIK4CxRM0JnlK8VYIU0WbNIDnp2ih4V3lk5Q0PkeOha2cqwMTin1lU5Q X-Received: by 2002:a5b:7c2:: with SMTP id t2-v6mr1755954ybq.212.1539816301852; Wed, 17 Oct 2018 15:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816301; cv=none; d=google.com; s=arc-20160816; b=cwgrjpsa5o0KHLjQXCPmbK2R7c0HXDxpCzh6jOst1WW9k1+Xc+qzHN+8IDBqwfZiWo J7VCVATkcCUh3/BiSHelYWM0YpoIu5g8LHeS9Tfz0q6NC6vF+7jILrVkKHVygrn3UMYg rdXlPCdixRLgxDPlsdPJcgy5biKeiMig74XXLPVzQs2EZglNMOp2KmY0XZkLlA0ukxOY FB16QB9unKwIIny61SS822qodaBHExeyWrIdudRPI5fcc7WtREJ8izxP5Gy2xccCpfDX RzILZiLfWOVnN9S1O3b9smuujo5owXQeqHsQzTBfEq4z7yBDVM6xFMgavcr4HaZ+7f6h ptYQ== 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=f39+QAJi32v5nJKIHEy0BjdLT/wLeh0ohgqLo1PJKDMLUmkqRvfZl/1offG+jZS19L AXL1xW157Ghp3/Xft7mPn1oDaq6NoAffmMTA7KNl9MDaglcFduhn98HPadfBx+6O2xed Z2DxRLGH8rpxZG/z176esgMsdJEuv05/KwHoRgsdDI7bL3F6SCEF3bYjUw0j25Ptk3yK rNYoqyFO0aAC0+cEq3jznIQO9nUk5VypYHzrq/Os2/yG/ZxXoHbwVP7AI2rVaPFHsZQZ j60EFF9jpfze1A/sK14QpLg9wYiUOdq45A9zWL4aGLFRtXZAPwJQCHUyGctXt7pErvnS duJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=PpxfeYre; 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 t82-v6si6760204yba.96.2018.10.17.15.45.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:45:01 -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=PpxfeYre; 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 w9HMiAUC048830; Wed, 17 Oct 2018 22:45: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=DsB/GfHe8rY/6K9TRDqJFG41++LpUZSoAdzvXmeEYVk=; b=PpxfeYreEHqJ6vcORlZ7iIwVkK/qS8IqoNykPQqre69vtU4Xd3mMLGx73BLRXmhUj9yE bl5c1Zx7soRvcZCcUcIQMnE2d+KFLETNzE4pOv08JEQpQf/oHVRBlnbCp5S7005rk94+ jZbVYPaCT581APqiBmea6ZvLOALtEaVAPCXC1qMMiQSSr3HdBswEoGShXjh9gfiiUcUo /GHq3rrjiXKeak9arZrBjWtjMwkMWw6lGuXzOJbUdGw4SuXR/V6cXduazKzmcFA1UllG gCb1qV5B6TddpFw8dHzbdWy4YDxiW04Wxk0+Eu46plkevvvy0jch+urulROVmNFrWl4U AA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2n38nq9srq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:00 +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 w9HMixj7006278 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:44:59 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMiwrN028452; Wed, 17 Oct 2018 22:44:58 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:44:58 -0700 Subject: [PATCH 06/29] 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: Wed, 17 Oct 2018 15:44:56 -0700 Message-ID: <153981629660.5568.10517610908803733732.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=754 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Wed Oct 17 22:45:03 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: 10646235 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 88300157A for ; Wed, 17 Oct 2018 22:45:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7920C288C7 for ; Wed, 17 Oct 2018 22:45:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6D6F4288E4; Wed, 17 Oct 2018 22:45: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 E7590288C7 for ; Wed, 17 Oct 2018 22:45:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BC6C6B0274; Wed, 17 Oct 2018 18:45:15 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 06AF36B0275; Wed, 17 Oct 2018 18:45: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 E29276B0276; Wed, 17 Oct 2018 18:45:14 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 9D46F6B0274 for ; Wed, 17 Oct 2018 18:45:14 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id 127-v6so92071pgb.7 for ; Wed, 17 Oct 2018 15:45: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=EVBOjpjVeZ0uqv5Ytj51D02SOvbvYZvIxgFPH2/97ks=; b=WST9Xh9Tuedea+7M9jheALjzZcOCv8IHcXzW6gPTDTI26VTPr/sNhS80gdhvblbZCi xU/G3rH9xVOuBRvtVxYKPL1EGpM7DaiTbHM8g8ZUJcxLmDrRlmX4thZhbC1rN1Ux6Gmh 8nJo2njo2CPHU7Xg1ZfouhzgwH6or4+vIhXU74JY4vU3Pvme3Sa8Ir8s5+FAjEtmYaqG ERpl0kj8pc3qn/nRzGqgpAwEN2MEmYByWWyC7nR2oOcKeWqiJz0YM//YGGY62B5ttSbx hXKF47dxSpuc5ur0kn1FewzjLuvRCrZPSAYP11YMrqj7Rjk0Hu/vH+m9anjJ0lTvjghe AcOA== X-Gm-Message-State: ABuFfoj/HPAmAy95CtFPw0vOafqncvBGYXLYS3W51qIxyTeR557CUIZY Y2lYb/VKZiRAZRGfW3QGpmW+6qYwDqHjI9QZea46VGflExJHqpMYIAiTYLB6DNDF5uvNDsndilJ EXkBsf4pRTQVOCSzTVXib812WdsIO8CxzR1NDe6JFbT3gvBt2KZcnCFhjfwpfdks7/Q== X-Received: by 2002:a62:c502:: with SMTP id j2-v6mr28872156pfg.194.1539816314310; Wed, 17 Oct 2018 15:45:14 -0700 (PDT) X-Google-Smtp-Source: ACcGV63+SmQRnt9TPpTY8fRMQ9tWzaO76URObZ6qjWjd1PXkUAtLO6F5lHvNNG0frijU+VMYDURl X-Received: by 2002:a62:c502:: with SMTP id j2-v6mr28872109pfg.194.1539816313378; Wed, 17 Oct 2018 15:45:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816313; cv=none; d=google.com; s=arc-20160816; b=IwASlibnWsUU66brtiwrDwwk6/VCqrfj8KnMLbx0FtBgkB+STBGWvSdGmQZnJuCnxX LvEebxw7BWaxvDbdaCBMdg7myZZlyU/Yi8EZyg06oBGKnO2/x6enTKMUa5n4X/5fAQW1 gCNO6GugCEL5b/qRDDvHEA7u/hfKZijBTuw8U7Aq1CTnGNaggzzW4noV2PBGoi+9c9wl zC9jY3L2+caSmjem8En8o/YjSWnZnPVM+AhIsnHMCTPdh73+rAwvA6FR/ZhDT4iyrAH2 5ggVZLRkgLkXzcvyO2fStIKwwbD8+v9ZiVjAcj9OZp7Ys6FuYdQ/jANKP6W/EUUZUuEU 5C2A== 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=W26QvWJpiqfpjmd4l1tUgV/kdxT6wPk1W5c07EEF3bySJ2tb+4zjmzyYgSV/nVxpkT NWXgWDOsAkALDb2p1mDLu2pYLaocRNUTk8iPMZmxJSAGA2PhfDKr1KBEdxyDjjDd349f rR0c/sdKSsOspS1no/r7x3Ng+ehputze0AN416/g5w4yNAQPPN+g+dJ61GxMI93Q9W13 VWiZHfRZFstaIdybDDAhvVAV+Vst3v9JY4mBb5gZOf0FLdXNzv9o4f9h25nz2gPEbBHo 9mJN5T80dPEX4xpAMfsC3BAdb9aJc+4v1Eime/D1uCFMmYQC99FYC0qhmbxXV9BA8PeQ Zkaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=xC+PVhCV; 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 20-v6si18579995pfk.287.2018.10.17.15.45.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:45:13 -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=xC+PVhCV; 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 w9HMhlJY040059; Wed, 17 Oct 2018 22:45: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=EVBOjpjVeZ0uqv5Ytj51D02SOvbvYZvIxgFPH2/97ks=; b=xC+PVhCV2MUkoCriIdCTKjieFycCSlQ45RgvqEaWIXaQ2wNgkFqI/WURC6boEo8PeY9z uNzBprCxbKBWLJB+qVc5BDXluCEyunTE0FZtN6RydvxsPAhtYCatnA2SK4Rxk/UTY8Cv 2Zy3D2y9WDokefKWu2fF4/RsAl3ixgAOGUm1dcqpj9Qq6cyr8sViGrj++/mwQ7HhR+AE gveqdG6PiDNIyR++6EMlSG+kDIwBO7Z8Zy53G5iD+p24wWlIPD+Uk00rPyK1VlRCHSYc 6/X8+Oq5SIuC/sK/XCAhZMJolslhxwZNGRE0//RNYRCWuITppm598E3QeuDK2n+bkKLS Hw== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2n384u9yx0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:11 +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 w9HMj5MQ011933 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:05 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMj5ei031599; Wed, 17 Oct 2018 22:45:05 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:45:05 -0700 Subject: [PATCH 07/29] 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: Wed, 17 Oct 2018 15:45:03 -0700 Message-ID: <153981630347.5568.10618491872993138395.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=750 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Wed Oct 17 22:45: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: 10646243 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 F0672157A for ; Wed, 17 Oct 2018 22:45:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E19E7288C7 for ; Wed, 17 Oct 2018 22:45:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D56F5288F8; Wed, 17 Oct 2018 22:45: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 70CE2288C7 for ; Wed, 17 Oct 2018 22:45:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA7DB6B0275; Wed, 17 Oct 2018 18:45:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C2EC16B0277; Wed, 17 Oct 2018 18:45: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 A80346B0278; Wed, 17 Oct 2018 18:45:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id 605116B0275 for ; Wed, 17 Oct 2018 18:45:16 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id v88-v6so28415378pfk.19 for ; Wed, 17 Oct 2018 15:45: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=lbgR3wOuOLZGLL8/c8R4UCc54EWHiKBjm/iFOf5M+sk=; b=ubVWP/WPtiUS8mf3LZX4usL0O6ISRabDaqHhRZ8Zx9bXEdVXJyu87v2pPgMJTpcS/s nFT2iaf78Nn+6/QnOKq72Pfd6IzZ/HEKX9QVhxdWYSMp5yZjfnfid0/tWbIMASqKzf/T +rxz8Q9i5cUJ85CI7TM3kj0JzZHZPR/PjT+PModQV7jRLsXI/pHzrxfDza8Vuxh9ZUTK KLgXU1M+ao4jXsVXe9XzElP4fJt669xDKSsKXwUTJ4I3k1MbprFxFvUKTAhsrfSbGcYv U8t2cj7UZKkzS6DOqH+cSw/NS2K3diHEBASbEwF0xXfFjwlN3b/xXvNdQ36RCgvEAtdi jU5Q== X-Gm-Message-State: ABuFfohIHQBcN/Sf2hgEZSJUcPxCr0zMUOc61EHtAzfGzYxZC5hWdC59 nICs3seeYxI1BxSSElnGdfyLvzwdTwWdblIDYRwi9J/x0BBBOzcju9efai5tD4xdr5SrvN4aIf8 cr19BxErW4ik9YQhD7u4zvTMCtBxRyp/bB+e4/FRw+2igXTOLGuoklMO4HIgENti4Fg== X-Received: by 2002:a17:902:f203:: with SMTP id gn3mr26504867plb.93.1539816316083; Wed, 17 Oct 2018 15:45:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV60RMLXllv0YlwztXdPdmDmJwqohv5uFgQHS5EwIMKGzDyYFyAWimvxuj0gTdPhFzw4y9Klg X-Received: by 2002:a17:902:f203:: with SMTP id gn3mr26504837plb.93.1539816315432; Wed, 17 Oct 2018 15:45:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816315; cv=none; d=google.com; s=arc-20160816; b=WaV73XEkUAs6KU5nuj5F8m3pbnWpB8iNlcTClD664Yd68qoozZw4BvP4Sl3X92ESLu dFgPtuh5499AKWcrarzCcDqmQ8GAhqjQ+4WjDp5KyXO3J04EY0XueI6oImiGzL0+ScSw /esj86A8UqFRv3a2mkbAEL1F1LTLMiUVEFIRAglw3fK77a0huhRAP4IlmNMbeah1Jxv+ leYujXRNLDXCLiUFuEsUiiwCZrwhzlhzt68sTuUFEkdQePB7y2sHf3udiGJfqNNkwDtG 4/MZSoM8kFVwuWOxn9Dmg4ZWvtwfhkWVDYSwOXw1OV4wEgQ0wiAefndc/aWfxD1ur+mm NWxA== 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=lEgDL1nJ4H+CQJOVmMUlMW02mJ6Vmq1WdmWD0XYW9cq+uoCSd/0etqXFkYceVZfji+ lCZWDZTK0+80g2CxfhaA/N7VYuhKRv2nNDhQ9OQPtLBSNGpYfP18riLzTBTHZXlTmZrw 55cQnStSnJVziZulqxy+dCBDpfyJCM1K234bKfbPPuwXPvX/IYGLosLdFAtCUfe4UEDx HdX0OV45kUfeBOGwvN/eM1mkfDHcPZQHgcpHAEUoGXXdZ1OqZzoy2kTilZEDvJNfQ01W +neyjdc3+4ar2LSmEtN46utmEiNJ+5qPypoy+eAPRcHaOSQlJ7rTORzTW57AAYg/hGEe smcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=a0WQ4eNp; 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 e3-v6si2517531plk.215.2018.10.17.15.45.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:45:15 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) client-ip=156.151.31.86; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=a0WQ4eNp; 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 w9HMiGVa040211; Wed, 17 Oct 2018 22:45: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=lbgR3wOuOLZGLL8/c8R4UCc54EWHiKBjm/iFOf5M+sk=; b=a0WQ4eNpPV039yem0kQR1DYG4bktBk8YqILWNlveUzMisQBxCkkf1s6909UG3Tzg2eyp p0mbi1m9GTiLsGNIU4265KRt3hPIFlmIdLvnATM/SiIM5MFh9mka1YYCKxjXWrYnziUg ONHRSYh8OUvyHRgOzPqczLCZ1Y8lMqroEzF6fUsTP+spSBFGksjm+v/FWuQf2RAFeXuT VySIebyEKSwIaxCCa59W/Bk2k0GPyrLF9wTAB/wAfPOVC7ZtzvwfBj8Fc4MvAVwpzFsn YpIserfWD9WaOvEjIs8Zddosprp8qnXsZv0KpYTBBdOfn+Z0dP9BO3zJ9Zk1xBOOEcqq 0w== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2n384u9yx5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:13 +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 w9HMjCBa012260 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:12 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 w9HMjClM014843; Wed, 17 Oct 2018 22:45:12 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:45:11 -0700 Subject: [PATCH 08/29] 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: Wed, 17 Oct 2018 15:45:10 -0700 Message-ID: <153981631026.5568.8290637209446807642.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=710 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Since 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 Wed Oct 17 22:45: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: 10646261 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 43CDD15E2 for ; Wed, 17 Oct 2018 22:45:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 328F5288C7 for ; Wed, 17 Oct 2018 22:45:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26A88288E4; Wed, 17 Oct 2018 22:45:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2A48288C7 for ; Wed, 17 Oct 2018 22:45:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 997656B0278; Wed, 17 Oct 2018 18:45:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 91D7C6B0279; Wed, 17 Oct 2018 18:45: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 7BFF06B027A; Wed, 17 Oct 2018 18:45:25 -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 3AC6A6B0278 for ; Wed, 17 Oct 2018 18:45:25 -0400 (EDT) Received: by mail-yb1-f200.google.com with SMTP id n8-v6so15106129yba.13 for ; Wed, 17 Oct 2018 15:45: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=PID3dHGKshLXa4/RFi8zcppDdatKxDr5U/pSv5qD8LA=; b=rQtH2X8ooZjdql5E4aoMV22J0K83opwr8M1PwWFD8Z3M4X/va/H6u7ZK6GQOPFkRNh SrsCkAcJ+0kI/jYnKO1zywpivjkDwY4CeTaNZMtvtfwHH/XD4F6ShVlPIFY3N0LSGwyO 4USczcmFbvCCsQ1WcrBceUiXc2LAZYjeIvYLHUdbpeXQd8mF3tG8EGIwXArcnxn8Onfl F7hKUcME1hSL3ybCTowdZVx9oq5t+oyBWkJcJuJTmZm2WI7ztv+eHkyXIY1ckGyES0U4 tg2f/YyQPXA8phgsIXWjnJKsgT5MTRgtEZwCHMIIIJ9cwH/uOuacZqCVfwrnN20rvSb+ /ROw== X-Gm-Message-State: ABuFfojTbX2jfZI+P1F0AEgtTMc6mVgguIuTFroHo6NindKttgGLp49q +vLWmM8RrDQ8tzZWvnPg2Ow98DUXLDEdUhRTKQ8UcRSDUQNVIm6fKvdCONa3p3XhWU1QxbtavmI 5Jn/kbXl4jSCVsRmcrWbi5IW8R/c5/VBQ0TtNT+WRG8Q/YPTt/l43djduqn5HR2Tg6A== X-Received: by 2002:a81:5505:: with SMTP id j5-v6mr16604734ywb.186.1539816324924; Wed, 17 Oct 2018 15:45:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV62LPXgz9ljZScz6X/vpRDGpUoHC6sLyoS/fLGd1CcITLIq566fYR4L8a/ueQMuwXsJqEnWm X-Received: by 2002:a81:5505:: with SMTP id j5-v6mr16604675ywb.186.1539816323459; Wed, 17 Oct 2018 15:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816323; cv=none; d=google.com; s=arc-20160816; b=bsOL/XovQVmO5TA9wBeDVKqhFgWveNtvHGKXx/EhNuSucq7CG4Mk0u7xIp8DAHk6ue Qk/I7yGSeam7eRnGMz7MKlkkOYkMoRw1ugRiS5BGcJPCmzgkBVPjPYCw9PwwpEDHr9ks y3WsankIJ2AUI52xxgZhdN2paE9PXrkvESrM1wwjs3b7EblPTqNNcu/O9VF/px7h0UHt qLJR1/MoVK+LhnVllz40SnFctW2c3/Hil2FzJpL491WJgd8Swy7Yphg8XHlsk2RGAreU sjpVi+lWYnm+Fviw2uvbSsOdcG+6dFvNVlU7C5XhEU+7KhTzgaSC4mYqgzjSdrkwRw7s mIWA== 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=PID3dHGKshLXa4/RFi8zcppDdatKxDr5U/pSv5qD8LA=; b=J5+ziBRTwVu5QyM58vWyLbY1ksGkGEKdy+/KvHn9ZWAh/rHl84AE6HRYqO99BtGYwm qdzOfMTtgLxN+aGVQ06nLBxKP+RNWi+YcrdHdQSneKr2bfhczMHP6gYZicQWSkxeaup9 qxeM+C5GEm+jxz/Vr9ho4Td7nSBsOB8TvjIHt/gDyOS5rGYlCtWe5S+6dV9SRzq6yDmr vZrnKldzU/wRPrxJqDZEZ4GJdR93VMiWDA/NegPA2WnXj0ucFnbl+8r2pUP4UaoZ87If 8G5GelV8me5bAMwTkdPVb7ZT7BlH3Xz/U8XiIc5VmZ4C9KrLusxrgWIl0nAzFuSsP25/ gfug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=vDRNPfYS; 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 s9-v6si6674424ybg.344.2018.10.17.15.45.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:45: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=vDRNPfYS; 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 w9HMhuI1048513; Wed, 17 Oct 2018 22:45: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=PID3dHGKshLXa4/RFi8zcppDdatKxDr5U/pSv5qD8LA=; b=vDRNPfYSUOWcyfoxz1EUgujPU7dVSKnjBNhSOTP1q5yFWQRHWl1zATy+r99JD2gUJE2Q 9jAKvQm83dkZzBtzscwcNqBanl7ELD5W7Y8UX84fF5BHjUen1rh88+2/P292zhqP53Cn Mx41dGmuJEkn7odcOWN9VMyPPzG7pMcR5ikneeB0HMKZK/bq8ExqkoaVxKL8AUXbbBrf cSYmBxs0ht6RIlMZPCeqXW3JNt5nLmhTOxaFinMcZ76j7ZQVILLNtwsb35tZmOMSOzKa +oW88cQHVPf+qRvtdi6kSsLL3j0vDLJ/vmzVub5iJfM9nIeqbf7bb5q4TnDCYiToIGwu 7Q== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2n38nq9st3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:20 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMjJiI009590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:19 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMjJww031666; Wed, 17 Oct 2018 22:45:19 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:45:18 -0700 Subject: [PATCH 09/29] 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: Wed, 17 Oct 2018 15:45:17 -0700 Message-ID: <153981631706.5568.6473120432728396978.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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/vfs.txt | 13 +++++------ 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 | 20 +++++++++++++--- 11 files changed, 110 insertions(+), 106 deletions(-) diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index a6c6a8af48a2..bb3183334ab9 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,9 @@ 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. Note that + a zero length implies "remap to end of source file". 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..177b0402b65d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1721,6 +1721,19 @@ 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". + * + * REMAP_FILE_DEDUP: only remap if contents identical (i.e. deduplicate) + */ +#define REMAP_FILE_DEDUP (1 << 0) + +/* + * These flags should be taken care of by the implementation (possibly using + * vfs helpers) but can be ignored by the implementation. + */ +#define REMAP_FILE_ADVISORY (0) struct iov_iter; @@ -1759,10 +1772,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 Wed Oct 17 22:45:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10646265 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 360D2181D for ; Wed, 17 Oct 2018 22:45:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2770C288C7 for ; Wed, 17 Oct 2018 22:45:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B54D288F8; Wed, 17 Oct 2018 22:45:33 +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 2A854288E4 for ; Wed, 17 Oct 2018 22:45:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DDA0F6B027A; Wed, 17 Oct 2018 18:45:30 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D8A316B027B; Wed, 17 Oct 2018 18:45:30 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C08A26B027C; Wed, 17 Oct 2018 18:45:30 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 7906B6B027A for ; Wed, 17 Oct 2018 18:45:30 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id s15-v6so21339113pgv.9 for ; Wed, 17 Oct 2018 15:45:30 -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=e1FSvIn/7jOJf3BF8yqOlwWFBW7i7PM3su6IsEDOKqk=; b=iS4HxPB9Ii9bPp2zkNaidvamOwOhAfYXUbXHc9yVJPyjC4SDNi3NTxTvw2myz0VbME lIuzAyqjSR9vOnDApLECK4HcmIfCj1wPbY1Z3KrO892pLgxjEgowY6MltN0+MJbJ6QtT ctRiBALPNSWztyKIOtUCTwdiAVZFSqUKQ4waEhygvr3XsQr1hz4IcIJyieeHuRQW9JBj MkiKoNIBpwYghzAg+/1FwSr78Gur3LN3Dm0qBtYfLOxB4ZjmHdh/Z4A3lgqhGH2GWamO IiKsHnGzHK5KnYBccF13iiRzZluZJ97h9aJ1HZFcj1Iz3di2KPl3dTiK6JBWIJQvK3U2 BEeg== X-Gm-Message-State: ABuFfoiztPnhBNH2LIdMwtFo7Tw8YsNhNKyy0z7CAA8WM43ka7IyqwsV 8FIQu9NEw+NZJl/xf5cCjOLwQs0t8UMT6qj8ZmIj9UF3VdQy6doJCfVFWhJy1vj8q3hyRxdEY4E WxhoPof9X+D7vVJIsYjZEX5VfN6XQ+gu0v+wr3vZRdsGun4sm0E7AkwDv422ZCHrwng== X-Received: by 2002:a63:3e06:: with SMTP id l6-v6mr24659343pga.96.1539816330084; Wed, 17 Oct 2018 15:45:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV60uP0LMY/a8WVvY96mErun5wDLiTwXplRjR2bfexIqdptVOgCtwcp/JNBrE//OmCYL7iwcx X-Received: by 2002:a63:3e06:: with SMTP id l6-v6mr24659308pga.96.1539816329130; Wed, 17 Oct 2018 15:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816329; cv=none; d=google.com; s=arc-20160816; b=CkbLdNaVqRlLgZ88Wt9NVRjWzsMOuXofFecbLAU3BH3E+nhnHbE3GgMjg0D3kVNJJ+ ULRiLnN3LgnxePKiAsXeN1fHuDCU9FbdXSat1Z5gEvbLr8MtxN1pVg/qmzmMIFlvCqb8 DARNFhMEXrQzg6xVuRgEFe7cNaLKZ7uta3W2+En8rB2klqEUg8S2QfyAB5ETA4AdfnvQ 544j3WPV8euMcI667425yWcLSIVEDv43Y86+tl1frjczaBkrYYAKHXwSNBGEf4MWnQjb k2NnGJXwB2n+dUJkXuCLw+oBiF4CzhstNEPmwDyooevNSgvJMojufrSrv0zBjUk3ZiEC XqJQ== 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=e1FSvIn/7jOJf3BF8yqOlwWFBW7i7PM3su6IsEDOKqk=; b=lkCAaC7lg/HhxxWq0iW3XQVL1B+VaAs4pu0Le5jA35vL0heRV8V5daTB2N8vVT+/Lu GJ3GAxaPycjuNWg9/g2vqQxKaU1vIDjA4DKVoodIpnO/FdhVk7ROjdrN4xeOH1IloJ82 bkVIMWIeM3Cdz+yb9NuY16No7VdqmdtSd1vPIrX8sLFb5q+Zzye7BwLT66umdd4XXGgY nErURrdiaGgwxtaYH/Vf4HRBBOB6BN3BQd2KRSIn6+T5GbZl13SnmI9VnToZjMfLkLMB E8B8vVij7qDMt2j09wSqm4h9ThX8Y9YPvcUOuF/Ayn9jR7pO4zVQwAUr/vVhiTM7rCu5 3GZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=KwggdmBv; 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 e36-v6si4056701pgm.95.2018.10.17.15.45.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:45:29 -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=KwggdmBv; 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 w9HMhxLM040110; Wed, 17 Oct 2018 22:45:27 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=e1FSvIn/7jOJf3BF8yqOlwWFBW7i7PM3su6IsEDOKqk=; b=KwggdmBv4HmAuxXAL/uBfw97eEvbX02iEHtp7Hh4Fy6APaIG68cbMeNLFyqazGcGzcXn I4PFDfkPtipd2FGjAU1mSuKQLhkeaVvAEqFPIJkUtYnaVo/cQVYqvjCYT1nHTcGUzUY9 e/bQIikycylPnmogK+KBM4QoSKyLPQlTaLq0/Iv23nFbwfNlW0FlMbgbcYDo7k3tZA6j lPfGLsxbDljfFd85NfG3idO5cxLKrNGLpNHfKqyfWFFojAKQleav+4D+FJUTuIZjU2Pj ICtKkrFGoEL9GX7sih4RXoF1Egph41rX/EL8cxsEaoOiNzS0JFyEsHpVBSzShBBga6o5 CA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n384u9yy8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:27 +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 w9HMjQxZ002934 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:26 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMjQlW014889; Wed, 17 Oct 2018 22:45:26 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:45:25 -0700 Subject: [PATCH 10/29] 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: Wed, 17 Oct 2018 15:45:24 -0700 Message-ID: <153981632414.5568.10603680991855102023.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 177b0402b65d..ecdfcb8b15ff 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1839,7 +1839,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 Wed Oct 17 22:45:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10646291 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 3044015E2 for ; Wed, 17 Oct 2018 22:45:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20E88288C7 for ; Wed, 17 Oct 2018 22:45:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 157C5288E7; Wed, 17 Oct 2018 22:45: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 7F785288C7 for ; Wed, 17 Oct 2018 22:45:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43DF76B027D; Wed, 17 Oct 2018 18:45:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3EE456B027E; Wed, 17 Oct 2018 18:45:36 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2B6E76B027F; Wed, 17 Oct 2018 18:45:36 -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 E98226B027D for ; Wed, 17 Oct 2018 18:45:35 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id z8-v6so15653150ybo.17 for ; Wed, 17 Oct 2018 15:45:35 -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=OAmrVIXZc2CEqsPGpMLoE9bdmYA/ls2wwpsz5LDZp+Q=; b=UJgqzbUjDSLrtnijTb6TOSJm2dbNNQgAtdgquBdnVBABBWrahBN60iD4/BeEgIgoeI kqSXYBHlouTx6C5z6BXCPMmrtRPdb5FiZBsGYlnTbkrgvWRdl7WRfa5sLmzSen9JAQLm 352h7nnkQRQWau1DPO6j81W5R4GJaksJafoC/heQZVBlKNFTeo9JwXkopJt6g4DON1BZ w8U/ZRG3odu0LQJTZl9WOiCdc0xyUrV28F7wkLA296w2Sijsbciy3FARJT6n6OOTdYGz OIvWLmeav4k6KkTZ7tUqK9whka3kciGj3BFnd+FX+w/2SNOdcYEfLtui6hQSdkWIoSL+ ferg== X-Gm-Message-State: ABuFfoiOj1YD+NpPncEy7A8EpytRtLKtu2hzvhsWoGEs/zvKkLQIegFX Pe2SKnyyHddCPhN3xubUlxWeCtO7H1M8Z9lQRYfkJydLxI56400w0LJE/BAJ5QVhkly+AQo4Amo SWyyKdEgG6bIWtDkscvT/HWqMrIEXSxI0x3tl247TUkIO6H7eNaf6LNOlw+HoMnfjfA== X-Received: by 2002:a0d:e18c:: with SMTP id k134-v6mr15705354ywe.314.1539816335709; Wed, 17 Oct 2018 15:45:35 -0700 (PDT) X-Google-Smtp-Source: ACcGV60WieTiKuFsfk+Cs2LeHmc/AjdV7kcCgggbFtu2zc8XO9E36KoWUkfKLxTYsYufj5T9bJOe X-Received: by 2002:a0d:e18c:: with SMTP id k134-v6mr15705333ywe.314.1539816335131; Wed, 17 Oct 2018 15:45:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816335; cv=none; d=google.com; s=arc-20160816; b=FL4F4JziwUYHX8ZOjsR+sv1f5h8yPFaCzhoHd9nF9OqkAolWvEW8P35WF71tu7nUe1 ccYDKLgXvsedHDee7kqz4xOMaSULtnmP/4UVS2cYVgnU10/b3krvCZPP6BcCNgiAWyuv Zho4P4cj2w4vMQINxztYAqlMkgOgdeH07NLERnkDNIQUDvqUZ1+8H1lAcah/ytpnCJSG jNZ4uS+4KPSTUcmnPgZBZDjLOoaK2OuqTqg9r27T05JxIsRObAiTHAGVi4YD12eOsX6u pwtAXMnebfviDL5AHsWJmq336r1IYOXjMn8hcm2PzkW6Ju8ZJ64p0EIehCK1OPW5LUg0 gPWA== 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=OAmrVIXZc2CEqsPGpMLoE9bdmYA/ls2wwpsz5LDZp+Q=; b=W+qY2c71bTDQWDznnqIx01hXQL3eHrfKeaT7d76PGVgOqv57S3FPGNd+4JN+D49HLR 7uvDxu8eGwh89wpejPm/Tce0iWt1b9acqGXoVTZ+QqUyjWJtsODC/8Yh+6c9bZ22pi1G TM33iXuVN1SK4x4JTnUwXIOa3zE11R6/CLmARYSy2tvtl+f3FhorkIxaaF8nT80/d9s6 WNPCWdX0SnRbPblE3vGIC2Z1j84xSVRT+vJyMLegCwtrx2RIR9DTUH2pdDZoTlgcoU93 hfInTA2tZBO9tyB726mUokfTUqCRq+8Q2vkzFxziTbsUxtQsPH/o9pi/tYgC7y9Obqy7 rJpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=d5+Xdicg; spf=pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from aserp2120.oracle.com (aserp2120.oracle.com. [141.146.126.78]) by mx.google.com with ESMTPS id o5-v6si6934269ywf.320.2018.10.17.15.45.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:45:35 -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=d5+Xdicg; 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 w9HMhuI5048513; Wed, 17 Oct 2018 22:45:33 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=OAmrVIXZc2CEqsPGpMLoE9bdmYA/ls2wwpsz5LDZp+Q=; b=d5+XdicglkEpvelN18WVtSxT6qcC7XHaFMI2C+b89CIH3Wq3CHUMaC4sDRMTpiz4BERT DoYQWCNgwdLyaduBojLLKnw9sSb4Z6o1qyY2K2hqcGJ7L9jbGa3vXTrjJRFNXEeSAT2A kQ4WY9Gj/rx9T8Z5qhWcR9RqZz0uAHXV7uYzVL7r6x4AnZPaprqvhOhtF93cGuP4PEeL pUyM0h5qM7Wy1gF9xU53MjDUgNaGjxOtivA9tEP+t76WTerpu0dp5fTkKOBhNXHr6ZDJ 4d2Hx7ikrnLjN9Hkz6NDuH1U2kNuMhkbjwKEpTo5BpJfgGlvbGpAYqvReEHhVX+L5zhU qQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2n38nq9sup-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:33 +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 w9HMjXf4003259 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:33 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMjX4D014965; Wed, 17 Oct 2018 22:45:33 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:45:32 -0700 Subject: [PATCH 11/29] 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: Wed, 17 Oct 2018 15:45:31 -0700 Message-ID: <153981633108.5568.15177882405104151982.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=503 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 ecdfcb8b15ff..c3e807f1f022 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2981,7 +2981,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 08ad210fee49..b0f1f6d93d9c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3001,7 +3001,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; @@ -3023,7 +3023,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 Wed Oct 17 22:45:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10646317 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 9AF4B181D for ; Wed, 17 Oct 2018 22:45:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A71D288C7 for ; Wed, 17 Oct 2018 22:45:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DDBC288E4; Wed, 17 Oct 2018 22:45: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 06046288C7 for ; Wed, 17 Oct 2018 22:45:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8F5B6B027F; Wed, 17 Oct 2018 18:45:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D3D046B0280; Wed, 17 Oct 2018 18:45: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 C2C5B6B0281; Wed, 17 Oct 2018 18:45:44 -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 8CECB6B027F for ; Wed, 17 Oct 2018 18:45:44 -0400 (EDT) Received: by mail-yw1-f70.google.com with SMTP id c67-v6so17928612ywh.13 for ; Wed, 17 Oct 2018 15:45: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=JKTdos3g9sr+caRIKtd3XTJY6SNyMhNBCwtE8oUJnVs=; b=oYn3TF3+mIKEtXpyeaNeiH3yojLQ1PMr7+lfr4C14OshU4PjWZGIeWPpkNHqD4SDDV c2LuKE1dj2Y+leVq85KUaomef/wRwlsuqL1T6vyJmm4TqXfqzUUmi3yRJ8CE/IihOnk9 /9dY2DQ5T5f1fCn7QybYvDGnyTwoQeKyFbmKdPy+s8KlLGSURtwAd5qARQWtPkoVmgqr 5ipMEAxdzBfGGFWsEwjTjD7JUR/eLbKNf8U1YMs0QPv/06tHTrQlMTgKoyZswcHnltxz KoX8u82Nu2p0OL0U5XwB/rCO+hG4KZKeQR7w9GnVlvJc6HpsXk5II9ldQu68iheN1214 nutA== X-Gm-Message-State: ABuFfohh8ej/flCgGuxzIoSO3XJ0TmIpqsQBvxP8yI824BRlOKfAHTCS qnh5rN8oMtWCg/Yq/arb5b/DGg10JcGBp1s6HV6XvLcFworYnro2SFEBJ47IetxnjbETGrvczJJ aw9eS4vPq6FpqzT+sEHfVDyal5gAn1Fxjg9Z8edkWmeSbLZ3frmrEW+yI/OIyKndmgA== X-Received: by 2002:a81:2287:: with SMTP id i129-v6mr16999608ywi.74.1539816344259; Wed, 17 Oct 2018 15:45:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV60txoGfbls91kIsw9PyLk7zH2iMvPrebi30e2xwYhyn+7hGSwDtD4CNNdEfB9uC32U5WtR5 X-Received: by 2002:a81:2287:: with SMTP id i129-v6mr16999589ywi.74.1539816343749; Wed, 17 Oct 2018 15:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816343; cv=none; d=google.com; s=arc-20160816; b=z2tKg1vmrYeeyRcdNr2j8cooUlWMXF5/AdjEUEs4BlCP1m2S51VApVOdN9WnUNLBW5 1HjrOGnzwSer8jlqEsp+0z7nggOV/AJO7IuK/7IxCVdEe2HejlikZUnkk4oTt4joDvXH /4urYUh+X6/Dmg8CQLcQVHtH0lX9Jsj8iVf5yP5rn7CYtC14aJCtsNy95mV+7j+wr1SX 9csGHIBcqrWmi7lQUhY7FjV9UF6SsP3gwbVNq2vZyQtCRm8enDiUhHsLRIGxrU6SM8A1 x70c18hET3PFMliuQlVoTm8TPjpe8rtDX2NtrKyEpZ4ZImjGL8CyVkqqoXJtEK53dMw2 QgNw== 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=UKrNTsXVjM66Fi65mv3T/yDb8IcK8MwQZkXkxz/AtMcokk57CVaUUgoZDOM46JGXZh hRJ/yAvbePqVu9rSqSzKjwtMW/tEwomdwbYIL0DkulB/zJmlotsbMKMaaPxm+nrrOzOC OtUDPe+SiS1ThZ6GphQfzZcetocxZ47X8GlckUTFiGz6TSrpM6TL8DfFLYVt2LER3oV1 26/GH69Uzy2mIjPlCJ98BpEYjVzzMkLvwbdEMcnapjTZVbDdnQdJnWIZhWT2eViWg7DN YNHG/XwjW795O0lYUk9uV4SkaQIkHC5LgIBNA7wDFFkoSheQL8Wa786KD61H1D8fIW+g LCDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=nZSL7Dos; 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 x125-v6si3386613yba.408.2018.10.17.15.45.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:45:43 -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=nZSL7Dos; 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 w9HMiLH9048920; Wed, 17 Oct 2018 22:45:41 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=nZSL7Dos4JyHJSm01mcLftgKVKykwsGWd3+cEc1eg4k+OBYfJVnbfo+agYL7xCk6vvSB eB4bF7YgyZmSbJvPzL94iyNnJuO3IA9lUnpaJ3Y9pmkj0NxPxJMxbEq1GkhawoK+zb7/ 6iLGrZo2FRaxapmHn56RnDYsLkhRl/j/75Gyvio74EIEgJI//omlTZLtyURFV0avdAgL oTu8oNFNowFb1it/c/vJGBYdspFJvI6Ef7xWswBWOEeWuYk9ldAgtqgPDNvkQjuUVAIK ppU60URUixc55epMd7mURu+UsahTp8BzcX5LhaxcD0ZnW4NrW10eP9b44C9u8BXJZ46+ GA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2n38nq9sv5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:41 +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 w9HMjdc1010282 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:40 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 w9HMjdil015073; Wed, 17 Oct 2018 22:45:39 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:45:39 -0700 Subject: [PATCH 12/29] 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: Wed, 17 Oct 2018 15:45:38 -0700 Message-ID: <153981633799.5568.10992236383232225210.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=850 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Wed Oct 17 22:45: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: 10646331 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 BB953157A for ; Wed, 17 Oct 2018 22:45:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA73A288C7 for ; Wed, 17 Oct 2018 22:45:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DF2B288E4; Wed, 17 Oct 2018 22:45: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 43830288C7 for ; Wed, 17 Oct 2018 22:45:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0471D6B0281; Wed, 17 Oct 2018 18:45:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F37A76B0282; Wed, 17 Oct 2018 18:45:52 -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 DD9056B0283; Wed, 17 Oct 2018 18:45:52 -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 A00956B0281 for ; Wed, 17 Oct 2018 18:45:52 -0400 (EDT) Received: by mail-yb1-f200.google.com with SMTP id z14-v6so15887693ybp.6 for ; Wed, 17 Oct 2018 15:45:52 -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=PupGOsqbZQm3jxwYy25waOiqK5BEm8xTiHaU69UwATA=; b=miuzfRdum+sWbka5NCwmiCfqgd5z47K5fKLX4BpBXIaM2kOrfspVB+5sbwYeZOVUut F4ve51gLeXEKmqgF1IB7C/i42Ds5EcqvPmJ9gabOPSL/Y8+mOqztWeUZ2WdurAr0g2HK j+hY803TDfNeSW+bs7ujmwEsQej3HMSM/nDhgqfz9XvUcGKrHIVsBJSip+pJneqtQMoR rpSYKBPgOb3ia3QsR/ZdqpUv42A7QljwXoexxTxTeK2LtWYft8i+vhkdwTHyRv6kUpe3 iD1ZZi2716uJsdkZGPee4efUCOPcdiviTxleLwyxYd03/kbvX7r6ErOTpwt70vxZBzwk 5uKg== X-Gm-Message-State: ABuFfoiw8rZTJ2TnSBnHkJj5hp4uY6jY6TCMNJPasfeCZ/hpH87KcCLX HMAbSdRhr7HycBayixAJPpyyBTKNUewpDoOCtxqDXeWB+bYIatXwuOv8H1pszrXAEV/3uhsF23o 25cTDvSvJm1Gy673h71hq1aM/LOtideG7bDmYokmNJ8oZ6x8Yb4xMxIAw0b+YlEUGTw== X-Received: by 2002:a5b:781:: with SMTP id b1-v6mr1946317ybq.127.1539816352373; Wed, 17 Oct 2018 15:45:52 -0700 (PDT) X-Google-Smtp-Source: ACcGV604RvkxcusQc4D/c6z5zobqB2hD9Oar13+DxwM+o9rnKZhtJQCg4pubmaa/acu+KlAmGeSp X-Received: by 2002:a5b:781:: with SMTP id b1-v6mr1946260ybq.127.1539816350918; Wed, 17 Oct 2018 15:45:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816350; cv=none; d=google.com; s=arc-20160816; b=mzxzOlymChBq0/DUMv3AOIikhcuDUOQstAWsxfTqy2YY0vvceFKPXfcIAZ67AZLniN jpDjw7PZFk840GdD/MDiBGZ7VnTEd8QTVH4DU7G0W/vp+NIQWdJBkRDCC1TbX9+pzNrP x/vJCZ9+DRBUdWqNWmZo7/XEuPRRgbrQJHk52cIlOMuKKyC29VcnMRIFCzsg+vqhOJAV ICc47GIBQMfF8UtDUxDaitFMfSDJKLyVkBpe3B1FmhSPmPuNjnIRjzUq9489GoSOo2xD 4EEhBXa4URbr2jGuubHuCFoGE6HCmLOwqIRNe7a+UjCb5A8ydHH/TqgZkK/FYXHGmoL0 eLaQ== 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=PupGOsqbZQm3jxwYy25waOiqK5BEm8xTiHaU69UwATA=; b=bfnURiS8bt/HFRLnuRxuQq0EKoGfxxkXxe1XHSOjLc6eNhtY/MRP5+CvhEJLvhS6t3 M/E8NQDX/dySzRffsUPLkiun3NW331WAVArITEXAEo0J8qslBm3+kN9S9taUpJGXt3Vr xQTmgfOdJ1T+oWEelvikPxQLaQR/pkHBcFtQgX6oTYd/hYShfOlWvIsJrr5iHQOQqahI rFxJjS7QtmTWM92kRnkutFPDIigksf8dy85bUxF/Ovj9ozDQY5P84tVcyLe2qgB0LGKf v8sLjoPVK05+diieapHPERe/S059a5uwRjbEJPbC8CyNtowx5VBJ9sbgdIl6CnsTlKHB MMhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=aCBt94Vk; 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 g194-v6si7542514ybf.30.2018.10.17.15.45.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:45:50 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 141.146.126.78 as permitted sender) client-ip=141.146.126.78; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=aCBt94Vk; 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 w9HMiDGa048890; Wed, 17 Oct 2018 22:45:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=PupGOsqbZQm3jxwYy25waOiqK5BEm8xTiHaU69UwATA=; b=aCBt94VkieghBIP0fchy3d4bQwwuJausq7cvuiC8Q7zzHYCV7b7sOLgoeUIkwCTzHDL+ 8MlhQsCxddXsFai3uvn55DSkEmAuI6dvCma62RTDg0V2cXd0DX1Cy8C6/0kiIOzFeALT KXFKb9CFu9Y7efJipPc048Q9z4wISc/zBCI/ES2R/+9ypnucfQvPlCHqXPSf5kuBFbSq RAJoD4M2PDHxYbxEAGMvjkumFi0SDSIzkBnU/R+J5494SWsH9fw7h2BPDzGTlu3jAaee tY6Mp7bN5LQkrY9Bwym1eEOEFHgoFEwS3y8pLbA3jWbFjtdFb90xNp2AkoFaQkvxb2SB ZQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2n38nq9svu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:48 +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 w9HMjlfA004109 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:45:48 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMjkLY028790; Wed, 17 Oct 2018 22:45:47 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:45:46 -0700 Subject: [PATCH 13/29] 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: Wed, 17 Oct 2018 15:45:44 -0700 Message-ID: <153981634479.5568.15302566721707849625.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=945 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 | 6 ++--- 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, 106 insertions(+), 80 deletions(-) diff --git a/Documentation/filesystems/vfs.txt b/Documentation/filesystems/vfs.txt index bb3183334ab9..8ba47d9d6cae 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); }; 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 c3e807f1f022..80485efad457 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1772,9 +1772,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; @@ -1839,19 +1839,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 { @@ -2981,7 +2984,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 b0f1f6d93d9c..1e93269efafe 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3001,7 +3001,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 Wed Oct 17 22:45: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: 10646351 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 835B8157A for ; Wed, 17 Oct 2018 22:46:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 737F1288C7 for ; Wed, 17 Oct 2018 22:46:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 67E2D288E4; Wed, 17 Oct 2018 22:46:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7C20288C7 for ; Wed, 17 Oct 2018 22:46:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB7856B0270; Wed, 17 Oct 2018 18:46:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B68206B0282; Wed, 17 Oct 2018 18:46:05 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0B086B0283; Wed, 17 Oct 2018 18:46:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by kanga.kvack.org (Postfix) with ESMTP id 5AB4E6B0270 for ; Wed, 17 Oct 2018 18:46:05 -0400 (EDT) Received: by mail-pf1-f197.google.com with SMTP id 25-v6so24797028pfs.5 for ; Wed, 17 Oct 2018 15:46:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=s1A/ONl963LUI7qx+O/mSM7mRMlbfSmdcwcuUbUZbpI=; b=ST8F0gkxsfMz8S+31STQbYkdyQE9aKdVmrDH04Sxt4Dg4PUnC7WztV1ADKxYO+tJUH 01XtwiZCx4h+InU7vyjUnL0pmFov/s+PSMKAzOEERcnhbWAxIaAZ9qzd/0vfuGmNH0iB 9UYPvF96zjBrau3Kh0IbmJtGcIeBQ6JNmAeLfn6pnEB2QrOmzv3PstQ4aYPvyC1m2j/W 7kjlwFl7SwD5efRi4YVtgc0cXlATa0aRDlfT8ZrPa5w0/b2r+6XCBz/z9PoWfXOwOGOl NK0d+ZgGDkfAtcS/5Y5YSsnz+8pQrBViOpKRAu2k0/nBqByn94w8EBGtRkuVMdFIO5AD Iv1g== X-Gm-Message-State: ABuFfohWUC7QyS2/6KYGKGWQ5d/qg3VAFAw4ksnrKUJ7DCrhIbkpNH7l IvtvRs70bAUW9wtPG6l+XiJ/pFY4Iz6Ry8NfUpvBrQieEdJt1clXaVOaZo9n0xHZ74Mj2Kv/cRX +XUydASHUkn78SteaRPpCeYpOiBaCvD8SZ80bZ1lydAsdXh/ikMrhr2johuPMwhfvAQ== X-Received: by 2002:a62:5f05:: with SMTP id t5-v6mr28177380pfb.223.1539816365029; Wed, 17 Oct 2018 15:46:05 -0700 (PDT) X-Google-Smtp-Source: ACcGV611cOldJKRitLYrC8lcb06zrhAhymGMIDB8I75LB+w6Mw5NlgT2/gPBa0uxRq/0m6gWVMjE X-Received: by 2002:a62:5f05:: with SMTP id t5-v6mr28177354pfb.223.1539816364287; Wed, 17 Oct 2018 15:46:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816364; cv=none; d=google.com; s=arc-20160816; b=DsoEBkMvLKNkVEOlbq0R6pVrwBeuk8E02J9Ihl6w40x78hcxEc2Fn3DJRBrrZJXtM2 aPj3im9QfiykktRfaES80ekpZFEa4vAZyxQpb7O/I9yZtWhJphAmZsNb691DtePkzoqb dI7H3UKGOwzpxSZGf1gqyziLJIRnBkXag/g4QQFclseEsPzeCrAmZm0ph/qenOv6UXFU whbsixZi0dDKj2uvWPpuRUC1lDHvqthMFEMlVkLNGtLJjCzQzXpyuVehb8JtNSV8y2VO a146/7vXVyPl75XJ35l9MHeXoNBuNpq+OYdzb2wtrSc2Gs+1M4r2Ni65UzuKppVzPuVc PPmg== 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=s1A/ONl963LUI7qx+O/mSM7mRMlbfSmdcwcuUbUZbpI=; b=OEfs7K3/imy0V/XUDCu/rekr7RPvkgoZFKrHxg9aECmuGxUZPCjNKCDEcv6Rmog1LH v+c0FQZEDsmL/7zuSfZ9KP4mmbgw8E4DDAkVKaKGD5QiYoG0eiZIxpSgGEmNlN2QRcdu d3Wpxn1r5nSaxVyjeS/Jep6VGao5lWVxydlwBL6LqUSyaCDzZEFmnoaA+GrLsmh4qFJM prRUfeXVA9j/3QNepxZcAfzpLUmsDGqxCQ52+X0eHwWtL9bdMcbazkx8xF3BFWiIMLg1 WWQLMH0+jmM/Z4JDtOKmsHfEN4jW8JapGtGv1FPPhV9Y4BnN8vEJW4sXUEw5OwVINTrG GYMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ocZImKv6; 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 n2-v6si18557000plk.255.2018.10.17.15.46.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46:04 -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=ocZImKv6; 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 w9HMiHst040218; Wed, 17 Oct 2018 22:46: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=s1A/ONl963LUI7qx+O/mSM7mRMlbfSmdcwcuUbUZbpI=; b=ocZImKv6lvQwf9jgRR5gDmIISLQPGwDuEhHo4lS5IGyaOunMp7PrB7lGq633vVpcyfQ7 rsmj0XnZyq+h3ezGPdjMKk/xV4wIcixvVnLPVsv0YdKigmc+wdukK8/mr5Cuy0qG/Rh8 nNRLI3g2QqdZVspKJc22bbE69RGHpicP1sB06GINSXu4+QA4ct0tCiV+x2iCC3GBUr08 PEc90hw2nXboUkaYlB0ZzDVxQXkhUwvZRocNSoNUhSNUeDsQM+rMGA/AZp/JnLqvVu06 lYZ/Fnuwgc/6OnHdkydlbuNGL2Xt9iL9RB4IamM6cmZaNUw/FtVlzsdN4ao+S8CnSfDS IQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n384ua01r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:02 +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 w9HMk1vK004688 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:01 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMk0dB031457; Wed, 17 Oct 2018 22:46:00 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:00 -0700 Subject: [PATCH 14/29] 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: Wed, 17 Oct 2018 15:45:51 -0700 Message-ID: <153981635183.5568.14122129836747881883.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=582 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 80485efad457..bc78ad7e21b2 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1843,10 +1843,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 Wed Oct 17 22:46: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: 10646363 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 CAF37157A for ; Wed, 17 Oct 2018 22:46:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BB102288C7 for ; Wed, 17 Oct 2018 22:46:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AEE3F288E4; Wed, 17 Oct 2018 22:46:12 +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 3820E288C7 for ; Wed, 17 Oct 2018 22:46:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2B8506B0283; Wed, 17 Oct 2018 18:46:11 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 266A16B0284; Wed, 17 Oct 2018 18:46:11 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 107D46B0285; Wed, 17 Oct 2018 18:46:11 -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 D04FC6B0283 for ; Wed, 17 Oct 2018 18:46:10 -0400 (EDT) Received: by mail-yb1-f198.google.com with SMTP id j71-v6so15896341ybg.1 for ; Wed, 17 Oct 2018 15:46:10 -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=HOn8xVwkR3JYwNdX4ZaYESKF2/1a5rj2a7MLye/55c0=; b=PtpVd0ELdinmf/CzWZOFmqrYwZTjt4cPiLKi9fybcWPV+3pfl2AQSPUErsaQinrN7i JOo1mnQ3RZV/D2ZIxRReEwxIliml5XQwOlPQc2pLeGkRKlf1PC4QUkEKaQzOlpn6ZAu5 4LVOJukh/gDQCaAeX6my2ySrxdGA1E+gn315abwLEFm0EsVgY/q0MS1MihaN+IKrnAzx fN/BWyT+Sq4RjyMlVCPxNAUelk1p+4OYKo487hmmcYCeuYjATW7rOw6HvZxnaPo8POS4 UKVuJ7dyeqUHTlz/jfChXMoWXmHFDs2ONflUaavj0/C/mFYPC1imTxbLr6oCg7E1Pirq P41g== X-Gm-Message-State: ABuFfoikJnSdA7c2ZCJLpDgbEu34NSZ7qp17p2ktIdvYRJHZbtXjr0z4 NLc5mi1JLOq5e52Ro7CBS23A2bzlkS77yOW/X8YzXBZgilRhCytEddZXanzi7Q86A/+1YccwlHd iPuazqEsi541lC1bfEUiMHmjotbnE29OU/ok04G5TJmgs4R4kmAzMrZaL5MGdqHp17w== X-Received: by 2002:a25:4148:: with SMTP id o69-v6mr15687944yba.492.1539816370610; Wed, 17 Oct 2018 15:46:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV62YWQWQpv2xbnBxZaAM00TJva3wcPgRyw7Adx60QanY+0QvHVWWROKPu6zijmzJ4HtfQrgE X-Received: by 2002:a25:4148:: with SMTP id o69-v6mr15687922yba.492.1539816370049; Wed, 17 Oct 2018 15:46:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816370; cv=none; d=google.com; s=arc-20160816; b=pQkdBrnOs5EEz7/If11TD08oIrIodKk8RnRbF4CkuYb0KHYmXDhHPEENGDaD0R6uol 43ycDl/YH9JjDELPKq4JnonBjTa+fqkjN7Q25bz5PYeAqqS9hnmFXoginfAYK0306amw NKR675lZutGaE+fIpGI25ZiibTHDTwxzBKg8L6h6LR+yTd0jEU7MBMClgMUVe4JT6WJY zRbM2P3I/FaodxFAnqaYu9JtxpQ6FPI52y1lhh5tqlVUHxFkJrjGTRx3cjb1wbQnV5SL LG/FVIjfJ7ZWZnOd55W8+3DvXbc73LwHd2ADLIlf0u5W0XzNLdzn37QV8GYtFDnRXywX NNqQ== 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=HOn8xVwkR3JYwNdX4ZaYESKF2/1a5rj2a7MLye/55c0=; b=x6mnSMQ5xk8kc7q3DufJySo84dxO+ui1XhzVQA0b+OYzmt2tDb/PVBs2eSO3MFgeP4 CZj3d8+jZM9Bl0gLWMGdw6gWvOaWDvsmbLP5BIHoRA5of1XPA+bgOXzkP49WtKQzj7X+ NQWx21QY264D+8ng0qrjMKiXHXF1xpTuZyu5RyQL9631Me2Uysj2A8DX4vAgR/FCnRpN LFgbbGr465b3YQv/lJGXAK+Cvt4p6CgZLbhLCecTkLlHjVwWHK3MSHTZYWngpGeBPVY5 ge5PdDVUa32kq6SOcO7JyT6lFjTxjxyyxTlOdiIduZLYJbuuOHd2Kd/u2clVSRvLRzY1 RYvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=xkLlJwfa; 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 f62-v6si6772541ywd.388.2018.10.17.15.46.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46:10 -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=xkLlJwfa; 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 w9HMhpju048476; Wed, 17 Oct 2018 22:46: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=HOn8xVwkR3JYwNdX4ZaYESKF2/1a5rj2a7MLye/55c0=; b=xkLlJwfaBBdV2InSDSQFzbV42FS6ndUXIM2QfrB9HS11MCxb2E7q8za1iI9JyLppgAx0 G0yl775T8asSQTeQXJ/O5Jo3GE4yYk/QDBiCk+6iyw0nMAFfaF9qdFKs3teORPalhYQw rk9uHEPpECSJOFQRyfdnNE/17ivVdzi9XzPpDM4kl02POlXuDLX3o1vobuwi866Pdzib cQkw9uDVAkY3osExOpopDGaRueXtRa4uRYMS8gXgSODPtrP8TH51A7QGvq9Zx+qXL3cM sZanjggJvjxA9PcE/oNDER72kufd1T+Cc9pC/mRdQHfiNmucwyy7jZpLu3tOFotkPpzZ 7A== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2n38nq9sx5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:07 +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 w9HMk7KH005400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:07 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMk7Na015235; Wed, 17 Oct 2018 22:46:07 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:06 -0700 Subject: [PATCH 15/29] 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: Wed, 17 Oct 2018 15:46:05 -0700 Message-ID: <153981636536.5568.11691478301880924161.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=517 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 bc78ad7e21b2..ea2c2f673ecb 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1854,7 +1854,7 @@ extern int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same); extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, struct file *dst_file, loff_t dst_pos, - loff_t len); + loff_t len, unsigned int remap_flags); struct super_operations { From patchwork Wed Oct 17 22:46:12 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: 10646377 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 822DF157A for ; Wed, 17 Oct 2018 22:46:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7241F288C7 for ; Wed, 17 Oct 2018 22:46:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6668D288E4; Wed, 17 Oct 2018 22:46:20 +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 C87B7288C7 for ; Wed, 17 Oct 2018 22:46:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8AA4D6B0286; Wed, 17 Oct 2018 18:46:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 85A196B0287; Wed, 17 Oct 2018 18:46:18 -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 724656B0288; Wed, 17 Oct 2018 18:46:18 -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 3E9376B0286 for ; Wed, 17 Oct 2018 18:46:18 -0400 (EDT) Received: by mail-yw1-f71.google.com with SMTP id h38-v6so17814341ywk.20 for ; Wed, 17 Oct 2018 15:46:18 -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=/+V3iC/KzQAzJs+XcKeeWtH75caGTwIlDYVj0kBbFn4=; b=iIhWQ9PBx5qvn5hVfzNNaCBE2Jo03tOV++ZOuIBgRS1D9LvIg6ZzfMZiv3DC3DW6xV tGDr4fH7SS6bXgmAaE4UFgxFE+yhM1+uWv05cCArR2TyLiMQWcEohTz3/3QPh7iYTMZG XNdw759CgwktEp3ZwZd1jfuxKPOzwv3RdO0UqLVAuVKE2Qa1a5F5WCUN95PbaxErWlj+ yv5/StEZbcqTanomO2WVz4EdN6+SjFE3h6qwYMnzFxW1o55VvLyfaZ4IzlRzfHTSzWex mGjG5YwXVYvy0EEnEGPwzGGhcjeUjGL3JvOFkN4HlcikETxvAlVQkWGxrMjO/yLj1mcS Tz3w== X-Gm-Message-State: ABuFfoinAEa4vGLGyDEdHskQICHdp9OEYQZrmjGOtF8Pv7kTPxTdvmbP 1A3+dQ0VFqVEwlzr7CR370vc7WzU50cNKY3KP7MpRVtcaD68kexK1uFfEC9kHhjlFkEeD9g8roU IgQAhdYAy6uKgvbl+dWOWmKsW7q278GYrCKPNjE6laMYahUYy1OtjTMJ22/C8bo2/xw== X-Received: by 2002:a0d:f0c1:: with SMTP id z184-v6mr16415481ywe.479.1539816377967; Wed, 17 Oct 2018 15:46:17 -0700 (PDT) X-Google-Smtp-Source: ACcGV61fyY2jelAwFuVS6QbC/0HGA3jPTC0g9Dc7/a+VY4I3PaA6LBJEZg9cvfxBKUfCB9RWS1+i X-Received: by 2002:a0d:f0c1:: with SMTP id z184-v6mr16415459ywe.479.1539816377182; Wed, 17 Oct 2018 15:46:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816377; cv=none; d=google.com; s=arc-20160816; b=HPsq6RB/JgS8BfCqTEJyewfPozjy41cN408XtOOcs5l4sPy7NvQvG0z74vJyqpCNaF 4aBzoAqVTRX4Li4R97nrM8eUrOMa2PSoBFr+zLFTL/DjundcziemlHtQiZpcVj5VdyuB /PfgMGdzT77wAkUvaGj/hgxnCwNp7B/Zl+l40tRtB1aLxWEYJIhp+EeSgDY4LyvMVzQ6 9EUBddtd7NAaIfHWWpXL4PfjpRhsjqOaLNHIaYXedHgWbhX/822Bykq/VTwyaw9yWH5B JHj6L1u+WYJs22/FMw2pe2nG9+kMTXN7uuDBwXG7x+UfBnWGyVNmYjFzRg+p3rV02LNs c/KA== 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=/+V3iC/KzQAzJs+XcKeeWtH75caGTwIlDYVj0kBbFn4=; b=qdmdcEK8QyHVa7P3GnI4xFpUfCU5LyL480EFak9zMktUepzI3Z8pwxaXkyorgdJC/1 VP87vS1D3Okm5Okb9L5PDRSpF8MGVrVjFmZlDxJ0gEskEiCbI/Qj2Zq72TcF0zpMLyqx dlD7jQ6fmt+neDtYPg7U3TVZeOVZa7VbUeg2ywlC3I7q7glkx7QlLhEhwUBZHKqG5xYq UQD6w0UMUFdu48XxMmzGc35wYKTSzCv6I/IKorbAAttBaXVTlGBuKH69AQ7QRQXy4P+v Ap5uq6wotUwH5joWC49vLU/nw0rLZV0D7UHThVnDxPyUOXW8LGMoiq8Az2FccyDYbZNs r99g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=uoXJgQkl; 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 m6-v6si6678408yba.340.2018.10.17.15.46.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46:17 -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=uoXJgQkl; 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 w9HMhsPe048507; Wed, 17 Oct 2018 22:46:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=/+V3iC/KzQAzJs+XcKeeWtH75caGTwIlDYVj0kBbFn4=; b=uoXJgQkld0ERp2GU78syXOKb+ZPcIP88Z0GKImAICtHXkmu+mppw/hf0AwiP0UU3x+I4 V2TuzmmJ8tB9ku7NAADfX7X66+0nDrsnv3Q2YrPfKEOoOiAHTe2OD0aQgwj3sDoK+8yk lmneATPTJ5PhVqJO1FNgO314UjhweAjH7e1b9D6HTIpCm48OVH28EiLYpTa4HXK5k4I8 JSCqGzNj0NMJHvDeBgF5ENXqDYRSmQnAkfzq7Wu9jv1VJgm/ZLVRFWUeDMF0H/mA4d0e 1ALBw8lF6psym86LpSLwZnlwWHB1rJEWkjFhKMOx1jWAXrhSHQ0ONAlmYxvUn/voydoY Ww== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2n38nq9sxk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:15 +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 w9HMkEJD010683 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:15 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMkE6b031612; Wed, 17 Oct 2018 22:46:14 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:13 -0700 Subject: [PATCH 16/29] 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: Wed, 17 Oct 2018 15:46:12 -0700 Message-ID: <153981637217.5568.7500888859511338974.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 --- fs/read_write.c | 28 ++++++++++++++++++++-------- include/linux/fs.h | 4 +++- mm/filemap.c | 11 +++++++---- 3 files changed, 30 insertions(+), 13 deletions(-) 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 ea2c2f673ecb..0b750e3f8f20 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1726,14 +1726,16 @@ struct block_device_operations; * If it is called with len == 0 that means "remap to end of source file". * * 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 should be taken care of by the implementation (possibly using * vfs helpers) but can be ignored by the implementation. */ -#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 1e93269efafe..0731869541ce 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3052,8 +3052,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; } @@ -3063,10 +3062,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 Wed Oct 17 22:46:19 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: 10646393 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 6A72515E2 for ; Wed, 17 Oct 2018 22:46:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 59D64288C7 for ; Wed, 17 Oct 2018 22:46:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D92C288E4; Wed, 17 Oct 2018 22:46: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 A1047288C7 for ; Wed, 17 Oct 2018 22:46:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6D5126B0287; Wed, 17 Oct 2018 18:46:25 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6854A6B0289; Wed, 17 Oct 2018 18:46: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 575B06B028A; Wed, 17 Oct 2018 18:46:25 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id 13F1D6B0287 for ; Wed, 17 Oct 2018 18:46:25 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id z8-v6so21138282pgp.20 for ; Wed, 17 Oct 2018 15:46: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=KzS1YpGdWiJRTm/Yeg6QnEh5g6eeuSdILXoQJhMO7DM=; b=W0ayM2Lc8M9cRw1t+s796h1jPudttrM2sOIy3kAEIlejWcJN0ZLZPPGJXsRDZraFK6 Uo9HcdRjaqLhigd5lpZyhU8LGftk8igza1k77nrJsy7Ii4MbDdqMWXIpy++2AWPP1xap 3zyTxkOChybeq9wnxKJzI+IeVbsaJHaEklHnPfCkI4aLNMUfYxiqGVEK8S4B6I/RvVQi avA0hrGSYReSdkXuBjvoBV9NietufByGqrOa/kc88Asd+R/SbwQCDl3zOPyV7/s5Avgb DmBEK0ADBNZKJhBD4qhuZv7EwROiuCB4k5ZpLdiBldwtkMWjWkVzaIAlT0oS7j987CJA YnBQ== X-Gm-Message-State: ABuFfohCiLSYRV61s+dpnrVGsHRRWkP5ZGxXmCEHFhaD8wC7r/fpTriA a4Dsb/w4KJtp69/iFllW5DjlCA5uleeWHT3eo6tm8T9nmdffJdun6MUolg2OARyhdlR6y6rd9zW Jx7efztstnYk9cGOxBjBTvRqKBfZG6UhpqPpvpfV++ZLkS1n5Z3UqTYKeSknX1H7oXw== X-Received: by 2002:a63:c5a:: with SMTP id 26-v6mr26136498pgm.372.1539816384741; Wed, 17 Oct 2018 15:46:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV63bDs2uPByPeXFll6KVXLS7YwV7KLB0J6/alFlkz06rPmROa6oXEIGuIz/nDor+2hmM+3PJ X-Received: by 2002:a63:c5a:: with SMTP id 26-v6mr26136471pgm.372.1539816383859; Wed, 17 Oct 2018 15:46:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816383; cv=none; d=google.com; s=arc-20160816; b=g9ZRHlFy37Z6VjwFwhXGgyc91pF8kGmeH/x99lxwvkye7AErkGb9x+uHYbY4gZMdKm Ps9KAlF7fY5AfgLhRzgRuT37XhKhuHPpimgeHO78FIOb4V04SGsA28LUN2LVIlij0drd Uh9y+knR9WdogEv6AenkB4ZqPmxIfOfQIyugWH3q1JNiQk2DK3p6F/WX0o47DJtLFbEh JrnXWXXns11wus3wUepVXoEGd8aVdWH9yfkkMyNX9MtVlmeGcYBIFrY48crY0Ti8qnQ5 Hw5qovxVPWfs1tmfsULum1OazDdIDBOpuG0rFBZCLqQmecDuPDRax5FiD+o7U/qneT2x vFUQ== 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=KzS1YpGdWiJRTm/Yeg6QnEh5g6eeuSdILXoQJhMO7DM=; b=ZFrrbB2zuWrGx8z3ER9Cb4/+1divAdhoL/5st4MMU3oZ7Xzhsfz4KHDrdoaL4VyPuD qLgxGdvYT9IfVLVZPtKRZhfR9wag7jaCe0MEgJj4w/uhfApMKjzbt4JccE0VFJZgdH+N 6SN9KLvt7l7bb3USlQgwASWXtEo953INGQKipmUbQ19vxw6XLYWnE1oLxS1X8mPyZTje xNqZlWtAYATVup8b+UpM8k63Xt29djZHeOM5JTS91rVLAbxnWpSZkHCabxMnjRXghET5 TcmVKs+n+0hiTX82hzacWF+9MXkm9W9vJK46i+F7IEtSc+RlRtt4N6dR3ONKOAh++Kzk /4pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=lVtnE4It; 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 c21-v6si18496455pgg.407.2018.10.17.15.46.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46:23 -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=lVtnE4It; 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 w9HMiZQA040586; Wed, 17 Oct 2018 22:46:22 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=KzS1YpGdWiJRTm/Yeg6QnEh5g6eeuSdILXoQJhMO7DM=; b=lVtnE4It0+qQyj8BXkhNWaG0Xp5U867+NBJr7ZE5Po5ANUyHDC1U2SIMXlPpa+Pybwvb +kcNZ6l95Kk75J4l3OGR50Y6v0OFuIpCgFVQdTVeR3J5acjGxsj2YpJYI4HpLpRnodUD oMGCTgDRV56pNni+LUaYHWqwHZ+XQykCTS/sKkE3NbHDpRlOXaGFySJoNC9pZVfP0pm1 Wds0+jJTZGA1DgMu4E23+OfhPa09jdgFYYNC2cnwO39emNVFK6b6ZsovtTbdPWnkQJJ8 iZsUVGuinun6jYa40ZVrfK98mOeeeGmG30EuKtB3BHBm3dU3eunIzvb1YSx81Lk7uT76 tA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n384ua02q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:21 +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 w9HMkKnp006053 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:21 GMT Received: from abhmp0009.oracle.com (abhmp0009.oracle.com [141.146.116.15]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMkKB5015316; Wed, 17 Oct 2018 22:46:20 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:20 -0700 Subject: [PATCH 17/29] 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: Wed, 17 Oct 2018 15:46:19 -0700 Message-ID: <153981637899.5568.11427312080035617896.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=638 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 0b750e3f8f20..403860b25725 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1849,9 +1849,6 @@ extern loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, extern loff_t vfs_clone_file_range(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, loff_t len, unsigned int remap_flags); -extern int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, - struct inode *dest, loff_t destoff, - loff_t len, bool *is_same); extern int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same); extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos, From patchwork Wed Oct 17 22:46:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10646399 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB8FC15E2 for ; Wed, 17 Oct 2018 22:46:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC657288C7 for ; Wed, 17 Oct 2018 22:46:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A079B288E4; Wed, 17 Oct 2018 22:46:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 213B4288C7 for ; Wed, 17 Oct 2018 22:46:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F11D16B0289; Wed, 17 Oct 2018 18:46:36 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id EC1CB6B028B; Wed, 17 Oct 2018 18:46:36 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB2F36B028C; Wed, 17 Oct 2018 18:46:36 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by kanga.kvack.org (Postfix) with ESMTP id 99D106B0289 for ; Wed, 17 Oct 2018 18:46:36 -0400 (EDT) Received: by mail-pg1-f198.google.com with SMTP id r134-v6so16196613pgr.19 for ; Wed, 17 Oct 2018 15:46:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=A4sDFXPvAlL63/6+A19QlnFZhnOxuaNlawZcJx8i2yQ=; b=qwIWxk5ILQeX6vWa4k2KxeC3u83uT01QTgbR9cgltdbXeM12Gp0NAduKh0j1A/t6+1 mNwISq5ybFUyVOHvYJzkKxQQf7SapnNOQ1X8dMtyjSj3q/XIreiub6er0ixkcb0az1np n5txZc8Rx+Vsme8Xylr5wth/+XDARDhIe8rPH/OUAyDSakX5Ph9j9GmntdaFUyak8KaH lIZ6/vGxkzfpR7JCPnwXZNUZdWFvBSsrEt+/kX1e+KBWIEz4obGlvn9j7Rd23PFGPiG8 j1qIaYTtQHdDbOKg7U/7Ycm7Fo1Hh8TgvIf8DbnnIuFoZYNlkp1xK7+MiVp9GN1CIOAA xXEg== X-Gm-Message-State: ABuFfogswd3D/HDXfTxMU44pvX/hzF/E3fNqZmcOe4JDCAWVECUJuSDA KNUxQl2KPLApfiAYKdH3J3HzkZZskfuWKvpK/USb9Uv/DPBkH29/Ms23THMjaaz3JY0UvBHNhTK HeYrRTpioYjHDgFZ8jO+VnjVAxPHfLg/CLFsEXSokjrxKeHQcZSZt+p6V9h6I2NyGYw== X-Received: by 2002:a62:c68e:: with SMTP id x14-v6mr20370400pfk.151.1539816396301; Wed, 17 Oct 2018 15:46:36 -0700 (PDT) X-Google-Smtp-Source: ACcGV60ZBK5L83MigueskVLOm+YEiEdBYHDxgBdptizKjUe9p6dFnEpiZlGVEB25cLz0LJUYMZ90 X-Received: by 2002:a62:c68e:: with SMTP id x14-v6mr20370368pfk.151.1539816395568; Wed, 17 Oct 2018 15:46:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816395; cv=none; d=google.com; s=arc-20160816; b=KhbQVyXmOIWI6/jGZ1Eb8ziP91DWwoooyyxSdaFAH0iNN0XM9UCW5xxR92HjVXcuJt rYb1rUkDvg1yu1T1XNt41WETWke9YerNY5Lc4oNfvpCyw2VU2tF8ovTvNLOWs/SkbSpJ gb/Bbv303dF8gqWCfyjWp14m151P0jTcYh1OU4yISbrWMMhujUFIBQm8C1x9zYQj2Uwd SZijAsCwRXKu2DEITyRWTg+I1m1Q1YmunGfeV50CyNkiXpYTvclVW5+8wgWkEUOPWCfb EPag2qhvVpI6OXZfy5DsrsgbiRvsqEAnP02fzOD6oGg+q98h8KgTRHeJ9AKUKmIYLX8u gYEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:message-id:date:cc:to:from:subject:dkim-signature; bh=A4sDFXPvAlL63/6+A19QlnFZhnOxuaNlawZcJx8i2yQ=; b=wayzeiu3+MGfw9/0hf6/M5YRzwcoBFQAFC4frTK5ryChH6eVSnVwvqlLJyFEY3m+4g fI9zAvRCvn4VLDrdMsSI6b1tuTZKapOT/XcI0Bky370YZbp07jlUrJVlwYow7jIrFFvy +S/BiCzH8ATMmjgD4ZYuXxUQVNRhlRRyNeKqwGDRvtF7Pa4yNx0JtDvXVJmp6qCKQdfa VRlE6fF2tk9EQNqNPjM/qBnI6TQDlcAZW6H2CZA7aS/xv2t6pifyblQHX1oUdDIZ8Y5A Etwm4zqfLiohR+hc5E0gpFFDQrukos0PYFqhdgafWQsmlu+4z5J2TDBcl2bXKygGdSf0 g6tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=gZ9KvyJJ; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from userp2130.oracle.com (userp2130.oracle.com. [156.151.31.86]) by mx.google.com with ESMTPS id q4-v6si19315872pgh.563.2018.10.17.15.46.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46:35 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) client-ip=156.151.31.86; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=gZ9KvyJJ; spf=pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) smtp.mailfrom=darrick.wong@oracle.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w9HMj6WV040876; Wed, 17 Oct 2018 22:46:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=A4sDFXPvAlL63/6+A19QlnFZhnOxuaNlawZcJx8i2yQ=; b=gZ9KvyJJ1+cu6bic06h6RtbOYxLaLl1r+a40zZbTayaXYoxYWgL57FzRpduD2TeVIJNT GN1B2Zf7FkxTtvqpfpXaj22VPsugJ32Z5GLWlZM1xLOq03inLljzWLunzT5CGAUQhpt8 2gCIJO9rDjqgIL4B87oDyM6Qlla41PDjERKJTz3cAZbfcmhPQrmctnNYEtqQtr4nLXDR bvIMO3hg4BdD4RUZcu3+yoHreUsYSew4N4IOWtbKNLXczkCt2Wp7bE38G85++t/mQCIu Q8bKz0n1MjiaW7cMu0YaBYIyhc3xa0JfE54Lzh9Q477Wlwccrtvg9ryG6LPwK8CL1eav lQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2n384ua03t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:34 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMkRHl014954 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:28 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMkRuf032168; Wed, 17 Oct 2018 22:46:27 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:27 -0700 Subject: [PATCH 18/29] vfs: clean up generic_remap_file_range_prep return value From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: sandeen@redhat.com, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Christoph Hellwig , ocfs2-devel@oss.oracle.com Date: Wed, 17 Oct 2018 15:46:25 -0700 Message-ID: <153981638588.5568.15494557106783144592.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=873 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Since the remap prep function can update the length of the remap request, we can change this function to return the usual return status instead of the odd behavior it has now. Signed-off-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- fs/ocfs2/refcounttree.c | 2 +- fs/read_write.c | 6 +++--- fs/xfs/xfs_reflink.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c index 6a42c04ac0ab..46bbd315c39f 100644 --- a/fs/ocfs2/refcounttree.c +++ b/fs/ocfs2/refcounttree.c @@ -4852,7 +4852,7 @@ int ocfs2_reflink_remap_range(struct file *file_in, ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, &len, remap_flags); - if (ret <= 0) + if (ret < 0 || len == 0) goto out_unlock; /* Lock out changes to the allocation maps and remap. */ diff --git a/fs/read_write.c b/fs/read_write.c index e4d295d0d236..6b40a43edf18 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1848,8 +1848,8 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, * sense, and then flush all dirty data. Caller must ensure that the * inodes have been locked against any other modifications. * - * Returns: 0 for "nothing to clone", 1 for "something to clone", or - * the usual negative error code. + * If there's an error, then the usual negative error code is returned. + * Otherwise returns 0 with *len set to the request length. */ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, struct file *file_out, loff_t pos_out, @@ -1945,7 +1945,7 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, return ret; } - return 1; + return 0; } EXPORT_SYMBOL(generic_remap_file_range_prep); diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c index 3dbe5fb7e9c0..9b1ea42c81d1 100644 --- a/fs/xfs/xfs_reflink.c +++ b/fs/xfs/xfs_reflink.c @@ -1329,7 +1329,7 @@ xfs_reflink_remap_prep( ret = generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out, len, remap_flags); - if (ret <= 0) + if (ret < 0 || *len == 0) goto out_unlock; /* @@ -1409,7 +1409,7 @@ xfs_reflink_remap_range( /* Prepare and then clone file data. */ ret = xfs_reflink_remap_prep(file_in, pos_in, file_out, pos_out, &len, remap_flags); - if (ret <= 0) + if (ret < 0 || len == 0) return ret; trace_xfs_reflink_remap_range(src, pos_in, len, dest, pos_out); From patchwork Wed Oct 17 22:46:32 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: 10646401 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 72AAC15E2 for ; Wed, 17 Oct 2018 22:46:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60EA7288C7 for ; Wed, 17 Oct 2018 22:46:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52DCD288E4; Wed, 17 Oct 2018 22:46: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 EC10B288C7 for ; Wed, 17 Oct 2018 22:46:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E018A6B0005; Wed, 17 Oct 2018 18:46:42 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id DB1FD6B0006; Wed, 17 Oct 2018 18:46: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 CA41E6B0007; Wed, 17 Oct 2018 18:46:42 -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 9617B6B0005 for ; Wed, 17 Oct 2018 18:46:42 -0400 (EDT) Received: by mail-yw1-f70.google.com with SMTP id i64-v6so17584931ywa.22 for ; Wed, 17 Oct 2018 15:46:42 -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=gYAryt5th2UPDrXqFluQKozy2EzkID1d3c65lHFuXAmotF1N06mHNInPO8f74BDKDn 048QVIuZ7b1iQJh4PlkFPVnhHhLKed5pwhzFTBK64yxL9UEjyTfdgoU2EyC56FZwkxeG wc/ABtt56h4EGajyn+YAH4j8oTs784VIVymA3Wglck4+n7SmwBsIhzHuZHfhE+1COoDD pFsQxKzWazQAK2Lq3z4p58AA8hp63qgmEQ3j/dQBtffPXDXSL9nNALaGvqRiHsALT0v0 utr769ZPPjTBiv9/zUjQfAtNCXsGsPe0xXwjO+8AGAohRoixD1NmaZAcA6JbkizVztnS KNGQ== X-Gm-Message-State: ABuFfojaHPSqIc2f8VwJeDQ/nTt8mNvbBvtaShaajFyaksT7acKX3CM8 nasFmnZiQp6lEf7DSo/V9rsv66l30UbFagY1CMgxgEOm00M2Wbxv7wIZOPs6qOgqa4lzoukotoa VtCyh3YcYRv7WbUh0KAr5JH4CtVt/9UbnNPyTcAkq9dCdXDoVh/ckHEqm8XkkIRmn2Q== X-Received: by 2002:a81:91c2:: with SMTP id i185-v6mr16756125ywg.390.1539816402381; Wed, 17 Oct 2018 15:46:42 -0700 (PDT) X-Google-Smtp-Source: ACcGV60dEypKta9wd2nhNfk8tsVmQLVy+ZziDjyQlkzra0kQNkBuWjn0sMeRX2EM1eMANSG/IXmh X-Received: by 2002:a81:91c2:: with SMTP id i185-v6mr16756099ywg.390.1539816401884; Wed, 17 Oct 2018 15:46:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816401; cv=none; d=google.com; s=arc-20160816; b=XLys4HSmqP5FDOAxV0uAt2DHsX/gy0zy7Z7mTdvNyJxXmwZS5U5ufd0hrxolQiSwfq 0jvrWbzPo5TePGadHK9U7KdoiU4uakfeVv1jSIL7cPCZ+2L/cKCvHvETm8Dxka1Nd85K fJSCGgfBA9Ak4tIvGktL86Hb1HEGTZhKFiUsueYWoV3jIVfvOJWwlGSNCuaujDJqORGC PkwTIq+eRUtBhRnzsKx31p30V5emCtIa4hSXePDNGJlvj6lhU1diBdiUIcScvkkRY2Qp r16hCaBEUCB1JUER2/CvVUlROno5Bhekh8bg4spMHnNnQk217ej4nCxdqlTgoWZVFe0W B46A== 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=Q/mAgVsOI/HzUop+ABkaokgRg55wSFyBZ3oA7LxuIEhY8Pq2Ll7G0/OrNXVOV/7uhr ZP971Lp1+copxbpcOJro+McD2oF1073lAoQrblkCfLk/NXqZztyDf1Wf3dSX5/x1Jbfj pdlqw2tFKOYu0nrnDd5EsME26HO/K224/y5sPO7ilCxn847zUcTU/CLscdMJmHTra2SJ vLHO8zQzzgs16m3wyy2V5MpdHNhA1lD0qWlDea0LTQKFpm2rBRPBHETMcy+2+364BpNH OhjAFZyHhZESjJuPIqQAZ4+5UEeXU72bbMZwH8JifXlpGwyZssXhMEAe/CoPDkXrPInX uo1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b="o3/bI3MG"; 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 d81-v6si6977816ywe.206.2018.10.17.15.46.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46: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="o3/bI3MG"; 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 w9HMi4iD048600; Wed, 17 Oct 2018 22:46:41 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=o3/bI3MGQg4IokfWjtLHh1ccM2XQaUDUSn+omteFW90NWDR9hNWg7IFQZC90rMsdN3xK Zp3qRe6pXtR5CMvDyQkBEJ/7lKQKD+wHGsMVkjMnSXPegWDGwGDp8QPRhcqVCFV1G4bW QXPXkQHP1C4UfwycxBvk1/yqB3o4ja9z5sv+GDUQudpemKySfn7wqBxkljn+GQmPazDf XydGX5aizZDcYtDqNFSH6ZghWiOF4ePwhQbwkHUmwWCn5wwiryoCFSDwS3zSNAO6Qhb1 fhSHqy/qxE11a9/dhn6/ORFTl7aQQ+EvRXdNjaUT/x7TwtMA4j7kLZh6SZBStGhKipqF NQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2n38nq9t0s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:40 +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 w9HMkZlG011233 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:35 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMkYGG029063; Wed, 17 Oct 2018 22:46:34 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:34 -0700 Subject: [PATCH 19/29] 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: Wed, 17 Oct 2018 15:46:32 -0700 Message-ID: <153981639268.5568.1964703365268884972.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=803 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Wed Oct 17 22:46:39 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: 10646403 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 CF263157A for ; Wed, 17 Oct 2018 22:46:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C0A6D288C7 for ; Wed, 17 Oct 2018 22:46:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4C2B288E4; Wed, 17 Oct 2018 22:46: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 59804288C7 for ; Wed, 17 Oct 2018 22:46:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43D776B0006; Wed, 17 Oct 2018 18:46:44 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3EF9B6B0008; Wed, 17 Oct 2018 18:46: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 244056B028B; Wed, 17 Oct 2018 18:46:44 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by kanga.kvack.org (Postfix) with ESMTP id D1B256B0006 for ; Wed, 17 Oct 2018 18:46:43 -0400 (EDT) Received: by mail-pf1-f199.google.com with SMTP id z12-v6so28124122pfl.17 for ; Wed, 17 Oct 2018 15:46: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=HOYBOBGpflqwSaMT4PmSGK8TNSkXTGNQVQO8YcwuUKs=; b=JmrTDGEzzVr/nCbsXoeCXukK2bxZvloDGw7Vavm9PQ+HZw5B+j3KIgPn9VDrwysBoN BHafYsu78aGCtXyPhiJjxvBmXlUnbQhkP0tnL4/9K5MdIgt/0Hn7n9xpWXmuI6St1axf +sKyoZTWf4AVUknoEs09Fiwl0cvt9lzi+yAkgiHTm/aaLJ0ouoT0c0f1uUyFIdT6QuWi 9PILLHv7jq9923tLWiAtGekbw+pCcFOHI70ArHDf0V1m6fGx3QKALgiC3ZhGnjOWEgod z90VqUycmVAvC/S6ZJkJylQe4zl2WbWyOcPMkHEd4lpYuWcXtd4m57JBivEjqm/RP0FY tNpA== X-Gm-Message-State: ABuFfoi1FNLU48mnCY0wlnlgoq2gMRyPSkkRNUnXc3Itt83DBN+F5Iu5 pXEug0IM1D7k0mxnGeqf0p1feCtn08xp+Zg5TFeT3V9o0+7PCXg6U1sHMRmcQmP0m/L46LEeUvD w3hTKaSEw8AHQtu+rQbvUnDtDL3ZLYXpAFhN4OGLOluaz3us6Yfytk2oRlLHHQZwUQQ== X-Received: by 2002:a17:902:a40c:: with SMTP id p12-v6mr27867018plq.165.1539816403514; Wed, 17 Oct 2018 15:46:43 -0700 (PDT) X-Google-Smtp-Source: ACcGV61in7PKau5ddX+RBJKPVw3Rb6ss6Veao5LS7shCmqMwxezbCAJjIebfyCgpywyKk0PbTLT1 X-Received: by 2002:a17:902:a40c:: with SMTP id p12-v6mr27866995plq.165.1539816402924; Wed, 17 Oct 2018 15:46:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816402; cv=none; d=google.com; s=arc-20160816; b=JbEal7fpf+4HGxJgJdhqh2M7ZQWFCvHRSHuMixjFtg4r9s98vziQTtCwxnAaS7GNxm XTiYk/eyT5hUBIeuQUa9XSRv4PxhBTEynYaqeNn+yF9t7EHy4StdJh1G0apwNwEiS0Oz s4X43+YmhQZQjs/vmqf0XyVrn302Xo3haoC9CdMYsQLP2o9DlEYbI+BmFOZqIX2bLGHj 8CGj3vnLnWdPei8jOH4qNfSPG6SSLkK8z2TDYiBDCOU/vMO8iR0HayWAaxHmJjq9XOp4 /iqfRpPuSn0MqRIeOHUwbm45EVhiipxyInwxYg/Pa8auHgC5Ukz8oK5i+YfQa/SgWnra /TiQ== 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=ouIFP/Yz1d1OkB42ENSV1iudw7kgnyZJpQ4Fu2veo9YofwAQzoKM3OPhNiWHMvf6t6 1FsRcbyAe23c52Igw8285N+W+9PbGSi/ofLZfqJxfz6tpcJGYgFcOvzywxJGbWxSMJpf d6w9ejKKjiPwSOBa+mziuoYdcNOgjlBZDoqXfOG+CEQc6kKBi//mtv7IwdW2oyXBH7pD HKuQ0jmuNKRYwpn4eyl+3B1rJWVZR8cEJSQINFp8CF39Ru1xt1zR/l3q/2Yaq/EWqjZi sK3JvfpVFcfh79/0C8EHbLIsR0PA74ZhOC1PfuBBaGGr165ZqAp8Z/DMTrLcMjy+KIfo sCXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ufFadL0Y; 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 a9-v6si11926518pla.291.2018.10.17.15.46.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46:42 -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=ufFadL0Y; 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 w9HMiKIe040242; Wed, 17 Oct 2018 22:46: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=HOYBOBGpflqwSaMT4PmSGK8TNSkXTGNQVQO8YcwuUKs=; b=ufFadL0YPA8f4GUDQyuEefSLolBmVx61eERC4UgMImb7wMgc+TbVhfuk79EO5+v5o0KY ughVyo8bMkXAwK2HByJKg1CEDNKHSLztfzp4Q9J44HdO1BCOF2omr72+t8z3aGpcGcMk 4eg8Enh36yyRJl4W7oQswucet3lyRwMqhZrtwRd8UM6zRgk94xWL/4r63jctaXvn7pOX Gz6j4VdaxVg91wBp3EkfUriZe7QNiNs9FApLY3jk/erfykxI//5w2Zfaa6trt+gmIQMl 84SqNFIsN7GFhSVfefVXWnkW+mWoJqmgDYNGUZnC3rLOkGNHkY2icpETnoKORJecGQjg nQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2n384ua047-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:42 +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 w9HMkfdY011472 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:41 GMT Received: from abhmp0020.oracle.com (abhmp0020.oracle.com [141.146.116.26]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMkfS8015518; Wed, 17 Oct 2018 22:46:41 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:40 -0700 Subject: [PATCH 20/29] 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: Wed, 17 Oct 2018 15:46:39 -0700 Message-ID: <153981639941.5568.14471990950819406360.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Wed Oct 17 22:46:46 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: 10646427 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 141CF15E2 for ; Wed, 17 Oct 2018 22:47:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04D11288C7 for ; Wed, 17 Oct 2018 22:47:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC2072890A; Wed, 17 Oct 2018 22:47:00 +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 A1D43288C7 for ; Wed, 17 Oct 2018 22:46:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 834A76B0008; Wed, 17 Oct 2018 18:46:55 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 7E4096B028D; Wed, 17 Oct 2018 18:46:55 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6D42A6B028E; Wed, 17 Oct 2018 18:46:55 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 286936B0008 for ; Wed, 17 Oct 2018 18:46:55 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id h9-v6so21061556pgs.11 for ; Wed, 17 Oct 2018 15:46: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=6J/QYq4s6QFaJLMu3nSz4IUXRy/yndbu5A+K+2UxqS4=; b=lNc2OR6rpeExt9+6rJQnmEhTxCLTU3mw/ZOx06AigCuBjv2N58ZzM1MaLSldHLvhEE 2BzILY/23X5ctygTilebTw3JAnjAUu/GEpR8F6XIdo3d9TVs0Atym/z5X2RVfXa72rX3 Nm9VEQ1Dbj21E4bpxnQz6/0zkzDgRiZLASkf9kwrwtJStOvWtIuu0537MgUNvrACB6uM riRB0ETcFc1iucYMsJTwn2uezwJ5DKIvVVpoBuhTl42gx2zU6ZOqCEqOPY9wR5VKWD7u q7XSRdj8vbRrI/NzRfH7UKGDUV7vifguY7NjVVlp/TWfBSG/u1KLppNbYROq0kLSpx3c rYpQ== X-Gm-Message-State: ABuFfoieK/r3hfJs+/tuQYwJNloFkJn6mpvWDImtpogY7HYW1/lT6emd M6TvYeG9MkUaG5GD1SW8+0PRnfOqaw09iUkT9C9qul0bOctNDlnnRbZ0L22tzXnpTIg9YsJ2c8r QVPf3MOZlhxm5qtMl2xH1fiVqiiTNsGfmDzIJPBOJAds8W/KXslwHeW9sQfME7Tyqgg== X-Received: by 2002:a65:4cc3:: with SMTP id n3-v6mr26680683pgt.257.1539816414824; Wed, 17 Oct 2018 15:46:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV60thJf1KT2KmC6cMn9V+vGZQtl2a2ysywL93YQoUHIP0ZKX37qQL7H1X6JdCH2C5mKn9Av5 X-Received: by 2002:a65:4cc3:: with SMTP id n3-v6mr26680646pgt.257.1539816413887; Wed, 17 Oct 2018 15:46:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816413; cv=none; d=google.com; s=arc-20160816; b=lrBN3NH/cSybLVfQlJGfv9FKYtlTiS+g7CCbYXByDHH3U1umfzQqY50is9PryNq4qC MfFB1P9NVBenJKfVVVnCfDUln+hu3o2i+NWE6fjHspssI5McGOXvOjdDehR7Y6PmhVsP OqIfznjtc8kprs4tXyeI3Zs4fP3MPfjxD220djk8hL2IaJqieAbCQVU3twmYGg5yUVkC T4PmsufAAGSANIyHExa8hYoRqFDQrYzAbP5NVLa/mBHX1PNvhCdis0+QMCaGjAURrYqu f+80x/8mvYWI9Gvy4aJq5qKj/LwUDm6ZivM9lR5MFxbQRF94c2NhmxUaU3BfZxdDJrNt 0xPg== 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=MDkw/z/2DI5ESLCFc0VofFeoBEuTORfzahec1yzCaBhkOLgIcHUYPQwwIuQJ89CW4y 88e7SYeU1CiD+F19s3JxHk1nRbWieoF6KELGHaXc1RXWA0CZSEcKoqcYVcYXWvhKw1Hu w7aAQqn3KPFlSyHBH2DXmpqkgXUZBrWx7TbgT3/HOWxP0LuyD1fWBG2gXrK+fCINdKxW xCEwjJdPktPP6oTHSDBX9g61+0IHBPDm5YlocA2/6RH1QuKRXafmS27jF1k7oMAMzoww zRp0mFYMvmJwMC2SQ9vUXBRaOo4Wbaq65hC5ZNWcDVPjOkEuZaWfY0oYLGKjGVekIT4P gfEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=2KSdAmzK; 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 d18-v6si20338634plj.82.2018.10.17.15.46.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46:53 -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=2KSdAmzK; 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 w9HMiJLC040234; Wed, 17 Oct 2018 22:46:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=6J/QYq4s6QFaJLMu3nSz4IUXRy/yndbu5A+K+2UxqS4=; b=2KSdAmzKhXGBdYMg2nxhIF1a3Pl+LJ7BQOlZO3Hd9U3bqIO3Krg1QhtlyViB6eTlA1BJ 6EIbd5kVex8Df+K45UFdy8izgwGUEh3vdZd9++l3T8e9bbIP90FLZqgelrMOgATQYUa3 1SAcFeBPYoxZeSAb/D4Q4bs6rkI7nFL9APbIwi2pg8wko6dAM3bH0af4Z48C1bziLp84 C15jcZt1jj/9lCMnUHriCbTuY4LOU0yyR587wgRC7dXollqjxvCCIIfZb9EIKLPMNZti 7TwG2PsfziaN+XyYvaoxpd9RVUG10kfG9wXjBJT/HIhJ3hHlXbMCXcMbns5WF5oyXcLy Ew== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n384ua04u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:52 +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 w9HMkmdY007302 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:49 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMkmFo031735; Wed, 17 Oct 2018 22:46:48 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:47 -0700 Subject: [PATCH 21/29] 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: Wed, 17 Oct 2018 15:46:46 -0700 Message-ID: <153981640612.5568.3581451993357141348.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Wed Oct 17 22:46:53 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: 10646437 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 BCDB346E4 for ; Wed, 17 Oct 2018 22:47:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD149288C7 for ; Wed, 17 Oct 2018 22:47:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0BC3288E7; Wed, 17 Oct 2018 22:47:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3215288FD for ; Wed, 17 Oct 2018 22:46:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7BF3F6B028D; Wed, 17 Oct 2018 18:46:58 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 76F596B028F; Wed, 17 Oct 2018 18:46: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 611CA6B0290; Wed, 17 Oct 2018 18:46: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 2A1056B028D for ; Wed, 17 Oct 2018 18:46:58 -0400 (EDT) Received: by mail-yb1-f197.google.com with SMTP id h139-v6so15692471ybg.7 for ; Wed, 17 Oct 2018 15:46:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=yAZ/1PPkeVRlAU93kCg6O9O78UCd/8KO5hoqJKQC2Ek=; b=NXawc/mNYkFdK7mgZkrWp/fL7zJdyxL3O9HggNxPdLAE6HtvuKyb7F3h0/ThfAr8P/ SLNa0VQqq2D3BfgicGgAo6hMUfiZ0qehwL4CBAXp2lk0ewrJzwQf5XdqmxKmYO2Sd+c6 1NhfHYbQC8HE3dIoLp5F5vrraNWHw9nDcwSYkbrcOMch6dUMgQX/qdwOdoBJnv3p651P /P5dxZ+DaFlizyUtzWTxpjJmOf1idorBTI8VHA6Foxu/ug4v27m7jorEyMziZP+ypN24 cQrlsxR850wu+UNwYyfK2LqrAXd7PKS9IBDuVfuSHdIKnJ1FXGfpeu03wQRUyYoqRw/e JTFg== X-Gm-Message-State: ABuFfoj/gvCaAfqaEE2tvSp1mq5yT3oom9LlUVFbSfdLaX/BxVPUzHls ieF5qI5OIz9wDIZe6Ea9Y2tMMqXPcgtod51V74srwxKpVYtzlT9bYkPmAX56qqYx69JRzpksvS/ qRAyMsY79VmX39eLJFfkl683AwhrDqu02l/f2nhjEIU+vkhgcd8bZE7ROmnfe5I4hIQ== X-Received: by 2002:a81:4ac5:: with SMTP id x188-v6mr9972924ywa.262.1539816417902; Wed, 17 Oct 2018 15:46:57 -0700 (PDT) X-Google-Smtp-Source: ACcGV63HPr9IVJYKI2OKgQukc19vDB2mxiwrKQvHW9hKE0IwyhJtUe4rgJB+xv59ptNmsd3wiPd4 X-Received: by 2002:a81:4ac5:: with SMTP id x188-v6mr9972888ywa.262.1539816417004; Wed, 17 Oct 2018 15:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816416; cv=none; d=google.com; s=arc-20160816; b=MoMSnJOVaul5NqnPWpaiWHoZtoJvCC7j7kc+mrFVPzIv/zGvnSSpF2inXmMXYmLfnp Mnd+u1yQQy/MdNXotBP0Pk4wq2Ssw3OgtAtvadW/IgmFxhzoiY8Xwhy8iGxzv8Bn+LV8 1wP4DwSsOitPK/qnl8kLXKRxvdM25xIg3PajYrQ7yHaPxVcoghnOyHyIQsdov0RonCKH McbW+8dtGakDhEVXb+ri5PWmNBwKfi5C/9mJQYiDIqzZ1+8dUsycvQEV1cHG+4UeoyK2 +ajLEhBL7olVbPPwucSTv+rxRVYBHvYO8uPyuaARfpAXubq5SFKg7hIzIgmKngtfanba NN+w== 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=C+8rMNNDPccBU+ii+jQipCT0UuTM1RyLMWVOYGymMomUrK6YuZh+3rQ9+PiUTE4xb0 Ix8P+sG9Au0Omo0fYz1bK5GvkMIvtaL6lS6sN1zgWSGNML7X0jZIJI7WPyl0dE8vw4Nj m+afqTb8EWIsdZOINjyOh0kCB659Kdx5JPBLZYcSz2oMUmsZ7pZlxXCW9eDHi7ddJ/0j ZzQ3dvfNNltgQ7PekljlWnfhi54NEokYBlqvRrnsEo/FsW++qNa5nJUfuFGzhBUXcWyA ycERWPpiGbyCGzVWGIkVMiIqa2vtlRVFp7au5zZWxP8CZIRf8y85AUxXqwjc2fFU/sa0 +Jew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=XkzBMUrj; 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 p184-v6si2627478ybb.38.2018.10.17.15.46.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:46:56 -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=XkzBMUrj; 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 w9HMhlRn048467; Wed, 17 Oct 2018 22:46:56 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=yAZ/1PPkeVRlAU93kCg6O9O78UCd/8KO5hoqJKQC2Ek=; b=XkzBMUrjUQPItWcMWh9bCxGMsusGcWZH2/89KLTzbHsn0Sxox7g96r0900zUbyPluRqi 4V6yDkCuPD9t0zjeo+g3HUPYKo+b9nLdjNdqEqFcoc1wB3gGnRi4wPiz3AihgR55YUFw FjMhJhBHwh+1j3eMbWbk8bjzx+qW3Lzwc0Ht42cRK1L77g/JAjl/CSPrfusqsUtEUN7W utWEpuJzJoOYKdzPdHw8HnoWPHMJFvI/H8goOckfpZNkj4eeE0KBldzy1l1ezB+eicR8 pB+xDGZNSEZEimLJkNyCusI8EfqZKMNt/OC+yqyOMKljHfaMzTDi1NgkbG83Jtynsvnx KA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2n38nq9t1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:56 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMks1r012915 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:46:55 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMksDh032314; Wed, 17 Oct 2018 22:46:54 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:46:54 -0700 Subject: [PATCH 22/29] 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: Wed, 17 Oct 2018 15:46:53 -0700 Message-ID: <153981641295.5568.12054121625513548926.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Since 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 Wed Oct 17 22:46:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10646453 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 B82AD15E2 for ; Wed, 17 Oct 2018 22:47:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8B04288CA for ; Wed, 17 Oct 2018 22:47:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9D201288E4; Wed, 17 Oct 2018 22:47:06 +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 3EC3A288C7 for ; Wed, 17 Oct 2018 22:47:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1F23E6B028F; Wed, 17 Oct 2018 18:47:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 1A34D6B0291; Wed, 17 Oct 2018 18:47:05 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 046B16B0292; Wed, 17 Oct 2018 18:47:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id B3AFF6B028F for ; Wed, 17 Oct 2018 18:47:04 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id x2-v6so21048435pgr.8 for ; Wed, 17 Oct 2018 15:47:04 -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=SGDSArbiullpYs/XPOG6T2xvgHyk5haCgm1b67adURI=; b=LBzbBACplDCV3hiKRQ184O63CYOQyclzcELEH0jumZ/t6AKQ+ZFYdZLnG2Nsa7SSIk taU3/BIkuq8CfMZhF7zNUMVjN26y4F8CifT6nt8WBCX/a8adPb82QzVj2ytNQITBeP+J rJbmdsUm4Ili40LUgHl2V7fYoiM0B6lmntfHyH9sXpPRBzk7VZaeOgh9Gz2NCwPrVxHY AqFivNBJy+LpuFsMg5UJoxgViMyndywG1QERGAdFlWF77ZI51smaTbP70xypPp4Q0pyq D1e1L8VGP/22KcqOo0MjTLErdsHzwl6bDEHDcYMGFXFDm8dR85YGfmr74xTHXAGAYobK VPlQ== X-Gm-Message-State: ABuFfoiQeep+kw+UR5+HJW1/UMOvmf5FHMNrzzuWmUf3Il40xW9Valrc 8npswdySEmIDgFUIw8lKgX5a2oG530ki/Vqexw5cxLYHR2avROWVAWKxUl/6fl8pDkXw4CyQ8qF 1Jb64P3rqDcVLumlhpYtHE7ZBUgjh6JkBAh+/KvJN5ULXTPj7BDudBVY+sVDoSi2liQ== X-Received: by 2002:aa7:80cd:: with SMTP id a13-v6mr27878990pfn.86.1539816424400; Wed, 17 Oct 2018 15:47:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV62ZdF99hMEtkt005cgRd6diyWqxavUhI9o94ACi2zR6EyEr85+Ho1jZ8us7/MI09xyD/aq4 X-Received: by 2002:aa7:80cd:: with SMTP id a13-v6mr27878964pfn.86.1539816423736; Wed, 17 Oct 2018 15:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816423; cv=none; d=google.com; s=arc-20160816; b=MX1JKToxTkGDmfhJOZnzdtdBudvXMVjX0sfxlI530DEKeGTyWAG90YQQnMd2CXExHO 4CGRNNeOiXO6JFa3OhIxi/uBGFT3gI0+c0t0fSvorh2+oST/737UWSTA8I2YVyeODwIG DVd7wvT/SjQRV/BSBQCADZCc0A8ltzye6LupwBruhxgs+3PKyaAYutqiALwvKHVdXlAt enNu4MM9E2qQqmtYEgeJH8z+II/thPuZKkft38d5SX+B+j/JqbCymR4F1wtM/Ps2Kh5P 1DI0w+5QRAa4fgco0GidOkOrmL6lAeMsoSb2L6+UkaWPYQZU+OThI2E8DljR9HbYbDGx R7Lg== 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=SGDSArbiullpYs/XPOG6T2xvgHyk5haCgm1b67adURI=; b=fT7iHO4uy+hm6XSd9IWfet70HBFXuq/V0GeQApSmTushcTTxIOXPejv+ayQf+hTzvh yUPbTIbOUSBUzKJcMgYpqGkSJKVyt/uOdyizZz+45Eok4brlg7NpnAGJdmX1a+KWfRg4 q0GkrKKmoISazUxg/LDhTT+gCEAz5cIiurF4mdd/0tMqrH/LQ5ZfKndkiLfpeQryX6co EHkuxRoFZXzc/hly+juKwR3ZdhA6tzztAYfHQf/hY1QMVf+n4DY8OLsW3JCYN80J/aN2 XeYwj70DiykcxO3556aIT4VhXAIMVzz0pGvOqYWnPcTl5rUkHmhWautlnEmnkPPzVEYT oh2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=GpfsTTzn; 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 bb10-v6si18506072plb.359.2018.10.17.15.47.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:47:03 -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=GpfsTTzn; 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 w9HMjJCk190217; Wed, 17 Oct 2018 22:47: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=SGDSArbiullpYs/XPOG6T2xvgHyk5haCgm1b67adURI=; b=GpfsTTzn2FDJOHVvdOCtMqCeAseCxfMgHNLE+mQwEdG77npdgHddYIEYM2/zi1ISAPsz R1VueayZv2tBM8+cEkl4KaeT6O+U0lPnv+Diw7fgZSrYBNQi2h3AVRgf2fKjOcCcPOln x7LBzYy72Lzr01waDkzXsU6XUS5fhmNhe9nJKTH6Cne3lb+e/iNbcI/fZOQwe3horA/e LVYfol8SX9g2G7c2dkZsQ8+z6G7oIt+lP09n8ih1aj9HxyqCjQD4CAZAlwC+oK5pc5iQ KlDXEvLyj0M+NlTzelagWWcojei/EswJTYptda+tlV835Uuo7rIkh9xzkDZrVifjCe6+ XA== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2n39brhp9b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:02 +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 w9HMl2s7013248 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:02 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMl1rL031780; Wed, 17 Oct 2018 22:47:01 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:47:01 -0700 Subject: [PATCH 23/29] xfs: add a per-xfs trace_printk macro From: "Darrick J. Wong" To: david@fromorbit.com, darrick.wong@oracle.com Cc: sandeen@redhat.com, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, linux-unionfs@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-btrfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@oss.oracle.com Date: Wed, 17 Oct 2018 15:46:59 -0700 Message-ID: <153981641972.5568.6155004838582569988.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=966 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Add a "xfs_tprintk" macro so that developers can use trace_printk to print out arbitrary debugging information with the XFS device name attached to the trace output. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_error.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h index 246d3e989c6c..5caa8bdf6c38 100644 --- a/fs/xfs/xfs_error.h +++ b/fs/xfs/xfs_error.h @@ -76,6 +76,11 @@ extern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag, unsigned int tag_value); extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag); extern int xfs_errortag_clearall(struct xfs_mount *mp); + +/* trace printk version of xfs_err and friends */ +#define xfs_tprintk(mp, fmt, args...) \ + trace_printk("dev %d:%d " fmt, MAJOR((mp)->m_super->s_dev), \ + MINOR((mp)->m_super->s_dev), ##args) #else #define xfs_errortag_init(mp) (0) #define xfs_errortag_del(mp) @@ -83,6 +88,7 @@ extern int xfs_errortag_clearall(struct xfs_mount *mp); #define xfs_errortag_set(mp, tag, val) (ENOSYS) #define xfs_errortag_add(mp, tag) (ENOSYS) #define xfs_errortag_clearall(mp) (ENOSYS) +#define xfs_tprintk(mp, fmt, args...) do { } while (0) #endif /* DEBUG */ /* From patchwork Wed Oct 17 22:47:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 10646471 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 904D415E2 for ; Wed, 17 Oct 2018 22:47:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 81681288C7 for ; Wed, 17 Oct 2018 22:47:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 750BD288E7; Wed, 17 Oct 2018 22:47: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 1566B288C7 for ; Wed, 17 Oct 2018 22:47:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 046CF6B0291; Wed, 17 Oct 2018 18:47:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id F36E16B0293; Wed, 17 Oct 2018 18:47: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 DFEEA6B0294; Wed, 17 Oct 2018 18:47:16 -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 B2ED16B0291 for ; Wed, 17 Oct 2018 18:47:16 -0400 (EDT) Received: by mail-yw1-f69.google.com with SMTP id b76-v6so17579304ywb.11 for ; Wed, 17 Oct 2018 15:47: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=5749FIFK93ihy3lPNOQ7wkYeCVTZYvwQHKIL7IXrY6w=; b=ft024OZMu1cvnT2IukJtt87Itp//GymrvlpB5tKXh4hynkyfOrITrtoWVvVfv5pz8U 4LAAsjgvPC9ypYRr/l4qkMPi8RU7woJeIgD2PrwVtuoJQgJWXtff32/os2VsxTFdw+8B 6MmxZCi3eOuCLoOu0WRKnHMm/iEP3fPpGx1tLlqwvrMw5BZx7JnsSiTFAzyinQH5i+s9 Hnw9XQV9MtvekesmQ8HsOZpuyBMYcio6KI2wF8th6XuQLxfCYS+RbRMV2BYKfbhEc/Gk tZQXJw5VscSCbhX2ZPKKDPQQMarlgNerP6FqzJVkUtqajEnWvcEgdl3Gzsc/ce+9YJzW a8XA== X-Gm-Message-State: ABuFfoj+AOxFiEASAzh12fFvzu71fA3ekIYVJeWKiiA96EyH630kR2OW k+4VGkMWetWmE8WFADbdbehKUpbHHW6GXnpveIzpceOlfjEixM8N0c7Lq45KghxpCa5QfTYtVE5 J7XlgsLS/gKA6lg0OoSa3wDti0CTcDQY8uOvtWkzYqdhrDYQOPMfef0neK1zaxl/rBQ== X-Received: by 2002:a81:ed8:: with SMTP id 207-v6mr15900477ywo.425.1539816436494; Wed, 17 Oct 2018 15:47:16 -0700 (PDT) X-Google-Smtp-Source: ACcGV613pH3TLNHtRowMhqxy9EEy1crr7W9Mf+0XH8KGzZX+mK+Jbt1YClX2V53nYqDMp3A8rH6U X-Received: by 2002:a81:ed8:: with SMTP id 207-v6mr15900460ywo.425.1539816435856; Wed, 17 Oct 2018 15:47:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816435; cv=none; d=google.com; s=arc-20160816; b=jEruccukccTYOLPTqHfpPBmOTYUR6UqSFtGB5SbJPQ47k7fJqDX3oyCSd9yCcKY+0t 1AlVKMqnEkp/3a6z20axbfLey5g8x+KKavhkTulEdqgrmi1ptI5qRQXtMD655vUV0iij z7OujQQpPkmd2rykTzQb+MYPgoavc/ceNtluGPcf22qu5qwAT0x54DKA1tyFD9XdxF5k DsSknHar+IrOtN6qj2QdWLGy7KHNqkog/bqGehn5n2Gt9HHDmsnN0vSGanavCmDOqe7O 3lkTWImZaxeceac39fQM2zH1FumkINGpZ+Cy8VauNJ784PUUy21Elu9CwbDEWvXYZA7D bW0g== 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=bMlDzQksZeTP0b2k0s6NQyHUMN4NHmSWElqwg4iVOcExmRDc7Ac8Mr4Mv1ts3VPfxp Kll+1odipoUis/Nd/snHc1KEzpRsGrG3fUhZHKI7NTK7kceQ90xUNunbOFIx7WHOCM9v D6INlL9EE9QgvVQLX2MTshlV++DhDAW24q1LiaJcBsJCLjBSexZ99qUInk5pGWheeHGo C0JMkLT+PA8Mr6P/nmbWQwKhTjXaRakSPMPq8lXW3EH9t/OoJKNwu2BeVJLAcoFf2+QF b9Jx3etq77Sk1QVcjg2brdCQiUvlftkoMOibJibTFr4WoIPVlnbAqG9fASasrkzSU5pM eZog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=qoLvGvXL; 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 h5-v6si3930282ywb.278.2018.10.17.15.47.15 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:47:15 -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=qoLvGvXL; 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 w9HMhlRq048467; Wed, 17 Oct 2018 22:47:15 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=5749FIFK93ihy3lPNOQ7wkYeCVTZYvwQHKIL7IXrY6w=; b=qoLvGvXLW/mrOXWPJD7EXkzG6Z31dK3ldUbZ74sXxqpN0oTWNkjoEqRr/lcWC4x+PKVF t0QUEBQw0LlSo7KHBWE5XXuRt3y8VMEG/+V6WiL3zutRxXaLCAvDISDzaDN6CbVODyov FWixDpXUva3ebZg1ZTziiVmKnUAfhTjRDMx4E5+VVusNDonLaEPXM7S4Fwg73obGiLrH uyVUUI80d+OiAx28Rk7ld79sY3W3f0JZtkOL6KVa9X0dMdlJrS+vpHDLyq3eNCoojx1X IpfRIASRl6ZGM49hli0UvK8hrQma8o2OzZRG8QozLQBC1Rhn9e2ptbLmTFVMXQntL+TI Rg== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2n38nq9t3j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:14 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMl9Qf012414 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:09 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMl8er029254; Wed, 17 Oct 2018 22:47:08 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:47:08 -0700 Subject: [PATCH 24/29] 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: Wed, 17 Oct 2018 15:47:06 -0700 Message-ID: <153981642640.5568.16793693439327747778.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=947 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Wed Oct 17 22:47: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: 10646473 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 EA0AF15E2 for ; Wed, 17 Oct 2018 22:47:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB4ED288C7 for ; Wed, 17 Oct 2018 22:47:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEBBB288E4; Wed, 17 Oct 2018 22:47: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 585B9288C7 for ; Wed, 17 Oct 2018 22:47:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37A936B0293; Wed, 17 Oct 2018 18:47:22 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 329106B0295; Wed, 17 Oct 2018 18:47:22 -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 21A706B0296; Wed, 17 Oct 2018 18:47:22 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by kanga.kvack.org (Postfix) with ESMTP id D0D276B0293 for ; Wed, 17 Oct 2018 18:47:21 -0400 (EDT) Received: by mail-pf1-f198.google.com with SMTP id n23-v6so28015570pfk.23 for ; Wed, 17 Oct 2018 15:47: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=LiozndoqC/TzvqN9AZSX3PUuVQc7boe5NscE8EdW/X4=; b=pWwS0l1l7Co9k/LXDK4pjeDDUF7rUspzQ5+lN6I+5McxLyBl6AQW8qTbfKvbIqhF63 N+G1rEYPza8UC6INkJucT1cFLccWSREVxiJlmslA/LECPdE5+F14eL+Ya3avJVcspDfq 78gSq0DbyLruX4DjcY2y+FLGI9yqNEKUg6aPis6B64qqYPnCqv1RqlDziQ5UMsSSb7Gg HQPIoqAg0UW3deEmX85tnsLiolHyUOkVVVAvq1BhBIBKiIJ8GOJLkSavf1AyIAaa3oU6 AnEKs6clfDRvcAP/HnfwN69qze2Us6uqnpuVyuqHKZ4D5dprdcOaYMsNF796dnxdPdFr JXsA== X-Gm-Message-State: ABuFfojZI7EgntPsPMc98qGMibdJ/+yFzyvgqk9OqwyNUJVt5xy3WQjq 1bZWjAhE6LspRclJ/SttvZ2/qfJH8F9Jh/H6g+zY0a15do3Dbfxl36laC1Fkxepm/B/XbPVS9C+ VG8uUQ62Yc784xqfGIQxqKyUeTTs+d5yoDoUZHzeNApU8o96xxuStUo2UmH/i2MhjdA== X-Received: by 2002:a63:4904:: with SMTP id w4-v6mr26101005pga.303.1539816441531; Wed, 17 Oct 2018 15:47:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV623XLnj2CW5KgEC2FjhRhLdzq7QDD5fOZ58IuLgpIjmAR5dLQVzEElkbJAQRS6sejoTsq2Z X-Received: by 2002:a63:4904:: with SMTP id w4-v6mr26100980pga.303.1539816440956; Wed, 17 Oct 2018 15:47:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816440; cv=none; d=google.com; s=arc-20160816; b=rC6yJQ0av1AHwsnfig0YwXi+0uakKo0dfXYVvGN2lCOG92lg08/7/fNRsgXhZLqU7/ lbP3YlJsx4swR9Y/Z+S55/b3fjQPBcpPPwisvVowrSUhzQl3aLzbsXgzeDvjjfTLLmfJ rlQwdI12YgkwzUePLlGW/eAF9TMA9Dqt0p3FsKRaVijZwWJWskw83erBKXl+0z+od0vA wZ8Fl3H0PiKH8raNvjer6V6BtkS3oKmZo18XgynarAV9BvnaWYxX5p22mfzpei6x1aBU PkUBzovgeAlNIRu0G+DENqskJbtP8XhLQnU/bNEP7//2pqc7EluAPjT0cFU/AHxmwne8 PXsA== 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=Id5gMJbATpWT+eSD88aQLSm7wFHfBbBSO1KZW0JPi2JFZyoxyrRs2FKslox/Eta1ti f8AwyiYNeNmMDRDtgZ1404Or6x7Vj7XqhtsNjt6PGY7/5v1IBbQvtGN0F/Aw7gN2uk3+ EuZTjY2wWwu+yRwLcRuDVSAnZKEjNjWM4dT6JCN4tof03MOkHyqFz8Wj4tmUibih5tQd 3p3Xd+wlvvgueJAgW/99pBJzYkg556sDTIIp4OzRjZoU/bKqhB7Xez83CtdNEypcENYb 2bK5PRPM8V7Ca8qAJkiHt++tSPqk1/HEzaR1lP5lYoHg3qWEVeeDhbZ0c8N2Bd++5xBz Gw1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=q4NysuBL; 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 94-v6si19943188pla.11.2018.10.17.15.47.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:47: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=q4NysuBL; 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 w9HMiGVl040211; Wed, 17 Oct 2018 22:47: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=LiozndoqC/TzvqN9AZSX3PUuVQc7boe5NscE8EdW/X4=; b=q4NysuBLWlyn5Azt58kZ18x53W7uwDuEmMqu1CDI5KXa+AWrw+CeiYqw3+cYFXUzQwd9 oBqKgi6yAHhBEp+hZYU3Yc7nM0219K3ra0hekc4VijOKpbOujxXFwoXbVsrTwf8ckQ6Q 7RtWE5pCzdKO9Xz201SEMNDLXkryVXkaMac/K/+xEY4034riBKPEniLJecgnkMi8/rs4 rGNILnjfCf56jRKr5v2X8xC7LChch+h3BL2JX9RQ0l0dZfnKGdx4O3X0EuhlNDiwUGVK VG48MTZp75WfXupTPSpNFfm0a6IGSfwp5AopBqjaJ0ZN3CmzWHZx7g2BBWpKg46EIGnH yQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2n384ua071-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:20 +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 w9HMlFA2008571 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:16 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMlF9p031923; Wed, 17 Oct 2018 22:47:15 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:47:14 -0700 Subject: [PATCH 25/29] 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: Wed, 17 Oct 2018 15:47:13 -0700 Message-ID: <153981643329.5568.5878961664707094374.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Move the offset <-> blocks unit conversions into xfs_reflink_remap_blocks to make the call site less ugly. Signed-off-by: Darrick J. Wong --- 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 Wed Oct 17 22:47: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: 10646487 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 CFFDB157A for ; Wed, 17 Oct 2018 22:47:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C19B9288CA for ; Wed, 17 Oct 2018 22:47:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B62C8288E7; Wed, 17 Oct 2018 22:47:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FBAF288CA for ; Wed, 17 Oct 2018 22:47:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D15E6B0295; Wed, 17 Oct 2018 18:47:24 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 885CC6B0297; Wed, 17 Oct 2018 18:47:24 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6AF226B0298; Wed, 17 Oct 2018 18:47:24 -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 390336B0295 for ; Wed, 17 Oct 2018 18:47:24 -0400 (EDT) Received: by mail-yw1-f72.google.com with SMTP id b70-v6so17905945ywh.3 for ; Wed, 17 Oct 2018 15:47:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=jBhmb/N7l//SEdkHcVUE3iIqA8iaNxSFon2zX2S1w8g=; b=m4+FdQzH1sUTbVcW3RctoNwjnrLdsjp7lf9Px+hnHpjUfU6SaL/PMWUVQDhnU/ww+o 9tlvaL7rX/FyzsVLRorQ8EtxnFvWFa/mbDLcAkktX9eSTk40jTWNNQEh7+Xk9QBvKRQk xfaPQdU/bg5QVw5rPjnk589wxPlanoDLJGuPGAcVg/dVYA2UZ4GMRf30uO+x1eGWzWZt s5wPdETgeEeP9vo7MYsOB+IpUwJAXerACSJIBKZAU57abYMZlPFE5zcw5YmO1j2/Ys7g FD45knTsE9DcrxJfwvHmOqMeYS6K0AMebKRtOHL8Z/yUa982x22LjUAJiJleEj3F5UnZ Ghlw== X-Gm-Message-State: ABuFfohpRtrYqBz0BH4QOcB7qo30Gv4h6Yjg1MjpQgkUeDAybjSFCCLk 8Ug97FiuKgA9fD4mVLXtDyGzTRGE/XpD7XNWfqutp8A6tdiMkbpwxwxp0x/IYXpJ0irc7OjWec4 5kgfjXL9ALjnkh5UdfLcV+Ex9fAwV/agWceHKmJLiJYKlRBW+uowPtCIyKh7b25M1MA== X-Received: by 2002:a25:e443:: with SMTP id b64-v6mr11717633ybh.396.1539816443940; Wed, 17 Oct 2018 15:47:23 -0700 (PDT) X-Google-Smtp-Source: ACcGV62Geocj4zpbReYcmna7pO4/O0wYORuZ9h4HOqBWcx3gj3OAzg0aelpBxImuj+CyQNqUfiY2 X-Received: by 2002:a25:e443:: with SMTP id b64-v6mr11717604ybh.396.1539816443222; Wed, 17 Oct 2018 15:47:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816443; cv=none; d=google.com; s=arc-20160816; b=k9YICeeCDkTibSTJ8CuBear/shF4GSAlXBDQJ74x6wpJkSo6YtiSIImgCokxiCkl4Z 4OECe/7vAYYX23EREJ8H976leA4x5zGJugrZRx+TwJmz8JMBdbJr2Dxt+VEfmye6SLMy OZ7vQbo2thWxh7COl563Vhjnj3S1FYRhJ/jVQm1Yn2W7vSSctw11gDEd4H3+YKvtTi+P SCwMl5lOBGPfhwjke6hUTdkKazbL4xAq9K1sDYt5AJovBay6Yjkga7wAMmYKKqBc7lw9 12tkHgj50Bnd2c2KhDunJMaSZRxpBG/PRMwq6gw06yMZKMvkZrx4B+HPu3j5/Ebb3MtL JpMg== 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=UqxoZlGRutXiluR88JDPyp3Hm53W/QwaEKSM0ns8tTfS955KXt0GaKaoGkEydcsiZ6 my/cFTHWPr8qR+PBsZCJyqopf32VaPceuy2o/rhWJb5D3cze4JfngWNXHIDtfyIJKgJo k9YMfLvZI295LNUiHoKjsa52A8hECjzlKdp3nQHDw0wcMeVkIv40ni5/2YfobNiPcTF2 aFqrLb6bSDFFjNaD187DmtnElfjJlS44PCwy8Zt6ckpktZpmBSHaSYeoQ3BOlIG/LgMF NkD1M4uRzQyFdDPmuoaFymWMS4AfBlXqk6z66abkmWuJP+lsKFGnG6DAtXqNshbz4hkl IInA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=wfwOTMXn; 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 w6-v6si7192458ywl.199.2018.10.17.15.47.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:47: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=wfwOTMXn; 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 w9HMhlRu048467; Wed, 17 Oct 2018 22:47:22 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=wfwOTMXn49H6rQz0BKn+Qzw8yNcqwuWtvlfuAAJvFbiwKBukNM/MR6Vw5fYGNEgWxqmT jS/FC2vlm34p8uvG7rXSW026I4ErIYQeDgB7jYJw+HtPdS4fQL25ys40TL5j3iBe4gax 4eRsseZqvqzfOn6A76nP20CFOhhVYyayVGesKMtQHlxM3enw11eTo6zNWZXxvmcy8jo3 8ZP9y89ZVzCj/QC6gbBeFnV81vc+bY0/zQg8Yqzhs7r3Sf7wZURzSZbsrEIJClF7ZF6v u3jHSwjFvAlFSB3G7kq9uaWJixVQ5EkRcuoDjafZa+hdeC2qxzUxI7L26kmU0Jx+lPHS Ng== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2n38nq9t4j-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:22 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMlLmE008918 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:21 GMT Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMlLgW032583; Wed, 17 Oct 2018 22:47:21 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:47:21 -0700 Subject: [PATCH 26/29] 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: Wed, 17 Oct 2018 15:47:20 -0700 Message-ID: <153981644001.5568.18043005268118852272.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=852 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Back when the XFS reflink code only supported clone_file_range, we were only able to return zero or negative error codes to userspace. However, now that copy_file_range (which returns bytes copied) can use XFS' clone_file_range, we have the opportunity to return partial results. For example, if userspace sends a 1GB clone request and we run out of space halfway through, we at least can tell userspace that we completed 512M of that request like a regular write. Signed-off-by: Darrick J. Wong --- fs/xfs/xfs_file.c | 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 Wed Oct 17 22:47: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: 10646501 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 30952157A for ; Wed, 17 Oct 2018 22:47:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2177C288C7 for ; Wed, 17 Oct 2018 22:47:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 160BB288E4; Wed, 17 Oct 2018 22:47:33 +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 AA6F7288C7 for ; Wed, 17 Oct 2018 22:47:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9BC866B0297; Wed, 17 Oct 2018 18:47:31 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 96B3E6B0299; Wed, 17 Oct 2018 18:47:31 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85ADE6B029A; Wed, 17 Oct 2018 18:47:31 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by kanga.kvack.org (Postfix) with ESMTP id 43F5A6B0297 for ; Wed, 17 Oct 2018 18:47:31 -0400 (EDT) Received: by mail-pg1-f200.google.com with SMTP id s7-v6so21314603pgp.3 for ; Wed, 17 Oct 2018 15:47:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=jZPaIA2I61+2o/Blz6OYutRXgyd1ozFk3SQt5++KfCo=; b=myVSANrFBs3DKtVrtBYXcg5n/a8QqcJQIRBXKiOvhVoLSpjdoymvxnNzYpmyomb381 0ybiZKgccxWAMzUGQv2GJwz3ILquVb/t9AaDv8YHJJyekS2x3OyzHEf+H4USte8TqQiq bQnDzs+snam4Cy/kvZ0frCdh6gbWTxgjhUG980nrrN8B3ZwiJjsOXDcAVpYsVLlvu9vt VuSiTDsQmyiZdPHpbBb+opW8y5MyY+jDoOHjcf/U1P8tANixabvt5kzvUf1puMmmhrYW Ko7PP+jx3C+sBUFXQsbziDkE4PpufpHNA7miW0ZkQIugxJVnqApp/UtxpGc2LoBQjQGL A8qA== X-Gm-Message-State: ABuFfoiJk+l/qTIkdaCpuMvMraGWzzeCCh45tLW/my18GCNy+A3fCw9f BPRPHgJ0ctolc0s2QWwRxldBORlM6u4lUVB3dOe2sN4p+Yhkn5oHhZLis8VstUHtnmRpt35H0f2 bPsLgT6pTPE6R8idEd5aDX4yPNyKEhyNgDmElHhvl4/EtRNmv7Y12sngA/3XPnZk2aQ== X-Received: by 2002:a17:902:5590:: with SMTP id g16-v6mr27302839pli.46.1539816450943; Wed, 17 Oct 2018 15:47:30 -0700 (PDT) X-Google-Smtp-Source: ACcGV62VTDj6+HtvodoMbaUB8ntsx35+zFzbZCYK6o5tw3MJd6uiWK9sxu2yibNQCgh1iM6bT7V4 X-Received: by 2002:a17:902:5590:: with SMTP id g16-v6mr27302809pli.46.1539816450321; Wed, 17 Oct 2018 15:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816450; cv=none; d=google.com; s=arc-20160816; b=Z9S7G+juELeVawVbnNGk5VSmOdpFDVAGZwC0zyebuc3lUEIs3U4xbKukluICuFmih7 zSSecWCNDIBkUFkS1SdQzFa6hZ3mTOLz9Tx7ppt0cHucpl3RqPADzVq6hNyegGzEpX8g hJdNeNU/9i2bV7lIOM7i3Yx/6YkUJlQz7eQok/vRk8KxpYJcpF0wOvGZLB9rFKQE+R1Q birqfSnQdPHfl9xq+5VdeIOJQ5FVzJsqmkyZqdnXs3U/hpVW2lRZijrdTC5Iati4eCUb LNXoJfktACgNxCtzobR5dc46kiM8EslVaAYcuxEkFR/F64LkKu+wXHsJAS1CBHMm9wl4 +5eg== 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=0WsKHEQM6K2G3Wel5+kege2CoTtj+W2sYzbNaqfitkvidKpJlHsib+6zXYAa0Zf55y RslrcXa2VRHUw4++F1QLb0wWyL4mvmlPn/T0ycteaKjSIY75d0gvkbZ8YcknjPNAjjsu cDSpoLH6Bu7gZY0LCdJcTyoWerODPdAbNZ/TVBIfgOIQcksexuHYqjKzL3YM5rXhvTcn PMrFj8iUhEWFsYY6QgIceiCtkYq0ITSwN1c3a1e5/OK/cc0KDMweQp8SvRQYZQnruv9/ EaVGAKNCObY+kuKqzXghIz2Yt9twQc0wrg9aZdfKsXlRYP66FPaKFuZmwmuEVdUWULtn 01RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=et99L8gB; 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 g24-v6si19287134pgh.188.2018.10.17.15.47.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:47:30 -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=et99L8gB; 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 w9HMiLoX189514; Wed, 17 Oct 2018 22:47:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=jZPaIA2I61+2o/Blz6OYutRXgyd1ozFk3SQt5++KfCo=; b=et99L8gB2MUC0kjQQLsBf5KglW6mvyO+CGSRLYvf6VyqpuLhl4nuZ0flh0AxGDtVDAvv Q4lvfKCK4C9lUkqt6reNowEq3JsreJQ851PMtcLOdOLVzfKOvmD5NLNzZd4E92RGsxRJ QOY8lGCAXMYD2BaiheEhYsRfMff+zhQbgUNWaMONWZVi7YSY+3Z4DOzjTiZJKESii6l3 P2jlzDJCpUzOz11dnHoYsohBxlNHBsTcCaal12BfRGlCaghUln7gxllPnHHL+u3mwnuh +FRoH3mcpmCclYzpn20F7XAc9Yj6xVDsqI1yZA0eZr/Bb4RMccBOV/QnsZ/voAQvp3CG PA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2n39brhpc1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:29 +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 w9HMlS3N013123 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:28 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMlSIM032606; Wed, 17 Oct 2018 22:47:28 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:47:28 -0700 Subject: [PATCH 27/29] 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: Wed, 17 Oct 2018 15:47:26 -0700 Message-ID: <153981644678.5568.12082748496872368668.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 Wed Oct 17 22:47: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: 10646515 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 2E4E3157A for ; Wed, 17 Oct 2018 22:47:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1EC23288C7 for ; Wed, 17 Oct 2018 22:47:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 129C8288E4; Wed, 17 Oct 2018 22:47:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6148C288C7 for ; Wed, 17 Oct 2018 22:47:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DCE36B0299; Wed, 17 Oct 2018 18:47:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 28D606B029B; Wed, 17 Oct 2018 18:47:38 -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 155AE6B029C; Wed, 17 Oct 2018 18:47:38 -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 DBFCF6B029B for ; Wed, 17 Oct 2018 18:47:37 -0400 (EDT) Received: by mail-yb1-f200.google.com with SMTP id h139-v6so15693470ybg.7 for ; Wed, 17 Oct 2018 15:47: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=16P3zwKvrT99XdZtAWDX1lXYkN0QjMaraaBIuWhVyNg=; b=jZ6FnlGsRO3DAWAnGFePlUMNnxu9lNkunHhpFEujyQPc2crVtlUvkH0V0syiPXCSy/ RrafWVguE30oIdJo1Uj4h8TX+4XPLannmsCQsJIj8xp+Zsy65tpcCsPTfq23O+sUTFKa m/9tm69RhgQtY4/Atabn69+1AmUCNc+mIn/1wlHqQSnuZCJidUSsiBoobTOOxUxK1Yg/ ojpPBjy0ak2UyRI0oWMzZpWqFm5NBpSQxcm8zmSa17f593b9wRbjKziLLfserN2l98dH s6BsVnwLaWS+efYYbFW1Ks9Orz+/Ehb+DeW8UujYnHFLiC5TbCA6BnspDc2VvlVBnEDy Jj/Q== X-Gm-Message-State: ABuFfoiZ99L/6gjYNkIpA89mv2jnsiIFL9LK72X/4sTgfWgkkruzvCMe CiKP32n/t+ozSbuMtph6X6X3Jq2z4gacSZvtmS/zqX3OFpEE1+0Kq5b3MBp3dA2xecnwHiFNqJy mV35fkWaB2Za4o14OBiICnwyG9eqT/lReSBvgvhTDR4pkC8MNBneweHjZMxySEWNDGw== X-Received: by 2002:a25:4c02:: with SMTP id z2-v6mr16755055yba.68.1539816457633; Wed, 17 Oct 2018 15:47:37 -0700 (PDT) X-Google-Smtp-Source: ACcGV62rJ7zSn4ocaCUIZ8dsbhCNt902nn5e7lQVpxIhRgTCUSFuX1TdmnntMGAma6kE5B0zU9x+ X-Received: by 2002:a25:4c02:: with SMTP id z2-v6mr16755026yba.68.1539816456765; Wed, 17 Oct 2018 15:47:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816456; cv=none; d=google.com; s=arc-20160816; b=LwtPx5bEmadYvxwOybsGmAeDwqozwrIxqrGDs3pZtaZFlHlogqsDZSqze0Q4skbe15 VmCA4RxkC8KxAlHNe1B9McalHcBa386yJauIynw7kOMgcxaUN0qv4vQPNkVhb2t06pDR JJC7YhOXjCq6wA9gavP40sOkd2OQRrwdmsF75iBMqUmmVg8xhcl3RCL7NNRN2B+irITi GaBla4wk2FGQxaFj+/MqLGil1kq/Dq4aF3pmfKbRZvN4WOVfup/mV7maKMDWQL8w0lMv Ho+4pWCivs5RVguXNmLhoUFDz354falyn3Ch+NPgYKXw6DPzzePQWhcAO8F/MKr7r8m4 u85A== 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=f2TEwfxU8o1NtTMaPnbaa9wcfPafg1G2u8U6wn9fybpA68/2EuKP6cfriey4WhLt6v 6xaCTEYJYl0bL+JmkiAvqjIhZPNpVsxYRV+QTMJWyV3T+snicA/A1FyXeIWkfhdDOj21 cskbOk89kaBMj9xLxecoY7P2+bt2xOWFODgKsxPT+cxA+28me5mNNCXCjHTNUV1EK4ER uhudJ2B77q2KxPY6sx7CSHb60r+7mbqSIRu0E/ULndS14DbN0nD4KTgqAUDSuW0VCB5V pA78vG8zWgu3o9zTpTO5fG2Eru2I/O35ZSylo69HM+0dlK6hyvutW3/FhmMlgSiKJUrd mNIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Uk+CdsWO; 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 t96-v6si6792796ybi.379.2018.10.17.15.47.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:47:36 -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=Uk+CdsWO; 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 w9HMiDGk048890; Wed, 17 Oct 2018 22:47:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : from : to : cc : date : message-id : in-reply-to : references : mime-version : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=16P3zwKvrT99XdZtAWDX1lXYkN0QjMaraaBIuWhVyNg=; b=Uk+CdsWOnlx6Vq2OEDO5DJVNNoO7+FerZZx4hOqq3mXHpCDM41OBcQGETNpIhXvUcvap h9DKzUu94QoPg8n+jP9YlIufM3cFZsAz2AAVz9CsOEnPLb6GF9Xde/l1C0Fh1ktXTyon AkS6CAIpW7aX8mdJC3BoDtJ7HWyBNqrKrZNB7hRAEwmdhk7rLhqpMmq3KTN+OCS2aFqv 4HGp0CnLjO6/4wsmCc4BFaTF49dFJdeu8zWIqjHmdli27Xpn/GfT4+zmVOjffk6Iax3V qeGBAQtSvyj0Gvip04GhSv5NlPkcwp/44WsTQOKRVlCZJi3Z5eo2i9pV/KUKkV10ccR7 ZA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by aserp2120.oracle.com with ESMTP id 2n38nq9t5c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:35 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w9HMlZrV009654 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:35 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMlZhk032721; Wed, 17 Oct 2018 22:47:35 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:47:35 -0700 Subject: [PATCH 28/29] 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: Wed, 17 Oct 2018 15:47:33 -0700 Message-ID: <153981645357.5568.13554065440987931594.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong Since 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 --- 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 Wed Oct 17 22:47:40 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: 10646531 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 C5D9F15E2 for ; Wed, 17 Oct 2018 22:47:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B769E288C7 for ; Wed, 17 Oct 2018 22:47:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABA56288E4; Wed, 17 Oct 2018 22:47: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 49E4B288C7 for ; Wed, 17 Oct 2018 22:47:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 305EB6B029B; Wed, 17 Oct 2018 18:47:45 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 2DAFD6B029D; Wed, 17 Oct 2018 18:47:45 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1CAC26B029E; Wed, 17 Oct 2018 18:47:45 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by kanga.kvack.org (Postfix) with ESMTP id D28576B029D for ; Wed, 17 Oct 2018 18:47:44 -0400 (EDT) Received: by mail-pg1-f197.google.com with SMTP id m4-v6so21184147pgv.15 for ; Wed, 17 Oct 2018 15:47: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=jIAzzc18fmqpZ/u/wL5JmiNfFJR+FqDbUB467dFODYU=; b=cztuBnXghIpjn31KtOEW2P3kksUTUTvMFB9hh7YPIYryzpT9iaoRnI43bi6YN23+yX 2DBCVz547KUOV/z9mIP1Ew7ANXPno12NHgpqLjurwhqGrLwQ67dxR0lmCfbAyRMpgCEW odWqmk3/3DwBzrTiHT4FMj7LjZ0K8lk003GVWz6SUamZpBJ6Rr5qm3iFxToBuQPajttL G0Q7UofbOKIlYXlY1253/vUVJhkb3ewFi8SDjoJ0WSWhXLsWSgK3XTqQPMRCLWcaWurK nZvm3EdrBjTA5NFNoxUPEARsOvD/xTDUqD1j3dUGrxF2kn9ZIyjXu21Q+UWMh+X4LXhp tbjA== X-Gm-Message-State: ABuFfoj9DvIzHPIs70pFEvcoNvc8r+baJ3X/pMpf3bsgvPF9+wdxiW+j nH1zYifjBlNHf3PN8gkPc5B7NGsyLjUdlPfq5jvPoHYfSfO9CNtcSvsCfaJxAUzlieD5YTaEh8q 0qHOD5k9QnxucNK1oDZq7EPOztn0IeNhRbHTydfuCTODRw1NeSRxAHpVp+yzypyti2g== X-Received: by 2002:a63:7506:: with SMTP id q6-v6mr25881091pgc.137.1539816464535; Wed, 17 Oct 2018 15:47:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV60WHmL2QyIfkrRkcCYq7Ztg9eXD3LV++zB24o8Y/mUJzVAanfFCTVusq5jbjMV+KTPMK0B8 X-Received: by 2002:a63:7506:: with SMTP id q6-v6mr25881069pgc.137.1539816464014; Wed, 17 Oct 2018 15:47:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539816463; cv=none; d=google.com; s=arc-20160816; b=MPbOv71V2ml3uBa6mK3Se4rHyI2PxA0l9aneGgTPvlIFy2A4H+GT6tYVSmB/f7wTIF H7Lf++sN2PFTFJgFgjKEIFRXkZgKx4/yJmEe8bkSUqSWJ5Yz9ALOQmkFzgCIINAGPSz8 7he6H81xK3dQduE1BylSt+KQoBiQtiI+9xOnPJ0LJBZ54Zan+Aj7hrjk2dMA12ILMVV8 9hy4pGR96PdZ7HQgxHEVo8awBTv6+7LbsBYPGHEDFxR/8gAck/95xsGjzukC5lLBzq7a YU7VL8tMqNTCGQlZPHcnLZ3wAy3Q07h0B+CzZR03FShanPcdqvA7udhTa582NXqTQZvW 8RCw== 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=Q1w3iw+zsLpsTrkz8TyNTcZ6Hi+7W8hq+vxYjLuklqAR9RBKj9VkfdziCWr4bvftMp 3pNoPGfzOr868B+Dumw34rs+Ymcg/qr79xB5M9sLmHSJ0wL4a/u38yuL1PpWyCukk37w kfgVoUmQseYcSvsgzczQbBZL8mwsCCoghffkTunW9P2q0uTybBJKoR3rOXtRzfMLa9LJ 8qi90BtSEqswazbCyDA4ujJ5RuyKa5xXDrtIS313pOszjnTzcnu21uzTlwYgy7XOhUUN tiN8710k3lTRbhPuWoldSIEi+Ccgl9a04BH5UWPqqZzeehzcyMTi9En/XdnYlJneCzjJ 3QCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=sOaVtFlF; 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 d185-v6si14331803pfd.260.2018.10.17.15.47.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Oct 2018 15:47:43 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.85 as permitted sender) client-ip=156.151.31.85; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=sOaVtFlF; 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 w9HMiGkT189473; Wed, 17 Oct 2018 22:47:43 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=sOaVtFlFmuGfSGGEryyxYpPVZSMUeGhKV3nKWZU+P1e252Rk2IiyNjV12YEx/9QM8HXf 3vjy/ehgTK1KERrMDye+MGTZeMvjn+vFwAXQdymuBAdiQXd8lJ2/UGiJS1fKx+ubP5no XVVlIO7qQRbNyFnRuJka2lGmODDWrPf27/UIGYu3aleL2Jt8MllcnQstEcLxsfcOcoqe H/ZqdZ4PcaWtcYEnLmkuYUZ0z3xzoSE2PfWydWQTmJA7wtD7UxYOCHpDQnATvuTWkqYa 6pshZ6dUnpxyfAqJQmlkDMRALAs/0awyLFymHeYvEAVI5fuflOrisUMW4IbKZ4Up8pjI qA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2n39brhpd8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:43 +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 w9HMlgdj013644 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 17 Oct 2018 22:47:42 GMT Received: from abhmp0011.oracle.com (abhmp0011.oracle.com [141.146.116.17]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w9HMlgXE032742; Wed, 17 Oct 2018 22:47:42 GMT Received: from localhost (/10.159.132.177) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 17 Oct 2018 15:47:41 -0700 Subject: [PATCH 29/29] 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: Wed, 17 Oct 2018 15:47:40 -0700 Message-ID: <153981646034.5568.15367504587850383353.stgit@magnolia> In-Reply-To: <153981625504.5568.2708520119290577378.stgit@magnolia> References: <153981625504.5568.2708520119290577378.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9049 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=865 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810170188 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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 --- 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);