From patchwork Tue Dec 10 19:47:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 13901998 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 D1429226181 for ; Tue, 10 Dec 2024 19:58:42 +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=1733860724; cv=none; b=B30uEekTKOLUIHj+3w33HdFMMjxxDW+n7Zuu2TjMqxqKjHDXv8D3GP9ypT8w5ZngfxxwxO5Vc9QMWAIM8bMbv203bV7BxqZ0zZiDqKd/F9kq7EwhvGeo3c+b/hZAz9154tWe7HZWSZmjYEyT0IeJVcZgezJw8mJtRwRRjCE2UzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733860724; c=relaxed/simple; bh=9bdeO/gQYhJwlrC6m59FA2mdSVREETfOSiU3VZ800AU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rBqDcfF2tFAnK8xZSWetgFsDhDgoZXPKrby5WBqZhwyLjTeHPIogWKzv5QJwIuy/5K212D/89DidKh61wfK8qPR0XgBRYg2RxkgkVQpolM0fTlVLlFvJMq5PG+4MOUiC93n3Lwn2YP/uRH7mIcoPADmz5UC/JazpbrWU0wnftkw= 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=D0xnDSIi; 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="D0xnDSIi" Received: from pps.filterd (m0109333.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BAEatlV003672 for ; Tue, 10 Dec 2024 11:58:42 -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=mgFHOgHaE4jw+dGMPOn2vA2NFSP+ToU+o7GNI61mlAU=; b=D0xnDSIiPRiW j93myHXtOI/RtGihPRVrqLwI8ggzoBlhuvUgZLXh0ypnc28LCZGwNAQ96xtYWUQ3 cX2Wxozs4noVcHXr5amhDe4YraaTjUBKosroiirT7sg6A+Ke41DigUl6+svn+dG5 EcESsvySIdKHxPQL4l6WkwIbjBcVZnlUJTx01zgVh/lgHr8WtyqvquSrH7nOJ766 Yw6DzZnzW4rTDh30o83IilcHzi+4rQxwKTyMux7DWgXlWnBVSp/AY7hkziO17MMa 9JKPCvC0vm2sgEQNBsG2uMeIJw+dWpdDPs6B62TWWIbZyQs206v+L4Bo9YXOh8Oe lI7nygUdEw== Received: from mail.thefacebook.com ([163.114.134.16]) by mx0a-00082601.pphosted.com (PPS) with ESMTPS id 43eqja2nhv-11 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 10 Dec 2024 11:58:41 -0800 (PST) Received: from twshared11082.06.ash8.facebook.com (2620:10d:c085:108::4) by mail.thefacebook.com (2620:10d:c08b:78::2ac9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1544.11; Tue, 10 Dec 2024 19:58:39 +0000 Received: by devbig638.nha1.facebook.com (Postfix, from userid 544533) id 7D8EC15D5C7C7; Tue, 10 Dec 2024 11:48:08 -0800 (PST) From: Keith Busch To: , , , , , CC: , , , , Hannes Reinecke , Keith Busch Subject: [PATCHv13 05/11] block: expose write streams for block device nodes Date: Tue, 10 Dec 2024 11:47:16 -0800 Message-ID: <20241210194722.1905732-6-kbusch@meta.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241210194722.1905732-1-kbusch@meta.com> References: <20241210194722.1905732-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FB-Internal: Safe X-Proofpoint-ORIG-GUID: gZTBX_DlX6pjl3OKlrEVFYdxUweyPg2n X-Proofpoint-GUID: gZTBX_DlX6pjl3OKlrEVFYdxUweyPg2n X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-05_03,2024-10-04_01,2024-09-30_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 Signed-off-by: Christoph Hellwig [kbusch: removed statx reporting] Signed-off-by: Keith Busch Reviewed-by: Nitesh Shetty --- block/fops.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/block/fops.c b/block/fops.c index 6d5c4fc5a2168..f16aa39bf5bad 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))