mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 14:51:51 -04:00
smb: server: make use of smbdirect_socket_wait_for_credits()
This will allow us to share more common code between client and server soon. Cc: Namjae Jeon <linkinjeon@kernel.org> Cc: Steve French <smfrench@gmail.com> Cc: Tom Talpey <tom@talpey.com> Cc: linux-cifs@vger.kernel.org Cc: samba-technical@lists.samba.org Signed-off-by: Stefan Metzmacher <metze@samba.org> Acked-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
committed by
Steve French
parent
be0ac9f59f
commit
0911d32ba2
@@ -910,27 +910,6 @@ static int smb_direct_flush_send_list(struct smbdirect_socket *sc,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int wait_for_credits(struct smbdirect_socket *sc,
|
||||
wait_queue_head_t *waitq, atomic_t *total_credits,
|
||||
int needed)
|
||||
{
|
||||
int ret;
|
||||
|
||||
do {
|
||||
if (atomic_sub_return(needed, total_credits) >= 0)
|
||||
return 0;
|
||||
|
||||
atomic_add(needed, total_credits);
|
||||
ret = wait_event_interruptible(*waitq,
|
||||
atomic_read(total_credits) >= needed ||
|
||||
sc->status != SMBDIRECT_SOCKET_CONNECTED);
|
||||
|
||||
if (sc->status != SMBDIRECT_SOCKET_CONNECTED)
|
||||
return -ENOTCONN;
|
||||
else if (ret < 0)
|
||||
return ret;
|
||||
} while (true);
|
||||
}
|
||||
|
||||
static int wait_for_send_bcredit(struct smbdirect_socket *sc,
|
||||
struct smbdirect_send_batch *send_ctx)
|
||||
@@ -940,10 +919,12 @@ static int wait_for_send_bcredit(struct smbdirect_socket *sc,
|
||||
if (send_ctx->credit)
|
||||
return 0;
|
||||
|
||||
ret = wait_for_credits(sc,
|
||||
&sc->send_io.bcredits.wait_queue,
|
||||
&sc->send_io.bcredits.count,
|
||||
1);
|
||||
ret = smbdirect_socket_wait_for_credits(sc,
|
||||
SMBDIRECT_SOCKET_CONNECTED,
|
||||
-ENOTCONN,
|
||||
&sc->send_io.bcredits.wait_queue,
|
||||
&sc->send_io.bcredits.count,
|
||||
1);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
@@ -962,10 +943,12 @@ static int wait_for_send_lcredit(struct smbdirect_socket *sc,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return wait_for_credits(sc,
|
||||
&sc->send_io.lcredits.wait_queue,
|
||||
&sc->send_io.lcredits.count,
|
||||
1);
|
||||
return smbdirect_socket_wait_for_credits(sc,
|
||||
SMBDIRECT_SOCKET_CONNECTED,
|
||||
-ENOTCONN,
|
||||
&sc->send_io.lcredits.wait_queue,
|
||||
&sc->send_io.lcredits.count,
|
||||
1);
|
||||
}
|
||||
|
||||
static int wait_for_send_credits(struct smbdirect_socket *sc,
|
||||
@@ -980,15 +963,22 @@ static int wait_for_send_credits(struct smbdirect_socket *sc,
|
||||
return ret;
|
||||
}
|
||||
|
||||
return wait_for_credits(sc, &sc->send_io.credits.wait_queue, &sc->send_io.credits.count, 1);
|
||||
return smbdirect_socket_wait_for_credits(sc,
|
||||
SMBDIRECT_SOCKET_CONNECTED,
|
||||
-ENOTCONN,
|
||||
&sc->send_io.credits.wait_queue,
|
||||
&sc->send_io.credits.count,
|
||||
1);
|
||||
}
|
||||
|
||||
static int wait_for_rw_credits(struct smbdirect_socket *sc, int credits)
|
||||
{
|
||||
return wait_for_credits(sc,
|
||||
&sc->rw_io.credits.wait_queue,
|
||||
&sc->rw_io.credits.count,
|
||||
credits);
|
||||
return smbdirect_socket_wait_for_credits(sc,
|
||||
SMBDIRECT_SOCKET_CONNECTED,
|
||||
-ENOTCONN,
|
||||
&sc->rw_io.credits.wait_queue,
|
||||
&sc->rw_io.credits.count,
|
||||
credits);
|
||||
}
|
||||
|
||||
static int calc_rw_credits(struct smbdirect_socket *sc,
|
||||
|
||||
Reference in New Issue
Block a user