Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bf97b673 authored by Benjamin Marzinski's avatar Benjamin Marzinski Committed by Steven Whitehouse
Browse files

GFS2: reserve more blocks for transactions



Some of the functions in GFS2 were not reserving space in the transaction for
the resource group header and the resource groups bitblocks that get added
when you do allocation. GFS2 now makes sure to reserve space for the
resource group header and either all the bitblocks in the resource group, or
one for each block that it may allocate, whichever is smaller using the new
gfs2_rg_blocks() inline function.

Signed-off-by: default avatarBenjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent d0795f91
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -663,6 +663,8 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping,
		rblocks += RES_STATFS + RES_QUOTA;
	if (&ip->i_inode == sdp->sd_rindex)
		rblocks += 2 * RES_STATFS;
	if (alloc_required)
		rblocks += gfs2_rg_blocks(al);

	error = gfs2_trans_begin(sdp, rblocks,
				 PAGE_CACHE_SIZE/sdp->sd_sb.sb_bsize);
+1 −1
Original line number Diff line number Diff line
@@ -1151,7 +1151,7 @@ static int do_grow(struct inode *inode, u64 size)
			goto do_grow_qunlock;
	}

	error = gfs2_trans_begin(sdp, RES_DINODE + 1, 0);
	error = gfs2_trans_begin(sdp, RES_DINODE + RES_STATFS + RES_RG_BIT, 0);
	if (error)
		goto do_grow_release;

+3 −1
Original line number Diff line number Diff line
@@ -382,8 +382,10 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
	rblocks = RES_DINODE + ind_blocks;
	if (gfs2_is_jdata(ip))
		rblocks += data_blocks ? data_blocks : 1;
	if (ind_blocks || data_blocks)
	if (ind_blocks || data_blocks) {
		rblocks += RES_STATFS + RES_QUOTA;
		rblocks += gfs2_rg_blocks(al);
	}
	ret = gfs2_trans_begin(sdp, rblocks, 0);
	if (ret)
		goto out_trans_fail;
+3 −3
Original line number Diff line number Diff line
@@ -219,7 +219,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir,
			goto out_gunlock_q;

		error = gfs2_trans_begin(sdp, sdp->sd_max_dirres +
					 al->al_rgd->rd_length +
					 gfs2_rg_blocks(al) +
					 2 * RES_DINODE + RES_STATFS +
					 RES_QUOTA, 0);
		if (error)
@@ -884,7 +884,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
			goto out_gunlock_q;

		error = gfs2_trans_begin(sdp, sdp->sd_max_dirres +
					 al->al_rgd->rd_length +
					 gfs2_rg_blocks(al) +
					 4 * RES_DINODE + 4 * RES_LEAF +
					 RES_STATFS + RES_QUOTA + 4, 0);
		if (error)
@@ -1481,7 +1481,7 @@ static long gfs2_fallocate(struct inode *inode, int mode, loff_t offset,
		al->al_requested = data_blocks + ind_blocks;

		rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA +
			  RES_RG_HDR + ip->i_alloc->al_rgd->rd_length;
			  RES_RG_HDR + gfs2_rg_blocks(al);
		if (gfs2_is_jdata(ip))
			rblocks += data_blocks ? data_blocks : 1;

+2 −1
Original line number Diff line number Diff line
@@ -815,7 +815,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda)
		goto out_alloc;

	if (nalloc)
		blocks += al->al_rgd->rd_length + nalloc * ind_blocks + RES_STATFS;
		blocks += gfs2_rg_blocks(al) + nalloc * ind_blocks + RES_STATFS;

	error = gfs2_trans_begin(sdp, blocks, 0);
	if (error)
@@ -1586,6 +1586,7 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id,
		error = gfs2_inplace_reserve(ip);
		if (error)
			goto out_alloc;
		blocks += gfs2_rg_blocks(al);
	}

	error = gfs2_trans_begin(sdp, blocks + RES_DINODE + 1, 0);
Loading