aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/gfs2/incore.h29
-rw-r--r--fs/gfs2/inode.c10
-rw-r--r--fs/gfs2/inode.h15
-rw-r--r--fs/gfs2/jdata.c7
-rw-r--r--fs/gfs2/ops_export.c2
-rw-r--r--fs/gfs2/ops_file.h4
-rw-r--r--fs/gfs2/ops_fstype.c184
-rw-r--r--fs/gfs2/ops_super.c22
-rw-r--r--fs/gfs2/quota.c27
-rw-r--r--fs/gfs2/rgrp.c13
-rw-r--r--fs/gfs2/super.c19
-rw-r--r--fs/gfs2/unlinked.c4
12 files changed, 187 insertions, 149 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 3bc40ff5fdf9..d1954e2bb908 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -98,10 +98,13 @@ struct gfs2_rgrpd {
98 98
99enum gfs2_state_bits { 99enum gfs2_state_bits {
100 BH_Pinned = BH_PrivateStart, 100 BH_Pinned = BH_PrivateStart,
101 BH_Escaped = BH_PrivateStart + 1,
101}; 102};
102 103
103BUFFER_FNS(Pinned, pinned) 104BUFFER_FNS(Pinned, pinned)
104TAS_BUFFER_FNS(Pinned, pinned) 105TAS_BUFFER_FNS(Pinned, pinned)
106BUFFER_FNS(Escaped, escaped)
107TAS_BUFFER_FNS(Escaped, escaped)
105 108
106struct gfs2_bufdata { 109struct gfs2_bufdata {
107 struct buffer_head *bd_bh; 110 struct buffer_head *bd_bh;
@@ -254,7 +257,7 @@ struct gfs2_inode {
254 struct inode *i_vnode; 257 struct inode *i_vnode;
255 258
256 struct gfs2_holder i_iopen_gh; 259 struct gfs2_holder i_iopen_gh;
257 260 struct gfs2_holder i_gh; /* for prepare/commit_write only */
258 struct gfs2_alloc i_alloc; 261 struct gfs2_alloc i_alloc;
259 uint64_t i_last_rg_alloc; 262 uint64_t i_last_rg_alloc;
260 263
@@ -511,17 +514,17 @@ struct gfs2_sbd {
511 514
512 /* Inode Stuff */ 515 /* Inode Stuff */
513 516
514 struct gfs2_inode *sd_master_dir; 517 struct inode *sd_master_dir;
515 struct gfs2_inode *sd_jindex; 518 struct inode *sd_jindex;
516 struct gfs2_inode *sd_inum_inode; 519 struct inode *sd_inum_inode;
517 struct gfs2_inode *sd_statfs_inode; 520 struct inode *sd_statfs_inode;
518 struct gfs2_inode *sd_ir_inode; 521 struct inode *sd_ir_inode;
519 struct gfs2_inode *sd_sc_inode; 522 struct inode *sd_sc_inode;
520 struct gfs2_inode *sd_ut_inode; 523 struct inode *sd_ut_inode;
521 struct gfs2_inode *sd_qc_inode; 524 struct inode *sd_qc_inode;
522 struct gfs2_inode *sd_rindex; 525 struct inode *sd_rindex;
523 struct gfs2_inode *sd_quota_inode; 526 struct inode *sd_quota_inode;
524 struct gfs2_inode *sd_root_dir; 527 struct inode *sd_root_dir;
525 528
526 /* Inum stuff */ 529 /* Inum stuff */
527 530
@@ -615,6 +618,8 @@ struct gfs2_sbd {
615 unsigned int sd_log_num_revoke; 618 unsigned int sd_log_num_revoke;
616 unsigned int sd_log_num_rg; 619 unsigned int sd_log_num_rg;
617 unsigned int sd_log_num_databuf; 620 unsigned int sd_log_num_databuf;
621 unsigned int sd_log_num_jdata;
622
618 struct list_head sd_log_le_gl; 623 struct list_head sd_log_le_gl;
619 struct list_head sd_log_le_buf; 624 struct list_head sd_log_le_buf;
620 struct list_head sd_log_le_revoke; 625 struct list_head sd_log_le_revoke;
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index e4ba380b286a..4c193e38f8e4 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -725,7 +725,7 @@ int gfs2_lookupi(struct gfs2_inode *dip, struct qstr *name, int is_root,
725 return -ENAMETOOLONG; 725 return -ENAMETOOLONG;
726 726
727 if (gfs2_filecmp(name, ".", 1) || 727 if (gfs2_filecmp(name, ".", 1) ||
728 (gfs2_filecmp(name, "..", 2) && dip == sdp->sd_root_dir)) { 728 (gfs2_filecmp(name, "..", 2) && dip == get_v2ip(sdp->sd_root_dir))) {
729 gfs2_inode_hold(dip); 729 gfs2_inode_hold(dip);
730 *ipp = dip; 730 *ipp = dip;
731 return 0; 731 return 0;
@@ -764,7 +764,7 @@ int gfs2_lookupi(struct gfs2_inode *dip, struct qstr *name, int is_root,
764 764
765static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino) 765static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino)
766{ 766{
767 struct gfs2_inode *ip = sdp->sd_ir_inode; 767 struct gfs2_inode *ip = get_v2ip(sdp->sd_ir_inode);
768 struct buffer_head *bh; 768 struct buffer_head *bh;
769 struct gfs2_inum_range ir; 769 struct gfs2_inum_range ir;
770 int error; 770 int error;
@@ -805,8 +805,8 @@ static int pick_formal_ino_1(struct gfs2_sbd *sdp, uint64_t *formal_ino)
805 805
806static int pick_formal_ino_2(struct gfs2_sbd *sdp, uint64_t *formal_ino) 806static int pick_formal_ino_2(struct gfs2_sbd *sdp, uint64_t *formal_ino)
807{ 807{
808 struct gfs2_inode *ip = sdp->sd_ir_inode; 808 struct gfs2_inode *ip = get_v2ip(sdp->sd_ir_inode);
809 struct gfs2_inode *m_ip = sdp->sd_inum_inode; 809 struct gfs2_inode *m_ip = get_v2ip(sdp->sd_inum_inode);
810 struct gfs2_holder gh; 810 struct gfs2_holder gh;
811 struct buffer_head *bh; 811 struct buffer_head *bh;
812 struct gfs2_inum_range ir; 812 struct gfs2_inum_range ir;
@@ -1460,7 +1460,7 @@ int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
1460 error = -EINVAL; 1460 error = -EINVAL;
1461 break; 1461 break;
1462 } 1462 }
1463 if (to == sdp->sd_root_dir) { 1463 if (to == get_v2ip(sdp->sd_root_dir)) {
1464 error = 0; 1464 error = 0;
1465 break; 1465 break;
1466 } 1466 }
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index 4df7da51f715..e42ae38d6778 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -60,14 +60,23 @@ int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr);
60 60
61int gfs2_repermission(struct inode *inode, int mask, struct nameidata *nd); 61int gfs2_repermission(struct inode *inode, int mask, struct nameidata *nd);
62 62
63static inline int gfs2_lookup_simple(struct gfs2_inode *dip, char *name, 63static inline int gfs2_lookup_simple(struct inode *dip, char *name,
64 struct gfs2_inode **ipp) 64 struct inode **ipp)
65{ 65{
66 struct gfs2_inode *ip;
66 struct qstr qstr; 67 struct qstr qstr;
68 int err;
67 memset(&qstr, 0, sizeof(struct qstr)); 69 memset(&qstr, 0, sizeof(struct qstr));
68 qstr.name = name; 70 qstr.name = name;
69 qstr.len = strlen(name); 71 qstr.len = strlen(name);
70 return gfs2_lookupi(dip, &qstr, 1, ipp); 72 err = gfs2_lookupi(get_v2ip(dip), &qstr, 1, &ip);
73 if (err == 0) {
74 *ipp = gfs2_ip2v(ip);
75 if (*ipp == NULL)
76 err = -ENOMEM;
77 gfs2_inode_put(ip);
78 }
79 return err;
71} 80}
72 81
73#endif /* __INODE_DOT_H__ */ 82#endif /* __INODE_DOT_H__ */
diff --git a/fs/gfs2/jdata.c b/fs/gfs2/jdata.c
index 6caa93e46ce0..e43eaf133f10 100644
--- a/fs/gfs2/jdata.c
+++ b/fs/gfs2/jdata.c
@@ -22,6 +22,13 @@
22#include "meta_io.h" 22#include "meta_io.h"
23#include "trans.h" 23#include "trans.h"
24 24
25int gfs2_internal_read(struct gfs2_inode *ip,
26 struct file_ra_state *ra_state,
27 char *buf, loff_t *pos, unsigned size)
28{
29 return gfs2_jdata_read_mem(ip, buf, *pos, size);
30}
31
25int gfs2_jdata_get_buffer(struct gfs2_inode *ip, uint64_t block, int new, 32int gfs2_jdata_get_buffer(struct gfs2_inode *ip, uint64_t block, int new,
26 struct buffer_head **bhp) 33 struct buffer_head **bhp)
27{ 34{
diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c
index 0ae3a0af192d..335448d3be21 100644
--- a/fs/gfs2/ops_export.c
+++ b/fs/gfs2/ops_export.c
@@ -81,7 +81,7 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
81 fh[3] = cpu_to_be32(fh[3]); 81 fh[3] = cpu_to_be32(fh[3]);
82 *len = 4; 82 *len = 4;
83 83
84 if (!connectable || ip == sdp->sd_root_dir) 84 if (!connectable || ip == get_v2ip(sdp->sd_root_dir))
85 return *len; 85 return *len;
86 86
87 spin_lock(&dentry->d_lock); 87 spin_lock(&dentry->d_lock);
diff --git a/fs/gfs2/ops_file.h b/fs/gfs2/ops_file.h
index 95123d7bbcdf..3c237bfc143d 100644
--- a/fs/gfs2/ops_file.h
+++ b/fs/gfs2/ops_file.h
@@ -10,6 +10,10 @@
10#ifndef __OPS_FILE_DOT_H__ 10#ifndef __OPS_FILE_DOT_H__
11#define __OPS_FILE_DOT_H__ 11#define __OPS_FILE_DOT_H__
12 12
13extern int gfs2_internal_read(struct gfs2_inode *ip,
14 struct file_ra_state *ra_state,
15 char *buf, loff_t *pos, unsigned size);
16
13extern struct file_operations gfs2_file_fops; 17extern struct file_operations gfs2_file_fops;
14extern struct file_operations gfs2_dir_fops; 18extern struct file_operations gfs2_dir_fops;
15 19
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index c61a80c439a6..139cef8fff3a 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -275,14 +275,38 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh,
275 return error; 275 return error;
276} 276}
277 277
278int gfs2_lookup_root(struct gfs2_sbd *sdp)
279{
280 int error;
281 struct gfs2_glock *gl;
282 struct gfs2_inode *ip;
283
284 error = gfs2_glock_get(sdp, sdp->sd_sb.sb_root_dir.no_addr,
285 &gfs2_inode_glops, CREATE, &gl);
286 if (!error) {
287 error = gfs2_inode_get(gl, &sdp->sd_sb.sb_root_dir,
288 CREATE, &ip);
289 if (!error) {
290 if (!error)
291 gfs2_inode_min_init(ip, DT_DIR);
292 sdp->sd_root_dir = gfs2_ip2v(ip);
293 gfs2_inode_put(ip);
294 }
295 gfs2_glock_put(gl);
296 }
297
298 return error;
299}
300
278static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) 301static int init_sb(struct gfs2_sbd *sdp, int silent, int undo)
279{ 302{
280 struct super_block *sb = sdp->sd_vfs; 303 struct super_block *sb = sdp->sd_vfs;
281 struct gfs2_holder sb_gh; 304 struct gfs2_holder sb_gh;
305 struct inode *inode;
282 int error = 0; 306 int error = 0;
283 307
284 if (undo) { 308 if (undo) {
285 gfs2_inode_put(sdp->sd_master_dir); 309 iput(sdp->sd_master_dir);
286 return 0; 310 return 0;
287 } 311 }
288 312
@@ -321,14 +345,35 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo)
321 345
322 sb_set_blocksize(sb, sdp->sd_sb.sb_bsize); 346 sb_set_blocksize(sb, sdp->sd_sb.sb_bsize);
323 347
324 error = gfs2_lookup_master_dir(sdp); 348 /* Get the root inode */
325 if (error) 349 error = gfs2_lookup_root(sdp);
326 fs_err(sdp, "can't read in master directory: %d\n", error); 350 if (error) {
351 fs_err(sdp, "can't read in root inode: %d\n", error);
352 goto out;
353 }
327 354
328 out: 355 /* Get the root inode/dentry */
356 inode = sdp->sd_root_dir;
357 if (!inode) {
358 fs_err(sdp, "can't get root inode\n");
359 error = -ENOMEM;
360 goto out_rooti;
361 }
362
363 sb->s_root = d_alloc_root(inode);
364 if (!sb->s_root) {
365 fs_err(sdp, "can't get root dentry\n");
366 error = -ENOMEM;
367 goto out_rooti;
368 }
369
370out:
329 gfs2_glock_dq_uninit(&sb_gh); 371 gfs2_glock_dq_uninit(&sb_gh);
330 372
331 return error; 373 return error;
374out_rooti:
375 iput(sdp->sd_root_dir);
376 goto out;
332} 377}
333 378
334static int init_journal(struct gfs2_sbd *sdp, int undo) 379static int init_journal(struct gfs2_sbd *sdp, int undo)
@@ -349,7 +394,7 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
349 fs_err(sdp, "can't lookup journal index: %d\n", error); 394 fs_err(sdp, "can't lookup journal index: %d\n", error);
350 return error; 395 return error;
351 } 396 }
352 set_bit(GLF_STICKY, &sdp->sd_jindex->i_gl->gl_flags); 397 set_bit(GLF_STICKY, &get_v2ip(sdp->sd_jindex)->i_gl->gl_flags);
353 398
354 /* Load in the journal index special file */ 399 /* Load in the journal index special file */
355 400
@@ -465,53 +510,44 @@ static int init_journal(struct gfs2_sbd *sdp, int undo)
465 gfs2_glock_dq_uninit(&ji_gh); 510 gfs2_glock_dq_uninit(&ji_gh);
466 511
467 fail: 512 fail:
468 gfs2_inode_put(sdp->sd_jindex); 513 iput(sdp->sd_jindex);
469 514
470 return error; 515 return error;
471} 516}
472 517
473int gfs2_lookup_root(struct gfs2_sbd *sdp)
474{
475 int error;
476 struct gfs2_glock *gl;
477
478 error = gfs2_glock_get(sdp, sdp->sd_sb.sb_root_dir.no_addr,
479 &gfs2_inode_glops, CREATE, &gl);
480 if (!error) {
481 error = gfs2_inode_get(gl, &sdp->sd_sb.sb_root_dir,
482 CREATE, &sdp->sd_root_dir);
483 if (!error)
484 gfs2_inode_min_init(sdp->sd_root_dir, DT_DIR);
485 gfs2_glock_put(gl);
486 }
487
488 return error;
489}
490
491 518
492static int init_inodes(struct gfs2_sbd *sdp, int undo) 519static int init_inodes(struct gfs2_sbd *sdp, int undo)
493{ 520{
494 struct inode *inode;
495 struct dentry **dentry = &sdp->sd_vfs->s_root;
496 int error = 0; 521 int error = 0;
497 522
498 if (undo) 523 if (undo)
499 goto fail_dput; 524 goto fail_qinode;
525
526 error = gfs2_lookup_master_dir(sdp);
527 if (error) {
528 fs_err(sdp, "can't read in master directory: %d\n", error);
529 goto fail;
530 }
531
532 error = init_journal(sdp, undo);
533 if (error)
534 goto fail_master;
500 535
501 /* Read in the master inode number inode */ 536 /* Read in the master inode number inode */
502 error = gfs2_lookup_simple(sdp->sd_master_dir, "inum", 537 error = gfs2_lookup_simple(sdp->sd_master_dir, "inum",
503 &sdp->sd_inum_inode); 538 &sdp->sd_inum_inode);
504 if (error) { 539 if (error) {
505 fs_err(sdp, "can't read in inum inode: %d\n", error); 540 fs_err(sdp, "can't read in inum inode: %d\n", error);
506 return error; 541 goto fail_journal;
507 } 542 }
508 543
544
509 /* Read in the master statfs inode */ 545 /* Read in the master statfs inode */
510 error = gfs2_lookup_simple(sdp->sd_master_dir, "statfs", 546 error = gfs2_lookup_simple(sdp->sd_master_dir, "statfs",
511 &sdp->sd_statfs_inode); 547 &sdp->sd_statfs_inode);
512 if (error) { 548 if (error) {
513 fs_err(sdp, "can't read in statfs inode: %d\n", error); 549 fs_err(sdp, "can't read in statfs inode: %d\n", error);
514 goto fail; 550 goto fail_inum;
515 } 551 }
516 552
517 /* Read in the resource index inode */ 553 /* Read in the resource index inode */
@@ -521,8 +557,8 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo)
521 fs_err(sdp, "can't get resource index inode: %d\n", error); 557 fs_err(sdp, "can't get resource index inode: %d\n", error);
522 goto fail_statfs; 558 goto fail_statfs;
523 } 559 }
524 set_bit(GLF_STICKY, &sdp->sd_rindex->i_gl->gl_flags); 560 set_bit(GLF_STICKY, &get_v2ip(sdp->sd_rindex)->i_gl->gl_flags);
525 sdp->sd_rindex_vn = sdp->sd_rindex->i_gl->gl_vn - 1; 561 sdp->sd_rindex_vn = get_v2ip(sdp->sd_rindex)->i_gl->gl_vn - 1;
526 562
527 /* Read in the quota inode */ 563 /* Read in the quota inode */
528 error = gfs2_lookup_simple(sdp->sd_master_dir, "quota", 564 error = gfs2_lookup_simple(sdp->sd_master_dir, "quota",
@@ -531,58 +567,31 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo)
531 fs_err(sdp, "can't get quota file inode: %d\n", error); 567 fs_err(sdp, "can't get quota file inode: %d\n", error);
532 goto fail_rindex; 568 goto fail_rindex;
533 } 569 }
534
535 /* Get the root inode */
536 error = gfs2_lookup_root(sdp);
537 if (error) {
538 fs_err(sdp, "can't read in root inode: %d\n", error);
539 goto fail_qinode;
540 }
541
542 /* Get the root inode/dentry */
543 inode = gfs2_ip2v(sdp->sd_root_dir);
544 if (!inode) {
545 fs_err(sdp, "can't get root inode\n");
546 error = -ENOMEM;
547 goto fail_rooti;
548 }
549
550 *dentry = d_alloc_root(inode);
551 if (!*dentry) {
552 iput(inode);
553 fs_err(sdp, "can't get root dentry\n");
554 error = -ENOMEM;
555 goto fail_rooti;
556 }
557
558 return 0; 570 return 0;
559 571
560 fail_dput: 572fail_qinode:
561 dput(*dentry); 573 iput(sdp->sd_quota_inode);
562 *dentry = NULL;
563 574
564 fail_rooti: 575fail_rindex:
565 gfs2_inode_put(sdp->sd_root_dir);
566
567 fail_qinode:
568 gfs2_inode_put(sdp->sd_quota_inode);
569
570 fail_rindex:
571 gfs2_clear_rgrpd(sdp); 576 gfs2_clear_rgrpd(sdp);
572 gfs2_inode_put(sdp->sd_rindex); 577 iput(sdp->sd_rindex);
573
574 fail_statfs:
575 gfs2_inode_put(sdp->sd_statfs_inode);
576 578
577 fail: 579fail_statfs:
578 gfs2_inode_put(sdp->sd_inum_inode); 580 iput(sdp->sd_statfs_inode);
579 581
582fail_inum:
583 iput(sdp->sd_inum_inode);
584fail_journal:
585 init_journal(sdp, UNDO);
586fail_master:
587 iput(sdp->sd_master_dir);
588fail:
580 return error; 589 return error;
581} 590}
582 591
583static int init_per_node(struct gfs2_sbd *sdp, int undo) 592static int init_per_node(struct gfs2_sbd *sdp, int undo)
584{ 593{
585 struct gfs2_inode *pn = NULL; 594 struct inode *pn = NULL;
586 char buf[30]; 595 char buf[30];
587 int error = 0; 596 int error = 0;
588 597
@@ -626,10 +635,10 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo)
626 goto fail_ut_i; 635 goto fail_ut_i;
627 } 636 }
628 637
629 gfs2_inode_put(pn); 638 iput(pn);
630 pn = NULL; 639 pn = NULL;
631 640
632 error = gfs2_glock_nq_init(sdp->sd_ir_inode->i_gl, 641 error = gfs2_glock_nq_init(get_v2ip(sdp->sd_ir_inode)->i_gl,
633 LM_ST_EXCLUSIVE, GL_NEVER_RECURSE, 642 LM_ST_EXCLUSIVE, GL_NEVER_RECURSE,
634 &sdp->sd_ir_gh); 643 &sdp->sd_ir_gh);
635 if (error) { 644 if (error) {
@@ -637,7 +646,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo)
637 goto fail_qc_i; 646 goto fail_qc_i;
638 } 647 }
639 648
640 error = gfs2_glock_nq_init(sdp->sd_sc_inode->i_gl, 649 error = gfs2_glock_nq_init(get_v2ip(sdp->sd_sc_inode)->i_gl,
641 LM_ST_EXCLUSIVE, GL_NEVER_RECURSE, 650 LM_ST_EXCLUSIVE, GL_NEVER_RECURSE,
642 &sdp->sd_sc_gh); 651 &sdp->sd_sc_gh);
643 if (error) { 652 if (error) {
@@ -645,7 +654,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo)
645 goto fail_ir_gh; 654 goto fail_ir_gh;
646 } 655 }
647 656
648 error = gfs2_glock_nq_init(sdp->sd_ut_inode->i_gl, 657 error = gfs2_glock_nq_init(get_v2ip(sdp->sd_ut_inode)->i_gl,
649 LM_ST_EXCLUSIVE, GL_NEVER_RECURSE, 658 LM_ST_EXCLUSIVE, GL_NEVER_RECURSE,
650 &sdp->sd_ut_gh); 659 &sdp->sd_ut_gh);
651 if (error) { 660 if (error) {
@@ -653,7 +662,7 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo)
653 goto fail_sc_gh; 662 goto fail_sc_gh;
654 } 663 }
655 664
656 error = gfs2_glock_nq_init(sdp->sd_qc_inode->i_gl, 665 error = gfs2_glock_nq_init(get_v2ip(sdp->sd_qc_inode)->i_gl,
657 LM_ST_EXCLUSIVE, GL_NEVER_RECURSE, 666 LM_ST_EXCLUSIVE, GL_NEVER_RECURSE,
658 &sdp->sd_qc_gh); 667 &sdp->sd_qc_gh);
659 if (error) { 668 if (error) {
@@ -676,20 +685,20 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo)
676 gfs2_glock_dq_uninit(&sdp->sd_ir_gh); 685 gfs2_glock_dq_uninit(&sdp->sd_ir_gh);
677 686
678 fail_qc_i: 687 fail_qc_i:
679 gfs2_inode_put(sdp->sd_qc_inode); 688 iput(sdp->sd_qc_inode);
680 689
681 fail_ut_i: 690 fail_ut_i:
682 gfs2_inode_put(sdp->sd_ut_inode); 691 iput(sdp->sd_ut_inode);
683 692
684 fail_sc_i: 693 fail_sc_i:
685 gfs2_inode_put(sdp->sd_sc_inode); 694 iput(sdp->sd_sc_inode);
686 695
687 fail_ir_i: 696 fail_ir_i:
688 gfs2_inode_put(sdp->sd_ir_inode); 697 iput(sdp->sd_ir_inode);
689 698
690 fail: 699 fail:
691 if (pn) 700 if (pn)
692 gfs2_inode_put(pn); 701 iput(pn);
693 return error; 702 return error;
694} 703}
695 704
@@ -793,14 +802,10 @@ static int fill_super(struct super_block *sb, void *data, int silent)
793 error = init_sb(sdp, silent, DO); 802 error = init_sb(sdp, silent, DO);
794 if (error) 803 if (error)
795 goto fail_locking; 804 goto fail_locking;
796
797 error = init_journal(sdp, DO);
798 if (error)
799 goto fail_sb;
800 805
801 error = init_inodes(sdp, DO); 806 error = init_inodes(sdp, DO);
802 if (error) 807 if (error)
803 goto fail_journals; 808 goto fail_sb;
804 809
805 error = init_per_node(sdp, DO); 810 error = init_per_node(sdp, DO);
806 if (error) 811 if (error)
@@ -837,9 +842,6 @@ static int fill_super(struct super_block *sb, void *data, int silent)
837 fail_inodes: 842 fail_inodes:
838 init_inodes(sdp, UNDO); 843 init_inodes(sdp, UNDO);
839 844
840 fail_journals:
841 init_journal(sdp, UNDO);
842
843 fail_sb: 845 fail_sb:
844 init_sb(sdp, 0, UNDO); 846 init_sb(sdp, 0, UNDO);
845 847
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c
index ca6a4d81bc26..e06ef8dbd4d3 100644
--- a/fs/gfs2/ops_super.c
+++ b/fs/gfs2/ops_super.c
@@ -97,13 +97,13 @@ static void gfs2_put_super(struct super_block *sb)
97 97
98 /* Release stuff */ 98 /* Release stuff */
99 99
100 gfs2_inode_put(sdp->sd_master_dir); 100 iput(sdp->sd_master_dir);
101 gfs2_inode_put(sdp->sd_jindex); 101 iput(sdp->sd_jindex);
102 gfs2_inode_put(sdp->sd_inum_inode); 102 iput(sdp->sd_inum_inode);
103 gfs2_inode_put(sdp->sd_statfs_inode); 103 iput(sdp->sd_statfs_inode);
104 gfs2_inode_put(sdp->sd_rindex); 104 iput(sdp->sd_rindex);
105 gfs2_inode_put(sdp->sd_quota_inode); 105 iput(sdp->sd_quota_inode);
106 gfs2_inode_put(sdp->sd_root_dir); 106 iput(sdp->sd_root_dir);
107 107
108 gfs2_glock_put(sdp->sd_rename_gl); 108 gfs2_glock_put(sdp->sd_rename_gl);
109 gfs2_glock_put(sdp->sd_trans_gl); 109 gfs2_glock_put(sdp->sd_trans_gl);
@@ -115,10 +115,10 @@ static void gfs2_put_super(struct super_block *sb)
115 gfs2_glock_dq_uninit(&sdp->sd_sc_gh); 115 gfs2_glock_dq_uninit(&sdp->sd_sc_gh);
116 gfs2_glock_dq_uninit(&sdp->sd_ut_gh); 116 gfs2_glock_dq_uninit(&sdp->sd_ut_gh);
117 gfs2_glock_dq_uninit(&sdp->sd_qc_gh); 117 gfs2_glock_dq_uninit(&sdp->sd_qc_gh);
118 gfs2_inode_put(sdp->sd_ir_inode); 118 iput(sdp->sd_ir_inode);
119 gfs2_inode_put(sdp->sd_sc_inode); 119 iput(sdp->sd_sc_inode);
120 gfs2_inode_put(sdp->sd_ut_inode); 120 iput(sdp->sd_ut_inode);
121 gfs2_inode_put(sdp->sd_qc_inode); 121 iput(sdp->sd_qc_inode);
122 } 122 }
123 123
124 gfs2_glock_dq_uninit(&sdp->sd_live_gh); 124 gfs2_glock_dq_uninit(&sdp->sd_live_gh);
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index 5fb5a5305e0e..69e8f4e92e57 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -56,6 +56,7 @@
56#include "rgrp.h" 56#include "rgrp.h"
57#include "super.h" 57#include "super.h"
58#include "trans.h" 58#include "trans.h"
59#include "ops_file.h"
59 60
60#define QUOTA_USER 1 61#define QUOTA_USER 1
61#define QUOTA_GROUP 0 62#define QUOTA_GROUP 0
@@ -241,7 +242,7 @@ static void slot_put(struct gfs2_quota_data *qd)
241static int bh_get(struct gfs2_quota_data *qd) 242static int bh_get(struct gfs2_quota_data *qd)
242{ 243{
243 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; 244 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd;
244 struct gfs2_inode *ip = sdp->sd_qc_inode; 245 struct gfs2_inode *ip = get_v2ip(sdp->sd_qc_inode);
245 unsigned int block, offset; 246 unsigned int block, offset;
246 uint64_t dblock; 247 uint64_t dblock;
247 int new = 0; 248 int new = 0;
@@ -522,7 +523,7 @@ static int sort_qd(const void *a, const void *b)
522static void do_qc(struct gfs2_quota_data *qd, int64_t change) 523static void do_qc(struct gfs2_quota_data *qd, int64_t change)
523{ 524{
524 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; 525 struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd;
525 struct gfs2_inode *ip = sdp->sd_qc_inode; 526 struct gfs2_inode *ip = get_v2ip(sdp->sd_qc_inode);
526 struct gfs2_quota_change *qc = qd->qd_bh_qc; 527 struct gfs2_quota_change *qc = qd->qd_bh_qc;
527 int64_t x; 528 int64_t x;
528 529
@@ -563,12 +564,13 @@ static void do_qc(struct gfs2_quota_data *qd, int64_t change)
563static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) 564static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda)
564{ 565{
565 struct gfs2_sbd *sdp = (*qda)->qd_gl->gl_sbd; 566 struct gfs2_sbd *sdp = (*qda)->qd_gl->gl_sbd;
566 struct gfs2_inode *ip = sdp->sd_quota_inode; 567 struct gfs2_inode *ip = get_v2ip(sdp->sd_quota_inode);
567 unsigned int data_blocks, ind_blocks; 568 unsigned int data_blocks, ind_blocks;
569 struct file_ra_state ra_state;
568 struct gfs2_holder *ghs, i_gh; 570 struct gfs2_holder *ghs, i_gh;
569 unsigned int qx, x; 571 unsigned int qx, x;
570 struct gfs2_quota_data *qd; 572 struct gfs2_quota_data *qd;
571 uint64_t offset; 573 loff_t offset;
572 unsigned int nalloc = 0; 574 unsigned int nalloc = 0;
573 struct gfs2_alloc *al = NULL; 575 struct gfs2_alloc *al = NULL;
574 int error; 576 int error;
@@ -631,6 +633,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda)
631 goto out_gunlock; 633 goto out_gunlock;
632 } 634 }
633 635
636 file_ra_state_init(&ra_state, ip->i_vnode->i_mapping);
634 for (x = 0; x < num_qd; x++) { 637 for (x = 0; x < num_qd; x++) {
635 char buf[sizeof(struct gfs2_quota)]; 638 char buf[sizeof(struct gfs2_quota)];
636 struct gfs2_quota q; 639 struct gfs2_quota q;
@@ -642,7 +645,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda)
642 sizeof(struct gfs2_quota) bytes. */ 645 sizeof(struct gfs2_quota) bytes. */
643 memset(buf, 0, sizeof(struct gfs2_quota)); 646 memset(buf, 0, sizeof(struct gfs2_quota));
644 647
645 error = gfs2_jdata_read_mem(ip, buf, offset, 648 error = gfs2_internal_read(ip, &ra_state, buf, &offset,
646 sizeof(struct gfs2_quota)); 649 sizeof(struct gfs2_quota));
647 if (error < 0) 650 if (error < 0)
648 goto out_end_trans; 651 goto out_end_trans;
@@ -703,8 +706,10 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh,
703 struct gfs2_holder i_gh; 706 struct gfs2_holder i_gh;
704 struct gfs2_quota q; 707 struct gfs2_quota q;
705 char buf[sizeof(struct gfs2_quota)]; 708 char buf[sizeof(struct gfs2_quota)];
709 struct file_ra_state ra_state;
706 int error; 710 int error;
707 711
712 file_ra_state_init(&ra_state, sdp->sd_quota_inode->i_mapping);
708 restart: 713 restart:
709 error = gfs2_glock_nq_init(qd->qd_gl, LM_ST_SHARED, 0, q_gh); 714 error = gfs2_glock_nq_init(qd->qd_gl, LM_ST_SHARED, 0, q_gh);
710 if (error) 715 if (error)
@@ -713,6 +718,7 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh,
713 gfs2_quota_lvb_in(&qd->qd_qb, qd->qd_gl->gl_lvb); 718 gfs2_quota_lvb_in(&qd->qd_qb, qd->qd_gl->gl_lvb);
714 719
715 if (force_refresh || qd->qd_qb.qb_magic != GFS2_MAGIC) { 720 if (force_refresh || qd->qd_qb.qb_magic != GFS2_MAGIC) {
721 loff_t pos;
716 gfs2_glock_dq_uninit(q_gh); 722 gfs2_glock_dq_uninit(q_gh);
717 error = gfs2_glock_nq_init(qd->qd_gl, 723 error = gfs2_glock_nq_init(qd->qd_gl,
718 LM_ST_EXCLUSIVE, GL_NOCACHE, 724 LM_ST_EXCLUSIVE, GL_NOCACHE,
@@ -720,16 +726,17 @@ static int do_glock(struct gfs2_quota_data *qd, int force_refresh,
720 if (error) 726 if (error)
721 return error; 727 return error;
722 728
723 error = gfs2_glock_nq_init(sdp->sd_quota_inode->i_gl, 729 error = gfs2_glock_nq_init(get_v2ip(sdp->sd_quota_inode)->i_gl,
724 LM_ST_SHARED, 0, 730 LM_ST_SHARED, 0,
725 &i_gh); 731 &i_gh);
726 if (error) 732 if (error)
727 goto fail; 733 goto fail;
728 734
729 memset(buf, 0, sizeof(struct gfs2_quota)); 735 memset(buf, 0, sizeof(struct gfs2_quota));
730 736 pos = qd2offset(qd);
731 error = gfs2_jdata_read_mem(sdp->sd_quota_inode, buf, 737 error = gfs2_internal_read(get_v2ip(sdp->sd_quota_inode),
732 qd2offset(qd), 738 &ra_state, buf,
739 &pos,
733 sizeof(struct gfs2_quota)); 740 sizeof(struct gfs2_quota));
734 if (error < 0) 741 if (error < 0)
735 goto fail_gunlock; 742 goto fail_gunlock;
@@ -1059,7 +1066,7 @@ int gfs2_quota_read(struct gfs2_sbd *sdp, int user, uint32_t id,
1059 1066
1060int gfs2_quota_init(struct gfs2_sbd *sdp) 1067int gfs2_quota_init(struct gfs2_sbd *sdp)
1061{ 1068{
1062 struct gfs2_inode *ip = sdp->sd_qc_inode; 1069 struct gfs2_inode *ip = get_v2ip(sdp->sd_qc_inode);
1063 unsigned int blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; 1070 unsigned int blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift;
1064 unsigned int x, slot = 0; 1071 unsigned int x, slot = 0;
1065 unsigned int found = 0; 1072 unsigned int found = 0;
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c
index 87c80bbce1cf..758cc565813a 100644
--- a/fs/gfs2/rgrp.c
+++ b/fs/gfs2/rgrp.c
@@ -12,19 +12,20 @@
12#include <linux/spinlock.h> 12#include <linux/spinlock.h>
13#include <linux/completion.h> 13#include <linux/completion.h>
14#include <linux/buffer_head.h> 14#include <linux/buffer_head.h>
15#include <linux/fs.h>
15#include <asm/semaphore.h> 16#include <asm/semaphore.h>
16 17
17#include "gfs2.h" 18#include "gfs2.h"
18#include "bits.h" 19#include "bits.h"
19#include "glock.h" 20#include "glock.h"
20#include "glops.h" 21#include "glops.h"
21#include "jdata.h"
22#include "lops.h" 22#include "lops.h"
23#include "meta_io.h" 23#include "meta_io.h"
24#include "quota.h" 24#include "quota.h"
25#include "rgrp.h" 25#include "rgrp.h"
26#include "super.h" 26#include "super.h"
27#include "trans.h" 27#include "trans.h"
28#include "ops_file.h"
28 29
29/** 30/**
30 * gfs2_rgrp_verify - Verify that a resource group is consistent 31 * gfs2_rgrp_verify - Verify that a resource group is consistent
@@ -268,8 +269,10 @@ static int compute_bitstructs(struct gfs2_rgrpd *rgd)
268static int gfs2_ri_update(struct gfs2_inode *ip) 269static int gfs2_ri_update(struct gfs2_inode *ip)
269{ 270{
270 struct gfs2_sbd *sdp = ip->i_sbd; 271 struct gfs2_sbd *sdp = ip->i_sbd;
272 struct inode *inode = ip->i_vnode;
271 struct gfs2_rgrpd *rgd; 273 struct gfs2_rgrpd *rgd;
272 char buf[sizeof(struct gfs2_rindex)]; 274 char buf[sizeof(struct gfs2_rindex)];
275 struct file_ra_state ra_state;
273 uint64_t junk = ip->i_di.di_size; 276 uint64_t junk = ip->i_di.di_size;
274 int error; 277 int error;
275 278
@@ -280,10 +283,10 @@ static int gfs2_ri_update(struct gfs2_inode *ip)
280 283
281 clear_rgrpdi(sdp); 284 clear_rgrpdi(sdp);
282 285
286 file_ra_state_init(&ra_state, inode->i_mapping);
283 for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) { 287 for (sdp->sd_rgrps = 0;; sdp->sd_rgrps++) {
284 error = gfs2_jdata_read_mem(ip, buf, 288 loff_t pos = sdp->sd_rgrps * sizeof(struct gfs2_rindex);
285 sdp->sd_rgrps * 289 error = gfs2_internal_read(ip, &ra_state, buf, &pos,
286 sizeof(struct gfs2_rindex),
287 sizeof(struct gfs2_rindex)); 290 sizeof(struct gfs2_rindex));
288 if (!error) 291 if (!error)
289 break; 292 break;
@@ -350,7 +353,7 @@ static int gfs2_ri_update(struct gfs2_inode *ip)
350 353
351int gfs2_rindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ri_gh) 354int gfs2_rindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ri_gh)
352{ 355{
353 struct gfs2_inode *ip = sdp->sd_rindex; 356 struct gfs2_inode *ip = get_v2ip(sdp->sd_rindex);
354 struct gfs2_glock *gl = ip->i_gl; 357 struct gfs2_glock *gl = ip->i_gl;
355 int error; 358 int error;
356 359
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index cab7ab5fb506..bae32ba0c481 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -271,7 +271,7 @@ int gfs2_do_upgrade(struct gfs2_sbd *sdp, struct gfs2_glock *sb_gl)
271 271
272int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh) 272int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
273{ 273{
274 struct gfs2_inode *dip = sdp->sd_jindex; 274 struct gfs2_inode *dip = get_v2ip(sdp->sd_jindex);
275 struct qstr name; 275 struct qstr name;
276 char buf[20]; 276 char buf[20];
277 struct gfs2_jdesc *jd; 277 struct gfs2_jdesc *jd;
@@ -289,7 +289,7 @@ int gfs2_jindex_hold(struct gfs2_sbd *sdp, struct gfs2_holder *ji_gh)
289 289
290 name.len = sprintf(buf, "journal%u", sdp->sd_journals); 290 name.len = sprintf(buf, "journal%u", sdp->sd_journals);
291 291
292 error = gfs2_dir_search(sdp->sd_jindex, &name, NULL, NULL); 292 error = gfs2_dir_search(get_v2ip(sdp->sd_jindex), &name, NULL, NULL);
293 if (error == -ENOENT) { 293 if (error == -ENOENT) {
294 error = 0; 294 error = 0;
295 break; 295 break;
@@ -437,6 +437,7 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd)
437 437
438int gfs2_lookup_master_dir(struct gfs2_sbd *sdp) 438int gfs2_lookup_master_dir(struct gfs2_sbd *sdp)
439{ 439{
440 struct inode *inode = NULL;
440 struct gfs2_glock *gl; 441 struct gfs2_glock *gl;
441 int error; 442 int error;
442 443
@@ -444,8 +445,8 @@ int gfs2_lookup_master_dir(struct gfs2_sbd *sdp)
444 sdp->sd_sb.sb_master_dir.no_addr, 445 sdp->sd_sb.sb_master_dir.no_addr,
445 &gfs2_inode_glops, CREATE, &gl); 446 &gfs2_inode_glops, CREATE, &gl);
446 if (!error) { 447 if (!error) {
447 error = gfs2_inode_get(gl, &sdp->sd_sb.sb_master_dir, CREATE, 448 error = gfs2_lookup_simple(sdp->sd_root_dir, ".gfs2_admin", &inode);
448 &sdp->sd_master_dir); 449 sdp->sd_master_dir = inode;
449 gfs2_glock_put(gl); 450 gfs2_glock_put(gl);
450 } 451 }
451 452
@@ -549,9 +550,9 @@ int gfs2_make_fs_ro(struct gfs2_sbd *sdp)
549 550
550int gfs2_statfs_init(struct gfs2_sbd *sdp) 551int gfs2_statfs_init(struct gfs2_sbd *sdp)
551{ 552{
552 struct gfs2_inode *m_ip = sdp->sd_statfs_inode; 553 struct gfs2_inode *m_ip = get_v2ip(sdp->sd_statfs_inode);
553 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master; 554 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
554 struct gfs2_inode *l_ip = sdp->sd_sc_inode; 555 struct gfs2_inode *l_ip = get_v2ip(sdp->sd_sc_inode);
555 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; 556 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
556 struct buffer_head *m_bh, *l_bh; 557 struct buffer_head *m_bh, *l_bh;
557 struct gfs2_holder gh; 558 struct gfs2_holder gh;
@@ -598,7 +599,7 @@ int gfs2_statfs_init(struct gfs2_sbd *sdp)
598void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free, 599void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free,
599 int64_t dinodes) 600 int64_t dinodes)
600{ 601{
601 struct gfs2_inode *l_ip = sdp->sd_sc_inode; 602 struct gfs2_inode *l_ip = get_v2ip(sdp->sd_sc_inode);
602 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; 603 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
603 struct buffer_head *l_bh; 604 struct buffer_head *l_bh;
604 int error; 605 int error;
@@ -624,8 +625,8 @@ void gfs2_statfs_change(struct gfs2_sbd *sdp, int64_t total, int64_t free,
624 625
625int gfs2_statfs_sync(struct gfs2_sbd *sdp) 626int gfs2_statfs_sync(struct gfs2_sbd *sdp)
626{ 627{
627 struct gfs2_inode *m_ip = sdp->sd_statfs_inode; 628 struct gfs2_inode *m_ip = get_v2ip(sdp->sd_statfs_inode);
628 struct gfs2_inode *l_ip = sdp->sd_sc_inode; 629 struct gfs2_inode *l_ip = get_v2ip(sdp->sd_sc_inode);
629 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master; 630 struct gfs2_statfs_change *m_sc = &sdp->sd_statfs_master;
630 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local; 631 struct gfs2_statfs_change *l_sc = &sdp->sd_statfs_local;
631 struct gfs2_holder gh; 632 struct gfs2_holder gh;
diff --git a/fs/gfs2/unlinked.c b/fs/gfs2/unlinked.c
index b8d836e3a5c0..405b91b0295d 100644
--- a/fs/gfs2/unlinked.c
+++ b/fs/gfs2/unlinked.c
@@ -25,7 +25,7 @@
25static int munge_ondisk(struct gfs2_sbd *sdp, unsigned int slot, 25static int munge_ondisk(struct gfs2_sbd *sdp, unsigned int slot,
26 struct gfs2_unlinked_tag *ut) 26 struct gfs2_unlinked_tag *ut)
27{ 27{
28 struct gfs2_inode *ip = sdp->sd_ut_inode; 28 struct gfs2_inode *ip = get_v2ip(sdp->sd_ut_inode);
29 unsigned int block, offset; 29 unsigned int block, offset;
30 uint64_t dblock; 30 uint64_t dblock;
31 int new = 0; 31 int new = 0;
@@ -312,7 +312,7 @@ int gfs2_unlinked_dealloc(struct gfs2_sbd *sdp)
312 312
313int gfs2_unlinked_init(struct gfs2_sbd *sdp) 313int gfs2_unlinked_init(struct gfs2_sbd *sdp)
314{ 314{
315 struct gfs2_inode *ip = sdp->sd_ut_inode; 315 struct gfs2_inode *ip = get_v2ip(sdp->sd_ut_inode);
316 unsigned int blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift; 316 unsigned int blocks = ip->i_di.di_size >> sdp->sd_sb.sb_bsize_shift;
317 unsigned int x, slot = 0; 317 unsigned int x, slot = 0;
318 unsigned int found = 0; 318 unsigned int found = 0;