From patchwork Fri Nov 18 00:07:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9486429 X-Mozilla-Keys: nonjunk Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on sandeen.net X-Spam-Level: X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM, RP_MATCHES_RCVD, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 X-Spam-HP: BAYES_00=-1.9, DKIM_SIGNED=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.001, RCVD_IN_DNSWL_HI=-5,RCVD_IN_SORBS_SPAM=0.5,RP_MATCHES_RCVD=-0.1, T_DKIM_INVALID=0.01 X-Original-To: sandeen@sandeen.net Delivered-To: sandeen@sandeen.net Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by sandeen.net (Postfix) with ESMTP id 5A93A6F7BCA for ; Thu, 17 Nov 2016 18:07:42 -0600 (CST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753050AbcKRAIH (ORCPT ); Thu, 17 Nov 2016 19:08:07 -0500 Received: from mail-pg0-f44.google.com ([74.125.83.44]:35108 "EHLO mail-pg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753225AbcKRAID (ORCPT ); Thu, 17 Nov 2016 19:08:03 -0500 Received: by mail-pg0-f44.google.com with SMTP id p66so96412249pga.2 for ; Thu, 17 Nov 2016 16:08:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=NDSlKG/jn8qVjkhbnLKTgInCzX3W3CExofd7B/6z/Ec=; b=QyrWnEsEO4dXhLDuf0QGqhQkbdHa1C+FzN9qWqSt9+6nUJAglFeVE+ivRDr0kKrhAz DFWzT9+dqNPGaBFu1CZMxEs++uV9DXwLc7R+j8uempb+mjhY1diKCvuYzHFWgMXWVMpn 3TcRE/WwHZQ3CcwQupCgmCF1tpFicGTtguhwR9JvzgrJkFd4BBLgsTxCJYl0tFfufmmA VZ37mLBmfR4G80/HNLaiCY6CzULX3WZv6C3nXZF3BT/Om46l/EH4sEgWQCZl+sTHn5Zu 8frf/15bmd8BaA9blcWaowzuzVVT8adLYxXRYsQ971UvEpy02BYsfUWVkoUaEd8EUAbF N5AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=NDSlKG/jn8qVjkhbnLKTgInCzX3W3CExofd7B/6z/Ec=; b=Ks7Ah8I5laxfn+zjFMt69vBp70Fve9imy0nd+uQ4U+Ntp42WFgyobRtLNHhiHwf5pP 1wcXPIYOkTJGs76iZGq3TxcZTe1D/MLQpKQbglKbYxVOIhcxY9jOpnwu86pC1zqtY2Wl elE3LMSae/GQyhg+lcs6b0ArxnTj8mB8jpeMctZRCt+fi0yL95e11jJDJqcvBzdbUSaN ZtucjN8O7k5GkBMi7WswFRoT5Qrx2vv37jkX/02GyVtkdGxX9i2SIN0g6NTbFBqzyZuE R1eeqLL+V7g3EzgWGP0CyjxyVIP4npf2RG/DW+TC43h0w8ycaX04fZYu7rikRxf3/3J+ J2SA== X-Gm-Message-State: ABUngvdHn6zsyUapQIzUc6/+36qY0dWNUMSOz3Fh3l00fgX8O6DVcElYclVk6uCwCAhut8/o X-Received: by 10.98.58.132 with SMTP id v4mr7807085pfj.7.1479427681783; Thu, 17 Nov 2016 16:08:01 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:200::8:4aae]) by smtp.gmail.com with ESMTPSA id c128sm11054226pfc.39.2016.11.17.16.08.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Nov 2016 16:08:01 -0800 (PST) From: Omar Sandoval To: linux-btrfs@vger.kernel.org, linux-xfs@vger.kernel.org Cc: "Darrick J. Wong" , Qu Wenruo , Christoph Hellwig , kernel-team@fb.com Subject: [RFC PATCH 2/2] Btrfs: make a source length of 0 imply EOF for dedupe Date: Thu, 17 Nov 2016 16:07:50 -0800 Message-Id: <42687716155fb892c55b56f22a995b39e543f906.1479427384.git.osandov@fb.com> X-Mailer: git-send-email 2.10.2 In-Reply-To: References: In-Reply-To: References: Sender: linux-xfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Omar Sandoval This makes us consistent with both reflink and the XFS implementation of dedupe. Signed-off-by: Omar Sandoval --- fs/btrfs/ioctl.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index e23f945..320fb35 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -3121,21 +3121,25 @@ static int extent_same_check_offsets(struct inode *inode, u64 off, u64 *plen, static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen, struct inode *dst, u64 dst_loff) { - int ret; - u64 len = olen; + int ret = 0; + u64 len; struct cmp_pages cmp; bool same_inode = (src == dst); u64 same_lock_start = 0; u64 same_lock_len = 0; - if (len == 0) - return 0; - if (same_inode) inode_lock(src); else btrfs_double_inode_lock(src, dst); + if (olen == 0) { + olen = i_size_read(src) - loff; + if (olen == 0) + goto out_unlock; + } + len = olen; + ret = extent_same_check_offsets(src, loff, &len, olen); if (ret) goto out_unlock;