diff --git a/src/XrdOss/XrdOssApi.cc b/src/XrdOss/XrdOssApi.cc index 923e366a2d9..f0971573289 100644 --- a/src/XrdOss/XrdOssApi.cc +++ b/src/XrdOss/XrdOssApi.cc @@ -1028,6 +1028,28 @@ int XrdOssFile::Fchmod(mode_t Mode) return (fchmod(fd, Mode) ? -errno : XrdOssOK); } +/******************************************************************************/ +/* F l u s h */ +/******************************************************************************/ + +/* + Function: Flush file pages from the filesyste cacheĀ. + + Output: Returns XrdOssOK upon success and -errno upon failure. +*/ + +void XrdOssFile::Flush() +{ +// This actually only works in Linux so we punt otherwise +// +#if defined(__linux__) + if (fd>= 0) + {fdatasync(fd); + posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED); + } +#endif +} + /******************************************************************************/ /* F s t a t */ /******************************************************************************/ diff --git a/src/XrdOss/XrdOssApi.hh b/src/XrdOss/XrdOssApi.hh index 7cc39fe41df..99e53b1eaa0 100644 --- a/src/XrdOss/XrdOssApi.hh +++ b/src/XrdOss/XrdOssApi.hh @@ -92,6 +92,7 @@ virtual int Close(long long *retsz=0); virtual int Open(const char *, int, mode_t, XrdOucEnv &); int Fchmod(mode_t mode); +void Flush(); int Fstat(struct stat *); int Fsync(); int Fsync(XrdSfsAio *aiop);