Skip to content

Commit

Permalink
fscache: Add more tracepoints
Browse files Browse the repository at this point in the history
Add more tracepoints to fscache, including:

 (*) fscache_page - Tracks netfs pages known to fscache.

 (*) fscache_check_page - Tracks the netfs querying whether a page is
     pending storage.

 (*) fscache_wake_cookie - Tracks cookies being woken up after a page
     completes/aborts storage in the cache.

 (*) fscache_op - Tracks operations being initialised.

 (*) fscache_wrote_page - Tracks return of the backend write_page op.

 (*) fscache_gang_lookup - Tracks lookup of pages to be stored in the write
     operation.

Signed-off-by: David Howells <[email protected]>
  • Loading branch information
dhowells committed Apr 4, 2018
1 parent a18feb5 commit 08c2e3d
Show file tree
Hide file tree
Showing 6 changed files with 330 additions and 8 deletions.
3 changes: 2 additions & 1 deletion fs/fscache/cookie.c
Original file line number Diff line number Diff line change
Expand Up @@ -691,10 +691,11 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
if (!op)
return -ENOMEM;

fscache_operation_init(op, NULL, NULL, NULL);
fscache_operation_init(cookie, op, NULL, NULL, NULL);
op->flags = FSCACHE_OP_MYTHREAD |
(1 << FSCACHE_OP_WAITING) |
(1 << FSCACHE_OP_UNUSE_COOKIE);
trace_fscache_page_op(cookie, NULL, op, fscache_page_op_check_consistency);

spin_lock(&cookie->lock);

Expand Down
3 changes: 2 additions & 1 deletion fs/fscache/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,11 +982,12 @@ static const struct fscache_state *_fscache_invalidate_object(struct fscache_obj
if (!op)
goto nomem;

fscache_operation_init(op, object->cache->ops->invalidate_object,
fscache_operation_init(cookie, op, object->cache->ops->invalidate_object,
NULL, NULL);
op->flags = FSCACHE_OP_ASYNC |
(1 << FSCACHE_OP_EXCLUSIVE) |
(1 << FSCACHE_OP_UNUSE_COOKIE);
trace_fscache_page_op(cookie, NULL, op, fscache_page_op_invalidate);

spin_lock(&cookie->lock);
if (fscache_submit_exclusive_op(object, op) < 0)
Expand Down
26 changes: 25 additions & 1 deletion fs/fscache/operation.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ static void fscache_operation_dummy_cancel(struct fscache_operation *op)
* Do basic initialisation of an operation. The caller must still set flags,
* object and processor if needed.
*/
void fscache_operation_init(struct fscache_operation *op,
void fscache_operation_init(struct fscache_cookie *cookie,
struct fscache_operation *op,
fscache_operation_processor_t processor,
fscache_operation_cancel_t cancel,
fscache_operation_release_t release)
Expand All @@ -46,6 +47,7 @@ void fscache_operation_init(struct fscache_operation *op,
op->release = release;
INIT_LIST_HEAD(&op->pend_link);
fscache_stat(&fscache_n_op_initialised);
trace_fscache_op(cookie, op, fscache_op_init);
}
EXPORT_SYMBOL(fscache_operation_init);

Expand All @@ -59,6 +61,8 @@ EXPORT_SYMBOL(fscache_operation_init);
*/
void fscache_enqueue_operation(struct fscache_operation *op)
{
struct fscache_cookie *cookie = op->object->cookie;

_enter("{OBJ%x OP%x,%u}",
op->object->debug_id, op->debug_id, atomic_read(&op->usage));

Expand All @@ -71,12 +75,14 @@ void fscache_enqueue_operation(struct fscache_operation *op)
fscache_stat(&fscache_n_op_enqueue);
switch (op->flags & FSCACHE_OP_TYPE) {
case FSCACHE_OP_ASYNC:
trace_fscache_op(cookie, op, fscache_op_enqueue_async);
_debug("queue async");
atomic_inc(&op->usage);
if (!queue_work(fscache_op_wq, &op->work))
fscache_put_operation(op);
break;
case FSCACHE_OP_MYTHREAD:
trace_fscache_op(cookie, op, fscache_op_enqueue_mythread);
_debug("queue for caller's attention");
break;
default:
Expand All @@ -101,6 +107,8 @@ static void fscache_run_op(struct fscache_object *object,
wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
if (op->processor)
fscache_enqueue_operation(op);
else
trace_fscache_op(object->cookie, op, fscache_op_run);
fscache_stat(&fscache_n_op_run);
}

Expand Down Expand Up @@ -155,6 +163,8 @@ int fscache_submit_exclusive_op(struct fscache_object *object,

_enter("{OBJ%x OP%x},", object->debug_id, op->debug_id);

trace_fscache_op(object->cookie, op, fscache_op_submit_ex);

ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED);
ASSERTCMP(atomic_read(&op->usage), >, 0);

Expand Down Expand Up @@ -240,6 +250,8 @@ int fscache_submit_op(struct fscache_object *object,
_enter("{OBJ%x OP%x},{%u}",
object->debug_id, op->debug_id, atomic_read(&op->usage));

trace_fscache_op(object->cookie, op, fscache_op_submit);

ASSERTCMP(op->state, ==, FSCACHE_OP_ST_INITIALISED);
ASSERTCMP(atomic_read(&op->usage), >, 0);

Expand Down Expand Up @@ -357,6 +369,8 @@ int fscache_cancel_op(struct fscache_operation *op,

_enter("OBJ%x OP%x}", op->object->debug_id, op->debug_id);

trace_fscache_op(object->cookie, op, fscache_op_cancel);

ASSERTCMP(op->state, >=, FSCACHE_OP_ST_PENDING);
ASSERTCMP(op->state, !=, FSCACHE_OP_ST_CANCELLED);
ASSERTCMP(atomic_read(&op->usage), >, 0);
Expand Down Expand Up @@ -419,6 +433,8 @@ void fscache_cancel_all_ops(struct fscache_object *object)
fscache_stat(&fscache_n_op_cancelled);
list_del_init(&op->pend_link);

trace_fscache_op(object->cookie, op, fscache_op_cancel_all);

ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
op->cancel(op);
op->state = FSCACHE_OP_ST_CANCELLED;
Expand Down Expand Up @@ -454,9 +470,11 @@ void fscache_op_complete(struct fscache_operation *op, bool cancelled)
spin_lock(&object->lock);

if (!cancelled) {
trace_fscache_op(object->cookie, op, fscache_op_completed);
op->state = FSCACHE_OP_ST_COMPLETE;
} else {
op->cancel(op);
trace_fscache_op(object->cookie, op, fscache_op_cancelled);
op->state = FSCACHE_OP_ST_CANCELLED;
}

Expand Down Expand Up @@ -488,6 +506,8 @@ void fscache_put_operation(struct fscache_operation *op)
if (!atomic_dec_and_test(&op->usage))
return;

trace_fscache_op(op->object->cookie, op, fscache_op_put);

_debug("PUT OP");
ASSERTIFCMP(op->state != FSCACHE_OP_ST_INITIALISED &&
op->state != FSCACHE_OP_ST_COMPLETE,
Expand Down Expand Up @@ -563,6 +583,8 @@ void fscache_operation_gc(struct work_struct *work)
spin_unlock(&cache->op_gc_list_lock);

object = op->object;
trace_fscache_op(object->cookie, op, fscache_op_gc);

spin_lock(&object->lock);

_debug("GC DEFERRED REL OBJ%x OP%x",
Expand Down Expand Up @@ -601,6 +623,8 @@ void fscache_op_work_func(struct work_struct *work)
_enter("{OBJ%x OP%x,%d}",
op->object->debug_id, op->debug_id, atomic_read(&op->usage));

trace_fscache_op(op->object->cookie, op, fscache_op_work);

ASSERT(op->processor != NULL);
start = jiffies;
op->processor(op);
Expand Down
Loading

0 comments on commit 08c2e3d

Please sign in to comment.