aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@redhat.com>2018-05-11 11:49:31 -0400
committerMiklos Szeredi <mszeredi@redhat.com>2018-07-20 03:56:11 -0400
commit4823d49c26eaf269cd2c2723bed8249aaed80795 (patch)
treeb843d3babb5b0a66a331670298fb0c7569643e11
parent2664bd0897c2889258472a1ee922ef9d4c5fa58f (diff)
ovl: Add helper ovl_inode_realdata()
Add an helper to retrieve real data inode associated with overlay inode. This helper will ignore all metacopy inodes and will return only the real inode which has data. Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
-rw-r--r--fs/overlayfs/overlayfs.h1
-rw-r--r--fs/overlayfs/util.c12
2 files changed, 13 insertions, 0 deletions
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 0ad593a85121..99f793904801 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -229,6 +229,7 @@ struct inode *ovl_inode_upper(struct inode *inode);
229struct inode *ovl_inode_lower(struct inode *inode); 229struct inode *ovl_inode_lower(struct inode *inode);
230struct inode *ovl_inode_lowerdata(struct inode *inode); 230struct inode *ovl_inode_lowerdata(struct inode *inode);
231struct inode *ovl_inode_real(struct inode *inode); 231struct inode *ovl_inode_real(struct inode *inode);
232struct inode *ovl_inode_realdata(struct inode *inode);
232struct ovl_dir_cache *ovl_dir_cache(struct inode *inode); 233struct ovl_dir_cache *ovl_dir_cache(struct inode *inode);
233void ovl_set_dir_cache(struct inode *inode, struct ovl_dir_cache *cache); 234void ovl_set_dir_cache(struct inode *inode, struct ovl_dir_cache *cache);
234void ovl_dentry_set_flag(unsigned long flag, struct dentry *dentry); 235void ovl_dentry_set_flag(unsigned long flag, struct dentry *dentry);
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index 63311c536216..73939e08d8bf 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -256,6 +256,18 @@ struct inode *ovl_inode_lowerdata(struct inode *inode)
256 return OVL_I(inode)->lowerdata ?: ovl_inode_lower(inode); 256 return OVL_I(inode)->lowerdata ?: ovl_inode_lower(inode);
257} 257}
258 258
259/* Return real inode which contains data. Does not return metacopy inode */
260struct inode *ovl_inode_realdata(struct inode *inode)
261{
262 struct inode *upperinode;
263
264 upperinode = ovl_inode_upper(inode);
265 if (upperinode && ovl_has_upperdata(inode))
266 return upperinode;
267
268 return ovl_inode_lowerdata(inode);
269}
270
259struct ovl_dir_cache *ovl_dir_cache(struct inode *inode) 271struct ovl_dir_cache *ovl_dir_cache(struct inode *inode)
260{ 272{
261 return OVL_I(inode)->cache; 273 return OVL_I(inode)->cache;