summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-02-13 12:27:43 +0000
committerSteven Whitehouse <swhiteho@redhat.com>2006-02-13 12:27:43 +0000
commit7359a19cc758946aba0e45233b8641256b194884 (patch)
treed96aaeb2fb239efe6fdb0b4698eb94108719f423
parent18ec7d5c3f434aed9661ed10a9e1f48cdeb4981d (diff)
downloadlinux-7359a19cc758946aba0e45233b8641256b194884.tar.bz2
[GFS2] Fix for root inode ref count bug
Umount is now working correctly again. The bug was due to not getting an extra ref count when mounting the fs. We should have bumped it by two (once for the internal pointer to the root inode from the super block and once for the inode hanging off the dcache entry for root). Also this patch tidys up the code dealing with looking up and creating inodes. We now pass Linux inodes (with gfs2_inodes attached) rather than the other way around and this reduces code duplication in various places. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
-rw-r--r--fs/gfs2/glops.c4
-rw-r--r--fs/gfs2/incore.h2
-rw-r--r--fs/gfs2/inode.c70
-rw-r--r--fs/gfs2/inode.h15
-rw-r--r--fs/gfs2/log.c2
-rw-r--r--fs/gfs2/lops.c30
-rw-r--r--fs/gfs2/ops_export.c9
-rw-r--r--fs/gfs2/ops_fstype.c3
-rw-r--r--fs/gfs2/ops_inode.c67
-rw-r--r--fs/gfs2/quota.c2
-rw-r--r--fs/gfs2/recovery.c20
-rw-r--r--fs/gfs2/super.c12
12 files changed, 103 insertions, 133 deletions
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c
index 127008146a57..27374306ecde 100644
--- a/fs/gfs2/glops.c
+++ b/fs/gfs2/glops.c
@@ -358,13 +358,13 @@ static void trans_go_xmote_th(struct gfs2_glock *gl, unsigned int state,
static void trans_go_xmote_bh(struct gfs2_glock *gl)
{
struct gfs2_sbd *sdp = gl->gl_sbd;
- struct gfs2_glock *j_gl = sdp->sd_jdesc->jd_inode->i_gl;
+ struct gfs2_glock *j_gl = get_v2ip(sdp->sd_jdesc->jd_inode)->i_gl;
struct gfs2_log_header head;
int error;
if (gl->gl_state != LM_ST_UNLOCKED &&
test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
- gfs2_meta_cache_flush(sdp->sd_jdesc->jd_inode);
+ gfs2_meta_cache_flush(get_v2ip(sdp->sd_jdesc->jd_inode));
j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA);
error = gfs2_find_jhead(sdp->sd_jdesc, &head);
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index d1954e2bb908..e43a0475d0d8 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -378,7 +378,7 @@ struct gfs2_ail {
struct gfs2_jdesc {
struct list_head jd_list;
- struct gfs2_inode *jd_inode;
+ struct inode *jd_inode;
unsigned int jd_jid;
int jd_dirty;
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 4c193e38f8e4..2a00b96eac01 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -711,24 +711,28 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
* Returns: errno
*/
-int gfs2_lookupi(struct gfs2_inode *dip, struct qstr *name, int is_root,
- struct gfs2_inode **ipp)
+int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root,
+ struct inode **inodep)
{
+ struct gfs2_inode *ipp;
+ struct gfs2_inode *dip = get_v2ip(dir);
struct gfs2_sbd *sdp = dip->i_sbd;
struct gfs2_holder d_gh;
struct gfs2_inum inum;
unsigned int type;
struct gfs2_glock *gl;
- int error;
+ int error = 0;
+
+ *inodep = NULL;
if (!name->len || name->len > GFS2_FNAMESIZE)
return -ENAMETOOLONG;
if (gfs2_filecmp(name, ".", 1) ||
- (gfs2_filecmp(name, "..", 2) && dip == get_v2ip(sdp->sd_root_dir))) {
+ (gfs2_filecmp(name, "..", 2) && dir == sdp->sd_root_dir)) {
gfs2_inode_hold(dip);
- *ipp = dip;
- return 0;
+ ipp = dip;
+ goto done;
}
error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh);
@@ -750,15 +754,21 @@ int gfs2_lookupi(struct gfs2_inode *dip, struct qstr *name, int is_root,
if (error)
goto out;
- error = gfs2_inode_get(gl, &inum, CREATE, ipp);
+ error = gfs2_inode_get(gl, &inum, CREATE, &ipp);
if (!error)
- gfs2_inode_min_init(*ipp, type);
+ gfs2_inode_min_init(ipp, type);
gfs2_glock_put(gl);
- out:
+out:
gfs2_glock_dq_uninit(&d_gh);
-
+done:
+ if (error == 0) {
+ *inodep = gfs2_ip2v(ipp);
+ if (!*inodep)
+ error = -ENOMEM;
+ gfs2_inode_put(ipp);
+ }
return error;
}
@@ -1171,15 +1181,16 @@ static int link_dinode(struct gfs2_inode *dip, struct qstr *name,
* @ghs[0] is an initialized holder for the directory
* @ghs[1] is the holder for the inode lock
*
- * If the return value is 0, the glocks on both the directory and the new
+ * If the return value is not NULL, the glocks on both the directory and the new
* file are held. A transaction has been started and an inplace reservation
* is held, as well.
*
- * Returns: errno
+ * Returns: An inode
*/
-int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
+struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
{
+ struct inode *inode;
struct gfs2_inode *dip = get_gl2ip(ghs->gh_gl);
struct gfs2_sbd *sdp = dip->i_sbd;
struct gfs2_unlinked *ul;
@@ -1187,11 +1198,11 @@ int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
int error;
if (!name->len || name->len > GFS2_FNAMESIZE)
- return -ENAMETOOLONG;
+ return ERR_PTR(-ENAMETOOLONG);
error = gfs2_unlinked_get(sdp, &ul);
if (error)
- return error;
+ return ERR_PTR(error);
gfs2_holder_reinit(LM_ST_EXCLUSIVE, 0, ghs);
error = gfs2_glock_nq(ghs);
@@ -1220,7 +1231,7 @@ int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
ghs + 1);
if (error) {
gfs2_unlinked_put(sdp, ul);
- return error;
+ return ERR_PTR(error);
}
gfs2_holder_reinit(LM_ST_EXCLUSIVE, 0, ghs);
@@ -1228,7 +1239,7 @@ int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
if (error) {
gfs2_glock_dq_uninit(ghs + 1);
gfs2_unlinked_put(sdp, ul);
- return error;
+ return ERR_PTR(error);
}
error = create_ok(dip, name, mode);
@@ -1266,7 +1277,11 @@ int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
gfs2_unlinked_put(sdp, ul);
- return 0;
+ inode = gfs2_ip2v(ip);
+ gfs2_inode_put(ip);
+ if (!inode)
+ return ERR_PTR(-ENOMEM);
+ return inode;
fail_iput:
gfs2_inode_put(ip);
@@ -1280,7 +1295,7 @@ int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
fail:
gfs2_unlinked_put(sdp, ul);
- return error;
+ return ERR_PTR(error);
}
/**
@@ -1445,7 +1460,8 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, struct qstr *name,
int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
{
struct gfs2_sbd *sdp = this->i_sbd;
- struct gfs2_inode *tmp;
+ struct inode *dir = to->i_vnode;
+ struct inode *tmp;
struct qstr dotdot;
int error = 0;
@@ -1453,27 +1469,27 @@ int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
dotdot.name = "..";
dotdot.len = 2;
- gfs2_inode_hold(to);
+ igrab(dir);
for (;;) {
- if (to == this) {
+ if (dir == this->i_vnode) {
error = -EINVAL;
break;
}
- if (to == get_v2ip(sdp->sd_root_dir)) {
+ if (dir == sdp->sd_root_dir) {
error = 0;
break;
}
- error = gfs2_lookupi(to, &dotdot, 1, &tmp);
+ error = gfs2_lookupi(dir, &dotdot, 1, &tmp);
if (error)
break;
- gfs2_inode_put(to);
- to = tmp;
+ iput(dir);
+ dir = tmp;
}
- gfs2_inode_put(to);
+ iput(dir);
return error;
}
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index 214975c6bb22..8ef85f5feb1b 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -44,9 +44,9 @@ void gfs2_inode_destroy(struct gfs2_inode *ip);
int gfs2_inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul);
int gfs2_change_nlink(struct gfs2_inode *ip, int diff);
-int gfs2_lookupi(struct gfs2_inode *dip, struct qstr *name, int is_root,
- struct gfs2_inode **ipp);
-int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode);
+int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root,
+ struct inode **ipp);
+struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode);
int gfs2_unlinki(struct gfs2_inode *dip, struct qstr *name,
struct gfs2_inode *ip, struct gfs2_unlinked *ul);
int gfs2_rmdiri(struct gfs2_inode *dip, struct qstr *name,
@@ -68,19 +68,12 @@ int gfs2_repermission(struct inode *inode, int mask, struct nameidata *nd);
static inline int gfs2_lookup_simple(struct inode *dip, char *name,
struct inode **ipp)
{
- struct gfs2_inode *ip;
struct qstr qstr;
int err;
memset(&qstr, 0, sizeof(struct qstr));
qstr.name = name;
qstr.len = strlen(name);
- err = gfs2_lookupi(get_v2ip(dip), &qstr, 1, &ip);
- if (err == 0) {
- *ipp = gfs2_ip2v(ip);
- gfs2_inode_put(ip);
- if (*ipp == NULL)
- err = -ENOMEM;
- }
+ err = gfs2_lookupi(dip, &qstr, 1, ipp);
return err;
}
diff --git a/fs/gfs2/log.c b/fs/gfs2/log.c
index 9b4484d366ca..49190a29dd4f 100644
--- a/fs/gfs2/log.c
+++ b/fs/gfs2/log.c
@@ -274,7 +274,7 @@ static uint64_t log_bmap(struct gfs2_sbd *sdp, unsigned int lbn)
uint64_t dbn;
int error;
- error = gfs2_block_map(sdp->sd_jdesc->jd_inode, lbn, &new, &dbn, NULL);
+ error = gfs2_block_map(get_v2ip(sdp->sd_jdesc->jd_inode), lbn, &new, &dbn, NULL);
gfs2_assert_withdraw(sdp, !error && dbn);
return dbn;
diff --git a/fs/gfs2/lops.c b/fs/gfs2/lops.c
index dd41863810d7..23be00141901 100644
--- a/fs/gfs2/lops.c
+++ b/fs/gfs2/lops.c
@@ -177,7 +177,7 @@ static void buf_lo_after_commit(struct gfs2_sbd *sdp, struct gfs2_ail *ai)
static void buf_lo_before_scan(struct gfs2_jdesc *jd,
struct gfs2_log_header *head, int pass)
{
- struct gfs2_sbd *sdp = jd->jd_inode->i_sbd;
+ struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
if (pass != 0)
return;
@@ -190,8 +190,8 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
struct gfs2_log_descriptor *ld, __be64 *ptr,
int pass)
{
- struct gfs2_sbd *sdp = jd->jd_inode->i_sbd;
- struct gfs2_glock *gl = jd->jd_inode->i_gl;
+ struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
+ struct gfs2_glock *gl = get_v2ip(jd->jd_inode)->i_gl;
unsigned int blks = be32_to_cpu(ld->ld_data1);
struct buffer_head *bh_log, *bh_ip;
uint64_t blkno;
@@ -236,16 +236,16 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
{
- struct gfs2_sbd *sdp = jd->jd_inode->i_sbd;
+ struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
if (error) {
- gfs2_meta_sync(jd->jd_inode->i_gl, DIO_START | DIO_WAIT);
+ gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT);
return;
}
if (pass != 1)
return;
- gfs2_meta_sync(jd->jd_inode->i_gl, DIO_START | DIO_WAIT);
+ gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT);
fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n",
jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
@@ -320,7 +320,7 @@ static void revoke_lo_before_commit(struct gfs2_sbd *sdp)
static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
struct gfs2_log_header *head, int pass)
{
- struct gfs2_sbd *sdp = jd->jd_inode->i_sbd;
+ struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
if (pass != 0)
return;
@@ -333,7 +333,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
struct gfs2_log_descriptor *ld, __be64 *ptr,
int pass)
{
- struct gfs2_sbd *sdp = jd->jd_inode->i_sbd;
+ struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
unsigned int blks = be32_to_cpu(ld->ld_length);
unsigned int revokes = be32_to_cpu(ld->ld_data1);
struct buffer_head *bh;
@@ -379,7 +379,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
{
- struct gfs2_sbd *sdp = jd->jd_inode->i_sbd;
+ struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
if (error) {
gfs2_revoke_clean(sdp);
@@ -458,8 +458,6 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
gfs2_trans_add_gl(bd->bd_gl);
list_add(&bd->bd_list_tr, &tr->tr_list_buf);
gfs2_pin(sdp, bd->bd_bh);
- } else {
- clear_buffer_pinned(bd->bd_bh);
}
gfs2_log_lock(sdp);
if (ip->i_di.di_flags & GFS2_DIF_JDATA)
@@ -630,8 +628,8 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
struct gfs2_log_descriptor *ld,
__be64 *ptr, int pass)
{
- struct gfs2_sbd *sdp = jd->jd_inode->i_sbd;
- struct gfs2_glock *gl = jd->jd_inode->i_gl;
+ struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
+ struct gfs2_glock *gl = get_v2ip(jd->jd_inode)->i_gl;
unsigned int blks = be32_to_cpu(ld->ld_data1);
struct buffer_head *bh_log, *bh_ip;
uint64_t blkno;
@@ -680,17 +678,17 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
{
- struct gfs2_sbd *sdp = jd->jd_inode->i_sbd;
+ struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
if (error) {
- gfs2_meta_sync(jd->jd_inode->i_gl, DIO_START | DIO_WAIT);
+ gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT);
return;
}
if (pass != 1)
return;
/* data sync? */
- gfs2_meta_sync(jd->jd_inode->i_gl, DIO_START | DIO_WAIT);
+ gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT);
fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n",
jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks);
diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c
index 335448d3be21..8389f771d28b 100644
--- a/fs/gfs2/ops_export.c
+++ b/fs/gfs2/ops_export.c
@@ -169,23 +169,16 @@ static struct dentry *gfs2_get_parent(struct dentry *child)
{
struct gfs2_inode *dip = get_v2ip(child->d_inode);
struct qstr dotdot = { .name = "..", .len = 2 };
- struct gfs2_inode *ip;
struct inode *inode;
struct dentry *dentry;
int error;
atomic_inc(&dip->i_sbd->sd_ops_export);
- error = gfs2_lookupi(dip, &dotdot, 1, &ip);
+ error = gfs2_lookupi(child->d_inode, &dotdot, 1, &inode);
if (error)
return ERR_PTR(error);
- inode = gfs2_ip2v(ip);
- gfs2_inode_put(ip);
-
- if (!inode)
- return ERR_PTR(-ENOMEM);
-
dentry = d_alloc_anon(inode);
if (!dentry) {
iput(inode);
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 139cef8fff3a..80d5582d9d9b 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -360,6 +360,7 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo)
goto out_rooti;
}
+ igrab(inode);
sb->s_root = d_alloc_root(inode);
if (!sb->s_root) {
fs_err(sdp, "can't get root dentry\n");
@@ -434,7 +435,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
goto fail_jindex;
}
- error = gfs2_glock_nq_init(sdp->sd_jdesc->jd_inode->i_gl,
+ error = gfs2_glock_nq_init(get_v2ip(sdp->sd_jdesc->jd_inode)->i_gl,
LM_ST_SHARED,
LM_FLAG_NOEXP | GL_EXACT,
&sdp->sd_jinode_gh);
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index 6fff30ef8b70..9fb9490eb67a 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -49,7 +49,7 @@
static int gfs2_create(struct inode *dir, struct dentry *dentry,
int mode, struct nameidata *nd)
{
- struct gfs2_inode *dip = get_v2ip(dir), *ip;
+ struct gfs2_inode *dip = get_v2ip(dir);
struct gfs2_sbd *sdp = dip->i_sbd;
struct gfs2_holder ghs[2];
struct inode *inode;
@@ -61,9 +61,8 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry,
gfs2_holder_init(dip->i_gl, 0, 0, ghs);
for (;;) {
- error = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode);
- if (!error) {
- ip = get_gl2ip(ghs[1].gh_gl);
+ inode = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode);
+ if (!IS_ERR(inode)) {
gfs2_trans_end(sdp);
if (dip->i_alloc.al_rgd)
gfs2_inplace_release(dip);
@@ -71,13 +70,13 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry,
gfs2_alloc_put(dip);
gfs2_glock_dq_uninit_m(2, ghs);
break;
- } else if (error != -EEXIST ||
+ } else if (PTR_ERR(inode) != -EEXIST ||
(nd->intent.open.flags & O_EXCL)) {
gfs2_holder_uninit(ghs);
- return error;
+ return PTR_ERR(inode);
}
- error = gfs2_lookupi(dip, &dentry->d_name, 0, &ip);
+ error = gfs2_lookupi(dir, &dentry->d_name, 0, &inode);
if (!error) {
new = 0;
gfs2_holder_uninit(ghs);
@@ -88,12 +87,6 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry,
}
}
- inode = gfs2_ip2v(ip);
- gfs2_inode_put(ip);
-
- if (!inode)
- return -ENOMEM;
-
d_instantiate(dentry, inode);
if (new)
mark_inode_dirty(inode);
@@ -115,7 +108,7 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry,
static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd)
{
- struct gfs2_inode *dip = get_v2ip(dir), *ip;
+ struct gfs2_inode *dip = get_v2ip(dir);
struct gfs2_sbd *sdp = dip->i_sbd;
struct inode *inode = NULL;
int error;
@@ -125,14 +118,8 @@ static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry,
if (!sdp->sd_args.ar_localcaching)
dentry->d_op = &gfs2_dops;
- error = gfs2_lookupi(dip, &dentry->d_name, 0, &ip);
- if (!error) {
- inode = gfs2_ip2v(ip);
- gfs2_inode_put(ip);
- if (!inode)
- return ERR_PTR(-ENOMEM);
-
- } else if (error != -ENOENT)
+ error = gfs2_lookupi(dir, &dentry->d_name, 0, &inode);
+ if (error && error != -ENOENT)
return ERR_PTR(error);
if (inode)
@@ -367,10 +354,10 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
gfs2_holder_init(dip->i_gl, 0, 0, ghs);
- error = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO);
- if (error) {
+ inode = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO);
+ if (IS_ERR(inode)) {
gfs2_holder_uninit(ghs);
- return error;
+ return PTR_ERR(inode);
}
ip = get_gl2ip(ghs[1].gh_gl);
@@ -394,12 +381,6 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
gfs2_glock_dq_uninit_m(2, ghs);
- inode = gfs2_ip2v(ip);
- gfs2_inode_put(ip);
-
- if (!inode)
- return -ENOMEM;
-
d_instantiate(dentry, inode);
mark_inode_dirty(inode);
@@ -428,10 +409,10 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
gfs2_holder_init(dip->i_gl, 0, 0, ghs);
- error = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode);
- if (error) {
+ inode = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode);
+ if (IS_ERR(inode)) {
gfs2_holder_uninit(ghs);
- return error;
+ return PTR_ERR(inode);
}
ip = get_gl2ip(ghs[1].gh_gl);
@@ -481,12 +462,6 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
gfs2_glock_dq_uninit_m(2, ghs);
- inode = gfs2_ip2v(ip);
- gfs2_inode_put(ip);
-
- if (!inode)
- return -ENOMEM;
-
d_instantiate(dentry, inode);
mark_inode_dirty(inode);
@@ -598,10 +573,10 @@ static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode,
gfs2_holder_init(dip->i_gl, 0, 0, ghs);
- error = gfs2_createi(ghs, &dentry->d_name, mode);
- if (error) {
+ inode = gfs2_createi(ghs, &dentry->d_name, mode);
+ if (IS_ERR(inode)) {
gfs2_holder_uninit(ghs);
- return error;
+ return PTR_ERR(inode);
}
ip = get_gl2ip(ghs[1].gh_gl);
@@ -624,12 +599,6 @@ static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode,
gfs2_glock_dq_uninit_m(2, ghs);
- inode = gfs2_ip2v(ip);
- gfs2_inode_put(ip);
-
- if (!inode)
- return -ENOMEM;
-
d_instantiate(dentry, inode);
mark_inode_dirty(inode);
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 138fdf559a9a..7b5573946f19 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -572,7 +572,7 @@ static void do_qc(struct gfs2_quota_data *qd, int64_t change)
static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc,
int64_t change, struct gfs2_quota_data *qd)
{
- struct inode *inode = gfs2_ip2v(ip);
+ struct inode *inode = ip->i_vnode;
struct address_space *mapping = inode->i_mapping;
unsigned long index = loc >> PAGE_CACHE_SHIFT;
unsigned offset = loc & (PAGE_CACHE_SHIFT - 1);
diff --git a/fs/gfs2/recovery.c b/fs/gfs2/recovery.c
index 15cd26fbcff9..bcb81c768c8b 100644
--- a/fs/gfs2/recovery.c
+++ b/fs/gfs2/recovery.c
@@ -27,17 +27,17 @@
int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
struct buffer_head **bh)
{
- struct gfs2_glock *gl = jd->jd_inode->i_gl;
+ struct gfs2_glock *gl = get_v2ip(jd->jd_inode)->i_gl;
int new = 0;
uint64_t dblock;
uint32_t extlen;
int error;
- error = gfs2_block_map(jd->jd_inode, blk, &new, &dblock, &extlen);
+ error = gfs2_block_map(get_v2ip(jd->jd_inode), blk, &new, &dblock, &extlen);
if (error)
return error;
if (!dblock) {
- gfs2_consist_inode(jd->jd_inode);
+ gfs2_consist_inode(get_v2ip(jd->jd_inode));
return -EIO;
}
@@ -184,7 +184,7 @@ static int find_good_lh(struct gfs2_jdesc *jd, unsigned int *blk,
*blk = 0;
if (*blk == orig_blk) {
- gfs2_consist_inode(jd->jd_inode);
+ gfs2_consist_inode(get_v2ip(jd->jd_inode));
return -EIO;
}
}
@@ -218,7 +218,7 @@ static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
continue;
if (lh.lh_sequence == head->lh_sequence) {
- gfs2_consist_inode(jd->jd_inode);
+ gfs2_consist_inode(get_v2ip(jd->jd_inode));
return -EIO;
}
if (lh.lh_sequence < head->lh_sequence)
@@ -294,7 +294,7 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
unsigned int end, int pass)
{
- struct gfs2_sbd *sdp = jd->jd_inode->i_sbd;
+ struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
struct buffer_head *bh;
struct gfs2_log_descriptor *ld;
int error = 0;
@@ -323,7 +323,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
continue;
}
if (error == 1) {
- gfs2_consist_inode(jd->jd_inode);
+ gfs2_consist_inode(get_v2ip(jd->jd_inode));
error = -EIO;
}
brelse(bh);
@@ -360,7 +360,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
{
- struct gfs2_inode *ip = jd->jd_inode;
+ struct gfs2_inode *ip = get_v2ip(jd->jd_inode);
struct gfs2_sbd *sdp = ip->i_sbd;
unsigned int lblock;
int new = 0;
@@ -419,7 +419,7 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
int gfs2_recover_journal(struct gfs2_jdesc *jd, int wait)
{
- struct gfs2_sbd *sdp = jd->jd_inode->i_sbd;
+ struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
struct gfs2_log_header head;
struct gfs2_holder j_gh, ji_gh, t_gh;
unsigned long t;
@@ -449,7 +449,7 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd, int wait)
goto fail;
};
- error = gfs2_glock_nq_init(jd->jd_inode->i_gl, LM_ST_SHARED,
+ error = gfs2_glock_nq_init(get_v2ip(jd->jd_inode)->i_gl, LM_ST_SHARED,
LM_FLAG_NOEXP, &ji_gh);
if (error)
goto fail_gunlock_j;
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index bae32ba0c481..9b5c31952c5d 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -305,7 +305,7 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
if (!jd)
break;
- error = gfs2_lookupi(dip, &name, 1, &jd->jd_inode);
+ error = gfs2_lookupi(sdp->sd_jindex, &name, 1, &jd->jd_inode);
if (error) {
kfree(jd);
break;
@@ -342,7 +342,7 @@ void gfs2_jindex_free(struct gfs2_sbd *sdp)
while (!list_empty(&list)) {
jd = list_entry(list.next, struct gfs2_jdesc, jd_list);
list_del(&jd->jd_list);
- gfs2_inode_put(jd->jd_inode);
+ iput(jd->jd_inode);
kfree(jd);
}
}
@@ -411,7 +411,7 @@ struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp)
int gfs2_jdesc_check(struct gfs2_jdesc *jd)
{
- struct gfs2_inode *ip = jd->jd_inode;
+ struct gfs2_inode *ip = get_v2ip(jd->jd_inode);
struct gfs2_sbd *sdp = ip->i_sbd;
int ar;
int error;
@@ -462,7 +462,7 @@ int gfs2_lookup_master_dir(struct gfs2_sbd *sdp)
int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
{
- struct gfs2_glock *j_gl = sdp->sd_jdesc->jd_inode->i_gl;
+ struct gfs2_glock *j_gl = get_v2ip(sdp->sd_jdesc->jd_inode)->i_gl;
struct gfs2_holder t_gh;
struct gfs2_log_header head;
int error;
@@ -472,7 +472,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
if (error)
return error;
- gfs2_meta_cache_flush(sdp->sd_jdesc->jd_inode);
+ gfs2_meta_cache_flush(get_v2ip(sdp->sd_jdesc->jd_inode));
j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA);
error = gfs2_find_jhead(sdp->sd_jdesc, &head);
@@ -854,7 +854,7 @@ int gfs2_lock_fs_check_clean(struct gfs2_sbd *sdp, struct gfs2_holder *t_gh)
error = -ENOMEM;
goto out;
}
- error = gfs2_glock_nq_init(jd->jd_inode->i_gl, LM_ST_SHARED, 0,
+ error = gfs2_glock_nq_init(get_v2ip(jd->jd_inode)->i_gl, LM_ST_SHARED, 0,
&lfcc->gh);
if (error) {
kfree(lfcc);