Skip to contentSkip to conversation

ocfs2: add extent block stealing for ocfs2

PATCH New Tiger Yang 4 participants 5 messages Jan 21, 2010 – Jan 22, 2010 OCFS2

lore
Share & tools
lore

Tiger Yang

author
#0 lore raw

PATCH 1/1 ocfs2: add extent block stealing for ocfs2

This patch add extent block (metadata) stealing mechanism for extent allocation. This mechanism is same as the inode stealing. if no room in slot specific extent_alloc, we will try to allocate extent block from the next slot.

---
 fs/ocfs2/alloc.c        |    5 +-
 fs/ocfs2/dir.c          |    2 +-
 fs/ocfs2/localalloc.c   |    2 +-
 fs/ocfs2/ocfs2.h        |   56 +++++++++++++++++++--
 fs/ocfs2/refcounttree.c |    6 +-
 fs/ocfs2/suballoc.c     |  123 +++++++++++++++++++++++++++++++---------------
 fs/ocfs2/super.c        |    9 ++-
 fs/ocfs2/xattr.c        |    2 +-
 8 files changed, 148 insertions(+), 57 deletions(-)
fs/ocfs2/alloc.c +3 -2
index d17bdc7..be4ebde 100644
@@ -1050,7 +1050,8 @@ static int ocfs2_create_new_meta_bhs(handle_t *handle,
 			strcpy(eb->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE);
 			eb->h_blkno = cpu_to_le64(first_blkno);
 			eb->h_fs_generation = cpu_to_le32(osb->fs_generation);
-			eb->h_suballoc_slot = cpu_to_le16(osb->slot_num);
+			eb->h_suballoc_slot =
+				cpu_to_le16(meta_ac->ac_alloc_slot);
 			eb->h_suballoc_bit = cpu_to_le16(suballoc_bit_start);
 			eb->h_list.l_count =
 				cpu_to_le16(ocfs2_extent_recs_per_eb(osb->sb));
@@ -6037,7 +6038,7 @@ static void ocfs2_truncate_log_worker(struct work_struct *work)
 	if (status < 0)
 		mlog_errno(status);
 	else
-		ocfs2_init_inode_steal_slot(osb);
+		ocfs2_init_steal_slot(osb);
 
 	mlog_exit(status);
 }
fs/ocfs2/dir.c +1 -1
index 28c3ec2..765d66c 100644
@@ -2439,7 +2439,7 @@ static int ocfs2_dx_dir_attach_index(struct ocfs2_super *osb,
 	dx_root = (struct ocfs2_dx_root_block *)dx_root_bh->b_data;
 	memset(dx_root, 0, osb->sb->s_blocksize);
 	strcpy(dx_root->dr_signature, OCFS2_DX_ROOT_SIGNATURE);
-	dx_root->dr_suballoc_slot = cpu_to_le16(osb->slot_num);
+	dx_root->dr_suballoc_slot = cpu_to_le16(meta_ac->ac_alloc_slot);
 	dx_root->dr_suballoc_bit = cpu_to_le16(dr_suballoc_bit);
 	dx_root->dr_fs_generation = cpu_to_le32(osb->fs_generation);
 	dx_root->dr_blkno = cpu_to_le64(dr_blkno);
fs/ocfs2/localalloc.c +1 -1
index ac10f83..33957ad 100644
@@ -476,7 +476,7 @@ out_mutex:
 
 out:
 	if (!status)
-		ocfs2_init_inode_steal_slot(osb);
+		ocfs2_init_steal_slot(osb);
 	mlog_exit(status);
 	return status;
 }
fs/ocfs2/ocfs2.h +50 -6

82 lines not on this page · raw message

fs/ocfs2/refcounttree.c +3 -3
index 74db2be..56abab3 100644
@@ -626,7 +626,7 @@ static int ocfs2_create_refcount_tree(struct inode *inode,
 	rb = (struct ocfs2_refcount_block *)new_bh->b_data;
 	memset(rb, 0, inode->i_sb->s_blocksize);
 	strcpy((void *)rb, OCFS2_REFCOUNT_BLOCK_SIGNATURE);
-	rb->rf_suballoc_slot = cpu_to_le16(osb->slot_num);
+	rb->rf_suballoc_slot = cpu_to_le16(meta_ac->ac_alloc_slot);
 	rb->rf_suballoc_bit = cpu_to_le16(suballoc_bit_start);
 	rb->rf_fs_generation = cpu_to_le32(osb->fs_generation);
 	rb->rf_blkno = cpu_to_le64(first_blkno);
@@ -1330,7 +1330,7 @@ static int ocfs2_expand_inline_ref_root(handle_t *handle,
 	memcpy(new_bh->b_data, ref_root_bh->b_data, sb->s_blocksize);
 
 	new_rb = (struct ocfs2_refcount_block *)new_bh->b_data;
-	new_rb->rf_suballoc_slot = cpu_to_le16(OCFS2_SB(sb)->slot_num);
+	new_rb->rf_suballoc_slot = cpu_to_le16(meta_ac->ac_alloc_slot);
 	new_rb->rf_suballoc_bit = cpu_to_le16(suballoc_bit_start);
 	new_rb->rf_blkno = cpu_to_le64(blkno);
 	new_rb->rf_cpos = cpu_to_le32(0);
@@ -1576,7 +1576,7 @@ static int ocfs2_new_leaf_refcount_block(handle_t *handle,
 	new_rb = (struct ocfs2_refcount_block *)new_bh->b_data;
 	memset(new_rb, 0, sb->s_blocksize);
 	strcpy((void *)new_rb, OCFS2_REFCOUNT_BLOCK_SIGNATURE);
-	new_rb->rf_suballoc_slot = cpu_to_le16(OCFS2_SB(sb)->slot_num);
+	new_rb->rf_suballoc_slot = cpu_to_le16(meta_ac->ac_alloc_slot);
 	new_rb->rf_suballoc_bit = cpu_to_le16(suballoc_bit_start);
 	new_rb->rf_fs_generation = cpu_to_le32(OCFS2_SB(sb)->fs_generation);
 	new_rb->rf_blkno = cpu_to_le64(blkno);
fs/ocfs2/suballoc.c +83 -40

178 lines not on this page · raw message

fs/ocfs2/super.c +6 -3
index 2606991..f4f5b65 100644
@@ -301,9 +301,12 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
 
 	spin_lock(&osb->osb_lock);
 	out += snprintf(buf + out, len - out,
-			"%10s => Slot: %d  NumStolen: %d\n", "Steal",
+			"%10s => InodeSlot: %d  StolenInodes: %d, "
+			"MetaSlot: %d  StolenMeta: %d\n", "Steal",
 			osb->s_inode_steal_slot,
-			atomic_read(&osb->s_num_inodes_stolen));
+			atomic_read(&osb->s_num_inodes_stolen),
+			osb->s_meta_steal_slot,
+			atomic_read(&osb->s_num_meta_stolen));
 	spin_unlock(&osb->osb_lock);
 
 	out += snprintf(buf + out, len - out, "OrphanScan => ");
@@ -1997,7 +2000,7 @@ static int ocfs2_initialize_super(struct super_block *sb,
 	osb->blocked_lock_count = 0;
 	spin_lock_init(&osb->osb_lock);
 	spin_lock_init(&osb->osb_xattr_lock);
-	ocfs2_init_inode_steal_slot(osb);
+	ocfs2_init_steal_slot(osb);
 
 	atomic_set(&osb->alloc_stats.moves, 0);
 	atomic_set(&osb->alloc_stats.local_data, 0);
fs/ocfs2/xattr.c +1 -1
index 8fc6fb0..8ae4e5d 100644
@@ -2282,7 +2282,7 @@ static int ocfs2_create_xattr_block(handle_t *handle,
 	xblk = (struct ocfs2_xattr_block *)new_bh->b_data;
 	memset(xblk, 0, inode->i_sb->s_blocksize);
 	strcpy((void *)xblk, OCFS2_XATTR_BLOCK_SIGNATURE);
-	xblk->xb_suballoc_slot = cpu_to_le16(osb->slot_num);
+	xblk->xb_suballoc_slot = cpu_to_le16(meta_ac->ac_alloc_slot);
 	xblk->xb_suballoc_bit = cpu_to_le16(suballoc_bit_start);
 	xblk->xb_fs_generation = cpu_to_le32(osb->fs_generation);
 	xblk->xb_blkno = cpu_to_le64(first_blkno);
Signature · 1 line
1.5.4.3
#1 lore raw

PATCH 1/1 ocfs2: add extent block stealing for ocfs2

fs/ocfs2/ocfs2.h static inline void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb) · line 775

Quoted 10 lines · Tiger Yang
fs/ocfs2/ocfs2.h +4 -3
-static inline void ocfs2_set_inode_steal_slot(struct ocfs2_super *osb,
-					      s16 slot)
+static inline void ocfs2_init_meta_steal_slot(struct ocfs2_super *osb)
 {
 	spin_lock(&osb->osb_lock);
-	osb->s_inode_steal_slot = slot;
+	osb->s_meta_steal_slot = OCFS2_INVALID_SLOT;
 	spin_unlock(&osb->osb_lock);
+	atomic_set(&osb->s_num_meta_stolen, 0);
+}

Doesn't need to be inline. Put it in suballoc.c.

fs/ocfs2/ocfs2.h static inline void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb) · line 792

Quoted 10 lines
fs/ocfs2/ocfs2.h +10 -0
+static inline void ocfs2_set_steal_slot(struct ocfs2_super *osb,
+					int slot, int type)
+{
+	spin_lock(&osb->osb_lock);
+	if (type == INODE_ALLOC_SYSTEM_INODE)
+		osb->s_inode_steal_slot = slot;
+	else if (type == EXTENT_ALLOC_SYSTEM_INODE)
+		osb->s_meta_steal_slot = slot;
+	spin_unlock(&osb->osb_lock);
+}

Doesn't need to be inline. Put it in suballoc.c and put an __
in front of it.

Quoted 6 lines
fs/ocfs2/ocfs2.h +2 -2
-static inline s16 ocfs2_get_inode_steal_slot(struct ocfs2_super *osb)
+static inline int ocfs2_get_steal_slot(struct ocfs2_super *osb, int type)
 {
-	s16 slot;
+	int slot = OCFS2_INVALID_SLOT;
 

fs/ocfs2/ocfs2.h static inline void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb) · line 818

Quoted 10 lines
fs/ocfs2/ocfs2.h +4 -1
 	spin_lock(&osb->osb_lock);
-	slot = osb->s_inode_steal_slot;
+	if (type == INODE_ALLOC_SYSTEM_INODE)
+		slot = osb->s_inode_steal_slot;
+	else if (type == EXTENT_ALLOC_SYSTEM_INODE)
+		slot = osb->s_meta_steal_slot;
 	spin_unlock(&osb->osb_lock);
 
 	return slot;
 }

Again regarding unline and __ prefix.

Joel

Signature · 9 lines
"Depend on the rabbit's foot if you will, but remember, it didn't
 help the rabbit."
	- R. E. Shay

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
#2 lore raw

PATCH 1/1 ocfs2: add extent block stealing for ocfs2

Quoted 47 lines · Joel Becker

fs/ocfs2/ocfs2.h static inline void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb) · line 775

Quoted 11 lines · Tiger Yang
fs/ocfs2/ocfs2.h +4 -3
-static inline void ocfs2_set_inode_steal_slot(struct ocfs2_super *osb,
-					      s16 slot)
+static inline void ocfs2_init_meta_steal_slot(struct ocfs2_super *osb)
 {
 	spin_lock(&osb->osb_lock);
-	osb->s_inode_steal_slot = slot;
+	osb->s_meta_steal_slot = OCFS2_INVALID_SLOT;
 	spin_unlock(&osb->osb_lock);
+	atomic_set(&osb->s_num_meta_stolen, 0);
+}

Doesn't need to be inline. Put it in suballoc.c.

fs/ocfs2/ocfs2.h static inline void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb) · line 792

Quoted 11 lines
fs/ocfs2/ocfs2.h +10 -0
+static inline void ocfs2_set_steal_slot(struct ocfs2_super *osb,
+					int slot, int type)
+{
+	spin_lock(&osb->osb_lock);
+	if (type == INODE_ALLOC_SYSTEM_INODE)
+		osb->s_inode_steal_slot = slot;
+	else if (type == EXTENT_ALLOC_SYSTEM_INODE)
+		osb->s_meta_steal_slot = slot;
+	spin_unlock(&osb->osb_lock);
+}

Doesn't need to be inline. Put it in suballoc.c and put an __
in front of it.

Quoted 14 lines
fs/ocfs2/ocfs2.h +6 -3
-static inline s16 ocfs2_get_inode_steal_slot(struct ocfs2_super *osb)
+static inline int ocfs2_get_steal_slot(struct ocfs2_super *osb, int type)
 {
-	s16 slot;
+	int slot = OCFS2_INVALID_SLOT;
 
 	spin_lock(&osb->osb_lock);
-	slot = osb->s_inode_steal_slot;
+	if (type == INODE_ALLOC_SYSTEM_INODE)
+		slot = osb->s_inode_steal_slot;
+	else if (type == EXTENT_ALLOC_SYSTEM_INODE)
+		slot = osb->s_meta_steal_slot;
 	spin_unlock(&osb->osb_lock);
Quoted 5 lines
Quoted 3 lines

return slot;
}

Again regarding unline and __ prefix.

All this is good.

The get and set routines are a bit convoluted. I agree with the hiding of the
type by adding ocfs2_steal_meta() and ocfs2_steal_inode(). But the get/set routines will be better off just accepting the type.

Right now the flow is:

ocfs2_steal_resource()
+ if (type == INODE_ALLOC_SYSTEM_INODE)
+ ocfs2_set_inode_steal_slot(osb, slot);

ocfs2_set_inode_steal_slot()
+ return ocfs2_set_steal_slot(osb, slot, INODE_ALLOC_SYSTEM_INODE);

ocfs2_set_steal_slot()
+ if (type == INODE_ALLOC_SYSTEM_INODE)
+ osb->s_inode_steal_slot = slot;

Sunil

#3 lore raw

PATCH 1/1 ocfs2: add extent block stealing for ocfs2

Quoted 16 lines · Sunil Mushran

The get and set routines are a bit convoluted. I agree with the hiding of the
type by adding ocfs2_steal_meta() and ocfs2_steal_inode(). But the get/set routines will be better off just accepting the type.

Right now the flow is:

ocfs2_steal_resource()

(quoted diff) +2 -0
+                       if (type == INODE_ALLOC_SYSTEM_INODE)
+                               ocfs2_set_inode_steal_slot(osb, slot);

ocfs2_set_inode_steal_slot()
+ return ocfs2_set_steal_slot(osb, slot, INODE_ALLOC_SYSTEM_INODE);

ocfs2_set_steal_slot()

fs/ocfs2/ocfs2.h static inline void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb) · line 788

Quoted 2 lines
fs/ocfs2/ocfs2.h +2 -0
+       if (type == INODE_ALLOC_SYSTEM_INODE)
+               osb->s_inode_steal_slot = slot;

I see your point. First, most of the slot stealing functions
don't belong in the header at all. They're only used in suballoc.c, so make them static there.
The set routine is only called from ocfs2_steal_resource(). It
should take the type, because the type is already there. The get routines are called from other places.
ocfs2_steal_resource() should call __ocfs2_set_steal_slot()
directly. No need for ocfs2_set_{inode,meta}_steal_slot(). Those should be removed. ocfs2_steal_resource() should call __ocfs2_get_steal_slot() directly to pass the type. The other callers of ocfs2_get_{inode,meta}_steal_slot() remain the same.

Joel

Signature · 9 lines
Life's Little Instruction Book #347

	"Never waste the oppourtunity to tell someone you love them."

Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
#4 lore raw

PATCH 1/1 ocfs2: add extent block stealing for ocfs2

Quoted 19 lines · Joel Becker
Quoted 15 lines · Sunil Mushran

The get and set routines are a bit convoluted. I agree with the hiding of the
type by adding ocfs2_steal_meta() and ocfs2_steal_inode(). But the get/set routines will be better off just accepting the type.

Right now the flow is:

ocfs2_steal_resource()

(quoted diff) +2 -0
+                       if (type == INODE_ALLOC_SYSTEM_INODE)
+                               ocfs2_set_inode_steal_slot(osb, slot);

ocfs2_set_inode_steal_slot()
+ return ocfs2_set_steal_slot(osb, slot, INODE_ALLOC_SYSTEM_INODE);

ocfs2_set_steal_slot()

fs/ocfs2/ocfs2.h static inline void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb) · line 788

Quoted 2 lines
fs/ocfs2/ocfs2.h +2 -0
+       if (type == INODE_ALLOC_SYSTEM_INODE)
+               osb->s_inode_steal_slot = slot;
Quoted 11 lines

I see your point. First, most of the slot stealing functions
don't belong in the header at all. They're only used in suballoc.c, so make them static there.
The set routine is only called from ocfs2_steal_resource(). It
should take the type, because the type is already there. The get routines are called from other places.
ocfs2_steal_resource() should call __ocfs2_set_steal_slot()
directly. No need for ocfs2_set_{inode,meta}_steal_slot(). Those should be removed. ocfs2_steal_resource() should call __ocfs2_get_steal_slot() directly to pass the type. The other callers of ocfs2_get_{inode,meta}_steal_slot() remain the same.

I tried to catch up with the discussion. agreed with Joel. In ocfs2_steal_resource, we know the type, so just call __ocfs2_{set,get}_steal_slot function with type should be ok.

Regards,
Tao