From mboxrd@z Thu Jan 1 00:00:00 1970 From: Steven Whitehouse Date: Tue, 28 Sep 2010 10:47:27 +0100 Subject: [Cluster-devel] [PATCH v2] GFS2: reserve more blocks for transactions In-Reply-To: <20100927210004.GM3044@ether.msp.redhat.com> References: <20100927210004.GM3044@ether.msp.redhat.com> Message-ID: <1285667247.2457.1.camel@dolmen> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi, Now in the -nmw tree. Thanks, Steve. On Mon, 2010-09-27 at 16:00 -0500, Benjamin Marzinski wrote: > 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: Benjamin Marzinski > --- > fs/gfs2/aops.c | 2 ++ > fs/gfs2/bmap.c | 2 +- > fs/gfs2/file.c | 4 +++- > fs/gfs2/ops_inode.c | 6 +++--- > fs/gfs2/quota.c | 3 ++- > fs/gfs2/trans.h | 8 ++++++++ > fs/gfs2/xattr.c | 2 +- > 7 files changed, 20 insertions(+), 7 deletions(-) > > Index: gfs2-2.6-nmw/fs/gfs2/aops.c > =================================================================== > --- gfs2-2.6-nmw.orig/fs/gfs2/aops.c > +++ gfs2-2.6-nmw/fs/gfs2/aops.c > @@ -663,6 +663,8 @@ static int gfs2_write_begin(struct file > 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); > Index: gfs2-2.6-nmw/fs/gfs2/bmap.c > =================================================================== > --- gfs2-2.6-nmw.orig/fs/gfs2/bmap.c > +++ gfs2-2.6-nmw/fs/gfs2/bmap.c > @@ -1151,7 +1151,7 @@ static int do_grow(struct inode *inode, > 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; > > Index: gfs2-2.6-nmw/fs/gfs2/file.c > =================================================================== > --- gfs2-2.6-nmw.orig/fs/gfs2/file.c > +++ gfs2-2.6-nmw/fs/gfs2/file.c > @@ -382,8 +382,10 @@ static int gfs2_page_mkwrite(struct vm_a > 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; > Index: gfs2-2.6-nmw/fs/gfs2/quota.c > =================================================================== > --- gfs2-2.6-nmw.orig/fs/gfs2/quota.c > +++ gfs2-2.6-nmw/fs/gfs2/quota.c > @@ -815,7 +815,7 @@ static int do_sync(unsigned int num_qd, > 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_b > 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); > Index: gfs2-2.6-nmw/fs/gfs2/ops_inode.c > =================================================================== > --- gfs2-2.6-nmw.orig/fs/gfs2/ops_inode.c > +++ gfs2-2.6-nmw/fs/gfs2/ops_inode.c > @@ -219,7 +219,7 @@ static int gfs2_link(struct dentry *old_ > 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) > @@ -893,7 +893,7 @@ static int gfs2_rename(struct inode *odi > 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) > @@ -1493,7 +1493,7 @@ retry: > 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; > > Index: gfs2-2.6-nmw/fs/gfs2/trans.h > =================================================================== > --- gfs2-2.6-nmw.orig/fs/gfs2/trans.h > +++ gfs2-2.6-nmw/fs/gfs2/trans.h > @@ -26,6 +26,14 @@ struct gfs2_glock; > #define RES_STATFS 1 > #define RES_QUOTA 2 > > +/* reserve either the number of blocks to be allocated plus the rg header > + * block, or all of the blocks in the rg, whichever is smaller */ > +static inline unsigned int gfs2_rg_blocks(const struct gfs2_alloc *al) > +{ > + return (al->al_requested < al->al_rgd->rd_length)? > + al->al_requested + 1 : al->al_rgd->rd_length; > +} > + > int gfs2_trans_begin(struct gfs2_sbd *sdp, unsigned int blocks, > unsigned int revokes); > > Index: gfs2-2.6-nmw/fs/gfs2/xattr.c > =================================================================== > --- gfs2-2.6-nmw.orig/fs/gfs2/xattr.c > +++ gfs2-2.6-nmw/fs/gfs2/xattr.c > @@ -734,7 +734,7 @@ static int ea_alloc_skeleton(struct gfs2 > goto out_gunlock_q; > > error = gfs2_trans_begin(GFS2_SB(&ip->i_inode), > - blks + al->al_rgd->rd_length + > + blks + gfs2_rg_blocks(al) + > RES_DINODE + RES_STATFS + RES_QUOTA, 0); > if (error) > goto out_ipres; >