Add an item next for key len ignoring val

Add scoutfs_item_next_same() which requires that the key lengths be
identical but which allows any values, including no value by way of a
null kvec.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2017-01-24 14:46:04 -08:00
parent 9d68e272cc
commit 9d6d70bd89
2 changed files with 23 additions and 0 deletions

View File

@@ -713,6 +713,27 @@ int scoutfs_item_next_same_min(struct super_block *sb,
return ret;
}
/*
* Like _next but requires that the found keys be the same length as the
* search key. It treats size mismatches as a sign of corruption.
*/
int scoutfs_item_next_same(struct super_block *sb, struct scoutfs_key_buf *key,
struct scoutfs_key_buf *last, struct kvec *val)
{
int key_len = key->key_len;
int ret;
trace_printk("key len %u\n", key_len);
ret = scoutfs_item_next(sb, key, last, val);
if (ret >= 0 && (key->key_len != key_len))
ret = -EIO;
trace_printk("ret %d\n", ret);
return ret;
}
/*
* Create a new dirty item in the cache. Returns -EEXIST if an item
* already exists with the given key.

View File

@@ -17,6 +17,8 @@ int scoutfs_item_next_same_min(struct super_block *sb,
struct scoutfs_key_buf *key,
struct scoutfs_key_buf *last,
struct kvec *val, int len);
int scoutfs_item_next_same(struct super_block *sb, struct scoutfs_key_buf *key,
struct scoutfs_key_buf *last, struct kvec *val);
int scoutfs_item_insert(struct super_block *sb, struct scoutfs_key_buf *key,
struct kvec *val);
int scoutfs_item_create(struct super_block *sb, struct scoutfs_key_buf *key,