Skip to content

Commit 0a9b00e

Browse files
Paulo AlcantaraSteve French
authored andcommitted
smb: client: get rid of TCP_Server_Info::refpath_lock
TCP_Server_Info::leaf_fullpath is allocated in cifs_get_tcp_session() and never changed afterwards, so there is no need to serialize its access. Signed-off-by: Paulo Alcantara (Red Hat) <pc@manguebit.com> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 2948f0d commit 0a9b00e

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

fs/smb/client/cifsglob.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -811,18 +811,9 @@ struct TCP_Server_Info {
811811
bool use_swn_dstaddr;
812812
struct sockaddr_storage swn_dstaddr;
813813
#endif
814-
struct mutex refpath_lock; /* protects leaf_fullpath */
815814
/*
816-
* leaf_fullpath: Canonical DFS referral path related to this
817-
* connection.
818-
* It is used in DFS cache refresher, reconnect and may
819-
* change due to nested DFS links.
820-
*
821-
* Protected by @refpath_lock and @srv_lock. The @refpath_lock is
822-
* mostly used for not requiring a copy of @leaf_fullpath when getting
823-
* cached or new DFS referrals (which might also sleep during I/O).
824-
* While @srv_lock is held for making string and NULL comparisons against
825-
* both fields as in mount(2) and cache refresh.
815+
* Canonical DFS referral path used in cifs_reconnect() for failover as
816+
* well as in DFS cache refresher.
826817
*
827818
* format: \\HOST\SHARE[\OPTIONAL PATH]
828819
*/

fs/smb/client/connect.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ static int reconnect_target_locked(struct TCP_Server_Info *server,
492492
static int reconnect_dfs_server(struct TCP_Server_Info *server)
493493
{
494494
struct dfs_cache_tgt_iterator *target_hint = NULL;
495-
495+
const char *ref_path = server->leaf_fullpath + 1;
496496
DFS_CACHE_TGT_LIST(tl);
497497
int num_targets = 0;
498498
int rc = 0;
@@ -505,10 +505,8 @@ static int reconnect_dfs_server(struct TCP_Server_Info *server)
505505
* through /proc/fs/cifs/dfscache or the target list is empty due to server settings after
506506
* refreshing the referral, so, in this case, default it to 1.
507507
*/
508-
mutex_lock(&server->refpath_lock);
509-
if (!dfs_cache_noreq_find(server->leaf_fullpath + 1, NULL, &tl))
508+
if (!dfs_cache_noreq_find(ref_path, NULL, &tl))
510509
num_targets = dfs_cache_get_nr_tgts(&tl);
511-
mutex_unlock(&server->refpath_lock);
512510
if (!num_targets)
513511
num_targets = 1;
514512

@@ -552,9 +550,7 @@ static int reconnect_dfs_server(struct TCP_Server_Info *server)
552550
mod_delayed_work(cifsiod_wq, &server->reconnect, 0);
553551
} while (server->tcpStatus == CifsNeedReconnect);
554552

555-
mutex_lock(&server->refpath_lock);
556-
dfs_cache_noreq_update_tgthint(server->leaf_fullpath + 1, target_hint);
557-
mutex_unlock(&server->refpath_lock);
553+
dfs_cache_noreq_update_tgthint(ref_path, target_hint);
558554
dfs_cache_free_tgts(&tl);
559555

560556
/* Need to set up echo worker again once connection has been established */
@@ -569,13 +565,8 @@ static int reconnect_dfs_server(struct TCP_Server_Info *server)
569565

570566
int cifs_reconnect(struct TCP_Server_Info *server, bool mark_smb_session)
571567
{
572-
mutex_lock(&server->refpath_lock);
573-
if (!server->leaf_fullpath) {
574-
mutex_unlock(&server->refpath_lock);
568+
if (!server->leaf_fullpath)
575569
return __cifs_reconnect(server, mark_smb_session);
576-
}
577-
mutex_unlock(&server->refpath_lock);
578-
579570
return reconnect_dfs_server(server);
580571
}
581572
#else
@@ -1754,9 +1745,6 @@ cifs_get_tcp_session(struct smb3_fs_context *ctx,
17541745
INIT_DELAYED_WORK(&tcp_ses->echo, cifs_echo_request);
17551746
INIT_DELAYED_WORK(&tcp_ses->reconnect, smb2_reconnect_server);
17561747
mutex_init(&tcp_ses->reconnect_mutex);
1757-
#ifdef CONFIG_CIFS_DFS_UPCALL
1758-
mutex_init(&tcp_ses->refpath_lock);
1759-
#endif
17601748
memcpy(&tcp_ses->srcaddr, &ctx->srcaddr,
17611749
sizeof(tcp_ses->srcaddr));
17621750
memcpy(&tcp_ses->dstaddr, &ctx->dstaddr,

fs/smb/client/dfs_cache.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,13 +1141,11 @@ static char *get_ses_refpath(struct cifs_ses *ses)
11411141
struct TCP_Server_Info *server = ses->server;
11421142
char *path = ERR_PTR(-ENOENT);
11431143

1144-
mutex_lock(&server->refpath_lock);
11451144
if (server->leaf_fullpath) {
1146-
path = kstrdup(server->leaf_fullpath + 1, GFP_ATOMIC);
1145+
path = kstrdup(server->leaf_fullpath + 1, GFP_KERNEL);
11471146
if (!path)
11481147
path = ERR_PTR(-ENOMEM);
11491148
}
1150-
mutex_unlock(&server->refpath_lock);
11511149
return path;
11521150
}
11531151

0 commit comments

Comments
 (0)