scoutfs: search_xattrs returns each ino once

Hash collisions can lead to multiple xattr ids in an inode being found
for a given name hash value.  If this happens we only want to return the
inode number once.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2020-12-01 16:34:48 -08:00
committed by Andy Grover
parent 18aee0ebbd
commit f0ddf5ff04

View File

@@ -773,6 +773,7 @@ static long scoutfs_ioc_search_xattrs(struct file *file, unsigned long arg)
struct rb_node *node;
char *name = NULL;
bool done = false;
u64 prev_ino = 0;
u64 total = 0;
int ret;
@@ -819,11 +820,17 @@ static long scoutfs_ioc_search_xattrs(struct file *file, unsigned long arg)
if (ret < 0)
goto out;
prev_ino = 0;
scoutfs_srch_foreach_rb_node(snode, node, &sroot) {
if (prev_ino == snode->ino)
continue;
if (put_user(snode->ino, uinos + total)) {
ret = -EFAULT;
break;
}
prev_ino = snode->ino;
if (++total == sx.nr_inodes)
break;
}