Skip to content

Commit 7f3f94c

Browse files
committed
FST: Update read conversion to support NFS backend - namely the local file rename
functionality which is used as part of the conversion process.
1 parent 12945ec commit 7f3f94c

7 files changed

Lines changed: 246 additions & 63 deletions

File tree

fst/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ set_target_properties(Jerasure-Objects PROPERTIES
128128
#-------------------------------------------------------------------------------
129129
add_library(EosFstIo-Objects OBJECT
130130
# File IO interface
131-
io/FileIo.hh
131+
io/FileIo.cc io/FileIo.hh
132132
io/local/FsIo.cc io/local/FsIo.hh
133133
io/davix/DavixIo.cc io/davix/DavixIo.hh
134134
io/nfs/NfsIo.cc io/nfs/NfsIo.hh

fst/XrdFstOfs.cc

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
#include "fst/Deletion.hh"
3434
#include "fst/Verify.hh"
3535
#include "fst/utils/XrdOfsPathHandler.hh"
36+
#ifdef HAVE_NFS
37+
#include "fst/io/nfs/NfsIo.hh"
38+
#endif
3639
#include "common/Utils.hh"
3740
#include "common/PasswordHandler.hh"
3841
#include "common/FileId.hh"
@@ -659,8 +662,9 @@ XrdFstOfs::Configure(XrdSysError& Eroute, XrdOucEnv* envP)
659662
"an absolute path like /etc/grid-security/jwt-token-grpc");
660663
NoGo = 1;
661664
} else {
662-
gConfig.JwtTokenPath = val;
665+
gConfig.JwtTokenPath = val;
663666
}
667+
664668
Eroute.Say("=====> fstofs.jwttokenpath : ", val);
665669
}
666670

@@ -1768,7 +1772,7 @@ XrdFstOfs::FSctl(const int cmd, XrdSfsFSctl& args, XrdOucErrInfo& error,
17681772
// Check that new path doesn't exist already
17691773
struct stat info;
17701774

1771-
if (::stat(new_path.c_str(), &info) == 0) {
1775+
if (FileIo::fsStat(new_path.c_str(), info) == 0) {
17721776
eos_static_err("msg=\"new path already exists on filesystem\" "
17731777
"fsid=%08llx new_path=%s", fsid, new_path.c_str());
17741778
return gOFS.Emsg(epname, error, EEXIST, "do local rename", "");
@@ -1789,12 +1793,12 @@ XrdFstOfs::FSctl(const int cmd, XrdSfsFSctl& args, XrdOucErrInfo& error,
17891793
return gOFS.Emsg(epname, error, EEXIST, "do local rename", "");
17901794
}
17911795

1792-
if (::rename(old_path.c_str(), new_path.c_str())) {
1796+
if (FileIo::fsRename(old_path, new_path) != 0) {
17931797
eos_static_err("msg=\"rename failed\" old_path=%s new_path=%s errno=%d",
17941798
old_path.c_str(), new_path.c_str(), errno);
17951799
return gOFS.Emsg(epname, error, EEXIST, "do local rename", "");
17961800
} else {
1797-
// Update the filemd info to point to the origianl file identifier
1801+
// Update the filemd info to point to the original fille identifier
17981802
if (!mFmdHandler->UpdateFmd(new_path, new_fid)) {
17991803
eos_static_err("msg=\"failed to update fid for the fmd object\" "
18001804
"path=%s new_fid=%08llx", new_path.c_str(), new_fid);
@@ -2075,10 +2079,15 @@ XrdFstOfs::UpdateTpcKeyValidity()
20752079
// Create directory hierarchy
20762080
//------------------------------------------------------------------------------
20772081
bool
2078-
XrdFstOfs::CreateDirHierarchy(const std::string& dir_hierarchy,
2082+
XrdFstOfs::CreateDirHierarchy(std::string dir_hierarchy,
20792083
mode_t mode) const
20802084
{
20812085
struct stat info;
2086+
2087+
if (dir_hierarchy.find("nfs:/") == 0) {
2088+
dir_hierarchy.erase(0, 5);
2089+
}
2090+
20822091
std::string path = "/";
20832092
auto lst_dirs = eos::common::StringTokenizer::split<std::list<std::string>>
20842093
(dir_hierarchy, '/');

fst/XrdFstOfs.hh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,8 +533,7 @@ public:
533533
//!
534534
//! @return true if successful, otherwise false
535535
//----------------------------------------------------------------------------
536-
bool CreateDirHierarchy(const std::string& dir_hierarchy,
537-
mode_t mode) const;
536+
bool CreateDirHierarchy(std::string dir_hierarchy, mode_t mode) const;
538537

539538
//----------------------------------------------------------------------------
540539
//! Handle debug query

fst/io/FileIo.cc

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//------------------------------------------------------------------------------
2+
//! @file FileIo.cc
3+
//! @author Elvin-Alin Sindrilaru <esindril@cern.ch>
4+
//! @brief Abstract class modelling an IO plugin
5+
//------------------------------------------------------------------------------
6+
7+
/************************************************************************
8+
* EOS - the CERN Disk Storage System *
9+
* Copyright (C) 2025 CERN/Switzerland *
10+
* *
11+
* This program is free software: you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation, either version 3 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
* This program is distributed in the hope that it will be useful, *
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19+
* GNU General Public License for more details. *
20+
* *
21+
* You should have received a copy of the GNU General Public License *
22+
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
23+
************************************************************************/
24+
25+
#include "fst/io/FileIo.hh"
26+
#ifdef HAVE_NFS
27+
#include "fst/io/nfs/NfsIo.hh"
28+
#endif
29+
30+
EOSFSTNAMESPACE_BEGIN
31+
32+
//--------------------------------------------------------------------------
33+
//! Rename operation
34+
//--------------------------------------------------------------------------
35+
int FileIo::fsRename(std::string old_path, std::string new_path)
36+
{
37+
if ((old_path.find("nfs:/") == 0) || (new_path.find("nfs:/") == 0)) {
38+
#ifdef HAVE_NFS
39+
return NfsIo::fsRename(old_path, new_path);
40+
#endif
41+
eos_static_crit("%s", "msg=\"no NFS built-in support!\"");
42+
return ENOTSUP;
43+
}
44+
45+
return ::rename(old_path.c_str(), new_path.c_str());
46+
}
47+
48+
EOSFSTNAMESPACE_END

fst/io/FileIo.hh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,32 @@ public:
6565
//--------------------------------------------------------------------------
6666
virtual ~FileIo() {}
6767

68+
//--------------------------------------------------------------------------
69+
//! Get stat information about the file
70+
//!
71+
//! @param path file path (can contain protocol specific info eg. nfs://)
72+
//!
73+
//! @return 0 if successful, otherwise non-zero
74+
//--------------------------------------------------------------------------
75+
static int fsStat(std::string path, struct stat& info)
76+
{
77+
if (path.find("nfs:/") == 0) {
78+
path.erase(0, 5); // remove "nfs:/" prefix
79+
}
80+
81+
return ::stat(path.c_str(), &info);
82+
}
83+
84+
//--------------------------------------------------------------------------
85+
//! Rename operation
86+
//!
87+
//! @param old_path old path
88+
//! @param new_path new path
89+
//!
90+
//! @return 0 if successful, otherwise non-zero
91+
//--------------------------------------------------------------------------
92+
static int fsRename(std::string old_path, std::string new_path);
93+
6894
//--------------------------------------------------------------------------
6995
//! Open file
7096
//!

0 commit comments

Comments
 (0)