Linux CIFS filesystem development
 help / color / mirror / Atom feed
* [PATCH] cifs: Show reason why autodisabling serverino support
@ 2025-06-08 16:44 Pali Rohár
  2025-06-08 20:57 ` Paulo Alcantara
  0 siblings, 1 reply; 14+ messages in thread
From: Pali Rohár @ 2025-06-08 16:44 UTC (permalink / raw)
  To: Steve French, Paulo Alcantara; +Cc: linux-cifs, linux-kernel

Before calling cifs_autodisable_serverino() function, show reason why it
has to be called.

This change allows to debug issues why cifs.ko decide to turn off server
inode number support and hence disable support for detection of hardlinks.

Signed-off-by: Pali Rohár <pali@kernel.org>
Cc: stable@vger.kernel.org
---
 fs/smb/client/connect.c   | 2 ++
 fs/smb/client/dfs_cache.c | 2 ++
 fs/smb/client/inode.c     | 3 +++
 fs/smb/client/readdir.c   | 3 +++
 4 files changed, 10 insertions(+)

diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index 6bf04d9a5491..e2dbf7eaf32a 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -3908,6 +3908,8 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
 	 * After reconnecting to a different server, unique ids won't match anymore, so we disable
 	 * serverino. This prevents dentry revalidation to think the dentry are stale (ESTALE).
 	 */
+	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
+		cifs_dbg(VFS, "Reconnecting to different server, inode numbers won't match anymore\n");
 	cifs_autodisable_serverino(cifs_sb);
 	/*
 	 * Force the use of prefix path to support failover on DFS paths that resolve to targets
diff --git a/fs/smb/client/dfs_cache.c b/fs/smb/client/dfs_cache.c
index 4dada26d56b5..bb5bf9f45557 100644
--- a/fs/smb/client/dfs_cache.c
+++ b/fs/smb/client/dfs_cache.c
@@ -1289,6 +1289,8 @@ int dfs_cache_remount_fs(struct cifs_sb_info *cifs_sb)
 	 * After reconnecting to a different server, unique ids won't match anymore, so we disable
 	 * serverino. This prevents dentry revalidation to think the dentry are stale (ESTALE).
 	 */
+	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
+		cifs_dbg(VFS, "Reconnecting to different server, inode numbers won't match anymore\n");
 	cifs_autodisable_serverino(cifs_sb);
 	/*
 	 * Force the use of prefix path to support failover on DFS paths that resolve to targets
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index cd06598eacbd..c6da25520f29 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -1077,6 +1077,7 @@ static void cifs_set_fattr_ino(int xid, struct cifs_tcon *tcon, struct super_blo
 			fattr->cf_uniqueid = CIFS_I(*inode)->uniqueid;
 		else {
 			fattr->cf_uniqueid = iunique(sb, ROOT_I);
+			cifs_dbg(VFS, "Cannot retrieve inode number for %s: %d\n", full_path, rc);
 			cifs_autodisable_serverino(cifs_sb);
 		}
 		return;
@@ -1530,6 +1531,7 @@ cifs_iget(struct super_block *sb, struct cifs_fattr *fattr)
 			fattr->cf_flags &= ~CIFS_FATTR_INO_COLLISION;
 
 			if (inode_has_hashed_dentries(inode)) {
+				cifs_dbg(VFS, "Inode number collision detected\n");
 				cifs_autodisable_serverino(CIFS_SB(sb));
 				iput(inode);
 				fattr->cf_uniqueid = iunique(sb, ROOT_I);
@@ -1597,6 +1599,7 @@ struct inode *cifs_root_iget(struct super_block *sb)
 	if (!rc) {
 		if (fattr.cf_flags & CIFS_FATTR_JUNCTION) {
 			fattr.cf_flags &= ~CIFS_FATTR_JUNCTION;
+			cifs_dbg(VFS, "Cannot retrieve attributes for junction point %s: %d\n", path, rc);
 			cifs_autodisable_serverino(cifs_sb);
 		}
 		inode = cifs_iget(sb, &fattr);
diff --git a/fs/smb/client/readdir.c b/fs/smb/client/readdir.c
index 787d6bcb5d1d..1235b5bf9814 100644
--- a/fs/smb/client/readdir.c
+++ b/fs/smb/client/readdir.c
@@ -413,6 +413,7 @@ _initiate_cifs_search(const unsigned int xid, struct file *file,
 		cifsFile->invalidHandle = false;
 	} else if ((rc == -EOPNOTSUPP) &&
 		   (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
+		cifs_dbg(VFS, "Cannot retrieve inode number for entries in dir %s: %d\n", full_path, rc);
 		cifs_autodisable_serverino(cifs_sb);
 		goto ffirst_retry;
 	}
@@ -1007,6 +1008,8 @@ static int cifs_filldir(char *find_entry, struct file *file,
 		fattr.cf_uniqueid = de.ino;
 	} else {
 		fattr.cf_uniqueid = iunique(sb, ROOT_I);
+		if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
+			cifs_dbg(VFS, "Cannot retrieve inode number for dir entry %.*s\n", name.len, name.name);
 		cifs_autodisable_serverino(cifs_sb);
 	}
 
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 14+ messages in thread
* [PATCH] cifs: Show reason why autodisabling serverino support
@ 2025-10-09 17:15 Steve French
  0 siblings, 0 replies; 14+ messages in thread
From: Steve French @ 2025-10-09 17:15 UTC (permalink / raw)
  To: CIFS, Paulo Alcantara

[-- Attachment #1: Type: text/plain, Size: 687 bytes --]

Do you remember if any objections to this patch?  Probably slightly
useful for debugging. See attached

    Extend cifs_autodisable_serverino() function to print also text message why
    the function was called.

    The text message is printed just once for mount then autodisabling
    serverino support. Once the serverino support is disabled for mount it will
    not be re-enabled. So those text messages do not cause flooding logs.

    This change allows to debug issues why cifs.ko decide to turn off server
    inode number support and hence disable support for detection of hardlinks.

    Signed-off-by: Pali Rohár <pali@kernel.org>


-- 
Thanks,

Steve

[-- Attachment #2: 0007-cifs-Show-reason-why-autodisabling-serverino-support.patch --]
[-- Type: text/x-patch, Size: 6537 bytes --]

From 769c4012c769ff95678eeea96b9b6a303b7ae94b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pali=20Roh=C3=A1r?= <pali@kernel.org>
Date: Sat, 7 Jun 2025 18:17:15 +0200
Subject: [PATCH 07/16] cifs: Show reason why autodisabling serverino support
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Extend cifs_autodisable_serverino() function to print also text message why
the function was called.

The text message is printed just once for mount then autodisabling
serverino support. Once the serverino support is disabled for mount it will
not be re-enabled. So those text messages do not cause flooding logs.

This change allows to debug issues why cifs.ko decide to turn off server
inode number support and hence disable support for detection of hardlinks.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 fs/smb/client/cifsproto.h | 2 +-
 fs/smb/client/connect.c   | 2 +-
 fs/smb/client/dfs_cache.c | 2 +-
 fs/smb/client/inode.c     | 6 +++---
 fs/smb/client/misc.c      | 6 +++++-
 fs/smb/client/readdir.c   | 4 ++--
 6 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h
index f467b24fd984..789716606192 100644
--- a/fs/smb/client/cifsproto.h
+++ b/fs/smb/client/cifsproto.h
@@ -602,7 +602,7 @@ extern int cifs_do_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
 extern int CIFSGetExtAttr(const unsigned int xid, struct cifs_tcon *tcon,
 			const int netfid, __u64 *pExtAttrBits, __u64 *pMask);
 #endif /* CIFS_ALLOW_INSECURE_LEGACY */
-extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb);
+extern void cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb, const char *reason, int rc);
 extern bool couldbe_mf_symlink(const struct cifs_fattr *fattr);
 extern int check_mf_symlink(unsigned int xid, struct cifs_tcon *tcon,
 			      struct cifs_sb_info *cifs_sb,
diff --git a/fs/smb/client/connect.c b/fs/smb/client/connect.c
index 587845a2452d..42cb7f172af2 100644
--- a/fs/smb/client/connect.c
+++ b/fs/smb/client/connect.c
@@ -3924,7 +3924,7 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx)
 	 * After reconnecting to a different server, unique ids won't match anymore, so we disable
 	 * serverino. This prevents dentry revalidation to think the dentry are stale (ESTALE).
 	 */
-	cifs_autodisable_serverino(cifs_sb);
+	cifs_autodisable_serverino(cifs_sb, "Reconnecting to different server, inode numbers won't match anymore", 0);
 	/*
 	 * Force the use of prefix path to support failover on DFS paths that resolve to targets
 	 * that have different prefix paths.
diff --git a/fs/smb/client/dfs_cache.c b/fs/smb/client/dfs_cache.c
index 4dada26d56b5..c3fe85c31e2b 100644
--- a/fs/smb/client/dfs_cache.c
+++ b/fs/smb/client/dfs_cache.c
@@ -1289,7 +1289,7 @@ int dfs_cache_remount_fs(struct cifs_sb_info *cifs_sb)
 	 * After reconnecting to a different server, unique ids won't match anymore, so we disable
 	 * serverino. This prevents dentry revalidation to think the dentry are stale (ESTALE).
 	 */
-	cifs_autodisable_serverino(cifs_sb);
+	cifs_autodisable_serverino(cifs_sb, "Reconnecting to different server, inode numbers won't match anymore", 0);
 	/*
 	 * Force the use of prefix path to support failover on DFS paths that resolve to targets
 	 * that have different prefix paths.
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index cd06598eacbd..b1c6e3986278 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -1077,7 +1077,7 @@ static void cifs_set_fattr_ino(int xid, struct cifs_tcon *tcon, struct super_blo
 			fattr->cf_uniqueid = CIFS_I(*inode)->uniqueid;
 		else {
 			fattr->cf_uniqueid = iunique(sb, ROOT_I);
-			cifs_autodisable_serverino(cifs_sb);
+			cifs_autodisable_serverino(cifs_sb, "Cannot retrieve inode number via get_srv_inum", rc);
 		}
 		return;
 	}
@@ -1530,7 +1530,7 @@ cifs_iget(struct super_block *sb, struct cifs_fattr *fattr)
 			fattr->cf_flags &= ~CIFS_FATTR_INO_COLLISION;
 
 			if (inode_has_hashed_dentries(inode)) {
-				cifs_autodisable_serverino(CIFS_SB(sb));
+				cifs_autodisable_serverino(CIFS_SB(sb), "Inode number collision detected", 0);
 				iput(inode);
 				fattr->cf_uniqueid = iunique(sb, ROOT_I);
 				goto retry_iget5_locked;
@@ -1597,7 +1597,7 @@ struct inode *cifs_root_iget(struct super_block *sb)
 	if (!rc) {
 		if (fattr.cf_flags & CIFS_FATTR_JUNCTION) {
 			fattr.cf_flags &= ~CIFS_FATTR_JUNCTION;
-			cifs_autodisable_serverino(cifs_sb);
+			cifs_autodisable_serverino(cifs_sb, "Cannot retrieve attributes for junction point", rc);
 		}
 		inode = cifs_iget(sb, &fattr);
 	}
diff --git a/fs/smb/client/misc.c b/fs/smb/client/misc.c
index da23cc12a52c..52f5bd6839ee 100644
--- a/fs/smb/client/misc.c
+++ b/fs/smb/client/misc.c
@@ -558,7 +558,7 @@ dump_smb(void *buf, int smb_buf_length)
 }
 
 void
-cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb)
+cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb, const char *reason, int rc)
 {
 	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
 		struct cifs_tcon *tcon = NULL;
@@ -568,6 +568,10 @@ cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb)
 
 		cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM;
 		cifs_sb->mnt_cifs_serverino_autodisabled = true;
+		if (rc)
+			cifs_dbg(VFS, "%s: %d\n", reason, rc);
+		else
+			cifs_dbg(VFS, "%s\n", reason);
 		cifs_dbg(VFS, "Autodisabling the use of server inode numbers on %s\n",
 			 tcon ? tcon->tree_name : "new server");
 		cifs_dbg(VFS, "The server doesn't seem to support them properly or the files might be on different servers (DFS)\n");
diff --git a/fs/smb/client/readdir.c b/fs/smb/client/readdir.c
index 4e5460206397..9060b0b63195 100644
--- a/fs/smb/client/readdir.c
+++ b/fs/smb/client/readdir.c
@@ -414,7 +414,7 @@ _initiate_cifs_search(const unsigned int xid, struct file *file,
 		cifsFile->invalidHandle = false;
 	} else if ((rc == -EOPNOTSUPP) &&
 		   (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) {
-		cifs_autodisable_serverino(cifs_sb);
+		cifs_autodisable_serverino(cifs_sb, "Cannot retrieve inode number via query_dir_first", rc);
 		goto ffirst_retry;
 	}
 error_exit:
@@ -1010,7 +1010,7 @@ static int cifs_filldir(char *find_entry, struct file *file,
 		fattr.cf_uniqueid = de.ino;
 	} else {
 		fattr.cf_uniqueid = iunique(sb, ROOT_I);
-		cifs_autodisable_serverino(cifs_sb);
+		cifs_autodisable_serverino(cifs_sb, "Cannot retrieve inode number", 0);
 	}
 
 	if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) &&
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2025-10-09 17:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-08 16:44 [PATCH] cifs: Show reason why autodisabling serverino support Pali Rohár
2025-06-08 20:57 ` Paulo Alcantara
2025-06-09  3:40   ` Steve French
2025-06-09  7:36     ` Pali Rohár
2025-06-10 15:36       ` Tom Talpey
2025-06-10 16:55         ` Pali Rohár
2025-06-10 17:10           ` Paulo Alcantara
2025-06-10 17:22             ` Pali Rohár
2025-06-10 18:15               ` [PATCH v2] " Pali Rohár
2025-06-17 22:23                 ` Paulo Alcantara
2025-06-17 23:01                   ` Pali Rohár
2025-06-17 23:48                     ` Paulo Alcantara
2025-06-18 21:53                       ` Pali Rohár
  -- strict thread matches above, loose matches on Subject: below --
2025-10-09 17:15 [PATCH] " Steve French

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox