Message ID | pw3ljisf6ctpku2o44bdy3aaqdt4ofnedrdt4a4qylhasxsli6@wxhy3nsjcwn4 |
---|---|
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7818133vqr; Mon, 26 Jun 2023 16:21:31 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5rTzhllFj7xp9h29Si7gcoXOVofmoaIn8ca6nAr7+pCEQQw8pkZ6xVmWXEewFZMGbiTB+Z X-Received: by 2002:a05:6830:14ce:b0:6b5:f4af:f21e with SMTP id t14-20020a05683014ce00b006b5f4aff21emr16112576otq.7.1687821691064; Mon, 26 Jun 2023 16:21:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687821691; cv=none; d=google.com; s=arc-20160816; b=VjFoXSvCwqImQ/xW6z2/Genf8VCWheHhdACohh84Tjtn6rLaB46lX7r5GhMAJm+soh /eoyIlSVmXvUDFT4MONcWGWQARqRygYYHIYr9yjSZBlxNacV/WzNSgkGw8+VoV1GkLMa TC0yhpFCFurRMXuAqdLjz7u7HYr76EUKm5U4hoX89THq2P5QNliT6EiFHjDlZsP9vG4R 4jkjUe870Qwu0LUZ7FWrsi2+g/Ny56pgOF9Nptqhy8dLpZ/ORro8SU3wX5pslELz8fWR 25PR+xn+8Lc9nsuVu2itJmzTzb/URFwmumwfXQxultgcqqYjEBTjWDXR9yL8CVyAtuEi 2YyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=dVmGHp5YLhfRZplhoZ1BMOCeE/kkSWqsgvaoxUBUoaA=; fh=IHFQlbVsC+DUr5Z3Sb1CE3j8cu6SvNBPXxR31tL4TGQ=; b=yHaAupFjY8iiiwRqbFr3/MvICen1BTass8ukzcpk4GPp/hTfzTiWawv7zcE5rv1wMB Uz1x6bTD/BCqnlsQ3BEzXTuc7E7RI3a2N22RbaDKA5Qs+S3DTgpUQfcndsK9T6iWoXlE 9GIt88c04qshnZ74yOLPiphnhyy39fXOYPa2vaK5jdWa14u7LiDnfyVxr8VNtfyinHnB 7pOzKZ4L0s8v68MPFNB+gTVPIclojE//sddSLZYvfaDx9AXowFgPvZrsX0qMOFDO9tW8 69kMzDehfagT/sDmivI6xkJnBnwdCnMKqLwol1eUzbkz3/ArktIY36KkdLdJ/5Mr7RGe VIGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=bk6TKlHs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t32-20020a635360000000b0054fd7759423si6360721pgl.485.2023.06.26.16.21.16; Mon, 26 Jun 2023 16:21:31 -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=@nabijaczleweli.xyz header.s=202305 header.b=bk6TKlHs; 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=pass (p=NONE sp=NONE dis=NONE) header.from=nabijaczleweli.xyz Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229898AbjFZXIq (ORCPT <rfc822;filip.gregor98@gmail.com> + 99 others); Mon, 26 Jun 2023 19:08:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229750AbjFZXIo (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 26 Jun 2023 19:08:44 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EF82610FB; Mon, 26 Jun 2023 16:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1687820919; bh=iASaIQSREKLq2OFVu4k4J+TAbxohSrL+yjCExkMJmeY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bk6TKlHsfUUcFxuVbDcSAjmmsUMXwKgcojyjXMlinXZS4Q45RXGFagnjSa2Y5MRXb U/chkw+pv6FTegKkZVDpN389XaGF6+VudrsW6Z3tsbr/BQD9LRGdkxdMrrS7Em+TbS HmZ1L2pYudBMIKl6lpDQxDgG/Em/HbwUh8HneMsja0jzSo6I5ov+E5ZTM9PEmjKIAo 8TrD4E/bYehXw0LS3wzH5y82JDbZHkI2BlqWwZ+YZYBW4wOjzwDfaL4MhaozxyW/p/ n+xywt0inXLQb3nA9S+/2d5xtHxK8fiVuwOAcaq8DjPL9XnBR14SB+aCi11VSni8Bp Uu6ogLMbwAweA== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id A6EC9CFC; Tue, 27 Jun 2023 01:08:39 +0200 (CEST) Date: Tue, 27 Jun 2023 01:08:38 +0200 From: =?utf-8?b?0L3QsNCx?= <nabijaczleweli@nabijaczleweli.xyz> To: Amir Goldstein <amir73il@gmail.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org>, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara <jack@suse.cz>, Chung-Chiang Cheng <cccheng@synology.com> Subject: [PATCH v2 0/3] fanotify accounting for fs/splice.c Message-ID: <pw3ljisf6ctpku2o44bdy3aaqdt4ofnedrdt4a4qylhasxsli6@wxhy3nsjcwn4> References: <CAOQ4uxj_DLm8_stRJPR7i8bp9aJ5VtjzWqHL2egCTKe3M-6KSw@mail.gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="u5ahfxgiox6lrsd2" Content-Disposition: inline In-Reply-To: <CAOQ4uxj_DLm8_stRJPR7i8bp9aJ5VtjzWqHL2egCTKe3M-6KSw@mail.gmail.com> User-Agent: NeoMutt/20230517 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,PDS_RDNS_DYNAMIC_FP, RDNS_DYNAMIC,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769809317722550559?= X-GMAIL-MSGID: =?utf-8?q?1769809317722550559?= |
Series | fanotify accounting for fs/splice.c | |
Message
Ahelenia Ziemiańska
June 26, 2023, 11:08 p.m. UTC
"people just forget to add inotify hooks to their I/O routines as a rule"? Guess what I did, fully knowing that some are missing in this file :) ==> te.c <== #define _GNU_SOURCE #include <fcntl.h> #include <stdio.h> int main() { ssize_t rd, acc = 0; while ((rd = tee(0, 1, 128 * 1024 * 1024, 0)) > 0) acc += rd; fprintf(stderr, "te=%zd: %m\n", acc); } ==> vm.c <== #define _GNU_SOURCE #include <fcntl.h> #include <stdio.h> #include <string.h> static char sb[1024 * 1024]; int main() { memcpy(sb, "żupan", sizeof("żupan")); ssize_t rd = vmsplice(1, &(struct iovec){.iov_base = sb, .iov_len = sizeof(sb)}, 1, SPLICE_F_GIFT); fprintf(stderr, "vm=%zd: %m\n", rd); } echo zupa | ./te > fifo tees a few times and then blocks when the pipe fills, at which point we get into the broken state. Similarly, ./vm > fifo (with the default 64k F_GETPIPE_SZ) enters that same state instantly. With 2/3 and 3/3, they instead do 1: mask=2, cook=0, len=0, name= rd=80 1: mask=2, cook=0, len=0, name= rd=80 ... in a loop, as-expected, and # ./vm > fifo vm=65200: Success 1: mask=2, cook=0, len=0, name= rd=65200 I took the liberty of marking 2/3 and 3/3 as Fixes: of the original fanotify-in-splice commit as well, I think they fit the bill. Ahelenia Ziemiańska (3): splice: always fsnotify_access(in), fsnotify_modify(out) on success splice: fsnotify_modify(fd) in vmsplice splice: fsnotify_access(in), fsnotify_modify(out) on success in tee fs/splice.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
Comments
On Tue, Jun 27, 2023 at 2:08 AM наб <nabijaczleweli@nabijaczleweli.xyz> wrote: > > "people just forget to add inotify hooks to their I/O routines as a rule"? > Guess what I did, fully knowing that some are missing in this file :) > > ==> te.c <== > #define _GNU_SOURCE > #include <fcntl.h> > #include <stdio.h> > int main() { > ssize_t rd, acc = 0; > while ((rd = tee(0, 1, 128 * 1024 * 1024, 0)) > 0) > acc += rd; > fprintf(stderr, "te=%zd: %m\n", acc); > } > > ==> vm.c <== > #define _GNU_SOURCE > #include <fcntl.h> > #include <stdio.h> > #include <string.h> > static char sb[1024 * 1024]; > int main() { > memcpy(sb, "żupan", sizeof("żupan")); > ssize_t rd = > vmsplice(1, &(struct iovec){.iov_base = sb, .iov_len = sizeof(sb)}, 1, > SPLICE_F_GIFT); > fprintf(stderr, "vm=%zd: %m\n", rd); > } > > > echo zupa | ./te > fifo tees a few times and then blocks when the pipe > fills, at which point we get into the broken state. > > Similarly, ./vm > fifo (with the default 64k F_GETPIPE_SZ) enters that > same state instantly. > > With 2/3 and 3/3, they instead do > 1: mask=2, cook=0, len=0, name= > rd=80 > 1: mask=2, cook=0, len=0, name= > rd=80 > ... > in a loop, as-expected, and > # ./vm > fifo > vm=65200: Success > 1: mask=2, cook=0, len=0, name= > rd=65200 > > I took the liberty of marking 2/3 and 3/3 as Fixes: of the original > fanotify-in-splice commit as well, I think they fit the bill. > Thank you for doing this thorough research on all the variants! It would be great if you could add test coverage for these syscalls. Simplest would be to clone an LTP inotify test, e.g. ltp/testcases/kernel/syscalls/inotify/inotify01 for the different splice syscall variants (sendfile as well). LTP already has other tests for all those syscalls, so there are plenty of examples of how to use the LTP helpers to test those syscalls. You can either clone one inotify test per syscall, or clone one inotify test that creates a fifo instead of a file that inotify watches and use a test cases array for the different syscalls to test (see example of test cases array in inotify10 test). Thanks, Amir.