[CHECKER] Return Error code gets treated as dir_table index, resultinglosses of other dir entries (JFS2.4, kernel 2.4.19)

From: Junfeng Yang
Date: Fri Apr 30 2004 - 17:25:13 EST



static function add_index can fail by return -EPERM (and it is declared to
return a unsigned 4-byte integer). This error gets ignored by the caller,
dtInsertEntry, which will treat the returned error code (u32)(-EPERM) as
an index to dir_table. This causes losses of directory entries in the
same parent directory.

static u32 add_index(tid_t tid, struct inode *ip, s64 bn, int slot)
{
...
if ((mp = get_index_page(ip, 0)) == 0) {
jfs_err("add_index: get_metapage failed!");
xtTruncate(tid, ip, 0, COMMIT_PWMAP);
Return --> return -EPERM;
...
}


static void dtInsertEntry(dtpage_t * p, int index, struct component_name * key,
ddata_t * data, struct dt_lock ** dtlock)
{
...
Error --> lh->index = cpu_to_le32(add_index(data->leaf.tid,
data->leaf.ip,
bn, index));
...
}


Here is a trace:

============ Filesystem Image Before System Call ===================
4 files, 1 dirs, 6 nodes
[0:D]
[1:F:1073741824]
[2:F:0]
[3:F:0]
[4:D]

create file 5 succeeded.
can't get dir entry Input/output error
ERROR: Filesystem images differ

============= Filesystem Image After System Call ===================
3 files, 0 dirs, 4 nodes
[0:D]
[1:F:1073741824]
[2:F:0]
[3:F:0]

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/