Skip to contentSkip to conversation

ocfs2.git: Combine ocfs2_xattr_get_clusters to ocfs2_get_cluster.

PATCH New Tao Ma 1 participant 4 messages Aug 26, 2008 – Aug 27, 2008 OCFS2

lore
Share & tools
lore

Tao Ma

author
#0 lore raw

cover ocfs2.git: Combine ocfs2_xattr_get_clusters to ocfs2_get_cluster.

Hi,
The ocfs2_xattr_get_clusters is originally copied from
ocfs2_get_clusters, so most of the codes are common. This patch set merge them together.

Regards,
Tao

author
#1 lore raw

PATCH 1/2 ocfs2: Add wrapper for the check of extent tree type.

In some places we may need to check the ocfs2_extent_tree's type, so add the checker for them.

---
 fs/ocfs2/alloc.c |   19 +++++++++++++++++--
 fs/ocfs2/alloc.h |    3 +++
 2 files changed, 20 insertions(+), 2 deletions(-)
fs/ocfs2/alloc.c +17 -2
index 5f44ef8..80dbf2f 100644
@@ -344,6 +344,21 @@ void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
 				 &ocfs2_xattr_value_et_ops);
 }
 
+int ocfs2_is_dinode_extent_tree(struct ocfs2_extent_tree *et)
+{
+	return et->et_ops == &ocfs2_dinode_et_ops;
+}
+
+int ocfs2_is_xattr_value_extent_tree(struct ocfs2_extent_tree *et)
+{
+	return et->et_ops == &ocfs2_xattr_value_et_ops;
+}
+
+int ocfs2_is_xattr_tree_extent_tree(struct ocfs2_extent_tree *et)
+{
+	return et->et_ops == &ocfs2_xattr_tree_et_ops;
+}
+
 static inline void ocfs2_et_set_last_eb_blk(struct ocfs2_extent_tree *et,
 					    u64 new_last_eb_blk)
 {
@@ -4476,7 +4491,7 @@ int ocfs2_insert_extent(struct ocfs2_super *osb,
 	status = ocfs2_do_insert_extent(inode, handle, et, &rec, &insert);
 	if (status < 0)
 		mlog_errno(status);
-	else if (et->et_ops == &ocfs2_dinode_et_ops)
+	else if (ocfs2_is_dinode_extent_tree(et))
 		ocfs2_extent_map_insert_rec(inode, &rec);
 
 bail:
@@ -4874,7 +4889,7 @@ int ocfs2_mark_extent_written(struct inode *inode,
 	 * XXX: This is a hack on the extent tree, maybe it should be
 	 * an op?
 	 */
-	if (et->et_ops == &ocfs2_dinode_et_ops)
+	if (ocfs2_is_dinode_extent_tree(et))
 		ocfs2_extent_map_trunc(inode, 0);
 
 	left_path = ocfs2_new_path(et->et_root_bh, et->et_root_el);
fs/ocfs2/alloc.h +3 -0
index a0ae6bd..8b98f40 100644
@@ -72,6 +72,9 @@ void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
 					struct inode *inode,
 					struct buffer_head *bh,
 					struct ocfs2_xattr_value_root *xv);
+int ocfs2_is_dinode_extent_tree(struct ocfs2_extent_tree *et);
+int ocfs2_is_xattr_value_extent_tree(struct ocfs2_extent_tree *et);
+int ocfs2_is_xattr_tree_extent_tree(struct ocfs2_extent_tree *et);
 
 struct ocfs2_alloc_context;
 int ocfs2_insert_extent(struct ocfs2_super *osb,
Signature · 1 line
1.5.4.GIT
author
#2 lore raw

PATCH 1/2 ocfs2: Add wrapper for the check of extent tree type.

In reply to Tao Ma

In some places we may need to check the ocfs2_extent_tree's type, so add the checker for them.

---
 fs/ocfs2/alloc.c |   19 +++++++++++++++++--
 fs/ocfs2/alloc.h |    3 +++
 2 files changed, 20 insertions(+), 2 deletions(-)
fs/ocfs2/alloc.c +17 -2
index 5f44ef8..80dbf2f 100644
@@ -344,6 +344,21 @@ void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
 				 &ocfs2_xattr_value_et_ops);
 }
 
+int ocfs2_is_dinode_extent_tree(struct ocfs2_extent_tree *et)
+{
+	return et->et_ops == &ocfs2_dinode_et_ops;
+}
+
+int ocfs2_is_xattr_value_extent_tree(struct ocfs2_extent_tree *et)
+{
+	return et->et_ops == &ocfs2_xattr_value_et_ops;
+}
+
+int ocfs2_is_xattr_tree_extent_tree(struct ocfs2_extent_tree *et)
+{
+	return et->et_ops == &ocfs2_xattr_tree_et_ops;
+}
+
 static inline void ocfs2_et_set_last_eb_blk(struct ocfs2_extent_tree *et,
 					    u64 new_last_eb_blk)
 {
@@ -4476,7 +4491,7 @@ int ocfs2_insert_extent(struct ocfs2_super *osb,
 	status = ocfs2_do_insert_extent(inode, handle, et, &rec, &insert);
 	if (status < 0)
 		mlog_errno(status);
-	else if (et->et_ops == &ocfs2_dinode_et_ops)
+	else if (ocfs2_is_dinode_extent_tree(et))
 		ocfs2_extent_map_insert_rec(inode, &rec);
 
 bail:
@@ -4874,7 +4889,7 @@ int ocfs2_mark_extent_written(struct inode *inode,
 	 * XXX: This is a hack on the extent tree, maybe it should be
 	 * an op?
 	 */
-	if (et->et_ops == &ocfs2_dinode_et_ops)
+	if (ocfs2_is_dinode_extent_tree(et))
 		ocfs2_extent_map_trunc(inode, 0);
 
 	left_path = ocfs2_new_path(et->et_root_bh, et->et_root_el);
fs/ocfs2/alloc.h +3 -0
index a0ae6bd..8b98f40 100644
@@ -72,6 +72,9 @@ void ocfs2_init_xattr_value_extent_tree(struct ocfs2_extent_tree *et,
 					struct inode *inode,
 					struct buffer_head *bh,
 					struct ocfs2_xattr_value_root *xv);
+int ocfs2_is_dinode_extent_tree(struct ocfs2_extent_tree *et);
+int ocfs2_is_xattr_value_extent_tree(struct ocfs2_extent_tree *et);
+int ocfs2_is_xattr_tree_extent_tree(struct ocfs2_extent_tree *et);
 
 struct ocfs2_alloc_context;
 int ocfs2_insert_extent(struct ocfs2_super *osb,
Signature · 1 line
1.5.4.GIT
author
#3 lore raw

PATCH 2/2 ocfs2: Combine normal and xattr get extent clusters process together.

In reply to Tao Ma

ocfs2_xattr_get_clusters was originally copied and modified from ocfs2_get_clusters and some codes are almost common, so combine them together with the help of new wrapper, ocfs2_extent_tree.

---
 fs/ocfs2/alloc.c      |    7 ++
 fs/ocfs2/extent_map.c |  146 +++++++++++++++++++------------------------------
 fs/ocfs2/extent_map.h |    2 +-
 fs/ocfs2/xattr.c      |    8 +--
 4 files changed, 68 insertions(+), 95 deletions(-)
fs/ocfs2/alloc.c +7 -0
index 80dbf2f..da51f52 100644
@@ -307,6 +307,13 @@ static void __ocfs2_init_extent_tree(struct ocfs2_extent_tree *et,
 				     void *obj,
 				     struct ocfs2_extent_tree_operations *ops)
 {
+	BUG_ON(!obj && !bh);
+	/*
+	 * We at least need one to get our et_root_el initialized.
+	 * And if no bh, No modification of the extent tree is allowed such
+	 * as inserting or removing extents.
+	 */
+
 	et->et_ops = ops;
 	et->et_root_bh = bh;
 	if (!obj)
fs/ocfs2/extent_map.c +57 -89

198 lines not on this page · raw message

fs/ocfs2/extent_map.h +1 -1
index d98444e..ac2d9d7 100644
@@ -52,5 +52,5 @@ int ocfs2_extent_map_get_blocks(struct inode *inode, u64 v_blkno, u64 *p_blkno,
 
 int ocfs2_xattr_get_clusters(struct inode *inode, u32 v_cluster,
 			     u32 *p_cluster, u32 *num_clusters,
-			     struct ocfs2_extent_list *el);
+			     struct ocfs2_xattr_value_root *xv);
 #endif  /* _EXTENT_MAP_H */
fs/ocfs2/xattr.c +3 -5
index 2ccffb1..2bc53b1 100644
@@ -423,7 +423,7 @@ static int ocfs2_xattr_shrink_size(struct inode *inode,
 	trunc_len = old_clusters - new_clusters;
 	while (trunc_len) {
 		ret = ocfs2_xattr_get_clusters(inode, cpos, &phys_cpos,
-					       &alloc_size, &xv->xr_list);
+					       &alloc_size, xv);
 		if (ret) {
 			mlog_errno(ret);
 			goto out;
@@ -656,9 +656,7 @@ static int ocfs2_xattr_get_value_outside(struct inode *inode,
 	int i, ret = 0;
 	size_t cplen, blocksize;
 	struct buffer_head *bh = NULL;
-	struct ocfs2_extent_list *el;
 
-	el = &xv->xr_list;
 	clusters = le32_to_cpu(xv->xr_clusters);
 	bpc = ocfs2_clusters_to_blocks(inode->i_sb, 1);
 	blocksize = inode->i_sb->s_blocksize;
@@ -666,7 +664,7 @@ static int ocfs2_xattr_get_value_outside(struct inode *inode,
 	cpos = 0;
 	while (cpos < clusters) {
 		ret = ocfs2_xattr_get_clusters(inode, cpos, &p_cluster,
-					       &num_clusters, el);
+					       &num_clusters, xv);
 		if (ret) {
 			mlog_errno(ret);
 			goto out;
@@ -916,7 +914,7 @@ static int __ocfs2_xattr_set_value_outside(struct inode *inode,
 
 	while (cpos < clusters) {
 		ret = ocfs2_xattr_get_clusters(inode, cpos, &p_cluster,
-					       &num_clusters, &xv->xr_list);
+					       &num_clusters, xv);
 		if (ret) {
 			mlog_errno(ret);
 			goto out_commit;
Signature · 1 line
1.5.4.GIT