Skip to content

Commit a091d97

Browse files
Wang Zhaolongsmfrench
authored andcommitted
smb:client: smb: client: Add reverse mapping from tcon to superblocks
Currently, when a SMB connection is reset and renegotiated with the server, there's no way to update all related mount points with new negotiated sizes. This is because while superblocks (cifs_sb_info) maintain references to tree connections (tcon) through tcon_link structures, there is no reverse mapping from a tcon back to all the superblocks using it. This patch adds a bidirectional relationship between tcon and cifs_sb_info structures by: 1. Adding a cifs_sb_list to tcon structure with appropriate locking 2. Adding tcon_sb_link to cifs_sb_info to join the list 3. Managing the list entries during mount and umount operations The bidirectional relationship enables future functionality to locate and update all superblocks connected to a specific tree connection, such as: - Updating negotiated parameters after reconnection - Efficiently notifying all affected mounts of capability changes This is the first part of a series to improve connection resilience by keeping all mount parameters in sync with server capabilities after reconnection. Signed-off-by: Wang Zhaolong <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent be5d361 commit a091d97

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

fs/smb/client/cifs_fs_sb.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949

5050
struct cifs_sb_info {
5151
struct rb_root tlink_tree;
52+
struct list_head tcon_sb_link;
5253
spinlock_t tlink_tree_lock;
5354
struct tcon_link *master_tlink;
5455
struct nls_table *local_nls;

fs/smb/client/cifsglob.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,8 @@ struct cifs_tcon {
13211321
#endif
13221322
struct list_head pending_opens; /* list of incomplete opens */
13231323
struct cached_fids *cfids;
1324-
/* BB add field for back pointer to sb struct(s)? */
1324+
struct list_head cifs_sb_list;
1325+
spinlock_t sb_list_lock;
13251326
#ifdef CONFIG_CIFS_DFS_UPCALL
13261327
struct delayed_work dfs_cache_work;
13271328
struct list_head dfs_ses_list;

fs/smb/client/connect.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3477,6 +3477,7 @@ int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb)
34773477
struct smb3_fs_context *ctx = cifs_sb->ctx;
34783478

34793479
INIT_DELAYED_WORK(&cifs_sb->prune_tlinks, cifs_prune_tlinks);
3480+
INIT_LIST_HEAD(&cifs_sb->tcon_sb_link);
34803481

34813482
spin_lock_init(&cifs_sb->tlink_tree_lock);
34823483
cifs_sb->tlink_tree = RB_ROOT;
@@ -3709,6 +3710,10 @@ static int mount_setup_tlink(struct cifs_sb_info *cifs_sb, struct cifs_ses *ses,
37093710
tlink_rb_insert(&cifs_sb->tlink_tree, tlink);
37103711
spin_unlock(&cifs_sb->tlink_tree_lock);
37113712

3713+
spin_lock(&tcon->sb_list_lock);
3714+
list_add(&cifs_sb->tcon_sb_link, &tcon->cifs_sb_list);
3715+
spin_unlock(&tcon->sb_list_lock);
3716+
37123717
queue_delayed_work(cifsiod_wq, &cifs_sb->prune_tlinks,
37133718
TLINK_IDLE_EXPIRE);
37143719
return 0;
@@ -4050,9 +4055,19 @@ cifs_umount(struct cifs_sb_info *cifs_sb)
40504055
struct rb_root *root = &cifs_sb->tlink_tree;
40514056
struct rb_node *node;
40524057
struct tcon_link *tlink;
4058+
struct cifs_tcon *tcon = NULL;
40534059

40544060
cancel_delayed_work_sync(&cifs_sb->prune_tlinks);
40554061

4062+
if (cifs_sb->master_tlink) {
4063+
tcon = cifs_sb->master_tlink->tl_tcon;
4064+
if (tcon) {
4065+
spin_lock(&tcon->sb_list_lock);
4066+
list_del_init(&cifs_sb->tcon_sb_link);
4067+
spin_unlock(&tcon->sb_list_lock);
4068+
}
4069+
}
4070+
40564071
spin_lock(&cifs_sb->tlink_tree_lock);
40574072
while ((node = rb_first(root))) {
40584073
tlink = rb_entry(node, struct tcon_link, tl_rbnode);

fs/smb/client/misc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,10 @@ tcon_info_alloc(bool dir_leases_enabled, enum smb3_tcon_ref_trace trace)
137137
spin_lock_init(&ret_buf->tc_lock);
138138
INIT_LIST_HEAD(&ret_buf->openFileList);
139139
INIT_LIST_HEAD(&ret_buf->tcon_list);
140+
INIT_LIST_HEAD(&ret_buf->cifs_sb_list);
140141
spin_lock_init(&ret_buf->open_file_lock);
141142
spin_lock_init(&ret_buf->stat_lock);
143+
spin_lock_init(&ret_buf->sb_list_lock);
142144
atomic_set(&ret_buf->num_local_opens, 0);
143145
atomic_set(&ret_buf->num_remote_opens, 0);
144146
ret_buf->stats_from_time = ktime_get_real_seconds();

0 commit comments

Comments
 (0)