From patchwork Wed Oct 16 10:03:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Garry X-Patchwork-Id: 13838078 Received: from mx0b-00069f02.pphosted.com (mx0b-00069f02.pphosted.com [205.220.177.32]) (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 E4404205142; Wed, 16 Oct 2024 10:04:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.177.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073051; cv=fail; b=PQX6THqt7CfCt9FImzh9gBq/KqtROnUH7KbKVFUraxdpXOZmFqnp5b5MBuIqODArRwWO672SSa17Ay1iwtmjJcslMjWvWDt0lxkQTBmTN0gi+BH+r3IviJJWJjPjnki3KmsltatrqJDQVAjVnJK7ia5v84PqXLIFragWRFhps0g= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729073051; c=relaxed/simple; bh=7sYTQfRJi+Pg/3bmTlcxn4KenjXJ7ZFkDJthE1pnCSo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: Content-Type:MIME-Version; b=mPO9rapUoDNJf/+V+WDSXQsLKMYehI0O53BNVQFhluAmWvMYalbM0sP2xdZU0WkCtrjzBoNCj1/+XVL5Oayovb37qrHorHqtzTFSA7oXdsqHi6cVO7TrN+5ujnnK+kqw/o2Xt/6tFOHyBGniYQ/iYyp9dfKB9yU7pGKKIhjlV9I= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com; spf=pass smtp.mailfrom=oracle.com; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b=KM4ZiaME; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=gwRFLkRt; arc=fail smtp.client-ip=205.220.177.32 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oracle.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oracle.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="KM4ZiaME"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="gwRFLkRt" Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 49G9tdup012975; Wed, 16 Oct 2024 10:03:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s= corp-2023-11-20; bh=P4QkuKPgfQips2jxDXpkAE4pKRyxdOB0HWwzFWFB5MU=; b= KM4ZiaME9WscugK5yt4+kmwNdIaWuipzzz3oGxmkMb+LNG43/U2zTax6u9GuSUUe U3XSP/UIbA50t6uCSEHIXPfn42QKZLrayJAPhd/pCffgFWZUNizJl+Fy1Eab4ZgH N8B4Fq7a/HTyGLnyJGC65zUrup1YIeAnvao++FIGBhCNjqsFZLsM3Un3Q9SEO8Jp f1+5o0zyKPumhHJy4cZWiRzRuNqLikVx4StFu7WfCAxZoYCZ0QjdGRRKzaEpyLf5 XGuPbN812bS6aMCmMDO0UUlIxNEldR7onxlsFdw4wzo4Mab5WHAKZ5lcC7nVTvY8 8KyP4k4VTBSVLPPTIdp7vA== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 427fw2kfaw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:54 +0000 (GMT) Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 49G9ANib019471; Wed, 16 Oct 2024 10:03:53 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2049.outbound.protection.outlook.com [104.47.74.49]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 427fj8mrkp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 16 Oct 2024 10:03:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jFOnMvMHkrlg8bMxYCnr9/Oice9Q5Jjy2Dz05Yhd93X8FW+iVp46uZmwVfQPdTegfG01l6mhmBKeUOTtOHmKmPMoMdCraHHOQWAJlIejJ3BNBOXqb49Jv2JdxaHE+oKsjBc0RCqhXLBL5wv99Caw8GggdPrXyurf64wWvGF8ZjskK3aKChojONnhQ/Ur2YloqWSAEeHssRrnGe0W0LEb7x9M0TgyAd6NoIU09di7efHL40MPUd0PWqTMFHwziVaX17ayQQQhKk5/jJ7yOIO3Z8q/ZFMO0CCby1YGdXHByVvKg0Y9M87jBPuRgr/cOWi+EWr1dcLxrBHU4fZQTNdItw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=P4QkuKPgfQips2jxDXpkAE4pKRyxdOB0HWwzFWFB5MU=; b=ZumPSgfSK/F4K4f+XE6dsxCNkyTlvBBTpBSh9lc1RwvsX8ISAyglWobyB6qEVnRdYEjaY78GY6sJ3+6qOHuz+bK7e0wRBiU2HA7n3JwCJXMHP1kCRe8kUty/ERGAFQiSeFPknjvqTNnEXDIxHJqMeYRUn7qmrONYbES3hYsVscs981AbQFbXaO05lDkq5yESJ71OyoC01x1oszeXVm9xBRCHPpICqDAuY0GBxe5kO2u22vKSA6v1Ik+4RsXOYGKRTfdLMOe7nxwNXvwCpawmXwOUzYXA1j3+J33Ddk8raZMYnS1MKy8AmFrxz2/vltryCiq5Ndmi9SmU2QK1EgDNeA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=P4QkuKPgfQips2jxDXpkAE4pKRyxdOB0HWwzFWFB5MU=; b=gwRFLkRtq/Kwgv/xt9rcftPwhIih8UXIDejdni5pU0ZwTFznp4paYqdOlUs9WS4+pUexNiDjsdibsMbHy5IdzDQ84Ll30bYo54+KcS4chdsjUh83y22hnAn405ovJzd18wZ9ayiJ51tU2VakpQivE9Kfo8ef305tbNKIaJfgVpo= Received: from DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) by CY8PR10MB6634.namprd10.prod.outlook.com (2603:10b6:930:56::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Wed, 16 Oct 2024 10:03:50 +0000 Received: from DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088]) by DM6PR10MB4313.namprd10.prod.outlook.com ([fe80::4f45:f4ab:121:e088%5]) with mapi id 15.20.8069.016; Wed, 16 Oct 2024 10:03:50 +0000 From: John Garry To: axboe@kernel.dk, brauner@kernel.org, djwong@kernel.org, viro@zeniv.linux.org.uk, jack@suse.cz, dchinner@redhat.com, hch@lst.de, cem@kernel.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, hare@suse.de, martin.petersen@oracle.com, catherine.hoang@oracle.com, mcgrof@kernel.org, ritesh.list@gmail.com, ojaswin@linux.ibm.com, John Garry Subject: [PATCH v9 3/8] block: Add bdev atomic write limits helpers Date: Wed, 16 Oct 2024 10:03:20 +0000 Message-Id: <20241016100325.3534494-4-john.g.garry@oracle.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20241016100325.3534494-1-john.g.garry@oracle.com> References: <20241016100325.3534494-1-john.g.garry@oracle.com> X-ClientProxiedBy: LO2P123CA0095.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:139::10) To DM6PR10MB4313.namprd10.prod.outlook.com (2603:10b6:5:212::20) Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR10MB4313:EE_|CY8PR10MB6634:EE_ X-MS-Office365-Filtering-Correlation-Id: b6a85e4e-0c15-4da4-263f-08dcedc9d547 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|1800799024|366016|376014; X-Microsoft-Antispam-Message-Info: I8Ko78psgNHvMe6PbuexMJS77DT1S4WKdbQm5YNWUAJYyhQaMKOOBnPr6vYK6m41Q5PSLc0jnyJLUOGRGYMRs6zvIhxM2pIvTBgGNLkuwkJeVh1nRPfC3qeyLrUTnNHyXjzXLRPOjYIkddnekwtYFuxab4QoDbHuGAeiuLcrVtCCK8ioX4nnckPtVhfdYwegnkGM5HnkyXjlDlQP/M8zZvOmUqEi6SJTxcEM722/VX+QZbEjV3+By8CIbkB7lkGeXlaRphAeiDghfKzXRC2tfYzfwKX6UCq50WQFhfeLV3xmHacPY0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M;H:DM6PR10MB4313.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(7416014)(1800799024)(366016)(376014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: opFVRvb1QpVTkDbFW3BXg+48ysIQXQlkeTg6JgXfTLsPviedDR4MvIgJhZFW/OA2RZqAzM3hzD67Q5cCKY513TpTPTX3xSI4bL+KBu0qPY+r9B++K+LFS+yYiq1nOWx8FFOSOk3mU8TRxdk4bLzGWOfkeFpOGjGu5r9IbmJRokR2+51J6QhT650z+jY4/v7LzXu/2niywNRTb+rAtRDAQ1+3OFQEOzxdl+lFxh9HYRz/Fmg2YJHp+3qFAF/gGUX+kX9kRdFl6WANdZ53+EHRTYDbICeocFGcNV5vEx5Z8gUH1qZ0dRy/+7tfqJcYhsd3GQFvJd2aIuJ/P1dFywiDX8Q0HquHCipybnr6IaKfxi+1xRMNeJmXGJHnS/6ll3+aMQA98F4Z/CHL5WJxoe0hvcY6FadydLQF/1ksbnH9t256DXj9v/YmZxcEB+tSi0ljcq/vliekITkCR55sKatp2Upjs7gNd5kg4NkB6xW2VolygWkKxGJ5okHmCCLzBdDpMtimUuEnU9nejs1PatMKDwgOwZtx6uAGy9Js6NL06NwRPcCZyLlJ4rYerEWz4G3A9k1PGn41vCr1mA52oE0HpFb0sulaXwAIMJpz8zxii8/VMyqvpAVew5waCN0rjezdmL3Nwh9LbMa2SDPJoAjj+ru6MEHiqqc7A/cu3oHmJ0gtFu4m/2Z2nKJ37A9lVpJ8HylwBWXEBUDWKC7il83AoydAA0v1SprbElxjIxVNI5P/vWJIjPBx2uv0tJDf9Zg/FQGfJwfPWxTCKPdXylkU2q3HYDd4bC9iOg8AK7iKOI0MY6wZJiyNF5IYcq7IiNnJ8HDPs55HP8XNGtFDiHAlxpGdpejhw31z6BjVDTnt2365gTNsu7rLIHiNVvbJiini1bHAR1k64faYiG8S3jeQhozXE0IIKjwYnV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9aKWfEAOz1n1wHK9EoCKKMroWqcuMcXsWeLwrz/aJsoRyq6rzKN5CB3zG2MDBiO2vN8+cQzRxn2+NXOM4N2gM0oxwnDzbKYmJCBEjfc+Nlz5EM9kdG5Kg2hmVm0rqIBf5P/jnG414uYgyAIq+ZRYxvd6gj34BkYKcaHpOdnjcD2FQVsQTcBQ7HAzNu8AL8RgfgUk0wO/6pk2lmzlujfSwMNcgHZ7q5k0O7XM7t39+YMCq6TFPhp+tvrg2Ou3bNaB7D49UBq4efftMkwpjyDAjS6NGw+fCxtwLeNdmX/k1GY+V9/PyV8= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6a85e4e-0c15-4da4-263f-08dcedc9d547 X-MS-Exchange-CrossTenant-AuthSource: DM6PR10MB4313.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2024 10:03:50.4510 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Akd9cdv/eOhXaAfoZDEthn5fz/yd663aSlRsXu+2NZBmnflSoC+XpchlcCwJLmBaENmv93UxLw6N/95noL1+Zg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR10MB6634 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-16_07,2024-10-15_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxlogscore=999 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 suspectscore=0 spamscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2409260000 definitions=main-2410160062 X-Proofpoint-GUID: 4RxZMyiGHPzuUDMKHB88NsSp5zUj50vM X-Proofpoint-ORIG-GUID: 4RxZMyiGHPzuUDMKHB88NsSp5zUj50vM Add helpers to get atomic write limits for a bdev, so that we don't access request_queue helpers outside the block layer. We check if the bdev can actually atomic write in these helpers, so we can avoid users missing using this check. Suggested-by: Christoph Hellwig Signed-off-by: John Garry Reviewed-by: Christoph Hellwig Reviewed-by: Darrick J. Wong --- include/linux/blkdev.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 50c3b959da28..c2cc3c146d74 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1674,6 +1674,22 @@ static inline bool bdev_can_atomic_write(struct block_device *bdev) return true; } +static inline unsigned int +bdev_atomic_write_unit_min_bytes(struct block_device *bdev) +{ + if (!bdev_can_atomic_write(bdev)) + return 0; + return queue_atomic_write_unit_min_bytes(bdev_get_queue(bdev)); +} + +static inline unsigned int +bdev_atomic_write_unit_max_bytes(struct block_device *bdev) +{ + if (!bdev_can_atomic_write(bdev)) + return 0; + return queue_atomic_write_unit_max_bytes(bdev_get_queue(bdev)); +} + #define DEFINE_IO_COMP_BATCH(name) struct io_comp_batch name = { } #endif /* _LINUX_BLKDEV_H */