From mboxrd@z Thu Jan 1 00:00:00 1970 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 BF188C433EF for ; Sun, 27 Feb 2022 09:34:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A5F08D0006; Sun, 27 Feb 2022 04:34:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 509F68D0001; Sun, 27 Feb 2022 04:34:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 383708D0006; Sun, 27 Feb 2022 04:34:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0133.hostedemail.com [216.40.44.133]) by kanga.kvack.org (Postfix) with ESMTP id 1FC7C8D0001 for ; Sun, 27 Feb 2022 04:34:50 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C29C7181AC9CC for ; Sun, 27 Feb 2022 09:34:49 +0000 (UTC) X-FDA: 79188050298.18.2AF09E3 Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by imf23.hostedemail.com (Postfix) with ESMTP id 45F15140003 for ; Sun, 27 Feb 2022 09:34:49 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id bt3so6502130qtb.0 for ; Sun, 27 Feb 2022 01:34:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2eyP4rVDSLxrBLm0L+IwXDpvwWoEKTOhBFmzO4cexJA=; b=SN1X/MqfJvhVYBUGyOf9BOYeLe+NmaeROrl70bvkK+f00RgsVrca1L7kNXuD/wcg9L xKCmZ2Pz8vWSqvhZGTSGz0bn+yPC7pzdLsxbAHOC7niJ2xUIRbSdTA006UFl43cSvClB Eu/WiEesp2A/IaFSnGxRHNzF65Nbr5OEyJxl/q5scyullQobittuRA9RsL64YhSAmZeE yblyQp16l6Hjn1nxs1PK37HlbUKIs3dYdip0CwpH9Jr/Npemuiakh89gz0E28sfp/eVK AuxWm+yRqP6ewJ+xN63QF5PgRvRcwe0IkEbB5ckzEiEAwC6gCacSZreeldbSK5SU8twf hn8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2eyP4rVDSLxrBLm0L+IwXDpvwWoEKTOhBFmzO4cexJA=; b=e7KodQ1iMl3XzdNPLdWwiVMd3EFcMJ8YE2js3F0b4xlqvQ7rcZl5klDxOq83Q5mjdd FyGYJ/xg9FLmCAOzqdX0WgxJTNxv0PlpKZC0f9HAIVagC68r+GAbaU2GjlPukSG30+J6 0MrHQWvYQy6TCy4eUNee202E3Y/XzmzjjyBQ/6jYO+/T0GMqUwZihUnZiQxklgzBr4tS 8r59Wjeg/DbjXQ1qeSu29isgZhhFbYNG3bMahxZgSKL3WYrzvMAfFsmjYlyHNra+w4uu xCnMhGN9+VSMpW/DH0tsegcncK70wNmSfi8nPP6RaQL0DpJx76L3rov4+BorZaiDINpp 2sLQ== X-Gm-Message-State: AOAM530U9KKZ7JpV/mkIDODn9HOA3qP/40r0mpwqmnt6iTTU6r0Y4N/f r2dTF7QQtXvLReyUsinvyDo= X-Google-Smtp-Source: ABdhPJyOSOodlyfcTfw39UkAF/bKoLbJjNNh1s2ZWZwG1dKH8ifuQJeJtZRTl4AMh8in27Ux3laN9Q== X-Received: by 2002:a05:622a:2c6:b0:2dd:2d3d:11cd with SMTP id a6-20020a05622a02c600b002dd2d3d11cdmr12732370qtx.638.1645954488604; Sun, 27 Feb 2022 01:34:48 -0800 (PST) Received: from sandstorm.attlocal.net (76-242-90-12.lightspeed.sntcca.sbcglobal.net. [76.242.90.12]) by smtp.gmail.com with ESMTPSA id h3-20020a05622a170300b002e008a93f8fsm469815qtk.91.2022.02.27.01.34.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 27 Feb 2022 01:34:48 -0800 (PST) From: jhubbard.send.patches@gmail.com X-Google-Original-From: jhubbard@nvidia.com To: Jens Axboe , Jan Kara , Christoph Hellwig , Dave Chinner , "Darrick J . Wong" , Theodore Ts'o , Alexander Viro , Miklos Szeredi , Andrew Morton , Chaitanya Kulkarni Cc: linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, LKML , John Hubbard Subject: [PATCH 3/6] block, fs: assert that key paths use iovecs, and nothing else Date: Sun, 27 Feb 2022 01:34:31 -0800 Message-Id: <20220227093434.2889464-4-jhubbard@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220227093434.2889464-1-jhubbard@nvidia.com> References: <20220227093434.2889464-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 45F15140003 X-Stat-Signature: wn6mjf9zmqx5o1enen5dea9ot77a311p Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="SN1X/Mqf"; spf=pass (imf23.hostedemail.com: domain of jhubbard.send.patches@gmail.com designates 209.85.160.193 as permitted sender) smtp.mailfrom=jhubbard.send.patches@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspam-User: X-HE-Tag: 1645954489-460615 Content-Transfer-Encoding: quoted-printable 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: From: John Hubbard 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 --- 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 +=3D entries_left * (PAGE_PTRS_PER_BVEC - 1); =20 + WARN_ON_ONCE(!iter_is_iovec(iter)); + size =3D iov_iter_get_pages(iter, pages, LONG_MAX, nr_pages, &offset); if (unlikely(size <=3D 0)) return size ? size : -EFAULT; @@ -1217,6 +1219,8 @@ static int __bio_iov_append_get_pages(struct bio *b= io, struct iov_iter *iter) BUILD_BUG_ON(PAGE_PTRS_PER_BVEC < 2); pages +=3D entries_left * (PAGE_PTRS_PER_BVEC - 1); =20 + WARN_ON_ONCE(!iter_is_iovec(iter)); + size =3D iov_iter_get_pages(iter, pages, LONG_MAX, nr_pages, &offset); if (unlikely(size <=3D 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, s= truct dio_submit *sdio) { ssize_t ret; =20 + WARN_ON_ONCE(!iter_is_iovec(sdio->iter)); + ret =3D iov_iter_get_pages(sdio->iter, dio->pages, LONG_MAX, DIO_PAGES, &sdio->from); =20 --=20 2.35.1