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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 66186C43334 for ; Thu, 30 Jun 2022 20:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=YJUMx25JnkLSpluSNWzz0LIB6yABqPp0PFY0YwPQEzk=; b=UQObuTNqVMBC+216t0N7XvvTxH s1bJo4THXw8STaUigAFeg1TwvXOw0r7lEzWh4ix20G47LJMabfhK9xV2rFfS9uWufwqLxVLJiE3SL QKZMppY6fDjX+RRk+wbq/BumHGqO2EIAYo6rbbgpIfZ+A6fp8nRQBZc+Tmmr/TZODwaUQr3A2eO08 mpuXXlm4RqLD2gLJzVE3JZO7JqVGUKwkD0/Yy/RgZR/Y9Ir/YEirJtPyzloold+AQX/aOf8EsHtws c7auu4irin0MY0X4Y1sL+lECRCn2J6A+do+huhUYzw2SW3p9NBLzyG4u/+gEdKZtu79/kQIIU3pa6 3vFrNmXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o711u-001U0Z-Nm; Thu, 30 Jun 2022 20:44:50 +0000 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o7107-001T8f-O2 for linux-nvme@lists.infradead.org; Thu, 30 Jun 2022 20:43:01 +0000 Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25UEbCcD022527 for ; Thu, 30 Jun 2022 13:42:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=YJUMx25JnkLSpluSNWzz0LIB6yABqPp0PFY0YwPQEzk=; b=IX8uBGPgUivsyHFY6eDNymaBh9cDdYPcMcC8VQwPUs8cNfTSKMZGMuihbDhhSVsF8zpi QapJ7mOX6ABhhJGyp02pUfBMO/7OuRd4FjsPEhMM357xHCYFO48g0r1MoFNKvz6hZzjv DqRZ9Ma2xeuFvOljgbIxQ2XYYcuCW54JNZg= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 3h0dgqwy3s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Thu, 30 Jun 2022 13:42:58 -0700 Received: from twshared35153.14.frc2.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 30 Jun 2022 13:42:58 -0700 Received: by devbig007.nao1.facebook.com (Postfix, from userid 544533) id 185D35932DC3; Thu, 30 Jun 2022 13:42:30 -0700 (PDT) From: Keith Busch To: , , CC: , Kernel Team , , , , Keith Busch Subject: [PATCH 11/12] iomap: add direct-io partial sector read support Date: Thu, 30 Jun 2022 13:42:11 -0700 Message-ID: <20220630204212.1265638-12-kbusch@fb.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220630204212.1265638-1-kbusch@fb.com> References: <20220630204212.1265638-1-kbusch@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-ORIG-GUID: daMVdjgrYcRjjt-Eixpvpg2hyhvLk_qT X-Proofpoint-GUID: daMVdjgrYcRjjt-Eixpvpg2hyhvLk_qT X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-30_14,2022-06-28_01,2022-06-22_01 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220630_134300_028954_AE312444 X-CRM114-Status: GOOD ( 17.22 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org From: Keith Busch Enable direct io to read partial sectors if the block device supports bit buckets. Signed-off-by: Keith Busch --- fs/iomap/direct-io.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/fs/iomap/direct-io.c b/fs/iomap/direct-io.c index 10a113358365..212e63b78950 100644 --- a/fs/iomap/direct-io.c +++ b/fs/iomap/direct-io.c @@ -251,9 +251,12 @@ static loff_t iomap_dio_bio_iter(const struct iomap_= iter *iter, int nr_pages, ret =3D 0; size_t copied =3D 0; size_t orig_count; + u16 skip =3D 0, trunc =3D 0; =20 if (blkdev_dio_unaligned(bdev, pos | length, dio->submit.iter)) - return -EINVAL; + if (!blkdev_bit_bucket(bdev, pos, length, dio->submit.iter, + &skip, &trunc)) + return -EINVAL; =20 if (iomap->type =3D=3D IOMAP_UNWRITTEN) { dio->flags |=3D IOMAP_DIO_UNWRITTEN; @@ -310,9 +313,10 @@ static loff_t iomap_dio_bio_iter(const struct iomap_= iter *iter, */ bio_opf =3D iomap_dio_bio_opflags(dio, iomap, use_fua); =20 - nr_pages =3D bio_iov_vecs_to_alloc(dio->submit.iter, BIO_MAX_VECS); + nr_pages =3D bio_iov_vecs_to_alloc_partial(dio->submit.iter, BIO_MAX_VE= CS, + skip, trunc); do { - size_t n; + size_t n, bucket_bytes =3D 0; if (dio->error) { iov_iter_revert(dio->submit.iter, copied); copied =3D ret =3D 0; @@ -327,6 +331,15 @@ static loff_t iomap_dio_bio_iter(const struct iomap_= iter *iter, bio->bi_private =3D dio; bio->bi_end_io =3D iomap_dio_bio_end_io; =20 + if (skip || trunc) { + bio_set_flag(bio, BIO_BIT_BUCKET); + if (skip) { + bucket_bytes +=3D skip; + blk_add_bb_page(bio, skip); + skip =3D 0; + } + } + ret =3D bio_iov_iter_get_pages(bio, dio->submit.iter); if (unlikely(ret)) { /* @@ -339,6 +352,12 @@ static loff_t iomap_dio_bio_iter(const struct iomap_= iter *iter, goto zero_tail; } =20 + if (trunc && !iov_iter_count(dio->submit.iter)) { + blk_add_bb_page(bio, trunc); + bucket_bytes +=3D trunc; + trunc =3D 0; + } + n =3D bio->bi_iter.bi_size; if (dio->flags & IOMAP_DIO_WRITE) { task_io_account_write(n); @@ -347,18 +366,19 @@ static loff_t iomap_dio_bio_iter(const struct iomap= _iter *iter, bio_set_pages_dirty(bio); } =20 - dio->size +=3D n; - copied +=3D n; + dio->size +=3D n - bucket_bytes; + copied +=3D n - bucket_bytes; =20 - nr_pages =3D bio_iov_vecs_to_alloc(dio->submit.iter, - BIO_MAX_VECS); + nr_pages =3D bio_iov_vecs_to_alloc_partial(dio->submit.iter, + BIO_MAX_VECS, skip, + trunc); /* * We can only poll for single bio I/Os. */ if (nr_pages) dio->iocb->ki_flags &=3D ~IOCB_HIPRI; iomap_dio_submit_bio(iter, dio, bio, pos); - pos +=3D n; + pos +=3D n - bucket_bytes; } while (nr_pages); =20 /* --=20 2.30.2