Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp8932873rwl; Tue, 10 Jan 2023 22:20:14 -0800 (PST) X-Google-Smtp-Source: AMrXdXv+11czAYSulHmMdUXseYfFbzo9sJsvCkZgtf2oV069actRVffg4crzcAaFwWR6OHUl9d8a X-Received: by 2002:a17:907:d10f:b0:83f:cbfd:31a9 with SMTP id uy15-20020a170907d10f00b0083fcbfd31a9mr54636720ejc.47.1673418014600; Tue, 10 Jan 2023 22:20:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673418014; cv=none; d=google.com; s=arc-20160816; b=l2IAAeAowSJlLCK5V23i9gP9LKjCe+UN7Xa3d04abKcuEyB6itkkK9GyXeJQdCdkNF jthQN/51YSLXHcUjWTkAU6yl1nKryebrcuzAHvBKmIGK2K6WsZOzz1TuZnBbKr3l1qeW CZQXLmdarQsq/7CzYhcLRl6vPA7qMkecz+6uMyqKJ5zzGfpPqK9DuUJa52VPUvCj1NFl AX3Gz2IdXwdSxECSuzX6DxJ8n9GqyQM9Z2ZFZCZVoDwK1erStttjuSj4Nkl+gFIqtCK1 BeV3+9vrK8yGZAJzOO+Uv+7YLVJNRZ0d65/4nnirjj22DsdGzzxj+NKchdzmxlHFqWBg LsVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=pDYD8kdF4QcIxV+XVTzksOOF3bsvD3XSTsyoZ+oU6es=; b=PyvfF63yCQxU9aevZhZjetD8KHqtKFNhsk+ZEkLo67fRwPMsFna+5eWrtjFJjXg4LR +SR2jBOma0OmxpZm9q0ofnUeDIblYTZ1heCBdK56vJKuFVvyu2SuR5mGkYD/8tNcyMCC cBTCC4W0BZKb8kyIBoEXgDVrocx3aTZy8wNwZQC4sgrvjTCBM0Aiag1B+eUECaox04aB x0fs2c2f8NI1wSVbBrkwswL0cMNS2ZMahxQh3Brb41JW6pLFyF2G3gUIaCb5O+SeJPYD 5iL+65yZg8SblptRuwNnrAdtQGKiTtMYDEsW8sUzn6Jy9Y/AvI6OA+0ldALkAQf7qmZZ pr2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=OmLcznBU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc41-20020a17090716a900b007ae74740fa4si5551236ejc.275.2023.01.10.22.20.02; Tue, 10 Jan 2023 22:20:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=OmLcznBU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230314AbjAKFhK (ORCPT + 53 others); Wed, 11 Jan 2023 00:37:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229592AbjAKFgf (ORCPT ); Wed, 11 Jan 2023 00:36:35 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 082A53C722 for ; Tue, 10 Jan 2023 21:25:40 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id n12so14733132pjp.1 for ; Tue, 10 Jan 2023 21:25:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pDYD8kdF4QcIxV+XVTzksOOF3bsvD3XSTsyoZ+oU6es=; b=OmLcznBUhwb6V7Iv7/A44e+lcoabUFSifrsud2HZbjVV7xNimVZi/xOnDXpfOVYkOV 0pgBY+uBOAHtdIjKnohFMo4hqlkBl9ZHyeqyzBaySzyKorNmjJiUSWtNAu1MnThr9bZ0 03dCX3pZ6EOLf0aI13y7Ym+iM2d6scbetEoZSNrRqLYPoVSFETLAuGx1cNfb9JjnrSTc mT157ARyhoes8Nqvpe4yrO/lbpCdnXgoypUyCK5igRGq+PUyXMi/WFxz99+plbto03cw sJIne/4ds8ktscqloKaTaaJHVs23pSHwZOS/mCkjRrjfeSok1V4aNUnBCpmKLtHysNCz qxbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pDYD8kdF4QcIxV+XVTzksOOF3bsvD3XSTsyoZ+oU6es=; b=Zy6aaJnJjUuJ7XbdeIknIobbkEg34wMIuPhkZNCeZc3WJS/KS53ofaJlpC3b5aog/I tzS+KbARl+D9FjhXlTv6QeFwu0iTtA9djaruvqso/JnIao2AlkowuECYSECxEPr2elbF lGZMfn/jCxkuRPIf6ofnGOsS2yIUOGR5t9wQAyIrr40BlqjjqD0gEjmCbnFdvHTFTo/x ZPBvIscdffgujBmyU88etqSqmu6m6eKicBHgTx/dRZ5WH4vpHICg8wwHLBoNtuUI0nEI 9ubryGXaT4/fXE6Zw7CC71JCZKkR8B4c7gQUF4yYpykAvW2+gKfX1nRqwqWY3jGh+DOu /X6w== X-Gm-Message-State: AFqh2kqQOSdm/K+15suI2Vkys6g78lbqOqazaHGyZR5joqkoTDY37+DS lMpDHIxFNoNWZKWCOy3xV1ZXaWrs21ygj0mD X-Received: by 2002:a17:902:968d:b0:192:8d74:99e0 with SMTP id n13-20020a170902968d00b001928d7499e0mr46324926plp.4.1673414739479; Tue, 10 Jan 2023 21:25:39 -0800 (PST) Received: from C02G705SMD6V.bytedance.net ([61.213.176.10]) by smtp.gmail.com with ESMTPSA id l10-20020a170903244a00b0019334350ce6sm4934520pls.244.2023.01.10.21.25.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Jan 2023 21:25:39 -0800 (PST) From: Jia Zhu To: dhowells@redhat.com Cc: linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jia Zhu , Xin Yin , Jingbo Xu Subject: [PATCH V4 4/5] cachefiles: narrow the scope of triggering EPOLLIN events in ondemand mode Date: Wed, 11 Jan 2023 13:25:14 +0800 Message-Id: <20230111052515.53941-5-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.1 (Apple Git-137.1) In-Reply-To: <20230111052515.53941-1-zhujia.zj@bytedance.com> References: <20230111052515.53941-1-zhujia.zj@bytedance.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Don't trigger EPOLLIN when there are only reopening read requests in xarray. Suggested-by: Xin Yin Signed-off-by: Jia Zhu Reviewed-by: Jingbo Xu --- fs/cachefiles/daemon.c | 15 +++++++++++++-- fs/cachefiles/internal.h | 12 ++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index aa4efcabb5e3..b8d8f280fb7a 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c @@ -355,14 +355,25 @@ static __poll_t cachefiles_daemon_poll(struct file *file, struct poll_table_struct *poll) { struct cachefiles_cache *cache = file->private_data; + struct xarray *xa = &cache->reqs; + struct cachefiles_req *req; + unsigned long index; __poll_t mask; poll_wait(file, &cache->daemon_pollwq, poll); mask = 0; if (cachefiles_in_ondemand_mode(cache)) { - if (!xa_empty(&cache->reqs)) - mask |= EPOLLIN; + if (!xa_empty(xa)) { + xa_lock(xa); + xa_for_each_marked(xa, index, req, CACHEFILES_REQ_NEW) { + if (!cachefiles_ondemand_is_reopening_read(req)) { + mask |= EPOLLIN; + break; + } + } + xa_unlock(xa); + } } else { if (test_bit(CACHEFILES_STATE_CHANGED, &cache->flags)) mask |= EPOLLIN; diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index 2ed836d4169e..3d94990a8b38 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -326,6 +326,13 @@ cachefiles_ondemand_set_object_##_state(struct cachefiles_object *object) \ CACHEFILES_OBJECT_STATE_FUNCS(open); CACHEFILES_OBJECT_STATE_FUNCS(close); CACHEFILES_OBJECT_STATE_FUNCS(reopening); + +static inline bool cachefiles_ondemand_is_reopening_read(struct cachefiles_req *req) +{ + return cachefiles_ondemand_object_is_reopening(req->object) && + req->msg.opcode == CACHEFILES_OP_READ; +} + #else static inline ssize_t cachefiles_ondemand_daemon_read(struct cachefiles_cache *cache, char __user *_buffer, size_t buflen) @@ -353,6 +360,11 @@ static inline int cachefiles_ondemand_init_obj_info(struct cachefiles_object *ob { return 0; } + +static inline bool cachefiles_ondemand_is_reopening_read(struct cachefiles_req *req) +{ + return false; +} #endif /* -- 2.20.1