Received: by 2002:ab2:6841:0:b0:1f8:2b01:8fb7 with SMTP id l1csp1988262lqp; Wed, 15 May 2024 06:04:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWncn/6I7CL1WCA1t2geGlNO502f8xzTUDfNcOeCN3SLEd13cfzdVreNMdsqHR9+r8XEdDwfdCNxRwHvpLECablH5eh4Din8SzJOxgNEw== X-Google-Smtp-Source: AGHT+IEqmCI1G7E9cepp7dHYNKfnjVQb2Hu/FYIUXKNEAtMy/W6PJtuMTHRSsgKMpakGaXaRb83F X-Received: by 2002:a05:6808:8f4:b0:3c8:6543:584b with SMTP id 5614622812f47-3c9970d19a0mr17297465b6e.54.1715778263774; Wed, 15 May 2024 06:04:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715778263; cv=pass; d=google.com; s=arc-20160816; b=EJIPeRENspNyg7XrRny9YlyY04AYJEgLSjQXzyqTx9GoyvbMvSuA5SXqsvwREoEimu 7ho2Dj8a3goIkweKqaVPB0QNq5uWLhXK3jpwid49HtZRscX2bfaSHjfIfcpOf2xuroRu nkmx3h3RrpVE9qcNofKvGAELnStbTQ4887Ohssu1RuNYvS0I/jxQoknZoBeaswHEgvFy KxPeVV9tP/lOJBYciKql3VUrXKfkXQyRMWzO94QBABKADZrqCnw/kK32KaSpHNRTNsRw fnx1be3TzlPD7RC0hPIw3dcmf8maUO6UddUMPCIH1lO3sI9eDiJcajwonbCSJ39jbtgK 8p9w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=98Io5krbRELJVr3bt+1mOtfP3/b4TuS9s5E3BAkeqBY=; fh=dfpuzL54LAMf7GQmHoqmub+qZCPWKUPNTVFHnj8Vxqk=; b=RFfJNaMMstfXJ6tsVkOThRVVjKFggLZAcD0ig1aG/WtOlRGxQSeQQP8Wtrni7Adhno DI7CYRCs8ZZGlS5KTmOj0eb+kxUDrs2Fo47wPPA3GNnUVAmBTo9rN3vMHS7ZmhgnaKnX hqeUVhKS9J5Wu/hAI3he6xyNAGu80kNPmsAJ1MAKvDjm3/Ros9nXt2m1renWSmwMxMxD mq+tpiwRrnB22KMewQAQTYjWz3pmYbVbdoIBbS+kIpnq6NVqyt2JXDT9GYCKGjSpBly6 Es3kbAvo2nV3VkVZjVwKZ2rvvMn0Mfz0IOruhwYe59GE1AuChUOrd2Zl3mJPz7R2dhto CgYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-179873-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179873-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ada2fe7eead31-4837c951d31si130929137.367.2024.05.15.06.04.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 May 2024 06:04:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179873-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-179873-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179873-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E36A21C2346A for ; Wed, 15 May 2024 13:03:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A271A12AAEB; Wed, 15 May 2024 13:02:19 +0000 (UTC) Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60D4E128832; Wed, 15 May 2024 13:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715778139; cv=none; b=UN5JaIB91WgfGEpdBAYZqN83w1HzGvxq4VwsMRXJvfzUyVmrvcKHLDJJtof3bdM18x56L5wMDQF0Lcs2XytbzIL/u85YG88OI3Nzk4saR5QfpRH54vfroL1Q4hbSe+bmIYgGH+wiW4zSHp2haTmF7P0r2HnVql6Pq4OG8rPBjEc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715778139; c=relaxed/simple; bh=rGUz3tqre6jZkRHHLRInW4qyEWvdmDURPSrNf7qY06c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KURTSOMd3fXrxh++ELHPawrp3ObZENLlc68dzFDxnlvNX7TUxSTjRKrIR8CxhASWow42i9O+wNvLu7OpkEXqSx+gxKbBcNxAF+DVP+LC93AQz0sMXleEWWKGRa8AmHrVggts35G4Xs4Fdmq+G6/A512eLz839FJBBoQMpnlt/x0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VfYK72H2Tz4f3k69; Wed, 15 May 2024 21:02:03 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id DA7C11A109C; Wed, 15 May 2024 21:02:08 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgAX6RFLskRmALLwMg--.18738S6; Wed, 15 May 2024 21:02:08 +0800 (CST) From: libaokun@huaweicloud.com To: netfs@lists.linux.dev, dhowells@redhat.com, jlayton@kernel.org Cc: hsiangkao@linux.alibaba.com, jefflexu@linux.alibaba.com, zhujia.zj@bytedance.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, libaokun@huaweicloud.com, yangerkun@huawei.com, houtao1@huawei.com, yukuai3@huawei.com, wozizhi@huawei.com, Baokun Li Subject: [PATCH v2 2/5] cachefiles: flush all requests for the object that is being dropped Date: Wed, 15 May 2024 20:51:33 +0800 Message-Id: <20240515125136.3714580-3-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240515125136.3714580-1-libaokun@huaweicloud.com> References: <20240515125136.3714580-1-libaokun@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID:cCh0CgAX6RFLskRmALLwMg--.18738S6 X-Coremail-Antispam: 1UD129KBjvJXoW7ur15uFWrWFWrWFyrJF47Jwb_yoW8WFWxpF WayFy3KFy8uFsFkrZ3XFZ5trySy3ykuFnrX3Waqa95Arn8XryrZr1rtw1DXFy5A393Xr4x tw4YkF9xG3yqkrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPC14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWUuVWrJwAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jryl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_Xr0_Ar1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwAKzVCY07xG64k0F24l42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1l x2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14 v26r1q6r43MIIYrxkI7VAKI48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IY x2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87 Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI 43ZEXa7VUbhvtJUUUUU== X-CM-SenderInfo: 5olet0hnxqqx5xdzvxpfor3voofrz/ From: Baokun Li Because after an object is dropped, requests for that object are useless, flush them to avoid causing other problems. This prepares for the later addition of cancel_work_sync(). After the reopen requests is generated, flush it to avoid cancel_work_sync() blocking by waiting for daemon to complete the reopen requests. Signed-off-by: Baokun Li --- fs/cachefiles/ondemand.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c index 73da4d4eaa9b..d24bff43499b 100644 --- a/fs/cachefiles/ondemand.c +++ b/fs/cachefiles/ondemand.c @@ -564,12 +564,31 @@ int cachefiles_ondemand_init_object(struct cachefiles_object *object) void cachefiles_ondemand_clean_object(struct cachefiles_object *object) { + unsigned long index; + struct cachefiles_req *req; + struct cachefiles_cache *cache; + if (!object->ondemand) return; cachefiles_ondemand_send_req(object, CACHEFILES_OP_CLOSE, 0, cachefiles_ondemand_init_close_req, NULL); + + if (!object->ondemand->ondemand_id) + return; + + /* Flush all requests for the object that is being dropped. */ + cache = object->volume->cache; + xa_lock(&cache->reqs); cachefiles_ondemand_set_object_dropping(object); + xa_for_each(&cache->reqs, index, req) { + if (req->object == object) { + req->error = -EIO; + complete(&req->done); + __xa_erase(&cache->reqs, index); + } + } + xa_unlock(&cache->reqs); } int cachefiles_ondemand_init_obj_info(struct cachefiles_object *object, -- 2.39.2