Skip to contentSkip to conversation

vfs: allow remap flags to be passed to vfs_clone_file_range

PATCH Superseded Darrick J. Wong 3 participants 4 messages Dec 1, 2018 – Dec 2, 2018 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vfs: allow remap flags to be passed to vfs_clone_file_range

From: Darrick J. Wong <[email protected]>

In overlayfs, ovl_remap_file_range calls vfs_clone_file_range on the lower filesystem's inode, passing through whatever remap flags it got from its caller. Since vfs_copy_file_range first tries a filesystem's remap function with REMAP_FILE_CAN_SHORTEN, this can get passed through to the second vfs_copy_file_range call, which isn't an issue. Remove the WARN_ON because it's unnecessary.

---
 fs/read_write.c |    2 --
 1 file changed, 2 deletions(-)
fs/read_write.c +0 -2
index 4dae0399c75a..2d9fed57e7dd 100644
@@ -1956,8 +1956,6 @@ loff_t do_clone_file_range(struct file *file_in, loff_t pos_in,
 	struct inode *inode_out = file_inode(file_out);
 	loff_t ret;
 
-	WARN_ON_ONCE(remap_flags);
-
 	if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode))
 		return -EISDIR;
 	if (!S_ISREG(inode_in->i_mode) || !S_ISREG(inode_out->i_mode))
Reviewed-by on v1 1/1
#1 lore raw
Quoted 20 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

In overlayfs, ovl_remap_file_range calls vfs_clone_file_range on the lower filesystem's inode, passing through whatever remap flags it got from its caller. Since vfs_copy_file_range first tries a filesystem's remap function with REMAP_FILE_CAN_SHORTEN, this can get passed through to the second vfs_copy_file_range call, which isn't an issue. Remove the WARN_ON because it's unnecessary.

---
 fs/read_write.c |    2 --
 1 file changed, 2 deletions(-)
fs/read_write.c +0 -0
index 4dae0399c75a..2d9fed57e7dd 100644

fs/read_write.c loff_t do_clone_file_range(struct file *file_in, loff_t pos_in, · line 1960

Quoted 5 lines
fs/read_write.c +0 -2
@@ -1956,8 +1956,6 @@ loff_t do_clone_file_range(struct file *file_in, loff_t pos_in,
        struct inode *inode_out = file_inode(file_out);
        loff_t ret;
 
-       WARN_ON_ONCE(remap_flags);
-

WARN_ON_ONCE(remap_flags & ~REMAP_FILE_ADVISORY);

We still do not want anyone to call do_clone_file_range(..., REMAP_FILE_DEDUP)

If we had more users of the overloaded interface, we need to do:

WARN_ON_ONCE((remap_flags & REMAP_FILE_OP_MASK) == REMAP_FILE_OP_CLONE);

With the minor fix, you can add:

Thanks,
Amir.

#2 lore raw

PATCH v2 1/1 vfs: allow some remap flags to be passed to vfs_clone_file_range

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

In overlayfs, ovl_remap_file_range calls vfs_clone_file_range on the lower filesystem's inode, passing through whatever remap flags it got from its caller. Since vfs_copy_file_range first tries a filesystem's remap function with REMAP_FILE_CAN_SHORTEN, this can get passed through to the second vfs_copy_file_range call, and this isn't an issue. Change the WARN_ON to look only for the DEDUP flag.

---
 fs/read_write.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/read_write.c +1 -1
index 4dae0399c75a..58f30537c47a 100644
@@ -1956,7 +1956,7 @@ loff_t do_clone_file_range(struct file *file_in, loff_t pos_in,
 	struct inode *inode_out = file_inode(file_out);
 	loff_t ret;
 
-	WARN_ON_ONCE(remap_flags);
+	WARN_ON_ONCE(remap_flags & REMAP_FILE_DEDUP);
 
 	if (S_ISDIR(inode_in->i_mode) || S_ISDIR(inode_out->i_mode))
 		return -EISDIR;
Reviewed-by on v1 1/1
#3 lore raw
In reply to Darrick J. Wong
Quoted 10 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

In overlayfs, ovl_remap_file_range calls vfs_clone_file_range on the lower filesystem's inode, passing through whatever remap flags it got from its caller. Since vfs_copy_file_range first tries a filesystem's remap function with REMAP_FILE_CAN_SHORTEN, this can get passed through to the second vfs_copy_file_range call, which isn't an issue. Remove the WARN_ON because it's unnecessary.

This looks ok:

But this also indicates that do_clone_file_range/vfs_clone_file_range are misnamed now, as they are wrappers for the remap_file_range method.