aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fscache/operation.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2012-12-20 16:52:36 -0500
committerDavid Howells <dhowells@redhat.com>2012-12-20 17:04:07 -0500
commitef778e7ae67cd426c30cad43378b908f5eb0bad5 (patch)
tree4893f19487cb99e8ec0eb835ec4391d952641a9c /fs/fscache/operation.c
parent9f10523f891928330b7529da54c1a3cc65180b1a (diff)
FS-Cache: Provide proper invalidation
Provide a proper invalidation method rather than relying on the netfs retiring the cookie it has and getting a new one. The problem with this is that isn't easy for the netfs to make sure that it has completed/cancelled all its outstanding storage and retrieval operations on the cookie it is retiring. Instead, have the cache provide an invalidation method that will cancel or wait for all currently outstanding operations before invalidating the cache, and will cause new operations to queue up behind that. Whilst invalidation is in progress, some requests will be rejected until the cache can stack a barrier on the operation queue to cause new operations to be deferred behind it. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'fs/fscache/operation.c')
-rw-r--r--fs/fscache/operation.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
index 748f9553c2cb..c58dbe613266 100644
--- a/fs/fscache/operation.c
+++ b/fs/fscache/operation.c
@@ -324,6 +324,38 @@ int fscache_cancel_op(struct fscache_operation *op)
324} 324}
325 325
326/* 326/*
327 * Cancel all pending operations on an object
328 */
329void fscache_cancel_all_ops(struct fscache_object *object)
330{
331 struct fscache_operation *op;
332
333 _enter("OBJ%x", object->debug_id);
334
335 spin_lock(&object->lock);
336
337 while (!list_empty(&object->pending_ops)) {
338 op = list_entry(object->pending_ops.next,
339 struct fscache_operation, pend_link);
340 fscache_stat(&fscache_n_op_cancelled);
341 list_del_init(&op->pend_link);
342
343 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
344 op->state = FSCACHE_OP_ST_CANCELLED;
345
346 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags))
347 object->n_exclusive--;
348 if (test_and_clear_bit(FSCACHE_OP_WAITING, &op->flags))
349 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
350 fscache_put_operation(op);
351 cond_resched_lock(&object->lock);
352 }
353
354 spin_unlock(&object->lock);
355 _leave("");
356}
357
358/*
327 * Record the completion of an in-progress operation. 359 * Record the completion of an in-progress operation.
328 */ 360 */
329void fscache_op_complete(struct fscache_operation *op) 361void fscache_op_complete(struct fscache_operation *op)