00001 #ifndef __XRDPFC_IO_FILE_BLOCK_HH__ 00002 #define __XRDPFC_IO_FILE_BLOCK_HH__ 00003 //---------------------------------------------------------------------------------- 00004 // Copyright (c) 2014 by Board of Trustees of the Leland Stanford, Jr., University 00005 // Author: Alja Mrak-Tadel, Matevz Tadel, Brian Bockelman 00006 //---------------------------------------------------------------------------------- 00007 // XRootD is free software: you can redistribute it and/or modify 00008 // it under the terms of the GNU Lesser General Public License as published by 00009 // the Free Software Foundation, either version 3 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // XRootD is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public License 00018 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 00019 //---------------------------------------------------------------------------------- 00020 #include <map> 00021 #include <string> 00022 00023 #include "XrdOuc/XrdOucCache.hh" 00024 #include "XrdSys/XrdSysPthread.hh" 00025 00026 #include "XrdPfcIO.hh" 00027 00028 class XrdSysError; 00029 class XrdOssDF; 00030 00031 namespace XrdPfc 00032 { 00033 //---------------------------------------------------------------------------- 00037 //---------------------------------------------------------------------------- 00038 class IOFileBlock : public IO 00039 { 00040 public: 00041 IOFileBlock(XrdOucCacheIO *io, XrdOucCacheStats &stats, Cache &cache); 00042 00043 ~IOFileBlock(); 00044 00047 bool ioActive() /* override */; 00048 00051 void DetachFinalize() /* override */; 00052 00053 //--------------------------------------------------------------------- 00055 //--------------------------------------------------------------------- 00056 using XrdOucCacheIO::Read; 00057 00058 virtual int Read(char *Buffer, long long Offset, int Length); 00059 00060 virtual int Fstat(struct stat &sbuff); 00061 00062 virtual long long FSize(); 00063 00064 private: 00065 long long m_blocksize; 00066 std::map<int, File*> m_blocks; 00067 XrdSysMutex m_mutex; 00068 struct stat *m_localStat; 00069 Info m_info; 00070 XrdOssDF* m_info_file; 00071 00072 void GetBlockSizeFromPath(); 00073 int initLocalStat(); 00074 File* newBlockFile(long long off, int blocksize); 00075 void CloseInfoFile(); 00076 }; 00077 } 00078 00079 #endif