Commit 8b550088 authored by Steve French's avatar Steve French Committed by Steve French

Fix major page leak in read code caused by extra page_cache_get call

parent 3006d859
Version 1.07
------------
Fix some small memory leaks in some unmount error paths.
Fix some small memory leaks in some unmount error paths. Fix major leak
of cache pages in readpages causing multiple read oriented stress
testcases (including fsx, and even large file copy) to fail over time.
Version 1.06
------------
......
......@@ -44,7 +44,7 @@ extern void SMBencrypt(unsigned char *passwd, unsigned char *c8,
unsigned char *p24);
extern void SMBNTencrypt(unsigned char *passwd, unsigned char *c8,
unsigned char *p24);
extern int cifs_inet_addr(char *);
extern int cifs_inet_pton(int, const char *, void *dst);
struct smb_vol {
char *username;
......@@ -992,7 +992,23 @@ cifs_mount(struct super_block *sb, struct cifs_sb_info *cifs_sb,
}
if (volume_info.UNCip && volume_info.UNC) {
sin_server.sin_addr.s_addr = cifs_inet_addr(volume_info.UNCip);
rc = cifs_inet_pton(AF_INET, volume_info.UNCip,&sin_server.sin_addr.s_addr);
if(rc == 0) {
/* not ipv4 address, try ipv6 */
rc = cifs_inet_pton(AF_INET6,volume_info.UNCip,&sin_server6.sin6_addr.in6_u);
}
if(rc != 1) {
/* we failed translating address */
if(volume_info.UNC)
kfree(volume_info.UNC);
if(volume_info.password)
kfree(volume_info.password);
FreeXid(xid);
return -EINVAL;
}
cFYI(1, ("UNC: %s ip: %s ", volume_info.UNC, volume_info.UNCip));
} else if (volume_info.UNCip){
/* BB using ip addr as server name connect to the DFS root below */
......
......@@ -933,7 +933,6 @@ static void cifs_copy_cache_pages(struct address_space *mapping,
continue;
}
page_cache_get(page);
target = kmap_atomic(page,KM_USER0);
if(PAGE_CACHE_SIZE > bytes_read) {
......@@ -947,12 +946,11 @@ static void cifs_copy_cache_pages(struct address_space *mapping,
}
kunmap_atomic(target,KM_USER0);
if (!pagevec_add(plru_pvec, page))
__pagevec_lru_add(plru_pvec);
flush_dcache_page(page);
SetPageUptodate(page);
unlock_page(page); /* BB verify we need to unlock here */
/* page_cache_release(page);*/
unlock_page(page);
if (!pagevec_add(plru_pvec, page))
__pagevec_lru_add(plru_pvec);
data += PAGE_CACHE_SIZE;
}
return;
......@@ -1092,10 +1090,10 @@ cifs_readpages(struct file *file, struct address_space *mapping,
pagevec_lru_add(&lru_pvec);
/* need to free smb_read_data buf before exit */
if(smb_read_data) {
cifs_buf_release(smb_read_data);
smb_read_data = 0;
}
if(smb_read_data) {
cifs_buf_release(smb_read_data);
smb_read_data = 0;
}
FreeXid(xid);
return rc;
......
......@@ -125,10 +125,10 @@ const struct smb_to_posix_error mapping_table_ERRHRD[] = {
/* Convert string containing dotted ip address to binary form */
/* returns 0 if invalid address */
/* BB add address family, change rc to status flag and return *//* also see inet_pton */
/* To identify v4 vs. v6 - 1) check for colon (v6 only) 2) then call inet_pton to parse for bad address */
/* BB add address family, change rc to status flag and return union or for ipv6 */
/* will need parent to call something like inet_pton to convert ipv6 address BB */
int
cifs_inet_addr(char *cp)
cifs_inet_pton(int address_family, char *cp,void *dst)
{
struct in_addr address;
int value;
......@@ -140,6 +140,9 @@ cifs_inet_addr(char *cp)
static const int addr_class_max[4] =
{ 0xffffffff, 0xffffff, 0xffff, 0xff };
if(address_family != AF_INET)
return -EAFNOSUPPORT;
for (i = 0; i < 4; i++) {
bytes[i] = 0;
}
......@@ -166,6 +169,9 @@ cifs_inet_addr(char *cp)
return 0;
*end++ = value;
temp = *++cp;
} else if (temp == ':') {
cFYI(1,("IPv6 addresses not supported for CIFS mounts yet"));
return -1;
} else
break;
}
......@@ -182,8 +188,8 @@ cifs_inet_addr(char *cp)
return 0;
address.s_addr = *((int *) bytes) | htonl(value);
return address.s_addr;
*((int *)dst) = address.s_addr;
return 1; /* success */
}
/*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment