From patchwork Tue Oct 16 03:19:47 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: 10642901 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 D639C18FD for ; Tue, 16 Oct 2018 03:19:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3ADD29ABC for ; Tue, 16 Oct 2018 03:19:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B846E29AD2; Tue, 16 Oct 2018 03:19:56 +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 45832299BC for ; Tue, 16 Oct 2018 03:19:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE7326B027E; Mon, 15 Oct 2018 23:19:53 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B42AA6B0280; Mon, 15 Oct 2018 23:19:53 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E2C36B0281; Mon, 15 Oct 2018 23:19:53 -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 52CFE6B0280 for ; Mon, 15 Oct 2018 23:19:53 -0400 (EDT) Received: by mail-pg1-f199.google.com with SMTP id e24-v6so16127965pga.16 for ; Mon, 15 Oct 2018 20:19:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:subject:from:to:cc:date :message-id:in-reply-to:references:user-agent:mime-version :content-transfer-encoding; bh=WeQ7JuRHLil+2Ip19vpZXJfw1JCjZG3ATcT72KvtVeA=; b=NrI199nOxTq3cI0uZPHN8ewP2XZQ/0bSe5Bt5PZMI8ubsa0OX1JirPzNCDd7IF12J5 wZ9UjjF+SKoP46wAmqvSty5IzDAXivaCVyIULub0GTon8d2TjQ3eRFVuN6Zil0rk8WUL roSy5Y9D67GSX0ucM+d3gpwDPXutmZM9JKbgrzoqS44iQADkL0owKHQ1R87IJ99nsjGo 7vDMLM9jm1/nUFdaZjyjctCTFIu1yQFxspn25+KDTNpV8xWOV+k9ghlpWI1m+KhCncqf 4Xo3uhM2OvrKnJTMk4brgsqiqALBHnM3PsakVm3ALtxp00h2g2qPikHohNwmDgN5IHGG Pecw== X-Gm-Message-State: ABuFfojb8jxCpTAHkTzLU5+KGKLJqisZTxweX0GrjlWM0p42L+Pzrl4b Nier/5VHAelL2GXC1AKXH55mALHXA2AwColst71qkaSfRMU5X7kN/YLGRTUM+yebAKZQ0sU86eQ H9BlVV9OvIdOGunE7wY3kRwEJf0vW2dUnQBfmwtKIz+b3Khv+WnLaXURGoMqhl4A+rg== X-Received: by 2002:a17:902:760b:: with SMTP id k11-v6mr19840573pll.103.1539659993025; Mon, 15 Oct 2018 20:19:53 -0700 (PDT) X-Google-Smtp-Source: ACcGV63HK+0Xiq7BDnbOYlh8K4SSt+IwchpfnezzxTaVASgkKWO1+GkqYFraC7P6AoUXJ40Ee3CZ X-Received: by 2002:a17:902:760b:: with SMTP id k11-v6mr19840540pll.103.1539659992368; Mon, 15 Oct 2018 20:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539659992; cv=none; d=google.com; s=arc-20160816; b=N7PzUtLWMupb8+xDGtiCj9Lh0QeLBwhRfCbpA0nIHumFNi9tBY2gLKyCoPlQ7vPQD7 EbXFPWBs+/prOGVMSpctfVC7wdDCDDUoQwqKpnky0OrnB1mTpBYqKbzv/IRH+WiuMwKt PypkMnq+H/i8I0F9rZiEg3X3AxpcDvFqymnSpMd6CLWXBEoOlDqRiDRNL/fsXtqZSplA Mt/s2GkXDMi0VhHzwvYCY0V1Y1q/NFLMn9Pn2nvytLAPZtJINlk8sCwstXGwHjZEVC8B iLrzu/Mj4Gl2fcUZRMoqpDtHdTbmLxwSEzxRNQUy/widv1QxjwRavy5mfEulZEYNg+uM eSvw== 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=WeQ7JuRHLil+2Ip19vpZXJfw1JCjZG3ATcT72KvtVeA=; b=ozzpkR5MJG8/MRlFFExccM7/4yDQBhzzGT58eCoIBB7U7JiObc/1AO9yVeWChov8g9 Ul6AmVUgvJMjEwRHcMetYMBFNio0MS+mfh5i0zbFfNjv8wNgzafsJuCCYhJ6g05YqeoE ByLqRY3CjAc9rtdmlpvC/CwGK9Vgii4i0L+Y4Qb98v5YVifK1NfMVoxljrvwmuxFtjo8 PN0W8iYkTGfMAtzS/7f2DM/gAflWhZekWYiw1R4LxkWpIBnjzUzbfCLxIPlE71cqVzMd co5zHL127RtWYOH6EHRHJyIEGsghEy3oUklEUFZyJRX/NvqcKhQosNONTXeQP73wfcDU bM8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ErLVYyAB; 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 w1-v6si12511005plz.23.2018.10.15.20.19.52 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Oct 2018 20:19:52 -0700 (PDT) Received-SPF: pass (google.com: domain of darrick.wong@oracle.com designates 156.151.31.86 as permitted sender) client-ip=156.151.31.86; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=ErLVYyAB; 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 w9G3JosX051805; Tue, 16 Oct 2018 03:19:50 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=WeQ7JuRHLil+2Ip19vpZXJfw1JCjZG3ATcT72KvtVeA=; b=ErLVYyABB1Y44zzHfgXVm6Og51DOVo2KhuIaLJ11buXmEt0uX1uHS3pojIufl9PPAykG aIc0A5WhguXvrkV11EWIXBN6n43gZP/ONu5EJfHIGONTEJ9mjQ/7VGsdelbjNs3Qot+F LRlqY0cz7wtGavnkT0VHE8HD4talmY+q/O6EDGG7Xr5i4AKdkVUnMcDiGWhkA6xrld/M mJ+FaPakCUgQLKMkQ/Z/rNJR6fEd+WtIDvCfSBBo+wh1UjB5xZbhj0bDeEXxgrcjQXdY c7TeemQ6SB73bBTC4XnLJiGSzPuq4m7n8Xfz/JIU14x91EnicGiCVOK7fh97Mn0OR7pO 0w== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2n384tx27v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Oct 2018 03:19:50 +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 w9G3Jnm1003664 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 16 Oct 2018 03:19:49 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 w9G3JnGF006837; Tue, 16 Oct 2018 03:19:49 GMT Received: from localhost (/10.159.227.150) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 15 Oct 2018 20:19:49 -0700 Subject: [PATCH 16/26] 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: Mon, 15 Oct 2018 20:19:47 -0700 Message-ID: <153965998743.3607.1661657709759570842.stgit@magnolia> In-Reply-To: <153965939489.1256.7400115244528045860.stgit@magnolia> References: <153965939489.1256.7400115244528045860.stgit@magnolia> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9047 signatures=668706 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=518 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810160028 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Darrick J. Wong 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 791b406e8264..f6ab5beb935a 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -2019,10 +2019,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; @@ -2053,7 +2055,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); @@ -2121,7 +2123,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 bc353a5224a4..c0ae85a7bd9d 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 {