aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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,
358static void trans_go_xmote_bh(struct gfs2_glock *gl) 358static void trans_go_xmote_bh(struct gfs2_glock *gl)
359{ 359{
360 struct gfs2_sbd *sdp = gl->gl_sbd; 360 struct gfs2_sbd *sdp = gl->gl_sbd;
361 struct gfs2_glock *j_gl = sdp->sd_jdesc->jd_inode->i_gl; 361 struct gfs2_glock *j_gl = get_v2ip(sdp->sd_jdesc->jd_inode)->i_gl;
362 struct gfs2_log_header head; 362 struct gfs2_log_header head;
363 int error; 363 int error;
364 364
365 if (gl->gl_state != LM_ST_UNLOCKED && 365 if (gl->gl_state != LM_ST_UNLOCKED &&
366 test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) { 366 test_bit(SDF_JOURNAL_LIVE, &sdp->sd_flags)) {
367 gfs2_meta_cache_flush(sdp->sd_jdesc->jd_inode); 367 gfs2_meta_cache_flush(get_v2ip(sdp->sd_jdesc->jd_inode));
368 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA); 368 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA);
369 369
370 error = gfs2_find_jhead(sdp->sd_jdesc, &head); 370 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 {
378struct gfs2_jdesc { 378struct gfs2_jdesc {
379 struct list_head jd_list; 379 struct list_head jd_list;
380 380
381 struct gfs2_inode *jd_inode; 381 struct inode *jd_inode;
382 unsigned int jd_jid; 382 unsigned int jd_jid;
383 int jd_dirty; 383 int jd_dirty;
384 384
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)
711 * Returns: errno 711 * Returns: errno
712 */ 712 */
713 713
714int gfs2_lookupi(struct gfs2_inode *dip, struct qstr *name, int is_root, 714int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root,
715 struct gfs2_inode **ipp) 715 struct inode **inodep)
716{ 716{
717 struct gfs2_inode *ipp;
718 struct gfs2_inode *dip = get_v2ip(dir);
717 struct gfs2_sbd *sdp = dip->i_sbd; 719 struct gfs2_sbd *sdp = dip->i_sbd;
718 struct gfs2_holder d_gh; 720 struct gfs2_holder d_gh;
719 struct gfs2_inum inum; 721 struct gfs2_inum inum;
720 unsigned int type; 722 unsigned int type;
721 struct gfs2_glock *gl; 723 struct gfs2_glock *gl;
722 int error; 724 int error = 0;
725
726 *inodep = NULL;
723 727
724 if (!name->len || name->len > GFS2_FNAMESIZE) 728 if (!name->len || name->len > GFS2_FNAMESIZE)
725 return -ENAMETOOLONG; 729 return -ENAMETOOLONG;
726 730
727 if (gfs2_filecmp(name, ".", 1) || 731 if (gfs2_filecmp(name, ".", 1) ||
728 (gfs2_filecmp(name, "..", 2) && dip == get_v2ip(sdp->sd_root_dir))) { 732 (gfs2_filecmp(name, "..", 2) && dir == sdp->sd_root_dir)) {
729 gfs2_inode_hold(dip); 733 gfs2_inode_hold(dip);
730 *ipp = dip; 734 ipp = dip;
731 return 0; 735 goto done;
732 } 736 }
733 737
734 error = gfs2_glock_nq_init(dip->i_gl, LM_ST_SHARED, 0, &d_gh); 738 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,
750 if (error) 754 if (error)
751 goto out; 755 goto out;
752 756
753 error = gfs2_inode_get(gl, &inum, CREATE, ipp); 757 error = gfs2_inode_get(gl, &inum, CREATE, &ipp);
754 if (!error) 758 if (!error)
755 gfs2_inode_min_init(*ipp, type); 759 gfs2_inode_min_init(ipp, type);
756 760
757 gfs2_glock_put(gl); 761 gfs2_glock_put(gl);
758 762
759 out: 763out:
760 gfs2_glock_dq_uninit(&d_gh); 764 gfs2_glock_dq_uninit(&d_gh);
761 765done:
766 if (error == 0) {
767 *inodep = gfs2_ip2v(ipp);
768 if (!*inodep)
769 error = -ENOMEM;
770 gfs2_inode_put(ipp);
771 }
762 return error; 772 return error;
763} 773}
764 774
@@ -1171,15 +1181,16 @@ static int link_dinode(struct gfs2_inode *dip, struct qstr *name,
1171 * @ghs[0] is an initialized holder for the directory 1181 * @ghs[0] is an initialized holder for the directory
1172 * @ghs[1] is the holder for the inode lock 1182 * @ghs[1] is the holder for the inode lock
1173 * 1183 *
1174 * If the return value is 0, the glocks on both the directory and the new 1184 * If the return value is not NULL, the glocks on both the directory and the new
1175 * file are held. A transaction has been started and an inplace reservation 1185 * file are held. A transaction has been started and an inplace reservation
1176 * is held, as well. 1186 * is held, as well.
1177 * 1187 *
1178 * Returns: errno 1188 * Returns: An inode
1179 */ 1189 */
1180 1190
1181int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode) 1191struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
1182{ 1192{
1193 struct inode *inode;
1183 struct gfs2_inode *dip = get_gl2ip(ghs->gh_gl); 1194 struct gfs2_inode *dip = get_gl2ip(ghs->gh_gl);
1184 struct gfs2_sbd *sdp = dip->i_sbd; 1195 struct gfs2_sbd *sdp = dip->i_sbd;
1185 struct gfs2_unlinked *ul; 1196 struct gfs2_unlinked *ul;
@@ -1187,11 +1198,11 @@ int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
1187 int error; 1198 int error;
1188 1199
1189 if (!name->len || name->len > GFS2_FNAMESIZE) 1200 if (!name->len || name->len > GFS2_FNAMESIZE)
1190 return -ENAMETOOLONG; 1201 return ERR_PTR(-ENAMETOOLONG);
1191 1202
1192 error = gfs2_unlinked_get(sdp, &ul); 1203 error = gfs2_unlinked_get(sdp, &ul);
1193 if (error) 1204 if (error)
1194 return error; 1205 return ERR_PTR(error);
1195 1206
1196 gfs2_holder_reinit(LM_ST_EXCLUSIVE, 0, ghs); 1207 gfs2_holder_reinit(LM_ST_EXCLUSIVE, 0, ghs);
1197 error = gfs2_glock_nq(ghs); 1208 error = gfs2_glock_nq(ghs);
@@ -1220,7 +1231,7 @@ int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
1220 ghs + 1); 1231 ghs + 1);
1221 if (error) { 1232 if (error) {
1222 gfs2_unlinked_put(sdp, ul); 1233 gfs2_unlinked_put(sdp, ul);
1223 return error; 1234 return ERR_PTR(error);
1224 } 1235 }
1225 1236
1226 gfs2_holder_reinit(LM_ST_EXCLUSIVE, 0, ghs); 1237 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)
1228 if (error) { 1239 if (error) {
1229 gfs2_glock_dq_uninit(ghs + 1); 1240 gfs2_glock_dq_uninit(ghs + 1);
1230 gfs2_unlinked_put(sdp, ul); 1241 gfs2_unlinked_put(sdp, ul);
1231 return error; 1242 return ERR_PTR(error);
1232 } 1243 }
1233 1244
1234 error = create_ok(dip, name, mode); 1245 error = create_ok(dip, name, mode);
@@ -1266,7 +1277,11 @@ int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
1266 1277
1267 gfs2_unlinked_put(sdp, ul); 1278 gfs2_unlinked_put(sdp, ul);
1268 1279
1269 return 0; 1280 inode = gfs2_ip2v(ip);
1281 gfs2_inode_put(ip);
1282 if (!inode)
1283 return ERR_PTR(-ENOMEM);
1284 return inode;
1270 1285
1271 fail_iput: 1286 fail_iput:
1272 gfs2_inode_put(ip); 1287 gfs2_inode_put(ip);
@@ -1280,7 +1295,7 @@ int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode)
1280 fail: 1295 fail:
1281 gfs2_unlinked_put(sdp, ul); 1296 gfs2_unlinked_put(sdp, ul);
1282 1297
1283 return error; 1298 return ERR_PTR(error);
1284} 1299}
1285 1300
1286/** 1301/**
@@ -1445,7 +1460,8 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, struct qstr *name,
1445int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to) 1460int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
1446{ 1461{
1447 struct gfs2_sbd *sdp = this->i_sbd; 1462 struct gfs2_sbd *sdp = this->i_sbd;
1448 struct gfs2_inode *tmp; 1463 struct inode *dir = to->i_vnode;
1464 struct inode *tmp;
1449 struct qstr dotdot; 1465 struct qstr dotdot;
1450 int error = 0; 1466 int error = 0;
1451 1467
@@ -1453,27 +1469,27 @@ int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
1453 dotdot.name = ".."; 1469 dotdot.name = "..";
1454 dotdot.len = 2; 1470 dotdot.len = 2;
1455 1471
1456 gfs2_inode_hold(to); 1472 igrab(dir);
1457 1473
1458 for (;;) { 1474 for (;;) {
1459 if (to == this) { 1475 if (dir == this->i_vnode) {
1460 error = -EINVAL; 1476 error = -EINVAL;
1461 break; 1477 break;
1462 } 1478 }
1463 if (to == get_v2ip(sdp->sd_root_dir)) { 1479 if (dir == sdp->sd_root_dir) {
1464 error = 0; 1480 error = 0;
1465 break; 1481 break;
1466 } 1482 }
1467 1483
1468 error = gfs2_lookupi(to, &dotdot, 1, &tmp); 1484 error = gfs2_lookupi(dir, &dotdot, 1, &tmp);
1469 if (error) 1485 if (error)
1470 break; 1486 break;
1471 1487
1472 gfs2_inode_put(to); 1488 iput(dir);
1473 to = tmp; 1489 dir = tmp;
1474 } 1490 }
1475 1491
1476 gfs2_inode_put(to); 1492 iput(dir);
1477 1493
1478 return error; 1494 return error;
1479} 1495}
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);
44int gfs2_inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul); 44int gfs2_inode_dealloc(struct gfs2_sbd *sdp, struct gfs2_unlinked *ul);
45 45
46int gfs2_change_nlink(struct gfs2_inode *ip, int diff); 46int gfs2_change_nlink(struct gfs2_inode *ip, int diff);
47int gfs2_lookupi(struct gfs2_inode *dip, struct qstr *name, int is_root, 47int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root,
48 struct gfs2_inode **ipp); 48 struct inode **ipp);
49int gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode); 49struct inode *gfs2_createi(struct gfs2_holder *ghs, struct qstr *name, unsigned int mode);
50int gfs2_unlinki(struct gfs2_inode *dip, struct qstr *name, 50int gfs2_unlinki(struct gfs2_inode *dip, struct qstr *name,
51 struct gfs2_inode *ip, struct gfs2_unlinked *ul); 51 struct gfs2_inode *ip, struct gfs2_unlinked *ul);
52int gfs2_rmdiri(struct gfs2_inode *dip, struct qstr *name, 52int gfs2_rmdiri(struct gfs2_inode *dip, struct qstr *name,
@@ -68,19 +68,12 @@ int gfs2_repermission(struct inode *inode, int mask, struct nameidata *nd);
68static inline int gfs2_lookup_simple(struct inode *dip, char *name, 68static inline int gfs2_lookup_simple(struct inode *dip, char *name,
69 struct inode **ipp) 69 struct inode **ipp)
70{ 70{
71 struct gfs2_inode *ip;
72 struct qstr qstr; 71 struct qstr qstr;
73 int err; 72 int err;
74 memset(&qstr, 0, sizeof(struct qstr)); 73 memset(&qstr, 0, sizeof(struct qstr));
75 qstr.name = name; 74 qstr.name = name;
76 qstr.len = strlen(name); 75 qstr.len = strlen(name);
77 err = gfs2_lookupi(get_v2ip(dip), &qstr, 1, &ip); 76 err = gfs2_lookupi(dip, &qstr, 1, ipp);
78 if (err == 0) {
79 *ipp = gfs2_ip2v(ip);
80 gfs2_inode_put(ip);
81 if (*ipp == NULL)
82 err = -ENOMEM;
83 }
84 return err; 77 return err;
85} 78}
86 79
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)
274 uint64_t dbn; 274 uint64_t dbn;
275 int error; 275 int error;
276 276
277 error = gfs2_block_map(sdp->sd_jdesc->jd_inode, lbn, &new, &dbn, NULL); 277 error = gfs2_block_map(get_v2ip(sdp->sd_jdesc->jd_inode), lbn, &new, &dbn, NULL);
278 gfs2_assert_withdraw(sdp, !error && dbn); 278 gfs2_assert_withdraw(sdp, !error && dbn);
279 279
280 return dbn; 280 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)
177static void buf_lo_before_scan(struct gfs2_jdesc *jd, 177static void buf_lo_before_scan(struct gfs2_jdesc *jd,
178 struct gfs2_log_header *head, int pass) 178 struct gfs2_log_header *head, int pass)
179{ 179{
180 struct gfs2_sbd *sdp = jd->jd_inode->i_sbd; 180 struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
181 181
182 if (pass != 0) 182 if (pass != 0)
183 return; 183 return;
@@ -190,8 +190,8 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
190 struct gfs2_log_descriptor *ld, __be64 *ptr, 190 struct gfs2_log_descriptor *ld, __be64 *ptr,
191 int pass) 191 int pass)
192{ 192{
193 struct gfs2_sbd *sdp = jd->jd_inode->i_sbd; 193 struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
194 struct gfs2_glock *gl = jd->jd_inode->i_gl; 194 struct gfs2_glock *gl = get_v2ip(jd->jd_inode)->i_gl;
195 unsigned int blks = be32_to_cpu(ld->ld_data1); 195 unsigned int blks = be32_to_cpu(ld->ld_data1);
196 struct buffer_head *bh_log, *bh_ip; 196 struct buffer_head *bh_log, *bh_ip;
197 uint64_t blkno; 197 uint64_t blkno;
@@ -236,16 +236,16 @@ static int buf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
236 236
237static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) 237static void buf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
238{ 238{
239 struct gfs2_sbd *sdp = jd->jd_inode->i_sbd; 239 struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
240 240
241 if (error) { 241 if (error) {
242 gfs2_meta_sync(jd->jd_inode->i_gl, DIO_START | DIO_WAIT); 242 gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT);
243 return; 243 return;
244 } 244 }
245 if (pass != 1) 245 if (pass != 1)
246 return; 246 return;
247 247
248 gfs2_meta_sync(jd->jd_inode->i_gl, DIO_START | DIO_WAIT); 248 gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT);
249 249
250 fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n", 250 fs_info(sdp, "jid=%u: Replayed %u of %u blocks\n",
251 jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks); 251 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)
320static void revoke_lo_before_scan(struct gfs2_jdesc *jd, 320static void revoke_lo_before_scan(struct gfs2_jdesc *jd,
321 struct gfs2_log_header *head, int pass) 321 struct gfs2_log_header *head, int pass)
322{ 322{
323 struct gfs2_sbd *sdp = jd->jd_inode->i_sbd; 323 struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
324 324
325 if (pass != 0) 325 if (pass != 0)
326 return; 326 return;
@@ -333,7 +333,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
333 struct gfs2_log_descriptor *ld, __be64 *ptr, 333 struct gfs2_log_descriptor *ld, __be64 *ptr,
334 int pass) 334 int pass)
335{ 335{
336 struct gfs2_sbd *sdp = jd->jd_inode->i_sbd; 336 struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
337 unsigned int blks = be32_to_cpu(ld->ld_length); 337 unsigned int blks = be32_to_cpu(ld->ld_length);
338 unsigned int revokes = be32_to_cpu(ld->ld_data1); 338 unsigned int revokes = be32_to_cpu(ld->ld_data1);
339 struct buffer_head *bh; 339 struct buffer_head *bh;
@@ -379,7 +379,7 @@ static int revoke_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
379 379
380static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) 380static void revoke_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
381{ 381{
382 struct gfs2_sbd *sdp = jd->jd_inode->i_sbd; 382 struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
383 383
384 if (error) { 384 if (error) {
385 gfs2_revoke_clean(sdp); 385 gfs2_revoke_clean(sdp);
@@ -458,8 +458,6 @@ static void databuf_lo_add(struct gfs2_sbd *sdp, struct gfs2_log_element *le)
458 gfs2_trans_add_gl(bd->bd_gl); 458 gfs2_trans_add_gl(bd->bd_gl);
459 list_add(&bd->bd_list_tr, &tr->tr_list_buf); 459 list_add(&bd->bd_list_tr, &tr->tr_list_buf);
460 gfs2_pin(sdp, bd->bd_bh); 460 gfs2_pin(sdp, bd->bd_bh);
461 } else {
462 clear_buffer_pinned(bd->bd_bh);
463 } 461 }
464 gfs2_log_lock(sdp); 462 gfs2_log_lock(sdp);
465 if (ip->i_di.di_flags & GFS2_DIF_JDATA) 463 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,
630 struct gfs2_log_descriptor *ld, 628 struct gfs2_log_descriptor *ld,
631 __be64 *ptr, int pass) 629 __be64 *ptr, int pass)
632{ 630{
633 struct gfs2_sbd *sdp = jd->jd_inode->i_sbd; 631 struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
634 struct gfs2_glock *gl = jd->jd_inode->i_gl; 632 struct gfs2_glock *gl = get_v2ip(jd->jd_inode)->i_gl;
635 unsigned int blks = be32_to_cpu(ld->ld_data1); 633 unsigned int blks = be32_to_cpu(ld->ld_data1);
636 struct buffer_head *bh_log, *bh_ip; 634 struct buffer_head *bh_log, *bh_ip;
637 uint64_t blkno; 635 uint64_t blkno;
@@ -680,17 +678,17 @@ static int databuf_lo_scan_elements(struct gfs2_jdesc *jd, unsigned int start,
680 678
681static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass) 679static void databuf_lo_after_scan(struct gfs2_jdesc *jd, int error, int pass)
682{ 680{
683 struct gfs2_sbd *sdp = jd->jd_inode->i_sbd; 681 struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
684 682
685 if (error) { 683 if (error) {
686 gfs2_meta_sync(jd->jd_inode->i_gl, DIO_START | DIO_WAIT); 684 gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT);
687 return; 685 return;
688 } 686 }
689 if (pass != 1) 687 if (pass != 1)
690 return; 688 return;
691 689
692 /* data sync? */ 690 /* data sync? */
693 gfs2_meta_sync(jd->jd_inode->i_gl, DIO_START | DIO_WAIT); 691 gfs2_meta_sync(get_v2ip(jd->jd_inode)->i_gl, DIO_START | DIO_WAIT);
694 692
695 fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n", 693 fs_info(sdp, "jid=%u: Replayed %u of %u data blocks\n",
696 jd->jd_jid, sdp->sd_replayed_blocks, sdp->sd_found_blocks); 694 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)
169{ 169{
170 struct gfs2_inode *dip = get_v2ip(child->d_inode); 170 struct gfs2_inode *dip = get_v2ip(child->d_inode);
171 struct qstr dotdot = { .name = "..", .len = 2 }; 171 struct qstr dotdot = { .name = "..", .len = 2 };
172 struct gfs2_inode *ip;
173 struct inode *inode; 172 struct inode *inode;
174 struct dentry *dentry; 173 struct dentry *dentry;
175 int error; 174 int error;
176 175
177 atomic_inc(&dip->i_sbd->sd_ops_export); 176 atomic_inc(&dip->i_sbd->sd_ops_export);
178 177
179 error = gfs2_lookupi(dip, &dotdot, 1, &ip); 178 error = gfs2_lookupi(child->d_inode, &dotdot, 1, &inode);
180 if (error) 179 if (error)
181 return ERR_PTR(error); 180 return ERR_PTR(error);
182 181
183 inode = gfs2_ip2v(ip);
184 gfs2_inode_put(ip);
185
186 if (!inode)
187 return ERR_PTR(-ENOMEM);
188
189 dentry = d_alloc_anon(inode); 182 dentry = d_alloc_anon(inode);
190 if (!dentry) { 183 if (!dentry) {
191 iput(inode); 184 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)
360 goto out_rooti; 360 goto out_rooti;
361 } 361 }
362 362
363 igrab(inode);
363 sb->s_root = d_alloc_root(inode); 364 sb->s_root = d_alloc_root(inode);
364 if (!sb->s_root) { 365 if (!sb->s_root) {
365 fs_err(sdp, "can't get root dentry\n"); 366 fs_err(sdp, "can't get root dentry\n");
@@ -434,7 +435,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
434 goto fail_jindex; 435 goto fail_jindex;
435 } 436 }
436 437
437 error = gfs2_glock_nq_init(sdp->sd_jdesc->jd_inode->i_gl, 438 error = gfs2_glock_nq_init(get_v2ip(sdp->sd_jdesc->jd_inode)->i_gl,
438 LM_ST_SHARED, 439 LM_ST_SHARED,
439 LM_FLAG_NOEXP | GL_EXACT, 440 LM_FLAG_NOEXP | GL_EXACT,
440 &sdp->sd_jinode_gh); 441 &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 @@
49static int gfs2_create(struct inode *dir, struct dentry *dentry, 49static int gfs2_create(struct inode *dir, struct dentry *dentry,
50 int mode, struct nameidata *nd) 50 int mode, struct nameidata *nd)
51{ 51{
52 struct gfs2_inode *dip = get_v2ip(dir), *ip; 52 struct gfs2_inode *dip = get_v2ip(dir);
53 struct gfs2_sbd *sdp = dip->i_sbd; 53 struct gfs2_sbd *sdp = dip->i_sbd;
54 struct gfs2_holder ghs[2]; 54 struct gfs2_holder ghs[2];
55 struct inode *inode; 55 struct inode *inode;
@@ -61,9 +61,8 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry,
61 gfs2_holder_init(dip->i_gl, 0, 0, ghs); 61 gfs2_holder_init(dip->i_gl, 0, 0, ghs);
62 62
63 for (;;) { 63 for (;;) {
64 error = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode); 64 inode = gfs2_createi(ghs, &dentry->d_name, S_IFREG | mode);
65 if (!error) { 65 if (!IS_ERR(inode)) {
66 ip = get_gl2ip(ghs[1].gh_gl);
67 gfs2_trans_end(sdp); 66 gfs2_trans_end(sdp);
68 if (dip->i_alloc.al_rgd) 67 if (dip->i_alloc.al_rgd)
69 gfs2_inplace_release(dip); 68 gfs2_inplace_release(dip);
@@ -71,13 +70,13 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry,
71 gfs2_alloc_put(dip); 70 gfs2_alloc_put(dip);
72 gfs2_glock_dq_uninit_m(2, ghs); 71 gfs2_glock_dq_uninit_m(2, ghs);
73 break; 72 break;
74 } else if (error != -EEXIST || 73 } else if (PTR_ERR(inode) != -EEXIST ||
75 (nd->intent.open.flags & O_EXCL)) { 74 (nd->intent.open.flags & O_EXCL)) {
76 gfs2_holder_uninit(ghs); 75 gfs2_holder_uninit(ghs);
77 return error; 76 return PTR_ERR(inode);
78 } 77 }
79 78
80 error = gfs2_lookupi(dip, &dentry->d_name, 0, &ip); 79 error = gfs2_lookupi(dir, &dentry->d_name, 0, &inode);
81 if (!error) { 80 if (!error) {
82 new = 0; 81 new = 0;
83 gfs2_holder_uninit(ghs); 82 gfs2_holder_uninit(ghs);
@@ -88,12 +87,6 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry,
88 } 87 }
89 } 88 }
90 89
91 inode = gfs2_ip2v(ip);
92 gfs2_inode_put(ip);
93
94 if (!inode)
95 return -ENOMEM;
96
97 d_instantiate(dentry, inode); 90 d_instantiate(dentry, inode);
98 if (new) 91 if (new)
99 mark_inode_dirty(inode); 92 mark_inode_dirty(inode);
@@ -115,7 +108,7 @@ static int gfs2_create(struct inode *dir, struct dentry *dentry,
115static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry, 108static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry,
116 struct nameidata *nd) 109 struct nameidata *nd)
117{ 110{
118 struct gfs2_inode *dip = get_v2ip(dir), *ip; 111 struct gfs2_inode *dip = get_v2ip(dir);
119 struct gfs2_sbd *sdp = dip->i_sbd; 112 struct gfs2_sbd *sdp = dip->i_sbd;
120 struct inode *inode = NULL; 113 struct inode *inode = NULL;
121 int error; 114 int error;
@@ -125,14 +118,8 @@ static struct dentry *gfs2_lookup(struct inode *dir, struct dentry *dentry,
125 if (!sdp->sd_args.ar_localcaching) 118 if (!sdp->sd_args.ar_localcaching)
126 dentry->d_op = &gfs2_dops; 119 dentry->d_op = &gfs2_dops;
127 120
128 error = gfs2_lookupi(dip, &dentry->d_name, 0, &ip); 121 error = gfs2_lookupi(dir, &dentry->d_name, 0, &inode);
129 if (!error) { 122 if (error && error != -ENOENT)
130 inode = gfs2_ip2v(ip);
131 gfs2_inode_put(ip);
132 if (!inode)
133 return ERR_PTR(-ENOMEM);
134
135 } else if (error != -ENOENT)
136 return ERR_PTR(error); 123 return ERR_PTR(error);
137 124
138 if (inode) 125 if (inode)
@@ -367,10 +354,10 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
367 354
368 gfs2_holder_init(dip->i_gl, 0, 0, ghs); 355 gfs2_holder_init(dip->i_gl, 0, 0, ghs);
369 356
370 error = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO); 357 inode = gfs2_createi(ghs, &dentry->d_name, S_IFLNK | S_IRWXUGO);
371 if (error) { 358 if (IS_ERR(inode)) {
372 gfs2_holder_uninit(ghs); 359 gfs2_holder_uninit(ghs);
373 return error; 360 return PTR_ERR(inode);
374 } 361 }
375 362
376 ip = get_gl2ip(ghs[1].gh_gl); 363 ip = get_gl2ip(ghs[1].gh_gl);
@@ -394,12 +381,6 @@ static int gfs2_symlink(struct inode *dir, struct dentry *dentry,
394 381
395 gfs2_glock_dq_uninit_m(2, ghs); 382 gfs2_glock_dq_uninit_m(2, ghs);
396 383
397 inode = gfs2_ip2v(ip);
398 gfs2_inode_put(ip);
399
400 if (!inode)
401 return -ENOMEM;
402
403 d_instantiate(dentry, inode); 384 d_instantiate(dentry, inode);
404 mark_inode_dirty(inode); 385 mark_inode_dirty(inode);
405 386
@@ -428,10 +409,10 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
428 409
429 gfs2_holder_init(dip->i_gl, 0, 0, ghs); 410 gfs2_holder_init(dip->i_gl, 0, 0, ghs);
430 411
431 error = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode); 412 inode = gfs2_createi(ghs, &dentry->d_name, S_IFDIR | mode);
432 if (error) { 413 if (IS_ERR(inode)) {
433 gfs2_holder_uninit(ghs); 414 gfs2_holder_uninit(ghs);
434 return error; 415 return PTR_ERR(inode);
435 } 416 }
436 417
437 ip = get_gl2ip(ghs[1].gh_gl); 418 ip = get_gl2ip(ghs[1].gh_gl);
@@ -481,12 +462,6 @@ static int gfs2_mkdir(struct inode *dir, struct dentry *dentry, int mode)
481 462
482 gfs2_glock_dq_uninit_m(2, ghs); 463 gfs2_glock_dq_uninit_m(2, ghs);
483 464
484 inode = gfs2_ip2v(ip);
485 gfs2_inode_put(ip);
486
487 if (!inode)
488 return -ENOMEM;
489
490 d_instantiate(dentry, inode); 465 d_instantiate(dentry, inode);
491 mark_inode_dirty(inode); 466 mark_inode_dirty(inode);
492 467
@@ -598,10 +573,10 @@ static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode,
598 573
599 gfs2_holder_init(dip->i_gl, 0, 0, ghs); 574 gfs2_holder_init(dip->i_gl, 0, 0, ghs);
600 575
601 error = gfs2_createi(ghs, &dentry->d_name, mode); 576 inode = gfs2_createi(ghs, &dentry->d_name, mode);
602 if (error) { 577 if (IS_ERR(inode)) {
603 gfs2_holder_uninit(ghs); 578 gfs2_holder_uninit(ghs);
604 return error; 579 return PTR_ERR(inode);
605 } 580 }
606 581
607 ip = get_gl2ip(ghs[1].gh_gl); 582 ip = get_gl2ip(ghs[1].gh_gl);
@@ -624,12 +599,6 @@ static int gfs2_mknod(struct inode *dir, struct dentry *dentry, int mode,
624 599
625 gfs2_glock_dq_uninit_m(2, ghs); 600 gfs2_glock_dq_uninit_m(2, ghs);
626 601
627 inode = gfs2_ip2v(ip);
628 gfs2_inode_put(ip);
629
630 if (!inode)
631 return -ENOMEM;
632
633 d_instantiate(dentry, inode); 602 d_instantiate(dentry, inode);
634 mark_inode_dirty(inode); 603 mark_inode_dirty(inode);
635 604
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)
572static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc, 572static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc,
573 int64_t change, struct gfs2_quota_data *qd) 573 int64_t change, struct gfs2_quota_data *qd)
574{ 574{
575 struct inode *inode = gfs2_ip2v(ip); 575 struct inode *inode = ip->i_vnode;
576 struct address_space *mapping = inode->i_mapping; 576 struct address_space *mapping = inode->i_mapping;
577 unsigned long index = loc >> PAGE_CACHE_SHIFT; 577 unsigned long index = loc >> PAGE_CACHE_SHIFT;
578 unsigned offset = loc & (PAGE_CACHE_SHIFT - 1); 578 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 @@
27int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk, 27int gfs2_replay_read_block(struct gfs2_jdesc *jd, unsigned int blk,
28 struct buffer_head **bh) 28 struct buffer_head **bh)
29{ 29{
30 struct gfs2_glock *gl = jd->jd_inode->i_gl; 30 struct gfs2_glock *gl = get_v2ip(jd->jd_inode)->i_gl;
31 int new = 0; 31 int new = 0;
32 uint64_t dblock; 32 uint64_t dblock;
33 uint32_t extlen; 33 uint32_t extlen;
34 int error; 34 int error;
35 35
36 error = gfs2_block_map(jd->jd_inode, blk, &new, &dblock, &extlen); 36 error = gfs2_block_map(get_v2ip(jd->jd_inode), blk, &new, &dblock, &extlen);
37 if (error) 37 if (error)
38 return error; 38 return error;
39 if (!dblock) { 39 if (!dblock) {
40 gfs2_consist_inode(jd->jd_inode); 40 gfs2_consist_inode(get_v2ip(jd->jd_inode));
41 return -EIO; 41 return -EIO;
42 } 42 }
43 43
@@ -184,7 +184,7 @@ static int find_good_lh(struct gfs2_jdesc *jd, unsigned int *blk,
184 *blk = 0; 184 *blk = 0;
185 185
186 if (*blk == orig_blk) { 186 if (*blk == orig_blk) {
187 gfs2_consist_inode(jd->jd_inode); 187 gfs2_consist_inode(get_v2ip(jd->jd_inode));
188 return -EIO; 188 return -EIO;
189 } 189 }
190 } 190 }
@@ -218,7 +218,7 @@ static int jhead_scan(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
218 continue; 218 continue;
219 219
220 if (lh.lh_sequence == head->lh_sequence) { 220 if (lh.lh_sequence == head->lh_sequence) {
221 gfs2_consist_inode(jd->jd_inode); 221 gfs2_consist_inode(get_v2ip(jd->jd_inode));
222 return -EIO; 222 return -EIO;
223 } 223 }
224 if (lh.lh_sequence < head->lh_sequence) 224 if (lh.lh_sequence < head->lh_sequence)
@@ -294,7 +294,7 @@ int gfs2_find_jhead(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
294static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start, 294static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
295 unsigned int end, int pass) 295 unsigned int end, int pass)
296{ 296{
297 struct gfs2_sbd *sdp = jd->jd_inode->i_sbd; 297 struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
298 struct buffer_head *bh; 298 struct buffer_head *bh;
299 struct gfs2_log_descriptor *ld; 299 struct gfs2_log_descriptor *ld;
300 int error = 0; 300 int error = 0;
@@ -323,7 +323,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
323 continue; 323 continue;
324 } 324 }
325 if (error == 1) { 325 if (error == 1) {
326 gfs2_consist_inode(jd->jd_inode); 326 gfs2_consist_inode(get_v2ip(jd->jd_inode));
327 error = -EIO; 327 error = -EIO;
328 } 328 }
329 brelse(bh); 329 brelse(bh);
@@ -360,7 +360,7 @@ static int foreach_descriptor(struct gfs2_jdesc *jd, unsigned int start,
360 360
361static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head) 361static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
362{ 362{
363 struct gfs2_inode *ip = jd->jd_inode; 363 struct gfs2_inode *ip = get_v2ip(jd->jd_inode);
364 struct gfs2_sbd *sdp = ip->i_sbd; 364 struct gfs2_sbd *sdp = ip->i_sbd;
365 unsigned int lblock; 365 unsigned int lblock;
366 int new = 0; 366 int new = 0;
@@ -419,7 +419,7 @@ static int clean_journal(struct gfs2_jdesc *jd, struct gfs2_log_header *head)
419 419
420int gfs2_recover_journal(struct gfs2_jdesc *jd, int wait) 420int gfs2_recover_journal(struct gfs2_jdesc *jd, int wait)
421{ 421{
422 struct gfs2_sbd *sdp = jd->jd_inode->i_sbd; 422 struct gfs2_sbd *sdp = get_v2ip(jd->jd_inode)->i_sbd;
423 struct gfs2_log_header head; 423 struct gfs2_log_header head;
424 struct gfs2_holder j_gh, ji_gh, t_gh; 424 struct gfs2_holder j_gh, ji_gh, t_gh;
425 unsigned long t; 425 unsigned long t;
@@ -449,7 +449,7 @@ int gfs2_recover_journal(struct gfs2_jdesc *jd, int wait)
449 goto fail; 449 goto fail;
450 }; 450 };
451 451
452 error = gfs2_glock_nq_init(jd->jd_inode->i_gl, LM_ST_SHARED, 452 error = gfs2_glock_nq_init(get_v2ip(jd->jd_inode)->i_gl, LM_ST_SHARED,
453 LM_FLAG_NOEXP, &ji_gh); 453 LM_FLAG_NOEXP, &ji_gh);
454 if (error) 454 if (error)
455 goto fail_gunlock_j; 455 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)
305 if (!jd) 305 if (!jd)
306 break; 306 break;
307 307
308 error = gfs2_lookupi(dip, &name, 1, &jd->jd_inode); 308 error = gfs2_lookupi(sdp->sd_jindex, &name, 1, &jd->jd_inode);
309 if (error) { 309 if (error) {
310 kfree(jd); 310 kfree(jd);
311 break; 311 break;
@@ -342,7 +342,7 @@ void gfs2_jindex_free(struct gfs2_sbd *sdp)
342 while (!list_empty(&list)) { 342 while (!list_empty(&list)) {
343 jd = list_entry(list.next, struct gfs2_jdesc, jd_list); 343 jd = list_entry(list.next, struct gfs2_jdesc, jd_list);
344 list_del(&jd->jd_list); 344 list_del(&jd->jd_list);
345 gfs2_inode_put(jd->jd_inode); 345 iput(jd->jd_inode);
346 kfree(jd); 346 kfree(jd);
347 } 347 }
348} 348}
@@ -411,7 +411,7 @@ struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp)
411 411
412int gfs2_jdesc_check(struct gfs2_jdesc *jd) 412int gfs2_jdesc_check(struct gfs2_jdesc *jd)
413{ 413{
414 struct gfs2_inode *ip = jd->jd_inode; 414 struct gfs2_inode *ip = get_v2ip(jd->jd_inode);
415 struct gfs2_sbd *sdp = ip->i_sbd; 415 struct gfs2_sbd *sdp = ip->i_sbd;
416 int ar; 416 int ar;
417 int error; 417 int error;
@@ -462,7 +462,7 @@ int gfs2_lookup_master_dir(struct gfs2_sbd *sdp)
462 462
463int gfs2_make_fs_rw(struct gfs2_sbd *sdp) 463int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
464{ 464{
465 struct gfs2_glock *j_gl = sdp->sd_jdesc->jd_inode->i_gl; 465 struct gfs2_glock *j_gl = get_v2ip(sdp->sd_jdesc->jd_inode)->i_gl;
466 struct gfs2_holder t_gh; 466 struct gfs2_holder t_gh;
467 struct gfs2_log_header head; 467 struct gfs2_log_header head;
468 int error; 468 int error;
@@ -472,7 +472,7 @@ int gfs2_make_fs_rw(struct gfs2_sbd *sdp)
472 if (error) 472 if (error)
473 return error; 473 return error;
474 474
475 gfs2_meta_cache_flush(sdp->sd_jdesc->jd_inode); 475 gfs2_meta_cache_flush(get_v2ip(sdp->sd_jdesc->jd_inode));
476 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA); 476 j_gl->gl_ops->go_inval(j_gl, DIO_METADATA | DIO_DATA);
477 477
478 error = gfs2_find_jhead(sdp->sd_jdesc, &head); 478 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)
854 error = -ENOMEM; 854 error = -ENOMEM;
855 goto out; 855 goto out;
856 } 856 }
857 error = gfs2_glock_nq_init(jd->jd_inode->i_gl, LM_ST_SHARED, 0, 857 error = gfs2_glock_nq_init(get_v2ip(jd->jd_inode)->i_gl, LM_ST_SHARED, 0,
858 &lfcc->gh); 858 &lfcc->gh);
859 if (error) { 859 if (error) {
860 kfree(lfcc); 860 kfree(lfcc);