[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220225085025.3052894-4-jhubbard@nvidia.com>
Date: Fri, 25 Feb 2022 00:50:21 -0800
From: John Hubbard <jhubbard@...dia.com>
To: Jens Axboe <axboe@...nel.dk>, Jan Kara <jack@...e.cz>,
Christoph Hellwig <hch@...radead.org>,
Dave Chinner <dchinner@...hat.com>,
"Darrick J . Wong" <djwong@...nel.org>,
Theodore Ts'o <tytso@....edu>,
Alexander Viro <viro@...iv.linux.org.uk>,
Miklos Szeredi <miklos@...redi.hu>,
Andrew Morton <akpm@...ux-foundation.org>,
Chaitanya Kulkarni <kch@...dia.com>
CC: <linux-block@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>,
<linux-xfs@...r.kernel.org>, <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>,
John Hubbard <jhubbard@...dia.com>
Subject: [RFC PATCH 3/7] block, fs: assert that key paths use iovecs, and nothing else
Upcoming changes to Direct IO will change it from acquiring pages via
get_user_pages_fast(), to calling pin_user_pages_fast() instead.
Place a few assertions at key points, that the pages are IOVEC (user
pages), to enforce the assumptions that there are no kernel or pipe or
other odd variations being passed.
Signed-off-by: John Hubbard <jhubbard@...dia.com>
---
block/bio.c | 4 ++++
fs/direct-io.c | 2 ++
2 files changed, 6 insertions(+)
diff --git a/block/bio.c b/block/bio.c
index b15f5466ce08..4679d6539e2d 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1167,6 +1167,8 @@ static int __bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
BUILD_BUG_ON(PAGE_PTRS_PER_BVEC < 2);
pages += entries_left * (PAGE_PTRS_PER_BVEC - 1);
+ WARN_ON_ONCE(!iter_is_iovec(iter));
+
size = iov_iter_get_pages(iter, pages, LONG_MAX, nr_pages, &offset);
if (unlikely(size <= 0))
return size ? size : -EFAULT;
@@ -1217,6 +1219,8 @@ static int __bio_iov_append_get_pages(struct bio *bio, struct iov_iter *iter)
BUILD_BUG_ON(PAGE_PTRS_PER_BVEC < 2);
pages += entries_left * (PAGE_PTRS_PER_BVEC - 1);
+ WARN_ON_ONCE(!iter_is_iovec(iter));
+
size = iov_iter_get_pages(iter, pages, LONG_MAX, nr_pages, &offset);
if (unlikely(size <= 0))
return size ? size : -EFAULT;
diff --git a/fs/direct-io.c b/fs/direct-io.c
index 38bca4980a1c..7dbbbfef300d 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -169,6 +169,8 @@ static inline int dio_refill_pages(struct dio *dio, struct dio_submit *sdio)
{
ssize_t ret;
+ WARN_ON_ONCE(!iter_is_iovec(sdio->iter));
+
ret = iov_iter_get_pages(sdio->iter, dio->pages, LONG_MAX, DIO_PAGES,
&sdio->from);
--
2.35.1
Powered by blists - more mailing lists