Skip to content

Commit 751f524

Browse files
LiBaokun96brauner
authored andcommitted
cachefiles: cancel all requests for the object that is being dropped
Because after an object is dropped, requests for that object are useless, cancel them to avoid causing other problems. This prepares for the later addition of cancel_work_sync(). After the reopen requests is generated, cancel it to avoid cancel_work_sync() blocking by waiting for daemon to complete the reopen requests. Signed-off-by: Baokun Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Jeff Layton <[email protected]> Reviewed-by: Gao Xiang <[email protected]> Reviewed-by: Jia Zhu <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
1 parent b2415d1 commit 751f524

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

fs/cachefiles/ondemand.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,31 @@ int cachefiles_ondemand_init_object(struct cachefiles_object *object)
564564

565565
void cachefiles_ondemand_clean_object(struct cachefiles_object *object)
566566
{
567+
unsigned long index;
568+
struct cachefiles_req *req;
569+
struct cachefiles_cache *cache;
570+
567571
if (!object->ondemand)
568572
return;
569573

570574
cachefiles_ondemand_send_req(object, CACHEFILES_OP_CLOSE, 0,
571575
cachefiles_ondemand_init_close_req, NULL);
576+
577+
if (!object->ondemand->ondemand_id)
578+
return;
579+
580+
/* Cancel all requests for the object that is being dropped. */
581+
cache = object->volume->cache;
582+
xa_lock(&cache->reqs);
572583
cachefiles_ondemand_set_object_dropping(object);
584+
xa_for_each(&cache->reqs, index, req) {
585+
if (req->object == object) {
586+
req->error = -EIO;
587+
complete(&req->done);
588+
__xa_erase(&cache->reqs, index);
589+
}
590+
}
591+
xa_unlock(&cache->reqs);
573592
}
574593

575594
int cachefiles_ondemand_init_obj_info(struct cachefiles_object *object,

0 commit comments

Comments
 (0)