scoutfs: remove scoutfs_item_lookup_exact() size

Every caller of scoutfs_item_lookup_exact() provided a size that matches
the value buffer.  Let's remove the redundant arg and use the value
buffer length as the exact size to match.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2018-04-04 09:15:27 -05:00
committed by Mark Swan
parent 9c1b393404
commit 08f544cc15
5 changed files with 16 additions and 27 deletions
+5 -14
View File
@@ -362,9 +362,7 @@ static int set_segno_free(struct super_block *sb, u64 segno)
init_free_key(&key, &fbk, sbi->node_id, segno,
SCOUTFS_FREE_BITS_SEGNO_TYPE);
scoutfs_kvec_init(val, &frb, sizeof(struct scoutfs_free_bits));
ret = scoutfs_item_lookup_exact(sb, &key, val,
sizeof(struct scoutfs_free_bits),
lock);
ret = scoutfs_item_lookup_exact(sb, &key, val, lock);
if (ret && ret != -ENOENT)
goto out;
@@ -443,9 +441,7 @@ static int clear_segno_free(struct super_block *sb, u64 segno)
init_free_key(&key, &fbk, sbi->node_id, segno,
SCOUTFS_FREE_BITS_SEGNO_TYPE);
scoutfs_kvec_init(val, &frb, sizeof(struct scoutfs_free_bits));
ret = scoutfs_item_lookup_exact(sb, &key, val,
sizeof(struct scoutfs_free_bits),
lock);
ret = scoutfs_item_lookup_exact(sb, &key, val, lock);
if (ret) {
/* XXX corruption, caller saw item.. should still exist */
if (ret == -ENOENT)
@@ -497,9 +493,7 @@ static int set_blkno_free(struct super_block *sb, u64 blkno)
init_free_key(&key, &fbk, sbi->node_id, blkno,
SCOUTFS_FREE_BITS_BLKNO_TYPE);
scoutfs_kvec_init(val, &frb, sizeof(struct scoutfs_free_bits));
ret = scoutfs_item_lookup_exact(sb, &key, val,
sizeof(struct scoutfs_free_bits),
lock);
ret = scoutfs_item_lookup_exact(sb, &key, val, lock);
if (ret && ret != -ENOENT)
goto out;
@@ -558,9 +552,7 @@ static int clear_blkno_free(struct super_block *sb, u64 blkno)
init_free_key(&key, &fbk, sbi->node_id, blkno,
SCOUTFS_FREE_BITS_BLKNO_TYPE);
scoutfs_kvec_init(val, &frb, sizeof(struct scoutfs_free_bits));
ret = scoutfs_item_lookup_exact(sb, &key, val,
sizeof(struct scoutfs_free_bits),
lock);
ret = scoutfs_item_lookup_exact(sb, &key, val, lock);
if (ret) {
/* XXX corruption, bits should have existed */
if (ret == -ENOENT)
@@ -856,8 +848,7 @@ static int find_free_blkno(struct super_block *sb, u64 blkno, u64 *blkno_ret)
SCOUTFS_FREE_BITS_BLKNO_TYPE);
scoutfs_kvec_init(val, &frb, sizeof(struct scoutfs_free_bits));
ret = scoutfs_item_lookup_exact(sb, &key, val,
sizeof(struct scoutfs_free_bits), lock);
ret = scoutfs_item_lookup_exact(sb, &key, val, lock);
if (ret < 0)
goto out;
+3 -5
View File
@@ -258,8 +258,7 @@ static int lookup_dirent(struct super_block *sb, struct inode *dir,
scoutfs_kvec_init(val, dent, sizeof(struct scoutfs_dirent));
ret = scoutfs_item_lookup_exact(sb, key, val,
sizeof(struct scoutfs_dirent), lock);
ret = scoutfs_item_lookup_exact(sb, key, val, lock);
out:
scoutfs_key_free(sb, key);
return ret;
@@ -999,8 +998,7 @@ static int symlink_item_ops(struct super_block *sb, int op, u64 ino,
if (op == SYM_CREATE)
ret = scoutfs_item_create(sb, &key, val, lock);
else if (op == SYM_LOOKUP)
ret = scoutfs_item_lookup_exact(sb, &key, val, bytes,
lock);
ret = scoutfs_item_lookup_exact(sb, &key, val, lock);
else if (op == SYM_DELETE)
ret = scoutfs_item_delete(sb, &key, lock);
if (ret)
@@ -1445,7 +1443,7 @@ static int verify_entry(struct super_block *sb, u64 dir_ino, const char *name,
scoutfs_kvec_init(val, &dent, sizeof(dent));
ret = scoutfs_item_lookup_exact(sb, key, val, sizeof(dent), lock);
ret = scoutfs_item_lookup_exact(sb, key, val, lock);
if (ret == 0 && le64_to_cpu(dent.ino) != ino)
ret = -ENOENT;
else if (ret == -ENOENT && ino == 0)
+2 -3
View File
@@ -286,8 +286,7 @@ int scoutfs_inode_refresh(struct inode *inode, struct scoutfs_lock *lock,
mutex_lock(&si->item_mutex);
if (atomic64_read(&si->last_refreshed) < refresh_gen) {
ret = scoutfs_item_lookup_exact(sb, &key, val, sizeof(sinode),
lock);
ret = scoutfs_item_lookup_exact(sb, &key, val, lock);
if (ret == 0) {
load_inode(inode, &sinode);
atomic64_set(&si->last_refreshed, refresh_gen);
@@ -1415,7 +1414,7 @@ static int delete_inode_items(struct super_block *sb, u64 ino)
scoutfs_inode_init_key(&key, &ikey, ino);
scoutfs_kvec_init(val, &sinode, sizeof(sinode));
ret = scoutfs_item_lookup_exact(sb, &key, val, sizeof(sinode), lock);
ret = scoutfs_item_lookup_exact(sb, &key, val, lock);
if (ret < 0) {
if (ret == -ENOENT)
ret = 0;
+5 -4
View File
@@ -809,21 +809,22 @@ int scoutfs_item_lookup(struct super_block *sb, struct scoutfs_key_buf *key,
/*
* This requires that the item at the specified key has a value of the
* same length as the specified value. Callers are asserting that
* same length as the caller's value buffer. Callers are asserting that
* mismatched size are corruption so it returns -EIO if the sizes don't
* match. This isn't the fast path so we don't mind the copying
* overhead that comes from only detecting the size mismatch after the
* copy by reusing the more permissive _lookup().
*
* The end key limits how many keys after the search key can be read
* and inserted into the cache.
* The end key limits how many keys after the search key can be read and
* inserted into the cache.
*
* Returns 0 or -errno.
*/
int scoutfs_item_lookup_exact(struct super_block *sb,
struct scoutfs_key_buf *key, struct kvec *val,
int size, struct scoutfs_lock *lock)
struct scoutfs_lock *lock)
{
int size = scoutfs_kvec_length(val);
int ret;
ret = scoutfs_item_lookup(sb, key, val, lock);
+1 -1
View File
@@ -10,7 +10,7 @@ int scoutfs_item_lookup(struct super_block *sb, struct scoutfs_key_buf *key,
struct kvec *val, struct scoutfs_lock *lock);
int scoutfs_item_lookup_exact(struct super_block *sb,
struct scoutfs_key_buf *key, struct kvec *val,
int size, struct scoutfs_lock *lock);
struct scoutfs_lock *lock);
int scoutfs_item_next(struct super_block *sb, struct scoutfs_key_buf *key,
struct scoutfs_key_buf *last, struct kvec *val,
struct scoutfs_lock *lock);