summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Kleikamp <shaggy@shaggy.austin.ibm.com>2003-01-28 22:45:39 -0600
committerDave Kleikamp <shaggy@shaggy.austin.ibm.com>2003-01-28 22:45:39 -0600
commit45dd3dc80392cf0da0baa0d489856bee71ae4a71 (patch)
tree4b4e7101df15d78495d42e97e7e5fc578c5ea386
parent2ca0edce67c379873e3494c5d31d96ba148e46c0 (diff)
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().
-rw-r--r--fs/jfs/jfs_dtree.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index b5b2441a0147..89aab0bc5b46 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -222,6 +222,25 @@ static struct metapage *read_index_page(struct inode *inode, s64 blkno)
}
/*
+ * 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()
*
* Returns dtree page containing directory table entry for specified
@@ -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);