From patchwork Mon Feb 3 18:41:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13958035 Received: from mx0a-00082601.pphosted.com (mx0a-00082601.pphosted.com [67.231.145.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E4AC31C5F37 for ; Mon, 3 Feb 2025 18:46:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=67.231.145.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738608414; cv=none; b=muslIJK7J5UcLUagBypo2cQJmn5ajgxmmiTDMkR8W+Hd8ai8nVPjCjLSyY6uUd6Km0hi8TvGuh7FrwtoYtUOtCBzH/rZPHLeWGGVQvPit0ktk7BiwTCqTYJJUBFtfGDh4XwFIHGDqVYqSyVNPCL9GcfS236RCS38rIZD/E18yz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738608414; c=relaxed/simple; bh=/+wKU5EJqDJqXOd/rmfTWOgOxq2l6MFNquGYw1bk2Ao=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TwBisrGeqPA3i/MeJATebHnnPiLsxhFg8eT/dDZmwVb1J+h3xK4OBUvbxgBTwPHPCpM07FgCwp5EnfgmQ36zme3I4j46sNdCkhv/KRFDxhM6KJgsjjDk4FzL0t7921rZwSTbm50dXlReLZUZIuemfBoCV2S3S17qWvMMBuCdHtg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b=Screztrm; arc=none smtp.client-ip=67.231.145.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.b="Screztrm" Received: from pps.filterd (m0109334.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 513IHnAV023598 for ; Mon, 3 Feb 2025 10:46:52 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=s2048-2021-q4; bh=fNIXKTXv0cNcZjIIi47wETlFoGESbcaSE+f+/sI3Kv4=; b=ScreztrmcYk+ ik4FLgNhL9x1uriOEuoWH9gd8JsYQ5JEWkbQ/jbUTHo7eM0yw5BF5J4H09Kejr+J RAFpmDo9V4rHfzY6IdF65fqDiXtDsdIWqJhh2seZ847c9WmviqUKAP27jQ+n6YkR zMqn2icdmR8TaahvyVnVqkIYCOFsA9RKfbPC151Yhx4BIG+G6nJ65KKvOvLJ9rbm CqkJ1XpaHe2rQtXcb85b8x6BCD1Cl5WZf31aCH9S7tzFwDgQpWdRJs5OHBwhv40g CgSLfhmswjse5qOsWv1qHzPCa4s/j2qvoKa3KaspOCtyZ3ckp8NFyOJPkqTOzY5b 3CbsOjcYKQ== Received: from maileast.thefacebook.com ([163.114.135.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 44k2muge55-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 03 Feb 2025 10:46:51 -0800 (PST) Received: from twshared7122.08.ash9.facebook.com (2620:10d:c0a8:1c::1b) by mail.thefacebook.com (2620:10d:c0a9:6f::237c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.14; Mon, 3 Feb 2025 18:46:49 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id AD981179C262B; Mon, 3 Feb 2025 10:41:34 -0800 (PST) From: Keith Busch To: , , CC: , , , , , Hannes Reinecke , Nitesh Shetty , Keith Busch Subject: [PATCHv2 05/11] block: expose write streams for block device nodes Date: Mon, 3 Feb 2025 10:41:23 -0800 Message-ID: <20250203184129.1829324-6-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20250203184129.1829324-1-kbusch@meta.com> References: <20250203184129.1829324-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: 7VYcooOAH4Ydq1ahu3ZFr3S3xoxaLFwa X-Proofpoint-GUID: 7VYcooOAH4Ydq1ahu3ZFr3S3xoxaLFwa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-02-03_08,2025-01-31_02,2024-11-22_01 From: Christoph Hellwig Use the per-kiocb write stream if provided, or map temperature hints to write streams (which is a bit questionable, but this shows how it is done). Reviewed-by: Hannes Reinecke Reviewed-by: Nitesh Shetty Signed-off-by: Christoph Hellwig [kbusch: removed statx reporting] Signed-off-by: Keith Busch --- block/fops.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/block/fops.c b/block/fops.c index be9f1dbea9ce0..11902b7120af2 100644 --- a/block/fops.c +++ b/block/fops.c @@ -73,6 +73,7 @@ static ssize_t __blkdev_direct_IO_simple(struct kiocb *iocb, } bio.bi_iter.bi_sector = pos >> SECTOR_SHIFT; bio.bi_write_hint = file_inode(iocb->ki_filp)->i_write_hint; + bio.bi_write_stream = iocb->ki_write_stream; bio.bi_ioprio = iocb->ki_ioprio; if (iocb->ki_flags & IOCB_ATOMIC) bio.bi_opf |= REQ_ATOMIC; @@ -206,6 +207,7 @@ static ssize_t __blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter, for (;;) { bio->bi_iter.bi_sector = pos >> SECTOR_SHIFT; bio->bi_write_hint = file_inode(iocb->ki_filp)->i_write_hint; + bio->bi_write_stream = iocb->ki_write_stream; bio->bi_private = dio; bio->bi_end_io = blkdev_bio_end_io; bio->bi_ioprio = iocb->ki_ioprio; @@ -333,6 +335,7 @@ static ssize_t __blkdev_direct_IO_async(struct kiocb *iocb, dio->iocb = iocb; bio->bi_iter.bi_sector = pos >> SECTOR_SHIFT; bio->bi_write_hint = file_inode(iocb->ki_filp)->i_write_hint; + bio->bi_write_stream = iocb->ki_write_stream; bio->bi_end_io = blkdev_bio_end_io_async; bio->bi_ioprio = iocb->ki_ioprio; @@ -398,6 +401,26 @@ static ssize_t blkdev_direct_IO(struct kiocb *iocb, struct iov_iter *iter) if (blkdev_dio_invalid(bdev, iocb, iter)) return -EINVAL; + if (iov_iter_rw(iter) == WRITE) { + u16 max_write_streams = bdev_max_write_streams(bdev); + + if (iocb->ki_write_stream) { + if (iocb->ki_write_stream > max_write_streams) + return -EINVAL; + } else if (max_write_streams) { + enum rw_hint write_hint = + file_inode(iocb->ki_filp)->i_write_hint; + + /* + * Just use the write hint as write stream for block + * device writes. This assumes no file system is + * mounted that would use the streams differently. + */ + if (write_hint <= max_write_streams) + iocb->ki_write_stream = write_hint; + } + } + nr_pages = bio_iov_vecs_to_alloc(iter, BIO_MAX_VECS + 1); if (likely(nr_pages <= BIO_MAX_VECS)) { if (is_sync_kiocb(iocb))