scoutfs: fix sense of filldir return in readdir

The migration from the new iterator interface in upstream to the old
readdir interface in rhel7 got the sense of the filldir return code
wrong.  Any readdir would deadlock livelock as the dot entry was
returned at offset 0 without advancing f_pos.

Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
Zach Brown
2016-03-14 19:26:47 -07:00
parent 4b182c7759
commit c46fb0be78

View File

@@ -240,13 +240,13 @@ static int dir_emit_dots(struct file *file, void *dirent, filldir_t filldir)
struct inode *parent = dentry->d_parent->d_inode;
if (file->f_pos == 0) {
if (!filldir(dirent, ".", 1, 1, scoutfs_ino(inode), DT_DIR))
if (filldir(dirent, ".", 1, 1, scoutfs_ino(inode), DT_DIR))
return 0;
file->f_pos = 1;
}
if (file->f_pos == 1) {
if (!filldir(dirent, "..", 2, 1, scoutfs_ino(parent), DT_DIR))
if (filldir(dirent, "..", 2, 1, scoutfs_ino(parent), DT_DIR))
return 0;
file->f_pos = 2;
}
@@ -309,8 +309,8 @@ static int scoutfs_readdir(struct file *file, void *dirent, filldir_t filldir)
if (dent->coll_nr < nr)
continue;
if (!filldir(dirent, dent->name, dent->name_len, pos,
le64_to_cpu(dent->ino), dent->type))
if (filldir(dirent, dent->name, dent->name_len, pos,
le64_to_cpu(dent->ino), dent->type))
break;
file->f_pos = (pos | dent->coll_nr) + 1;