Commit 45dd3dc8 authored by Dave Kleikamp's avatar Dave Kleikamp

JFS: Implement get_index_page to replace some uses of read_index_page

  
A recent change added the function read_index_page to replace calls to
read_metapage() when accessing the directory index table.  However, we
replaced both calls to read_metapage() and get_metapage() with the same
function, but we really need two.  In addition to unnecesary disk reads,
this problem caused an oops in __get_metapage().
parent 2ca0edce
......@@ -221,6 +221,25 @@ static struct metapage *read_index_page(struct inode *inode, s64 blkno)
return read_metapage(inode, xaddr, PSIZE, 1);
}
/*
* get_index_page()
*
* Same as get_index_page(), but get's a new page without reading
*/
static struct metapage *get_index_page(struct inode *inode, s64 blkno)
{
int rc;
s64 xaddr;
int xflag;
s32 xlen;
rc = xtLookup(inode, blkno, 1, &xflag, &xaddr, &xlen, 1);
if (rc || (xlen == 0))
return NULL;
return get_metapage(inode, xaddr, PSIZE, 1);
}
/*
* find_index()
*
......@@ -390,7 +409,7 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
ip->i_size = PSIZE;
ip->i_blocks += LBLK2PBLK(sb, sbi->nbperpage);
if ((mp = read_index_page(ip, 0)) == 0) {
if ((mp = get_index_page(ip, 0)) == 0) {
jfs_err("add_index: get_metapage failed!");
xtTruncate(tid, ip, 0, COMMIT_PWMAP);
return -1;
......@@ -433,7 +452,7 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
ip->i_size += PSIZE;
ip->i_blocks += LBLK2PBLK(sb, sbi->nbperpage);
if ((mp = read_index_page(ip, blkno)))
if ((mp = get_index_page(ip, blkno)))
memset(mp->data, 0, PSIZE); /* Just looks better */
else
xtTruncate(tid, ip, offset, COMMIT_PWMAP);
......
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