From patchwork Mon Sep 12 15:06:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9326753 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7FB346077F for ; Mon, 12 Sep 2016 15:07:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71F1327D16 for ; Mon, 12 Sep 2016 15:07:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6699928339; Mon, 12 Sep 2016 15:07: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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C308B28DEF for ; Mon, 12 Sep 2016 15:07:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932996AbcILPHf (ORCPT ); Mon, 12 Sep 2016 11:07:35 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:36471 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932765AbcILPH3 (ORCPT ); Mon, 12 Sep 2016 11:07:29 -0400 Received: by mail-wm0-f67.google.com with SMTP id z194so1704961wmd.3; Mon, 12 Sep 2016 08:07:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GgKXVccKNqGE3wVdy5eWJO+hnjGRfHdeVFRVm/kUdhw=; b=vYJRspXzaczlr5zaCXKgjDBfJEHJq9whoKddVWBbGH+eHh2Jwx50Vsnhgca45WmCoF 5HRAsQAhWbnCAJB1zbcNK1gO0Sb1bOh7kqodKquKkW6aQRDiOK1mRfQsjaLWZtmbwC+z JVZBoW6O3MPRa/P2b1WKCGbPGlEl744q/EW/Qy4zDFzl/W8YlFPKXFvqIW3CvICMqa9R w46w/zMCSCztRi2D4bNZvsifafry45VmBJlOEAAkqcA6mmFFkz/vRQgS/TdXH8BHS0jV 84y/eQpJNAKcHnw55rdBytIBkl2RuhYAxBm2gRs6d/O5Bdj6rOL3fsMWR1eu41xDTSTC fILQ== 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; bh=GgKXVccKNqGE3wVdy5eWJO+hnjGRfHdeVFRVm/kUdhw=; b=bfzVIXvmM9wW2AxeEbOj9UdlnhwmroG7vkUhjg+fPqI1+OEfWi9tKWdXhMS4w55vK0 qLPXWFuznumCAtVuWyxIT5awtQOXt4kD1fWv54m8DhVe/5PmYUp/jzMgZ0LjLr6GjlMa Lv31bnnPDuW5w6JEajqnIOZeGL2w6hY0JORHu0IwQwKaceIL+THuPUqDLzq4bI1yalkF PXApJvOCDnvUJQruEifYqCPBw7++nwf4+ZfisoezrI8xbrmhcljCuZVQzHw/Q3+pKU2I dN3r/8O05pPpcMqA1gpsxgIt03h6pG1ygsB+fzS/161wm8hw1GN5dnKhQwOfAIy/+3Mb wOOg== X-Gm-Message-State: AE9vXwNkfOodsYUrZ1RCSEn4WooMiY1eEAT87iDXF+cHI3v68fqChN3QDWUGV4wPzJQzAw== X-Received: by 10.28.14.144 with SMTP id 138mr11759175wmo.96.1473692847678; Mon, 12 Sep 2016 08:07:27 -0700 (PDT) Received: from localhost.localdomain (bzq-82-81-193-202.cablep.bezeqint.net. [82.81.193.202]) by smtp.gmail.com with ESMTPSA id 3sm18313198wms.1.2016.09.12.08.07.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 12 Sep 2016 08:07:27 -0700 (PDT) From: Amir Goldstein To: Miklos Szeredi , Dave Chinner , linux-unionfs@vger.kernel.org Cc: Christoph Hellwig , linux-xfs@vger.kernel.org, "Darrick J . Wong" , linux-fsdevel@vger.kernel.org Subject: [PATCH v2 4/4] ovl: use vfs_copy_file_range() to copy up file data Date: Mon, 12 Sep 2016 18:06:43 +0300 Message-Id: <1473692803-11964-5-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473692803-11964-1-git-send-email-amir73il@gmail.com> References: <1473348594-31425-1-git-send-email-amir73il@gmail.com> <1473692803-11964-1-git-send-email-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use vfs_copy_file_range() helper instead of calling do_splice_direct() when copying up file data. When copying up within the same fs, which supports copy_file_range(), fs implementation can be more efficient then do_splice_direct(). vfs_copy_file_range() helper falls back to do_splice_direct() if it cannot use the file system's copy_file_range() implementation. Tested correct behavior when lower and upper are on: 1. same ext4 (copy) 2. same xfs + reflink patches + mkfs.xfs (copy) 3. same xfs + reflink patches + mkfs.xfs -m reflink=1 (clone) 4. different xfs + reflink patches + mkfs.xfs -m reflink=1 (copy) For comparison, on my laptop, xfstest overlay/001 (copy up of large sparse files) takes less than 1 second in the xfs reflink setup vs. 25 seconds on the rest of the setups. Signed-off-by: Amir Goldstein --- fs/overlayfs/copy_up.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c index e432d7e..32ea54f 100644 --- a/fs/overlayfs/copy_up.c +++ b/fs/overlayfs/copy_up.c @@ -159,15 +159,16 @@ static int ovl_copy_up_data(struct path *old, struct path *new, loff_t len) break; } - bytes = do_splice_direct(old_file, &old_pos, - new_file, &new_pos, - this_len, SPLICE_F_MOVE); + bytes = vfs_copy_file_range(old_file, old_pos, + new_file, new_pos, + this_len, 0); if (bytes <= 0) { error = bytes; break; } - WARN_ON(old_pos != new_pos); + old_pos += bytes; + new_pos += bytes; len -= bytes; }