aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorAbhi Das <adas@redhat.com>2014-09-18 22:40:28 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2014-09-19 05:45:18 -0400
commit00a158be83839f2d5370612d633eb2643ddf844e (patch)
treeafa1b3a2f820fe5b88af29975fc98004dd10bcdc /fs/gfs2
parent37504a3be90b69438426d74ccf467a9fe192932b (diff)
GFS2: fix bad inode i_goal values during block allocation
This patch checks if i_goal is either zero or if doesn't exist within any rgrp (i.e gfs2_blk2rgrpd() returns NULL). If so, it assigns the ip->i_no_addr block as the i_goal. There are two scenarios where a bad i_goal can result in a -EBADSLT error. 1. Attempting to allocate to an existing inode: Control reaches gfs2_inplace_reserve() and ip->i_goal is bad. We need to fix i_goal here. 2. A new inode is created in a directory whose i_goal is hosed: In this case, the parent dir's i_goal is copied onto the new inode. Since the new inode is not yet created, the ip->i_no_addr field is invalid and so, the fix in gfs2_inplace_reserve() as per 1) won't work in this scenario. We need to catch and fix it sooner in the parent dir itself (gfs2_create_inode()), before it is copied to the new inode. Signed-off-by: Abhi Das <adas@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/inode.c1
-rw-r--r--fs/gfs2/rgrp.c8
-rw-r--r--fs/gfs2/rgrp.h1
3 files changed, 10 insertions, 0 deletions
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index fc8ac2ee0667..9516f5c02151 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -672,6 +672,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
672 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; 672 inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
673 gfs2_set_inode_blocks(inode, 1); 673 gfs2_set_inode_blocks(inode, 1);
674 munge_mode_uid_gid(dip, inode); 674 munge_mode_uid_gid(dip, inode);
675 check_and_update_goal(dip);
675 ip->i_goal = dip->i_goal; 676 ip->i_goal = dip->i_goal;
676 ip->i_diskflags = 0; 677 ip->i_diskflags = 0;
677 ip->i_eattr = 0; 678 ip->i_eattr = 0;
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index f4cb9c0d6bbd..55ef72dc5b13 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -577,6 +577,13 @@ struct gfs2_rgrpd *gfs2_rgrpd_get_next(struct gfs2_rgrpd *rgd)
577 return rgd; 577 return rgd;
578} 578}
579 579
580void check_and_update_goal(struct gfs2_inode *ip)
581{
582 struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode);
583 if (!ip->i_goal || gfs2_blk2rgrpd(sdp, ip->i_goal, 1) == NULL)
584 ip->i_goal = ip->i_no_addr;
585}
586
580void gfs2_free_clones(struct gfs2_rgrpd *rgd) 587void gfs2_free_clones(struct gfs2_rgrpd *rgd)
581{ 588{
582 int x; 589 int x;
@@ -1910,6 +1917,7 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip, const struct gfs2_alloc_parms *a
1910 } else if (ip->i_rgd && rgrp_contains_block(ip->i_rgd, ip->i_goal)) { 1917 } else if (ip->i_rgd && rgrp_contains_block(ip->i_rgd, ip->i_goal)) {
1911 rs->rs_rbm.rgd = begin = ip->i_rgd; 1918 rs->rs_rbm.rgd = begin = ip->i_rgd;
1912 } else { 1919 } else {
1920 check_and_update_goal(ip);
1913 rs->rs_rbm.rgd = begin = gfs2_blk2rgrpd(sdp, ip->i_goal, 1); 1921 rs->rs_rbm.rgd = begin = gfs2_blk2rgrpd(sdp, ip->i_goal, 1);
1914 } 1922 }
1915 if (S_ISDIR(ip->i_inode.i_mode) && (ap->aflags & GFS2_AF_ORLOV)) 1923 if (S_ISDIR(ip->i_inode.i_mode) && (ap->aflags & GFS2_AF_ORLOV))
diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h
index 463ab2e95d1c..5d8f085f7ade 100644
--- a/fs/gfs2/rgrp.h
+++ b/fs/gfs2/rgrp.h
@@ -80,4 +80,5 @@ static inline bool gfs2_rs_active(struct gfs2_blkreserv *rs)
80 return rs && !RB_EMPTY_NODE(&rs->rs_node); 80 return rs && !RB_EMPTY_NODE(&rs->rs_node);
81} 81}
82 82
83extern void check_and_update_goal(struct gfs2_inode *ip);
83#endif /* __RGRP_DOT_H__ */ 84#endif /* __RGRP_DOT_H__ */