Skip to content

Commit

Permalink
gfs2: Add extra error check in alloc_dinode
Browse files Browse the repository at this point in the history
We have reserved the number of blocks we want to allocate, so the actual
allocation isn't expected to fail.  Nevertheless, make the code behave
correctly even when things go wrong.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
  • Loading branch information
Andreas Gruenbacher committed Dec 2, 2022
1 parent b7b275e commit 35c23fb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion fs/gfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,15 @@ static int alloc_dinode(struct gfs2_inode *ip, u32 flags, unsigned *dblocks)
goto out_ipreserv;

error = gfs2_alloc_blocks(ip, &ip->i_no_addr, dblocks, 1, &ip->i_generation);
if (error)
goto out_trans_end;

ip->i_no_formal_ino = ip->i_generation;
ip->i_inode.i_ino = ip->i_no_addr;
ip->i_goal = ip->i_no_addr;

out_trans_end:
gfs2_trans_end(sdp);

out_ipreserv:
gfs2_inplace_release(ip);
out_quota:
Expand Down

0 comments on commit 35c23fb

Please sign in to comment.