Received: by 2002:a05:7412:4e10:b0:e2:908c:2ebd with SMTP id gb16csp63180rdb; Tue, 7 Nov 2023 00:14:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFl53OI9zCAU0DXAkJ+K0OUY6m+fO5WWbkA/kPl8qzkd5O1/55ykD+s8CeFSu9Lf1beH3vR X-Received: by 2002:a05:6358:2908:b0:168:eeab:390d with SMTP id y8-20020a056358290800b00168eeab390dmr42204953rwb.22.1699344851962; Tue, 07 Nov 2023 00:14:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699344851; cv=none; d=google.com; s=arc-20160816; b=RG4Zlis9YVwTVYUKC7QMgFaB7OInKr0l/v04fyxxIkh65KX25rTujA6XbOZFmUVxcf dGdeIitrU5iCNPDDSLgMct1I/hT7F+HVpcCkNnngKaaQk50UVEtMd/nIDhz0Fyl+9PMX G+/LCamjpfKF3JuzAanzwK/+9dnBu4Lg2cD4SiiH14OAx69fiLCNaTA7DWVWfgymRmU0 0Hgr2TqrRgEmUjYj5sX0iIln2PMYTKhH9KeiTFI252KYnn+yyV1SacyDTGj0JYuRiMuf vQYe0GDdu4m3oQACEWUWv2TszFXFMTWDWjFagugqx11igmVBaWzybJNcQ8xqZm3Kt406 lhXQ== 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:references:in-reply-to:message-id:date:subject:cc:to :from; bh=bm9Zpx/1G3DAy+c9fxfNjN6xZylYBQt9SHas+jvOCQ0=; fh=EqIrd9hLjzVIR1t1jg++wy+HRcyLTFvswRAqQijWagc=; b=xU1zLggpf5acRjqhDvzVzhg703VlmCjyMBXu02HkPs9SkcM2Wao7ekXY+i2gf9Ne+v YX3f6SGNGq2O2NM5xzJPBVdoFk2lCc0ZzlnmPVTBfV7n5qG3SMlXCjA9RefEID6X/ciq efIJiilSUepqqDenByejxuj/Bf3QZ/gNGmeTcxblogGkoSFDQw9Mc0xGLAVOCVs+wFaF HZd9bjRYK3ZJNFyOEhr2Dlq2fXBtri21vkaIcGlZ+891TwbXFJVqu7yZX12Il2bTCNsN LCdAPvmWhw0EG/KH3zxLtXM0PxF41Ct/evfPrHC7XyRQS/D4Qe7kps1rknAVrVyrx6MF chaQ== 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:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id 184-20020a6308c1000000b005b918d9a3c2si1661438pgi.868.2023.11.07.00.14.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 00:14:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id 18117811F12B; Tue, 7 Nov 2023 00:14:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233658AbjKGIOJ (ORCPT + 99 others); Tue, 7 Nov 2023 03:14:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37232 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233590AbjKGIOI (ORCPT ); Tue, 7 Nov 2023 03:14:08 -0500 Received: from smtpbguseast1.qq.com (smtpbguseast1.qq.com [54.204.34.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8771FE8; Tue, 7 Nov 2023 00:14:03 -0800 (PST) X-QQ-mid: bizesmtp91t1699344838tve14rzx Received: from localhost.localdomain ( [175.11.90.246]) by bizesmtp.qq.com (ESMTP) with id ; Tue, 07 Nov 2023 16:13:52 +0800 (CST) X-QQ-SSF: 00400000000000O0T000000A0000000 X-QQ-FEAT: 3M0okmaRx3gmxPjUV56yDKvB3Uhj8OcIpw7vWvpFGbsFfrB+bfwV7TozelY5e DMI/DxjOU8Tal584vSNyxOx5pZja88QCqwwjIl0o4CnUzPFLiXAU5V+M/gM+ILYnZlGx2fL Jtl2leZXWwQhqffFZSUUQEocdjWH3F4eOS62spWgc7UHKQqsP8msvrB1ZrTyn/0osDH2IbE vLMPurMnhNfp3gYSRyxXgXcSFR8EijFT4Tc5E7FQEEtmDyQ5kGlsh+q0H5Fhu9zhx67geNf LIX4c7sTyfsZqkCglfVxYcWEEYPYE2251UY5+kro/DpLtPKHGkK0BdTXZKmtZBmMBpLtKWV B1POWAVC+ErxfxG5NqfZuSDd+jfAvfTIqZSM81S0nMdu5b7Xn/ktDwb+Q498ZuzIU6ci3Qs X-QQ-GoodBg: 2 X-BIZMAIL-ID: 11280650343400386784 From: Zhou Jifeng To: zhoujifeng@kylinos.com.cn Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, miklos@szeredi.hu Subject: [PATCH v2] fuse: Track process write operations in both direct and writethrough modes Date: Tue, 7 Nov 2023 16:13:50 +0800 Message-Id: <20231107081350.14472-1-zhoujifeng@kylinos.com.cn> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20231028065912.6084-1-zhoujifeng@kylinos.com.cn> References: <20231028065912.6084-1-zhoujifeng@kylinos.com.cn> 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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Tue, 07 Nov 2023 00:14:10 -0800 (PST) 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 --- v1 -> v2: Fix "Miss error code" issue fs/fuse/file.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 1cdb6327511e..4846ab8c01cf 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) { @@ -1330,6 +1332,9 @@ static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from) if (err <= 0) goto out; + count = err; + task_io_account_write(count); + err = file_remove_privs(file); if (err) goto out; @@ -1600,6 +1605,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