|
| 1 | +cifs: update dstaddr whenever channel iface is updated |
| 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 c1846893991f3b4ec8a0cc12219ada153f0814d6 |
| 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/c1846893.failed |
| 10 | + |
| 11 | +When the server interface info changes (more common in clustered |
| 12 | +servers like Azure Files), the per-channel iface gets updated. |
| 13 | +However, this did not update the corresponding dstaddr. As a result |
| 14 | +these channels will still connect (or try connecting) to older addresses. |
| 15 | + |
| 16 | +Fixes: b54034a73baf ("cifs: during reconnect, update interface if necessary") |
| 17 | + Cc: <stable@vger.kernel.org> |
| 18 | + Signed-off-by: Shyam Prasad N <sprasad@microsoft.com> |
| 19 | + Signed-off-by: Steve French <stfrench@microsoft.com> |
| 20 | +(cherry picked from commit c1846893991f3b4ec8a0cc12219ada153f0814d6) |
| 21 | + Signed-off-by: Jonathan Maple <jmaple@ciq.com> |
| 22 | + |
| 23 | +# Conflicts: |
| 24 | +# fs/cifs/sess.c |
| 25 | +diff --cc fs/cifs/sess.c |
| 26 | +index f27026148ee7,ec0db32c7d98..000000000000 |
| 27 | +--- a/fs/cifs/sess.c |
| 28 | ++++ b/fs/cifs/sess.c |
| 29 | +@@@ -274,45 -419,36 +274,52 @@@ cifs_chan_update_iface(struct cifs_ses |
| 30 | + cifs_dbg(FYI, "replacing iface: %pIS with %pIS\n", |
| 31 | + &old_iface->sockaddr, |
| 32 | + &iface->sockaddr); |
| 33 | + - |
| 34 | + - old_iface->num_channels--; |
| 35 | + - if (old_iface->weight_fulfilled) |
| 36 | + - old_iface->weight_fulfilled--; |
| 37 | + - iface->num_channels++; |
| 38 | + - iface->weight_fulfilled++; |
| 39 | + - |
| 40 | + kref_put(&old_iface->refcount, release_iface); |
| 41 | + - } else if (!chan_index) { |
| 42 | + - /* special case: update interface for primary channel */ |
| 43 | + - cifs_dbg(FYI, "referencing primary channel iface: %pIS\n", |
| 44 | + - &iface->sockaddr); |
| 45 | + - iface->num_channels++; |
| 46 | + - iface->weight_fulfilled++; |
| 47 | + + } else if (old_iface) { |
| 48 | + + cifs_dbg(FYI, "releasing ref to iface: %pIS\n", |
| 49 | + + &old_iface->sockaddr); |
| 50 | + + kref_put(&old_iface->refcount, release_iface); |
| 51 | + + } else { |
| 52 | + + WARN_ON(!iface); |
| 53 | + + cifs_dbg(FYI, "adding new iface: %pIS\n", &iface->sockaddr); |
| 54 | + } |
| 55 | + + |
| 56 | + spin_unlock(&ses->iface_lock); |
| 57 | + |
| 58 | + - spin_lock(&ses->chan_lock); |
| 59 | + - chan_index = cifs_ses_get_chan_index(ses, server); |
| 60 | + - if (chan_index == CIFS_INVAL_CHAN_INDEX) { |
| 61 | + - spin_unlock(&ses->chan_lock); |
| 62 | + - return; |
| 63 | + + /* No iface is found. if secondary chan, drop connection */ |
| 64 | + + if (!iface && CIFS_SERVER_IS_CHAN(server)) { |
| 65 | + + cifs_put_tcp_session(server, false); |
| 66 | + + ses->chans[chan_index].server = NULL; |
| 67 | + } |
| 68 | + |
| 69 | + - ses->chans[chan_index].iface = iface; |
| 70 | + + return rc; |
| 71 | + +} |
| 72 | + + |
| 73 | + +/* |
| 74 | + + * If server is a channel of ses, return the corresponding enclosing |
| 75 | + + * cifs_chan otherwise return NULL. |
| 76 | + + */ |
| 77 | + +struct cifs_chan * |
| 78 | + +cifs_ses_find_chan(struct cifs_ses *ses, struct TCP_Server_Info *server) |
| 79 | + +{ |
| 80 | + + int i; |
| 81 | + + |
| 82 | + + spin_lock(&ses->chan_lock); |
| 83 | + + for (i = 0; i < ses->chan_count; i++) { |
| 84 | + + if (ses->chans[i].server == server) { |
| 85 | + + spin_unlock(&ses->chan_lock); |
| 86 | + + return &ses->chans[i]; |
| 87 | + + } |
| 88 | + + } |
| 89 | + spin_unlock(&ses->chan_lock); |
| 90 | +++<<<<<<< HEAD:fs/cifs/sess.c |
| 91 | + + return NULL; |
| 92 | +++======= |
| 93 | ++ |
| 94 | ++ spin_lock(&server->srv_lock); |
| 95 | ++ memcpy(&server->dstaddr, &iface->sockaddr, sizeof(server->dstaddr)); |
| 96 | ++ spin_unlock(&server->srv_lock); |
| 97 | +++>>>>>>> c1846893991f (cifs: update dstaddr whenever channel iface is updated):fs/smb/client/sess.c |
| 98 | + } |
| 99 | + |
| 100 | + static int |
| 101 | +* Unmerged path fs/cifs/sess.c |
0 commit comments