XRootD
XrdOfsCksFile.hh
Go to the documentation of this file.
1 #ifndef _XRDOFSCKSFILE_H
2 #define _XRDOFSCKSFILE_H
3 /******************************************************************************/
4 /* */
5 /* X r d O f s C k s F i l e . h h */
6 /* */
7 /* (c) 2026 by the Board of Trustees of the Leland Stanford, Jr., University */
8 /* All Rights Reserved */
9 /* Produced by Andrew Hanushevsky for Stanford University under contract */
10 /* DE-AC02-76-SFO0515 with the Department of Energy */
11 /* */
12 /* This file is part of the XRootD software suite. */
13 /* */
14 /* XRootD is free software: you can redistribute it and/or modify it under */
15 /* the terms of the GNU Lesser General Public License as published by the */
16 /* Free Software Foundation, either version 3 of the License, or (at your */
17 /* option) any later version. */
18 /* */
19 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */
20 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
21 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
22 /* License for more details. */
23 /* */
24 /* You should have received a copy of the GNU Lesser General Public License */
25 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
26 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
27 /* */
28 /* The copyright holder's institutional names and contributor's names may not */
29 /* be used to endorse or promote products derived from this software without */
30 /* specific prior written permission of the institution or contributor. */
31 /******************************************************************************/
32 
33 #include <cstdint>
34 #include <map>
35 
36 #include "XrdOss/XrdOssWrapper.hh"
37 #include "XrdSys/XrdSysPthread.hh"
38 
39 class XrdCks;
40 class XrdCksCalc;
41 class XrdOucEnv;
42 class XrdSfsAio;
43 class XrdSysLogger;
44 
46 {
47 public:
48 
49 //-----------------------------------------------------------------------------
55 //-----------------------------------------------------------------------------
56 
57 int Close(long long* retsz=0) override;
58 
59 //-----------------------------------------------------------------------------
65 //-----------------------------------------------------------------------------
66 
67 int Ftruncate(unsigned long long flen) override;
68 
69 //-----------------------------------------------------------------------------
70 // Perform one time initialization
71 //
72 // @param cp - Pointer to checksum manager.
73 // @param ep - Pointer to the environment.
74 //-----------------------------------------------------------------------------
75 
76 static
77 void Init(XrdCks* cp, XrdOucEnv* ep);
78 
79 //-----------------------------------------------------------------------------
88 //-----------------------------------------------------------------------------
89 
90 int Open(const char* path, int Oflag, mode_t Mode, XrdOucEnv& env)
91  override;
92 
93 //-----------------------------------------------------------------------------
110 //-----------------------------------------------------------------------------
111 
112 ssize_t pgWrite(void* buffer, off_t offset, size_t wrlen,
113  uint32_t* csvec, uint64_t opts) override;
114 
115 //-----------------------------------------------------------------------------
123 //-----------------------------------------------------------------------------
124 
125 int pgWrite(XrdSfsAio* aioparm, uint64_t opts) override;
126 
127 //-----------------------------------------------------------------------------
128 // Set the reread buffer size
129 //
130 // @param sz - The desired size of the buffer.
131 //-----------------------------------------------------------------------------
132 
133 static
134 void setRDSZ(int sz) {sz = ((sz/65536) + (sz%65536 != 0)) * 65536;
135  if (sz > 2*1024*1024) ioBlen = 2*1024*1024;
136  else ioBlen = sz;
137  }
138 
139 //-----------------------------------------------------------------------------
148 //-----------------------------------------------------------------------------
149 
150 ssize_t Write(const void* buffer, off_t offset, size_t size) override;
151 
152 //-----------------------------------------------------------------------------
159 //-----------------------------------------------------------------------------
160 
161 int Write(XrdSfsAio* aiop) override;
162 
163 //-----------------------------------------------------------------------------
171 //-----------------------------------------------------------------------------
172 
173 ssize_t WriteV(XrdOucIOVec *writeV, int wrvcnt) override;
174 
175  XrdOfsCksFile(const char* tid, const char* path, XrdOssDF* df,
176  XrdCksCalc* cP, bool& delFlag);
177 
178 virtual ~XrdOfsCksFile();
179 
180 private:
181 
182 const char* RTC_CB32(const void* inBuff, off_t inoff, int inLen);
183 const char* RTC_NCXX(const void* inBuff, off_t inoff, int inLen);
184 const char* RTC_Updt(off_t inoff, int inLen);
185 
186 const char* (XrdOfsCksFile::*ProcessRTC)(const void*, off_t, int);
187 
188 XrdSysMutex cksMtx;
189 const char* tident;
190  char* fPath; // Valid throughout object lifetime
191 XrdOssDF* ossDF; // Underlying dir/file object
192 XrdCksCalc* calcP;
193 const char* cksName;
194 XrdCksCalc* altcP;
195 bool& viaDel;
196 off_t nextOff;
197 void* ioBuff;
198 static
199 inline int ioBlen = 1024*1024; // 1 MB default buffer size when needed
200 
201 struct inSeg
202  {off_t segBeg;
203  int segLen;
204  uint32_t segCks; // adler32 or crc...
205 
206  inSeg(off_t newOff, int newLen, uint32_t newCks)
207  : segBeg(newOff), segLen(newLen), segCks(newCks) {}
208  ~inSeg() {}
209  };
210 
211 std::map<off_t, inSeg> segMap;
212 
213 bool Dirty;
214 };
215 #endif
int Mode
struct myOpts opts
Definition: XrdCks.hh:92
int Open(const char *path, int Oflag, mode_t Mode, XrdOucEnv &env) override
ssize_t Write(const void *buffer, off_t offset, size_t size) override
ssize_t WriteV(XrdOucIOVec *writeV, int wrvcnt) override
static void Init(XrdCks *cp, XrdOucEnv *ep)
XrdOfsCksFile(const char *tid, const char *path, XrdOssDF *df, XrdCksCalc *cP, bool &delFlag)
int Close(long long *retsz=0) override
ssize_t pgWrite(void *buffer, off_t offset, size_t wrlen, uint32_t *csvec, uint64_t opts) override
static void setRDSZ(int sz)
int Ftruncate(unsigned long long flen) override
virtual ~XrdOfsCksFile()