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>
This commit is contained in:
parent
fa9c236249
commit
35adffed07
|
@ -10,6 +10,7 @@
|
||||||
#include <linux/falloc.h>
|
#include <linux/falloc.h>
|
||||||
#include <linux/scatterlist.h>
|
#include <linux/scatterlist.h>
|
||||||
#include <linux/uuid.h>
|
#include <linux/uuid.h>
|
||||||
|
#include <linux/sort.h>
|
||||||
#include <crypto/aead.h>
|
#include <crypto/aead.h>
|
||||||
#include "cifsglob.h"
|
#include "cifsglob.h"
|
||||||
#include "smb2pdu.h"
|
#include "smb2pdu.h"
|
||||||
|
@ -552,6 +553,13 @@ out:
|
||||||
return rc;
|
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
|
static int
|
||||||
SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon)
|
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)
|
if (rc)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
/* sort interfaces from fastest to slowest */
|
||||||
|
sort(iface_list, iface_count, sizeof(*iface_list), compare_iface, NULL);
|
||||||
|
|
||||||
spin_lock(&ses->iface_lock);
|
spin_lock(&ses->iface_lock);
|
||||||
kfree(ses->iface_list);
|
kfree(ses->iface_list);
|
||||||
ses->iface_list = iface_list;
|
ses->iface_list = iface_list;
|
||||||
|
|
Loading…
Reference in New Issue