From patchwork Fri Oct 14 03:07:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jia Zhu X-Patchwork-Id: 2473 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp590311wrs; Thu, 13 Oct 2022 20:10:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM63Dbf/UmLc5MGDkwNBYQuzsVnf+ep09jUe/At/Rgfv247/6FwmdrIxfxotD/KUpv4mWO8Y X-Received: by 2002:a17:902:d4ce:b0:177:fe49:19eb with SMTP id o14-20020a170902d4ce00b00177fe4919ebmr2912094plg.170.1665717054129; Thu, 13 Oct 2022 20:10:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665717054; cv=none; d=google.com; s=arc-20160816; b=0mm8oOPCy5J3D3lEh6B1wH/Fspu8NlPttA45I7zLW1vYLRWhK9z3yS0F2t+pMWzwjr 0pwhcxM0+PLU9NopuqoajK2sPI3zhniCHRkZJQg1GEYPgpMOKrZTrKJtDVodcFow+isO VLt21hpMi/NGR3rO4y6dmR7hz2uIXYM+/OKpEGMENmQvVM2jPkmu56x6mck12YDtm0ZQ hgBDahoNY+Ym9HSC5OveMqk24VQel+v1rhCTThJ26Jkpjx/vhrb+lYcPfaHxL2LjgmF2 CNSYxavMkO7cC8a+24WuvN06prdcrD76TBOnSpE3E6797Al0PQVfRf9Yn0rKQ9kQ4RL7 NACA== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l2-20020a170902f68200b001786d7bc2dfsi1938900plg.400.2022.10.13.20.10.40; Thu, 13 Oct 2022 20:10:54 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746630925621180419?= X-GMAIL-MSGID: =?utf-8?q?1746630925621180419?= 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 | 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 /*