Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

FS-Cache: Mark cancellation of in-progress operation

Mark as cancelled an operation that is in progress rather than pending at the
time it is cancelled, and call fscache_complete_op() to cancel an operation so
that blocked ops can be started.

Signed-off-by: David Howells <dhowells@redhat.com>

+12 -11
+1 -1
fs/cachefiles/interface.c
··· 484 484 } 485 485 } 486 486 487 - fscache_op_complete(op); 487 + fscache_op_complete(op, true); 488 488 _leave(""); 489 489 } 490 490
+4 -3
fs/fscache/operation.c
··· 363 363 } 364 364 365 365 /* 366 - * Record the completion of an in-progress operation. 366 + * Record the completion or cancellation of an in-progress operation. 367 367 */ 368 - void fscache_op_complete(struct fscache_operation *op) 368 + void fscache_op_complete(struct fscache_operation *op, bool cancelled) 369 369 { 370 370 struct fscache_object *object = op->object; 371 371 ··· 380 380 381 381 spin_lock(&object->lock); 382 382 383 - op->state = FSCACHE_OP_ST_COMPLETE; 383 + op->state = cancelled ? 384 + FSCACHE_OP_ST_CANCELLED : FSCACHE_OP_ST_COMPLETE; 384 385 385 386 if (test_bit(FSCACHE_OP_EXCLUSIVE, &op->flags)) 386 387 object->n_exclusive--;
+5 -5
fs/fscache/page.c
··· 171 171 fscache_abort_object(object); 172 172 } 173 173 174 - fscache_op_complete(op); 174 + fscache_op_complete(op, true); 175 175 _leave(""); 176 176 } 177 177 ··· 704 704 * exists, so we should just cancel this write operation. 705 705 */ 706 706 spin_unlock(&object->lock); 707 - op->op.state = FSCACHE_OP_ST_CANCELLED; 707 + fscache_op_complete(&op->op, false); 708 708 _leave(" [inactive]"); 709 709 return; 710 710 } ··· 717 717 * cancel this write operation. 718 718 */ 719 719 spin_unlock(&object->lock); 720 - op->op.state = FSCACHE_OP_ST_CANCELLED; 720 + fscache_op_complete(&op->op, false); 721 721 _leave(" [cancel] op{f=%lx s=%u} obj{s=%u f=%lx}", 722 722 _op->flags, _op->state, object->state, object->flags); 723 723 return; ··· 755 755 fscache_end_page_write(object, page); 756 756 if (ret < 0) { 757 757 fscache_abort_object(object); 758 - fscache_op_complete(&op->op); 758 + fscache_op_complete(&op->op, true); 759 759 } else { 760 760 fscache_enqueue_operation(&op->op); 761 761 } ··· 770 770 spin_unlock(&cookie->stores_lock); 771 771 clear_bit(FSCACHE_OBJECT_PENDING_WRITE, &object->flags); 772 772 spin_unlock(&object->lock); 773 - fscache_op_complete(&op->op); 773 + fscache_op_complete(&op->op, true); 774 774 _leave(""); 775 775 } 776 776
+2 -2
include/linux/fscache-cache.h
··· 116 116 extern void fscache_op_work_func(struct work_struct *work); 117 117 118 118 extern void fscache_enqueue_operation(struct fscache_operation *); 119 - extern void fscache_op_complete(struct fscache_operation *); 119 + extern void fscache_op_complete(struct fscache_operation *, bool); 120 120 extern void fscache_put_operation(struct fscache_operation *); 121 121 122 122 /** ··· 196 196 { 197 197 op->n_pages -= n_pages; 198 198 if (op->n_pages <= 0) 199 - fscache_op_complete(&op->op); 199 + fscache_op_complete(&op->op, true); 200 200 } 201 201 202 202 /**