Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 269963
b: refs/heads/master
c: 1041e3f
h: refs/heads/master
i:
  269961: d367cc2
  269959: c6a4a78
v: v3
  • Loading branch information
Jeff Layton committed Oct 19, 2011
1 parent 2c2299a commit 8346283
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 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: 42c4dfc213190fafffc53815c2ee6064430bc379
refs/heads/master: 1041e3f9919999b22c9c2a453aa0d92cd16b76ee
2 changes: 2 additions & 0 deletions trunk/fs/cifs/cifsglob.h
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ struct TCP_Server_Info {
bool sec_kerberos; /* supports plain Kerberos */
bool sec_mskerberos; /* supports legacy MS Kerberos */
struct delayed_work echo; /* echo ping workqueue job */
struct kvec *iov; /* reusable kvec array for receives */
unsigned int nr_iov; /* number of kvecs in array */
#ifdef CONFIG_CIFS_FSCACHE
struct fscache_cookie *fscache; /* client index cache cookie */
#endif
Expand Down
22 changes: 20 additions & 2 deletions trunk/fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,24 @@ kvec_array_init(struct kvec *new, struct kvec *iov, unsigned int nr_segs,
return nr_segs;
}

static struct kvec *
get_server_iovec(struct TCP_Server_Info *server, unsigned int nr_segs)
{
struct kvec *new_iov;

if (server->iov && nr_segs <= server->nr_iov)
return server->iov;

/* not big enough -- allocate a new one and release the old */
new_iov = kmalloc(sizeof(*new_iov) * nr_segs, GFP_NOFS);
if (new_iov) {
kfree(server->iov);
server->iov = new_iov;
server->nr_iov = nr_segs;
}
return new_iov;
}

static int
readv_from_socket(struct TCP_Server_Info *server, struct kvec *iov_orig,
unsigned int nr_segs, unsigned int to_read)
Expand All @@ -420,7 +438,7 @@ readv_from_socket(struct TCP_Server_Info *server, struct kvec *iov_orig,
struct msghdr smb_msg;
struct kvec *iov;

iov = kmalloc(sizeof(*iov_orig) * nr_segs, GFP_NOFS);
iov = get_server_iovec(server, nr_segs);
if (!iov)
return -ENOMEM;

Expand Down Expand Up @@ -464,7 +482,6 @@ readv_from_socket(struct TCP_Server_Info *server, struct kvec *iov_orig,
break;
}
}
kfree(iov);
return total_read;
}

Expand Down Expand Up @@ -669,6 +686,7 @@ static void clean_demultiplex_info(struct TCP_Server_Info *server)
}

kfree(server->hostname);
kfree(server->iov);
kfree(server);

length = atomic_dec_return(&tcpSesAllocCount);
Expand Down

0 comments on commit 8346283

Please sign in to comment.