|
| 1 | +cifs: reconnect helper should set reconnect for the right channel |
| 2 | + |
| 3 | +jira LE-4669 |
| 4 | +Rebuild_History Non-Buildable kernel-4.18.0-553.82.1.el8_10 |
| 5 | +commit-author Shyam Prasad N <sprasad@microsoft.com> |
| 6 | +commit c3326a61cdbf3ce1273d9198b6cbf90965d7e029 |
| 7 | +Empty-Commit: Cherry-Pick Conflicts during history rebuild. |
| 8 | +Will be included in final tarball splat. Ref for failed cherry-pick at: |
| 9 | +ciq/ciq_backports/kernel-4.18.0-553.82.1.el8_10/c3326a61.failed |
| 10 | + |
| 11 | +We introduced a helper function to be used by non-cifsd threads to |
| 12 | +mark the connection for reconnect. For multichannel, when only |
| 13 | +a particular channel needs to be reconnected, this had a bug. |
| 14 | + |
| 15 | +This change fixes that by marking that particular channel |
| 16 | +for reconnect. |
| 17 | + |
| 18 | +Fixes: dca65818c80c ("cifs: use a different reconnect helper for non-cifsd threads") |
| 19 | + Cc: stable@vger.kernel.org |
| 20 | + Signed-off-by: Shyam Prasad N <sprasad@microsoft.com> |
| 21 | + Reviewed-by: Paulo Alcantara (SUSE) <pc@manguebit.com> |
| 22 | + Signed-off-by: Steve French <stfrench@microsoft.com> |
| 23 | +(cherry picked from commit c3326a61cdbf3ce1273d9198b6cbf90965d7e029) |
| 24 | + Signed-off-by: Jonathan Maple <jmaple@ciq.com> |
| 25 | + |
| 26 | +# Conflicts: |
| 27 | +# fs/cifs/connect.c |
| 28 | +diff --cc fs/cifs/connect.c |
| 29 | +index ca2926c7b59e,a7147fa55c0c..000000000000 |
| 30 | +--- a/fs/cifs/connect.c |
| 31 | ++++ b/fs/cifs/connect.c |
| 32 | +@@@ -164,45 -140,66 +164,55 @@@ static void smb2_query_server_interface |
| 33 | + (SMB_INTERFACE_POLL_INTERVAL * HZ)); |
| 34 | + } |
| 35 | + |
| 36 | + -/* |
| 37 | + - * Update the tcpStatus for the server. |
| 38 | + - * This is used to signal the cifsd thread to call cifs_reconnect |
| 39 | + - * ONLY cifsd thread should call cifs_reconnect. For any other |
| 40 | + - * thread, use this function |
| 41 | + - * |
| 42 | + - * @server: the tcp ses for which reconnect is needed |
| 43 | + - * @all_channels: if this needs to be done for all channels |
| 44 | + - */ |
| 45 | + -void |
| 46 | + -cifs_signal_cifsd_for_reconnect(struct TCP_Server_Info *server, |
| 47 | + - bool all_channels) |
| 48 | + +static void cifs_resolve_server(struct work_struct *work) |
| 49 | + { |
| 50 | + - struct TCP_Server_Info *pserver; |
| 51 | + - struct cifs_ses *ses; |
| 52 | + - int i; |
| 53 | + + int rc; |
| 54 | + + struct TCP_Server_Info *server = container_of(work, |
| 55 | + + struct TCP_Server_Info, resolve.work); |
| 56 | + |
| 57 | + - /* If server is a channel, select the primary channel */ |
| 58 | + - pserver = SERVER_IS_CHAN(server) ? server->primary_server : server; |
| 59 | + + mutex_lock(&server->srv_mutex); |
| 60 | + |
| 61 | +++<<<<<<< HEAD:fs/cifs/connect.c |
| 62 | + + /* |
| 63 | + + * Resolve the hostname again to make sure that IP address is up-to-date. |
| 64 | + + */ |
| 65 | + + rc = reconn_set_ipaddr_from_hostname(server); |
| 66 | + + if (rc) { |
| 67 | + + cifs_dbg(FYI, "%s: failed to resolve hostname: %d\n", |
| 68 | + + __func__, rc); |
| 69 | +++======= |
| 70 | ++ /* if we need to signal just this channel */ |
| 71 | ++ if (!all_channels) { |
| 72 | ++ spin_lock(&server->srv_lock); |
| 73 | ++ if (server->tcpStatus != CifsExiting) |
| 74 | ++ server->tcpStatus = CifsNeedReconnect; |
| 75 | ++ spin_unlock(&server->srv_lock); |
| 76 | ++ return; |
| 77 | +++>>>>>>> c3326a61cdbf (cifs: reconnect helper should set reconnect for the right channel):fs/smb/client/connect.c |
| 78 | + } |
| 79 | + |
| 80 | + - spin_lock(&cifs_tcp_ses_lock); |
| 81 | + - list_for_each_entry(ses, &pserver->smb_ses_list, smb_ses_list) { |
| 82 | + - spin_lock(&ses->chan_lock); |
| 83 | + - for (i = 0; i < ses->chan_count; i++) { |
| 84 | + - spin_lock(&ses->chans[i].server->srv_lock); |
| 85 | + - ses->chans[i].server->tcpStatus = CifsNeedReconnect; |
| 86 | + - spin_unlock(&ses->chans[i].server->srv_lock); |
| 87 | + - } |
| 88 | + - spin_unlock(&ses->chan_lock); |
| 89 | + - } |
| 90 | + - spin_unlock(&cifs_tcp_ses_lock); |
| 91 | + + mutex_unlock(&server->srv_mutex); |
| 92 | + } |
| 93 | + |
| 94 | + -/* |
| 95 | + +/** |
| 96 | + * Mark all sessions and tcons for reconnect. |
| 97 | + - * IMPORTANT: make sure that this gets called only from |
| 98 | + - * cifsd thread. For any other thread, use |
| 99 | + - * cifs_signal_cifsd_for_reconnect |
| 100 | + * |
| 101 | + - * @server: the tcp ses for which reconnect is needed |
| 102 | + * @server needs to be previously set to CifsNeedReconnect. |
| 103 | + - * @mark_smb_session: whether even sessions need to be marked |
| 104 | + */ |
| 105 | + -void |
| 106 | + -cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server, |
| 107 | + - bool mark_smb_session) |
| 108 | + +static void cifs_mark_tcp_ses_conns_for_reconnect(struct TCP_Server_Info *server) |
| 109 | + { |
| 110 | + - struct TCP_Server_Info *pserver; |
| 111 | + - struct cifs_ses *ses, *nses; |
| 112 | + + unsigned int num_sessions = 0; |
| 113 | + + struct cifs_ses *ses; |
| 114 | + struct cifs_tcon *tcon; |
| 115 | + + struct mid_q_entry *mid, *nmid; |
| 116 | + + struct list_head retry_list; |
| 117 | + + struct TCP_Server_Info *pserver; |
| 118 | + + |
| 119 | + + server->maxBuf = 0; |
| 120 | + + server->max_read = 0; |
| 121 | + |
| 122 | + + cifs_dbg(FYI, "Mark tcp session as need reconnect\n"); |
| 123 | + + trace_smb3_reconnect(server->CurrentMid, server->conn_id, server->hostname); |
| 124 | + /* |
| 125 | + * before reconnecting the tcp session, mark the smb session (uid) and the tid bad so they |
| 126 | + * are not used until reconnected. |
| 127 | +* Unmerged path fs/cifs/connect.c |
0 commit comments