Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pfc offset fix #319

Merged
merged 2 commits into from
Dec 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/XrdFileCache/XrdFileCacheIOEntireFile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ void IOEntireFile::StartPrefetch()
{
pthread_t tid;
XrdSysThread::Run(&tid, PrefetchRunner, (void *)(m_prefetch), 0, "XrdFileCache Prefetcher");

}


Expand All @@ -87,8 +86,13 @@ int IOEntireFile::Read (char *buff, long long off, int size)
clLog()->Debug(XrdCl::AppMsg, "IO::Read() [%p] %lld@%d %s", this, off, size, m_io.Path());

// protect from reads over the file size
if (off >= m_io.FSize() || off < 0)
{
errno = EINVAL;
return -1;
}
if (off + size > m_io.FSize())
size = m_io.FSize() - off;
size = m_io.FSize() - off;

ssize_t bytes_read = 0;
ssize_t retval = 0;
Expand All @@ -97,7 +101,6 @@ int IOEntireFile::Read (char *buff, long long off, int size)
clLog()->Debug(XrdCl::AppMsg, "IO::Read() read from prefetch retval = %d %s", retval, m_io.Path());
if (retval > 0)
{

bytes_read += retval;
buff += retval;
size -= retval;
Expand Down
13 changes: 9 additions & 4 deletions src/XrdFileCache/XrdFileCacheIOFileBlock.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,21 @@ bool IOFileBlock::ioActive()
//______________________________________________________________________________
int IOFileBlock::Read (char *buff, long long off, int size)
{
// protect from reads over the file size
if (off >= m_io.FSize() || off < 0)
{
errno = EINVAL;
return -1;
}
if (off + size > m_io.FSize())
size = m_io.FSize() - off;

long long off0 = off;
int idx_first = off0/m_blocksize;
int idx_last = (off0+size-1)/m_blocksize;
int bytes_read = 0;
clLog()->Debug(XrdCl::AppMsg, "IOFileBlock::Read() %lld@%d block range [%d-%d] \n %s", off, size, idx_first, idx_last, m_io.Path());

// protect from reads over the file size
if (off + size > m_io.FSize())
size = m_io.FSize() - off;

for (int blockIdx = idx_first; blockIdx <= idx_last; ++blockIdx )
{
// locate block
Expand Down