@@ -36,10 +36,6 @@ EOSFSTNAMESPACE_BEGIN
3636
3737#define NFS_QUOTA_FILE " .nfs.quota"
3838
39- struct nfs_context * NfsIo::gContext = nullptr ;
40- std::mutex NfsIo::gContextMutex ;
41- std::string NfsIo::gMountedPath = " " ;
42-
4339namespace
4440{
4541std::string getAttrPath (std::string path)
@@ -64,30 +60,17 @@ NfsIo::NfsIo(std::string path, XrdFstOfsFile* file, const XrdSecEntity* client)
6460{
6561 eos_debug (" NfsIo::NfsIo called with path=%s" , path.c_str ());
6662
67- // Initialize NFS context
68- std::lock_guard<std::mutex> guard (gContextMutex );
69- if (gContext == nullptr ) {
70- gContext = nfs_init_context ();
71- if (gContext == nullptr ) {
72- eos_err (" msg=\" failed to initialize NFS context\" " );
73- } else {
74- eos_info (" msg=\" NFS context initialized successfully\" " );
75- }
76- }
77-
7863 // ............................................................................
7964 // Prepare the file path
8065 // ............................................................................
81- if (path.find (" nfs:" ) == 0 ) {
82- mFilePath = path.substr (4 ); // Remove "nfs:" prefix
83- } else if (path.find (" /nfs" ) == 0 ) {
84- mFilePath = path;
66+ if (path.find (" nfs:/" ) == 0 ) {
67+ mFilePath = path.substr (5 ); // Remove "nfs:/" prefix
8568 } else {
8669 eos_warning (" msg=\" NFS path does not start with 'nfs:' or '/nfs'\" path=\" %s\" " , path.c_str ());
8770 mFilePath = path;
8871 }
8972
90- eos_info (" msg=\" NfsIo initialized\" original_path=%s, parsed_path=%s" , path.c_str (), mFilePath .c_str ());
73+ eos_debug (" msg=\" NfsIo initialized\" original_path=%s, parsed_path=%s" , path.c_str (), mFilePath .c_str ());
9174
9275 // Standard initialization
9376 mFd = -1 ;
@@ -133,6 +116,19 @@ NfsIo::fileOpen(XrdSfsFileOpenMode flags, mode_t mode, const std::string& opaque
133116
134117 int pflags = 0 ;
135118
119+ XrdOucEnv openEnv (opaque.c_str ());
120+ const char *val;
121+
122+ if ((val = openEnv.Get (" mgm.ioflag" ))) {
123+ if (!strcmp (val, " direct" )) {
124+ pflags |= O_DIRECT;
125+ } else if (!strcmp (val, " sync" )) {
126+ pflags |= O_SYNC;
127+ } else if (!strcmp (val, " dsync" )) {
128+ pflags |= O_DSYNC;
129+ }
130+ }
131+
136132 if (flags & SFS_O_CREAT) {
137133 pflags |= (O_CREAT | O_RDWR);
138134 }
@@ -193,6 +189,7 @@ NfsIo::fileOpen(XrdSfsFileOpenMode flags, mode_t mode, const std::string& opaque
193189std::future<XrdCl::XRootDStatus>
194190NfsIo::fileOpenAsync (XrdSfsFileOpenMode flags, mode_t mode, const std::string& opaque, uint16_t timeout)
195191{
192+ eos_info (" msg=\" opening file asynchronously\" path=\" %s\" " , mFilePath .c_str ());
196193 std::promise<XrdCl::XRootDStatus> open_promise;
197194 std::future<XrdCl::XRootDStatus> open_future = open_promise.get_future ();
198195
435432NfsIo::fileRemove (uint16_t timeout)
436433{
437434 eos_debug (" " );
435+ eos_info (" msg=\" fileRemove called\" path=\" %s\" " , mFilePath .c_str ());
438436
439437 std::string attrPath = xattrPath ();
440- unlink (attrPath.c_str ());
438+ int attr_rc = unlink (attrPath.c_str ());
439+ if (attr_rc == 0 ) {
440+ eos_info (" msg=\" deleted attribute file\" path=\" %s\" " , attrPath.c_str ());
441+ } else if (errno != ENOENT) {
442+ eos_warning (" msg=\" failed to delete attribute file\" path=\" %s\" errno=%d error=\" %s\" " , attrPath.c_str (), errno, strerror (errno));
443+ }
441444
442445 int rc = unlink (mFilePath .c_str ());
443446 if (-1 == rc) {
473476NfsIo::fileDelete (const char * path)
474477{
475478 eos_debug (" " );
476- eos_info (" path=\" %s\" " , path);
479+
480+ // Delete xattr file
481+ std::string attrPath = getAttrPath (std::string (path));
482+ int attr_rc = unlink (attrPath.c_str ());
483+ if (attr_rc == 0 ) {
484+ eos_info (" msg=\" deleted attribute file\" path=\" %s\" " , attrPath.c_str ());
485+ } else if (errno != ENOENT) {
486+ eos_warning (" msg=\" failed to delete attribute file\" path=\" %s\" errno=%d error=\" %s\" " , attrPath.c_str (), errno, strerror (errno));
487+ }
488+
489+ // Delete the main file
477490 int rc = unlink (path);
478491
479492 if (-1 == rc) {
@@ -639,6 +652,14 @@ NfsIo::flushAttrFile()
639652 return 0 ;
640653 }
641654
655+ // Skip flush if main file is missing
656+ struct stat stMain;
657+ if (stat (mFilePath .c_str (), &stMain) != 0 && errno == ENOENT) {
658+ mAttrDirty = false ;
659+ mAttrLoaded = false ;
660+ return 0 ;
661+ }
662+
642663 std::string attrPath = xattrPath ();
643664 std::string content = mFileMap .Trim ();
644665
0 commit comments