00001 #ifndef __XROOTD_PROTOCOL_H__
00002 #define __XROOTD_PROTOCOL_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <stdlib.h>
00015 #include <unistd.h>
00016 #include <sys/types.h>
00017
00018 #include "XrdSys/XrdSysError.hh"
00019 #include "XrdSys/XrdSysPthread.hh"
00020 #include "XrdSec/XrdSecInterface.hh"
00021
00022 #include "Xrd/XrdObject.hh"
00023 #include "Xrd/XrdProtocol.hh"
00024 #include "XrdXrootd/XrdXrootdReqID.hh"
00025 #include "XrdXrootd/XrdXrootdResponse.hh"
00026 #include "XProtocol/XProtocol.hh"
00027
00028
00029
00030
00031
00032 #define XROOTD_VERSBIN 0x00000291
00033
00034 #define XROOTD_VERSION "2.9.1"
00035
00036 #define ROOTD_PQ 2012
00037
00038 #define XRD_LOGGEDIN 1
00039 #define XRD_NEED_AUTH 2
00040 #define XRD_ADMINUSER 4
00041 #define XRD_BOUNDPATH 8
00042
00043 #ifndef __GNUC__
00044 #define __attribute__(x)
00045 #endif
00046
00047
00048
00049
00050
00051 class XrdNetSocket;
00052 class XrdOucErrInfo;
00053 class XrdOucStream;
00054 class XrdOucTokenizer;
00055 class XrdOucTrace;
00056 class XrdSfsFileSystem;
00057 class XrdSecProtocol;
00058 class XrdBuffer;
00059 class XrdLink;
00060 class XrdXrootdAioReq;
00061 class XrdXrootdFile;
00062 class XrdXrootdFileLock;
00063 class XrdXrootdFileTable;
00064 class XrdXrootdJob;
00065 class XrdXrootdMonitor;
00066 class XrdXrootdPio;
00067 class XrdXrootdStats;
00068 class XrdXrootdXPath;
00069
00070 class XrdXrootdProtocol : public XrdProtocol
00071 {
00072 friend class XrdXrootdAdmin;
00073 friend class XrdXrootdAioReq;
00074 public:
00075
00076 static int Configure(char *parms, XrdProtocol_Config *pi);
00077
00078 void DoIt() {(*this.*Resume)();}
00079
00080 XrdProtocol *Match(XrdLink *lp);
00081
00082 int Process(XrdLink *lp);
00083
00084 void Recycle(XrdLink *lp, int consec, const char *reason);
00085
00086 int Stats(char *buff, int blen, int do_sync=0);
00087
00088 static int StatGen(struct stat &buf, char *xxBuff);
00089
00090 XrdXrootdProtocol operator =(const XrdXrootdProtocol &rhs);
00091 XrdXrootdProtocol();
00092 ~XrdXrootdProtocol() {Cleanup();}
00093
00094 private:
00095
00096
00097
00098 enum RD_func {RD_chmod = 0, RD_dirlist, RD_locate,RD_mkdir, RD_mv,
00099 RD_prepare, RD_prepstg, RD_rm, RD_rmdir, RD_stat,
00100 RD_open1, RD_open2, RD_open3, RD_open4, RD_Num};
00101
00102 int do_Admin();
00103 int do_Auth();
00104 int do_Bind();
00105 int do_Chmod();
00106 int do_CKsum(int canit);
00107 int do_Close();
00108 int do_Dirlist();
00109 int do_Endsess();
00110 int do_Getfile();
00111 int do_Login();
00112 int do_Locate();
00113 int do_Mkdir();
00114 int do_Mv();
00115 int do_Offload(int pathID, int isRead);
00116 int do_OffloadIO();
00117 int do_Open();
00118 int do_Ping();
00119 int do_Prepare();
00120 int do_Protocol();
00121 int do_Putfile();
00122 int do_Qconf();
00123 int do_Qfh();
00124 int do_Qopaque(short);
00125 int do_Qspace();
00126 int do_Query();
00127 int do_Qxattr();
00128 int do_Read();
00129 int do_ReadV();
00130 int do_ReadAll(int asyncOK=1);
00131 int do_ReadNone(int &retc, int &pathID);
00132 int do_Rm();
00133 int do_Rmdir();
00134 int do_Set();
00135 int do_Set_Mon(XrdOucTokenizer &setargs);
00136 int do_Stat();
00137 int do_Statx();
00138 int do_Sync();
00139 int do_Truncate();
00140 int do_Write();
00141 int do_WriteAll();
00142 int do_WriteCont();
00143 int do_WriteNone();
00144
00145 int aio_Error(const char *op, int ecode);
00146 int aio_Read();
00147 int aio_Write();
00148 int aio_WriteAll();
00149 int aio_WriteCont();
00150
00151 void Assign(const XrdXrootdProtocol &rhs);
00152 void Cleanup();
00153 static int Config(const char *fn);
00154 int fsError(int rc, XrdOucErrInfo &myError);
00155 int getBuff(const int isRead, int Quantum);
00156 int getData(const char *dtype, char *buff, int blen);
00157 static int mapMode(int mode);
00158 static void PidFile();
00159 int Process2();
00160 void Reset();
00161 static int rpCheck(char *fn, const char **opaque);
00162 int rpEmsg(const char *op, char *fn);
00163 int vpEmsg(const char *op, char *fn);
00164 static int Squash(char *);
00165 static int xapath(XrdOucStream &Config);
00166 static int xasync(XrdOucStream &Config);
00167 static int xcksum(XrdOucStream &Config);
00168 static int xexp(XrdOucStream &Config);
00169 static int xexpdo(char *path, int popt=0);
00170 static int xfsl(XrdOucStream &Config);
00171 static int xpidf(XrdOucStream &Config);
00172 static int xprep(XrdOucStream &Config);
00173 static int xlog(XrdOucStream &Config);
00174 static int xmon(XrdOucStream &Config);
00175 static int xred(XrdOucStream &Config);
00176 static void xred_set(RD_func func, const char *rHost, int rPort);
00177 static int xsecl(XrdOucStream &Config);
00178 static int xtrace(XrdOucStream &Config);
00179
00180 static XrdObjectQ<XrdXrootdProtocol> ProtStack;
00181 XrdObject<XrdXrootdProtocol> ProtLink;
00182
00183 protected:
00184
00185 static XrdXrootdXPath RPList;
00186 static XrdXrootdXPath XPList;
00187 static XrdSfsFileSystem *osFS;
00188 static XrdSecService *CIA;
00189 static XrdXrootdFileLock *Locker;
00190 static XrdScheduler *Sched;
00191 static XrdBuffManager *BPool;
00192 static XrdSysError eDest;
00193 static const char *myInst;
00194 static const char *TraceID;
00195 static char *pidPath;
00196 static int myPID;
00197
00198
00199
00200 static XrdNetSocket *AdminSock;
00201
00202
00203
00204 static int hailWait;
00205 static int readWait;
00206 static int Port;
00207 static int Window;
00208 static int WANPort;
00209 static int WANWindow;
00210 static char *SecLib;
00211 static char *FSLib;
00212 static char *Notify;
00213 static char isRedir;
00214 static char chkfsV;
00215 static XrdXrootdJob *JobCKS;
00216 static char *JobCKT;
00217
00218
00219
00220 static struct RD_Table {char *Host; int Port;} Route[RD_Num];
00221
00222
00223
00224 static int as_maxperlnk;
00225 static int as_maxperreq;
00226 static int as_maxpersrv;
00227 static int as_miniosz;
00228 static int as_minsfsz;
00229 static int as_segsize;
00230 static int as_maxstalls;
00231 static int as_force;
00232 static int as_noaio;
00233 static int as_nosf;
00234 static int as_syncw;
00235 static int maxBuffsz;
00236 static int maxTransz;
00237 static const int maxRvecsz = 1024;
00238
00239
00240
00241 static XrdXrootdStats *SI;
00242 int numReads;
00243 int numReadP;
00244 int numWrites;
00245 int numFiles;
00246
00247 int cumReads;
00248 int cumReadP;
00249 int cumWrites;
00250 long long totReadP;
00251
00252
00253
00254 XrdLink *Link;
00255 XrdBuffer *argp;
00256 XrdXrootdFileTable *FTab;
00257 XrdXrootdMonitor *Monitor;
00258 kXR_unt32 monUID;
00259 char monFILE;
00260 char monIO;
00261 char Status;
00262 unsigned char CapVer;
00263
00264
00265
00266 XrdSecEntity *Client;
00267 XrdSecProtocol *AuthProt;
00268 XrdSecEntity Entity;
00269
00270
00271
00272 XrdXrootdAioReq *myAioReq;
00273 char *myBuff;
00274 int myBlen;
00275 int myBlast;
00276 int (XrdXrootdProtocol::*Resume)();
00277 XrdXrootdFile *myFile;
00278 long long myOffset;
00279 int myIOLen;
00280 int myStalls;
00281
00282
00283
00284 static int hcMax;
00285 int hcPrev;
00286 int hcNext;
00287 int hcNow;
00288 int halfBSize;
00289
00290
00291
00292 static const int maxStreams = 16;
00293 XrdSysMutex streamMutex;
00294 XrdSysSemaphore *reTry;
00295 XrdXrootdProtocol *Stream[maxStreams];
00296 unsigned int mySID;
00297 char isActive;
00298 char isDead;
00299 char isBound;
00300 char isNOP;
00301
00302 static const int maxPio = 4;
00303 XrdXrootdPio *pioFirst;
00304 XrdXrootdPio *pioLast;
00305 XrdXrootdPio *pioFree;
00306
00307 short PathID;
00308 char doWrite;
00309 char doWriteC;
00310
00311
00312
00313 XrdXrootdReqID ReqID;
00314 ClientRequest Request;
00315 XrdXrootdResponse Response;
00316 };
00317 #endif