From 05a74f066636187a70ca4e8e41fc1e172623fcbb Mon Sep 17 00:00:00 2001 From: Derek Weitzel Date: Wed, 1 Jul 2020 20:44:14 -0500 Subject: [PATCH 1/2] Adding fbuff argument to monitoring to restrict maximum size of fstream packet --- src/XrdXrootd/XrdXrootdConfig.cc | 15 +++++++++++++-- src/XrdXrootd/XrdXrootdMonFile.cc | 12 +++++++----- src/XrdXrootd/XrdXrootdMonFile.hh | 5 +++-- src/XrdXrootd/XrdXrootdMonitor.cc | 4 ++-- src/XrdXrootd/XrdXrootdMonitor.hh | 2 +- 5 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/XrdXrootd/XrdXrootdConfig.cc b/src/XrdXrootd/XrdXrootdConfig.cc index 1ec85bf746e..584833bfd03 100644 --- a/src/XrdXrootd/XrdXrootdConfig.cc +++ b/src/XrdXrootd/XrdXrootdConfig.cc @@ -1345,6 +1345,7 @@ int XrdXrootdProtocol::xlog(XrdOucStream &Config) Purpose: Parse directive: monitor [all] [auth] [flush [io] ] [fstat [lfn] [ops] [ssq] [xfr ] + [fbuff ] [ident ] [mbuff ] [rbuff ] [rnums ] [window ] dest [Events] @@ -1362,6 +1363,7 @@ int XrdXrootdProtocol::xlog(XrdOucStream &Config) ssq - computes the sum of squares for the ops rec xfr - inserts i/o stats for open files every *. Minimum is 1. + fbuff size of message buffer for file stream monitoring. ident time (seconds, M, H) between identification records. mbuff size of message buffer for event trace monitoring. rbuff size of message buffer for redirection monitoring. @@ -1389,7 +1391,7 @@ int XrdXrootdProtocol::xmon(XrdOucStream &Config) }; char *val = 0, *cp, *monDest[2] = {0, 0}; long long tempval; - int i, monFlash = 0, monFlush=0, monMBval=0, monRBval=0, monWWval=0; + int i, monFlash = 0, monFlush=0, monMBval=0, monRBval=0, monWWval=0, monFbuff=0; int monIdent = 3600, xmode=0, monMode[2] = {0, 0}, mrType, *flushDest; int monRnums = 0, monFSint = 0, monFSopt = 0, monFSion = 0; int haveWord = 0; @@ -1441,6 +1443,15 @@ int XrdXrootdProtocol::xmon(XrdOucStream &Config) if (mrType) monRBval = static_cast(tempval); else monMBval = static_cast(tempval); } + else if (!strcmp("fbuff", val)) + {if (!(val = Config.GetWord())) + {eDest.Emsg("Config", "monitor fbuff value not specified"); + return 1; + } + if (XrdOuca2x::a2sz(eDest,"monitor fbuff", val, + &tempval, 1024, 65536)) return 1; + monFbuff = static_cast(tempval); + } else if (!strcmp("ident", val)) {if (!(val = Config.GetWord())) {eDest.Emsg("Config", "monitor ident value not specified"); @@ -1528,7 +1539,7 @@ int XrdXrootdProtocol::xmon(XrdOucStream &Config) // Set the monitor defaults // XrdXrootdMonitor::Defaults(monMBval, monRBval, monWWval, - monFlush, monFlash, monIdent, monRnums, + monFlush, monFlash, monIdent, monRnums, monFbuff, monFSint, monFSopt, monFSion); if (monDest[0]) monMode[0] |= (monMode[0] ? xmode : XROOTD_MON_FILE|xmode); diff --git a/src/XrdXrootd/XrdXrootdMonFile.cc b/src/XrdXrootd/XrdXrootdMonFile.cc index dbe63106bf3..c9948d47fb5 100644 --- a/src/XrdXrootd/XrdXrootdMonFile.cc +++ b/src/XrdXrootd/XrdXrootdMonFile.cc @@ -71,6 +71,7 @@ int XrdXrootdMonFile::repTime = 0; int XrdXrootdMonFile::fmHWM =-1; int XrdXrootdMonFile::crecSize = 0; int XrdXrootdMonFile::xfrCnt = 0; +int XrdXrootdMonFile::fBuff = 65472; int XrdXrootdMonFile::xfrRem = 0; XrdXrootdMonFileXFR XrdXrootdMonFile::xfrRec; short XrdXrootdMonFile::crecNLen = 0; @@ -174,7 +175,7 @@ void XrdXrootdMonFile::Close(XrdXrootdFileStats *fsP, bool isDisc) /* D e f a u l t s */ /******************************************************************************/ -void XrdXrootdMonFile::Defaults(int intv, int opts, int xfrcnt) +void XrdXrootdMonFile::Defaults(int intv, int opts, int xfrcnt, int fbuff) { // Set the reporting interval and I/O counter @@ -182,6 +183,7 @@ void XrdXrootdMonFile::Defaults(int intv, int opts, int xfrcnt) repTime = intv; xfrCnt = xfrcnt; xfrRem = xfrcnt; + fBuff = fbuff; // Expand out the options // @@ -319,15 +321,15 @@ void XrdXrootdMonFile::DoXFR(XrdXrootdFileStats *fsP) /* I n i t */ /******************************************************************************/ -bool XrdXrootdMonFile::Init(int bfsz) +bool XrdXrootdMonFile::Init() { XrdXrootdMonFile *mfP; int alignment, pagsz = getpagesize(); // Allocate a socket buffer // - alignment = (bfsz < pagsz ? 1024 : pagsz); - if (posix_memalign((void **)&repBuff, alignment, bfsz)) + alignment = (fBuff < pagsz ? 1024 : pagsz); + if (posix_memalign((void **)&repBuff, alignment, fBuff)) {XrdXrootdMonInfo::eDest->Emsg("MonFile", "Unable to allocate monitor buffer."); return false; } @@ -353,7 +355,7 @@ bool XrdXrootdMonFile::Init(int bfsz) // Calculate the end nut the next slot always starts with a null pointer // - repLast = repBuff+bfsz-1; + repLast = repBuff+fBuff-1; repNext = 0; // Calculate the close record size and the initial flags diff --git a/src/XrdXrootd/XrdXrootdMonFile.hh b/src/XrdXrootd/XrdXrootdMonFile.hh index 62ab8a5a8bf..eb7180caa5e 100644 --- a/src/XrdXrootd/XrdXrootdMonFile.hh +++ b/src/XrdXrootd/XrdXrootdMonFile.hh @@ -45,13 +45,13 @@ public: static void Close(XrdXrootdFileStats *fsP, bool isDisc=false); -static void Defaults(int intv, int opts, int iocnt); +static void Defaults(int intv, int opts, int iocnt, int fbuff); static void Disc(unsigned int usrID); void DoIt(); -static bool Init(int bfsz=65472); +static bool Init(); static void Open(XrdXrootdFileStats *fsP, const char *Path, unsigned int uDID, bool isRW); @@ -83,6 +83,7 @@ static int repTime; static int fmHWM; static int crecSize; static int xfrCnt; +static int fBuff; static int xfrRem; static XrdXrootdMonFileXFR xfrRec; static short crecNLen; diff --git a/src/XrdXrootd/XrdXrootdMonitor.cc b/src/XrdXrootd/XrdXrootdMonitor.cc index 66b859f1384..27dbba11219 100644 --- a/src/XrdXrootd/XrdXrootdMonitor.cc +++ b/src/XrdXrootd/XrdXrootdMonitor.cc @@ -452,7 +452,7 @@ void XrdXrootdMonitor::Defaults(char *dest1, int mode1, char *dest2, int mode2) void XrdXrootdMonitor::Defaults(int msz, int rsz, int wsz, int flush, int flash, int idt, int rnm, - int fsint, int fsopt, int fsion) + int fbuff, int fsint, int fsopt, int fsion) { // Set default window size and flush time @@ -467,7 +467,7 @@ void XrdXrootdMonitor::Defaults(int msz, int rsz, int wsz, // Set the fstat defaults // - XrdXrootdMonFile::Defaults(fsint, fsopt, fsion); + XrdXrootdMonFile::Defaults(fsint, fsopt, fsion, fbuff); monFSTAT = fsint != 0; // Set default monitor buffer size diff --git a/src/XrdXrootd/XrdXrootdMonitor.hh b/src/XrdXrootd/XrdXrootdMonitor.hh index 04557960be8..c6693cae6eb 100644 --- a/src/XrdXrootd/XrdXrootdMonitor.hh +++ b/src/XrdXrootd/XrdXrootdMonitor.hh @@ -114,7 +114,7 @@ inline void Add_wr(kXR_unt32 dictid, static void Defaults(char *dest1, int m1, char *dest2, int m2); static void Defaults(int msz, int rsz, int wsz, int flush, int flash, int iDent, int rnm, - int fsint=0, int fsopt=0, int fsion=0); + int fbuff, int fsint=0, int fsopt=0, int fsion=0); static int Flushing() {return autoFlush;} From ffa0decc89f033c93a3d4a4d2c09868572b9498c Mon Sep 17 00:00:00 2001 From: Derek Weitzel Date: Thu, 2 Jul 2020 12:13:11 -0500 Subject: [PATCH 2/2] Change names to fbsz --- src/XrdXrootd/XrdXrootdConfig.cc | 16 ++++++++-------- src/XrdXrootd/XrdXrootdMonFile.cc | 12 ++++++------ src/XrdXrootd/XrdXrootdMonFile.hh | 4 ++-- src/XrdXrootd/XrdXrootdMonitor.cc | 4 ++-- src/XrdXrootd/XrdXrootdMonitor.hh | 2 +- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/XrdXrootd/XrdXrootdConfig.cc b/src/XrdXrootd/XrdXrootdConfig.cc index 584833bfd03..c5735efb9c1 100644 --- a/src/XrdXrootd/XrdXrootdConfig.cc +++ b/src/XrdXrootd/XrdXrootdConfig.cc @@ -1363,7 +1363,7 @@ int XrdXrootdProtocol::xlog(XrdOucStream &Config) ssq - computes the sum of squares for the ops rec xfr - inserts i/o stats for open files every *. Minimum is 1. - fbuff size of message buffer for file stream monitoring. + fbsz size of message buffer for file stream monitoring. ident time (seconds, M, H) between identification records. mbuff size of message buffer for event trace monitoring. rbuff size of message buffer for redirection monitoring. @@ -1391,7 +1391,7 @@ int XrdXrootdProtocol::xmon(XrdOucStream &Config) }; char *val = 0, *cp, *monDest[2] = {0, 0}; long long tempval; - int i, monFlash = 0, monFlush=0, monMBval=0, monRBval=0, monWWval=0, monFbuff=0; + int i, monFlash = 0, monFlush=0, monMBval=0, monRBval=0, monWWval=0, monFbsz=0; int monIdent = 3600, xmode=0, monMode[2] = {0, 0}, mrType, *flushDest; int monRnums = 0, monFSint = 0, monFSopt = 0, monFSion = 0; int haveWord = 0; @@ -1443,14 +1443,14 @@ int XrdXrootdProtocol::xmon(XrdOucStream &Config) if (mrType) monRBval = static_cast(tempval); else monMBval = static_cast(tempval); } - else if (!strcmp("fbuff", val)) + else if (!strcmp("fbsz", val)) {if (!(val = Config.GetWord())) - {eDest.Emsg("Config", "monitor fbuff value not specified"); + {eDest.Emsg("Config", "monitor fbsz value not specified"); return 1; } - if (XrdOuca2x::a2sz(eDest,"monitor fbuff", val, - &tempval, 1024, 65536)) return 1; - monFbuff = static_cast(tempval); + if (XrdOuca2x::a2sz(eDest,"monitor fbsz", val, + &tempval, 1024, 65472)) return 1; + monFbsz = static_cast(tempval); } else if (!strcmp("ident", val)) {if (!(val = Config.GetWord())) @@ -1539,7 +1539,7 @@ int XrdXrootdProtocol::xmon(XrdOucStream &Config) // Set the monitor defaults // XrdXrootdMonitor::Defaults(monMBval, monRBval, monWWval, - monFlush, monFlash, monIdent, monRnums, monFbuff, + monFlush, monFlash, monIdent, monRnums, monFbsz, monFSint, monFSopt, monFSion); if (monDest[0]) monMode[0] |= (monMode[0] ? xmode : XROOTD_MON_FILE|xmode); diff --git a/src/XrdXrootd/XrdXrootdMonFile.cc b/src/XrdXrootd/XrdXrootdMonFile.cc index c9948d47fb5..00d04e6c36c 100644 --- a/src/XrdXrootd/XrdXrootdMonFile.cc +++ b/src/XrdXrootd/XrdXrootdMonFile.cc @@ -71,7 +71,7 @@ int XrdXrootdMonFile::repTime = 0; int XrdXrootdMonFile::fmHWM =-1; int XrdXrootdMonFile::crecSize = 0; int XrdXrootdMonFile::xfrCnt = 0; -int XrdXrootdMonFile::fBuff = 65472; +int XrdXrootdMonFile::fBsz = 65472; int XrdXrootdMonFile::xfrRem = 0; XrdXrootdMonFileXFR XrdXrootdMonFile::xfrRec; short XrdXrootdMonFile::crecNLen = 0; @@ -175,7 +175,7 @@ void XrdXrootdMonFile::Close(XrdXrootdFileStats *fsP, bool isDisc) /* D e f a u l t s */ /******************************************************************************/ -void XrdXrootdMonFile::Defaults(int intv, int opts, int xfrcnt, int fbuff) +void XrdXrootdMonFile::Defaults(int intv, int opts, int xfrcnt, int fbsz) { // Set the reporting interval and I/O counter @@ -183,7 +183,7 @@ void XrdXrootdMonFile::Defaults(int intv, int opts, int xfrcnt, int fbuff) repTime = intv; xfrCnt = xfrcnt; xfrRem = xfrcnt; - fBuff = fbuff; + fBsz = (fbsz <= 0 ? 65472 : fbsz); // Expand out the options // @@ -328,8 +328,8 @@ bool XrdXrootdMonFile::Init() // Allocate a socket buffer // - alignment = (fBuff < pagsz ? 1024 : pagsz); - if (posix_memalign((void **)&repBuff, alignment, fBuff)) + alignment = (fBsz < pagsz ? 1024 : pagsz); + if (posix_memalign((void **)&repBuff, alignment, fBsz)) {XrdXrootdMonInfo::eDest->Emsg("MonFile", "Unable to allocate monitor buffer."); return false; } @@ -355,7 +355,7 @@ bool XrdXrootdMonFile::Init() // Calculate the end nut the next slot always starts with a null pointer // - repLast = repBuff+fBuff-1; + repLast = repBuff+fBsz-1; repNext = 0; // Calculate the close record size and the initial flags diff --git a/src/XrdXrootd/XrdXrootdMonFile.hh b/src/XrdXrootd/XrdXrootdMonFile.hh index eb7180caa5e..fc5fad2e0f0 100644 --- a/src/XrdXrootd/XrdXrootdMonFile.hh +++ b/src/XrdXrootd/XrdXrootdMonFile.hh @@ -45,7 +45,7 @@ public: static void Close(XrdXrootdFileStats *fsP, bool isDisc=false); -static void Defaults(int intv, int opts, int iocnt, int fbuff); +static void Defaults(int intv, int opts, int iocnt, int fbsz); static void Disc(unsigned int usrID); @@ -83,7 +83,7 @@ static int repTime; static int fmHWM; static int crecSize; static int xfrCnt; -static int fBuff; +static int fBsz; static int xfrRem; static XrdXrootdMonFileXFR xfrRec; static short crecNLen; diff --git a/src/XrdXrootd/XrdXrootdMonitor.cc b/src/XrdXrootd/XrdXrootdMonitor.cc index 27dbba11219..3f8d356383d 100644 --- a/src/XrdXrootd/XrdXrootdMonitor.cc +++ b/src/XrdXrootd/XrdXrootdMonitor.cc @@ -452,7 +452,7 @@ void XrdXrootdMonitor::Defaults(char *dest1, int mode1, char *dest2, int mode2) void XrdXrootdMonitor::Defaults(int msz, int rsz, int wsz, int flush, int flash, int idt, int rnm, - int fbuff, int fsint, int fsopt, int fsion) + int fbsz, int fsint, int fsopt, int fsion) { // Set default window size and flush time @@ -467,7 +467,7 @@ void XrdXrootdMonitor::Defaults(int msz, int rsz, int wsz, // Set the fstat defaults // - XrdXrootdMonFile::Defaults(fsint, fsopt, fsion, fbuff); + XrdXrootdMonFile::Defaults(fsint, fsopt, fsion, fbsz); monFSTAT = fsint != 0; // Set default monitor buffer size diff --git a/src/XrdXrootd/XrdXrootdMonitor.hh b/src/XrdXrootd/XrdXrootdMonitor.hh index c6693cae6eb..7ba3a9883ab 100644 --- a/src/XrdXrootd/XrdXrootdMonitor.hh +++ b/src/XrdXrootd/XrdXrootdMonitor.hh @@ -114,7 +114,7 @@ inline void Add_wr(kXR_unt32 dictid, static void Defaults(char *dest1, int m1, char *dest2, int m2); static void Defaults(int msz, int rsz, int wsz, int flush, int flash, int iDent, int rnm, - int fbuff, int fsint=0, int fsopt=0, int fsion=0); + int fbsz, int fsint=0, int fsopt=0, int fsion=0); static int Flushing() {return autoFlush;}