Skip to contentSkip to conversation

gfs2: use reservation rgd, not inode rgd for allocating blocks

PATCH New Bob Peterson 2 participants 2 messages Jun 18, 2018 – Jun 20, 2018 1 message not in the archive GFS2 file system

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 gfs2: use reservation rgd, not inode rgd for allocating blocks

In reply to a message not in the archive

Hi,

Before this patch, function gfs2_alloc_blocks used ip->i_rgd as its starting rgrp for block allocations. In most cases that's correct. However, whenever an rlist is used, it can change the i_rgd value for better performance. Therefore, we should always use the reservation rgd instead. If we don't, the gfs2_rbm_eq function may not determine that the rgd for allocations is the same as the reservation, and therefore, the reservation won't be properly adjusted.

---
 fs/gfs2/rgrp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/rgrp.c +1 -1
index 9958a926cf72..5f695b8de30c 100644
@@ -2361,7 +2361,7 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks,
 {
 	struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
 	struct buffer_head *dibh;
-	struct gfs2_rbm rbm = { .rgd = ip->i_rgd, };
+	struct gfs2_rbm rbm = { .rgd = ip->i_res.rs_rbm.rgd, };
 	unsigned int ndata;
 	u64 block; /* block, within the file system scope */
 	int error;
#2 lore raw

PATCH 1/1 gfs2: use reservation rgd, not inode rgd for allocating blocks

Bob,

Quoted 22 lines · Bob Peterson

Hi,

Before this patch, function gfs2_alloc_blocks used ip->i_rgd as its starting rgrp for block allocations. In most cases that's correct. However, whenever an rlist is used, it can change the i_rgd value for better performance. Therefore, we should always use the reservation rgd instead. If we don't, the gfs2_rbm_eq function may not determine that the rgd for allocations is the same as the reservation, and therefore, the reservation won't be properly adjusted.

---
 fs/gfs2/rgrp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/gfs2/rgrp.c +0 -0
index 9958a926cf72..5f695b8de30c 100644

fs/gfs2/rgrp.c int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks, · line 2367

Quoted 8 lines
fs/gfs2/rgrp.c +1 -1
@@ -2361,7 +2361,7 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *nblocks,
 {
        struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
        struct buffer_head *dibh;
-       struct gfs2_rbm rbm = { .rgd = ip->i_rgd, };
+       struct gfs2_rbm rbm = { .rgd = ip->i_res.rs_rbm.rgd, };
        unsigned int ndata;
        u64 block; /* block, within the file system scope */
        int error;

I think we can do better than that; see the two patches I've just posted.

Thanks,
Andreas