From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH v7 09/12] gfs2: gfs2_extent_length cleanup
Date: Mon, 4 Jun 2018 14:37:26 +0200 [thread overview]
Message-ID: <20180604123729.23414-10-agruenba@redhat.com> (raw)
In-Reply-To: <20180604123729.23414-1-agruenba@redhat.com>
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: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/bmap.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index b394fa5979be..f485a5b748bc 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -406,22 +406,17 @@ static 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
- * @ptr: Current position in the buffer
- * @limit: Max extent length to return (0 = unlimited)
+ * @bh: The metadata block
+ * @ptr: Current position in @bh
+ * @limit: Max extent length to return
* @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)
*/
-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;
u64 d = be64_to_cpu(*ptr);
@@ -430,14 +425,11 @@ static inline unsigned int gfs2_extent_length(void *start, unsigned int len, __b
ptr++;
if (ptr >= end)
break;
- if (limit && --limit == 0)
- break;
- if (d)
- d++;
+ d++;
} while(be64_to_cpu(*ptr) == d);
if (ptr >= end)
*eob = 1;
- return (ptr - first);
+ return ptr - first;
}
typedef const __be64 *(*gfs2_metadata_walker)(
@@ -883,7 +875,7 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
goto do_alloc;
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->length = len << inode->i_blkbits;
--
2.17.0
WARNING: multiple messages have this Message-ID (diff)
From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel@redhat.com, Christoph Hellwig <hch@lst.de>
Cc: linux-fsdevel@vger.kernel.org, Andreas Gruenbacher <agruenba@redhat.com>
Subject: [PATCH v7 09/12] gfs2: gfs2_extent_length cleanup
Date: Mon, 4 Jun 2018 14:37:26 +0200 [thread overview]
Message-ID: <20180604123729.23414-10-agruenba@redhat.com> (raw)
In-Reply-To: <20180604123729.23414-1-agruenba@redhat.com>
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: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/bmap.c | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index b394fa5979be..f485a5b748bc 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -406,22 +406,17 @@ static 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
- * @ptr: Current position in the buffer
- * @limit: Max extent length to return (0 = unlimited)
+ * @bh: The metadata block
+ * @ptr: Current position in @bh
+ * @limit: Max extent length to return
* @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)
*/
-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;
u64 d = be64_to_cpu(*ptr);
@@ -430,14 +425,11 @@ static inline unsigned int gfs2_extent_length(void *start, unsigned int len, __b
ptr++;
if (ptr >= end)
break;
- if (limit && --limit == 0)
- break;
- if (d)
- d++;
+ d++;
} while(be64_to_cpu(*ptr) == d);
if (ptr >= end)
*eob = 1;
- return (ptr - first);
+ return ptr - first;
}
typedef const __be64 *(*gfs2_metadata_walker)(
@@ -883,7 +875,7 @@ static int gfs2_iomap_get(struct inode *inode, loff_t pos, loff_t length,
goto do_alloc;
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->length = len << inode->i_blkbits;
--
2.17.0
next prev parent reply other threads:[~2018-06-04 12:37 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-04 12:37 [Cluster-devel] [PATCH v7 00/12] gfs2 iomap write support Andreas Gruenbacher
2018-06-04 12:37 ` Andreas Gruenbacher
2018-06-04 12:37 ` [Cluster-devel] [PATCH v7 01/12] iomap: inline data should be an iomap type, not a flag Andreas Gruenbacher
2018-06-04 12:37 ` Andreas Gruenbacher
2018-06-04 12:37 ` [Cluster-devel] [PATCH v7 02/12] iomap: Mark newly allocated buffer heads as new Andreas Gruenbacher
2018-06-04 12:37 ` Andreas Gruenbacher
2018-06-04 12:37 ` [Cluster-devel] [PATCH v7 03/12] iomap: Complete partial direct I/O writes synchronously Andreas Gruenbacher
2018-06-04 12:37 ` Andreas Gruenbacher
2018-06-04 12:37 ` [Cluster-devel] [PATCH v7 04/12] fs: factor out a __generic_write_end helper Andreas Gruenbacher
2018-06-04 12:37 ` Andreas Gruenbacher
2018-06-04 12:37 ` [Cluster-devel] [PATCH v7 05/12] fs: allow to always dirty inode in __generic_write_end Andreas Gruenbacher
2018-06-04 12:37 ` Andreas Gruenbacher
2018-06-04 12:48 ` [Cluster-devel] " Christoph Hellwig
2018-06-04 12:48 ` Christoph Hellwig
2018-06-04 16:24 ` [Cluster-devel] " Andreas Grünbacher
2018-06-04 16:24 ` Andreas Grünbacher
2018-06-04 12:37 ` [Cluster-devel] [PATCH v7 06/12] iomap: Generic inline data handling Andreas Gruenbacher
2018-06-04 12:37 ` Andreas Gruenbacher
2018-06-04 12:37 ` [Cluster-devel] [PATCH v7 07/12] iomap: Add page_write_end iomap hook Andreas Gruenbacher
2018-06-04 12:37 ` Andreas Gruenbacher
2018-06-04 12:50 ` [Cluster-devel] " Christoph Hellwig
2018-06-04 12:50 ` Christoph Hellwig
2018-06-04 16:40 ` [Cluster-devel] " Andreas Grünbacher
2018-06-04 16:40 ` Andreas Grünbacher
2018-06-04 12:37 ` [Cluster-devel] [PATCH v7 08/12] gfs2: iomap buffered write support Andreas Gruenbacher
2018-06-04 12:37 ` Andreas Gruenbacher
2018-06-04 12:37 ` Andreas Gruenbacher [this message]
2018-06-04 12:37 ` [PATCH v7 09/12] gfs2: gfs2_extent_length cleanup Andreas Gruenbacher
2018-06-04 12:37 ` [Cluster-devel] [PATCH v7 10/12] gfs2: iomap direct I/O support Andreas Gruenbacher
2018-06-04 12:37 ` Andreas Gruenbacher
2018-06-04 12:37 ` [Cluster-devel] [PATCH v7 11/12] gfs2: Remove gfs2_write_{begin, end} Andreas Gruenbacher
2018-06-04 12:37 ` [PATCH v7 11/12] gfs2: Remove gfs2_write_{begin,end} Andreas Gruenbacher
2018-06-04 12:37 ` [Cluster-devel] [PATCH v7 12/12] iomap: Put struct iomap_ops into struct iomap Andreas Gruenbacher
2018-06-04 12:37 ` Andreas Gruenbacher
2018-06-04 12:52 ` [Cluster-devel] " Christoph Hellwig
2018-06-04 12:52 ` Christoph Hellwig
2018-06-04 17:00 ` [Cluster-devel] " Andreas Grünbacher
2018-06-04 17:00 ` Andreas Grünbacher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180604123729.23414-10-agruenba@redhat.com \
--to=agruenba@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.