]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: increment ctx->pos for every emitted or skipped dirent in readdir
authorJeff Mahoney <jeffm@suse.com>
Sat, 5 Nov 2016 17:26:35 +0000 (13:26 -0400)
committerDavid Sterba <dsterba@suse.com>
Wed, 30 Nov 2016 12:45:19 +0000 (13:45 +0100)
commit9b69f6004f39b8a2664a118ec2bb5d7ec74a42c4
tree0c966e4f6fd1b7115944f3a44c9c4c75adcc1b0d
parent2b6cceb9e1cf5d664d3bc5d99ad22236d58fdbe5
btrfs: increment ctx->pos for every emitted or skipped dirent in readdir

If we process the last item in the leaf and hit an I/O error while
reading the next leaf, we return -EIO without having adjusted the
position.  Since we have emitted dirents, getdents() will return
the byte count to the user instead of the error.  Subsequent callers
will emit the last successful dirent again, and return -EIO again,
with the same result.  Callers loop forever.

Instead, if we always increment ctx->pos after emitting or skipping
the dirent, we'll be sure that we won't hit the same one again.  When
we go to process the next leaf, we won't have emitted any dirents
and the -EIO will be returned to the user properly.  We also don't
need to track if we've emitted a dirent already or if we've changed
the position yet.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/delayed-inode.c
fs/btrfs/delayed-inode.h
fs/btrfs/inode.c