Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 294589
b: refs/heads/master
c: bc205ed
h: refs/heads/master
i:
  294587: 704203e
v: v3
  • Loading branch information
Pavel Shilovsky authored and Steve French committed Mar 21, 2012
1 parent 0761c76 commit b34b3d0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5bc594982f49220d33e927e3c9e028bf87b4745c
refs/heads/master: bc205ed19bdb56576b291830bc3f752aef5e3923
14 changes: 12 additions & 2 deletions trunk/fs/cifs/cifsglob.h
Original file line number Diff line number Diff line change
Expand Up @@ -315,12 +315,22 @@ in_flight(struct TCP_Server_Info *server)
return num;
}

static inline int*
get_credits_field(struct TCP_Server_Info *server)
{
/*
* This will change to switch statement when we reserve slots for echos
* and oplock breaks.
*/
return &server->credits;
}

static inline bool
has_credits(struct TCP_Server_Info *server)
has_credits(struct TCP_Server_Info *server, int *credits)
{
int num;
spin_lock(&server->req_lock);
num = server->credits;
num = *credits;
spin_unlock(&server->req_lock);
return num > 0;
}
Expand Down
22 changes: 14 additions & 8 deletions trunk/fs/cifs/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,26 +255,26 @@ smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer,
}

static int
wait_for_free_request(struct TCP_Server_Info *server, const int long_op)
wait_for_free_credits(struct TCP_Server_Info *server, const int optype,
int *credits)
{
int rc;

spin_lock(&server->req_lock);

if (long_op == CIFS_ASYNC_OP) {
if (optype == CIFS_ASYNC_OP) {
/* oplock breaks must not be held up */
server->in_flight++;
server->credits--;
*credits -= 1;
spin_unlock(&server->req_lock);
return 0;
}

while (1) {
if (server->credits <= 0) {
if (*credits <= 0) {
spin_unlock(&server->req_lock);
cifs_num_waiters_inc(server);
rc = wait_event_killable(server->request_q,
has_credits(server));
has_credits(server, credits));
cifs_num_waiters_dec(server);
if (rc)
return rc;
Expand All @@ -291,8 +291,8 @@ wait_for_free_request(struct TCP_Server_Info *server, const int long_op)
*/

/* update # of requests on the wire to server */
if (long_op != CIFS_BLOCKING_OP) {
server->credits--;
if (optype != CIFS_BLOCKING_OP) {
*credits -= 1;
server->in_flight++;
}
spin_unlock(&server->req_lock);
Expand All @@ -302,6 +302,12 @@ wait_for_free_request(struct TCP_Server_Info *server, const int long_op)
return 0;
}

static int
wait_for_free_request(struct TCP_Server_Info *server, const int optype)
{
return wait_for_free_credits(server, optype, get_credits_field(server));
}

static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf,
struct mid_q_entry **ppmidQ)
{
Expand Down

0 comments on commit b34b3d0

Please sign in to comment.