Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp176525lqd; Tue, 23 Apr 2024 20:43:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVEuVVSScaFp4YgsWvEt0Ua8xQFs2vRidmdbaU1skMzfltSPU4PFxRBGHJEMnokWat74wHl4/CekD/39JdxNzTqTeub6dNL2gr4ZJvuvQ== X-Google-Smtp-Source: AGHT+IGhmy4ZXw1qrLMEl7zOgP0fcdzCjf+EQiUnYaFcFYKFvuzX66zSI/Oeae9f8AbvqIR9FeeH X-Received: by 2002:a50:8e0f:0:b0:56e:238e:372c with SMTP id 15-20020a508e0f000000b0056e238e372cmr697517edw.26.1713930228983; Tue, 23 Apr 2024 20:43:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713930228; cv=pass; d=google.com; s=arc-20160816; b=08mEZx4hJxWhruQjrSYFCoiZwbkulNHHyHhPqWA5b2g5s1+Taxa1Q6qFG+5SnuxvFM q0xKYyVd3JeuynGlsQZmU5sJjWlg7aTmPiEhvMuEBZf9UcEMIrWEzKnqfHWGwLjeidbQ 2/oBiKuUiqRPuRB9Yr66pEM1pXHHyrL51HDyC6o3mtyzLcccIwRsFhgAxkgdqWczyUnb 8mNA2j2RY3X/pct57wLxNcetnjmrJ9FY6VMeJoXAP8aRJbdXoSY3IotXgdrmjvLcpnaV BNBVqesdBlKH6//k14IVSxQJ+v7akgeWQxIWA1dh0cRmg7Sz8v4dN08Un9p4P2C+Go6q P2JA== 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=jkZh2F5uC4DWR8uaaHzricRiTuB5OK8z4k9eP0JJR0g=; fh=Ye1aB3Y8ZI5cub/+xDqe1Iol73ORxWApZQj750gAZJs=; b=Q1caX9Ua7blsvm9o1lgekaM56ETCcyo6cqrO3dMs2kIYcoA/pEQ5bMb33cdC+8e2nY 89sw39tQezEEazCrr8HVi4hAyDnFCS4U/HGAiDhjtjivIQibDsRErCZMa2pLHFn/tbp4 cnrLZpotBdMLpL73Zzq9C5TiusAdUQvXU3O7EghP3pnjUT53upWrgUgwMVZsLZ6s7nfF OelQGYsQys47RbeENbXCylfRdEMRSz3EwBPrwkpGCx9wWJjfo+l1wKxIYwoo/BZnFGm7 Gg6YIuuwYd3MRsUdQfImU3fnJRKiopa24cCb3PbelazgvsqlqdwqrFOtEReDuWrH+tWZ 78Bw==; 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-156226-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156226-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id f13-20020a0564021e8d00b0057211ccf863si2957864edf.630.2024.04.23.20.43.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 20:43:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156226-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huaweicloud.com); spf=pass (google.com: domain of linux-kernel+bounces-156226-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156226-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 am.mirrors.kernel.org (Postfix) with ESMTPS id B3CCD1F2479F for ; Wed, 24 Apr 2024 03:43:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FA4214290F; Wed, 24 Apr 2024 03:43:29 +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 4390D139CEB; Wed, 24 Apr 2024 03:43:27 +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=1713930208; cv=none; b=Qm6nkDD3MR8S84GyKh8qbaa0kBP+bXKth2rmbVbc/N5uZzdZs469PSimgeCUJTIPp8zn4bRLh0kXDFq2rNc5mxDaDcffsvCcyPeyvUwuBR3/SZ0obbHdgDye/SKWIj9kVbo87/TZEDYHugC2ltyEk8iHviFoHl3XWRub/eJHNrE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713930208; c=relaxed/simple; bh=klE7ewnkfYNzuZ52pxanOrEsvUoVVsXNsM1uSrsVQ1o=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JP8E9Nx3hMV+lvhnbkuCx/ESS5kEiXIZOeCbGv+/8tujvPCFMHopiCFGGkddSk266tDy0c4FLQP77nJ3pfUASAZnsv1sYJFPSojFVj0SGxAkFHBmEkub82WuKIgrRJoJPTzDkbXmd75jJA2SaiNNZ9JxhvxES5suXV5jCCg2IIk= 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.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4VPPw309Hhz4f3nbg; Wed, 24 Apr 2024 11:43:15 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 359071A0572; Wed, 24 Apr 2024 11:43:24 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBHGBHafyhmuSA4Kw--.57541S5; Wed, 24 Apr 2024 11:43:23 +0800 (CST) From: libaokun@huaweicloud.com To: netfs@lists.linux.dev Cc: dhowells@redhat.com, jlayton@kernel.org, zhujia.zj@bytedance.com, jefflexu@linux.alibaba.com, linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, libaokun@huaweicloud.com, Baokun Li Subject: [PATCH 1/5] cachefiles: stop sending new request when dropping object Date: Wed, 24 Apr 2024 11:34:05 +0800 Message-Id: <20240424033409.2735257-2-libaokun@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240424033409.2735257-1-libaokun@huaweicloud.com> References: <20240424033409.2735257-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:cCh0CgBHGBHafyhmuSA4Kw--.57541S5 X-Coremail-Antispam: 1UD129KBjvJXoWxAF47Zw1DXw4rurW3Xw17GFg_yoW5AFW5pF WayFy3Kry8ur17GrZ7Za95GrySy3ykZrnFga4Yq3WUAanIqr4rZr1ktr1DuF1Uu3yxXr43 tw48Casxt3y2y3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUQ014x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWUWVWUuwAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwAKzVCY07xG64k0F24lc7CjxVAKzI0EY4vE52x082I5MxAIw28IcxkI7VAKI48JMxC2 0s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI 0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x0EwIxGrwCI42IY6xIIjxv20xvE 14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWxJVW8Jr1lIxAIcVCF04k26cxKx2 IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_ Gr1j6F4UJbIYCTnIWIevJa73UjIFyTuYvjTRR7KVUUUUU X-CM-SenderInfo: 5olet0hnxqqx5xdzvxpfor3voofrz/ From: Baokun Li Added CACHEFILES_ONDEMAND_OBJSTATE_DROPPING indicates that the cachefiles object is being dropped, and is set after the close request for the dropped object completes, and no new requests are allowed to be sent after this state. Signed-off-by: Baokun Li --- fs/cachefiles/internal.h | 2 ++ fs/cachefiles/ondemand.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index d33169f0018b..8ecd296cc1c4 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -48,6 +48,7 @@ enum cachefiles_object_state { CACHEFILES_ONDEMAND_OBJSTATE_CLOSE, /* Anonymous fd closed by daemon or initial state */ CACHEFILES_ONDEMAND_OBJSTATE_OPEN, /* Anonymous fd associated with object is available */ CACHEFILES_ONDEMAND_OBJSTATE_REOPENING, /* Object that was closed and is being reopened. */ + CACHEFILES_ONDEMAND_OBJSTATE_DROPPING, /* Object is being dropped. */ }; struct cachefiles_ondemand_info { @@ -332,6 +333,7 @@ cachefiles_ondemand_set_object_##_state(struct cachefiles_object *object) \ CACHEFILES_OBJECT_STATE_FUNCS(open, OPEN); CACHEFILES_OBJECT_STATE_FUNCS(close, CLOSE); CACHEFILES_OBJECT_STATE_FUNCS(reopening, REOPENING); +CACHEFILES_OBJECT_STATE_FUNCS(dropping, DROPPING); static inline bool cachefiles_ondemand_is_reopening_read(struct cachefiles_req *req) { diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c index 4ba42f1fa3b4..73da4d4eaa9b 100644 --- a/fs/cachefiles/ondemand.c +++ b/fs/cachefiles/ondemand.c @@ -422,7 +422,8 @@ static int cachefiles_ondemand_send_req(struct cachefiles_object *object, */ xas_lock(&xas); - if (test_bit(CACHEFILES_DEAD, &cache->flags)) { + if (test_bit(CACHEFILES_DEAD, &cache->flags) || + cachefiles_ondemand_object_is_dropping(object)) { xas_unlock(&xas); ret = -EIO; goto out; @@ -463,7 +464,8 @@ static int cachefiles_ondemand_send_req(struct cachefiles_object *object, * If error occurs after creating the anonymous fd, * cachefiles_ondemand_fd_release() will set object to close. */ - if (opcode == CACHEFILES_OP_OPEN) + if (opcode == CACHEFILES_OP_OPEN && + !cachefiles_ondemand_object_is_dropping(object)) cachefiles_ondemand_set_object_close(object); kfree(req); return ret; @@ -562,8 +564,12 @@ int cachefiles_ondemand_init_object(struct cachefiles_object *object) void cachefiles_ondemand_clean_object(struct cachefiles_object *object) { + if (!object->ondemand) + return; + cachefiles_ondemand_send_req(object, CACHEFILES_OP_CLOSE, 0, cachefiles_ondemand_init_close_req, NULL); + cachefiles_ondemand_set_object_dropping(object); } int cachefiles_ondemand_init_obj_info(struct cachefiles_object *object, -- 2.39.2