Commit bdd39891 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Kleikamp

JFS: use block device inode/mapping instead of direct_inode/direct_mapping

Change __get_metapage to use the block device mapping to back metapages
that are addresses by filesystem relative blocks.  Remove all code to
implement the JFS-private per-filesystem mapping and fake inode.
parent 5a43291d
......@@ -1179,7 +1179,7 @@ int diFree(struct inode *ip)
* invalidate any page of the inode extent freed from buffer cache;
*/
freepxd = iagp->inoext[extno];
invalidate_pxd_metapages(JFS_SBI(ip->i_sb)->direct_inode, freepxd);
invalidate_pxd_metapages(ip->i_sb->s_bdev->bd_inode, freepxd);
/*
* update iag list(s) (careful update step 2)
......
......@@ -152,8 +152,6 @@ struct jfs_sb_info {
/* Formerly in ipbmap */
struct bmap *bmap; /* 4: incore bmap descriptor */
struct nls_table *nls_tab; /* 4: current codepage */
struct inode *direct_inode; /* 4: inode for physical I/O */
struct address_space *direct_mapping; /* 4: mapping for physical I/O */
uint state; /* 4: mount/recovery state */
};
......
......@@ -960,20 +960,22 @@ int lmLogSync(log_t * log, int nosyncwait)
* reset syncpt = sync
*/
if (log->sync != log->syncpt) {
struct jfs_sb_info *sbi = JFS_SBI(log->sb);
struct super_block *sb = log->sb;
struct jfs_sb_info *sbi = JFS_SBI(sb);
/*
* We need to make sure all of the "written" metapages
* actually make it to disk
*/
filemap_fdatawait(sbi->ipbmap->i_mapping);
filemap_fdatawait(sbi->ipimap->i_mapping);
filemap_fdatawait(sbi->direct_inode->i_mapping);
filemap_fdatawait(sb->s_bdev->bd_inode->i_mapping);
filemap_fdatawrite(sbi->ipbmap->i_mapping);
filemap_fdatawrite(sbi->ipimap->i_mapping);
filemap_fdatawrite(sbi->direct_inode->i_mapping);
filemap_fdatawrite(sb->s_bdev->bd_inode->i_mapping);
filemap_fdatawait(sbi->ipbmap->i_mapping);
filemap_fdatawait(sbi->ipimap->i_mapping);
filemap_fdatawait(sbi->direct_inode->i_mapping);
filemap_fdatawait(sb->s_bdev->bd_inode->i_mapping);
lrd.logtid = 0;
lrd.backchain = 0;
......
......@@ -217,51 +217,6 @@ static void remove_from_hash(metapage_t * mp, metapage_t ** hash_ptr)
mp->hash_next->hash_prev = mp->hash_prev;
}
/*
* Direct address space operations
*/
static int direct_get_block(struct inode *ip, sector_t lblock,
struct buffer_head *bh_result, int create)
{
if (create)
set_buffer_new(bh_result);
map_bh(bh_result, ip->i_sb, lblock);
return 0;
}
static int direct_writepage(struct page *page)
{
return block_write_full_page(page, direct_get_block);
}
static int direct_readpage(struct file *fp, struct page *page)
{
return block_read_full_page(page, direct_get_block);
}
static int direct_prepare_write(struct file *file, struct page *page,
unsigned from, unsigned to)
{
return block_prepare_write(page, from, to, direct_get_block);
}
static int direct_bmap(struct address_space *mapping, long block)
{
return generic_block_bmap(mapping, block, direct_get_block);
}
struct address_space_operations direct_aops = {
.readpage = direct_readpage,
.writepage = direct_writepage,
.sync_page = block_sync_page,
.prepare_write = direct_prepare_write,
.commit_write = generic_commit_write,
.bmap = direct_bmap,
};
metapage_t *__get_metapage(struct inode *inode,
unsigned long lblock, unsigned int size,
int absolute, unsigned long new)
......@@ -278,14 +233,12 @@ metapage_t *__get_metapage(struct inode *inode,
inode, lblock));
if (absolute)
mapping = JFS_SBI(inode->i_sb)->direct_mapping;
mapping = inode->i_sb->s_bdev->bd_inode->i_mapping;
else
mapping = inode->i_mapping;
spin_lock(&meta_lock);
hash_ptr = meta_hash(mapping, lblock);
mp = search_hash(hash_ptr, mapping, lblock);
if (mp) {
page_found:
......@@ -301,7 +254,7 @@ metapage_t *__get_metapage(struct inode *inode,
lock_metapage(mp);
spin_unlock(&meta_lock);
} else {
l2bsize = inode->i_sb->s_blocksize_bits;
l2bsize = inode->i_blkbits;
l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize;
page_index = lblock >> l2BlocksPerPage;
page_offset = (lblock - (page_index << l2BlocksPerPage)) <<
......@@ -423,12 +376,11 @@ void hold_metapage(metapage_t * mp, int force)
static void __write_metapage(metapage_t * mp)
{
struct inode *ip = (struct inode *) mp->mapping->host;
int l2bsize = mp->mapping->host->i_blkbits;
int l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize;
unsigned long page_index;
unsigned long page_offset;
int rc;
int l2bsize = ip->i_sb->s_blocksize_bits;
int l2BlocksPerPage = PAGE_CACHE_SHIFT - l2bsize;
jFYI(1, ("__write_metapage: mp = 0x%p\n", mp));
......@@ -553,7 +505,7 @@ void __invalidate_metapages(struct inode *ip, s64 addr, int len)
{
metapage_t **hash_ptr;
unsigned long lblock;
int l2BlocksPerPage = PAGE_CACHE_SHIFT - ip->i_sb->s_blocksize_bits;
int l2BlocksPerPage = PAGE_CACHE_SHIFT - ip->i_blkbits;
struct address_space *mapping = ip->i_mapping;
metapage_t *mp;
struct page *page;
......
......@@ -57,11 +57,6 @@ typedef struct metapage {
struct jfs_log *log;
} metapage_t;
/*
* Direct-access address space operations
*/
extern struct address_space_operations direct_aops;
/* metapage flag */
#define META_locked 0
#define META_absolute 1
......
......@@ -108,14 +108,6 @@ int jfs_umount(struct super_block *sb)
diFreeSpecial(ipbmap);
sbi->ipimap = NULL;
/*
* Make sure all metadata makes it to disk before we mark
* the superblock as clean
*/
filemap_fdatawait(sbi->direct_inode->i_mapping);
filemap_fdatawrite(sbi->direct_inode->i_mapping);
filemap_fdatawait(sbi->direct_inode->i_mapping);
/*
* ensure all file system file pages are propagated to their
* home blocks on disk (and their in-memory buffer pages are
......@@ -159,9 +151,6 @@ int jfs_umount_rw(struct super_block *sb)
*/
dbSync(sbi->ipbmap);
diSync(sbi->ipimap);
filemap_fdatawait(sbi->direct_inode->i_mapping);
filemap_fdatawrite(sbi->direct_inode->i_mapping);
filemap_fdatawait(sbi->direct_inode->i_mapping);
updateSuper(sb, FM_CLEAN);
sbi->log = NULL;
......
......@@ -142,18 +142,6 @@ static void jfs_put_super(struct super_block *sb)
unload_nls(sbi->nls_tab);
sbi->nls_tab = NULL;
/*
* We need to clean out the direct_inode pages since this inode
* is not in the inode hash.
*/
filemap_fdatawait(sbi->direct_inode->i_mapping);
filemap_fdatawrite(sbi->direct_inode->i_mapping);
filemap_fdatawait(sbi->direct_inode->i_mapping);
truncate_inode_pages(sbi->direct_mapping, 0);
iput(sbi->direct_inode);
sbi->direct_inode = NULL;
sbi->direct_mapping = NULL;
kfree(sbi);
}
......@@ -222,7 +210,6 @@ static int parse_options(char *options, struct super_block *sb, s64 *newLVSize)
int jfs_remount(struct super_block *sb, int *flags, char *data)
{
struct jfs_sb_info *sbi = JFS_SBI(sb);
s64 newLVSize = 0;
int rc = 0;
......@@ -240,15 +227,9 @@ int jfs_remount(struct super_block *sb, int *flags, char *data)
return rc;
}
if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY)) {
/*
* Invalidate any previously read metadata. fsck may
* have changed the on-disk data since we mounted r/o
*/
truncate_inode_pages(sbi->direct_mapping, 0);
if ((sb->s_flags & MS_RDONLY) && !(*flags & MS_RDONLY))
return jfs_mount_rw(sb, 1);
} else if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY))
else if ((!(sb->s_flags & MS_RDONLY)) && (*flags & MS_RDONLY))
return jfs_umount_rw(sb);
return 0;
......@@ -290,28 +271,13 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
sb->s_op = &jfs_super_operations;
sb->s_export_op = &jfs_export_operations;
/*
* Initialize direct-mapping inode/address-space
*/
inode = new_inode(sb);
if (inode == NULL)
goto out_kfree;
inode->i_ino = 0;
inode->i_nlink = 1;
inode->i_size = 0x0000010000000000LL;
inode->i_mapping->a_ops = &direct_aops;
inode->i_mapping->gfp_mask = GFP_NOFS;
sbi->direct_inode = inode;
sbi->direct_mapping = inode->i_mapping;
rc = jfs_mount(sb);
if (rc) {
if (!silent) {
jERROR(1,
("jfs_mount failed w/return code = %d\n", rc));
}
goto out_mount_failed;
goto out_kfree;
}
if (sb->s_flags & MS_RDONLY)
sbi->log = 0;
......@@ -361,15 +327,6 @@ static int jfs_fill_super(struct super_block *sb, void *data, int silent)
if (rc) {
jERROR(1, ("jfs_umount failed with return code %d\n", rc));
}
out_mount_failed:
filemap_fdatawait(sbi->direct_inode->i_mapping);
filemap_fdatawrite(sbi->direct_inode->i_mapping);
filemap_fdatawait(sbi->direct_inode->i_mapping);
truncate_inode_pages(sbi->direct_mapping, 0);
make_bad_inode(sbi->direct_inode);
iput(sbi->direct_inode);
sbi->direct_inode = NULL;
sbi->direct_mapping = NULL;
out_kfree:
if (sbi->nls_tab)
unload_nls(sbi->nls_tab);
......
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