XRootD
Loading...
Searching...
No Matches
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
38
39class XrdCks;
40class XrdCksCalc;
41class XrdOucEnv;
42class XrdSfsAio;
43class XrdSysLogger;
44
46{
47public:
48
49//-----------------------------------------------------------------------------
55//-----------------------------------------------------------------------------
56
57int Close(long long* retsz=0) override;
58
59//-----------------------------------------------------------------------------
65//-----------------------------------------------------------------------------
66
67int 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
76static
77void Init(XrdCks* cp, XrdOucEnv* ep);
78
79//-----------------------------------------------------------------------------
88//-----------------------------------------------------------------------------
89
90int Open(const char* path, int Oflag, mode_t Mode, XrdOucEnv& env)
91 override;
92
93//-----------------------------------------------------------------------------
110//-----------------------------------------------------------------------------
111
112ssize_t pgWrite(void* buffer, off_t offset, size_t wrlen,
113 uint32_t* csvec, uint64_t opts) override;
114
115//-----------------------------------------------------------------------------
123//-----------------------------------------------------------------------------
124
125int 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
133static
134void 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
150ssize_t Write(const void* buffer, off_t offset, size_t size) override;
151
152//-----------------------------------------------------------------------------
159//-----------------------------------------------------------------------------
160
161int Write(XrdSfsAio* aiop) override;
162
163//-----------------------------------------------------------------------------
171//-----------------------------------------------------------------------------
172
173ssize_t WriteV(XrdOucIOVec *writeV, int wrvcnt) override;
174
175 XrdOfsCksFile(const char* tid, const char* path, XrdOssDF* df,
176 XrdCksCalc* cP, bool& delFlag);
177
178virtual ~XrdOfsCksFile();
179
180private:
181
182const char* RTC_CB32(const void* inBuff, off_t inoff, int inLen);
183const char* RTC_NCXX(const void* inBuff, off_t inoff, int inLen);
184const char* RTC_Updt(off_t inoff, int inLen);
185
186const char* (XrdOfsCksFile::*ProcessRTC)(const void*, off_t, int);
187
188XrdSysMutex cksMtx;
189const char* tident;
190 char* fPath; // Valid throughout object lifetime
191XrdOssDF* ossDF; // Underlying dir/file object
192XrdCksCalc* calcP;
193const char* cksName;
194XrdCksCalc* altcP;
195bool& viaDel;
196off_t nextOff;
197void* ioBuff;
198static
199inline int ioBlen = 1024*1024; // 1 MB default buffer size when needed
200
201struct 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
211std::map<off_t, inSeg> segMap;
212
213bool Dirty;
214};
215#endif
#define tident
int Mode
struct myOpts opts
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()
XrdOssWrapDF(XrdOssDF &df2Wrap)