Skip to content

Commit

Permalink
GFS2: Make sure rindex is uptodate before starting transactions
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
  • Loading branch information
Bob Peterson authored and Steven Whitehouse committed Apr 5, 2012
1 parent 97cc008 commit 5e2f7d6
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
6 changes: 5 additions & 1 deletion fs/gfs2/bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions fs/gfs2/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 11 additions & 2 deletions fs/gfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions fs/gfs2/rgrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);

Expand Down
12 changes: 12 additions & 0 deletions fs/gfs2/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5e2f7d6

Please sign in to comment.