Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1618081rdh; Fri, 27 Oct 2023 23:59:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEPcWbsHk6Beeauy20DseWcWhqOVMd72mOoMNM9MvAayDNCd87rciKx3qK+OKBWbO/EWN57 X-Received: by 2002:a05:6870:214b:b0:1e9:b9e6:98db with SMTP id g11-20020a056870214b00b001e9b9e698dbmr6264446oae.26.1698476391906; Fri, 27 Oct 2023 23:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698476391; cv=none; d=google.com; s=arc-20160816; b=mmDaJsLsLFEsxeKKyVHjffgaTxs+w6D/YEh+urofDntwyNKGcxK1Vr7ufzvnUNvtfU XWtjEBCYxA2pQZf0fBBL/2TVF1RQ87KCbiOGbqgTwbFAu3HVooJdZ5BLYHc5v06AgSKC F1aRCSTW0cjLgfIbrNF9h8H7dLLD3ZKW/o05r6x11fJ6L2XZWnH2Nh7SAv0QqSA27Eyp kPIpNARBtVYgFtDJvY+s06hZc38M+/2ZCYtjSPNKtY67MIM52LwquonUXl2zprXk/TtV 3jX7fBQP2HnkquGYRfwjSmUODiErYLORqv+8kk/qts76FWR5lyxNM3NDgUtjOyXwK8f4 ri6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=+MQVo6S+M+UV7mjaTlbWGgnfy0UPs/8DSL7sd/eFS3Q=; fh=7H3rEh7h4we4IbTADzgpgLC38j1zdyecebZiMRz1YzE=; b=LIDoFeKZ5aBZqipgWxrn2treXiDF6LyZU/fLzeLrwthWmvFnrrlgPWzfvl2zy/eJML fzGqQe5n/kKHefxZ25pVCliAQOBYRH8Dduv9QAwxdpmpiY0PlnnyHpBYAy3WAY3NSu82 k3JWYk/eC24bSlx1q6e9gqkrr3Pu5X9TQF9PbyjZN5qaVrl2dyq4U+Y7DDg2bKeYHQ+2 eAIPFMgA/5g48Hhvn23oR9majGgIz02FTQSBvJNhBQlaHv2Hui2txE5Xlg4/MQX7vm7h gFqTK9K+9K2nQVRgt46x0jCmPgxxdYi7Ye6L8neAeEiuVojFk43aDK3kOkdch/sOe8Fv 9++w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id c6-20020a633506000000b005b95eaa5841si708239pga.731.2023.10.27.23.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 23:59:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 405A382E15A8; Fri, 27 Oct 2023 23:59:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229484AbjJ1G7b (ORCPT + 99 others); Sat, 28 Oct 2023 02:59:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjJ1G7a (ORCPT ); Sat, 28 Oct 2023 02:59:30 -0400 Received: from smtpbg151.qq.com (smtpbg151.qq.com [18.169.211.239]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F9B7E3; Fri, 27 Oct 2023 23:59:24 -0700 (PDT) X-QQ-mid: bizesmtp63t1698476359tcw69q76 Received: from localhost.localdomain ( [175.10.24.131]) by bizesmtp.qq.com (ESMTP) with id ; Sat, 28 Oct 2023 14:59:13 +0800 (CST) X-QQ-SSF: 00400000000000O0T000000A0000000 X-QQ-FEAT: S0uf0xb+BQn1Qs6ENthHsLfFauTVfiNdT4Kdi4ekkZOrMzbIs+8ImU0wAvR5U GehrhuypVGXjps3h1ip/EFdWFlYbfZ1PiHxGEXt+RRO1215o398S9M2A2RnHRfKM2QmCQNH QwOROKIvO596jthBOGmMCjaOgU7a3SoRA9TMiVi8v40cAhCMbiL5a9x7UHSCNoFbaUSZdiy 5/MJm4a3qVk/SBv5pUqPwlz3Pvn5PEKiqiPv2nNVQQQApH83PT7eF8ysr5rdoyPsopUfSeO pTKMXOPVjUvns7108Y++J1ntULyLTBUfkv/ZUGyCu85wywdbZmmTaTD2LiWAMafFHiZY5OQ RP345d+IHz/XC+5tDAHQW8ZVhvcJwN3ToSL3HQNl9nuLu+9khE3t5psQv1iew== X-QQ-GoodBg: 2 X-BIZMAIL-ID: 11460424809230058568 From: Zhou Jifeng To: miklos@szeredi.hu Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Zhou Jifeng Subject: [PATCH] fuse: Track process write operations in both direct and writethrough modes Date: Sat, 28 Oct 2023 14:59:12 +0800 Message-Id: <20231028065912.6084-1-zhoujifeng@kylinos.com.cn> X-Mailer: git-send-email 2.18.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:kylinos.com.cn:qybglogicsvrgz:qybglogicsvrgz6a-1 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 27 Oct 2023 23:59:49 -0700 (PDT) Due to the fact that fuse does not count the write IO of processes in the direct and writethrough write modes, user processes cannot track write_bytes through the “/proc/[pid]/io” path. For example, the system tool iotop cannot count the write operations of the corresponding process. Signed-off-by: Zhou Jifeng --- fs/fuse/file.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 1cdb6327511e..6051d2e2a021 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -19,6 +19,7 @@ #include #include #include +#include static int fuse_send_open(struct fuse_mount *fm, u64 nodeid, unsigned int open_flags, int opcode, @@ -1305,6 +1306,7 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) ssize_t written = 0; struct inode *inode = mapping->host; ssize_t err; + ssize_t count; struct fuse_conn *fc = get_fuse_conn(inode); if (fc->writeback_cache) { @@ -1326,10 +1328,12 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) writethrough: inode_lock(inode); - err = generic_write_checks(iocb, from); - if (err <= 0) + count = generic_write_checks(iocb, from); + if (count <= 0) goto out; + task_io_account_write(count); + err = file_remove_privs(file); if (err) goto out; @@ -1600,6 +1604,7 @@ static ssize_t fuse_direct_write_iter(struct kiocb *iocb, struct iov_iter *from) res = generic_write_checks(iocb, from); if (res > 0) { + task_io_account_write(res); if (!is_sync_kiocb(iocb) && iocb->ki_flags & IOCB_DIRECT) { res = fuse_direct_IO(iocb, from); } else { -- 2.18.1