From: Aurelien Aptel Date: Fri, 20 Sep 2019 04:29:39 +0000 (+0200) Subject: cifs: sort interface list by speed X-Git-Tag: microblaze-v5.6-rc1~124^2~17 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=35adffed079fdcf1818bfe9da7625a5446b626e0;p=linux-2.6-microblaze.git 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 Signed-off-by: Steve French --- diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index eb92cd4502cc..3b0f6cda9a87 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "cifsglob.h" #include "smb2pdu.h" @@ -552,6 +553,13 @@ out: return rc; } +static int compare_iface(const void *ia, const void *ib) +{ + const struct cifs_server_iface *a = (struct cifs_server_iface *)ia; + const struct cifs_server_iface *b = (struct cifs_server_iface *)ib; + + return a->speed == b->speed ? 0 : (a->speed > b->speed ? -1 : 1); +} static int SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon) @@ -581,6 +589,9 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon) if (rc) goto out; + /* sort interfaces from fastest to slowest */ + sort(iface_list, iface_count, sizeof(*iface_list), compare_iface, NULL); + spin_lock(&ses->iface_lock); kfree(ses->iface_list); ses->iface_list = iface_list;