linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Al Viro <viro@ZenIV.linux.org.uk>,
	"Darrick J. Wong" <darrick.wong@oracle.com>,
	David Chinner <david@fromorbit.com>,
	linux-xfs@vger.kernel.org
Cc: Linux-Next Mailing List <linux-next@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Mark Fasheh <mfasheh@suse.de>
Subject: linux-next: manual merge of the vfs tree with the xfs tree
Date: Wed, 31 Oct 2018 11:52:47 +1100	[thread overview]
Message-ID: <20181031115247.6adcb659@canb.auug.org.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 4410 bytes --]

Hi all,

[I don't understand why all this new work turned up in the xfs tree
during the merge window ...]

Today's linux-next merge of the vfs tree got a conflict in:

  fs/read_write.c

between commits:

  42ec3d4c0218 ("vfs: make remap_file_range functions take and return bytes completed")
  eca3654e3cc7 ("vfs: enable remap callers that can handle short operations")

from the xfs tree and commit:

  5de4480ae7f8 ("vfs: allow dedupe of user owned read-only files")

from the vfs tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc fs/read_write.c
index 50680b900b52,10f9bed985f4..000000000000
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@@ -2014,14 -1880,120 +2013,28 @@@ loff_t vfs_clone_file_range(struct fil
  }
  EXPORT_SYMBOL(vfs_clone_file_range);
  
 -/*
 - * Read a page's worth of file data into the page cache.  Return the page
 - * locked.
 - */
 -static struct page *vfs_dedupe_get_page(struct inode *inode, loff_t offset)
 -{
 -	struct address_space *mapping;
 -	struct page *page;
 -	pgoff_t n;
 -
 -	n = offset >> PAGE_SHIFT;
 -	mapping = inode->i_mapping;
 -	page = read_mapping_page(mapping, n, NULL);
 -	if (IS_ERR(page))
 -		return page;
 -	if (!PageUptodate(page)) {
 -		put_page(page);
 -		return ERR_PTR(-EIO);
 -	}
 -	lock_page(page);
 -	return page;
 -}
 -
 -/*
 - * Compare extents of two files to see if they are the same.
 - * Caller must have locked both inodes to prevent write races.
 - */
 -int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff,
 -				  struct inode *dest, loff_t destoff,
 -				  loff_t len, bool *is_same)
 -{
 -	loff_t src_poff;
 -	loff_t dest_poff;
 -	void *src_addr;
 -	void *dest_addr;
 -	struct page *src_page;
 -	struct page *dest_page;
 -	loff_t cmp_len;
 -	bool same;
 -	int error;
 -
 -	error = -EINVAL;
 -	same = true;
 -	while (len) {
 -		src_poff = srcoff & (PAGE_SIZE - 1);
 -		dest_poff = destoff & (PAGE_SIZE - 1);
 -		cmp_len = min(PAGE_SIZE - src_poff,
 -			      PAGE_SIZE - dest_poff);
 -		cmp_len = min(cmp_len, len);
 -		if (cmp_len <= 0)
 -			goto out_error;
 -
 -		src_page = vfs_dedupe_get_page(src, srcoff);
 -		if (IS_ERR(src_page)) {
 -			error = PTR_ERR(src_page);
 -			goto out_error;
 -		}
 -		dest_page = vfs_dedupe_get_page(dest, destoff);
 -		if (IS_ERR(dest_page)) {
 -			error = PTR_ERR(dest_page);
 -			unlock_page(src_page);
 -			put_page(src_page);
 -			goto out_error;
 -		}
 -		src_addr = kmap_atomic(src_page);
 -		dest_addr = kmap_atomic(dest_page);
 -
 -		flush_dcache_page(src_page);
 -		flush_dcache_page(dest_page);
 -
 -		if (memcmp(src_addr + src_poff, dest_addr + dest_poff, cmp_len))
 -			same = false;
 -
 -		kunmap_atomic(dest_addr);
 -		kunmap_atomic(src_addr);
 -		unlock_page(dest_page);
 -		unlock_page(src_page);
 -		put_page(dest_page);
 -		put_page(src_page);
 -
 -		if (!same)
 -			break;
 -
 -		srcoff += cmp_len;
 -		destoff += cmp_len;
 -		len -= cmp_len;
 -	}
 -
 -	*is_same = same;
 -	return 0;
 -
 -out_error:
 -	return error;
 -}
 -EXPORT_SYMBOL(vfs_dedupe_file_range_compare);
 -
+ /* Check whether we are allowed to dedupe the destination file */
+ static bool allow_file_dedupe(struct file *file)
+ {
+ 	if (capable(CAP_SYS_ADMIN))
+ 		return true;
+ 	if (file->f_mode & FMODE_WRITE)
+ 		return true;
+ 	if (uid_eq(current_fsuid(), file_inode(file)->i_uid))
+ 		return true;
+ 	if (!inode_permission(file_inode(file), MAY_WRITE))
+ 		return true;
+ 	return false;
+ }
+ 
 -int vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
 -			      struct file *dst_file, loff_t dst_pos, u64 len)
 +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, unsigned int remap_flags)
  {
 -	s64 ret;
 +	loff_t ret;
 +
 +	WARN_ON_ONCE(remap_flags & ~(REMAP_FILE_DEDUP |
 +				     REMAP_FILE_CAN_SHORTEN));
  
  	ret = mnt_want_write_file(dst_file);
  	if (ret)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2018-10-31  0:52 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-31  0:52 Stephen Rothwell [this message]
2018-10-31  1:12 ` linux-next: manual merge of the vfs tree with the xfs tree Dave Chinner
  -- strict thread matches above, loose matches on Subject: below --
2021-04-19  0:49 Stephen Rothwell
2021-04-20 16:40 ` Darrick J. Wong
2021-04-12  2:22 Stephen Rothwell
2021-04-13 15:20 ` Darrick J. Wong
2016-12-11 23:19 Stephen Rothwell
2015-11-10 23:21 Stephen Rothwell
2015-04-14  1:34 Stephen Rothwell
2015-04-13  1:57 Stephen Rothwell
2015-04-13  2:12 ` Dave Chinner
2011-07-18  3:36 Stephen Rothwell
2011-07-19  1:29 ` Dave Chinner
2010-07-26  1:51 Stephen Rothwell
2010-07-26  3:59 ` Dave Chinner
2010-07-26  4:05   ` Stephen Rothwell
2010-07-05  0:02 Stephen Rothwell
2010-07-07  1:48 ` Christoph Hellwig
2010-07-07  3:50   ` Stephen Rothwell
2010-08-04  1:54 ` Stephen Rothwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181031115247.6adcb659@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=darrick.wong@oracle.com \
    --cc=david@fromorbit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=mfasheh@suse.de \
    --cc=viro@ZenIV.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).