* [Cluster-devel] [GFS2 PATCH] GFS2: Make sure rindex is uptodate before starting transactions [not found] <fec51564-d2da-46ef-a067-16d79b5bbffa@zmail12.collab.prod.int.phx2.redhat.com> @ 2012-04-05 2:11 ` Bob Peterson 2012-04-05 9:45 ` Steven Whitehouse 0 siblings, 1 reply; 2+ messages in thread From: Bob Peterson @ 2012-04-05 2:11 UTC (permalink / raw) To: cluster-devel.redhat.com Hi, This patch removes the call from gfs2_blk2rgrd to function gfs2_rindex_update and replaces it with individual calls. The former way turned out to be too problematic. Regards, Bob Peterson Red Hat File Systems Signed-off-by: Bob Peterson <rpeterso@redhat.com> -- Author: Bob Peterson <rpeterso@redhat.com> Date: Wed Apr 4 22:04:57 2012 -0500 GFS2: Make sure rindex is uptodate before starting transactions This patch checks to make sure rindex is uptodate (all the rgrps are read in properly) in case gfs2_grow adds some. It replaces the call from gfs2_blk2rgrd which was too frought with danger. diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index 197c5c4..03c04fe 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c @@ -724,7 +724,11 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, int metadata; unsigned int revokes = 0; int x; - int error = 0; + int error; + + error = gfs2_rindex_update(sdp); + if (error) + return error; if (!*top) sm->sm_first = 0; diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index c35573a..a836056 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c @@ -1844,6 +1844,10 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, unsigned int x, size = len * sizeof(u64); int error; + error = gfs2_rindex_update(sdp); + if (error) + return error; + memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); ht = kzalloc(size, GFP_NOFS); diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index c98a60e..a9ba244 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -1031,7 +1031,13 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry) struct buffer_head *bh; struct gfs2_holder ghs[3]; struct gfs2_rgrpd *rgd; - int error = -EROFS; + int error; + + error = gfs2_rindex_update(sdp); + if (error) + return error; + + error = -EROFS; gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); @@ -1224,6 +1230,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, return 0; } + error = gfs2_rindex_update(sdp); + if (error) + return error; + if (odip != ndip) { error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE, 0, &r_gh); @@ -1345,7 +1355,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, error = alloc_required; if (error < 0) goto out_gunlock; - error = 0; if (alloc_required) { struct gfs2_qadata *qa = gfs2_qadata_get(ndip); diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 19354a2..3df65c9 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c @@ -332,9 +332,6 @@ struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk, bool exact) struct rb_node *n, *next; struct gfs2_rgrpd *cur; - if (gfs2_rindex_update(sdp)) - return NULL; - spin_lock(&sdp->sd_rindex_spin); n = sdp->sd_rindex_tree.rb_node; while (n) { @@ -928,6 +925,10 @@ int gfs2_fitrim(struct file *filp, void __user *argp) } else if (copy_from_user(&r, argp, sizeof(r))) return -EFAULT; + ret = gfs2_rindex_update(sdp); + if (ret) + return ret; + rgd = gfs2_blk2rgrpd(sdp, r.start, 0); rgd_end = gfs2_blk2rgrpd(sdp, r.start + r.len, 0); diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c index 2e5ba42..927f4df 100644 --- a/fs/gfs2/xattr.c +++ b/fs/gfs2/xattr.c @@ -238,6 +238,10 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, unsigned int x; int error; + error = gfs2_rindex_update(sdp); + if (error) + return error; + if (GFS2_EA_IS_STUFFED(ea)) return 0; @@ -1330,6 +1334,10 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip) unsigned int x; int error; + error = gfs2_rindex_update(sdp); + if (error) + return error; + memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, &indbh); @@ -1439,6 +1447,10 @@ static int ea_dealloc_block(struct gfs2_inode *ip) struct gfs2_holder gh; int error; + error = gfs2_rindex_update(sdp); + if (error) + return error; + rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr, 1); if (!rgd) { gfs2_consist_inode(ip); ^ permalink raw reply related [flat|nested] 2+ messages in thread
* [Cluster-devel] [GFS2 PATCH] GFS2: Make sure rindex is uptodate before starting transactions 2012-04-05 2:11 ` [Cluster-devel] [GFS2 PATCH] GFS2: Make sure rindex is uptodate before starting transactions Bob Peterson @ 2012-04-05 9:45 ` Steven Whitehouse 0 siblings, 0 replies; 2+ messages in thread From: Steven Whitehouse @ 2012-04-05 9:45 UTC (permalink / raw) To: cluster-devel.redhat.com Hi, Now in the -nmw and -fixes tree. Thanks, Steve. On Wed, 2012-04-04 at 22:11 -0400, Bob Peterson wrote: > Hi, > > This patch removes the call from gfs2_blk2rgrd to function > gfs2_rindex_update and replaces it with individual calls. > The former way turned out to be too problematic. > > Regards, > > Bob Peterson > Red Hat File Systems > > Signed-off-by: Bob Peterson <rpeterso@redhat.com> > -- > Author: Bob Peterson <rpeterso@redhat.com> > Date: Wed Apr 4 22:04:57 2012 -0500 > > GFS2: Make sure rindex is uptodate before starting transactions > > This patch checks to make sure rindex is uptodate (all the rgrps are > read in properly) in case gfs2_grow adds some. It replaces the call > from gfs2_blk2rgrd which was too frought with danger. > > diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c > index 197c5c4..03c04fe 100644 > --- a/fs/gfs2/bmap.c > +++ b/fs/gfs2/bmap.c > @@ -724,7 +724,11 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, > int metadata; > unsigned int revokes = 0; > int x; > - int error = 0; > + int error; > + > + error = gfs2_rindex_update(sdp); > + if (error) > + return error; > > if (!*top) > sm->sm_first = 0; > diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c > index c35573a..a836056 100644 > --- a/fs/gfs2/dir.c > +++ b/fs/gfs2/dir.c > @@ -1844,6 +1844,10 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, > unsigned int x, size = len * sizeof(u64); > int error; > > + error = gfs2_rindex_update(sdp); > + if (error) > + return error; > + > memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); > > ht = kzalloc(size, GFP_NOFS); > diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c > index c98a60e..a9ba244 100644 > --- a/fs/gfs2/inode.c > +++ b/fs/gfs2/inode.c > @@ -1031,7 +1031,13 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry) > struct buffer_head *bh; > struct gfs2_holder ghs[3]; > struct gfs2_rgrpd *rgd; > - int error = -EROFS; > + int error; > + > + error = gfs2_rindex_update(sdp); > + if (error) > + return error; > + > + error = -EROFS; > > gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); > gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); > @@ -1224,6 +1230,10 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, > return 0; > } > > + error = gfs2_rindex_update(sdp); > + if (error) > + return error; > + > if (odip != ndip) { > error = gfs2_glock_nq_init(sdp->sd_rename_gl, LM_ST_EXCLUSIVE, > 0, &r_gh); > @@ -1345,7 +1355,6 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, > error = alloc_required; > if (error < 0) > goto out_gunlock; > - error = 0; > > if (alloc_required) { > struct gfs2_qadata *qa = gfs2_qadata_get(ndip); > diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c > index 19354a2..3df65c9 100644 > --- a/fs/gfs2/rgrp.c > +++ b/fs/gfs2/rgrp.c > @@ -332,9 +332,6 @@ struct gfs2_rgrpd *gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk, bool exact) > struct rb_node *n, *next; > struct gfs2_rgrpd *cur; > > - if (gfs2_rindex_update(sdp)) > - return NULL; > - > spin_lock(&sdp->sd_rindex_spin); > n = sdp->sd_rindex_tree.rb_node; > while (n) { > @@ -928,6 +925,10 @@ int gfs2_fitrim(struct file *filp, void __user *argp) > } else if (copy_from_user(&r, argp, sizeof(r))) > return -EFAULT; > > + ret = gfs2_rindex_update(sdp); > + if (ret) > + return ret; > + > rgd = gfs2_blk2rgrpd(sdp, r.start, 0); > rgd_end = gfs2_blk2rgrpd(sdp, r.start + r.len, 0); > > diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c > index 2e5ba42..927f4df 100644 > --- a/fs/gfs2/xattr.c > +++ b/fs/gfs2/xattr.c > @@ -238,6 +238,10 @@ static int ea_dealloc_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, > unsigned int x; > int error; > > + error = gfs2_rindex_update(sdp); > + if (error) > + return error; > + > if (GFS2_EA_IS_STUFFED(ea)) > return 0; > > @@ -1330,6 +1334,10 @@ static int ea_dealloc_indirect(struct gfs2_inode *ip) > unsigned int x; > int error; > > + error = gfs2_rindex_update(sdp); > + if (error) > + return error; > + > memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); > > error = gfs2_meta_read(ip->i_gl, ip->i_eattr, DIO_WAIT, &indbh); > @@ -1439,6 +1447,10 @@ static int ea_dealloc_block(struct gfs2_inode *ip) > struct gfs2_holder gh; > int error; > > + error = gfs2_rindex_update(sdp); > + if (error) > + return error; > + > rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr, 1); > if (!rgd) { > gfs2_consist_inode(ip); > ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-04-05 9:45 UTC | newest] Thread overview: 2+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- [not found] <fec51564-d2da-46ef-a067-16d79b5bbffa@zmail12.collab.prod.int.phx2.redhat.com> 2012-04-05 2:11 ` [Cluster-devel] [GFS2 PATCH] GFS2: Make sure rindex is uptodate before starting transactions Bob Peterson 2012-04-05 9:45 ` Steven Whitehouse
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).