XrdXrootdProtocol.hh

Go to the documentation of this file.
00001 #ifndef __XROOTD_PROTOCOL_H__
00002 #define __XROOTD_PROTOCOL_H__
00003 /******************************************************************************/
00004 /*                                                                            */
00005 /*                  X r d X r o o t d P r o t o c o l . h h                   */
00006 /*                                                                            */
00007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University  */
00008 /*   Produced by Andrew Hanushevsky for Stanford University under contract    */
00009 /*              DE-AC03-76-SFO0515 with the Department of Energy              */
00010 /******************************************************************************/
00011 
00012 //       $Id: XrdXrootdProtocol.hh 34000 2010-06-21 06:49:56Z ganis $
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 /*                               D e f i n e s                                */
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 /*                   x r d _ P r o t o c o l _ X R o o t d                    */
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); //  Sync: Job->Link.DoIt->Process
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           mapError(int rc);
00089 static int           StatGen(struct stat &buf, char *xxBuff);
00090 
00091               XrdXrootdProtocol operator =(const XrdXrootdProtocol &rhs);
00092               XrdXrootdProtocol();
00093              ~XrdXrootdProtocol() {Cleanup();}
00094 
00095 private:
00096 
00097 // Note that Route[] structure (below) must have RD_Num elements!
00098 //
00099 enum RD_func {RD_chmod = 0, RD_dirlist, RD_locate,RD_mkdir, RD_mv,
00100               RD_prepare,   RD_prepstg, RD_rm,    RD_rmdir, RD_stat,
00101               RD_open1,     RD_open2,   RD_open3, RD_open4, RD_Num};
00102 
00103        int   do_Admin();
00104        int   do_Auth();
00105        int   do_Bind();
00106        int   do_Chmod();
00107        int   do_CKsum(int canit);
00108        int   do_Close();
00109        int   do_Dirlist();
00110        int   do_Endsess();
00111        int   do_Getfile();
00112        int   do_Login();
00113        int   do_Locate();
00114        int   do_Mkdir();
00115        int   do_Mv();
00116        int   do_Offload(int pathID, int isRead);
00117        int   do_OffloadIO();
00118        int   do_Open();
00119        int   do_Ping();
00120        int   do_Prepare();
00121        int   do_Protocol();
00122        int   do_Putfile();
00123        int   do_Qconf();
00124        int   do_Qfh();
00125        int   do_Qopaque(short);
00126        int   do_Qspace();
00127        int   do_Query();
00128        int   do_Qxattr();
00129        int   do_Read();
00130        int   do_ReadV();
00131        int   do_ReadAll(int asyncOK=1);
00132        int   do_ReadNone(int &retc, int &pathID);
00133        int   do_Rm();
00134        int   do_Rmdir();
00135        int   do_Set();
00136        int   do_Set_Mon(XrdOucTokenizer &setargs);
00137        int   do_Stat();
00138        int   do_Statx();
00139        int   do_Sync();
00140        int   do_Truncate();
00141        int   do_Write();
00142        int   do_WriteAll();
00143        int   do_WriteCont();
00144        int   do_WriteNone();
00145 
00146        int   aio_Error(const char *op, int ecode);
00147        int   aio_Read();
00148        int   aio_Write();
00149        int   aio_WriteAll();
00150        int   aio_WriteCont();
00151 
00152        void  Assign(const XrdXrootdProtocol &rhs);
00153        void  Cleanup();
00154 static int   Config(const char *fn);
00155        int   fsError(int rc, XrdOucErrInfo &myError);
00156        int   getBuff(const int isRead, int Quantum);
00157        int   getData(const char *dtype, char *buff, int blen);
00158 static int   mapMode(int mode);
00159 static void  PidFile();
00160        int   Process2();
00161        void  Reset();
00162 static int   rpCheck(char *fn, const char **opaque);
00163        int   rpEmsg(const char *op, char *fn);
00164        int   vpEmsg(const char *op, char *fn);
00165 static int   Squash(char *);
00166 static int   xapath(XrdOucStream &Config);
00167 static int   xasync(XrdOucStream &Config);
00168 static int   xcksum(XrdOucStream &Config);
00169 static int   xexp(XrdOucStream &Config);
00170 static int   xexpdo(char *path, int popt=0);
00171 static int   xfsl(XrdOucStream &Config);
00172 static int   xpidf(XrdOucStream &Config);
00173 static int   xprep(XrdOucStream &Config);
00174 static int   xlog(XrdOucStream &Config);
00175 static int   xmon(XrdOucStream &Config);
00176 static int   xred(XrdOucStream &Config);
00177 static void  xred_set(RD_func func, const char *rHost, int rPort);
00178 static int   xsecl(XrdOucStream &Config);
00179 static int   xtrace(XrdOucStream &Config);
00180 
00181 static XrdObjectQ<XrdXrootdProtocol> ProtStack;
00182 XrdObject<XrdXrootdProtocol>         ProtLink;
00183 
00184 protected:
00185 
00186 static XrdXrootdXPath        RPList;    // Redirected paths
00187 static XrdXrootdXPath        XPList;    // Exported   paths
00188 static XrdSfsFileSystem     *osFS;      // The filesystem
00189 static XrdSecService        *CIA;       // Authentication Server
00190 static XrdXrootdFileLock    *Locker;    // File lock handler
00191 static XrdScheduler         *Sched;     // System scheduler
00192 static XrdBuffManager       *BPool;     // Buffer manager
00193 static XrdSysError           eDest;     // Error message handler
00194 static const char           *myInst;
00195 static const char           *TraceID;
00196 static       char           *pidPath;
00197 static int                   myPID;
00198 
00199 // Admin control area
00200 //
00201 static XrdNetSocket         *AdminSock;
00202 
00203 // Processing configuration values
00204 //
00205 static int                 hailWait;
00206 static int                 readWait;
00207 static int                 Port;
00208 static int                 Window;
00209 static int                 WANPort;
00210 static int                 WANWindow;
00211 static char               *SecLib;
00212 static char               *FSLib;
00213 static char               *Notify;
00214 static char                isRedir;
00215 static char                chkfsV;
00216 static XrdXrootdJob       *JobCKS;
00217 static char               *JobCKT;
00218 
00219 // Static redirection
00220 //
00221 static struct RD_Table {char *Host; int Port;} Route[RD_Num];
00222 
00223 // async configuration values
00224 //
00225 static int                 as_maxperlnk; // Max async requests per link
00226 static int                 as_maxperreq; // Max async ops per request
00227 static int                 as_maxpersrv; // Max async ops per server
00228 static int                 as_miniosz;   // Min async request size
00229 static int                 as_minsfsz;   // Min sendf request size
00230 static int                 as_segsize;   // Aio quantum (optimal)
00231 static int                 as_maxstalls; // Maximum stalls we will tolerate
00232 static int                 as_force;     // aio to be forced
00233 static int                 as_noaio;     // aio is disabled
00234 static int                 as_nosf;      // sendfile is disabled
00235 static int                 as_syncw;     // writes to be synchronous
00236 static int                 maxBuffsz;    // Maximum buffer size we can have
00237 static int                 maxTransz;    // Maximum transfer size we can have
00238 static const int           maxRvecsz = 1024;   // Maximum read vector size
00239 
00240 // Statistical area
00241 //
00242 static XrdXrootdStats     *SI;
00243 int                        numReads;     // Count
00244 int                        numReadP;     // Count
00245 int                        numWrites;    // Count
00246 int                        numFiles;     // Count
00247 
00248 int                        cumReads;     // Count less numReads
00249 int                        cumReadP;     // Count less numReadP
00250 int                        cumWrites;    // Count less numWrites
00251 long long                  totReadP;     // Bytes
00252 
00253 // Data local to each protocol/link combination
00254 //
00255 XrdLink                   *Link;
00256 XrdBuffer                 *argp;
00257 XrdXrootdFileTable        *FTab;
00258 XrdXrootdMonitor          *Monitor;
00259 kXR_unt32                  monUID;
00260 char                       monFILE;
00261 char                       monIO;
00262 char                       Status;
00263 unsigned char              CapVer;
00264 
00265 // Authentication area
00266 //
00267 XrdSecEntity              *Client;
00268 XrdSecProtocol            *AuthProt;
00269 XrdSecEntity               Entity;
00270 
00271 // Buffer information, used to drive DoIt(), getData(), and (*Resume)()
00272 //
00273 XrdXrootdAioReq           *myAioReq;
00274 char                      *myBuff;
00275 int                        myBlen;
00276 int                        myBlast;
00277 int                       (XrdXrootdProtocol::*Resume)();
00278 XrdXrootdFile             *myFile;
00279 long long                  myOffset;
00280 int                        myIOLen;
00281 int                        myStalls;
00282 
00283 // Buffer resize control area
00284 //
00285 static int                 hcMax;
00286        int                 hcPrev;
00287        int                 hcNext;
00288        int                 hcNow;
00289        int                 halfBSize;
00290 
00291 // This area is used for parallel streams
00292 //
00293 static const int           maxStreams = 16;
00294 XrdSysMutex                streamMutex;
00295 XrdSysSemaphore           *reTry;
00296 XrdXrootdProtocol         *Stream[maxStreams];
00297 unsigned int               mySID;
00298 char                       isActive;
00299 char                       isDead;
00300 char                       isBound;
00301 char                       isNOP;
00302 
00303 static const int           maxPio = 4;
00304 XrdXrootdPio              *pioFirst;
00305 XrdXrootdPio              *pioLast;
00306 XrdXrootdPio              *pioFree;
00307 
00308 short                      PathID;
00309 char                       doWrite;
00310 char                       doWriteC;
00311 
00312 // Buffers to handle client requests
00313 //
00314 XrdXrootdReqID             ReqID;
00315 ClientRequest              Request;
00316 XrdXrootdResponse          Response;
00317 };
00318 #endif

Generated on Tue Jul 5 14:47:04 2011 for ROOT_528-00b_version by  doxygen 1.5.1