From 157efb47e8fb0585582550ef6c9ac53d47b5be66 Mon Sep 17 00:00:00 2001 From: Alja Mrak-Tadel Date: Wed, 31 Dec 2014 12:45:20 -0800 Subject: [PATCH 1/2] Propagate XrdPss Remove and Rename actions to OucCache layer. --- src/XrdOuc/XrdOucCache.hh | 9 +++++++++ src/XrdPosix/XrdPosixXrootd.cc | 23 +++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/XrdOuc/XrdOucCache.hh b/src/XrdOuc/XrdOucCache.hh index 5262802bc12..9c8ab408c3b 100644 --- a/src/XrdOuc/XrdOucCache.hh +++ b/src/XrdOuc/XrdOucCache.hh @@ -394,6 +394,15 @@ Debug = 0x0003; // Produce some debug messages (levels 0, 1, 2, or 3) virtual XrdOucCache *Create(Parms &Params, XrdOucCacheIO::aprParms *aprP=0) = 0; +virtual +int Unlink(const char* /*path*/) { return 0; } + +virtual +int Rmdir(const char* /*path*/) { return 0; } + +virtual +int Rename(const char* /*path*/, const char* /*newPath*/) { return 0; } + /* The following holds statistics for the cache itself. It is updated as associated cacheIO objects are deleted and their statistics are added. */ diff --git a/src/XrdPosix/XrdPosixXrootd.cc b/src/XrdPosix/XrdPosixXrootd.cc index e6e6d8b8ceb..0da7741c7fd 100644 --- a/src/XrdPosix/XrdPosixXrootd.cc +++ b/src/XrdPosix/XrdPosixXrootd.cc @@ -745,8 +745,13 @@ int XrdPosixXrootd::Rename(const char *oldpath, const char *newpath) // Issue the rename // - return XrdPosixMap::Result(admin.Xrd.Mv(admin.Url.GetPathWithParams(), - newUrl.GetPathWithParams())); + std::string urlp = admin.Url.GetPathWithParams(); + std::string nurlp = newUrl.GetPathWithParams(); + int res = XrdPosixMap::Result(admin.Xrd.Mv(urlp, nurlp)); + if (!res && myCache) + myCache->Rename(urlp.c_str(), nurlp.c_str()); + + return res; } /******************************************************************************/ @@ -780,7 +785,12 @@ int XrdPosixXrootd::Rmdir(const char *path) // Issue the rmdir // - return XrdPosixMap::Result(admin.Xrd.RmDir(admin.Url.GetPathWithParams())); + std::string urlp = admin.Url.GetPathWithParams(); + int res = XrdPosixMap::Result(admin.Xrd.RmDir(urlp)); + if (!res && myCache) + myCache->Rmdir(urlp.c_str()); + + return res; } /******************************************************************************/ @@ -992,7 +1002,12 @@ int XrdPosixXrootd::Unlink(const char *path) // Issue the UnLink // - return XrdPosixMap::Result(admin.Xrd.Rm(admin.Url.GetPathWithParams())); + std::string urlp = admin.Url.GetPathWithParams(); + int res = XrdPosixMap::Result(admin.Xrd.Rm(urlp)); + if (!res && myCache) + myCache->Unlink(urlp.c_str()); + + return res; } /******************************************************************************/ From cbb85a089d00428072dd4b1fdc96ce72c9e2773c Mon Sep 17 00:00:00 2001 From: Alja Mrak-Tadel Date: Wed, 14 Jan 2015 14:36:55 -0800 Subject: [PATCH 2/2] Propagate Truncate request from posix to cache. --- src/XrdOuc/XrdOucCache.hh | 14 +++++++++++--- src/XrdPosix/XrdPosixXrootd.cc | 10 ++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/XrdOuc/XrdOucCache.hh b/src/XrdOuc/XrdOucCache.hh index 9c8ab408c3b..0fcedc71773 100644 --- a/src/XrdOuc/XrdOucCache.hh +++ b/src/XrdOuc/XrdOucCache.hh @@ -394,14 +394,22 @@ Debug = 0x0003; // Produce some debug messages (levels 0, 1, 2, or 3) virtual XrdOucCache *Create(Parms &Params, XrdOucCacheIO::aprParms *aprP=0) = 0; + +// Propagate Unlink client request from posix layer to cache. +virtual +int Unlink(const char* /*path*/) { return 0; } + +// Propagate Rmdir client request from posix layer to cache. virtual -int Unlink(const char* /*path*/) { return 0; } +int Rmdir(const char* /*path*/) { return 0; } +// Propagate Rename client request from posix layer to cache. virtual -int Rmdir(const char* /*path*/) { return 0; } +int Rename(const char* /*path*/, const char* /*newPath*/) { return 0; } +// Propagate Truncate client request from posix layer to cache. virtual -int Rename(const char* /*path*/, const char* /*newPath*/) { return 0; } +int Truncate(const char* /*path*/, off_t /*size*/) { return 0; } /* The following holds statistics for the cache itself. It is updated as associated cacheIO objects are deleted and their statistics are added. diff --git a/src/XrdPosix/XrdPosixXrootd.cc b/src/XrdPosix/XrdPosixXrootd.cc index 0da7741c7fd..adb17e50378 100644 --- a/src/XrdPosix/XrdPosixXrootd.cc +++ b/src/XrdPosix/XrdPosixXrootd.cc @@ -984,8 +984,14 @@ int XrdPosixXrootd::Truncate(const char *path, off_t Size) // Issue the truncate // - return XrdPosixMap::Result(admin.Xrd.Truncate(admin.Url.GetPathWithParams(), - tSize)); + std::string urlp = admin.Url.GetPathWithParams(); + int res = XrdPosixMap::Result(admin.Xrd.Truncate(urlp,tSize)); + + if (!res && myCache) { + myCache->Truncate(urlp.c_str(), tSize); + } + + return res; } /******************************************************************************/