cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
* [Cluster-devel] [GFS2 Patch] GFS2: simplify function gfs2_extent_length
       [not found] <16ff6117-2840-4e01-86b8-b4e256e30fa0@zmail12.collab.prod.int.phx2.redhat.com>
@ 2012-05-10 12:31 ` Bob Peterson
  2012-05-11  9:41   ` Steven Whitehouse
  0 siblings, 1 reply; 2+ messages in thread
From: Bob Peterson @ 2012-05-10 12:31 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

See description below. :)

Regards,

Bob Peterson
Red Hat File Systems

Signed-off-by: Bob Peterson <rpeterso@redhat.com> 
---
Author: Bob Peterson <rpeterso@redhat.com>
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.

diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index 420bbeb..31c5e81 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -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);



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

* [Cluster-devel] [GFS2 Patch] GFS2: simplify function gfs2_extent_length
  2012-05-10 12:31 ` [Cluster-devel] [GFS2 Patch] GFS2: simplify function gfs2_extent_length Bob Peterson
@ 2012-05-11  9:41   ` Steven Whitehouse
  0 siblings, 0 replies; 2+ messages in thread
From: Steven Whitehouse @ 2012-05-11  9:41 UTC (permalink / raw)
  To: cluster-devel.redhat.com

Hi,

On Thu, 2012-05-10 at 08:31 -0400, Bob Peterson wrote:
> Hi,
> 
> See description below. :)
> 
> Regards,
> 
> Bob Peterson
> Red Hat File Systems
> 
> Signed-off-by: Bob Peterson <rpeterso@redhat.com> 
> ---
> Author: Bob Peterson <rpeterso@redhat.com>
> 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.

> diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
> index 420bbeb..31c5e81 100644
> --- a/fs/gfs2/bmap.c
> +++ b/fs/gfs2/bmap.c
> @@ -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);
> 




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

end of thread, other threads:[~2012-05-11  9:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <16ff6117-2840-4e01-86b8-b4e256e30fa0@zmail12.collab.prod.int.phx2.redhat.com>
2012-05-10 12:31 ` [Cluster-devel] [GFS2 Patch] GFS2: simplify function gfs2_extent_length Bob Peterson
2012-05-11  9:41   ` Steven Whitehouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).