aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/incore.h1
-rw-r--r--fs/gfs2/inode.c13
-rw-r--r--fs/gfs2/inode.h2
-rw-r--r--fs/gfs2/ops_export.c4
-rw-r--r--fs/gfs2/ops_fstype.c40
-rw-r--r--fs/gfs2/ops_super.c1
-rw-r--r--fs/gfs2/super.c19
-rw-r--r--fs/gfs2/super.h1
8 files changed, 27 insertions, 54 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index c741016d07dc..62f109e553c4 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -532,7 +532,6 @@ struct gfs2_sbd {
532 struct inode *sd_qc_inode; 532 struct inode *sd_qc_inode;
533 struct inode *sd_rindex; 533 struct inode *sd_rindex;
534 struct inode *sd_quota_inode; 534 struct inode *sd_quota_inode;
535 struct inode *sd_root_dir;
536 535
537 /* Inum stuff */ 536 /* Inum stuff */
538 537
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index ea9e996f3673..cd1de61bff2f 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -288,7 +288,7 @@ int gfs2_inode_refresh(struct gfs2_inode *ip)
288 * Returns: errno 288 * Returns: errno
289 */ 289 */
290 290
291static int inode_create(struct gfs2_glock *i_gl, struct gfs2_inum *inum, 291static int inode_create(struct gfs2_glock *i_gl, const struct gfs2_inum *inum,
292 struct gfs2_glock *io_gl, unsigned int io_state, 292 struct gfs2_glock *io_gl, unsigned int io_state,
293 struct gfs2_inode **ipp) 293 struct gfs2_inode **ipp)
294{ 294{
@@ -354,8 +354,8 @@ static int inode_create(struct gfs2_glock *i_gl, struct gfs2_inum *inum,
354 * Returns: errno 354 * Returns: errno
355 */ 355 */
356 356
357int gfs2_inode_get(struct gfs2_glock *i_gl, struct gfs2_inum *inum, int create, 357int gfs2_inode_get(struct gfs2_glock *i_gl, const struct gfs2_inum *inum,
358 struct gfs2_inode **ipp) 358 int create, struct gfs2_inode **ipp)
359{ 359{
360 struct gfs2_sbd *sdp = i_gl->gl_sbd; 360 struct gfs2_sbd *sdp = i_gl->gl_sbd;
361 struct gfs2_glock *io_gl; 361 struct gfs2_glock *io_gl;
@@ -718,6 +718,7 @@ int gfs2_change_nlink(struct gfs2_inode *ip, int diff)
718int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root, 718int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root,
719 struct inode **inodep) 719 struct inode **inodep)
720{ 720{
721 struct super_block *sb = dir->i_sb;
721 struct gfs2_inode *ipp; 722 struct gfs2_inode *ipp;
722 struct gfs2_inode *dip = dir->u.generic_ip; 723 struct gfs2_inode *dip = dir->u.generic_ip;
723 struct gfs2_sbd *sdp = dip->i_sbd; 724 struct gfs2_sbd *sdp = dip->i_sbd;
@@ -733,7 +734,7 @@ int gfs2_lookupi(struct inode *dir, struct qstr *name, int is_root,
733 return -ENAMETOOLONG; 734 return -ENAMETOOLONG;
734 735
735 if (gfs2_filecmp(name, ".", 1) || 736 if (gfs2_filecmp(name, ".", 1) ||
736 (gfs2_filecmp(name, "..", 2) && dir == sdp->sd_root_dir)) { 737 (gfs2_filecmp(name, "..", 2) && dir == sb->s_root->d_inode)) {
737 gfs2_inode_hold(dip); 738 gfs2_inode_hold(dip);
738 ipp = dip; 739 ipp = dip;
739 goto done; 740 goto done;
@@ -1466,8 +1467,8 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, struct qstr *name,
1466 1467
1467int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to) 1468int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
1468{ 1469{
1469 struct gfs2_sbd *sdp = this->i_sbd;
1470 struct inode *dir = to->i_vnode; 1470 struct inode *dir = to->i_vnode;
1471 struct super_block *sb = dir->i_sb;
1471 struct inode *tmp; 1472 struct inode *tmp;
1472 struct qstr dotdot; 1473 struct qstr dotdot;
1473 int error = 0; 1474 int error = 0;
@@ -1483,7 +1484,7 @@ int gfs2_ok_to_move(struct gfs2_inode *this, struct gfs2_inode *to)
1483 error = -EINVAL; 1484 error = -EINVAL;
1484 break; 1485 break;
1485 } 1486 }
1486 if (dir == sdp->sd_root_dir) { 1487 if (dir == sb->s_root->d_inode) {
1487 error = 0; 1488 error = 0;
1488 break; 1489 break;
1489 } 1490 }
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index 069f0e21db6d..c3fa6cfce169 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -35,7 +35,7 @@ void gfs2_inode_min_init(struct gfs2_inode *ip, unsigned int type);
35int gfs2_inode_refresh(struct gfs2_inode *ip); 35int gfs2_inode_refresh(struct gfs2_inode *ip);
36 36
37int gfs2_inode_get(struct gfs2_glock *i_gl, 37int gfs2_inode_get(struct gfs2_glock *i_gl,
38 struct gfs2_inum *inum, int create, 38 const struct gfs2_inum *inum, int create,
39 struct gfs2_inode **ipp); 39 struct gfs2_inode **ipp);
40void gfs2_inode_hold(struct gfs2_inode *ip); 40void gfs2_inode_hold(struct gfs2_inode *ip);
41void gfs2_inode_put(struct gfs2_inode *ip); 41void gfs2_inode_put(struct gfs2_inode *ip);
diff --git a/fs/gfs2/ops_export.c b/fs/gfs2/ops_export.c
index d149584cff30..a346943363c6 100644
--- a/fs/gfs2/ops_export.c
+++ b/fs/gfs2/ops_export.c
@@ -64,8 +64,8 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
64 int connectable) 64 int connectable)
65{ 65{
66 struct inode *inode = dentry->d_inode; 66 struct inode *inode = dentry->d_inode;
67 struct super_block *sb = inode->i_sb;
67 struct gfs2_inode *ip = inode->u.generic_ip; 68 struct gfs2_inode *ip = inode->u.generic_ip;
68 struct gfs2_sbd *sdp = ip->i_sbd;
69 69
70 if (*len < 4 || (connectable && *len < 8)) 70 if (*len < 4 || (connectable && *len < 8))
71 return 255; 71 return 255;
@@ -80,7 +80,7 @@ static int gfs2_encode_fh(struct dentry *dentry, __u32 *fh, int *len,
80 fh[3] = cpu_to_be32(fh[3]); 80 fh[3] = cpu_to_be32(fh[3]);
81 *len = 4; 81 *len = 4;
82 82
83 if (!connectable || ip == sdp->sd_root_dir->u.generic_ip) 83 if (!connectable || inode == sb->s_root->d_inode)
84 return *len; 84 return *len;
85 85
86 spin_lock(&dentry->d_lock); 86 spin_lock(&dentry->d_lock);
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 4c4115f9d960..c3b830bd838b 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -280,27 +280,30 @@ static int init_locking(struct gfs2_sbd *sdp, struct gfs2_holder *mount_gh,
280 return error; 280 return error;
281} 281}
282 282
283int gfs2_lookup_root(struct gfs2_sbd *sdp) 283static struct inode *gfs2_lookup_root(struct gfs2_sbd *sdp,
284 const struct gfs2_inum *inum)
284{ 285{
285 int error; 286 int error;
286 struct gfs2_glock *gl; 287 struct gfs2_glock *gl;
287 struct gfs2_inode *ip; 288 struct gfs2_inode *ip;
289 struct inode *inode;
288 290
289 error = gfs2_glock_get(sdp, sdp->sd_sb.sb_root_dir.no_addr, 291 error = gfs2_glock_get(sdp, inum->no_addr,
290 &gfs2_inode_glops, CREATE, &gl); 292 &gfs2_inode_glops, CREATE, &gl);
291 if (!error) { 293 if (!error) {
292 error = gfs2_inode_get(gl, &sdp->sd_sb.sb_root_dir, 294 error = gfs2_inode_get(gl, inum,
293 CREATE, &ip); 295 CREATE, &ip);
294 if (!error) { 296 if (!error) {
295 if (!error) 297 if (!error)
296 gfs2_inode_min_init(ip, DT_DIR); 298 gfs2_inode_min_init(ip, DT_DIR);
297 sdp->sd_root_dir = gfs2_ip2v(ip); 299 inode = gfs2_ip2v(ip);
298 gfs2_inode_put(ip); 300 gfs2_inode_put(ip);
301 return inode;
299 } 302 }
300 gfs2_glock_put(gl); 303 gfs2_glock_put(gl);
301 } 304 }
302 305
303 return error; 306 return ERR_PTR(error);
304} 307}
305 308
306static int init_sb(struct gfs2_sbd *sdp, int silent, int undo) 309static int init_sb(struct gfs2_sbd *sdp, int silent, int undo)
@@ -311,7 +314,6 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo)
311 int error = 0; 314 int error = 0;
312 315
313 if (undo) { 316 if (undo) {
314 iput(sdp->sd_master_dir);
315 return 0; 317 return 0;
316 } 318 }
317 319
@@ -351,35 +353,24 @@ static int init_sb(struct gfs2_sbd *sdp, int silent, int undo)
351 sb_set_blocksize(sb, sdp->sd_sb.sb_bsize); 353 sb_set_blocksize(sb, sdp->sd_sb.sb_bsize);
352 354
353 /* Get the root inode */ 355 /* Get the root inode */
354 error = gfs2_lookup_root(sdp); 356 inode = gfs2_lookup_root(sdp, &sdp->sd_sb.sb_root_dir);
355 if (error) { 357 if (IS_ERR(inode)) {
358 error = PTR_ERR(inode);
356 fs_err(sdp, "can't read in root inode: %d\n", error); 359 fs_err(sdp, "can't read in root inode: %d\n", error);
357 goto out; 360 goto out;
358 } 361 }
359 362
360 /* Get the root inode/dentry */
361 inode = sdp->sd_root_dir;
362 if (!inode) {
363 fs_err(sdp, "can't get root inode\n");
364 error = -ENOMEM;
365 goto out_rooti;
366 }
367
368 igrab(inode);
369 sb->s_root = d_alloc_root(inode); 363 sb->s_root = d_alloc_root(inode);
370 if (!sb->s_root) { 364 if (!sb->s_root) {
371 fs_err(sdp, "can't get root dentry\n"); 365 fs_err(sdp, "can't get root dentry\n");
372 error = -ENOMEM; 366 error = -ENOMEM;
373 goto out_rooti; 367 iput(inode);
374 } 368 }
375 369
376out: 370out:
377 gfs2_glock_dq_uninit(&sb_gh); 371 gfs2_glock_dq_uninit(&sb_gh);
378 372
379 return error; 373 return error;
380out_rooti:
381 iput(sdp->sd_root_dir);
382 goto out;
383} 374}
384 375
385static int init_journal(struct gfs2_sbd *sdp, int undo) 376static int init_journal(struct gfs2_sbd *sdp, int undo)
@@ -529,15 +520,18 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo)
529{ 520{
530 int error = 0; 521 int error = 0;
531 struct gfs2_inode *ip; 522 struct gfs2_inode *ip;
523 struct inode *inode;
532 524
533 if (undo) 525 if (undo)
534 goto fail_qinode; 526 goto fail_qinode;
535 527
536 error = gfs2_lookup_master_dir(sdp); 528 inode = gfs2_lookup_root(sdp, &sdp->sd_sb.sb_master_dir);
537 if (error) { 529 if (IS_ERR(inode)) {
530 error = PTR_ERR(inode);
538 fs_err(sdp, "can't read in master directory: %d\n", error); 531 fs_err(sdp, "can't read in master directory: %d\n", error);
539 goto fail; 532 goto fail;
540 } 533 }
534 sdp->sd_master_dir = inode;
541 535
542 error = init_journal(sdp, undo); 536 error = init_journal(sdp, undo);
543 if (error) 537 if (error)
diff --git a/fs/gfs2/ops_super.c b/fs/gfs2/ops_super.c
index 10f70ee12161..f7349c0989a9 100644
--- a/fs/gfs2/ops_super.c
+++ b/fs/gfs2/ops_super.c
@@ -103,7 +103,6 @@ static void gfs2_put_super(struct super_block *sb)
103 iput(sdp->sd_statfs_inode); 103 iput(sdp->sd_statfs_inode);
104 iput(sdp->sd_rindex); 104 iput(sdp->sd_rindex);
105 iput(sdp->sd_quota_inode); 105 iput(sdp->sd_quota_inode);
106 iput(sdp->sd_root_dir);
107 106
108 gfs2_glock_put(sdp->sd_rename_gl); 107 gfs2_glock_put(sdp->sd_rename_gl);
109 gfs2_glock_put(sdp->sd_trans_gl); 108 gfs2_glock_put(sdp->sd_trans_gl);
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c
index 9ccf0b9c5980..fff5a96f4152 100644
--- a/fs/gfs2/super.c
+++ b/fs/gfs2/super.c
@@ -447,25 +447,6 @@ int gfs2_jdesc_check(struct gfs2_jdesc *jd)
447 return error; 447 return error;
448} 448}
449 449
450int gfs2_lookup_master_dir(struct gfs2_sbd *sdp)
451{
452 struct inode *inode = NULL;
453 struct gfs2_glock *gl;
454 int error;
455
456 error = gfs2_glock_get(sdp,
457 sdp->sd_sb.sb_master_dir.no_addr,
458 &gfs2_inode_glops, CREATE, &gl);
459 if (!error) {
460 error = gfs2_lookup_simple(sdp->sd_root_dir, ".gfs2_admin",
461 &inode);
462 sdp->sd_master_dir = inode;
463 gfs2_glock_put(gl);
464 }
465
466 return error;
467}
468
469/** 450/**
470 * gfs2_make_fs_rw - Turn a Read-Only FS into a Read-Write one 451 * gfs2_make_fs_rw - Turn a Read-Only FS into a Read-Write one
471 * @sdp: the filesystem 452 * @sdp: the filesystem
diff --git a/fs/gfs2/super.h b/fs/gfs2/super.h
index cc1a3df1949a..6abb7b5c8828 100644
--- a/fs/gfs2/super.h
+++ b/fs/gfs2/super.h
@@ -33,7 +33,6 @@ void gfs2_jdesc_make_dirty(struct gfs2_sbd *sdp, unsigned int jid);
33struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp); 33struct gfs2_jdesc *gfs2_jdesc_find_dirty(struct gfs2_sbd *sdp);
34int gfs2_jdesc_check(struct gfs2_jdesc *jd); 34int gfs2_jdesc_check(struct gfs2_jdesc *jd);
35 35
36int gfs2_lookup_master_dir(struct gfs2_sbd *sdp);
37int gfs2_lookup_in_master_dir(struct gfs2_sbd *sdp, char *filename, 36int gfs2_lookup_in_master_dir(struct gfs2_sbd *sdp, char *filename,
38 struct gfs2_inode **ipp); 37 struct gfs2_inode **ipp);
39 38