Commit 5c83baf5 authored by Dave Kleikamp's avatar Dave Kleikamp

JFS: [CHECKER] More robust error recovery in add_index

If an error is encountered in add_index, it now leaves the index table
in a consistent state.  Since the return value is stored in the
directory entry regardless of add_index's success, return zero
instead of -EPERM (which made no sense).
parent 6f7df258
...@@ -342,7 +342,6 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot) ...@@ -342,7 +342,6 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
struct metapage *mp; struct metapage *mp;
s64 offset; s64 offset;
uint page_offset; uint page_offset;
int rc;
struct tlock *tlck; struct tlock *tlck;
s64 xaddr; s64 xaddr;
...@@ -396,11 +395,11 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot) ...@@ -396,11 +395,11 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
* Allocate the first block & add it to the xtree * Allocate the first block & add it to the xtree
*/ */
xaddr = 0; xaddr = 0;
if ((rc = if (xtInsert(tid, ip, 0, 0, sbi->nbperpage, &xaddr, 0)) {
xtInsert(tid, ip, 0, 0, sbi->nbperpage,
&xaddr, 0))) {
jfs_warn("add_index: xtInsert failed!"); jfs_warn("add_index: xtInsert failed!");
return -EPERM; memcpy(&jfs_ip->i_dirtable, temp_table,
sizeof (temp_table));
goto clean_up;
} }
ip->i_size = PSIZE; ip->i_size = PSIZE;
ip->i_blocks += LBLK2PBLK(sb, sbi->nbperpage); ip->i_blocks += LBLK2PBLK(sb, sbi->nbperpage);
...@@ -408,7 +407,9 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot) ...@@ -408,7 +407,9 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
if ((mp = get_index_page(ip, 0)) == 0) { if ((mp = get_index_page(ip, 0)) == 0) {
jfs_err("add_index: get_metapage failed!"); jfs_err("add_index: get_metapage failed!");
xtTruncate(tid, ip, 0, COMMIT_PWMAP); xtTruncate(tid, ip, 0, COMMIT_PWMAP);
return -EPERM; memcpy(&jfs_ip->i_dirtable, temp_table,
sizeof (temp_table));
goto clean_up;
} }
tlck = txLock(tid, ip, mp, tlckDATA); tlck = txLock(tid, ip, mp, tlckDATA);
llck = (struct linelock *) & tlck->lock; llck = (struct linelock *) & tlck->lock;
...@@ -438,12 +439,9 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot) ...@@ -438,12 +439,9 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
* This will be the beginning of a new page * This will be the beginning of a new page
*/ */
xaddr = 0; xaddr = 0;
if ((rc = if (xtInsert(tid, ip, 0, blkno, sbi->nbperpage, &xaddr, 0)) {
xtInsert(tid, ip, 0, blkno, sbi->nbperpage,
&xaddr, 0))) {
jfs_warn("add_index: xtInsert failed!"); jfs_warn("add_index: xtInsert failed!");
jfs_ip->next_index--; goto clean_up;
return -EPERM;
} }
ip->i_size += PSIZE; ip->i_size += PSIZE;
ip->i_blocks += LBLK2PBLK(sb, sbi->nbperpage); ip->i_blocks += LBLK2PBLK(sb, sbi->nbperpage);
...@@ -457,7 +455,7 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot) ...@@ -457,7 +455,7 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
if (mp == 0) { if (mp == 0) {
jfs_err("add_index: get/read_metapage failed!"); jfs_err("add_index: get/read_metapage failed!");
return -EPERM; goto clean_up;
} }
lock_index(tid, ip, mp, index); lock_index(tid, ip, mp, index);
...@@ -472,6 +470,12 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot) ...@@ -472,6 +470,12 @@ static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
release_metapage(mp); release_metapage(mp);
return index; return index;
clean_up:
jfs_ip->next_index--;
return 0;
} }
/* /*
......
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