From patchwork Mon Jul 3 14:42:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ahelenia_Ziemia=C5=84ska?= X-Patchwork-Id: 11558 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp605423vqx; Mon, 3 Jul 2023 08:30:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlHPvSvD5IUOSUFdLEVG5cyRxIuzJg8VWk8URRCje8vdP3G2QpgaCBoym06nptCzM4m1QJWq X-Received: by 2002:a17:902:c246:b0:1b8:5827:8763 with SMTP id 6-20020a170902c24600b001b858278763mr10946719plg.4.1688398254443; Mon, 03 Jul 2023 08:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688398254; cv=none; d=google.com; s=arc-20160816; b=v3RmpaOHCv5sPbNCvw0z868tfIKhJtsDkj8hWCuYo8Z9a4gmnW00LbQuzcfsyX+SfP hcio1MkKSRwtctw/hokK/4/3rDq/2Gi0kzft/maxbaXRbgPPx8Q7hFqmW0T0vUbCzFSa eZhiYLnpLa8DmJom0WZBvwk/zt976+3VolWt1KlCZNl+wlX0LK1wXul30KYtRNj4TsDG UFvOraEdI99hyq+EgSKBJ70McT6ibtzBaU2/FY6dX7ARrQajGQjvVhOI+5dcAwVHWQ83 BR6VIoJFe8UZLyz40RGC3ZEJIpa1kXvNwkXn2IcGDAIlIfCCxFR4bxVsuhMMo1DwH+qT yFqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=706/sF4nxxjlUtmMNFdic0TFCqE3UNrp0TzHHV53oCI=; fh=AfCaarrJloRV9X8pgVoQkWOYp+JFhFv1/c5FQOfH+1Q=; b=KGDsS9J8uTPxLJvrP05oy7eqOEgjtBzEdkvc2z50zYfnz5QzX8URDHydWKyCdvhvds SDdyVpWgO8Len7PN+tmeiqiULGirblDVAXUwroH8rFSpNyJiIfEeLdGSiLaClkP1vBtw kPZVu27EvCRVoD487MDo1pKj90SbfuorFsKacdbbY+bh6NhE+E3Ve6wHHS4WhiBhNZZu xIeLupzKY+U9jBeYegKQ02ESfpzq6nEHiu2shoQk1dyG5P4Ml0ErUgQNs5exWqppezxs /Atxppm5XC6koGnwjBvHAei8bFoMwkX6Y4KmwuM3IsJPuLI7N9aOJ4WRF5WSKTcQg1oX GgUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=Dr9I8ddw; 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 w24-20020a1709027b9800b001b81a9aa3d1si12277073pll.223.2023.07.03.08.30.41; Mon, 03 Jul 2023 08:30: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=@nabijaczleweli.xyz header.s=202305 header.b=Dr9I8ddw; 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 S231215AbjGCOmP (ORCPT + 99 others); Mon, 3 Jul 2023 10:42:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229585AbjGCOmN (ORCPT ); Mon, 3 Jul 2023 10:42:13 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F34F7B2; Mon, 3 Jul 2023 07:42:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1688395327; bh=cre8VZmV6gYgTF6bv9oEQ8gWcE0Cd+BqTyhkY8/8Gww=; h=Date:From:To:Cc:Subject:From; b=Dr9I8ddw6AGZrBWNXdhCwPsLl7OBiyps+er9THFZTMJfnH8N7VAlV3RTkS+pq1JNj RVbiC1xrGkH/NFNXZNcH6htc23Mgdynw9goSOMtioI2dtq40ocBcTTSDID4MPm1mt4 WBD6COK4jCA5WYIJi3HnPLu5xiEaS2fQcnqjalF/+tRo+k52fHlDFy7p0M2nM900RA wKm1gjh2G88hdPq44Gp1fcsfWvDpTVFCOK18ms7+DR4k/CaWuVr6pqTsA+gwL5jRQv tF3sgn1V1kOVyg56IMY4cZGSHmzOAEOwQ0+QTqp1rrZHSP/IAdEQ99RESkG4Ti/1HO 3ryDp42PYV7zQ== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id 04C8A1B6A; Mon, 3 Jul 2023 16:42:07 +0200 (CEST) Date: Mon, 3 Jul 2023 16:42:05 +0200 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= To: Christian Brauner Cc: Alexander Viro , Jan Kara , Amir Goldstein , Chung-Chiang Cheng , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 0/3] fanotify accounting for fs/splice.c Message-ID: MIME-Version: 1.0 Content-Disposition: inline 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770413888059949217?= X-GMAIL-MSGID: =?utf-8?q?1770413888059949217?= Previously: https://lore.kernel.org/linux-fsdevel/jbyihkyk5dtaohdwjyivambb2gffyjs3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u In short: * most read/write APIs generate ACCESS/MODIFY for the read/written file(s) * except the [vm]splice/tee family (actually, since 6.4, splice itself /does/ generate events but only for the non-pipes being spliced from/to; this commit is Fixes:ed) * userspace that registers (i|fa)notify on pipes usually relies on it actually working (coreutils tail -f is the primo example) * it's sub-optimal when someone with a magic syscall can fill up a pipe simultaneously ensuring it will never get serviced Thus: actually generate ACCESS/MODIFY for all the [vm]spliced/teed-from/to files. LTP tests are staged in https://git.sr.ht/~nabijaczleweli/ltp/commit/v4 ("inotify13: new test for fs/splice.c functions vs pipes vs inotify"), validating that one A and/or one M event per [vm]splice(), tee(), and sendfile() is generated ‒ without this patchset, this only holds for sendfile(). Amir has identified a potential performance impact caused by correctly generating events, and has prepared patches at https://github.com/amir73il/linux/commits/fsnotify_pipe that optimise the most common cases more aggressively. Please review, and please consider taking these through the vfs tree for 6.6. Thanks, Ahelenia Ziemiańska (3): splice: always fsnotify_access(in), fsnotify_modify(out) on success splice: fsnotify_access(fd)/fsnotify_modify(fd) in vmsplice splice: fsnotify_access(in), fsnotify_modify(out) on success in tee fs/splice.c | 43 +++++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 18 deletions(-)