From 6916881f443f67f6893b504fa2171468c8aed915 Mon Sep 17 00:00:00 2001 From: Paulo Alcantara Date: Tue, 13 Dec 2022 01:23:16 -0300 Subject: cifs: fix refresh of cached referrals We can't rely on cifs_tcon::ses to refresh cached referral as the server target might not respond to referrals, e.g. share is not hosted in a DFS root server. Consider the following mount //dom/dfs/link -> /root1/dfs/link -> /fs0/share where fs0 can't get a referral for "/root1/dfs/link". To simplify and fix the access of dfs root sessions, store the dfs root session pointer directly to new sessions so making it easier to select the appropriate ipc connection and use it for failover or cache refresh. Signed-off-by: Paulo Alcantara (SUSE) Signed-off-by: Steve French --- fs/cifs/dfs.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'fs/cifs/dfs.c') diff --git a/fs/cifs/dfs.c b/fs/cifs/dfs.c index 88a0cab335b4..fbc8e880a1fe 100644 --- a/fs/cifs/dfs.c +++ b/fs/cifs/dfs.c @@ -95,7 +95,13 @@ static int get_session(struct cifs_mount_ctx *mnt_ctx, const char *full_path) ctx->leaf_fullpath = (char *)full_path; rc = cifs_mount_get_session(mnt_ctx); ctx->leaf_fullpath = NULL; + if (!rc) { + struct cifs_ses *ses = mnt_ctx->ses; + mutex_lock(&ses->session_mutex); + ses->dfs_root_ses = mnt_ctx->root_ses; + mutex_unlock(&ses->session_mutex); + } return rc; } -- cgit v1.2.3