all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH] fix #4499: prevent superblock read errors for containers on CIFS storage
@ 2025-03-21 10:52 Hugo via pve-devel
  0 siblings, 0 replies; only message in thread
From: Hugo via pve-devel @ 2025-03-21 10:52 UTC (permalink / raw)
  To: pve-devel; +Cc: Hugo

[-- Attachment #1: Type: message/rfc822, Size: 5329 bytes --]

From: Hugo <hugo@pml.blue>
To: pve-devel@lists.proxmox.com
Subject: [PATCH] fix #4499: prevent superblock read errors for containers on CIFS storage
Date: Fri, 21 Mar 2025 11:52:09 +0100
Message-ID: <20250321105209.626382-1-hugo@pml.blue>

Signed-off-by: Hugo <hugo@pml.blue>
---
 src/PVE/Storage/CIFSPlugin.pm | 32 +++++++++++++++++++++++++-------
 1 file changed, 25 insertions(+), 7 deletions(-)

diff --git a/src/PVE/Storage/CIFSPlugin.pm b/src/PVE/Storage/CIFSPlugin.pm
index 475065a..9a8a02c 100644
--- a/src/PVE/Storage/CIFSPlugin.pm
+++ b/src/PVE/Storage/CIFSPlugin.pm
@@ -78,13 +78,17 @@ sub cifs_mount : prototype($$$$$) {
     my $cmd = ['/bin/mount', '-t', 'cifs', $source, $mountpoint, '-o', 'soft', '-o'];
 
     if (my $cred_file = get_cred_file($storeid)) {
-	push @$cmd, "username=$user", '-o', "credentials=$cred_file";
-	push @$cmd, '-o', "domain=$domain" if defined($domain);
+        push @$cmd, "username=$user", '-o', "credentials=$cred_file";
+        push @$cmd, '-o', "domain=$domain" if defined($domain);
     } else {
-	push @$cmd, 'guest,username=guest';
+        push @$cmd, 'guest,username=guest';
     }
 
-    push @$cmd, '-o', defined($smbver) ? "vers=$smbver" : "vers=default";
+    push @$cmd, '-o', defined($smbver) ? "vers=$smbver" : "vers=3.0";
+    
+    # Fix inode issue
+    push @$cmd, '-o', 'noserverino,cache=none,actimeo=0';
+
     push @$cmd, '-o', $options if $options;
 
     run_command($cmd, errmsg => "mount error");
@@ -248,13 +252,27 @@ sub deactivate_storage {
     my ($class, $storeid, $scfg, $cache) = @_;
 
     $cache->{mountdata} = PVE::ProcFSTools::parse_proc_mounts()
-	if !$cache->{mountdata};
+        if !$cache->{mountdata};
 
     my $path = $scfg->{path};
 
     if (cifs_is_mounted($scfg, $cache->{mountdata})) {
-	my $cmd = ['/bin/umount', $path];
-	run_command($cmd, errmsg => 'umount error');
+        system('/bin/sync');
+
+        my $output = `lsof +D $path 2>/dev/null`;
+        if ($output) {
+            warn "Warning: Processes still using CIFS mount at $path. Trying lazy unmount...\n";
+            system('/bin/umount', '-l', $path);
+        } else {
+            system('/bin/umount', $path);
+        }
+
+        
+        sleep 1; # Give time for unmount
+        if (cifs_is_mounted($scfg, PVE::ProcFSTools::parse_proc_mounts())) {
+            warn "Unmount failed, forcing unmount...\n";
+            system('/bin/umount', '-f', $path);
+        }
     }
 }
 
-- 
2.48.1



[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-03-21 10:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-21 10:52 [pve-devel] [PATCH] fix #4499: prevent superblock read errors for containers on CIFS storage Hugo via pve-devel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal