Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CBE45C636D4 for ; Mon, 13 Feb 2023 15:34:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231278AbjBMPe1 (ORCPT ); Mon, 13 Feb 2023 10:34:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231187AbjBMPeN (ORCPT ); Mon, 13 Feb 2023 10:34:13 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CD0216339 for ; Mon, 13 Feb 2023 07:33:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676302403; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xJXt4KNNFIdMvSSPmBpCRCAi8g0JFMLHorMyvAgfics=; b=EoZ4+zo9eJbbHbmh7cOYqBY15uCH//mg80tA1UsDa2VJo76jZvkIjSW/BwT+ZRDgFGK9J+ I3XQoSf0k/NdNaWDKdEMeVz0UEj0sRhji2G+ePR2ksVD5mvntEY8WeLURGMhomuSTtSLpn WUNLalUoiMgJJLreQnvcBZbDJit/yKg= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-325-ffjTGi4LPyGsidvz5tnMXw-1; Mon, 13 Feb 2023 10:33:15 -0500 X-MC-Unique: ffjTGi4LPyGsidvz5tnMXw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 590D43C14851; Mon, 13 Feb 2023 15:33:14 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53FA22026D4B; Mon, 13 Feb 2023 15:33:12 +0000 (UTC) From: David Howells To: Jens Axboe , Al Viro , Christoph Hellwig Cc: David Howells , Matthew Wilcox , Jan Kara , Jeff Layton , David Hildenbrand , Jason Gunthorpe , Logan Gunthorpe , Hillf Danton , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , John Hubbard Subject: [PATCH v2 3/4] splice: Use init_sync_kiocb() in filemap_splice_read() Date: Mon, 13 Feb 2023 15:33:00 +0000 Message-Id: <20230213153301.2338806-4-dhowells@redhat.com> In-Reply-To: <20230213153301.2338806-1-dhowells@redhat.com> References: <20230213153301.2338806-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use init_sync_kiocb() in filemap_splice_read() rather than open coding it. Requested-by: Christoph Hellwig Signed-off-by: David Howells cc: Christoph Hellwig cc: Jens Axboe cc: Al Viro cc: John Hubbard cc: David Hildenbrand cc: Matthew Wilcox cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- Notes: ver #2) - Don't attempt to filter IOCB_* flags. fs/splice.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/splice.c b/fs/splice.c index 7c0ff187f87a..4ea63d6a9040 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -419,15 +419,14 @@ static ssize_t filemap_splice_read(struct file *in, loff_t *ppos, size_t len, unsigned int flags) { struct folio_batch fbatch; + struct kiocb iocb; size_t total_spliced = 0, used, npages; loff_t isize, end_offset; bool writably_mapped; int i, error = 0; - struct kiocb iocb = { - .ki_filp = in, - .ki_pos = *ppos, - }; + init_sync_kiocb(&iocb, in); + iocb.ki_pos = *ppos; /* Work out how much data we can actually add into the pipe */ used = pipe_occupancy(pipe->head, pipe->tail);