fs/remap_range: Pass the file pointer to read_mapping_folio()

We have the struct file in generic_remap_file_range_prep() already;
we just need to pass it around instead of the inode.
Signed-off-by: default avatarMatthew Wilcox (Oracle) <willy@infradead.org>
Tested-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Acked-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Tested-by: Mike Marshall <hubcap@omnibond.com> # orangefs
Tested-by: David Howells <dhowells@redhat.com> # afs
parent c14c6843
...@@ -146,11 +146,11 @@ static int generic_remap_check_len(struct inode *inode_in, ...@@ -146,11 +146,11 @@ static int generic_remap_check_len(struct inode *inode_in,
} }
/* Read a page's worth of file data into the page cache. */ /* Read a page's worth of file data into the page cache. */
static struct folio *vfs_dedupe_get_folio(struct inode *inode, loff_t pos) static struct folio *vfs_dedupe_get_folio(struct file *file, loff_t pos)
{ {
struct folio *folio; struct folio *folio;
folio = read_mapping_folio(inode->i_mapping, pos >> PAGE_SHIFT, NULL); folio = read_mapping_folio(file->f_mapping, pos >> PAGE_SHIFT, file);
if (IS_ERR(folio)) if (IS_ERR(folio))
return folio; return folio;
if (!folio_test_uptodate(folio)) { if (!folio_test_uptodate(folio)) {
...@@ -187,8 +187,8 @@ static void vfs_unlock_two_folios(struct folio *folio1, struct folio *folio2) ...@@ -187,8 +187,8 @@ static void vfs_unlock_two_folios(struct folio *folio1, struct folio *folio2)
* Compare extents of two files to see if they are the same. * Compare extents of two files to see if they are the same.
* Caller must have locked both inodes to prevent write races. * Caller must have locked both inodes to prevent write races.
*/ */
static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, static int vfs_dedupe_file_range_compare(struct file *src, loff_t srcoff,
struct inode *dest, loff_t dstoff, struct file *dest, loff_t dstoff,
loff_t len, bool *is_same) loff_t len, bool *is_same)
{ {
bool same = true; bool same = true;
...@@ -224,8 +224,8 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff, ...@@ -224,8 +224,8 @@ static int vfs_dedupe_file_range_compare(struct inode *src, loff_t srcoff,
* someone is invalidating pages on us and we lose. * someone is invalidating pages on us and we lose.
*/ */
if (!folio_test_uptodate(src_folio) || !folio_test_uptodate(dst_folio) || if (!folio_test_uptodate(src_folio) || !folio_test_uptodate(dst_folio) ||
src_folio->mapping != src->i_mapping || src_folio->mapping != src->f_mapping ||
dst_folio->mapping != dest->i_mapping) { dst_folio->mapping != dest->f_mapping) {
same = false; same = false;
goto unlock; goto unlock;
} }
...@@ -333,8 +333,8 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in, ...@@ -333,8 +333,8 @@ int generic_remap_file_range_prep(struct file *file_in, loff_t pos_in,
if (remap_flags & REMAP_FILE_DEDUP) { if (remap_flags & REMAP_FILE_DEDUP) {
bool is_same = false; bool is_same = false;
ret = vfs_dedupe_file_range_compare(inode_in, pos_in, ret = vfs_dedupe_file_range_compare(file_in, pos_in,
inode_out, pos_out, *len, &is_same); file_out, pos_out, *len, &is_same);
if (ret) if (ret)
return ret; return ret;
if (!is_same) if (!is_same)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment