Skip to contentSkip to conversation

ovl: fix incorrect extent info in metacopy case

PATCH In review Chengguang Xu 3 participants 6 messages Jun 24, 2020 – Oct 30, 2020 Overlay filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ovl: fix incorrect extent info in metacopy case

In metacopy case, we should use ovl_inode_realdata() instead of ovl_inode_real() to get real inode which has data, so that we can get correct information of extentes in ->fiemap operation.

---
 fs/overlayfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/inode.c +1 -1
index 981f11ec51bc..a524af04b71d 100644
@@ -472,7 +472,7 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
 		      u64 start, u64 len)
 {
 	int err;
-	struct inode *realinode = ovl_inode_real(inode);
+	struct inode *realinode = ovl_inode_realdata(inode);
 	const struct cred *old_cred;
 
 	if (!realinode->i_op->fiemap)
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Chengguang Xu

In metacopy case, we should use ovl_inode_realdata() instead of ovl_inode_real() to get real inode which has data, so that we can get correct information of extentes in ->fiemap operation.

looks right

Quoted 21 lines
---
 fs/overlayfs/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/inode.c +1 -2
index 981f11ec51bc..a524af04b71d 100644
@@ -472,7 +472,7 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
                      u64 start, u64 len)
 {
        int err;
-       struct inode *realinode = ovl_inode_real(inode);
+       struct inode *realinode = ovl_inode_realdata(inode);
        const struct cred *old_cred;
 
        if (!realinode->i_op->fiemap)
--

2.20.1

maintainer
#2 lore raw
Quoted 10 lines · Amir Goldstein
Quoted 6 lines · Chengguang Xu

In metacopy case, we should use ovl_inode_realdata() instead of ovl_inode_real() to get real inode which has data, so that we can get correct information of extentes in ->fiemap operation.

looks right

Miklos,

Not related to this patch, I noticed something that could be odd with ovl_fiemap().

When passed the flag FIEMAP_FLAG_SYNC, ->fiemap() will trigger writeback of lower inode pages.

This behavior is border line for overlayfs.
I did not check if filemap_write_and_wait() ends up being a noop on read-only fs or if it can return an error.
Following ovl_fsync() practice, we may want to silently drop the FIEMAP_FLAG_SYNC flag? but that could result in unexpected results.

Am I overthinking this?

Thanks,
Amir.

author
#3 lore raw
Quoted 13 lines · Amir Goldstein
Quoted 7 lines · Amir Goldstein
Quoted 5 lines · Chengguang Xu

In metacopy case, we should use ovl_inode_realdata() instead of ovl_inode_real() to get real inode which has data, so that we can get correct information of extentes in ->fiemap operation.

looks right

Miklos,

Not related to this patch, I noticed something that could be odd with ovl_fiemap().

Quoted 6 lines

When passed the flag FIEMAP_FLAG_SYNC, ->fiemap() will trigger writeback of lower inode pages.

This behavior is border line for overlayfs.
I did not check if filemap_write_and_wait() ends up being a noop on read-only fs or if it can return an error.

vfs ioctl does the same behavior regardless of read-only fs and IIUC, writeback functions will do DIRTY tag check before actually sync dirty data.

Thanks,
cgxu

Quoted 7 lines

Following ovl_fsync() practice, we may want to silently drop the FIEMAP_FLAG_SYNC flag? but that could result in unexpected results.

Am I overthinking this?

Thanks,
Amir.

author
#4 lore raw
In reply to Chengguang Xu
Quoted 5 lines · Chengguang Xu

In metacopy case, we should use ovl_inode_realdata() instead of ovl_inode_real() to get real inode which has data, so that we can get correct information of extentes in ->fiemap operation.

ping

Quoted 18 lines
---
  fs/overlayfs/inode.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/overlayfs/inode.c +1 -1
index 981f11ec51bc..a524af04b71d 100644
@@ -472,7 +472,7 @@ static int ovl_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
  		      u64 start, u64 len)
  {
  	int err;
-	struct inode *realinode = ovl_inode_real(inode);
+	struct inode *realinode = ovl_inode_realdata(inode);
  	const struct cred *old_cred;
 
  	if (!realinode->i_op->fiemap)
maintainer
#5 lore raw
Quoted 9 lines · cgxu
Quoted 5 lines · Chengguang Xu

In metacopy case, we should use ovl_inode_realdata() instead of ovl_inode_real() to get real inode which has data, so that we can get correct information of extentes in ->fiemap operation.

ping

Sorry, I missed this patch. Applied now.

Thanks,
Miklos