Skip to contentSkip to conversation

GFS2: simplify function gfs2_extent_length

PATCH New Bob Peterson 2 participants 2 messages May 10, 2012 – May 11, 2012 1 message not in the archive GFS2 file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 16ff6117-2840-4e01-86b8-b4e256e30fa0@zmail12.collab.prod.int.phx2.redhat.com

#1 lore raw

PATCH 1/1 GFS2: simplify function gfs2_extent_length

Hi,

See description below. :)

Regards,

Bob Peterson
Red Hat File Systems

---

Author: Bob Peterson <[email protected]>
Date:   Wed May 9 14:27:00 2012 -0500

GFS2: simplify function gfs2_extent_length

This patch simplifies function gfs2_extent_length by passing a single parameter to the function rather than two.

fs/gfs2/bmap.c +7 -7
index 420bbeb..31c5e81 100644
@@ -345,8 +345,7 @@ static inline void release_metapath(struct metapath *mp)
 
 /**
  * gfs2_extent_length - Returns length of an extent of blocks
- * @start: Start of the buffer
- * @len: Length of the buffer in bytes
+ * @bh: The buffer header
  * @ptr: Current position in the buffer
  * @limit: Max extent length to return (0 = unlimited)
  * @eob: Set to 1 if we hit "end of block"
@@ -358,9 +357,11 @@ static inline void release_metapath(struct metapath *mp)
  * Returns: The length of the extent (minimum of one block)
  */
 
-static inline unsigned int gfs2_extent_length(void *start, unsigned int len, __be64 *ptr, unsigned limit, int *eob)
+static inline unsigned int gfs2_extent_length(struct buffer_head *bh,
+					      __be64 *ptr, unsigned limit,
+					      int *eob)
 {
-	const __be64 *end = (start + len);
+	const __be64 *end = (const __be64 *)(bh->b_data + bh->b_size);
 	const __be64 *first = ptr;
 	u64 d = be64_to_cpu(*ptr);
 
@@ -475,8 +476,7 @@ static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock,
 		/* Bottom indirect block exists, find unalloced extent size */
 		ptr = metapointer(end_of_metadata, mp);
 		bh = mp->mp_bh[end_of_metadata];
-		dblks = gfs2_extent_length(bh->b_data, bh->b_size, ptr, maxlen,
-					   &eob);
+		dblks = gfs2_extent_length(bh, ptr, maxlen, &eob);
 		BUG_ON(dblks < 1);
 		state = ALLOC_DATA;
 	} else {
@@ -650,7 +650,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
 		goto do_alloc;
 	map_bh(bh_map, inode->i_sb, be64_to_cpu(*ptr));
 	bh = mp.mp_bh[ip->i_height - 1];
-	len = gfs2_extent_length(bh->b_data, bh->b_size, ptr, maxlen, &eob);
+	len = gfs2_extent_length(bh, ptr, maxlen, &eob);
 	bh_map->b_size = (len << inode->i_blkbits);
 	if (eob)
 		set_buffer_boundary(bh_map);
#2 lore raw

PATCH 1/1 GFS2: simplify function gfs2_extent_length

Hi,

Quoted 10 lines · Bob Peterson

Hi,

See description below. :)

Regards,

Bob Peterson
Red Hat File Systems

Quoted 9 lines

---

Author: Bob Peterson <[email protected]>
Date:   Wed May 9 14:27:00 2012 -0500

GFS2: simplify function gfs2_extent_length

This patch simplifies function gfs2_extent_length by passing a single parameter to the function rather than two.

Hmm. I'm not sure this really buys us anything. The function is inline anyway and it means that it will then be tied to only using buffer heads whereas before it could potentially have been used for any situation,

Steve.

Quoted 48 lines
fs/gfs2/bmap.c +7 -7
index 420bbeb..31c5e81 100644
@@ -345,8 +345,7 @@ static inline void release_metapath(struct metapath *mp)
 
 /**
  * gfs2_extent_length - Returns length of an extent of blocks
- * @start: Start of the buffer
- * @len: Length of the buffer in bytes
+ * @bh: The buffer header
  * @ptr: Current position in the buffer
  * @limit: Max extent length to return (0 = unlimited)
  * @eob: Set to 1 if we hit "end of block"
@@ -358,9 +357,11 @@ static inline void release_metapath(struct metapath *mp)
  * Returns: The length of the extent (minimum of one block)
  */
 
-static inline unsigned int gfs2_extent_length(void *start, unsigned int len, __be64 *ptr, unsigned limit, int *eob)
+static inline unsigned int gfs2_extent_length(struct buffer_head *bh,
+					      __be64 *ptr, unsigned limit,
+					      int *eob)
 {
-	const __be64 *end = (start + len);
+	const __be64 *end = (const __be64 *)(bh->b_data + bh->b_size);
 	const __be64 *first = ptr;
 	u64 d = be64_to_cpu(*ptr);
 
@@ -475,8 +476,7 @@ static int gfs2_bmap_alloc(struct inode *inode, const sector_t lblock,
 		/* Bottom indirect block exists, find unalloced extent size */
 		ptr = metapointer(end_of_metadata, mp);
 		bh = mp->mp_bh[end_of_metadata];
-		dblks = gfs2_extent_length(bh->b_data, bh->b_size, ptr, maxlen,
-					   &eob);
+		dblks = gfs2_extent_length(bh, ptr, maxlen, &eob);
 		BUG_ON(dblks < 1);
 		state = ALLOC_DATA;
 	} else {
@@ -650,7 +650,7 @@ int gfs2_block_map(struct inode *inode, sector_t lblock,
 		goto do_alloc;
 	map_bh(bh_map, inode->i_sb, be64_to_cpu(*ptr));
 	bh = mp.mp_bh[ip->i_height - 1];
-	len = gfs2_extent_length(bh->b_data, bh->b_size, ptr, maxlen, &eob);
+	len = gfs2_extent_length(bh, ptr, maxlen, &eob);
 	bh_map->b_size = (len << inode->i_blkbits);
 	if (eob)
 		set_buffer_boundary(bh_map);