Mark Moseley <moseleymark@xxxxxxxxx> wrote: > [ 7719.996883] FS-Cache: Assertion failed > [ 7719.996886] 3 == 5 is false > [ 7719.996906] ------------[ cut here ]------------ > [ 7720.006139] kernel BUG at fs/fscache/operation.c:408! Can you add the attached patch? It will display which operation was being run just before displaying the above assertion. David --- From: David Howells <dhowells@xxxxxxxxxx> Subject: [PATCH] FS-Cache: Give operations names for debugging Give operations names for debugging and print it if we're going to assert. Signed-off-by: David Howells <dhowells@xxxxxxxxxx> --- fs/fscache/object.c | 1 + fs/fscache/operation.c | 18 ++++++++++++++++++ fs/fscache/page.c | 5 +++++ include/linux/fscache-cache.h | 14 +++++++++++++- 4 files changed, 37 insertions(+), 1 deletions(-) diff --git a/fs/fscache/object.c b/fs/fscache/object.c index 80b5491..91d998b 100644 --- a/fs/fscache/object.c +++ b/fs/fscache/object.c @@ -940,6 +940,7 @@ static void fscache_invalidate_object(struct fscache_object *object) } fscache_operation_init(op, object->cache->ops->invalidate_object, NULL); + op->name = FSCACHE_OP_INVALIDATE; op->flags = FSCACHE_OP_ASYNC | (1 << FSCACHE_OP_EXCLUSIVE); spin_lock(&cookie->lock); diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c index 2037f03..6bfefee 100644 --- a/fs/fscache/operation.c +++ b/fs/fscache/operation.c @@ -20,6 +20,16 @@ atomic_t fscache_op_debug_id; EXPORT_SYMBOL(fscache_op_debug_id); +static const char *const fscache_op_names[FSCACHE_OP__NR] = { + [FSCACHE_OP_UNNAMED] = "Unnamed", + [FSCACHE_OP_INVALIDATE] = "Invalidate", + [FSCACHE_OP_ATTR_CHANGED] = "AttrChanged", + [FSCACHE_OP_ALLOC_PAGE] = "AllocPage", + [FSCACHE_OP_READ_OR_ALLOC_PAGE] = "ReadOrAllocPage", + [FSCACHE_OP_READ_OR_ALLOC_PAGES] = "ReadOrAllocPages", + [FSCACHE_OP_WRITE] = "Write", +}; + /** * fscache_enqueue_operation - Enqueue an operation for processing * @op: The operation to enqueue @@ -86,6 +96,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object, { _enter("{OBJ%x OP%x},", object->debug_id, op->debug_id); + ASSERTCMP(op->name, >, FSCACHE_OP_UNNAMED); ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED); ASSERTCMP(atomic_read(&op->usage), >, 0); @@ -189,6 +200,7 @@ int fscache_submit_op(struct fscache_object *object, _enter("{OBJ%x OP%x},{%u}", object->debug_id, op->debug_id, atomic_read(&op->usage)); + ASSERTCMP(op->name, >, FSCACHE_OP_UNNAMED); ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED); ASSERTCMP(atomic_read(&op->usage), >, 0); @@ -404,6 +416,12 @@ void fscache_put_operation(struct fscache_operation *op) return; _debug("PUT OP"); + + if (op->state != FSCACHE_OP_ST_COMPLETE && + op->state != FSCACHE_OP_ST_CANCELLED) + printk("FS-Cache: Asserting on %s operation\n", + fscache_op_names[op->name]); + ASSERTIFCMP(op->state != FSCACHE_OP_ST_COMPLETE, op->state, ==, FSCACHE_OP_ST_CANCELLED); op->state = FSCACHE_OP_ST_DEAD; diff --git a/fs/fscache/page.c b/fs/fscache/page.c index 00a5ed9..cf6dd34 100644 --- a/fs/fscache/page.c +++ b/fs/fscache/page.c @@ -188,6 +188,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie) } fscache_operation_init(op, fscache_attr_changed_op, NULL); + op->name = FSCACHE_OP_ATTR_CHANGED; op->flags = FSCACHE_OP_ASYNC | (1 << FSCACHE_OP_EXCLUSIVE); spin_lock(&cookie->lock); @@ -379,6 +380,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie, _leave(" = -ENOMEM"); return -ENOMEM; } + op->op.name = FSCACHE_OP_READ_OR_ALLOC_PAGE; op->n_pages = 1; spin_lock(&cookie->lock); @@ -505,6 +507,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie, op = fscache_alloc_retrieval(mapping, end_io_func, context); if (!op) return -ENOMEM; + op->op.name = FSCACHE_OP_READ_OR_ALLOC_PAGES; op->n_pages = *nr_pages; spin_lock(&cookie->lock); @@ -635,6 +638,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie, op = fscache_alloc_retrieval(page->mapping, NULL, NULL); if (!op) return -ENOMEM; + op->op.name = FSCACHE_OP_ALLOC_PAGE; op->n_pages = 1; spin_lock(&cookie->lock); @@ -856,6 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie, fscache_operation_init(&op->op, fscache_write_op, fscache_release_write_op); + op->op.name = FSCACHE_OP_WRITE; op->op.flags = FSCACHE_OP_ASYNC | (1 << FSCACHE_OP_WAITING); ret = radix_tree_preload(gfp & ~__GFP_HIGHMEM); diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h index 29f552d..fa61436 100644 --- a/include/linux/fscache-cache.h +++ b/include/linux/fscache-cache.h @@ -85,6 +85,17 @@ enum fscache_operation_state { FSCACHE_OP_ST_DEAD /* Op is now dead */ }; +enum fscache_operation_name { + FSCACHE_OP_UNNAMED, + FSCACHE_OP_INVALIDATE, + FSCACHE_OP_ATTR_CHANGED, + FSCACHE_OP_ALLOC_PAGE, + FSCACHE_OP_READ_OR_ALLOC_PAGE, + FSCACHE_OP_READ_OR_ALLOC_PAGES, + FSCACHE_OP_WRITE, + FSCACHE_OP__NR +}; + struct fscache_operation { struct work_struct work; /* record for async ops */ struct list_head pend_link; /* link in object->pending_ops */ @@ -99,7 +110,8 @@ struct fscache_operation { #define FSCACHE_OP_DEC_READ_CNT 6 /* decrement object->n_reads on destruction */ #define FSCACHE_OP_KEEP_FLAGS 0x0070 /* flags to keep when repurposing an op */ - enum fscache_operation_state state; + enum fscache_operation_state state : 8; + enum fscache_operation_name name : 8; atomic_t usage; unsigned debug_id; /* debugging ID */ -- Linux-cachefs mailing list Linux-cachefs@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/linux-cachefs