From patchwork Mon Jun 26 23:09:00 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: 113154 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7822220vqr; Mon, 26 Jun 2023 16:31:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4/8hSIHThs9ea0xKAUzHJKFGB7l//JqM3LuvK2bUxAaasXkPubJbQyiNrxcXtN6YdjSmFo X-Received: by 2002:a17:907:3d92:b0:98e:1c4b:10e2 with SMTP id he18-20020a1709073d9200b0098e1c4b10e2mr6010799ejc.20.1687822282492; Mon, 26 Jun 2023 16:31:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687822282; cv=none; d=google.com; s=arc-20160816; b=KMZ1CcA61sYfqolwYap2k744MWHQQJeqVZ8geuZOgLyF6OtnN9lkbH8kf/XGM18wZ4 CpCAmVkWL3rhNRWcWV7BbOToj6EmcHy7fPkZz2FOaGbJy1s3d6QK33ABY4M7L+fQAkZ9 QQBTA3OYk/9JOy4dDUrAoMnesvV5VhCcjwCg5UUMCM3+AGSoktRNsREuG3RlVq4b5CzE 0hh54KAyitDNpQsUm5QUBQiGDI2N1RSbmWFr9xVBYk7pwgWM822gAbEJNyDopcAS3RoX GjypqMRyswN/2caNqE/jtZ+Bx+RaSVQE9pKgeWUy1iGrSrDJ59vrssE4C72n49IqtY8d 4IgQ== 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=9+UnP4YU/hmPsP6DwYLo5zHvmgpSFBYW3L690x3d9SI=; fh=IHFQlbVsC+DUr5Z3Sb1CE3j8cu6SvNBPXxR31tL4TGQ=; b=sv0HpE+M3qub9aJaexmbFfNjiNy0kZsq+Q9FvdSnBrxCUMe18/Nno9dJOfxIi2kueg P9gcjUfFb8IYVwUz/FLBzZ0wU0L3JdC3c/07yF2g7Nm4qtCiiN55ZYwkZUsyJU3RO7rJ Vuxed97sZfMiS/TCFmfz/8cRqoUDZsUgaBlWpuMhUzeRQllneyUO/L9/RDKTHFdFEtVH XhBhEa1a9ucvDeeUcQT4mhxhC6lc1LyDPUxFKwKCE7r3eOY3TfwGZdxtxdsfeTVGVU4P SCJkMFi2cWAopwCL/ArD3nt42TRsRtZugAcAGSopOiGLOltswCBDvIJT8An67v2iuR8V cbBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nabijaczleweli.xyz header.s=202305 header.b=HxqwL28g; 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 f14-20020a170906390e00b0098882d02831si3232429eje.710.2023.06.26.16.30.58; Mon, 26 Jun 2023 16:31:22 -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=HxqwL28g; 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 S230016AbjFZXJH (ORCPT + 99 others); Mon, 26 Jun 2023 19:09:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229571AbjFZXJG (ORCPT ); Mon, 26 Jun 2023 19:09:06 -0400 Received: from tarta.nabijaczleweli.xyz (unknown [139.28.40.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A77FD1701; Mon, 26 Jun 2023 16:09:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nabijaczleweli.xyz; s=202305; t=1687820942; bh=sub/f/fHhbhbOWVCyd50R46uZcOKsIBrfjQMG/W+FCw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HxqwL28g71pwu+IzMPEwCvy41NJdhiKG+zYcdx2zjgKQ91pOvlul3YCIP+DzvVLKG f6IEv3xbPmNa28JVA/k1ED8XGqkXTn0qniqHcv3n68NlNyYcV4BwDq1lBVdOEh/FIf 3bK5xwypKzuEqZ2REhkXsk1H3B0PYfqdQXB/M+4chFeS+ETdxatb1RXAnpN85AYBJi SEU0yauqTvLue95Rq252Ihl1kM7pT7uR3Q7zOFH/n0slXtIvHuXq3c1CPkyzYszmXM n0Efd7R1qXXshbGFMj1l4aJDkJW/joG6HztqM6DRXyTk4iPo2Ir12J/IQVsP1OCNKp Lh+dcGejjbOSw== Received: from tarta.nabijaczleweli.xyz (unknown [192.168.1.250]) by tarta.nabijaczleweli.xyz (Postfix) with ESMTPSA id EA355CFE; Tue, 27 Jun 2023 01:09:01 +0200 (CEST) Date: Tue, 27 Jun 2023 01:09:00 +0200 From: Ahelenia =?utf-8?q?Ziemia=C5=84ska?= To: Amir Goldstein Cc: Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jan Kara , Chung-Chiang Cheng Subject: [PATCH v2 1/3] splice: always fsnotify_access(in), fsnotify_modify(out) on success Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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?1769809937953593859?= X-GMAIL-MSGID: =?utf-8?q?1769809937953593859?= The current behaviour caused an asymmetry where some write APIs (write, sendfile) would notify the written-to/read-from objects, but splice wouldn't. This affected userspace which used inotify, like coreutils tail -f. Fixes: 983652c69199 ("splice: report related fsnotify events") Link: https://lore.kernel.org/linux-fsdevel/jbyihkyk5dtaohdwjyivambb2gffyjs3dodpofafnkkunxq7bu@jngkdxx65pux/t/#u Signed-off-by: Ahelenia ZiemiaƄska Reviewed-by: Amir Goldstein --- No changes since v1 (except in the message). fs/splice.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 3e06611d19ae..94fae24f9d54 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -1154,7 +1154,8 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, if ((in->f_flags | out->f_flags) & O_NONBLOCK) flags |= SPLICE_F_NONBLOCK; - return splice_pipe_to_pipe(ipipe, opipe, len, flags); + ret = splice_pipe_to_pipe(ipipe, opipe, len, flags); + goto notify; } if (ipipe) { @@ -1182,15 +1183,12 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret = do_splice_from(ipipe, out, &offset, len, flags); file_end_write(out); - if (ret > 0) - fsnotify_modify(out); - if (!off_out) out->f_pos = offset; else *off_out = offset; - return ret; + goto notify; } if (opipe) { @@ -1209,18 +1207,23 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out, ret = splice_file_to_pipe(in, opipe, &offset, len, flags); - if (ret > 0) - fsnotify_access(in); - if (!off_in) in->f_pos = offset; else *off_in = offset; - return ret; + goto notify; } return -EINVAL; + +notify: + if (ret > 0) { + fsnotify_access(in); + fsnotify_modify(out); + } + + return ret; } static long __do_splice(struct file *in, loff_t __user *off_in,