Skip to content
Snippets Groups Projects
Commit 59d1c7e2 authored by Eric Barton's avatar Eric Barton
Browse files

* fixed bug tracefile.c: tage_alloc() as encountered in bug 5857

*   Asserted tage->page != NULL in tage_free; how could it ever be otherwise?

*   Moved what seemed like an obviously incorrect assertion in trace_get_tage()
    that tcd_pages was not empty into the "debug daemon buffer overflowed"
    branch.

    Someone should review this change; I'm flagging it in bug 5857
parent 38de8da7
No related branches found
No related tags found
No related merge requests found
...@@ -52,22 +52,25 @@ static struct trace_page *tage_alloc(int gfp) ...@@ -52,22 +52,25 @@ static struct trace_page *tage_alloc(int gfp)
struct trace_page *tage; struct trace_page *tage;
page = cfs_alloc_page(gfp); page = cfs_alloc_page(gfp);
if (page != NULL) { if (page == NULL)
tage = cfs_alloc(sizeof *tage, gfp); return NULL;
if (tage == NULL)
cfs_free_page(page); tage = cfs_alloc(sizeof(*tage), gfp);
tage->page = page; if (tage == NULL) {
} else cfs_free_page(page);
tage = NULL; return NULL;
}
tage->page = page;
return tage; return tage;
} }
static void tage_free(struct trace_page *tage) static void tage_free(struct trace_page *tage)
{ {
LASSERT(tage != NULL); LASSERT(tage != NULL);
LASSERT(tage->page != NULL);
if (tage->page != NULL) cfs_free_page(tage->page);
cfs_free_page(tage->page);
cfs_free(tage); cfs_free(tage);
} }
...@@ -81,10 +84,10 @@ static void tage_to_tail(struct trace_page *tage, struct list_head *queue) ...@@ -81,10 +84,10 @@ static void tage_to_tail(struct trace_page *tage, struct list_head *queue)
static int tage_invariant(struct trace_page *tage) static int tage_invariant(struct trace_page *tage)
{ {
return return (tage != NULL &&
tage != NULL && tage->page != NULL &&
tage->used <= CFS_PAGE_SIZE && tage->used <= CFS_PAGE_SIZE &&
cfs_page_count(tage->page) > 0; cfs_page_count(tage->page) > 0);
} }
/* return a page that has 'len' bytes left at the end */ /* return a page that has 'len' bytes left at the end */
...@@ -112,6 +115,7 @@ static struct trace_page *trace_get_tage(struct trace_cpu_data *tcd, ...@@ -112,6 +115,7 @@ static struct trace_page *trace_get_tage(struct trace_cpu_data *tcd,
* to using the last page in the ring buffer. */ * to using the last page in the ring buffer. */
goto ring_buffer; goto ring_buffer;
} }
tage->used = 0; tage->used = 0;
tage->cpu = smp_processor_id(); tage->cpu = smp_processor_id();
list_add_tail(&tage->linkage, &tcd->tcd_pages); list_add_tail(&tage->linkage, &tcd->tcd_pages);
...@@ -145,8 +149,12 @@ static struct trace_page *trace_get_tage(struct trace_cpu_data *tcd, ...@@ -145,8 +149,12 @@ static struct trace_page *trace_get_tage(struct trace_cpu_data *tcd,
tcd->tcd_cur_pages--; tcd->tcd_cur_pages--;
} }
put_pages_on_daemon_list_on_cpu(&pc); put_pages_on_daemon_list_on_cpu(&pc);
LASSERT(!list_empty(&tcd->tcd_pages));
} }
LASSERT(!list_empty(&tcd->tcd_pages));
if (list_empty(&tcd->tcd_pages))
return NULL;
tage = tage_from_list(tcd->tcd_pages.next); tage = tage_from_list(tcd->tcd_pages.next);
tage->used = 0; tage->used = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment