Commit bcfe9413 authored by Andreas Gruenbacher's avatar Andreas Gruenbacher

gfs2: gfs2_extent_length cleanup

Now that gfs2_extent_length is no longer used for determining the size
of a hole and always with an upper size limit, the function can be
simplified.
Signed-off-by: default avatarAndreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: default avatarBob Peterson <rpeterso@redhat.com>
parent 64bc06bb
...@@ -406,22 +406,17 @@ static void release_metapath(struct metapath *mp) ...@@ -406,22 +406,17 @@ static void release_metapath(struct metapath *mp)
/** /**
* gfs2_extent_length - Returns length of an extent of blocks * gfs2_extent_length - Returns length of an extent of blocks
* @start: Start of the buffer * @bh: The metadata block
* @len: Length of the buffer in bytes * @ptr: Current position in @bh
* @ptr: Current position in the buffer * @limit: Max extent length to return
* @limit: Max extent length to return (0 = unlimited)
* @eob: Set to 1 if we hit "end of block" * @eob: Set to 1 if we hit "end of block"
* *
* If the first block is zero (unallocated) it will return the number of
* unallocated blocks in the extent, otherwise it will return the number
* of contiguous blocks in the extent.
*
* Returns: The length of the extent (minimum of one block) * Returns: The length of the extent (minimum of one block)
*/ */
static inline unsigned int gfs2_extent_length(void *start, unsigned int len, __be64 *ptr, size_t limit, int *eob) static inline unsigned int gfs2_extent_length(struct buffer_head *bh, __be64 *ptr, size_t limit, int *eob)
{ {
const __be64 *end = (start + len); const __be64 *end = (__be64 *)(bh->b_data + bh->b_size);
const __be64 *first = ptr; const __be64 *first = ptr;
u64 d = be64_to_cpu(*ptr); u64 d = be64_to_cpu(*ptr);
...@@ -430,14 +425,11 @@ static inline unsigned int gfs2_extent_length(void *start, unsigned int len, __b ...@@ -430,14 +425,11 @@ static inline unsigned int gfs2_extent_length(void *start, unsigned int len, __b
ptr++; ptr++;
if (ptr >= end) if (ptr >= end)
break; break;
if (limit && --limit == 0) d++;
break;
if (d)
d++;
} while(be64_to_cpu(*ptr) == d); } while(be64_to_cpu(*ptr) == d);
if (ptr >= end) if (ptr >= end)
*eob = 1; *eob = 1;
return (ptr - first); return ptr - first;
} }
typedef const __be64 *(*gfs2_metadata_walker)( typedef const __be64 *(*gfs2_metadata_walker)(
...@@ -893,7 +885,7 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length, ...@@ -893,7 +885,7 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
goto do_alloc; goto do_alloc;
bh = mp->mp_bh[ip->i_height - 1]; bh = mp->mp_bh[ip->i_height - 1];
len = gfs2_extent_length(bh->b_data, bh->b_size, ptr, len, &eob); len = gfs2_extent_length(bh, ptr, len, &eob);
iomap->addr = be64_to_cpu(*ptr) << inode->i_blkbits; iomap->addr = be64_to_cpu(*ptr) << inode->i_blkbits;
iomap->length = len << inode->i_blkbits; iomap->length = len << inode->i_blkbits;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment