Commit 957fb7ef authored by Nathan Scott's avatar Nathan Scott

[XFS] Fix a small pagebuf memory leak and keep track of slab pages ourselves.

SGI Modid: 2.5.x-xfs:slinx:163124a
parent 52f83275
...@@ -372,9 +372,6 @@ _pagebuf_freepages( ...@@ -372,9 +372,6 @@ _pagebuf_freepages(
page_cache_release(page); page_cache_release(page);
} }
} }
if (pb->pb_pages != pb->pb_page_array)
kfree(pb->pb_pages);
} }
/* /*
...@@ -413,20 +410,17 @@ _pagebuf_free_object( ...@@ -413,20 +410,17 @@ _pagebuf_free_object(
if (pb->pb_flags & _PBF_MEM_ALLOCATED) { if (pb->pb_flags & _PBF_MEM_ALLOCATED) {
if (pb->pb_pages) { if (pb->pb_pages) {
/* release the pages in the address list */ /* release the pages in the address list */
if (pb->pb_pages[0] && if ((pb->pb_pages[0]) &&
PageSlab(pb->pb_pages[0])) { (pb->pb_flags & _PBF_MEM_SLAB)) {
/*
* This came from the slab
* allocator free it as such
*/
kfree(pb->pb_addr); kfree(pb->pb_addr);
} else { } else {
_pagebuf_freepages(pb); _pagebuf_freepages(pb);
} }
if (pb->pb_pages != pb->pb_page_array)
kfree(pb->pb_pages);
pb->pb_pages = NULL; pb->pb_pages = NULL;
} }
pb->pb_flags &= ~_PBF_MEM_ALLOCATED; pb->pb_flags &= ~(_PBF_MEM_ALLOCATED|_PBF_MEM_SLAB);
} }
} }
...@@ -718,7 +712,8 @@ _pagebuf_find( /* find buffer for block */ ...@@ -718,7 +712,8 @@ _pagebuf_find( /* find buffer for block */
_PBF_LOCKABLE | \ _PBF_LOCKABLE | \
_PBF_ALL_PAGES_MAPPED | \ _PBF_ALL_PAGES_MAPPED | \
_PBF_ADDR_ALLOCATED | \ _PBF_ADDR_ALLOCATED | \
_PBF_MEM_ALLOCATED; _PBF_MEM_ALLOCATED | \
_PBF_MEM_SLAB;
PB_TRACE(pb, "got_lock", 0); PB_TRACE(pb, "got_lock", 0);
PB_STATS_INC(pb_get_locked); PB_STATS_INC(pb_get_locked);
return (pb); return (pb);
...@@ -947,8 +942,8 @@ pagebuf_get_no_daddr( ...@@ -947,8 +942,8 @@ pagebuf_get_no_daddr(
page_buf_t *pb; page_buf_t *pb;
size_t tlen = 0; size_t tlen = 0;
if (len > 0x20000) if (unlikely(len > 0x20000))
return(NULL); return NULL;
pb = pagebuf_allocate(flags); pb = pagebuf_allocate(flags);
if (!pb) if (!pb)
...@@ -975,7 +970,7 @@ pagebuf_get_no_daddr( ...@@ -975,7 +970,7 @@ pagebuf_get_no_daddr(
return NULL; return NULL;
} }
/* otherwise pagebuf_free just ignores it */ /* otherwise pagebuf_free just ignores it */
pb->pb_flags |= _PBF_MEM_ALLOCATED; pb->pb_flags |= (_PBF_MEM_ALLOCATED | _PBF_MEM_SLAB);
PB_CLEAR_OWNER(pb); PB_CLEAR_OWNER(pb);
up(&pb->pb_sema); /* Return unlocked pagebuf */ up(&pb->pb_sema); /* Return unlocked pagebuf */
......
...@@ -93,12 +93,13 @@ typedef enum page_buf_flags_e { /* pb_flags values */ ...@@ -93,12 +93,13 @@ typedef enum page_buf_flags_e { /* pb_flags values */
_PBF_PRIVATE_BH = (1 << 17), /* do not use public buffer heads */ _PBF_PRIVATE_BH = (1 << 17), /* do not use public buffer heads */
_PBF_ALL_PAGES_MAPPED = (1 << 18), /* all pages in range mapped */ _PBF_ALL_PAGES_MAPPED = (1 << 18), /* all pages in range mapped */
_PBF_ADDR_ALLOCATED = (1 << 19), /* pb_addr space was allocated */ _PBF_ADDR_ALLOCATED = (1 << 19), /* pb_addr space was allocated */
_PBF_MEM_ALLOCATED = (1 << 20), /* pb_mem+underlying pages alloc'd */ _PBF_MEM_ALLOCATED = (1 << 20), /* underlying pages are allocated */
_PBF_MEM_SLAB = (1 << 21), /* underlying pages are slab allocated */
PBF_FORCEIO = (1 << 21), PBF_FORCEIO = (1 << 22), /* ignore any cache state */
PBF_FLUSH = (1 << 22), /* flush disk write cache */ PBF_FLUSH = (1 << 23), /* flush disk write cache */
PBF_READ_AHEAD = (1 << 23), PBF_READ_AHEAD = (1 << 24), /* asynchronous read-ahead */
PBF_RUN_QUEUES = (1 << 24), /* run block device task queue */ PBF_RUN_QUEUES = (1 << 25), /* run block device task queue */
} page_buf_flags_t; } page_buf_flags_t;
......
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