Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2246282rwi; Tue, 11 Oct 2022 06:40:01 -0700 (PDT) X-Google-Smtp-Source: AMsMyM64GDpTLbHtXsKdkOziJzsGnFuQg5S4/KBS/0T90paI1STWbLIb7CjfWYICeWSyIocVYpci X-Received: by 2002:a17:906:58c8:b0:6fe:91d5:18d2 with SMTP id e8-20020a17090658c800b006fe91d518d2mr19310580ejs.190.1665495601421; Tue, 11 Oct 2022 06:40:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665495601; cv=none; d=google.com; s=arc-20160816; b=RfhXUvNgA1+6W8uhAVKiQKFOA9pcFl1N5+UP6zDwJ/+A1hsWNDQtZiAEDPhrvXxwSG ngyEnVVNcTnwilxICFARDZypQCe0nypgr2fbFqbHMh0GILaLMibo1t5LSK4cpkZXayxb B7tpvkimVToiC8tLSbIkHw7zdAqpo/Xcdd0IKI4pZkY9OsMEQop5+jYXVRXWzyAl4cRl IUOfaxFGfOU5URf3TT1T6f/YMGlt6btFT3Wez7gAmB0NjxrBSm2y65PM0LngS7Ke0NAZ J+IT8ZKeDPurc9qAGHFu+AIRdncnVFbh8S+ujqxIxP5JsnVDEEhRu3leijdr7gOip0/2 Ra/w== 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=dX9f5qZPLVHrgCUiGgy5JOsn3quuTKMm5YppO0P4KlY=; b=xL5WYWfMuppMTFobShxugJ3RyfRqCVDmSKiE6NavgRl6Bj8UjIBU3LlZ+eQt8huvIB T3ciqn/BSpjMb+TSbMd9MMootPY+pnfUYcdaEWRE0AncG13ZL6ct07OruPrnRV+/wyWH AGbYR5v+6xjWGATv9gd3zwJwlfY/r9uoznAYPBXBmNaaxnXhi5mNc8vu7tlFmganDqRV REDRqsL3X6m33msgiHgPKmgQ41ZX5//DkvJN2yM2/db/9NRCZ7fxhn+tj+aDFeOuw4gP Z+aLUChAwVCte3jphKwU09QvTIRC5MUHOk4hl9JrRujYRDRz3Ye8WjqA/Oc3/udGe/M1 +FFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b="F65b2P/G"; 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 co28-20020a0564020c1c00b0043d00293d23si11152900edb.391.2022.10.11.06.39.25; Tue, 11 Oct 2022 06:40:01 -0700 (PDT) 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="F65b2P/G"; 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 S230163AbiJKNSE (ORCPT + 99 others); Tue, 11 Oct 2022 09:18:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230082AbiJKNRS (ORCPT ); Tue, 11 Oct 2022 09:17:18 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1B3E8260C for ; Tue, 11 Oct 2022 06:16:28 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id b2so13142456plc.7 for ; Tue, 11 Oct 2022 06:16:28 -0700 (PDT) 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=dX9f5qZPLVHrgCUiGgy5JOsn3quuTKMm5YppO0P4KlY=; b=F65b2P/G06eaZvAyboOoRaXh7m+6agjce1dFZUanFKLUUaBMRPvPytdz6aG/A2p9L2 LQU9Ga6MtZpeLnIa+DgP8/C5+SxccG8Sh9VG0OfGE3Jwesgnvo00+D0qPCzi3MFUTvof ekuDjZgPlMF/CqSvumHBpryDcTnQHmcaIkdJNm/Wz7ffETRrRS9MluJaoWMHM5PKjDIb VCexd3Wztbj4W6kda0U6rtFfniOgBf7oW9PWko0NEwPs9ksrBlwQohgxjVOFmZhNcu12 RdA6woNdXgvbuNd6bI03lWZvMQ27FTSuU5CUnfFzaLjqF1UPg9YwaJhJpBps9+8xudW6 hfdw== 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=dX9f5qZPLVHrgCUiGgy5JOsn3quuTKMm5YppO0P4KlY=; b=3Mq4FVF5Jtv6V70vFkuHtTWUVdGkXLRZS8kVPUmL5VY8UZO7qBn1RJ5fuhbdif8pYc siG7z69NqfUoDDvpH6C7Km3qBGECI8tCS/a4tnq+nqCOMngkJ1Wfv3Ux/EZ3KV4yE7Dy X0V0eDBlSPkkU+fSPP75wCrvOBNbTqWy52KyKJ5aOzMrDrhMuNWWD3DlQ41S7doENBPx W2IXVPuJSmB/xmRKujDcm+x3aBbYVPSLppgNw4oeCToUHHVCBnZUlycGZ/FSixzbJAZD x7nHxBkWOTIquNaoTStl/Var5zEj/m3t7mhjoGCfWL7JlsanH1QcaJEtkoDq8rgMRt5g BhBA== X-Gm-Message-State: ACrzQf1nn8C3bf9IxPF9HKmu4WagwsLk3M4sMFYKL2dhMZ28XtPK67Ob VEtM4m59rWIC8L8ZCXyEWhfceg== X-Received: by 2002:a17:902:848c:b0:17a:b4c0:a02b with SMTP id c12-20020a170902848c00b0017ab4c0a02bmr24145709plo.122.1665494179680; Tue, 11 Oct 2022 06:16:19 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([63.216.146.190]) by smtp.gmail.com with ESMTPSA id d14-20020a170902654e00b00181f8523f60sm4773415pln.225.2022.10.11.06.16.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Oct 2022 06:16:19 -0700 (PDT) From: Jia Zhu To: dhowells@redhat.com, xiang@kernel.org, jefflexu@linux.alibaba.com Cc: linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yinxin.x@bytedance.com, Jia Zhu Subject: [PATCH 4/5] cachefiles: narrow the scope of triggering EPOLLIN events in ondemand mode Date: Tue, 11 Oct 2022 21:15:51 +0800 Message-Id: <20221011131552.23833-5-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20221011131552.23833-1-zhujia.zj@bytedance.com> References: <20221011131552.23833-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=unavailable 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 --- fs/cachefiles/daemon.c | 13 +++++++++++-- fs/cachefiles/internal.h | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c index aa4efcabb5e3..c74bd1f4ecf5 100644 --- a/fs/cachefiles/daemon.c +++ b/fs/cachefiles/daemon.c @@ -355,14 +355,23 @@ 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_for_each_marked(xa, index, req, CACHEFILES_REQ_NEW) { + if (!cachefiles_ondemand_is_reopening_read(req)) { + mask |= EPOLLIN; + break; + } + } + } } else { if (test_bit(CACHEFILES_STATE_CHANGED, &cache->flags)) mask |= EPOLLIN; diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index a9f45972945d..4655b8a14a60 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -340,6 +340,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) @@ -367,6 +374,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