* 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
struct trace_page *tage;
page = cfs_alloc_page(gfp);
struct trace_page *tage;
page = cfs_alloc_page(gfp);
- if (page != NULL) {
- tage = cfs_alloc(sizeof *tage, gfp);
- if (tage == NULL)
- cfs_free_page(page);
- tage->page = page;
- } else
- tage = NULL;
+ if (page == NULL)
+ return NULL;
+
+ tage = cfs_alloc(sizeof(*tage), gfp);
+ if (tage == NULL) {
+ cfs_free_page(page);
+ return NULL;
+ }
+
+ tage->page = page;
return tage;
}
static void tage_free(struct trace_page *tage)
{
LASSERT(tage != NULL);
return tage;
}
static void tage_free(struct trace_page *tage)
{
LASSERT(tage != NULL);
+ LASSERT(tage->page != NULL);
- if (tage->page != NULL)
- cfs_free_page(tage->page);
+ cfs_free_page(tage->page);
static int tage_invariant(struct trace_page *tage)
{
static int tage_invariant(struct trace_page *tage)
{
- return
- tage != NULL &&
+ return (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 */
* to using the last page in the ring buffer. */
goto ring_buffer;
}
* to using the last page in the ring buffer. */
goto ring_buffer;
}
tage->used = 0;
tage->cpu = smp_processor_id();
list_add_tail(&tage->linkage, &tcd->tcd_pages);
tage->used = 0;
tage->cpu = smp_processor_id();
list_add_tail(&tage->linkage, &tcd->tcd_pages);
tcd->tcd_cur_pages--;
}
put_pages_on_daemon_list_on_cpu(&pc);
tcd->tcd_cur_pages--;
}
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->used = 0;
tage = tage_from_list(tcd->tcd_pages.next);
tage->used = 0;