Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp33745rwi; Thu, 13 Oct 2022 20:52:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4uCfxVhLkPw47VO9iqH6fz1lRFELjlREyi8H5UN2UeC7LnY19norCZS0OLRz0Xabvjv1gp X-Received: by 2002:a17:902:db11:b0:17d:5e67:c51c with SMTP id m17-20020a170902db1100b0017d5e67c51cmr2978842plx.64.1665719550409; Thu, 13 Oct 2022 20:52:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665719550; cv=none; d=google.com; s=arc-20160816; b=IakZ1jwIycvrqTxpNWl5rbDr1l1hen8DCCVQHkmOq3cMvGwPuNhovdA6A/1CBJjBjZ 7Sk3jWdIWwR5M2mf7ldt1AStSPaVJC8Zcq7e94W0DUbuhp/IJASOZ62GpcvEq+ASgnKz kNgouiEH/mlKvyUs4Ggy3lnUrAX6kjQcDPtYOa/m3ZOXTgIi40ljN7i+dbqEnulVylg4 7q0T45sfnVdk9OA9YMVdTvAFVYpJsejglYl78TXd1Vma9oSXFELMwJfPPUdsnxJnJVEh Zp5WJxRMVwTSvBL2Bt5tjcfyLIxhzZRYht1Uf0ugHa5RbPEBU0ybofn1or2gagdABB0y A47g== 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=i1R7QPYLS3htwC9+m+eMmhkdxMHPXqw45xmXhqmncaA=; b=ZM/UPG5muywtC82QYk/hSwiULW5PA9bUkngy3GpWBwUIuyNKWXG9ThQTqJfIWbBHxl Qhg9qUEQL7kZQNeylyKGGU5TAjyFpFt3kIY6O0J7yKkVizonlvUFELS34R95aoHFtFCp I89dd7uQv4W799GHsop+IYyZf71yl6PT/kxnumSAMZc+sRX1o1lS2hhTohkI9R4niYJY Pj2e4ZucCKaKQ+5tTYOmdcZ5lrCLM6uIeNmhfebEpNbMeL5bhC/ay0+RGV2jywqVNYtT UHmEZalZP7ygRYj+a5lQjT5/fR8xldw+KeEEU8gj1xG8bXD3LoPcjisK+YMOPTfWIy0P pk4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=22pn9Os6; 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 z4-20020a6552c4000000b0046439853c62si1438471pgp.127.2022.10.13.20.52.15; Thu, 13 Oct 2022 20:52:30 -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=22pn9Os6; 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 S229679AbiJNDJ1 (ORCPT + 99 others); Thu, 13 Oct 2022 23:09:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229732AbiJNDIk (ORCPT ); Thu, 13 Oct 2022 23:08:40 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DA5BEF589 for ; Thu, 13 Oct 2022 20:08:38 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id y10so2497699qvo.11 for ; Thu, 13 Oct 2022 20:08:38 -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=i1R7QPYLS3htwC9+m+eMmhkdxMHPXqw45xmXhqmncaA=; b=22pn9Os6EXT6UWfc9ZeKQ71GM5Bhmq9AlSEpgZrKl0IUo/yufgpYJMahaOmGApuHFQ 0HjgOrbOd3sJY2g4HJFuY1sgb4TaAlQP3aRsz10/ANjJZl4lMgHQsK7sWfd8Y0DMkh+C Dnl17PUMBTdKkOZPaPAnFJ/golfWNeftyDK3tNB7RN8JVIyFOYWbhGQkwRm4hg/oIKKh XWwkEhfZvnj2wPG3jNFSKte8oOALG7BsAxuzpit/Iy/IXoZtVY0BmdVKoGN2ayiG8T6J v607OE1Wb3Zg/vDA9PphT7Zvanzlont5JanwatBkMlDh5o+XUUb8SSx2FdIDrQQBfhxj TvmQ== 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=i1R7QPYLS3htwC9+m+eMmhkdxMHPXqw45xmXhqmncaA=; b=v8eFqwasSqR6d6qnnZUA3+fD9lePasmA8LOWHABddfNqiQ33yxVrt/JKLum33vYO96 fCSI/mmRBM5UIeMUALWMJ4YntWKqNFZ4K87ZUZcIYtSBI7l24dRw9o7+11FQGK78Jv/s bkvtV+ZSMcHNPQagG1Ro0TpWs49SrsjcH8gQCQh+ONXCh2Q69l3NOdiPBlyNn4ZUURFo j8iJazB6cM2Ib/qOiN8kFMIcmaZ2RhPYw+UzhHnhXcO68/ijta6ysS8AdiiChPtWEb1R PonYFGQ4yXSXoHCP8rc1Grv/8IQ7UGrVoatI44PKyShoNVUgl/3ClnmW4L1wiBGY8bKf dAOw== X-Gm-Message-State: ACrzQf1uvsFB4U4/B0aU3Q7Isya9b9OPAb97WawJgzDI5N7K8SS+8xhx T4TnmZk8zYdxCWFRih5CHaCVwZFbThkO5dOh X-Received: by 2002:a17:903:1003:b0:181:6c26:1114 with SMTP id a3-20020a170903100300b001816c261114mr2921922plb.75.1665716906763; Thu, 13 Oct 2022 20:08:26 -0700 (PDT) Received: from C02G705SMD6V.bytedance.net ([63.216.146.183]) by smtp.gmail.com with ESMTPSA id h4-20020a17090a710400b0020ae09e9724sm425524pjk.53.2022.10.13.20.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 20:08:26 -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 V2 4/5] cachefiles: narrow the scope of triggering EPOLLIN events in ondemand mode Date: Fri, 14 Oct 2022 11:07:44 +0800 Message-Id: <20221014030745.25748-5-zhujia.zj@bytedance.com> X-Mailer: git-send-email 2.37.0 (Apple Git-136) In-Reply-To: <20221014030745.25748-1-zhujia.zj@bytedance.com> References: <20221014030745.25748-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 --- 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 21ef5007f488..98d6cf58db11 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -327,6 +327,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) @@ -354,6 +361,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