Skip to content

Commit

Permalink
gfs2: Use a tighter bound in gfs2_trans_begin
Browse files Browse the repository at this point in the history
Use a tighter bound for the number of blocks required by transactions in
gfs2_trans_begin: in the worst case, we'll have mixed data and metadata,
so we'll need a log desciptor for each type.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
  • Loading branch information
Andreas Gruenbacher committed Feb 3, 2021
1 parent 5ae8fff commit 297de31
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fs/gfs2/trans.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,14 @@ int __gfs2_trans_begin(struct gfs2_trans *tr, struct gfs2_sbd *sdp,
tr->tr_blocks = blocks;
tr->tr_revokes = revokes;
tr->tr_reserved = 1;
if (blocks)
tr->tr_reserved += 6 + blocks;
if (blocks) {
/*
* The reserved blocks are either used for data or metadata.
* We can have mixed data and metadata, each with its own log
* descriptor block; see calc_reserved().
*/
tr->tr_reserved += blocks + 1 + DIV_ROUND_UP(blocks - 1, databuf_limit(sdp));
}
if (revokes)
tr->tr_reserved += gfs2_struct2blk(sdp, revokes);
INIT_LIST_HEAD(&tr->tr_databuf);
Expand Down

0 comments on commit 297de31

Please sign in to comment.