Commit 5a43291d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Kleikamp

JFS: use buffer_heads to access the superblock

parent e83b40a4
......@@ -42,6 +42,8 @@
*/
#include <linux/fs.h>
#include <linux/buffer_head.h>
#include "jfs_incore.h"
#include "jfs_filsys.h"
#include "jfs_dinode.h"
......@@ -2965,26 +2967,30 @@ printf("diExtendFS: iag:%d agstart:%Ld agno:%d\n", i, agstart, n);
*
* note: shadow page with regular inode (rel.2);
*/
static void
duplicateIXtree(struct super_block *sb, s64 blkno, int xlen, s64 * xaddr)
static void duplicateIXtree(struct super_block *sb, s64 blkno,
int xlen, s64 *xaddr)
{
int rc;
tid_t tid;
struct inode *ip;
metapage_t *mpsuper;
struct jfs_superblock *j_sb;
struct buffer_head *bh;
struct inode *ip;
tid_t tid;
int rc;
/* if AIT2 ipmap2 is bad, do not try to update it */
if (JFS_SBI(sb)->mntflag & JFS_BAD_SAIT) /* s_flag */
return;
ip = diReadSpecial(sb, FILESYSTEM_I, 1);
if (ip == 0) {
if (ip == NULL) {
JFS_SBI(sb)->mntflag |= JFS_BAD_SAIT;
if ((rc = readSuper(sb, &mpsuper)))
if ((rc = readSuper(sb, &bh)))
return;
j_sb = (struct jfs_superblock *) (mpsuper->data);
j_sb = (struct jfs_superblock *)bh->b_data;
j_sb->s_flag |= JFS_BAD_SAIT;
write_metapage(mpsuper);
mark_buffer_dirty(bh);
ll_rw_block(WRITE, 1, &bh);
wait_on_buffer(bh);
brelse(bh);
return;
}
......
......@@ -48,6 +48,8 @@
*/
#include <linux/fs.h>
#include <linux/buffer_head.h>
#include "jfs_incore.h"
#include "jfs_filsys.h"
#include "jfs_superblock.h"
......@@ -314,18 +316,18 @@ int jfs_mount_rw(struct super_block *sb, int remount)
static int chkSuper(struct super_block *sb)
{
int rc = 0;
metapage_t *mp;
struct jfs_sb_info *sbi = JFS_SBI(sb);
struct jfs_superblock *j_sb;
struct buffer_head *bh;
int AIM_bytesize, AIT_bytesize;
int expected_AIM_bytesize, expected_AIT_bytesize;
s64 AIM_byte_addr, AIT_byte_addr, fsckwsp_addr;
s64 byte_addr_diff0, byte_addr_diff1;
s32 bsize;
if ((rc = readSuper(sb, &mp)))
if ((rc = readSuper(sb, &bh)))
return rc;
j_sb = (struct jfs_superblock *) (mp->data);
j_sb = (struct jfs_superblock *)bh->b_data;
/*
* validate superblock
......@@ -414,8 +416,7 @@ static int chkSuper(struct super_block *sb)
sbi->ait2 = j_sb->s_ait2;
out:
release_metapage(mp);
brelse(bh);
return rc;
}
......@@ -429,7 +430,7 @@ int updateSuper(struct super_block *sb, uint state)
{
struct jfs_superblock *j_sb;
struct jfs_sb_info *sbi = JFS_SBI(sb);
metapage_t *mp;
struct buffer_head *bh;
int rc;
/*
......@@ -438,10 +439,10 @@ int updateSuper(struct super_block *sb, uint state)
if (sbi->state == FM_DIRTY)
return 0;
if ((rc = readSuper(sb, &mp)))
if ((rc = readSuper(sb, &bh)))
return rc;
j_sb = (struct jfs_superblock *) (mp->data);
j_sb = (struct jfs_superblock *)bh->b_data;
j_sb->s_state = cpu_to_le32(state);
sbi->state = state;
......@@ -459,7 +460,10 @@ int updateSuper(struct super_block *sb, uint state)
j_sb->s_flag |= cpu_to_le32(JFS_DASD_PRIME);
}
flush_metapage(mp);
mark_buffer_dirty(bh);
ll_rw_block(WRITE, 1, &bh);
wait_on_buffer(bh);
brelse(bh);
return 0;
}
......@@ -470,18 +474,19 @@ int updateSuper(struct super_block *sb, uint state)
*
* read superblock by raw sector address
*/
int readSuper(struct super_block *sb, metapage_t ** mpp)
int readSuper(struct super_block *sb, struct buffer_head **bpp)
{
/* read in primary superblock */
*mpp = read_metapage(JFS_SBI(sb)->direct_inode,
SUPER1_OFF >> sb->s_blocksize_bits, PSIZE, 1);
if (*mpp == NULL) {
/* read in secondary/replicated superblock */
*mpp = read_metapage(JFS_SBI(sb)->direct_inode,
SUPER2_OFF >> sb->s_blocksize_bits,
PSIZE, 1);
}
return *mpp ? 0 : 1;
*bpp = sb_bread(sb, SUPER1_OFF >> sb->s_blocksize_bits);
if (bpp)
return 0;
/* read in secondary/replicated superblock */
*bpp = sb_bread(sb, SUPER2_OFF >> sb->s_blocksize_bits);
if (bpp)
return 0;
return -EIO;
}
......
......@@ -106,7 +106,7 @@ struct jfs_superblock {
};
extern int readSuper(struct super_block *, struct metapage **);
extern int readSuper(struct super_block *, struct buffer_head **);
extern int updateSuper(struct super_block *, uint);
#endif /*_H_JFS_SUPERBLOCK */
......@@ -144,7 +144,6 @@ struct {
*/
extern int lmGroupCommit(log_t * log, tblock_t * tblk);
extern void lmSync(log_t *);
extern int readSuper(struct super_block *sb, metapage_t ** bpp);
extern int jfs_commit_inode(struct inode *, int);
extern int jfs_stop_threads;
......
......@@ -79,9 +79,8 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)
int log_formatted = 0;
struct inode *iplist[1];
struct jfs_superblock *j_sb, *j_sb2;
metapage_t *sbp, *sb2p;
uint old_agsize;
struct buffer_head *bh;
struct buffer_head *bh, *bh2;
/* If the volume hasn't grown, get out now */
......@@ -230,9 +229,9 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)
*/
/* read in superblock */
if ((rc = readSuper(sb, &sbp)))
if ((rc = readSuper(sb, &bh)))
goto error_out;
j_sb = (struct jfs_superblock *) (sbp->data);
j_sb = (struct jfs_superblock *)bh->b_data;
/* mark extendfs() in progress */
j_sb->s_state |= cpu_to_le32(FM_EXTENDFS);
......@@ -243,7 +242,10 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)
PXDlength(&j_sb->s_xlogpxd, newLogSize);
/* synchronously update superblock */
flush_metapage(sbp);
mark_buffer_dirty(bh);
ll_rw_block(WRITE, 1, &bh);
wait_on_buffer(bh);
brelse(bh);
/*
* format new inline log synchronously;
......@@ -474,12 +476,13 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)
diWriteSpecial(ipbmap2, 1);
diFreeSpecial(ipbmap2);
/*
* update superblock
*/
if ((rc = readSuper(sb, &sbp)))
if ((rc = readSuper(sb, &bh)))
goto error_out;
j_sb = (struct jfs_superblock *) (sbp->data);
j_sb = (struct jfs_superblock *)bh->b_data;
/* mark extendfs() completion */
j_sb->s_state &= cpu_to_le32(~FM_EXTENDFS);
......@@ -503,17 +506,22 @@ int jfs_extendfs(struct super_block *sb, s64 newLVSize, int newLogSize)
/* sb->s_fsckloglen remains the same */
/* Update secondary superblock */
sb2p = read_metapage(sbi->direct_inode,
SUPER2_OFF >> sb->s_blocksize_bits, PSIZE, 1);
if (sb2p) {
j_sb2 = (struct jfs_superblock *) (sb2p->data);
bh2 = sb_bread(sb, SUPER2_OFF >> sb->s_blocksize_bits);
if (bh2) {
j_sb2 = (struct jfs_superblock *)bh2->b_data;
memcpy(j_sb2, j_sb, sizeof (struct jfs_superblock));
flush_metapage(sb2p);
mark_buffer_dirty(bh);
ll_rw_block(WRITE, 1, &bh2);
wait_on_buffer(bh2);
brelse(bh);
}
/* write primary superblock */
flush_metapage(sbp);
mark_buffer_dirty(bh);
ll_rw_block(WRITE, 1, &bh);
wait_on_buffer(bh);
brelse(bh);
goto resume;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment