Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cifs: sort interface list by speed

New channels are going to be opened by walking the list sequentially,
so by sorting it we will connect to the fastest interfaces first.

Signed-off-by: Aurelien Aptel <aaptel@suse.com>
Signed-off-by: Steve French <stfrench@microsoft.com>

authored by

Aurelien Aptel and committed by
Steve French
35adffed fa9c2362

+11
+11
fs/cifs/smb2ops.c
··· 10 10 #include <linux/falloc.h> 11 11 #include <linux/scatterlist.h> 12 12 #include <linux/uuid.h> 13 + #include <linux/sort.h> 13 14 #include <crypto/aead.h> 14 15 #include "cifsglob.h" 15 16 #include "smb2pdu.h" ··· 553 552 return rc; 554 553 } 555 554 555 + static int compare_iface(const void *ia, const void *ib) 556 + { 557 + const struct cifs_server_iface *a = (struct cifs_server_iface *)ia; 558 + const struct cifs_server_iface *b = (struct cifs_server_iface *)ib; 559 + 560 + return a->speed == b->speed ? 0 : (a->speed > b->speed ? -1 : 1); 561 + } 556 562 557 563 static int 558 564 SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon) ··· 588 580 &iface_list, &iface_count); 589 581 if (rc) 590 582 goto out; 583 + 584 + /* sort interfaces from fastest to slowest */ 585 + sort(iface_list, iface_count, sizeof(*iface_list), compare_iface, NULL); 591 586 592 587 spin_lock(&ses->iface_lock); 593 588 kfree(ses->iface_list);