mirror of
https://github.com/Zygo/bees.git
synced 2025-05-17 21:35:45 +02:00
readahead: use the right parameter order when checking the range
In some cases the offset and size arguments were flipped when checking to see if a range had already been read. This would have been OK as long as the same mistake had been made consistently, since `bees_readahead_check` only does a cache lookup on the parameters, it doesn't try to use them to read a file. Alas, there was one case where the correct order was used, albeit a relatively rare one. Fix all the calls to use the correct order. Also fix a comment: the recent request cache is global to all threads. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
parent
1dd96f20c6
commit
e40339856f
@ -220,7 +220,7 @@ bees_readahead_check(int const fd, off_t const offset, size_t const size)
|
|||||||
{
|
{
|
||||||
// FIXME: the rest of the code calls this function more often than necessary,
|
// FIXME: the rest of the code calls this function more often than necessary,
|
||||||
// usually back-to-back calls on the same range in a loop.
|
// usually back-to-back calls on the same range in a loop.
|
||||||
// Simply discard requests that are identical to recent requests from the same thread.
|
// Simply discard requests that are identical to recent requests.
|
||||||
const Stat stat_rv(fd);
|
const Stat stat_rv(fd);
|
||||||
auto tup = make_tuple(offset, size, stat_rv.st_dev, stat_rv.st_ino);
|
auto tup = make_tuple(offset, size, stat_rv.st_dev, stat_rv.st_ino);
|
||||||
static mutex s_recent_mutex;
|
static mutex s_recent_mutex;
|
||||||
@ -242,7 +242,7 @@ static
|
|||||||
void
|
void
|
||||||
bees_readahead_nolock(int const fd, const off_t offset, const size_t size)
|
bees_readahead_nolock(int const fd, const off_t offset, const size_t size)
|
||||||
{
|
{
|
||||||
if (!bees_readahead_check(fd, size, offset)) return;
|
if (!bees_readahead_check(fd, offset, size)) return;
|
||||||
Timer readahead_timer;
|
Timer readahead_timer;
|
||||||
BEESNOTE("readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
BEESNOTE("readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
||||||
BEESTOOLONG("readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
BEESTOOLONG("readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
||||||
@ -278,7 +278,7 @@ static mutex s_only_one;
|
|||||||
void
|
void
|
||||||
bees_readahead_pair(int fd, off_t offset, size_t size, int fd2, off_t offset2, size_t size2)
|
bees_readahead_pair(int fd, off_t offset, size_t size, int fd2, off_t offset2, size_t size2)
|
||||||
{
|
{
|
||||||
if (!bees_readahead_check(fd, size, offset) && !bees_readahead_check(fd2, offset2, size2)) return;
|
if (!bees_readahead_check(fd, offset, size) && !bees_readahead_check(fd2, offset2, size2)) return;
|
||||||
BEESNOTE("waiting to readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size) << ","
|
BEESNOTE("waiting to readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size) << ","
|
||||||
<< "\n\t" << name_fd(fd2) << " offset " << to_hex(offset2) << " len " << pretty(size2));
|
<< "\n\t" << name_fd(fd2) << " offset " << to_hex(offset2) << " len " << pretty(size2));
|
||||||
unique_lock<mutex> m_lock(s_only_one);
|
unique_lock<mutex> m_lock(s_only_one);
|
||||||
@ -289,7 +289,7 @@ bees_readahead_pair(int fd, off_t offset, size_t size, int fd2, off_t offset2, s
|
|||||||
void
|
void
|
||||||
bees_readahead(int const fd, const off_t offset, const size_t size)
|
bees_readahead(int const fd, const off_t offset, const size_t size)
|
||||||
{
|
{
|
||||||
if (!bees_readahead_check(fd, size, offset)) return;
|
if (!bees_readahead_check(fd, offset, size)) return;
|
||||||
BEESNOTE("waiting to readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
BEESNOTE("waiting to readahead " << name_fd(fd) << " offset " << to_hex(offset) << " len " << pretty(size));
|
||||||
unique_lock<mutex> m_lock(s_only_one);
|
unique_lock<mutex> m_lock(s_only_one);
|
||||||
bees_readahead_nolock(fd, offset, size);
|
bees_readahead_nolock(fd, offset, size);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user