From patchwork Wed Sep 14 12:43:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 9331327 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 A3DA36077A for ; Wed, 14 Sep 2016 12:44:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91EBE29DC3 for ; Wed, 14 Sep 2016 12:44:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86B0029DC5; Wed, 14 Sep 2016 12:44: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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 2E46529DC3 for ; Wed, 14 Sep 2016 12:44:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761889AbcINMn4 (ORCPT ); Wed, 14 Sep 2016 08:43:56 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:35226 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1761865AbcINMny (ORCPT ); Wed, 14 Sep 2016 08:43:54 -0400 Received: by mail-wm0-f67.google.com with SMTP id 133so361606wmq.2; Wed, 14 Sep 2016 05:43:53 -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=kJ/sdBYwxU0qiTVhSr7NCgD+bCFekfq+x3Fzw023s/M=; b=ICZ7SWii+500IiHSJZ08awS+8oIWQaNFb3AbvgLxU2cj6vuSGjhzFtuCq+camhcHrp iznpJqV1ndmbl17XBePR0mWSb6hVSY2UFOZSqc9MiTuBgbPrtQAfaLRnJfIqGeFEv9At nVLcG+xqK5V+1DSBUw4Mazh433alIWFgE2dSD8goTDfxGz/iRL/JreoqHPtaIPBEQYzi 6sowH+Oa2HatPxWyggq+t3z6lzUOMIyQ7E/K5av/DtItQQHje7aQiRQqIXiPKR/p5xqZ IiHZP3MTPlorf9KPqAHXlcyaDqNZUkvxO+bTPkh651OamqvaI339bzvpsgxlHn0o80HZ 3cuA== 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=kJ/sdBYwxU0qiTVhSr7NCgD+bCFekfq+x3Fzw023s/M=; b=A//wt/B5qlcx5azwydrXV4pcqfXdrOmSv+TENYKh6RX5v8yAQtUKNI0lCP/8FJy/65 lNzbnZxh6vR5LrFkKbQD7gSaNpoa7+odGADIa32jPb6GJlkirFH4yUZ0fy1SeVMbVJQa TqDi9NiPZAqMwnTLYOpeQwk2mC+EisuaNBAHo3Pm2ZNCeX2hJRPuvX8Q3WwGryLOWUfN irYeY8Pmr45tNlahm93byxtxD1mx1q3enbKlT/9bfwsvC3UOd7pFVl/GEvvn3GUrLaV+ IeP26vryVphcUhmJ+JvwS2sBZT09BK/HpeVNRgGbldbiwXtWHrF4twOZdFLf2BfVMjMF fQhQ== X-Gm-Message-State: AE9vXwME1+IWkiP4ErfDNkTcWsEtNNtVCGzPryGtwhjq/afhxRNorr+rGMky+mkNfKll6g== X-Received: by 10.28.54.68 with SMTP id d65mr11051419wma.91.1473857032998; Wed, 14 Sep 2016 05:43:52 -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 m133sm10629574wmg.0.2016.09.14.05.43.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 14 Sep 2016 05:43:52 -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 v3 1/4] vfs: allow vfs_clone_file_range() across mount points Date: Wed, 14 Sep 2016 15:43:11 +0300 Message-Id: <1473856994-27463-2-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473856994-27463-1-git-send-email-amir73il@gmail.com> References: <1473856994-27463-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 FICLONE/FICLONERANGE ioctls return -EXDEV if src and dest files are not on the same mount point. Practically, clone only requires that src and dest files are on the same file system. Move the check for same mount point to ioctl code and keep only the check for same super block in the vfs helper. A following patch is going to use the vfs_clone_file_range() helper in overlayfs to copy up between lower and upper mount points on the same file system. Signed-off-by: Amir Goldstein --- fs/ioctl.c | 2 ++ fs/read_write.c | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/ioctl.c b/fs/ioctl.c index c415668..34d2994 100644 --- a/fs/ioctl.c +++ b/fs/ioctl.c @@ -223,6 +223,8 @@ static long ioctl_file_clone(struct file *dst_file, unsigned long srcfd, if (!src_file.file) return -EBADF; + if (src_file.file->f_path.mnt != dst_file->f_path.mnt) + return -EXDEV; ret = vfs_clone_file_range(src_file.file, off, dst_file, destoff, olen); fdput(src_file); return ret; diff --git a/fs/read_write.c b/fs/read_write.c index 66215a7..9dc6e52 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -1628,8 +1628,12 @@ int vfs_clone_file_range(struct file *file_in, loff_t pos_in, struct inode *inode_out = file_inode(file_out); int ret; - if (inode_in->i_sb != inode_out->i_sb || - file_in->f_path.mnt != file_out->f_path.mnt) + /* + * FICLONE/FICLONERANGE ioctls enforce that src and dest files + * are on the same mount point. Practically, they only need + * to be on the same file system. + */ + if (inode_in->i_sb != inode_out->i_sb) return -EXDEV; if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode))