Zach BrownandMark Fasheh 51e8b614e5 scoutfs: stop livelocking in item_next
scoutfs_item_next() could livelock given the right key and segment key
boundaries.  This was easiest to trigger with an fio command that wrote
a lot of data:

	fio --filesize=100m --nrfiles=25 --name=100m --numjobs=1 \
		--iodepth=1 --ioengine=sync --fallocate=0 \
		--rw=write --openfiles=256 \
		--directory=$TEST_DIR

There were two problems.

First, if it found a cached region that didn't contain a next item it
would try to read the *end* of the existing cached region instead of
trying to populate more items by reading from the key past the existing
cached region.  This is fixed by incrementing the key to read from after
setting it to the end of the cached region.

Second, it got totally confused by non-merged but adjacent cached
regions.  It would find a cached region that contains the search key and
try to read from the key after that region, but that key could also be
cached and just not merged with its previous region.  This is fixed by
(duh) having an allocated pos key that we set as we walk through cached
regions.  It used to always try and read from the search key which was
bonkers.

With these fixes fio now completes.

Signed-off-by: Zach Brown <zab@versity.com>
2017-09-05 14:22:47 -07:00
S
Description
No description provided
7.7 MiB
Languages
C 86.4%
Shell 10%
Roff 2.5%
TeX 0.8%
Makefile 0.3%