Skip to content

Commit 6e1c1c0

Browse files
sprasad-microsoftSteve French
authored andcommitted
cifs: periodically query network interfaces from server
Currently, we only query the server for network interfaces information at the time of mount, and never afterwards. This can be a problem, especially for services like Azure, where the IP address of the channel endpoints can change over time. With this change, we schedule a 600s polling of this info from the server for each tree connect. An alternative for periodic polling was to do this only at the time of reconnect. But this could delay the reconnect time slightly. Also, there are some challenges w.r.t how we have cifs_reconnect implemented today. Signed-off-by: Shyam Prasad N <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent b54034a commit 6e1c1c0

File tree

4 files changed

+35
-1
lines changed

4 files changed

+35
-1
lines changed

fs/cifs/cifsglob.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
#define SMB_DNS_RESOLVE_INTERVAL_MIN 120
8181
#define SMB_DNS_RESOLVE_INTERVAL_DEFAULT 600
8282

83+
/* smb multichannel query server interfaces interval in seconds */
84+
#define SMB_INTERFACE_POLL_INTERVAL 600
85+
8386
/* maximum number of PDUs in one compound */
8487
#define MAX_COMPOUND 5
8588

@@ -1255,6 +1258,7 @@ struct cifs_tcon {
12551258
#ifdef CONFIG_CIFS_DFS_UPCALL
12561259
struct list_head ulist; /* cache update list */
12571260
#endif
1261+
struct delayed_work query_interfaces; /* query interfaces workqueue job */
12581262
};
12591263

12601264
/*

fs/cifs/cifsproto.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,8 @@ cifs_chan_is_iface_active(struct cifs_ses *ses,
641641
struct TCP_Server_Info *server);
642642
int
643643
cifs_chan_update_iface(struct cifs_ses *ses, struct TCP_Server_Info *server);
644+
int
645+
SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon);
644646

645647
void extract_unc_hostname(const char *unc, const char **h, size_t *len);
646648
int copy_path_name(char *dst, const char *src);

fs/cifs/connect.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,25 @@ static int reconn_set_ipaddr_from_hostname(struct TCP_Server_Info *server)
145145
return rc;
146146
}
147147

148+
static void smb2_query_server_interfaces(struct work_struct *work)
149+
{
150+
int rc;
151+
struct cifs_tcon *tcon = container_of(work,
152+
struct cifs_tcon,
153+
query_interfaces.work);
154+
155+
/*
156+
* query server network interfaces, in case they change
157+
*/
158+
rc = SMB3_request_interfaces(0, tcon);
159+
if (rc) {
160+
cifs_dbg(FYI, "%s: failed to query server interfaces: %d\n",
161+
__func__, rc);
162+
}
163+
164+
queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
165+
(SMB_INTERFACE_POLL_INTERVAL * HZ));
166+
}
148167

149168
static void cifs_resolve_server(struct work_struct *work)
150169
{
@@ -2276,6 +2295,9 @@ cifs_put_tcon(struct cifs_tcon *tcon)
22762295
list_del_init(&tcon->tcon_list);
22772296
spin_unlock(&cifs_tcp_ses_lock);
22782297

2298+
/* cancel polling of interfaces */
2299+
cancel_delayed_work_sync(&tcon->query_interfaces);
2300+
22792301
if (tcon->use_witness) {
22802302
int rc;
22812303

@@ -2513,6 +2535,12 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb3_fs_context *ctx)
25132535
tcon->local_lease = ctx->local_lease;
25142536
INIT_LIST_HEAD(&tcon->pending_opens);
25152537

2538+
/* schedule query interfaces poll */
2539+
INIT_DELAYED_WORK(&tcon->query_interfaces,
2540+
smb2_query_server_interfaces);
2541+
queue_delayed_work(cifsiod_wq, &tcon->query_interfaces,
2542+
(SMB_INTERFACE_POLL_INTERVAL * HZ));
2543+
25162544
spin_lock(&cifs_tcp_ses_lock);
25172545
list_add(&tcon->tcon_list, &ses->tcon_list);
25182546
spin_unlock(&cifs_tcp_ses_lock);

fs/cifs/smb2ops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ parse_server_interfaces(struct network_interface_info_ioctl_rsp *buf,
671671
return rc;
672672
}
673673

674-
static int
674+
int
675675
SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
676676
{
677677
int rc;

0 commit comments

Comments
 (0)