From patchwork Fri Jun 30 15:16:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13298346 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 95EF2EB64D7 for ; Fri, 30 Jun 2023 15:17:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3BBA08E001B; Fri, 30 Jun 2023 11:17:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 344858E000F; Fri, 30 Jun 2023 11:17:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 233878E001B; Fri, 30 Jun 2023 11:17:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 132AD8E000F for ; Fri, 30 Jun 2023 11:17:06 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 9D67980BC6 for ; Fri, 30 Jun 2023 15:17:05 +0000 (UTC) X-FDA: 80959767210.20.DBD2593 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id B842840011 for ; Fri, 30 Jun 2023 15:17:02 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WXYa9BIC; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688138222; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=sac/z7qt8qX/jw2GCw1Fghx39S+xMjFejmZ6Kx/zzF8=; b=iVH6qCshU5BdUD4fqgofjzse1iwr0Qqn53etnfg7C5efDL5auTtNMH+jFVHXsW1pQTLHQk CElnkciU1IKwEbv/EDvrcrr/JKdlYI+jAEUL4sjjrKzrXzgvVCOfHP67YNviF5ufoqx4+7 vqoXHFoOoOYxlNjJ/6Q7CIgtdaOGoXc= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WXYa9BIC; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688138222; a=rsa-sha256; cv=none; b=dD9yHwQlqYjxZc7hRPSG4dAnQUp66nqbEhdoUfRbR3IgOZTrAU9TTc3GrDru1hq3laVhPw sFLLXLovMJ+hibYM+5DZAbtGvKRvyB4hFjTM6WBK4ZU8njQYQMYXYZBfkQBrlQtuheDtll xHeHFX3nuELcWWCE7X1Wv3JnR/KFoXU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688138222; 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=sac/z7qt8qX/jw2GCw1Fghx39S+xMjFejmZ6Kx/zzF8=; b=WXYa9BICVC4VN1v7qn1YYtvj+0JB+5vojZ65vqCq4NoGZVZMm+RaClZRSv117VoFK3M0kj icjCZ12mItUJs8/MXHFW5vXsU8SyMnsMIET9C+QsC4xVUJN7uWYdL2mt2A5Cp9KbbXEeK8 gdanyf9DmS4DKfx7zbK1VHuppjFBzXE= 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-549-wd4BOK4CNAGGF3o5uSBHdw-1; Fri, 30 Jun 2023 11:16:57 -0400 X-MC-Unique: wd4BOK4CNAGGF3o5uSBHdw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D66FB2812949; Fri, 30 Jun 2023 15:16:56 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.39.192.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B1CB492B02; Fri, 30 Jun 2023 15:16:53 +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 , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , Christian Brauner Subject: [RFC PATCH 01/11] iov_iter: Fix comment refs to iov_iter_get_pages/pages_alloc() Date: Fri, 30 Jun 2023 16:16:18 +0100 Message-ID: <20230630151628.660343-2-dhowells@redhat.com> In-Reply-To: <20230630151628.660343-1-dhowells@redhat.com> References: <20230630151628.660343-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Queue-Id: B842840011 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: pb91q747xnimbnot9koidzjb1gmyga8c X-HE-Tag: 1688138222-246127 X-HE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Wc7A6QZ6LiS0+W3ABQlP6ZToFABW1YIIOw/xRDTv5pIy6rV9Bs0pRPitEkIa5U8XBujxY1cWGIOf65YndiTKbxghDWzSdFaF4qdeRlDkCb3JQLP9U7VBoUUctkC1Ic76gj/sfKmMGd0g+N28AO/ZKZU26wsX9NVV3+Z3XghclcMgH2mCNTMKl579SmHCXg6WTelj7kzGQ0krKHLh9aaQIDYyte2CrKeT30VS7AH1tGcHNT2+RND0YAXaihijEbDVn+xmwQNVdmCIlL+Z3w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Fix references to iov_iter_get_pages/pages_alloc() in comments to refer to the *2 interfaces instead. Signed-off-by: David Howells cc: Christoph Hellwig cc: Jens Axboe cc: Christian Brauner cc: Alexander Viro cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- fs/ceph/file.c | 4 ++-- include/linux/mm_types.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index b1925232dc08..3bb27b9ce751 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -75,7 +75,7 @@ static __le32 ceph_flags_sys2wire(u32 flags) */ /* - * How many pages to get in one call to iov_iter_get_pages(). This + * How many pages to get in one call to iov_iter_get_pages2(). This * determines the size of the on-stack array used as a buffer. */ #define ITER_GET_BVECS_PAGES 64 @@ -115,7 +115,7 @@ static ssize_t __iter_get_bvecs(struct iov_iter *iter, size_t maxsize, } /* - * iov_iter_get_pages() only considers one iov_iter segment, no matter + * iov_iter_get_pages2() only considers one iov_iter segment, no matter * what maxsize or maxpages are given. For ITER_BVEC that is a single * page. * diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index de10fc797c8e..f49029c943b0 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -1249,7 +1249,7 @@ enum { /* * FOLL_LONGTERM indicates that the page will be held for an indefinite * time period _often_ under userspace control. This is in contrast to - * iov_iter_get_pages(), whose usages are transient. + * iov_iter_get_pages2(), whose usages are transient. */ FOLL_LONGTERM = 1 << 8, /* split huge pmd before returning */ From patchwork Fri Jun 30 15:16:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13298347 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2450EB64D7 for ; Fri, 30 Jun 2023 15:17:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 84FD68E001C; Fri, 30 Jun 2023 11:17:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FF2A8E000F; Fri, 30 Jun 2023 11:17:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6C71D8E001C; Fri, 30 Jun 2023 11:17:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5D9EB8E000F for ; Fri, 30 Jun 2023 11:17:17 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 166BF80E28 for ; Fri, 30 Jun 2023 15:17:17 +0000 (UTC) X-FDA: 80959767714.21.BC6012C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf03.hostedemail.com (Postfix) with ESMTP id F271620027 for ; Fri, 30 Jun 2023 15:17:13 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Zwg0MAZR; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1688138234; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=HIKi0zHLnu1hjZ3YJMMoOoPZaQGGpdOq8FelXRkEWEM=; b=JgB3RaaaC96asy5K1xxbVwvfFS1IryRR5sWllU9DBMZaNPSQPCp13zA2SX4+ChauvHKZqK MNiqajq+kx6bgWy3qTTWz9Vz5/zGYMccJJTD6KUao5DgKXTWdlkTSbji0+duer6YVAKTu2 l/iOPtmgYdk1n00SLPzUuyLsk+cE/OU= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Zwg0MAZR; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1688138234; a=rsa-sha256; cv=none; b=aS0O35pbo56cC2DxKSLDtAlGc8DG5blnoXsJa0dzJGrRQ3zsm28UVYIgwqulC68sXpl6IJ Xo6mmhqhIc/m0p5cRwM24FolaWTYorOKcdXbuo5ipsL2/YE0EYejEhSfObVxiR+PkrYQsf IU1LOL+1Vcy1TKsYnJTT+C+u2vOkFgk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1688138233; 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=HIKi0zHLnu1hjZ3YJMMoOoPZaQGGpdOq8FelXRkEWEM=; b=Zwg0MAZRJ6m7poTmjNLIJjJ5HmB0zEIFaBHiSlKleYyU+WLMtGsa9Eyx7YJqoc3qFwtCWs CqieLpn1trG0OI5ApCOxSGg8XJo9/geITWf+4fcXtf1aAwLnQ/vUgK3sdRpOlGc8GmNNHs kYSL0RNHRCTgD50gKU0fruastvWButE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-593-_LC-zIbSMR-X7w2nKGx5pA-1; Fri, 30 Jun 2023 11:17:08 -0400 X-MC-Unique: _LC-zIbSMR-X7w2nKGx5pA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3C049800B35; Fri, 30 Jun 2023 15:17:07 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.39.192.26]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9A6E71121314; Fri, 30 Jun 2023 15:16:57 +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 , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Christoph Hellwig , Christian Brauner Subject: [RFC PATCH 02/11] vfs: Set IOCB_WRITE in iocbs that we're going to write from Date: Fri, 30 Jun 2023 16:16:19 +0100 Message-ID: <20230630151628.660343-3-dhowells@redhat.com> In-Reply-To: <20230630151628.660343-1-dhowells@redhat.com> References: <20230630151628.660343-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.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UGTwIPQ/prD6a1ZwkkB/FKbYn+ N/nM8+ix OAnvLn+KTAE/cZOgaye9VosyL9MlVZhamIK1CmpvEFhIslPbSoOOaNvm5bk6KRsv4dCAeItjd9ARg1ErSpkcmPM4mO+LrqLfjHUxaFGx3gCOUJjI0aBxYhcMLpK6McrYQf3DUN7yC30Shggm5BV45Bbs4fDqkH9a1joDXifiNQAZtvTB4QAxDAEH3K9Du/cJ6VSZrRJWDN1/wV6NWtBCYEwDm7mrvxZxqANwqgTiHQNVBvrC2cqGAIK20+UZwUhW0Aqq+kKuNm+DE1SYNvVVt3jHlmgEoNl8J/1v64LNGuTJT/UQhkAv7npE12t/MGkvkQA/KwrYgFJJaBNy4R0oyXrAmRg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: IOCB_WRITE is set by aio, io_uring and cachefiles before submitting a write operation to the VFS, but it isn't set by, say, the write() system call. Fix this by adding an extra argument to init_sync_kiocb() to indicate the direction and setting that to READ or WRITE, which will cause IOCB_WRITE to be set as appropriate. Whilst we're at it, rename init_sync_kiocb() to init_kiocb(). This will allow drivers to use IOCB_WRITE instead of the iterator data source to determine the I/O direction. Signed-off-by: David Howells cc: Christoph Hellwig cc: Jens Axboe cc: Christian Brauner cc: Alexander Viro cc: linux-block@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- fs/btrfs/ioctl.c | 4 ++-- fs/read_write.c | 10 +++++----- fs/seq_file.c | 2 +- fs/splice.c | 2 +- include/linux/fs.h | 6 +++++- mm/filemap.c | 2 +- mm/page_io.c | 4 ++-- 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index a895d105464b..15870337dd26 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -4422,7 +4422,7 @@ static int btrfs_ioctl_encoded_read(struct file *file, void __user *argp, if (ret < 0) goto out_iov; - init_sync_kiocb(&kiocb, file); + init_kiocb(&kiocb, file, READ); kiocb.ki_pos = pos; ret = btrfs_encoded_read(&kiocb, &iter, &args); @@ -4523,7 +4523,7 @@ static int btrfs_ioctl_encoded_write(struct file *file, void __user *argp, bool if (ret < 0) goto out_end_write; - init_sync_kiocb(&kiocb, file); + init_kiocb(&kiocb, file, WRITE); ret = kiocb_set_rw_flags(&kiocb, 0); if (ret) goto out_end_write; diff --git a/fs/read_write.c b/fs/read_write.c index b07de77ef126..6fe517047095 100644 --- a/fs/read_write.c +++ b/fs/read_write.c @@ -382,7 +382,7 @@ static ssize_t new_sync_read(struct file *filp, char __user *buf, size_t len, lo struct iov_iter iter; ssize_t ret; - init_sync_kiocb(&kiocb, filp); + init_kiocb(&kiocb, filp, READ); kiocb.ki_pos = (ppos ? *ppos : 0); iov_iter_ubuf(&iter, ITER_DEST, buf, len); @@ -422,7 +422,7 @@ ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t *pos) if (unlikely(!file->f_op->read_iter || file->f_op->read)) return warn_unsupported(file, "read"); - init_sync_kiocb(&kiocb, file); + init_kiocb(&kiocb, file, READ); kiocb.ki_pos = pos ? *pos : 0; iov_iter_kvec(&iter, ITER_DEST, &iov, 1, iov.iov_len); ret = file->f_op->read_iter(&kiocb, &iter); @@ -484,7 +484,7 @@ static ssize_t new_sync_write(struct file *filp, const char __user *buf, size_t struct iov_iter iter; ssize_t ret; - init_sync_kiocb(&kiocb, filp); + init_kiocb(&kiocb, filp, WRITE); kiocb.ki_pos = (ppos ? *ppos : 0); iov_iter_ubuf(&iter, ITER_SOURCE, (void __user *)buf, len); @@ -512,7 +512,7 @@ ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff_t *po if (unlikely(!file->f_op->write_iter || file->f_op->write)) return warn_unsupported(file, "write"); - init_sync_kiocb(&kiocb, file); + init_kiocb(&kiocb, file, WRITE); kiocb.ki_pos = pos ? *pos : 0; ret = file->f_op->write_iter(&kiocb, from); if (ret > 0) { @@ -723,7 +723,7 @@ static ssize_t do_iter_readv_writev(struct file *filp, struct iov_iter *iter, struct kiocb kiocb; ssize_t ret; - init_sync_kiocb(&kiocb, filp); + init_kiocb(&kiocb, filp, type); ret = kiocb_set_rw_flags(&kiocb, flags); if (ret) return ret; diff --git a/fs/seq_file.c b/fs/seq_file.c index f5fdaf3b1572..1ee6ffc630da 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -155,7 +155,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) struct iov_iter iter; ssize_t ret; - init_sync_kiocb(&kiocb, file); + init_kiocb(&kiocb, file, READ); iov_iter_init(&iter, ITER_DEST, &iov, 1, size); kiocb.ki_pos = *ppos; diff --git a/fs/splice.c b/fs/splice.c index 004eb1c4ce31..867357ebb2c3 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -362,7 +362,7 @@ ssize_t copy_splice_read(struct file *in, loff_t *ppos, /* Do the I/O */ iov_iter_bvec(&to, ITER_DEST, bv, npages, len); - init_sync_kiocb(&kiocb, in); + init_kiocb(&kiocb, in, READ); kiocb.ki_pos = *ppos; ret = call_read_iter(in, &kiocb, &to); diff --git a/include/linux/fs.h b/include/linux/fs.h index d4b67bdeb53e..466eba253502 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2017,13 +2017,17 @@ static inline bool HAS_UNMAPPED_ID(struct mnt_idmap *idmap, !vfsgid_valid(i_gid_into_vfsgid(idmap, inode)); } -static inline void init_sync_kiocb(struct kiocb *kiocb, struct file *filp) +static inline void init_kiocb(struct kiocb *kiocb, struct file *filp, + unsigned int rw) { *kiocb = (struct kiocb) { .ki_filp = filp, .ki_flags = filp->f_iocb_flags, .ki_ioprio = get_current_ioprio(), }; + + if (rw == WRITE) + kiocb->ki_flags |= IOCB_WRITE; } static inline void kiocb_clone(struct kiocb *kiocb, struct kiocb *kiocb_src, diff --git a/mm/filemap.c b/mm/filemap.c index 9e44a49bbd74..cd763122d2a2 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2905,7 +2905,7 @@ ssize_t filemap_splice_read(struct file *in, loff_t *ppos, if (unlikely(*ppos >= in->f_mapping->host->i_sb->s_maxbytes)) return 0; - init_sync_kiocb(&iocb, in); + init_kiocb(&iocb, in, READ); iocb.ki_pos = *ppos; /* Work out how much data we can actually add into the pipe */ diff --git a/mm/page_io.c b/mm/page_io.c index 684cd3c7b59b..85cbadaf7395 100644 --- a/mm/page_io.c +++ b/mm/page_io.c @@ -312,7 +312,7 @@ static void swap_writepage_fs(struct page *page, struct writeback_control *wbc) } if (!sio) { sio = mempool_alloc(sio_pool, GFP_NOIO); - init_sync_kiocb(&sio->iocb, swap_file); + init_kiocb(&sio->iocb, swap_file, WRITE); sio->iocb.ki_complete = sio_write_complete; sio->iocb.ki_pos = pos; sio->pages = 0; @@ -443,7 +443,7 @@ static void swap_readpage_fs(struct page *page, } if (!sio) { sio = mempool_alloc(sio_pool, GFP_KERNEL); - init_sync_kiocb(&sio->iocb, sis->swap_file); + init_kiocb(&sio->iocb, sis->swap_file, READ); sio->iocb.ki_pos = pos; sio->iocb.ki_complete = sio_read_complete; sio->pages = 0;