mirror of
https://github.com/versity/scoutfs.git
synced 2026-02-11 13:01:07 +00:00
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:
@@ -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.
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user