Skip to contentSkip to conversation

Ocfs2: alloc_dinode counts and group bitmap should be update simultaneously

PATCH New Younger Liu 1 participant 1 message Mar 10, 2014 OCFS2

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Ocfs2: alloc_dinode counts and group bitmap should be update simultaneously

Updating alloc_dinode counts in ocfs2_alloc_dinode_update_counts()
and setting group bitmap in ocfs2_alloc_dinode_update_bitmap() have to be simultaneously.Two cases is as follow:
(1) If ocfs2_alloc_dinode_update_counts() fails, there is no need to
set group bitmap. This case has been considered.
(2) If ocfs2_alloc_dinode_update_bitmap() fails, alloc_dinode counts
should be rolled back. Otherwise, some clusters would never be used. This case is not considered.
So, we combine two functions, and ensure simultaneity.

---
 fs/ocfs2/move_extents.c |   11 ++--
 fs/ocfs2/ocfs2_trace.h  |    2 +-
 fs/ocfs2/suballoc.c     |  155 +++++++++++++++++++----------------------------
 fs/ocfs2/suballoc.h     |   21 +++----
 4 files changed, 77 insertions(+), 112 deletions(-)
fs/ocfs2/move_extents.c +4 -7
index 64c304d..9e15d8b 100644
@@ -681,18 +681,15 @@ static int ocfs2_move_extent(struct ocfs2_move_extents_context *context,
 	}
 
 	gd = (struct ocfs2_group_desc *)gd_bh->b_data;
-	ret = ocfs2_alloc_dinode_update_counts(gb_inode, handle, gb_bh, len,
-					       le16_to_cpu(gd->bg_chain));
+	ret = ocfs2_alloc_dinode_update_bitmap(handle,
+				gb_inode, gb_bh, gd, gb_bh,
+				le16_to_cpu(gd->bg_chain),
+				goal_bit, len);
 	if (ret) {
 		mlog_errno(ret);
 		goto out_commit;
 	}
 
-	ret = ocfs2_block_group_set_bits(handle, gb_inode, gd, gd_bh,
-					 goal_bit, len);
-	if (ret)
-		mlog_errno(ret);
-
 	/*
 	 * Here we should write the new page out first if we are
 	 * in write-back mode.
fs/ocfs2/ocfs2_trace.h +1 -1
index 1b60c62..90c997e 100644
@@ -788,7 +788,7 @@ DEFINE_OCFS2_UINT_UINT_UINT_EVENT(ocfs2_reserve_suballoc_bits_no_new_group);
 
 DEFINE_OCFS2_ULL_EVENT(ocfs2_reserve_new_inode_new_group);
 
-DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_block_group_set_bits);
+DEFINE_OCFS2_UINT_UINT_EVENT(ocfs2_alloc_dinode_update_bitmap);
 
 TRACE_EVENT(ocfs2_relink_block_group,
 	TP_PROTO(unsigned long long i_blkno, unsigned int chain,
fs/ocfs2/suballoc.c +64 -91

208 lines not on this page · raw message

fs/ocfs2/suballoc.h +8 -13
index 218d803..f704f3a 100644
@@ -85,19 +85,14 @@ int ocfs2_reserve_new_inode(struct ocfs2_super *osb,
 int ocfs2_reserve_clusters(struct ocfs2_super *osb,
 			   u32 bits_wanted,
 			   struct ocfs2_alloc_context **ac);
-
-int ocfs2_alloc_dinode_update_counts(struct inode *inode,
-			 handle_t *handle,
-			 struct buffer_head *di_bh,
-			 u32 num_bits,
-			 u16 chain);
-int ocfs2_block_group_set_bits(handle_t *handle,
-			 struct inode *alloc_inode,
-			 struct ocfs2_group_desc *bg,
-			 struct buffer_head *group_bh,
-			 unsigned int bit_off,
-			 unsigned int num_bits);
-
+int ocfs2_alloc_dinode_update_bitmap(handle_t *handle,
+				struct inode *alloc_inode,
+				struct buffer_head *di_bh,
+				struct ocfs2_group_desc *bg,
+				struct buffer_head *group_bh,
+				u16 chain,
+				u32 bit_off,
+				u32 num_bits);
 int ocfs2_claim_metadata(handle_t *handle,
 			 struct ocfs2_alloc_context *ac,
 			 u32 bits_wanted,
Signature · 1 line
1.7.9.5