mirror of
https://github.com/versity/scoutfs.git
synced 2026-09-26 18:04:40 +00:00
scoutfs: replace some open coded corruption checks
We can trivially do the simple check of value length against what the caller expects in btree.c. Signed-off-by: Mark Fasheh <mfasheh@versity.com> Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
+2
-12
@@ -427,16 +427,12 @@ static void delete_inode(struct super_block *sb, u64 ino)
|
||||
/* sample the inode mode, XXX don't need to copy whole thing here */
|
||||
scoutfs_set_key(&key, ino, SCOUTFS_INODE_KEY, 0);
|
||||
scoutfs_btree_init_val(&val, &sinode, sizeof(sinode));
|
||||
val.check_size_eq = 1;
|
||||
|
||||
ret = scoutfs_btree_lookup(sb, meta, &key, &val);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
|
||||
/* XXX corruption */
|
||||
if (ret != sizeof(sinode)) {
|
||||
ret = -EIO;
|
||||
goto out;
|
||||
}
|
||||
mode = le32_to_cpu(sinode.mode);
|
||||
|
||||
ret = __delete_inode(sb, &key, ino, mode);
|
||||
@@ -486,6 +482,7 @@ static int process_orphaned_inode(struct super_block *sb, u64 ino)
|
||||
|
||||
scoutfs_set_key(&key, ino, SCOUTFS_INODE_KEY, 0);
|
||||
scoutfs_btree_init_val(&val, &sinode, sizeof(sinode));
|
||||
val.check_size_eq = 1;
|
||||
|
||||
ret = scoutfs_btree_lookup(sb, meta, &key, &val);
|
||||
if (ret < 0) {
|
||||
@@ -494,18 +491,11 @@ static int process_orphaned_inode(struct super_block *sb, u64 ino)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* XXX corruption */
|
||||
if (ret != sizeof(sinode)) {
|
||||
ret = -EIO;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (le32_to_cpu(sinode.nlink) == 0)
|
||||
__delete_inode(sb, &key, ino, le32_to_cpu(sinode.mode));
|
||||
else
|
||||
scoutfs_warn(sb, "Dangling orphan item for inode %llu.", ino);
|
||||
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user