All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] ovl: refactor lowerstack related functions
@ 2018-04-17  2:42 Chengguang Xu
  2018-04-17  2:42 ` [PATCH 2/3] ovl: using lowestack handling functions to replace bare array operation Chengguang Xu
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Chengguang Xu @ 2018-04-17  2:42 UTC (permalink / raw)
  To: linux-unionfs; +Cc: miklos, amir73il, Chengguang Xu

Introduce __ovl_path_lower() to handle lowerstack related things
and refactor ovl_dentry_lower()/ovl_layer_lower() based on it.

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 fs/overlayfs/overlayfs.h |  1 +
 fs/overlayfs/util.c      | 35 +++++++++++++++++++++++++++++++----
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index e0b7de7..abb5cf4 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -215,6 +215,7 @@ static inline struct dentry *ovl_do_tmpfile(struct dentry *dentry, umode_t mode)
 enum ovl_path_type ovl_path_real(struct dentry *dentry, struct path *path);
 struct dentry *ovl_dentry_upper(struct dentry *dentry);
 struct dentry *ovl_dentry_lower(struct dentry *dentry);
+struct vfsmount *ovl_mnt_lower(struct dentry *dentry);
 struct ovl_layer *ovl_layer_lower(struct dentry *dentry);
 struct dentry *ovl_dentry_real(struct dentry *dentry);
 struct dentry *ovl_i_dentry_upper(struct inode *inode);
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index 6f10780..a3459e6 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -157,8 +157,8 @@ void ovl_path_lower(struct dentry *dentry, struct path *path)
 	struct ovl_entry *oe = dentry->d_fsdata;
 
 	if (oe->numlower) {
-		path->mnt = oe->lowerstack[0].layer->mnt;
-		path->dentry = oe->lowerstack[0].dentry;
+		path->mnt = ovl_mnt_lower(dentry);
+		path->dentry = ovl_dentry_lower(dentry);
 	} else {
 		*path = (struct path) { };
 	}
@@ -181,18 +181,45 @@ struct dentry *ovl_dentry_upper(struct dentry *dentry)
 	return ovl_upperdentry_dereference(OVL_I(d_inode(dentry)));
 }
 
+struct ovl_path *__ovl_path_lower(struct ovl_entry *oe, int layer)
+{
+	if (layer > oe->numlower)
+		return NULL;
+
+	return &oe->lowerstack[layer - 1];
+}
+
+struct vfsmount *ovl_mnt_lower(struct dentry *dentry)
+{
+	struct ovl_entry *oe = dentry->d_fsdata;
+	struct ovl_path *path = __ovl_path_lower(oe, 1);
+
+	if (path)
+		return path->layer->mnt;
+	else
+		return NULL;
+}
+
 struct dentry *ovl_dentry_lower(struct dentry *dentry)
 {
 	struct ovl_entry *oe = dentry->d_fsdata;
+	struct ovl_path *path = __ovl_path_lower(oe, 1);
 
-	return oe->numlower ? oe->lowerstack[0].dentry : NULL;
+	if (path)
+		return path->dentry;
+	else
+		return NULL;
 }
 
 struct ovl_layer *ovl_layer_lower(struct dentry *dentry)
 {
 	struct ovl_entry *oe = dentry->d_fsdata;
+	struct ovl_path *path = __ovl_path_lower(oe, 1);
 
-	return oe->numlower ? oe->lowerstack[0].layer : NULL;
+	if (path)
+		return path->layer;
+	else
+		return NULL;
 }
 
 struct dentry *ovl_dentry_real(struct dentry *dentry)
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-04-18  3:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-17  2:42 [PATCH 1/3] ovl: refactor lowerstack related functions Chengguang Xu
2018-04-17  2:42 ` [PATCH 2/3] ovl: using lowestack handling functions to replace bare array operation Chengguang Xu
2018-04-17 11:16   ` Amir Goldstein
2018-04-18  3:42     ` cgxu519
2018-04-17  2:42 ` [PATCH 3/3] ovl: introduce a dedicated cache pool for ovl_entry Chengguang Xu
2018-04-17 10:41   ` Amir Goldstein
2018-04-18  0:59     ` cgxu519
2018-04-17 11:04 ` [PATCH 1/3] ovl: refactor lowerstack related functions Amir Goldstein

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.