Received: by 10.192.165.156 with SMTP id m28csp477726imm; Tue, 17 Apr 2018 13:33:12 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/EG4I8z3I8Ixik5lKAvQZV+m/CFQaJ9SYFfJMaTM/8Sp7rTGYpOHozyO22KAxrEEc/RdoW X-Received: by 10.99.104.131 with SMTP id d125mr3016118pgc.9.1523997192253; Tue, 17 Apr 2018 13:33:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523997192; cv=none; d=google.com; s=arc-20160816; b=I/F7sB0J8cDlsaGLrMhPyN8vVDLbzIL9D/Wny+Cw25tH0JScEyEQNHkuJvdCVRflDv dVx22iKjvcl21g7aRIzIciF6qPMgzWFXS1T0MDIm6oVYHYgJpJ3GsAWsVU8ajmktNU/D JXXabISMOABfs1xTMIWQIZ9knkSo/AZ0VD79e0RtEQbZbWnw03iE13+4kNhXn2VjtVUe +gf3CpEuZpv9ggxgn0CBm3WE+cqHcKc96d3KsRycLB6+V+QO1+NhgBi7H3U+mPK8DGfr nuZAz1LHl8j+TUhqh61jBEZwhuxppj4zWRxiP2Vdoi7UzxSfoV5k6F4rn9HlTHdiqwxM EAcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=udIY2b0TzNStUXPiTkepcgnYK74vzGg287/yra22qIc=; b=ivMKuRUG85NhQCfDwnbLs6YgxrVNt3CtLmfg2zmeUbOSlwXnXHd/7JBiDaKUDfu9M/ nTNJmoYal0eBX5rvPhHfA7sRnDs2YRYDHPm4zV9DexVjnWFcuNM0o86Wxrqny28EWrUX SAeU0TulUQwRfZK8qcATUrA9q8JmdqGO1QleMV8JTXsDOvnWbAEWniZsKcJG9aYA0qED Aw5LZ8KYARLr0kPDhjPK7dvHOhlRftA+ms2dYyXmRJ9CZVKEfiuVubqatCgRQgjeFt4o 1VIjosh5rFUMa9xqb3JH/2/t9MyFVbjzGWRIoLhlpF/si3TpPiDg9cEwpe1yxvqZPbi2 rAhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BzcKEQOg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z2-v6si14637475plk.94.2018.04.17.13.32.56; Tue, 17 Apr 2018 13:33:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BzcKEQOg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752608AbeDQUbr (ORCPT + 99 others); Tue, 17 Apr 2018 16:31:47 -0400 Received: from mail-yb0-f173.google.com ([209.85.213.173]:40412 "EHLO mail-yb0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751878AbeDQUbq (ORCPT ); Tue, 17 Apr 2018 16:31:46 -0400 Received: by mail-yb0-f173.google.com with SMTP id c10-v6so9099788ybn.7; Tue, 17 Apr 2018 13:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=udIY2b0TzNStUXPiTkepcgnYK74vzGg287/yra22qIc=; b=BzcKEQOgV1heCKWIDi3jkKTFlPuyY53AyHCIRe5qAywMbw5vfb2D3o+jgKjUOx9mIx rrbqQzOibbOIx7y6ReDKifku0E7m0UfY4O3ME9Fe4OQtOjL6mKQZReANp87w56MhTxnB oZWgdqP9oBPAkUJp7KyMx3AVLJaLjQXXBfCjS1g4jG+sG0kOMGnN57nTdFNbeHoDr6dL vdRugWvGGMGG+PEXRreAAyR5fIyptUDNRxGZ/8kwpftsOoFuEmIMpejx0yahWl9jJiim e/R9MWKJrv/hUdhyvFEliOrtFumDxQII56yDKmwr3PAHfCs6/HYkLz+vJR5a0phVZjRY 4c5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=udIY2b0TzNStUXPiTkepcgnYK74vzGg287/yra22qIc=; b=UosLaqMehc10r0he8SjNAHGrpZPHt3bRJXyE2Ec4DCDq5uVxDHXUGrYB5O8t7W5LwY AIZ9jpKwFImL7pUGZjV3lN4+DGdRydB8t4DEaUgH+LSKUHMCcL4vihD3yX9gKWnkbMT3 xkBN800xRHzUFWdIBpaePi4ehonzPnOpkkflgwv7/rtHzWm6raUcnrEfohrUdO92UTnV KUkn7/906FuD9seXMgtqdKu2jRZFjN3w+ZIvpmkIbG1KR7jLCR9wgJZ8HuaAqx8ZjOHl il2KiNJMSfKHlVav71en9WdbbtlisfTMG1cpTrUKr2JlUqBlHxqg4BW9zq9YxOML/4f1 b+bA== X-Gm-Message-State: ALQs6tDHNaFp2uEc45V74DkdhYozccXCl6Nbg9cmPrPyKlJZwSLF3ZYo suuG+D7icndXOGLMN1+5ap7Xr4o3HjPz7MziD0+HXg== X-Received: by 2002:a25:2d43:: with SMTP id s3-v6mr2651322ybe.475.1523997105186; Tue, 17 Apr 2018 13:31:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.129.183.12 with HTTP; Tue, 17 Apr 2018 13:31:44 -0700 (PDT) In-Reply-To: <20180412150826.20988-20-mszeredi@redhat.com> References: <20180412150826.20988-1-mszeredi@redhat.com> <20180412150826.20988-20-mszeredi@redhat.com> From: Amir Goldstein Date: Tue, 17 Apr 2018 23:31:44 +0300 Message-ID: Subject: Re: [RFC PATCH 19/35] ovl: readd reflink/copyfile/dedup support To: Miklos Szeredi Cc: overlayfs , linux-fsdevel , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 12, 2018 at 6:08 PM, Miklos Szeredi wrote: > Since set of arguments are so similar, handle in a common helper. > > Signed-off-by: Miklos Szeredi > --- > fs/overlayfs/file.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 79 insertions(+) > > diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c > index 9670e160967e..39b1b73334ad 100644 > --- a/fs/overlayfs/file.c > +++ b/fs/overlayfs/file.c > @@ -352,6 +352,81 @@ long ovl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) > return ret; > } > > +enum ovl_copyop { > + OVL_COPY, > + OVL_CLONE, > + OVL_DEDUPE, > +}; > + > +static ssize_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) > +{ > + struct inode *inode_out = file_inode(file_out); > + struct fd real_in, real_out; > + const struct cred *old_cred; > + int ret; > + > + ret = ovl_real_file(file_out, &real_out); > + if (ret) > + return ret; > + > + ret = ovl_real_file(file_in, &real_in); > + if (ret) { > + fdput(real_out); > + return ret; > + } > + > + old_cred = ovl_override_creds(file_inode(file_out)->i_sb); > + switch (op) { > + case OVL_COPY: > + ret = vfs_copy_file_range(real_in.file, pos_in, > + real_out.file, pos_out, len, flags); Problem: vfs_copy_file_range(ovl_lower_file, ovl_upper_file) on non samefs will get -EXDEV from ovl_copy_file_range(), so will not fall back to do_splice_direct(). We may be better off checking in_sb != out_sb and returning -EOPNOTSUPP? not sure. > + break; > + > + case OVL_CLONE: > + ret = vfs_clone_file_range(real_in.file, pos_in, > + real_out.file, pos_out, len); > + break; > + > + case OVL_DEDUPE: > + ret = vfs_dedupe_file_range_one(real_in.file, pos_in, len, > + real_out.file, pos_out); Problem: real_out can be a readonly fd (for is_admin), so we will be deduping the lower file. I guess this problem is mitigated in current code by may_write_real(). How can we deal with that sort of "write leak" without patching mnt_want_write_file()? Thanks, Amir.