From: Andreas Gruenbacher <agruenba@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 2/3] gfs2: Split gfs2_indirect_init
Date: Mon, 30 Jul 2018 14:33:52 +0200 [thread overview]
Message-ID: <20180730123353.15815-2-agruenba@redhat.com> (raw)
In-Reply-To: <20180730123353.15815-1-agruenba@redhat.com>
Function gfs2_indirect_init currently initializes a new indirect block
and sets up the pointer to the new block in the parent indirect block.
This is easier to understand when done in two separate calls.
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
fs/gfs2/bmap.c | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c
index a564cf0b7221..caa0b6d71bce 100644
--- a/fs/gfs2/bmap.c
+++ b/fs/gfs2/bmap.c
@@ -571,22 +571,25 @@ static int gfs2_hole_size(struct inode *inode, sector_t lblock, u64 len,
return ret;
}
-static inline __be64 *gfs2_indirect_init(struct metapath *mp,
- struct gfs2_glock *gl, unsigned int i,
- unsigned offset, u64 bn)
+static void gfs2_indirect_init(struct metapath *mp, struct gfs2_glock *gl,
+ unsigned int i, u64 bn)
{
- __be64 *ptr = (__be64 *)(mp->mp_bh[i - 1]->b_data +
- ((i > 1) ? sizeof(struct gfs2_meta_header) :
- sizeof(struct gfs2_dinode)));
- BUG_ON(i < 1);
BUG_ON(mp->mp_bh[i] != NULL);
mp->mp_bh[i] = gfs2_meta_new(gl, bn);
gfs2_trans_add_meta(gl, mp->mp_bh[i]);
gfs2_metatype_set(mp->mp_bh[i], GFS2_METATYPE_IN, GFS2_FORMAT_IN);
gfs2_buffer_clear_tail(mp->mp_bh[i], sizeof(struct gfs2_meta_header));
+}
+
+static void gfs2_indirect_set(struct metapath *mp, unsigned int i,
+ unsigned offset, u64 bn)
+{
+ __be64 *ptr = (__be64 *)(mp->mp_bh[i]->b_data +
+ (i ? sizeof(struct gfs2_meta_header) :
+ sizeof(struct gfs2_dinode)));
+
ptr += offset;
*ptr = cpu_to_be64(bn);
- return ptr;
}
enum alloc_state {
@@ -688,8 +691,10 @@ static int gfs2_iomap_alloc(struct inode *inode, struct iomap *iomap,
zero_bn = *ptr;
}
for (; i - 1 < mp->mp_fheight - ip->i_height && n > 0;
- i++, n--)
- gfs2_indirect_init(mp, ip->i_gl, i, 0, bn++);
+ i++, n--, bn++) {
+ gfs2_indirect_init(mp, ip->i_gl, i, bn);
+ gfs2_indirect_set(mp, i - 1, 0, bn);
+ }
if (i - 1 == mp->mp_fheight - ip->i_height) {
i--;
gfs2_buffer_copy_tail(mp->mp_bh[i],
@@ -716,9 +721,10 @@ static int gfs2_iomap_alloc(struct inode *inode, struct iomap *iomap,
case ALLOC_GROW_DEPTH:
if (i > 1 && i < mp->mp_fheight)
gfs2_trans_add_meta(ip->i_gl, mp->mp_bh[i-1]);
- for (; i < mp->mp_fheight && n > 0; i++, n--)
- gfs2_indirect_init(mp, ip->i_gl, i,
- mp->mp_list[i-1], bn++);
+ for (; i < mp->mp_fheight && n > 0; i++, n--, bn++) {
+ gfs2_indirect_init(mp, ip->i_gl, i, bn);
+ gfs2_indirect_set(mp, i - 1, mp->mp_list[i - 1], bn);
+ }
if (i == mp->mp_fheight)
state = ALLOC_DATA;
if (n == 0)
--
2.17.1
next prev parent reply other threads:[~2018-07-30 12:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 12:33 [Cluster-devel] [PATCH 1/3] gfs2: Don't depend on mp_aheight in clone_metapath Andreas Gruenbacher
2018-07-30 12:33 ` Andreas Gruenbacher [this message]
2018-07-30 20:06 ` [Cluster-devel] [PATCH 2/3] gfs2: Split gfs2_indirect_init Bob Peterson
2018-07-30 12:33 ` [Cluster-devel] [PATCH 3/3] gfs2: Don't create unnecessary indirect blocks Andreas Gruenbacher
2018-07-30 20:12 ` Bob Peterson
2018-07-30 14:29 ` [Cluster-devel] [PATCH 1/3] gfs2: Don't depend on mp_aheight in clone_metapath Andreas Gruenbacher
2018-07-30 20:06 ` Bob Peterson
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=20180730123353.15815-2-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 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).