From patchwork Wed Jan 1 18:06:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13924246 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 CD0D933EC for ; Wed, 1 Jan 2025 18:09:56 +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=1735754998; cv=fail; b=Ry2xBpCESjKvMz+egQz+sxunK3Oee7FlUHr9EuzmhKNKwCbhaQvX/eN85gO/Lk3oNEWYAY47A/00gjdvdmAU9MmKJwZwnQ+tXedFda92JQjT7PINfE1OYLvETIFMtPJClzrNnbuo00uhSIQyI5bC1jo+N1jJtRiyx0QaOnH36OY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735754998; c=relaxed/simple; bh=R2BCkGML/AqEr1qSZ5unJxjAVDJLl0H8bnfTWh2ttlA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=eZ4s60Zzie0DnkheGIqGu5EDWUAUPlOFYUkuq49e717wCAaQ3VrLoklDvmvCImmRe8CD6TcVQ7QMVa2FQdnPyUqagvjvQv3iBk33op8cZw0yvH6l7dLCKY2LKYMjkdlhkcodQFEj38IJzUVqNnLHVxc1K2QGGnvgxUvDAtbmgMo= 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=MHfRhZna; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=PpQHAOcT; 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="MHfRhZna"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="PpQHAOcT" 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 501FlJc1004980; Wed, 1 Jan 2025 18:09:41 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=8MT7Fpd09X6igMXb/b14ECG46Fa7rDsL6SkenwXXXEA=; b= MHfRhZnaTTHc2P9zyE3JJ6TJOWzhkR7/OqW6sfpQZzof64/fPWRj9Ba5SgD5hlhQ SFNt3rmw366dfW8EU5eF3TFf+KO0Lld4dsTJjk2yJEd4GYI57BIl56zeO8pvjG5F np6GfgWiBV04kTf2FPxEqkKzCHmJhS6ZbFSNLlpK4KlQVrLwBcASKehkcahz8tXG /Tuml86lQgLLbMQQhd6SgX0B88Vjw+gQxkVx5+h360QOiKZv65v0gNKPDno3XivI cG4+w0inuosPvgQPjpvYTs3P/lMuLUIMbwV14oEU3LfWJwzyWyBsOZITcoExJfuI NMi/wBVjbIzdHN/vTy2y+A== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t841vg6c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:09:41 +0000 (GMT) Received: from pps.filterd (phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 501G3hss012965; Wed, 1 Jan 2025 18:09:40 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam04lp2046.outbound.protection.outlook.com [104.47.74.46]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s7x1yd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:09:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=N+AsbEuiW6+GrQB4D7jCRivFPjAzx+rCxjTMTHKC7OP6B9ZXqrk2hcv8sYEHWeXJB+NOfviSA3T+jRgDaQXVltKDtwkfsQIn3vLmWDRDxn62GdoOm+3LR+waNBb33UUc4OfmvSSJz2aw6JtbATNn7/A60NPJ4G8RiL7TBXeOHuPetXVhy0Sh8151AD+/xhgVy/UyLb9yM7jX6f99GLUP5QvDlY59AI37/QbnA1zor+qTJ75nv2ZAxFvF5VFmgxs0GRHZf8Fo+1S9OPM+SYJ/V3560IznN9cpPEKtnOYzB1SvMXUErWvBBcn4QEtM418nkWjgacX3y8O9gkwet0N55A== 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=8MT7Fpd09X6igMXb/b14ECG46Fa7rDsL6SkenwXXXEA=; b=pHQBf/uxwbdkYAKE5P+pt7dsudIdmxs6TCJgE7IDxIl+HMvalk6pH4DtNz8CyGjJdY7qGswR0M5NCn4alWqN1JjW4C35A7PNFIh7h3ZnxjK8uZMbXwo0b4Rg3NawIdavLoLQ/JMcbVZK957xfoeAHQvrEdx1OjL67YFQcVUd9q9TtUQMS9hv45LWXww014K8ZY6ZKNBCtIHOd99TJpEXEIk0Poq+rXYJLl2UHN8GfMR5Yl0/MbJH3WnHbh6ecgrO/flrLyDg/fiY+jDdDKLGLg2ALryjDV5QKEjTM0HXDPwNKjnCTC8/AVzmLNnRQzMK5bgslFJhTfDSYaDgd6tqSQ== 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=8MT7Fpd09X6igMXb/b14ECG46Fa7rDsL6SkenwXXXEA=; b=PpQHAOcTbY8vDbbOIGEGReiIUMR5GZ1PtEaljDo+tjv9fSN3EoZDoNIqA/AO91w3nKQDC5tY0TdJvwbdiIsNEaOGuWa5iF9gyvYXzZQp0Io62DH/8hZfuBD+7jzV/usOAJzAZl5kbwl+1mKDu1Jm8KkzXgCxWJIkidz4fRO+I8o= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SJ0PR10MB5549.namprd10.prod.outlook.com (2603:10b6:a03:3d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Wed, 1 Jan 2025 18:09:34 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%2]) with mapi id 15.20.8293.000; Wed, 1 Jan 2025 18:09:34 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, Naohiro.Aota@wdc.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net, Naohiro Aota Subject: [PATCH v5 01/10] btrfs: initialize fs_devices->fs_info earlier Date: Thu, 2 Jan 2025 02:06:30 +0800 Message-ID: <3256aeb56d180e3becaf5d05735cd2fa06d634c5.1735748715.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA0P287CA0006.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:d9::12) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SJ0PR10MB5549:EE_ X-MS-Office365-Filtering-Correlation-Id: e9b31b90-8161-42d0-e971-08dd2a8f71f1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: tMJq/6C38M1xVrQA4eT7GvFv5EqB4WPZuy9BzYCHHR/7mm6CTWo3hzi/lfKbabaJ7ZVjGXe70pL26TS8FkyobxlQjMdSV3QNkF2sSa9z19E0KO4IiqkP6zoStmMG1eR6kEf2c1XSNeGvKxWXCdXIvXl/BnMSFCQSYOqYLDEcLSjqJBNL8gscshCg31bVFskCAOkuRVJ2MoM/WDsvWUu7t5Z/zBFT4nRnz7R/X3nx2FL/KDv3PWgilU1hT2cQiIHC3ZW3zgQ5IVTbfKtBNb8ECQvANBMYleoG7uXJJ78//k3NSoUi0ARM86Us+YALN67631K7wdXuZNvvIHOqqycT3BeJ6q03W5PkioCetOzZ8YLAicMHCIMGL8KNz+4vymZbs+YOPT8bGj3K6vDIkIm6OmrgrvD4n6n53uab6YeuMiNqYRhldwlxM353/zb5ZlvciA3BM9UKMO0RNB01uoMApw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kV9abPjy82b5OxleSV48SNsgyQpHPJbU7ub1dyH99CB9UxEF4Y0jno1nqDxxa+WfqhA2UDyiK9yGP58yDp8rbWAt29XfQovr2iQeGgF0afbSmxNy/PJU+7G07jIPR2sJ8DeKl4pTmQo2envNm9RjSI2YB5ktkB3HtC7ZKcSayueYqIjbwwPx3N8ZOKyAKUiEeuDdp9l59Y= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: e9b31b90-8161-42d0-e971-08dd2a8f71f1 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jan 2025 18:09:34.0419 (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: wFdbmE16P+0m4E4Q/wWLAF01MS3p8yuGTNMqOjSIsBSHJYC1bxZog8OJSlmg5ODtGbwPr6UYxlZMYe+iKJX9rQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5549 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-01-01_08,2024-12-24_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 spamscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501010159 X-Proofpoint-ORIG-GUID: JTY-3ufcZw2ToFENiAbSbsmH5j8BGNkG X-Proofpoint-GUID: JTY-3ufcZw2ToFENiAbSbsmH5j8BGNkG Currently, fs_devices->fs_info is initialized in btrfs_init_devices_late(), but this occurs too late for find_live_mirror(), which is invoked by load_super_root() much earlier than btrfs_init_devices_late(). Fix this by moving the initialization to open_ctree(), before load_super_root(). Reviewed-by: Naohiro Aota Signed-off-by: Anand Jain --- fs/btrfs/disk-io.c | 1 + fs/btrfs/volumes.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 814320948645..ab45b02df957 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3321,6 +3321,7 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device fs_info->sectors_per_page = (PAGE_SIZE >> fs_info->sectorsize_bits); fs_info->csums_per_leaf = BTRFS_MAX_ITEM_SIZE(fs_info) / fs_info->csum_size; fs_info->stripesize = stripesize; + fs_info->fs_devices->fs_info = fs_info; /* * Handle the space caching options appropriately now that we have the diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 1cccaf9c2b0d..fe5ceea2ba0b 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -7568,8 +7568,6 @@ int btrfs_init_devices_late(struct btrfs_fs_info *fs_info) struct btrfs_device *device; int ret = 0; - fs_devices->fs_info = fs_info; - mutex_lock(&fs_devices->device_list_mutex); list_for_each_entry(device, &fs_devices->devices, dev_list) device->fs_info = fs_info; From patchwork Wed Jan 1 18:06:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13924245 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 AB8191E231E for ; Wed, 1 Jan 2025 18:09:55 +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=1735754997; cv=fail; b=AlYur089Gzm9So9Jux/a8l4E6t3PYK70yPC56/JYgZcngvQYJZf0WjNVSqYFuvdVFhkwb4ezCMD+GHMszhZUwZOpr8SCVPBtysnNZort//DFpbW4qeba+g2pNiQ3ME0gYmSWdmEavoW43fDVCMoGPKsMB/rZOSTDBLX8LF3jk3I= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735754997; c=relaxed/simple; bh=b7uPh5whV7MewalyZ7zR0knjGEdFLsevpwEqHQtFTPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=ZMkyszVgDh2xVLgA+Hnms/KPo48eeYp/ZTl9jx5W+7QuUzq9KxRHCn/jRcln//0Z04vWgKa6xaeKNFW8MkAzIdFcTCeDTJu+JahlZRK5cbs93mNccMj6QzIetXBB7l0jmJiF7HJ80LDjMc1dWXgAxzF2knvlWVmOkpZrBIjX2PE= 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=DFUoVr4O; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=O7wy1UBt; 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="DFUoVr4O"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="O7wy1UBt" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 501Fl7tQ027199; Wed, 1 Jan 2025 18:09:45 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=z65in74P5MF2tELa/EF17Ce6XG3Wx7bzC8YUMcexup0=; b= DFUoVr4OSxDjhUeWV9gIxV040gc6TlWutyP29Kf/0KaIIhKNc9JhmSTzmAsa0kfk WfGb8F1CJiSq6FFEEMtJv17OHYKhxPozd/Mj8s1kHGkiUP7l0Run3YovDFCX+Zkk /SwuT0uYhu4BJ5kh/oxX3Ur1+cEnvDI/vaphrKTjMgJ7A4oyVG4w2BVRDIgD4W2r RV1HTrBB2FyKmFBvfP7uXUqrJjZIEFIJRN1Sr1a2+E8e4lab4guoh2YCt3D/SYa7 1Bvo4JuqnEIKTUOIhUkqLm3la9JXixn4PNOdDWIteu9/YZu+uUTY5AnyOoJmjgFj W1enk/fMZEdp0a6MCFrevA== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t9chcgfs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:09:45 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 501E07h9009126; Wed, 1 Jan 2025 18:09:44 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2046.outbound.protection.outlook.com [104.47.55.46]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s861d8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:09:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Cw60TlJGsJjiG0LLUuokGD1H3jpqIz44U3G+QexemKvNUW51eK/SisufB6D+GTKgAAO0qx3u8Bvc/GbV7k0YqbibePWbO6FAEpyxk1v1PzwNtuBxST9WrxqYGHi7C1KQhxeK3XRQrs7vLQ9oxfHfizqZf2u+Qynn1OvWb+YciHvMm4l5qhR6ulK9zPZd2a2Cn+dhEc6j7CnuJrm+GgDKl4SI0kSas4TW4HGPAtkYVCknYLajnijTrR0wCC8cIJbgagJgiHqB5UO4aSQwRXnmb0VP+nQvr+BUSn+yWBzKWRZSTuo+Xg/AXK/MnUTHRVO+toaJbfDEzVA3UJTmr3ysZQ== 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=z65in74P5MF2tELa/EF17Ce6XG3Wx7bzC8YUMcexup0=; b=eej7jmWcCV+qpHH8xPn5K2C5MDwyJxIoLuzyLmyneQzz5ldsoYEJw31Jgxv6TQRMM3DTLTrwj8iED8xdqoeW8MQGPxIhO2Cd15MQgZuQQ6N2gBPL04iUJxjBgjjFcXgqMNxZwEuA/5sa5PWPeCs2wB/2UnhXK6rX5zgO7yP8gW1eBSZL2Gb3pLKa2HXGV5XK3/ycKLeuttrDKoYMuK2q4fqryw+drwwLGmeDtQ5if5xTB2Ob84E1D49DHiGkliMaliU0ALxYtgEZBGHs+ZHSjOw/7zc3Rq9hfZoKHCqFUrkosoSHTxWBHxT4pJSXEjtKQ6A6iyIhPu/OzNWOX01IsA== 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=z65in74P5MF2tELa/EF17Ce6XG3Wx7bzC8YUMcexup0=; b=O7wy1UBt0HgnBQ75fZmcTePqww7AIogc3MJqyQwEOJIL7Uu44GxxCz0SXIYtf5dTWwaSt/i6tSVnH5YeZAqTa+7KL+5t0ZhhI2V/yheHUknUs/mdS4GhhCv9OObnHGXQerL8y96aiVeL/kvUAc6N2Xa3ezwf5yzcmY12Kc2eUtw= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SJ0PR10MB5549.namprd10.prod.outlook.com (2603:10b6:a03:3d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Wed, 1 Jan 2025 18:09:38 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%2]) with mapi id 15.20.8293.000; Wed, 1 Jan 2025 18:09:38 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, Naohiro.Aota@wdc.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v5 02/10] btrfs: simplify output formatting in btrfs_read_policy_show Date: Thu, 2 Jan 2025 02:06:31 +0800 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA0P287CA0008.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:d9::19) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SJ0PR10MB5549:EE_ X-MS-Office365-Filtering-Correlation-Id: b151a24a-bd35-448c-ee96-08dd2a8f74cc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: 4XjATll171s2cne7XQaHkoNuUNK/+s1dz+qxDoxvDgwcg7GoIy5i10Hj1+aAdMI7jCHwCqL/LsJgWhDAiiPTyRodC1PyzvToGkdTQol5ARFUe25PEFfKEov63UpT6pyu9DKdO6xhTnlQ72xe03vd7qb+vY3Zz2AnTpgc2ZNSRjkT5AzjB67FzUsGVlG8kI6Eg4qK61IwV+6AXFAD4/PuTmSKsPd78g0XkpBkz6WUbAZ2/G1uqxRTMP5o/wEA1j59zCLWJGIGUUch7Bu47iK/DnM4z2BISh42z8rFt7/qi6yGuTk7JLhew5rkXKqQKfTPxAhc0qhGWd71DzGx99vvtohtcIn1a50ivQRbC1ViG8dX4QZXZ//YgKcs0nd5zHo5ppz4stqo+dSn+gQWETgpdU5QWxH8W3cbiesD0elemD3unBrItPLdw7ec6SfNayQ2+INq+7e8M1khwHV/MtWfOn610gVXjSCJ8b3absNRBE5/KZHhxVo0npyxlkj8y8dy4MNWT9NXClhjeJifUgsgYvAbX2qT98Ca9pd4rpnhTRcZGxmpaNwjAWVJL2KfZU0SGjqQhtUC0iGhagGsOi4zs+gnHWzAsIMP7iAf/TEwBigjiW8u7XNIXBUBncI4WUxP1RXuqRSeHQhyCxLvrTgt/Br1uEeVl/OnKV5YiRfS7Mk0/ZECjmE01v0YBYbBXbH1cm6Etk+9t1VLVaKvfLVEOKguyL/dlqdFvfQuA/BnmmxvqX8thl62Yi/sw5TfVVLxKOQaf8fSPrTVrptOyiVpRdW8ShmGl8S8wUsFZPcWkzdNu2qveqGsNu1GrK6X/soHnUOZeztI4pjb41nvqOzj/hpgpA34Magtrd4fpWfy1zG7hFCPiHlhaaoo4z/5dkjm7HCaGkH8HXOKnR8nl3EhtLXnKZpPTw/7bnLXWCe4si+K+0mlCrwdVRUaZ0a5tnUYcy+/n1dhNu5z9sVodNenfrJblz36MOh5NPWykpR/pshLSIHTcApIelqqQPlCG70vEm50+rW+mY+RnqaU9xCY72fftsvZSxwsxzzxyzSW9D9SmFcTLCkcE1xNGEKQZZeb38AQQRhRM+4xhO0CS7MpDuvje8Afb2ccydrNJejqIwnh3CIHTqIvv8YQH9020IbiKwVdBYbK2WLjFc3u9zeCf75miyOwt4RKGGVR6MDjs3d2KFB7Ne6ze/fK+xP1U68Gsg3kH2Ob9OpGJU0FuxaL85WPsJXP18tKnZO++m+poqbxYe72TXGfyLlUhpqznthL7bDJ0MfJ+jHBN7q6Eez9gYmbzjtV6Tp7hydIeP8Mfhgi4rhxPiaEhULgSnZN/jpA6JXNrSuZ8ENp5J89u+ZkiBZt8CZ6/y1/o8DeArye9+RsWrp0qbdvYJjnpR1gbBRN X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Z9L34PoGMX1V6pyURGxym7/asktsiiTQil0sJv4c2KibUChMbBGXSS1DopEkCvgMLUU4j+tQzqYpaMpl/ExchoXoh585hxhpjYrj7xwjatfZuuHbMMz96rcc9o0jJiR04G8c6+UOhrDClPoX9ScPvYqafiwTiU150uCAyb8+uADcAKlFhss9FfpjuTQjMZBx9KgPCd9nZDZNUoRTUdQXxgxFd5LAQCfeRNQi4XMAxgw3r/KbENQsqqD/YprlwXwNNlPrn9H3GAlTfsgTxnIaSlEt5WNon9VW8ekKYoNCgY0oSwHnH5gefHmtOeLKUHFcXuG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jCxJdkprEt28l6yJCOkWUoNXSXsft2VvxhV1tr/CC6zv3PfjMVgMBgRh1sGAPwLbF1v10t0nMIJkEoLYT8fdncZpx8x+N2pXrfpmQDokLJeMQUerw76gfWbLnseOw9A3uWGIWmC2JZuN3dGuruIkdg2HoORzvBCQSL/lMDkpnRo6bq9kOq5Z+ZT X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: OA9Nkb6cH7e+JA23lJ8dGbx5BM0DvjSVTGV44aECtgXvsTLjLB1m64CCK0FgruvwFONrwalRG0BzAKkXkN1ohm35AMj/NcRXaaRpiQv2QjBjnHDYcQdFCmbIvaY5uZMgzINVBjuw8OHZg42GXY52tafvhzluDku99hC5aUtUkZKpicrX2mIzmtQ4J0sROiZj1XlP3a7QxsBkWW8dEnbad/LIFSvR5mAy16t7yGX1pCMFli+kcIG11WrX7gm1fYHzaPrMlPSMrh/XTRtgcYjZu2rkq8MVrxRkN0zRSQfm0+bogllTeLGOhDQuzabYxxRG0RqXx0ratYoeYo54dqzz8L1NqcVbN3nBaDuXFc6oShaZp9LSdpFh2u5zt05Oe59+lhvF5feUkCC9H7+fveL6HiZtaalPyCI3cemw4ZZJ71rNS19vpzq0S+1ZhmgdX6RLOCduauKXXhhpUskJBK0IJvRhzFVjWlnPjdqjy3+eNEr3zsqztbjtJKHo0V2k0riXg9lNZriia96d7gKkIuNLTMr3BuSol4Q53KfeZVYsGx/S3Q+z+Q1mpvNwXRRydARhGv3/fyYPIibgdIvskeCPv2/D6qZBTtK1XPef/9USpsc= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b151a24a-bd35-448c-ee96-08dd2a8f74cc X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jan 2025 18:09:38.7703 (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: phRftiFjGM6I6aveq7bNyR7gIHAA30IGz1v1SB/XZbp70c5amkfqV2g3ovMQ5Kv7TJOro9Rd/IIHK2/nl4cpDQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5549 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-01-01_08,2024-12-24_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501010159 X-Proofpoint-GUID: 5mAZQspqRf9okQB0EeshbFEAHuf2nz4q X-Proofpoint-ORIG-GUID: 5mAZQspqRf9okQB0EeshbFEAHuf2nz4q Refactor the logic in btrfs_read_policy_show() to streamline the formatting of read policies output. Streamline the space and bracket handling around the active policy without altering the functional output. This is in preparation to add more methods. Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index b843308e2bc6..fd3c49c6c3c5 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1316,14 +1316,16 @@ static ssize_t btrfs_read_policy_show(struct kobject *kobj, int i; for (i = 0; i < BTRFS_NR_READ_POLICY; i++) { - if (policy == i) - ret += sysfs_emit_at(buf, ret, "%s[%s]", - (ret == 0 ? "" : " "), - btrfs_read_policy_name[i]); - else - ret += sysfs_emit_at(buf, ret, "%s%s", - (ret == 0 ? "" : " "), - btrfs_read_policy_name[i]); + if (ret != 0) + ret += sysfs_emit_at(buf, ret, " "); + + if (i == policy) + ret += sysfs_emit_at(buf, ret, "["); + + ret += sysfs_emit_at(buf, ret, "%s", btrfs_read_policy_name[i]); + + if (i == policy) + ret += sysfs_emit_at(buf, ret, "]"); } ret += sysfs_emit_at(buf, ret, "\n"); From patchwork Wed Jan 1 18:06:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13924247 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 19E3633EC for ; Wed, 1 Jan 2025 18:10:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755008; cv=fail; b=d8yZjremWj9QnlWy36O3pOwOwkwucHctr/yoKQuNMvwu4WxGfTjC9yBIbP/NPZG6AGKf21c1V++XnD5y4KoTLPA24FJeia8dvuuMdZs5VepDSEvu3PnMN9+gM6/sFpjLxq9W781C02RsvurNDGillyorWKoDsnymXU/coHnRyB8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755008; c=relaxed/simple; bh=GlhoRK4qeeQRrNbfP4o4PjZinEE/wFIFjCyoojDDiIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=RIVXMLpzU5AsqtW7xhleTrVKzewnSvOayQvXh3lj8xs2uyMtVX5icqOhguC9qXvDcXrYftSBjYZ2+zy/0qVMiKfjUYJlYTBXotbjbY215UUl1sFTAHKSo4eXl/WVt9tmMPuoTx0D6GmjgFFMfa46aZmB4Fsil4zNZXqBtdfrGRQ= 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=AyoR8WfU; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=XZTLsRG1; arc=fail smtp.client-ip=205.220.165.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="AyoR8WfU"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="XZTLsRG1" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 501FlLaq028112; Wed, 1 Jan 2025 18:09:51 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=8mJiYkJ5HxKBAig/15cQ2jG/ySttNkt4oQAyRlWFm9I=; b= AyoR8WfURYekzLoYP4jwirAXiZsGzRJjRjXQQVRv1X+XBniNwj35SR/+o2Dejxfr vJ3H/BaOzAAUoDHE70tRFxmLR5kifYSvJ/q1kIEQBozPfcSAvATuQD5IPLCAZQ/v iebWmWr3jfJZefOd4Js9A1AbZu1Ys2kBA709zrKK8+pnJRacsktIXr17dxMwAzkY FjZzBiVgquWcgFBBwt3uNxgeUO0TMexdrQt3ppKIzU0gooGyTu+wlUrtkPDJWyMA RM50JvvmXm7wjvuO6zVuEqGWfBFovfnnZzBkegK6pHU/KivrqVFj3jmKbhQ4Im1K aqvcMb0jTYJ3s2zxNinFMw== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t978md3r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:09:51 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 501Ej49g027818; Wed, 1 Jan 2025 18:09:49 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2048.outbound.protection.outlook.com [104.47.55.48]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43vry0ygrg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:09:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eqAjWQO0D3ovSHP0qNyVduu941HE+mwi+S1x6urOgPG+iEiQV8+U1XH/4m/tC/qlFhQKIMP843HBX4Fuzbe0g/Nqxo05NYP56tvxzI/9GGsbFKSI1AT/lke0OC5Ty8fuCFKGs1gvav1xw03SC6XGGaJ4XNF4u/Lpw6WVv3NuC7J2emMbSDlmqkZk81NrgF2ssuie4VOEVzHgplWDFHTGq1tWe10ydcMkVlJCWr3NPnk2IdeLaS8I47JH3xRFzLeiaTRVroin5/1aRg4RH9q5n8E3wgWOxdpf+Vw7BfLtiKW1dU8or19HOjT0OW/GDtt7kBk7HwbksoS4kW+FyUAQXg== 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=8mJiYkJ5HxKBAig/15cQ2jG/ySttNkt4oQAyRlWFm9I=; b=oEiuD4vztcU9zRUpfCJKC2W4Q1s5NtgHn3l/1cqxya+kV5d0LvDBLG6IUIE9unXlSj6epeaw5iLwokWDGletWbPpbX+252cYP696yCPdbiGYpCpXUnl0gUjzWE+HEuxeN/HuyEMmTgTH07AWFdDUi/SEIYMmCmHa27AGGlwJ69DF2+w2Z7kaiE/kHkgjpuUve217538R5n7uS+2xsRBlGEOzWDE0SjC+0Lvsq6LYq8n1PSxe4Qu8CQnec7oTqi7TdeH0NN8NPsUOsB6PDJtLtMz4GHWvcfS27uddWjVLozPcx53nhIygPYp6++9VrDV2NLhd4Zd6smgOYZBSpq26AA== 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=8mJiYkJ5HxKBAig/15cQ2jG/ySttNkt4oQAyRlWFm9I=; b=XZTLsRG1Q03WGxGrwDqnJblrTmrEhAtEXP7jxaFgmor3xzZlq0WVarbidzMct4M91xfDxYmD1aSRMn7FnroLfnDe09IumOLilRNWVQsVmSRe67sLVO4uG49vtxFP5RxTQOchA7VT4LXsri0E8VIWOE8sVKk3+CpnxoMhPyKihGE= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SJ0PR10MB5549.namprd10.prod.outlook.com (2603:10b6:a03:3d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Wed, 1 Jan 2025 18:09:43 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%2]) with mapi id 15.20.8293.000; Wed, 1 Jan 2025 18:09:43 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, Naohiro.Aota@wdc.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v5 03/10] btrfs: add btrfs_read_policy_to_enum helper and refactor read policy store Date: Thu, 2 Jan 2025 02:06:32 +0800 Message-ID: <3f4ce63b7690aa207fc6cd220ad7210883621986.1735748715.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA1PR01CA0179.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::22) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SJ0PR10MB5549:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d8c6321-3926-4e6f-71ac-08dd2a8f77bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: 9CUv+O0e8Hrn5qLcGXE1kd9u0jsRxY+fRoAvZTDvytYj4cjQuyP6uzxQAVDfwRtjYWUtSgUtVBphq09a/pQ0578E/WMwDsxzuU2XFBFVC3pvQlJGg8D/ROizvu6AY2iBhGm3zrE3danJncixzqR2BIY7QfXuEXPqxww3Fmvwj7SWlMd2SzjH/YbppZtVU0jxud9vw2DRC2jYz6qkT6HUKjzu01NJc1sE6YK3m0yQJXEP1YrR2cbxrKMj/ICrPISrnAMQTmdhrCXQ9ttNb8EiyozIlx3NCjtTdTv6GO3HrVvKZsnP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Dn6qRFZw/noH6ofCjQR/E X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tapEwd0o+kGcfaxUHaI2H+pBaTIHU/I9wviR2pGuDWg50o0hgxPdGcGIV9tlWLBaL2eCnHX037cViddr6XKxgr+Puh016qv26/0E06tgM6T1EHm8bfAfsJ4NrHug0hRlomLEP2HFGLWb1MIm1rGKODP0Dw4Rxx9iY07PuFH3KOFbaxhVfcCYYzrK62KcPHXZV3TAodXrDImw81vD8gr+LgpLkJEzKmBB4zHAkf5y3cf9Sk6/revd07Nih/hWGqE73PJII8M2Ew4IGjK6HyCujfLxbkREEQQ3/buN9XDoCCwDsUDJcpzUiPYMDq2336l9c6a4mH9MiQbwnl8vCas8RjgJv7kQ0t3sJv45aAoIwiFLpJADQEQoABpaeKvzKtpMqCCukip9viw4Bj4Ip0z4U/aTpM/CYBkMzep+YLtnhuo+4t2LFgeX9/JQoWr/uQOQui6ZbJW0+cOH8WTJnfyo0FKYG8eyeJPbgM5D7KHLQ0h4Qojz1jvC+UMOS38ynidSo+11NAQU/BA6yR6kySofjwBI9M1RC4s/QiYrokzHcjHX6eJ97SRiaQrnwdU3iNReuY+6hbtP2MecaXi4LF7bGPc5E06Gtaz9L+yaDlmeo8tLbJDO/UTGECy6nlUX6YJV7KGrKWyW+QWeGwZic9I33wd5W6WFxaDAINU9B7z0KWBaSjX+q+LD6yGE04d4Q9WwO3SUFHRtmf1bfmjOpsRCM7H/8cVnVwusr96r2oUiS2ir+4RXMh7GyNc/knSN2wJjOgrXO4+KzifHnk6wcT8MsJ4SimqSr602INzZImG7Z5ARGn10wjl1OgdJj5mQSdd8c8uqsAsHgvHkLGNLyr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bJxCsVIp3+8g+Cn3QY23KQDTHVxth3o+TXyU565Hu/oZfT7bRVjXoBUJz+vJ8YPqwa8Cm/CvLRA6hW3uTaKw+xQOjP5uGWruxPAZz0R+JmW4TWrUPKkIBsnqBZNHuB3oCjmK7c4H4HicywweV/OtZ5PKf/083qOl9hMdKdiQssaAfZVIOlhRLEDYTQzb0kzNICJmgmQvjbhdOv5iS3NKI8s9xGojuzJ7VkE8Cy3VJ2sHuClwTA3bh7f0zuhMdA3tuJjRibGT5kt2L+yZdnA5Q7p58GS2dDyhNpSyf0dEjXG2e84bbXV/1NtOkdYsdqucKbyfg3ok0lSbWkENAxq8THQt72MiciYQ1GjVBw/HCeRAKhS4W3Hfmw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d8c6321-3926-4e6f-71ac-08dd2a8f77bd X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jan 2025 18:09:43.7221 (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: 5AjvFYktK3DNiMnoLK+9mwifFFeNvU3pnTsZ+mi5OP649oDUI5y/jSRBIJo2tDmMYXOoj0EnCEHMVUV3agvNlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5549 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-01-01_08,2024-12-24_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501010159 X-Proofpoint-ORIG-GUID: L9XcIJNU1Wrv9X7FdrvGPKkKNtOgo2Ut X-Proofpoint-GUID: L9XcIJNU1Wrv9X7FdrvGPKkKNtOgo2Ut Introduce the `btrfs_read_policy_to_enum` helper function to simplify the conversion of a string read policy to its corresponding enum value. This reduces duplication and improves code clarity in `btrfs_read_policy_store`. The `btrfs_read_policy_store` function has been refactored to use the new helper. The parameter is copied locally to allow modification, enabling the separation of the method and its value. This prepares for the addition of more functionality in subsequent patches. Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index fd3c49c6c3c5..3b0325259c02 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1307,6 +1307,18 @@ BTRFS_ATTR(, temp_fsid, btrfs_temp_fsid_show); static const char * const btrfs_read_policy_name[] = { "pid" }; +static int btrfs_read_policy_to_enum(const char *str) +{ + char param[32] = {'\0'}; + + if (!str || strlen(str) == 0) + return 0; + + strncpy(param, str, sizeof(param) - 1); + + return sysfs_match_string(btrfs_read_policy_name, param); +} + static ssize_t btrfs_read_policy_show(struct kobject *kobj, struct kobj_attribute *a, char *buf) { @@ -1338,21 +1350,19 @@ static ssize_t btrfs_read_policy_store(struct kobject *kobj, const char *buf, size_t len) { struct btrfs_fs_devices *fs_devices = to_fs_devs(kobj); - int i; + int index; - for (i = 0; i < BTRFS_NR_READ_POLICY; i++) { - if (sysfs_streq(buf, btrfs_read_policy_name[i])) { - if (i != READ_ONCE(fs_devices->read_policy)) { - WRITE_ONCE(fs_devices->read_policy, i); - btrfs_info(fs_devices->fs_info, - "read policy set to '%s'", - btrfs_read_policy_name[i]); - } - return len; - } + index = btrfs_read_policy_to_enum(buf); + if (index < 0) + return -EINVAL; + + if (index != READ_ONCE(fs_devices->read_policy)) { + WRITE_ONCE(fs_devices->read_policy, index); + btrfs_info(fs_devices->fs_info, "read policy set to '%s'", + btrfs_read_policy_name[index]); } - return -EINVAL; + return len; } BTRFS_ATTR_RW(, read_policy, btrfs_read_policy_show, btrfs_read_policy_store); From patchwork Wed Jan 1 18:06:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13924249 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 975D91E2821 for ; Wed, 1 Jan 2025 18:10:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755012; cv=fail; b=Kz57lgm+qhoVN47lmsY5Be5ubW4fSM9AfChcHjerqVwogJ2/ituf24Q6sBB9f7XFOFhkZNTz3Qe3CdVvYexwP93+bk8RPEhwLfNMULat4t88BwDyTTpL/Oobct94TB4WwchLx9w9OALWddWYQYe6RFV8v3qlPbGBBNlwEe1psu8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755012; c=relaxed/simple; bh=CfZd6CztyGx9gXaLyG+79rQrgrflvzMspjCut+yvhK8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=EPh/ccBX2+PR9qn7CwBIZBM+Hb2c7dyisRj9b0MD1z/Q2hTX2M9AUNPoxltyrAS7R0v7sHYr8bdK23mCZ5ITAZG7/QVL3d7BKtbD5T4ZBPdXhsBfDy+QXS8RveF5TbvPk9YtQfu8IFGhL3PwJQa43YRJ4LpyylB1+lCJA78Mwhk= 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=Ripqu1M7; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=H53kvFyK; arc=fail smtp.client-ip=205.220.165.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="Ripqu1M7"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="H53kvFyK" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 501Fl8Ka013333; Wed, 1 Jan 2025 18:09:55 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=+7VsbehualOxc+Bs2p/CrkcUQNgs4owdWqmmECda9q8=; b= Ripqu1M71XBvhwXan0Qvi9IFZ/RqeYjI0vQWLOuCFDURAK/wzS6tydz7fLe6D6ms lQbSILFO5BozMVssR/dSWiqCGuMinkKGTwOHfM7f5duwftQtBG3s4u7uf2XAyIJb TUMzx37k16/lZVZ/k1Sl9ZdSky70JcBowkBJ9/+eSn2zMHUwJjCzKOjn0nmJddKW WvZp0TYxeYx47yFRmWnbg0lWsY4i1Yui8U44kWyOPdswtsrIhmgsQ/1qic3YEv0P dDORT9ZKKSK2W8X4iHXptroPkIjghFFYWkhAt7iHX/7NGmrfHJNx2LU6vnIOggDB v44fiEV/SM5t2JOaL1XqMQ== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t88a4g6r-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:09:55 +0000 (GMT) Received: from pps.filterd (iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 501D46Rx027662; Wed, 1 Jan 2025 18:09:54 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2043.outbound.protection.outlook.com [104.47.55.43]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43vry0ygsm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:09:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=E4jTJrRKui1harIAOd1y6HawCBKY5rmTA+EceFh2PRGwrDSwrDfvgxnKtw5+odBSIcJRORDsKjL2z+Dsr7KoWY+jWJ/m/4S6nkjGQY4ang6fvB1qwD9o+Rcfm5cVpZD5FGEdeW31IAFr5LWMFA0IPPQuMIX2NkCgkq/VgHgMcrEKUQ+awX2p1A7aJqV76sI6bURKcD+oVB88GW64/HJ7gcycgGCa2vFStVwqwZegogUs1XwzIBFkP55arOay//eN47nYt2mR2BOCeIhWyBqFEfSK0n4vQuFuKpgy4h1B6MGsHOAQ3UqxAwmrQZEdHcjSynhk8xwqdyh8XkW3N0ZvHA== 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=+7VsbehualOxc+Bs2p/CrkcUQNgs4owdWqmmECda9q8=; b=L5AGA0LXFrJMZWjFVbD30/VMN0KUp3KeayVJSrP3nXn5JDo6edJdNlqCDayLdgnVWnoVcVpJ1UPNfwsgpjlJA9WfWNkw2QgaPSwgKjscWW9bGqrWNX56HN5BQkXhkgt1jB4lIXc4KwiOIEktWldbUx5IKnNle4EQ1Rj0glgYoCb19CbM8nN6cbe85An3iwMK48aZtT4J9wkRFWJGVCnrWJzQyX9q8ODgbsdW3/HUDOx7Ib9pSXxVGKAyRTUytiS39cqEBFlU65qI6w5A37rLN/UH8MmeROw4Ugo2XaW5Gisc3FOrZYg63cGE7/Vg6Yk6yqYkfRTFKGFCg11eQ1EjGQ== 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=+7VsbehualOxc+Bs2p/CrkcUQNgs4owdWqmmECda9q8=; b=H53kvFyKlvA0UF9Fh5jROuenaT6pQGP8XWBeJfoda8IEckn1b69TjPcTFyDKrpnKLmKRZAHpWt/v8TidioCIzSIQ8+z5NlBoAQhy3wj0xcuCydh/CtoRqZVmwKGI3iA1m8VBeX/9a+BJ1xq/9N/IM/CLhBV8lz9h1zdhZj7/Iuo= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SJ0PR10MB5549.namprd10.prod.outlook.com (2603:10b6:a03:3d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Wed, 1 Jan 2025 18:09:47 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%2]) with mapi id 15.20.8293.000; Wed, 1 Jan 2025 18:09:47 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, Naohiro.Aota@wdc.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v5 04/10] btrfs: handle value associated with raid1 balancing parameter Date: Thu, 2 Jan 2025 02:06:33 +0800 Message-ID: <6a303a3da8116c3743fa9be605dde540d8a60f1a.1735748715.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA0P287CA0008.INDP287.PROD.OUTLOOK.COM (2603:1096:a01:d9::19) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SJ0PR10MB5549:EE_ X-MS-Office365-Filtering-Correlation-Id: 1e953f18-588f-444e-3b40-08dd2a8f7a3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: MozaHpygR0czhCMtzq4JZh+mqMGiXVQ0StcuCjfBDiJwUuGz0jxnniUJzcX1Un1FBnBiuJUiFLPuafRHYT/n6f3c8Hs4u923NW9fXWtEiEdi5QQVNRVAZkL68yQz19ny4pEUq527iEgnocUCAy8VisdhzfGRf96f3MBqsHj+2qsFyssixM2TVdLFt9ncD0xlftDVEX1/ka57IvoKZ8Uwr1WSMs1PjG3M2nAWHIbQUdXkdBGfIuacZQ3noPLxfnls2UVV9NY7b538prV1fteuawnIizeSncZ4cP+B5dPdeiqhgFmPRGYXgLcPb+Rm0NIPh1RDhcSgCfn3ipI2OohRtXLf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G:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: O1ICSg6hTsIIIx1JAggzm3npPr046CL363BdY4uhOxYu/3MJXVtC/GksAjtVXEXqDMTIr2jLH3zk1OzCozeAlE6m2VMI/fptfFBxWVotmstcOmyLXUAjSdm6xrWDpbhq7OdPPRkP+2vkcOEn0U1xjgUsd2nU1v2WkiLOfW5d9lhZTWqwNjcJznvTAM9Ihxnj6o8UWERWxwAMr8HKUTm+HAhXfs8l/hec9hzakmLq0fKftHlZm3nv4Fpr3wVKNaNEyJLG8tTEidzycIgdpG+8wdOxagOofqkuWRoVNmhQh63j7kciTBYxqA7j4q1D1bqDxYd1EfdBfzzjl/qP09D4TGWQWvni6vi7ZJFU0Ppi+KW+jJ0y4H4QPf5l9P1e7+C+1U5mGaBqm7VRF3NQN7jAtNndZY2yXTZZ/IF4pzNCElcpIbUGrAFlRc+PjBwuNhEcbBfI8cGCCYhu1vMwIC7fYcfAQh27SyVw+qc9VMKBGZi4x8oXrr1hvO/eBdVqmwkt06ptXl6pqpUHcHwBe/sMpqs421vZXZx+eVqY0N49p9AwzRA+lFNaLZfLoF2AKkfiyI13knCyncCphUfBPpCMCe9l7E42t65d9fWkbI3xGOJklkBRL0pAmwYCOODJEMQvRFO3N0AxBpmd7JgObUMm5qZ7AgbLFvN3oNz+GgFqSfGuLkfVb0wmpXqAgAHRUopMSmRFn0QdP8VbjX/STUnvPvDzwksZtZkH5M9lh4IzhwuBmZS92fcqRkrRi6x1g3+lAQrst14VjF149YlPXueshv4GvF0+fLFMTTfekxjUHqYyIIqIJ1s5T5igjnx4tHISaHZJI66/WvHgfLO/x5NbNBWeVhzzdBvqcmaZaoLK2HRrNjRbIGCXXUvycQ3LISwAWvLJMQwEJ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upT1G8woI4D4LYhVBq8mNWT4VklQsodgleB3FnVEQ+96764am+T1TKonLaNruRHZ+ZBqLstbXCkucfySABxmuX9Z9Pe8+Ehfczxvp+E63+pnyC9WX1LE+oE/jinj0elYuSBsalYcvbbPacOvlHKPxKEjUh3/essqz7Ugmx+EsdQOwkfQL8iZQByHgZZYSW7DGqMSt4euMxp8cZfHJZgMfn05jnIyMiLZTjGLPGtxfcpZnbiVonbNX2xbbXS8NthCx1d6omdVEXG9WlC51rX/QiQe3nIn7MHX/rsddzBWuMKyIUMIvcIGdKN1+k= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1e953f18-588f-444e-3b40-08dd2a8f7a3e X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jan 2025 18:09:47.8979 (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: 43rM86QX6m7hEfHWkqNMCYX0wezzpdyZ0bHcZSowKIChyTm3wTea/LBAurJfd8Kz0v5Xa89/a3lpt1eRth+4lg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5549 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-01-01_08,2024-12-24_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxscore=0 phishscore=0 spamscore=0 mlxlogscore=999 adultscore=0 suspectscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501010159 X-Proofpoint-GUID: eSj8yX07k5skmi8UHm0rxM4lJfEEz_Uy X-Proofpoint-ORIG-GUID: eSj8yX07k5skmi8UHm0rxM4lJfEEz_Uy This change enables specifying additional configuration values alongside the raid1 balancing / read policy in a single input string. Updated btrfs_read_policy_to_enum() to parse and handle a value associated with the policy in the format `policy:value`, the value part if present is converted 64-bit integer. Update btrfs_read_policy_store() to accommodate the new parameter. Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 3b0325259c02..cf6e5322621f 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1307,15 +1307,26 @@ BTRFS_ATTR(, temp_fsid, btrfs_temp_fsid_show); static const char * const btrfs_read_policy_name[] = { "pid" }; -static int btrfs_read_policy_to_enum(const char *str) +static int btrfs_read_policy_to_enum(const char *str, s64 *value) { char param[32] = {'\0'}; + char *__maybe_unused value_str; if (!str || strlen(str) == 0) return 0; strncpy(param, str, sizeof(param) - 1); +#ifdef CONFIG_BTRFS_EXPERIMENTAL + /* Separate value from input in policy:value format. */ + if ((value_str = strchr(param, ':'))) { + *value_str = '\0'; + value_str++; + if (value && kstrtou64(value_str, 10, value) != 0) + return -EINVAL; + } +#endif + return sysfs_match_string(btrfs_read_policy_name, param); } @@ -1351,8 +1362,9 @@ static ssize_t btrfs_read_policy_store(struct kobject *kobj, { struct btrfs_fs_devices *fs_devices = to_fs_devs(kobj); int index; + s64 value = -1; - index = btrfs_read_policy_to_enum(buf); + index = btrfs_read_policy_to_enum(buf, &value); if (index < 0) return -EINVAL; From patchwork Wed Jan 1 18:06:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13924248 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 EA4671E22E9 for ; Wed, 1 Jan 2025 18:10:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755010; cv=fail; b=aU2i2bRqXnAR2EmM+2qJ0HYd9C38eIPfCL/XyC/KjRZEBDOtXE+xBJJfrBNHa+kAC2eVNHQBxjUu1oNjeRMNtSxHMG1ie3hX7CRxY5+m7oV6PvVxeggGnEXfyOSN8dzljHhiXmiidzl2Gp0HzG/ff2ynk06ICJ++EZcLnBTHs6E= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755010; c=relaxed/simple; bh=sgx9FCTgYUCNiS2mxBqetvI7WQrlGaYR6ddwxzWYR1Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=E6BvfNg0LAWpKgPU3srD9JuTPYIu34UQL5X1b7SDYVL5b7KIAWHuwiLY2e6t8f8eG0KS/PNA7JKUPl5/i6OvQ84XE18eq+7Hb/zQMh5hvEYvFVVMY6OXO/Wz2B7civh7G/6+JlysJJF5qtuloRd8wl33p+/08g+0iiNH9J6DmfM= 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=YWPeqdDF; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=kZDkANH3; arc=fail smtp.client-ip=205.220.165.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="YWPeqdDF"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="kZDkANH3" Received: from pps.filterd (m0333521.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 501Fl6US013168; Wed, 1 Jan 2025 18:09:58 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=mtH+kHj25iJURDTetmMUln2QzgW+K7iGiglDsQ0ZVpQ=; b= YWPeqdDFpO+bVWxkktN4XhKexEjVLTmxHDGaIzFrF9Nb8mXTBCRLh2D4cazSyX4g 4y/7zMkXwxZFPV+/8+nbqe5tX393lchlQ6rqHLKhDpf92p6B7urcrQzhKqH2qOO/ awmDUoEbYExZTNtdcIguuqnH/lUg0PQF0nl2xQ9fSpnsvewtQP+jlw7zU209QQRG hmi6y2V7l+5e0Lk7O41YfXs6ZE4Rbvk8GX66oUgld2guDMmd9xxJjVeDQXPFBUh3 +XDKRx105+XYWtYH0CsyQea4psXuWZG9DF554/vVzLU80SzZr0Px/smhkmR8ecy6 WD/BGneBAUHQ5Lsu63JAKw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t88a4g6s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:09:58 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 501EGYf6009070; Wed, 1 Jan 2025 18:09:57 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2041.outbound.protection.outlook.com [104.47.55.41]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s861h1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:09:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nxJfpZj586lUGA2ifpKTm3VjcrYx4jTeWIwRDc3i9VfEmwksuaot0aBy/VJ+14VaxZqSQSdfhm2LCFl6kxjbXksF8jhnDsYIldVcJPY7ivkBT28GOGv5xOf2jDK2NMfBPsLI7bLgEuRmamPjmBFmGtTx10sNx/2GCKfYp1AZPgoWuVtMx4LjMM4FODkukF04MzA91nUVjjBLNPD4OCyIzcPb3yTSxXJdCTYo1pxciA1PU2j0nLrYniuy+0Dux+LiPrxbhtcCfoPJrK1ynuHCE7aocBk7AdDznluTZZkmmhx2PEEx1arMN+IKefrcgPllu+dJ8C+FmtcIdyU43EcqCA== 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=mtH+kHj25iJURDTetmMUln2QzgW+K7iGiglDsQ0ZVpQ=; b=qzwvKn9H9+RsD6zOEvRxIoMi+ZV9jTsfjA9nRncWuHolf0EigW/HkBM0CKAYpVCtnJTSNh7BdI7+psIViZhWZqlL9CbxcsY8SSt2ZT2SgqTgYSv8f8L5p4tgQylf0aRHV6qkLWciqNXh8qmuENm18fpJ+Qwh+T9WFtVgKLkMu5+xFpM582FLqeYODjv1FLalSzl2xE/KPomcICBWBejq1DT6QJVV0wmUdruFHeCcFo1myyH7u/Ryds2vrT3V90vb0iNBcyuIJhcEIznqr/QETj0834GKpt+0ugr7aZFs0L37tC3Iz7iI6DZyHHbuJb7hdtYKI2yXhucQlB2DYDxShw== 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=mtH+kHj25iJURDTetmMUln2QzgW+K7iGiglDsQ0ZVpQ=; b=kZDkANH36okcNT995ibe1nT66s/heemM3A/kpg5gVgzzhhRPIjIC3aqN7jxBZGNVhigYY7lm1HB/RUASZSDV3UHE3obQAEOEd80BvyyF7b1VDc7Zqlb04MIEPuAi5pwfUdZz026jwSTwIIJYL4SlDDJ9wz3TpkXRq4m9SXQLEKM= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SJ0PR10MB5549.namprd10.prod.outlook.com (2603:10b6:a03:3d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Wed, 1 Jan 2025 18:09:52 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%2]) with mapi id 15.20.8293.000; Wed, 1 Jan 2025 18:09:52 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, Naohiro.Aota@wdc.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v5 05/10] btrfs: add read count tracking for filesystem stats Date: Thu, 2 Jan 2025 02:06:34 +0800 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA0PR01CA0052.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:ac::13) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SJ0PR10MB5549:EE_ X-MS-Office365-Filtering-Correlation-Id: b6a1ebcd-d3bb-41f6-375d-08dd2a8f7cb7 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: atimC+KnCJ25oBxJEjjH+L547zP0I/kSZc0lOhS8xAyeVDBG45/DnKa5fouflIvepCXWuTYyidU/Q7RGDzjLYVqJ46kPzmdDW+a0g416o494/q/WHFwpQbw/tDtFd75m1KOAxyeMXNAIFucKvTV0uue9FBWv6qGJaLrEKRkZ8ww3NjzVHn6yANgzomNHnTnGh00fyIxBWKseyO6h3HYCBOY5e2oBBCCzaXYj3MLhmmiTEzJHGpz+mtrLPA9A+7+6b6KBMXXpODUNoVTJeIBEZH/Kd2v9+3t+0VS1wEJne/OE0jFT8jQqE26TwuXbWsRFp3veT1gs6sME6dwWHx+J24JYgYqCf+uTzv2uHVhPMpvELHWJEzl6p0ZNfdWA+tdKF2QGdfTFuiWJ6ZcvDleFAxwwT5/K1+MSk4Fo4FUwZFxuG0iB0CLCcJBiyVLMKBxlTalrsXmK98Lm04e6Ipjq1eo0Houu+lAY4liruPf/7e50tnqqVpfD0uMdnwwLUMZr6G/L9lnJgs9ZISyCRoNqRYUsNObfE/bDe04EjVJ1+oY08HsSUMV2bkGo7Ii42SSiNhM2p70JAHRVUjEMgbNVCMtEGkmQWbsqY7sYPBBB2GXd/vNQt5JWcCOJBeZCq3QhjZIamFPnQHrudeLTMiyiv9pCPbDTaDdW0RwFCnO9Wd7EWSOituQK2K0ZaKuLwZqX0cacg5EqtaTN3oT/t01EgBsOYfA5oZf01lF9ibGi01FmeUUx3KhTYCcL2D2MVL3Sh/WdCUPal91wYt7vNtOuIoKQS9t+3SgmhCnHW1xGhnuJq9hlZocID3rRZToy2/Mcj9RKdWBCEHmCEFXW5MWuKF+mYGSfrtasAZuPSgiDAxcaG+ZS1MWhZha0t8FM9I942db/JTRXLo+OkLqt9zZvZFrsJLsM7tMsv6C0aCF4ayQk7DWZ6zd+j0kdlyI1CeGeSh7z5My6JISDaUiMrY45z4EIasJ1A2j9kzJykZymWPmRkPmM+vkCk3dKGIxZs5KW2MAWtAC66SpaVV2jDOx5X+DLLKawfROhLC8tWfpzakBw1w0VINUCyNMOnswMR/gJjgHswoiYC6oa7Wx6mBqWBiZoxt+CM/l6qVtkxBpxerieKBnzSLqP92RG3eX2y9jTdYCuquHJPoFTUCfxOvEQJyWsSD5Fht14PcDAxeffYbabjdkZBLv2RIxVbDDWofIRjZVcqSacgOXxKd1hlA4TTQn/2IoLQSQCmjft175N57hCJarK6YviwOFRsRO4h/LeFi+QOKyLvwKnubt0orD1Tox/so6+ln9E4jmDdo+TfYR94xX6m525tBV2IYGMHJXco9wlQj+PuA8l++u1Veop1giorA9hFQDT1WbaFRp35MR6dwze6NW1bUHdB/lPudFl X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ng4I7qrn3/MSllA7Qt0TwdQcpFcClAAp+cCKDf6evc/gqXZQgAe3wByvzHy/V0dVeP/5ApZ1GauRYW60Sz2xr/VmWk9S8g+PYLkkUYzmWRygP/vbmbjlLuF+dcHFqYer9+g9buc7rqPhqxqDtHE6YteKogdowJ673JpceL2baiDj1bqFDn8N+PRVGI3WLAJqA6eulpsu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6bGGYHRAhfy8iVJ2Rvno9qqqJQV2vuG+IRfq+xD55bvlz75EIWs0IwU6OrywIukwif0gkpsOpeyMhvefDjyKcGXCLk9BMPvRA8AYUR04U9oehb0FySqOBb7YSJIhsQYOJNVXyfZMs1WTOrEWdGCvUnzXpsdJyQuglh5cWp/ShnqlPQuhDZxtfy0T5t3nscoC5VAsnVppmd5omiGfnV18BmLs0RWQ+KxCSufMawEyS6JKOjHtdFl4/Wc4Cke2CfDmnHlJzAWaiMtjRRmzeA1LrAbthgC91CLtvsZ04oE+VfLONXehEBoCIA+OWDe1hjRnsX2/rsmL2nSmXn X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: rqEai6QLPsIuNnQWCGMwapNR0HGcvvfJ07kLAxD7uLp3A4LuJyT3N75DnEh5mZcN5VW9HPMZhol2aHM++iuegW8bJIt0KAdKrAYsnLrqjfoQpYIVVb8SvOKx+EeEjDUgY95eM8zuAwFaLj7RCtY0r7QPycerWgrBKR02n6p9mk8n7QUXDIFjVjfHKsSgVnT6dm2bA3MHWx9lItqfB6OdydPXEl+1oul0SlOJFoiCs0qBJ/xzUPIU7Iaudz0XtPHogcjr2jcmFEuFvFEjj8p15WSj///qoW8lizyEl/Boewl9lScoYsvEKu7WS81RhmmKiskO/f4TnTr2o+htWK0sk+INi9BPtGmkRXBSoS9U3OC+PfuhOoePDD5sRUNuhCT3tkp2BjygIr1Ep4uqoLjcADS2XpVG2+s5W6gdKRSRjvhxpvafTvgir3tGLXyWzDShuIpJrkYkTTmYxCSZnEdmosp4TVyIzup65oXE5j+yXh86DUYe0YoZ2pSBChVvc3G39yMNZOlD0xUsHzAkn4iuHH1cdmh6MWmDu9uvOiDqlRQYpU4d/98hd1DepmYBwRlz9tl8/+D0rD8PeTanKSQfn24ypYqYMNC1Xx+xtm9oE7I= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6a1ebcd-d3bb-41f6-375d-08dd2a8f7cb7 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jan 2025 18:09:52.0632 (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: UU2/JnpNfKjaWl98veRMNgdCN/4ROBV9xLVVyGCh21PZSGwi8cQkuRex7xRd+F/JM0vz6K2eg+iGN2WqGwXffg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5549 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-01-01_08,2024-12-24_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501010159 X-Proofpoint-GUID: Suo5mVogahIxJ9okqg5aqRPvGx6LpcCa X-Proofpoint-ORIG-GUID: Suo5mVogahIxJ9okqg5aqRPvGx6LpcCa Add fs_devices::read_cnt_blocks to track read blocks, initialize it in open_fs_devices() and clean it up in close_fs_devices(). btrfs_submit_dev_bio() increments it for reads when stats tracking is enabled. Stats tracking is disabled by default and is enabled through fs_devices::fs_stats when required. The code is not under the EXPERIMENTAL define, as stats can be expanded to include write counts and other performance counters, with the user interface independent of its internal use. This is an in-memory-only feature, different to the dev error stats. Signed-off-by: Anand Jain --- fs/btrfs/bio.c | 8 ++++++++ fs/btrfs/disk-io.c | 3 +++ fs/btrfs/volumes.c | 8 +++++++- fs/btrfs/volumes.h | 7 ++++++- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index 1f216d07eff6..faefb18010fc 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -450,6 +450,14 @@ static void btrfs_submit_dev_bio(struct btrfs_device *dev, struct bio *bio) (unsigned long)dev->bdev->bd_dev, btrfs_dev_name(dev), dev->devid, bio->bi_iter.bi_size); + /* + * Track reads if tracking is enabled; ignore I/O operations before + * fully initialized. + */ + if (dev->fs_devices->fs_stats && bio_op(bio) == REQ_OP_READ && dev->fs_info) + percpu_counter_add(&dev->fs_devices->read_cnt_blocks, + bio->bi_iter.bi_size >> dev->fs_info->sectorsize_bits); + if (bio->bi_opf & REQ_BTRFS_CGROUP_PUNT) blkcg_punt_bio_submit(bio); else diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index ab45b02df957..79b859790e8c 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -3481,6 +3481,9 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device goto fail_sysfs; } + /* Disable filesystem stats tracking unless required by a feature. */ + fs_devices->fs_stats = false; + ret = btrfs_read_block_groups(fs_info); if (ret) { btrfs_err(fs_info, "failed to read block groups: %d", ret); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index fe5ceea2ba0b..1fa40bf6f708 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1254,6 +1254,7 @@ static void close_fs_devices(struct btrfs_fs_devices *fs_devices) list_for_each_entry_safe(device, tmp, &fs_devices->devices, dev_list) btrfs_close_one_device(device); + percpu_counter_destroy(&fs_devices->read_cnt_blocks); WARN_ON(fs_devices->open_devices); WARN_ON(fs_devices->rw_devices); fs_devices->opened = 0; @@ -1300,6 +1301,11 @@ static int open_fs_devices(struct btrfs_fs_devices *fs_devices, struct btrfs_device *tmp_device; int ret = 0; + /* Initialize the in-memory record of filesystem read count */ + ret = percpu_counter_init(&fs_devices->read_cnt_blocks, 0, GFP_KERNEL); + if (ret) + return ret; + list_for_each_entry_safe(device, tmp_device, &fs_devices->devices, dev_list) { int ret2; @@ -7669,7 +7675,7 @@ int btrfs_init_dev_stats(struct btrfs_fs_info *fs_info) list_for_each_entry(device, &fs_devices->devices, dev_list) { ret = btrfs_device_init_dev_stats(device, path); if (ret) - goto out; + return ret; } list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list) { list_for_each_entry(device, &seed_devs->devices, dev_list) { diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 3a416b1bc24c..45d0eb3429c6 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -185,7 +185,7 @@ struct btrfs_device { * enum btrfs_dev_stat_values in ioctl.h */ int dev_stats_valid; - /* Counter to record the change of device stats */ + /* Counter to record of the change of device stats */ atomic_t dev_stats_ccnt; atomic_t dev_stat_values[BTRFS_DEV_STAT_VALUES_MAX]; @@ -417,6 +417,8 @@ struct btrfs_fs_devices { bool seeding; /* The mount needs to use a randomly generated fsid. */ bool temp_fsid; + /* Enable/disable the filesystem stats tracking */ + bool fs_stats; struct btrfs_fs_info *fs_info; /* sysfs kobjects */ @@ -427,6 +429,9 @@ struct btrfs_fs_devices { enum btrfs_chunk_allocation_policy chunk_alloc_policy; + /* Tracks the number of blocks (sectors) read from the filesystem. */ + struct percpu_counter read_cnt_blocks; + /* Policy used to read the mirrored stripes. */ enum btrfs_read_policy read_policy; From patchwork Wed Jan 1 18:06:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13924250 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 0C4591E32C5 for ; Wed, 1 Jan 2025 18:10:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755014; cv=fail; b=f12Q6EZWX/VPtlcESxKdLiyf4C8xlAQkssKOAP81ogxaf18OXUgKAv5OwabpN3X6P6jWOzu832I2o4rIJgv2Nvapc07ghh6buckgI9yYtMPsDamQr4nfrFh3VkvzpqsiMsC3iojkMYmQruvfn5jnkAYXBpKuPF9jdHbxkK5ipzs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755014; c=relaxed/simple; bh=17UvpopZT7rH2KUF26JQpZrSn5fA/ddJoI/DMBrITyY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=K0cONKfYqqnBtmZMpoJkqfdBonmuv3uvSTv0N+S7ebPkENw3X7kjZq3GTAgPf3ArHjxTRkoq5A1oF4t9zIjoKZH6MCt/SD49mmqy3x41KCokRco0nMDKJbvrVQn0Wl4ZUtoGCNHPkr0A1ef8PCnu1KQ5G4GfilOTInoCYoL0q8s= 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=VwJj6n1W; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=isu7tMH1; arc=fail smtp.client-ip=205.220.165.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="VwJj6n1W"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="isu7tMH1" Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 501FlCfR027682; Wed, 1 Jan 2025 18:10:03 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=X/Zi4ZyndMHWVrsduqOwVKdneE9gkhj02tOtyRSR+iU=; b= VwJj6n1WDqj+Itxf6s6k1YkxhO8hT47WmjgEArBbe+1/4DwWkLwHdw1xLU0m6016 AbuLwUzA8nXv2xg4Gz5xJpEQ9Uj+e9G8ley6iXfjb03uAyHfs9KUa3uvocalXFok /Nnu2OHplfD/xHajXdsD6ivkPVuG04gwWxvd6DQE86r/xsrQtMGhlVzefG1WRXjN TfHulyLDXMuOYCIyXl58+2ai0llh7pxRsp4OyV+cHCMrYRNwIg3WyK9Qf7a2/nCK 9tGKidSl29I0q2L5o1ROomkeOfbB+Wc7J+ZuMsPreEseFnFWp69nJoLZwIXP7RrC WgTE7R4kR3hlz1GWQ5p/Cg== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t978md41-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:10:03 +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 501Ca4Lt008789; Wed, 1 Jan 2025 18:10:02 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2040.outbound.protection.outlook.com [104.47.55.40]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s7wvb1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:10:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=xBNnFAvOzyEUnTAULzn0wchNWNdIw9ohZyIw0cqPegRPjf/qUkJsvBP9NX+04jc9sl4/qI8eOX9gwGtzg2kvOKE5kuxpREyg4UgbIo05Pv3QadNQnhNV3ozvemmGJ46wlxdnoOkD371pw3fH2ZCqjTlSlqhhex+GCtCfK62t44Yj2Oq0DmRk+IYbkpX4xix1mJjdPVytcnroW435cCIOERDiKnKujiz4M1/j64+9KlxPCvmcxEJWKjNcSsV11VGGqbmmd3m75x1OE4runbMcKbZT6dxEjeefzPAvQjbOxbuoy+e7uY+sa6Rnr3xYyXOFBjsOaHnJ0/GWUmVaqmK52w== 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=X/Zi4ZyndMHWVrsduqOwVKdneE9gkhj02tOtyRSR+iU=; b=B0o50+Ht82xwCPGoMfbfVLrktG/huAqrZWy1z/W3gP6+lCmV9ZgM7tQzzp5hXPdPvquqf0SPliJ2Zj6LvVl+wB+D/UTUjtkfLDj1IZIjKeUQp90cZxxO/+ApKMnPPByoj3iud6Okm703lpfIhl8o7iJyCOLQp7IAn4q8M+irG0WhFudLmury0iGvG8Yw2eYTN9VAvOYAswVlKLybbPOMzDo5bNBmOOw5C5PSLY6CJAyTM0GOEY2GFtctQXz/l0mfKOgb8amrd4DmxNxE5laEXMfdM9YA/4geMbjrCRssHrSUR1qIaI3ErW2qo6qClocGkV+uYLr31nVvf30NRIL8Eg== 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=X/Zi4ZyndMHWVrsduqOwVKdneE9gkhj02tOtyRSR+iU=; b=isu7tMH1usfRMgxb73fzJ5l4anl0floFWB+HirmmVjyArZGdpUsaOGMz8DYuvsTRBhSnEbJas9RUkL0wRK+AoHaWuUZiWYaQ2odmeoAia+hEkjvtADivORNpvGjzSR2V4Izqn/j1xoPiJ0eWbFLt2XAsF1vMOiSPYj+Uu6CCwh4= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SJ0PR10MB5549.namprd10.prod.outlook.com (2603:10b6:a03:3d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Wed, 1 Jan 2025 18:09:56 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%2]) with mapi id 15.20.8293.000; Wed, 1 Jan 2025 18:09:56 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, Naohiro.Aota@wdc.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v5 06/10] btrfs: introduce RAID1 round-robin read balancing Date: Thu, 2 Jan 2025 02:06:35 +0800 Message-ID: <6f78674a41cfacc84a12f41d6ce8ec689a5c3382.1735748715.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA1P287CA0021.INDP287.PROD.OUTLOOK.COM (2603:1096:a00:35::29) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SJ0PR10MB5549:EE_ X-MS-Office365-Filtering-Correlation-Id: 1762fb35-afee-4b80-63c7-08dd2a8f7f99 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: AptX/N6x3jyQlAWnDkaG3K29IbAaOxL49iNbHlYjDSML1YkAf3SzMMpJ19LIiI2QIN/E4kUoOHeGQgOwFItNkZ+hiON8mTj90TKKI/ZsC8nS1pOrFOhBbwykILGIUIyCqpQBrEtQjzH2fLq4tua6eMPSrRj56O974jUfir5wOgL+bnI5ak3bHmv9gDqGqfjU4CwRN0osONQ/WgyAMvTN3TrrffUOTZ9yNt1ARkhE3CLQmIqAuzv1s6qgPS4fLlsREcgrvQZY79mg8zcmIKALpiu3geEg8nXeY6ZBrFJRghHGjU1CVRoerKx7TiPwWwboEv5BAi/nPsmDik0eq1T2/lkbql2V6G3c3oW1Kga3aPzOjiLIFlq504wXWqXMzs+4Nq2LDOR4XjeiIc8YEUYQdl5COMX5DIqZTceYit6DDQqkML0kYwDEhsmCLfFC5VUx179SAiM8vD6FsKysAjX2pXnguV/heE5PVvd8s8SvRnO/Nxn2e4aGC1lx3Bm/sbFYDKlMvxMUwx4y93KFBH/vJPHsgJn/9WdyXjN90z0GtIU17t4iCZTamJqacrWh7cw/gMMb+VWBaaUAfQpJQvgNCROwg/nu7YkaZEggRztlfajhqivXj4JtqKxlhvIODlNcgyVRqOdhDYCr81RG4CmKR6gxVoiHTowMNGSpyb1Ry9J1XFRslC8/AhL6nfXloFS9IiS+91nax6p3QIpcYWhr9BgJKVvpsEoYhQDMBsDJJAHMUZE48OEEFJLT2FtBqtLgICWIwdeZJ3i+2sqpsxiGYRahg1GLEK36morsMlj3btkU49H0+LcBjgqIHPyE4nRE46nu96bBHx+K87WHvSgaLDREsAEfABp0Y7b9mw2Kxi09Ov/BQbMnH9q3YQRpLW3kTKoVKTAdak9H05Tz0hKzZZRyp4HjotaWr0htMOZNnQt1jBwy6tZ37YgIFrzV8nL6cRtRTcKc/HcjKo8bH4FkN0y7zxPDiwZPHeYipWotVZ9jjNUqDakn5Pgl0u6IRIQYicExR3/6MkRaRWnTG//9DjJmXKbOzAnX1zECpNzWi923vKUvf6yc9NrcapFtB1AxGsTocYUWRJTvZIYGaoFDJ9oX0g1W3YQMnGHGMOOL4536LZOKU65SxVqee/WRVPCBkf53vNCqAeUrtRosGLvm1oCRMyZl6W/dgD0k5EZMGRiAVmV/mzldQaeHKrA5nZSV9whjXztTg8F9eFkzsnliEzMwZU7z41oQf15pvlZXcFzg1GnsQbcOdlbBLGnBl6xnx3Cvzpe7BzbGWVbqwXVtWgfciLxy8cg2iAM9UZD7Lvh00jKW3THDUt4pp0l+6R+oMfeX0OanMWGyMWWr4Y1xlhqbMCHObZEcS3jv0EKZNag1NLeKp7MiCEx5TxQ/HJnY X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ZgnqEGEN4skqmlzm7o5KuRm+9FzAfNU1SEOpZy9sSqU3wYu2mUkP6Ijsg9otjBJcFO/ogTmEBdyXfRta6xxeNjM+RixvRj5B0IHCggOGxgjbCnI5Yy4jOtPbzqld0hG+lLnzuSrgdq6qUYxXF1UQ6fujs5MSiXnvo8io8LXBT8flrxCCIb5vIHq2f/Cq91zWAK7qcNWKqL3GU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YbgcJ0cYTrHlrpISi2U+mQ4L460eKWes0Uxf+G0d0orGWh762RCA7E6NK0KvZlsQINQ6k4u+Hhty4Be5fpQw6iLTKWmbFO7hb9xp5M6kHxD8GQ2C0D+fc99yu1nD1yuScUsOGA/EVzTp45vYYlUoX3sYtNtJ/e7SvSp1WlMesm9IUvqsg+MqTBlFcNoloXz1eVNq60j/fJNDKKz8YBKaNoyr/yVku2Yrqz31ye4PcHwlSnPY1147X1Ou/8YpkBHo+zc9ER+9btwsMBmzF4XxeVnC7/k7qcnqg/zde8ZMXzmvQD2FFaCtiOzG0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ieuUO5R+H1Ypd/chnh6GkVUBntE4zo8Y5QjGbRazg/BJtKAQvkQRE7aNzmiKOLcl8wtVH5wd3Cj7dJADA6dgXMOhTAl1AAgXDprdHP/MsK4/RzDJLiPCi0JDVJ8n+2QjkGzuH0OnaLFXJM3J6UsNScVcZO3BEPceXcGLqz0m8cTPbwQfo6vB+0aGeSVkOm0ifrcWWyrtnUsFvZdPnR/3P8RD6IEM3HK3WzSQgwGXn8IQz2UDP/8fqDLQD1LYFhnXwrYsbzMhEqWvCSpciPhiuwx6AqvpSMSL/u3npJh0HkMQ3PI/WvjWijqYY6yLFPKtEy2xFuc/D6EpRclnpFTDVQyjEgovy87IQra1ZMmTD39At+QgoegrhrhiKW+Bdxsh5jLSyDYZ6H7dgzGsknEbcxCFJhhrJggWB1V+3x3lHORz5JOeKwIMGO/BmpkZhMiCc3QvOAVv9qSuWkfRYdHj5j3R5lSYxsISBKXtiX8Ubc1qMb6HJfbUhlbVL69ladzn5o35VqdgSA3L7di+g0PphjxYiL5wEYh4X3/qDC1Ez5GFPBYe4LogfIDMcekzux84q19BpdnIW5nIyjWb5W3nLGGphg7yGVO6Z1ldHvwRGN4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1762fb35-afee-4b80-63c7-08dd2a8f7f99 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jan 2025 18:09:56.9005 (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: ntFCCwZnmPG6eQJLtAAvZ0x/ZLIH9SzDAq+ZkBn9uv61GUC1RZ875kTwQ6fF+tJLR9FkSrUVLvepbArQuO9GpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5549 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-01-01_08,2024-12-24_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501010159 X-Proofpoint-ORIG-GUID: W5E7pDKrpBAJO0_9RpTB3VY-txvob2JP X-Proofpoint-GUID: W5E7pDKrpBAJO0_9RpTB3VY-txvob2JP This feature balances I/O across the striped devices when reading from RAID1 blocks. echo round-robin[:min_contiguous_read] > /sys/fs/btrfs//read_policy The min_contiguous_read parameter defines the minimum read size before switching to the next mirrored device. This setting is optional, with a default value of 192KiB. Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 49 ++++++++++++++++++++++++++++++- fs/btrfs/volumes.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++ fs/btrfs/volumes.h | 10 +++++++ 3 files changed, 130 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index cf6e5322621f..70f89d1adfbc 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1305,7 +1305,12 @@ static ssize_t btrfs_temp_fsid_show(struct kobject *kobj, } BTRFS_ATTR(, temp_fsid, btrfs_temp_fsid_show); -static const char * const btrfs_read_policy_name[] = { "pid" }; +static const char *btrfs_read_policy_name[] = { + "pid", +#ifdef CONFIG_BTRFS_EXPERIMENTAL + "round-robin", +#endif +}; static int btrfs_read_policy_to_enum(const char *str, s64 *value) { @@ -1347,6 +1352,12 @@ static ssize_t btrfs_read_policy_show(struct kobject *kobj, ret += sysfs_emit_at(buf, ret, "%s", btrfs_read_policy_name[i]); +#ifdef CONFIG_BTRFS_EXPERIMENTAL + if (i == BTRFS_READ_POLICY_RR) + ret += sysfs_emit_at(buf, ret, ":%d", + READ_ONCE(fs_devices->rr_min_contiguous_read)); +#endif + if (i == policy) ret += sysfs_emit_at(buf, ret, "]"); } @@ -1368,6 +1379,42 @@ static ssize_t btrfs_read_policy_store(struct kobject *kobj, if (index < 0) return -EINVAL; +#ifdef CONFIG_BTRFS_EXPERIMENTAL + /* If moving out of RR then disable fs_stats */ + if (fs_devices->read_policy == BTRFS_READ_POLICY_RR && + index != BTRFS_READ_POLICY_RR) + fs_devices->fs_stats = false; + + if (index == BTRFS_READ_POLICY_RR) { + if (value != -1) { + u32 sectorsize = fs_devices->fs_info->sectorsize; + + if (!IS_ALIGNED(value, sectorsize)) { + u64 temp_value = round_up(value, sectorsize); + + btrfs_warn(fs_devices->fs_info, +"read_policy: min contiguous read %lld should be multiples of the sectorsize %u, rounded to %llu", + value, sectorsize, temp_value); + value = temp_value; + } + } else { + value = BTRFS_DEFAULT_RR_MIN_CONTIGUOUS_READ; + } + + if (index != READ_ONCE(fs_devices->read_policy) || + value != READ_ONCE(fs_devices->rr_min_contiguous_read)) { + WRITE_ONCE(fs_devices->read_policy, index); + WRITE_ONCE(fs_devices->rr_min_contiguous_read, value); + + btrfs_info(fs_devices->fs_info, "read policy set to '%s:%lld'", + btrfs_read_policy_name[index], value); + } + + fs_devices->fs_stats = true; + + return len; + } +#endif if (index != READ_ONCE(fs_devices->read_policy)) { WRITE_ONCE(fs_devices->read_policy, index); btrfs_info(fs_devices->fs_info, "read policy set to '%s'", diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 1fa40bf6f708..ab2e970dd6bf 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1334,6 +1334,9 @@ static int open_fs_devices(struct btrfs_fs_devices *fs_devices, fs_devices->total_rw_bytes = 0; fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_REGULAR; fs_devices->read_policy = BTRFS_READ_POLICY_PID; +#ifdef CONFIG_BTRFS_EXPERIMENTAL + fs_devices->rr_min_contiguous_read = BTRFS_DEFAULT_RR_MIN_CONTIGUOUS_READ; +#endif return 0; } @@ -5965,6 +5968,70 @@ unsigned long btrfs_full_stripe_len(struct btrfs_fs_info *fs_info, return len; } +#ifdef CONFIG_BTRFS_EXPERIMENTAL +struct stripe_mirror { + u64 devid; + int num; +}; + +static int btrfs_cmp_devid(const void *a, const void *b) +{ + const struct stripe_mirror *s1 = (struct stripe_mirror *)a; + const struct stripe_mirror *s2 = (struct stripe_mirror *)b; + + if (s1->devid < s2->devid) + return -1; + if (s1->devid > s2->devid) + return 1; + return 0; +} + +/* + * btrfs_read_rr. + * + * Select a stripe for reading using a round-robin algorithm: + * + * 1. Compute the read cycle as the total sectors read divided by the minimum + * sectors per device. + * 2. Determine the stripe number for the current read by taking the modulus + * of the read cycle with the total number of stripes: + * + * stripe index = (total sectors / min sectors per dev) % num stripes + * + * The calculated stripe index is then used to select the corresponding device + * from the list of devices, which is ordered by devid. + */ +static int btrfs_read_rr(struct btrfs_chunk_map *map, int first, int num_stripe) +{ + struct stripe_mirror stripes[BTRFS_RAID1_MAX_MIRRORS] = {0}; + struct btrfs_device *device = map->stripes[first].dev; + struct btrfs_fs_devices *fs_devices = device->fs_devices; + int read_cycle; + int index; + int ret_stripe; + int total_reads; + int min_reads_per_dev; + + total_reads = percpu_counter_sum(&fs_devices->read_cnt_blocks); + min_reads_per_dev = READ_ONCE(fs_devices->rr_min_contiguous_read) >> + fs_devices->fs_info->sectorsize_bits; + + index = 0; + for (int i = first; i < first + num_stripe; i++) { + stripes[index].devid = map->stripes[i].dev->devid; + stripes[index].num = i; + index++; + } + sort(stripes, num_stripe, sizeof(struct stripe_mirror), + btrfs_cmp_devid, NULL); + + read_cycle = total_reads / min_reads_per_dev; + ret_stripe = stripes[read_cycle % num_stripe].num; + + return ret_stripe; +} +#endif + static int find_live_mirror(struct btrfs_fs_info *fs_info, struct btrfs_chunk_map *map, int first, int dev_replace_is_ongoing) @@ -5994,6 +6061,11 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info, case BTRFS_READ_POLICY_PID: preferred_mirror = first + (current->pid % num_stripes); break; +#ifdef CONFIG_BTRFS_EXPERIMENTAL + case BTRFS_READ_POLICY_RR: + preferred_mirror = btrfs_read_rr(map, first, num_stripes); + break; +#endif } if (dev_replace_is_ongoing && diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 45d0eb3429c6..5728b8717317 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -296,6 +296,9 @@ enum btrfs_chunk_allocation_policy { BTRFS_CHUNK_ALLOC_ZONED, }; +/* SZ_192K = 192 * 1024 = 196608 */ +#define BTRFS_DEFAULT_RR_MIN_CONTIGUOUS_READ (196608) +#define BTRFS_RAID1_MAX_MIRRORS (4) /* * Read policies for mirrored block group profiles, read picks the stripe based * on these policies. @@ -303,6 +306,10 @@ enum btrfs_chunk_allocation_policy { enum btrfs_read_policy { /* Use process PID to choose the stripe */ BTRFS_READ_POLICY_PID, +#ifdef CONFIG_BTRFS_EXPERIMENTAL + /* Balancing raid1 reads across all striped devices (round-robin) */ + BTRFS_READ_POLICY_RR, +#endif BTRFS_NR_READ_POLICY, }; @@ -436,6 +443,9 @@ struct btrfs_fs_devices { enum btrfs_read_policy read_policy; #ifdef CONFIG_BTRFS_EXPERIMENTAL + /* Min contiguous reads before switching to next device. */ + int rr_min_contiguous_read; + /* Checksum mode - offload it or do it synchronously. */ enum btrfs_offload_csum_mode offload_csum_mode; #endif From patchwork Wed Jan 1 18:06:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13924251 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 8EFC333EC for ; Wed, 1 Jan 2025 18:10:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755022; cv=fail; b=nCeUN7k+AILd/+YccvjwkduLrWI6mhewVSbZzbrVn1UirBBW9iapQRZwZaX4nHjjuO5kbmDhHxkJKbnjiCQQLf7L0XNe/sZGZe3KrDmkyRfGiApO12toTBXI2018VYyLO/7vyUnDzVzEzO8q3U5VUCw/o4xssFo0X2gqLjou2rU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755022; c=relaxed/simple; bh=YgNrPCtYZl3L7nsi7ImrjN7UogCKrJj7MJ7wQLbfNQs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=iAulZztCWMFQ/VLCYcj7oMnftHHMdJhNql1txScNuKneH9XfH43iyrCRDDbkr+5SC3jGSNFssNKr5aGC0jIph1t7rkfvrw5BjaVejLmMmnicou83c0AZT013z7EvmEtldzrYqmTsH8fZEPTBhJCe1X7oW9VF0yiROxbZL1/q/lM= 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=m5tG+FPH; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=F0pjC48P; arc=fail smtp.client-ip=205.220.165.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="m5tG+FPH"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="F0pjC48P" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 501Fl6Jq025760; Wed, 1 Jan 2025 18:10:10 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=QToNs/4UR0QdsnKtbIGEhbf3j6vzpiJgGKQeN14RD5k=; b= m5tG+FPHJ9VrU9yqoHBhCaNPed311cj3hqd0Ty/X4vw214ur9eOc11W2wjLC40fG 6jXmYHKE3xMr25ni4SoSFDzKgLxkBqpMuWN1+QgeQIfupSht1OTh6KxRiatf+nc0 5BSzxZJObBo4w7xreh02KnNFOd4m9nUUOND0p5Rql3KuWtuzV3b+Ts1SA1SKx2g7 kji1CHFcHKTj59/WlKe2Kxsf/Dll4T4Ak9btghha6TBgl5bPtANHa74afVzia0nq bvN1taLkB3LT8RuPx1xQMYWnxVkg092s78ska/zEAL2lymyNbWgAbp9BBNrogYe6 h3U08DEIBvu39CqJPUzPZw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t7x04f4v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:10:10 +0000 (GMT) Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 501DUmkc034097; Wed, 1 Jan 2025 18:10:09 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2048.outbound.protection.outlook.com [104.47.73.48]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s7pe59-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:10:08 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=CjvyIOFwwQ1xgdN3HtyXbE/ccwNQX7WuF+XpL3GASDHaTVpM6Q/LlJHmikUX72rTes8bOgZ/0iaoM83sjkqnSl7U1JcRQxMr9OE2H5IJUbHT0l+L2eUC0NC9A3hV3qIhBR6XunVPsisIjImiKurmkh79ve9anJZ6dA6W4NSdQ7ZdGenUb4WIIYnZvyflxPdo8D5dB0Jqrnxg15s2alUO9lT/kZCoYj9XDbtJX8iKw2LrlfdCKU1TtuOd/JBOUch6m9WXGROqUALctAgCqri7CfpNBl3NW+HedLAztd4FUmSVPCFknI5RxQhivUip7w4NKSA7wUQ83tlIPL94c0KUDw== 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=QToNs/4UR0QdsnKtbIGEhbf3j6vzpiJgGKQeN14RD5k=; b=jxJc7aljAEhq36+Gppz0d9OOhdVJlVs3DTfRMMHOcGRw/4DiP8GqeGIf3a7wsCMXpewsYyVVYrjxh10S+NWixD58NSQUuqo+H7jstOAA5KcVi/s/Mg80H+Ijf0mscXSTZHoW/yefEB+q14+NsBmWV8z98Jb/ZD1L3EoYwXuzkrMvaDc1js6NXSn+iDCachw21tUiU3I7d4sCDp+puCaPhwN5P1lBvRCm4VcM9/DAkLeeYP82Pj8H4+Q21v6kfRbxuTaKF3RaVtX9J0slUSgXs4O8871n8Pq2/uSvnHRg/IBSGD6rHjR1WWA6HAWsrq7JnwRHskgitRIhBg9ZlOJaQw== 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=QToNs/4UR0QdsnKtbIGEhbf3j6vzpiJgGKQeN14RD5k=; b=F0pjC48PGRfvSHg1e1RW5LfSxP+rzsbyIarZY8mIZxyKh5ZEGU6aAfVCLFZOPBwSYPRYjbRz2q0UZ1Uh9jiJuz+WOoyy8fTdPHzITx9lU5cxfavNoAwQ8GsfvnCpfx9Eh9IxheHmjorYu5TvwPcLyTwIZIKldbwkj+vrgZUIeRI= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SJ0PR10MB5549.namprd10.prod.outlook.com (2603:10b6:a03:3d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Wed, 1 Jan 2025 18:10:02 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%2]) with mapi id 15.20.8293.000; Wed, 1 Jan 2025 18:10:02 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, Naohiro.Aota@wdc.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v5 07/10] btrfs: add RAID1 preferred read device Date: Thu, 2 Jan 2025 02:06:36 +0800 Message-ID: <9b31f8f7142203dbdfe833fc87aa325dd74ff535.1735748715.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA0PR01CA0042.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:81::13) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SJ0PR10MB5549:EE_ X-MS-Office365-Filtering-Correlation-Id: d550165e-80d1-431c-b212-08dd2a8f832c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: KF3YdbVVg2sxOnfJGSJrP0V2dfSoxSsqSKWam17k681thv5VU4RbpsL02Sl8+1ebGsd4vagvaDXf8BaIj/z5E+q6kEYLDQsmSIPMFhpASAHVv/6pMKGdjw1Dmzpr+hcMPJTmb1wVTggG1qswTKLpnSFfl1JL6uLj0Sc9BGCTZSYDMHX8Dh15leJeH6i7CNxfwEpHWUnL0ZmaJr6OObIHekmeU04Fz0kyrU78ptdkKKAbS2zkz5ALxXb2eTR7aDe+Nrm9q2PZ9HRxKQEKn+vzwAj87mzsH3PeNXPCfh2fJ76iC0Y4mb4BlfDU2jttg9rkMdMCww/p8t0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Snb X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: L2bW957n4btDrsrqaGS8O6HXtfzUkHOWukJxrO4uQp9gKSmNqhCKMX1HNiN/hzngVtmj/PnqE09zAwEYCLm48vahbr1bd8/ToW/5OhMc3/eWrRdwG1urU/hpSwDBhA6iC17VPiRtMmLf+Qy+rDgMLswM+KIwdIrATXC5MO5LLfvJVJaK2NV452xVrC1VjaVabJP2ikyu2c+pfCHt15+pIRt9xyecpnbHXWA/zdEvh0QcDqUry1EHShPwG9Sght/fdC9eadNqChQ0YRM1mOkD0SlpkeuyahG0y4+H2GCFDKYo+W1QPm4xKZTu/Pgoy5vkpsFcU7gyu4JPzEGO+g5KHsBmC+uTx5M9P9KrwdookPezhRSfCEi0V8g4CY7JqCedsqwUpO03Zf9Ob9XzmJG/ACnfUDoOY7/21Jb87Q96n7qOxBfQoq8IGnugOUb1kkpTuPO3KX/1FDwfG+ps/DMkWMg1fW5vrw2/TbtIOJXOGu4M7XNW0qGxuCOJDTIxXC5JgGBQc6JHs6Q5+57j0UEdK7uf3J5MyCyCfg99ozOMLK2XjOHsf3yINV54U+VxL6NsWAJnxB5qcZDOVbr2x93hjUPFMa1in/sJn9wY8RlHf+BtjRJ5v++RtkX0JJgJNlZiadLD68tWts5cBvQeMCTMbLzQfbwwMqVLiw+9bmtgD1DuGjxxmFVJN1qCod46f1/dCKmFtbPyPmbv+d2RvlWejcQnv8cR/A05RBJGyNUkINxGgTuIpAQ/MO5b3G+3vzsaYAJ//4JoGW8uvhP+bKtRcXGgeMtj2g5mqmxLkwmnNlGP0y0XDi6bnencaRSSyZrArJo5WETQ9sx138dSa0CYo3kpK3891eSL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atuuSDFGd9haVjrr1/FFd3EN7uTVdHmOYKg6FExruRkiM4IihC2jCYqS7Tdfq3+hXP+kOb2yDIy9mO00BZ88KCkA5FHrlG4JWhQldX9Y/ohj0awiqhSnVae1u+Xj+z06n0HEgXfDeZiDZ6pF3tTDMcXWK4NCAAnnOfz67tovb/ZPV/OMmW202Kh8qIJrGCow8KuT0YLVYJAdhVZM/lQrHCKrqnXbsztJJYrVLgS+oxDEENkW335yleg//obi9uKrLH3foCRGmB3bVH/K3WLE9Kd10wDjht5LTTJe+bpjgRlg82KEJV+FxQXkjqjiex/i+L3H11GLDDJI5ZXZzq0AWvt62axytQmeaELG8p620NJY= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d550165e-80d1-431c-b212-08dd2a8f832c X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jan 2025 18:10:02.8934 (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: oRnGhv5NrYse3hFYm8EZhdT3NwrXhxqt7YD+p9dI4OxYUhZbePHt9Zyj8HAln16us8PUFllxsbxsqoFpEsoxSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5549 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-01-01_08,2024-12-24_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501010159 X-Proofpoint-ORIG-GUID: 8mamMy91bMM2wjBdHrmlyV19qnsjC7wj X-Proofpoint-GUID: 8mamMy91bMM2wjBdHrmlyV19qnsjC7wj When there's stale data on a mirrored device, this feature lets you choose which device to read from. Mainly used for testing. echo "devid:" > /sys/fs/btrfs//read_policy Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 33 ++++++++++++++++++++++++++++++++- fs/btrfs/volumes.c | 21 +++++++++++++++++++++ fs/btrfs/volumes.h | 5 +++++ 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 70f89d1adfbc..eb23f29995e4 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1309,6 +1309,7 @@ static const char *btrfs_read_policy_name[] = { "pid", #ifdef CONFIG_BTRFS_EXPERIMENTAL "round-robin", + "devid", #endif }; @@ -1356,8 +1357,11 @@ static ssize_t btrfs_read_policy_show(struct kobject *kobj, if (i == BTRFS_READ_POLICY_RR) ret += sysfs_emit_at(buf, ret, ":%d", READ_ONCE(fs_devices->rr_min_contiguous_read)); -#endif + if (i == BTRFS_READ_POLICY_DEVID) + ret += sysfs_emit_at(buf, ret, ":%llu", + READ_ONCE(fs_devices->read_devid)); +#endif if (i == policy) ret += sysfs_emit_at(buf, ret, "]"); } @@ -1414,6 +1418,33 @@ static ssize_t btrfs_read_policy_store(struct kobject *kobj, return len; } + + if (index == BTRFS_READ_POLICY_DEVID) { + + if (value != -1) { + BTRFS_DEV_LOOKUP_ARGS(args); + + /* Validate input devid */ + args.devid = value; + if (btrfs_find_device(fs_devices, &args) == NULL) + return -EINVAL; + } else { + /* Set default devid to the devid of the latest device */ + value = fs_devices->latest_dev->devid; + } + + if (index != READ_ONCE(fs_devices->read_policy) || + (value != READ_ONCE(fs_devices->read_devid))) { + WRITE_ONCE(fs_devices->read_policy, index); + WRITE_ONCE(fs_devices->read_devid, value); + + btrfs_info(fs_devices->fs_info, "read policy set to '%s:%llu'", + btrfs_read_policy_name[index], value); + + } + + return len; + } #endif if (index != READ_ONCE(fs_devices->read_policy)) { WRITE_ONCE(fs_devices->read_policy, index); diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index ab2e970dd6bf..e8cccfad6ad3 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1336,6 +1336,7 @@ static int open_fs_devices(struct btrfs_fs_devices *fs_devices, fs_devices->read_policy = BTRFS_READ_POLICY_PID; #ifdef CONFIG_BTRFS_EXPERIMENTAL fs_devices->rr_min_contiguous_read = BTRFS_DEFAULT_RR_MIN_CONTIGUOUS_READ; + fs_devices->read_devid = latest_dev->devid; #endif return 0; @@ -5969,6 +5970,23 @@ unsigned long btrfs_full_stripe_len(struct btrfs_fs_info *fs_info, } #ifdef CONFIG_BTRFS_EXPERIMENTAL +static int btrfs_read_preferred(struct btrfs_chunk_map *map, int first, + int num_stripe) +{ + int last = first + num_stripe; + int stripe_index; + + for (stripe_index = first; stripe_index < last; stripe_index++) { + struct btrfs_device *device = map->stripes[stripe_index].dev; + + if (device->devid == READ_ONCE(device->fs_devices->read_devid)) + return stripe_index; + } + + /* If no read-preferred device, use first stripe */ + return first; +} + struct stripe_mirror { u64 devid; int num; @@ -6065,6 +6083,9 @@ static int find_live_mirror(struct btrfs_fs_info *fs_info, case BTRFS_READ_POLICY_RR: preferred_mirror = btrfs_read_rr(map, first, num_stripes); break; + case BTRFS_READ_POLICY_DEVID: + preferred_mirror = btrfs_read_preferred(map, first, num_stripes); + break; #endif } diff --git a/fs/btrfs/volumes.h b/fs/btrfs/volumes.h index 5728b8717317..18521aebc484 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -309,6 +309,8 @@ enum btrfs_read_policy { #ifdef CONFIG_BTRFS_EXPERIMENTAL /* Balancing raid1 reads across all striped devices (round-robin) */ BTRFS_READ_POLICY_RR, + /* Read from the specific device */ + BTRFS_READ_POLICY_DEVID, #endif BTRFS_NR_READ_POLICY, }; @@ -446,6 +448,9 @@ struct btrfs_fs_devices { /* Min contiguous reads before switching to next device. */ int rr_min_contiguous_read; + /* Device to be used for reading in case of RAID1. */ + u64 read_devid; + /* Checksum mode - offload it or do it synchronously. */ enum btrfs_offload_csum_mode offload_csum_mode; #endif From patchwork Wed Jan 1 18:06:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13924252 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.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 B558833EC for ; Wed, 1 Jan 2025 18:10:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=205.220.165.32 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755026; cv=fail; b=qh67yeuOWXgmFtNoQqzs/jMzU//+6MJG6RwyvFStokGv8o6gGZ0J5o6c2Z43o8ehULj0aQYI1gdWQGywPho0Lg/AgdkwZpkAnfz1a3YwNVGIxsU37Mm4qgtVcMrYjVxDFxTzVVkf7/wXALNiS1Gv/1MCnk3Kn467+tGoY7QUmbM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755026; c=relaxed/simple; bh=8vgfFShkER6knPnhAas0XZX9pVV+P7Rar21OrcpqY1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=m23GJeaW0OQiEorykDeDQPvqKmV6LGQ7L+QCU7maC24CMAxhgMyQOhFxUL+4mINZEjCEAwR3Hy2A37wacVKWWdgm76Y50ymo9err+5vYhDAl545Ldxt7JgE12nsT8V0gngNA3VNukNO9DiDWVBGocCY0v0WIkaRAWMo0byARQLc= 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=HY4LMQUA; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=kEqDmR65; arc=fail smtp.client-ip=205.220.165.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="HY4LMQUA"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="kEqDmR65" Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 501Fl60m025784; Wed, 1 Jan 2025 18:10:15 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=x8+ucNLNelxAC10lgEUUfWVe8+nwNo4COFZdA+b69Yw=; b= HY4LMQUARBjT/HefmZTlR4tCvT6BqsvdB4Cn56YlgmqUzTXUrQwzzwR3tFFGoPup NN0ES5RGRTBwm6cpFhdpyi/vhJrVe7ttyMhY2lG+z4oxt1WKREEzPLHFeILLkdNL xzeFYDd8GbsMHthv7H9O+jVvcB/QLvWNiYHtG2HZj3FixO4Qyj6A873Zr1FPvbyC 82KjOeUkOx9Y+JxIRQjmGGdOVVl+s5G4vuhRsqoXT5aTAkgCUSrSkWoKhO1D5aK/ Km1TieCVtFxm10iRtOBHQzi5E9Ej23xw5GDCRLPEtCwYt9hmyX0MT8HRKwDzRzOv hIvoUDlrPcO/RvUo2fJY6g== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t7x04f5h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:10:15 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 501EUQPa009123; Wed, 1 Jan 2025 18:10:14 GMT Received: from nam04-dm6-obe.outbound.protection.outlook.com (mail-dm6nam04lp2043.outbound.protection.outlook.com [104.47.73.43]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s861qf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:10:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=m7AdQflVUUUe7T0W1aMn7j3Zs1h3qWOWVVI/NipNJe2ql4dZTvDX6vMBu7jiPFQvXamxtS1MLsVUf1viWvGWQCHtK3uKc10f6tgMirQSjJXuRPz4YqZhIEbbr6+uDgiqBhQ92kjyGsUNyGPHzL1MyHhLJD62znr8MVJ/dn0vrP4xnJg1crY2c0ZtxsCKQHKZFNM+G8bNO0rvXr/PTSCQSEi5sKmjjvDwsZMMwMKyggQxsYo6Bxlh1/udnTOn5thK92/Dl0BaP9wH6ZMWZ8RpU3iEQmZoWvPq5g59J5Ms3W5hd91W70FX2l+g7H5vWsyA27gwapLJpQnrX4zaKdk+Fw== 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=x8+ucNLNelxAC10lgEUUfWVe8+nwNo4COFZdA+b69Yw=; b=aHqh/F6o9c4V8KJ27PZmlgF0GtrZzNTKttkVhmP1x8HfOreaUFJ4KCKwpO0lR3isusLXUa9BX1b0/6IntM2ZEBV9r6rcCLarsyKDyGtheeErkKimQFjdDDdGLniAAKlskSprSevI2a8gyEFcp+W+T9NbElLT8uuiXYvR9g4L3eS/U7C3KwJ0sfP/5wTaq2niEY8rb94EoSAVpOiXjpNrZrT2uckEzkzeq5Yi6iy5Gypk5tCuhjIKwRfsnwGKK06/0jEyfUizUrOAS4WPbtEZNGaeNritYaJt1wtW/dvpcSwcW2pf1FTxAIxk2A2OqWp4c51saLDfWVvzqWF4K6uxTA== 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=x8+ucNLNelxAC10lgEUUfWVe8+nwNo4COFZdA+b69Yw=; b=kEqDmR65KTLcS6FY4eEISB/VnKOboaRpnlHUnBcQcjm3nExQX25rLYSmK0dL1vV96bD1EqRhPYHFxsRmkU1aBn4QO/7wj8RCyvnRLw3HIRGWquKHBtRa/tOQlALcUo19FgItQfBIIrVKkb8YMH+5NwaY6XaBgr87W/CorSeclfo= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SJ0PR10MB5549.namprd10.prod.outlook.com (2603:10b6:a03:3d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Wed, 1 Jan 2025 18:10:08 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%2]) with mapi id 15.20.8293.000; Wed, 1 Jan 2025 18:10:08 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, Naohiro.Aota@wdc.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v5 08/10] btrfs: expose experimental mode in module information Date: Thu, 2 Jan 2025 02:06:37 +0800 Message-ID: <0bd2f5b015ccbcd68dd1713ac3e4b598f0880cd8.1735748715.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA1P287CA0001.INDP287.PROD.OUTLOOK.COM (2603:1096:a00:35::14) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SJ0PR10MB5549:EE_ X-MS-Office365-Filtering-Correlation-Id: 04b3148e-dd6a-4270-6c6b-08dd2a8f8694 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: VS27kxHCta+j3IUFcfuumyQXcRiafmk+03RKVbXatSfbqbx0pxV/e65pagrB4qTBsYjCU+ooVJ9hBYYMqCWcl/WGOOrOxUzMyPuh40YOqLrOXv/UwuY/wKURGN/LfHk6WBSXmdPkTDizL5GwmThsR8r50KN6f58jov/218kMd2pMxa+HyelUFreJXYhvd3ZNI31l5rowzRrr+SKK0+zcSyjGIQUrcL6NyZXVUA7S+7oIbJnMUSdu5T+WftnTX9U5UXbpRZg1y2C+tZIKpJSbhZxJ1YBbO6B/VVHr+ZJ2G/cUFkOQyPzK6zIZW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QfnzYV X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VBPpTXcbGROcLqVgeFzi/L6jnS6JZhG+RDHkmwIJTPJfzK8bHd4fgLkiMewCVX/xzMG3YE0QI+fWeCHkT+/bDqmFIKjezRAg0DCX1Yr+UhBNTwL0WS2to7QLPE7PMkVwEKUdbfjTtCgqxddHkqWxZbyCCOC9zEpOoAnrTx0/BikDHebITx7kqCCSbJFZybnnzJqlJVNw73btbocr78Q8sm45pOCdOCrg4B/MS0QFdDiZJYH0MVoCwYZwaoNiImiQMLrwk2OSi9RcFk1pKh3KGDglpgP33upRx4Ed0ts/FnaBg446qz1NH110r2jQ4x1hKn998CM8nqJ5fGzxSh8/pHg6j7evGBbjoln2SYNIMI0xmiP7IQ92eMDcAvoU92YepK/3eJ0rbXOYLUQLAd3cmDzOfGH0aClTS3KcO24cTU5YGI/8c/FxzaDteBMqK+3U6kcasrK90M3Z2iWBVZqAKaOcO3XvMzhxx5xp9CzRa+yLaGYDwotBAI2SIWhmkUb+z1LkhSvAwrwDrRdpCC0jLkuCNnym80Rv4NzWZ6jXMrUofX2dgBo8AaL1odOWsSpd8IXEmzIJJPWXXSHjA0YGUzTxEHQ/SIRGQv75mCxgTsa2EwB5BA2MdtDu2Qg0JLcJsVGOc/Sox/9PZ9Vfr5tg6gghn5Yzc9dSF6w+m9t/WI/pJBn/FvHHBmvvuWZsOUL5hn63QObjs8UjdUssqiQczpRua48nbjtMhf9llODwvG0qLJ6rclj0hXO4MOL8wQ0jGzHwdMw5Xhx0CIhYvuWUweJgb+q8DbT0CnGDKFYGICYDVT5QkJVjOMtNY/tVfWv92oFW83HGcv+swEfr68xpIsv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5pb5TmCX//agvXvgZlsbEywDmrVlebPIy/EJf+NUrxDYL/ITIRUZTFbdf/ijhYslnR4dRnldfbA8m0bn02KD0s4MIN/MH3ZJooHL/0oCkAGHkfRdCDHe7Xt4fEqTdACddD5i4A51N9HjYKTHBUt/BWHacBnQIr7v1q98JmDH8jqSf/nfpOUPmPFXHD8O7//lgbZFLS08aBeC3XulkJBD/fn15L3qdi8uIPJBrRcjLsXtnpqrAjGdSXG848UaKpV+RcFBdKIJUatKBvj+FHd1HrQAcnvNpyPGnlcY/p9AE4ZCuN2oyAf6Z4xLAmUZUTuPIGkVu9P+8GQGTxtcexCn5cnmVV6KG1Cg3K/RtRy2KHbJ7eXILWDchs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04b3148e-dd6a-4270-6c6b-08dd2a8f8694 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jan 2025 18:10:08.3999 (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: E4+B+FQToWp0gbRFzzLA+X7gMU05iQEJOc+0CwqZUw8esvzfOrkq/8DwMsIMY35G4wU5HPAJd2Tlli8Yyd38zw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5549 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-01-01_08,2024-12-24_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501010159 X-Proofpoint-ORIG-GUID: YtpEMqJ9Vp357rNq90YJE7_XRjs7Qmsc X-Proofpoint-GUID: YtpEMqJ9Vp357rNq90YJE7_XRjs7Qmsc Commit c9c49e8f157e ("btrfs: split out CONFIG_BTRFS_EXPERIMENTAL from CONFIG_BTRFS_DEBUG") introduces a way to enable or disable experimental features, print its status during module load, like so: Btrfs loaded, experimental=on, debug=on, assert=on, zoned=yes, fsverity=yes Signed-off-by: Anand Jain --- fs/btrfs/super.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 3381389ab93a..fb6a009c72ae 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2457,6 +2457,9 @@ static __cold void btrfs_interface_exit(void) static int __init btrfs_print_mod_info(void) { static const char options[] = "" +#ifdef CONFIG_BTRFS_EXPERIMENTAL + ", experimental=on" +#endif #ifdef CONFIG_BTRFS_DEBUG ", debug=on" #endif From patchwork Wed Jan 1 18:06:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13924253 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 6335333EC for ; Wed, 1 Jan 2025 18:10:36 +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=1735755038; cv=fail; b=MdSyLzNmNS6pJTFkoObuTzrdUe/hBO1wol3FORVsBNwN0vfW1QtCtld+LO7/wjqYnlA+IPPfmAPaOtvbdkjVNOT5Rk9bUqwC4RVKPnjTqHpeZEtgzzNZt5AZewdSbyr1/xxgLadA0zbQeoCsjIXimH2t63OD/YjO4wA512VGP8o= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755038; c=relaxed/simple; bh=+WLN2EurTPdUKeA08rhkk0C/a9+UrKm1aw8a5tXQLmo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=s8xblBjPcIWafdUOi3XZf3kLU/dVE9Df/6YQ5+tpQ3DGt1Ir4DwhZa8ruy5/DAl9c6fuLdeOwZKqftBYorARIq6BUacCIles0T1UUqDtkEyBjlE6qap8ScgjTm1zwucs1mKA4qoBRLniSPdPBCFiNnFsHeXkw0BpuvZmgyulJv8= 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=oAaeuX3m; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=uf2lIMX0; 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="oAaeuX3m"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="uf2lIMX0" Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 501FlEsd024279; Wed, 1 Jan 2025 18:10:26 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=o2Z1qSNycH0fho0gM8U9mm0PRk1/xx3Q4lMbwVju/5c=; b= oAaeuX3m8Q6yVbQe/mzB1KzkuXkFOYly/aJxiJq/El/++JFcboZeywdo+u1FjnTg Fqp2bqEo1K+cSQ1tH/Q3f6o/SE8NSS7VAT50PLDSu4IOYp8ogGUiDBBthSJWXWHS ZjRKaLR3NJHrq4WZxZaxj3aiqvU2EjvAVekrFsT/LQEE/9kaILz80pFwaFGkAsOj QMsUjjoZUEpMR29dv6KCK34XN8JBz+UtL04LFo8uhrrWDRpllrm9O9WC6WZJJVCT pNgFiOOth2/E/7exHOBblQqnesLJF/ump4YpO9VXCVAUnHp3TlR+Fb8wmd1fAmL/ BADh4eblmN2nIZNLSrIATQ== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t7rbvgey-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:10:26 +0000 (GMT) Received: from pps.filterd (phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 501I3lhD009156; Wed, 1 Jan 2025 18:10:25 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2045.outbound.protection.outlook.com [104.47.55.45]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s861tp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:10:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=G8M3aBxQQ1CNxQ10JpBlG+E0t3oq/M2GqSmajolJ1wYEOcMQgb4jKm1tFeuTC+wHKRfoGMWnQIqs8kIgwCCN2n+O3IzL0dVAKicyTSzYutX7VGbvWBPQo5gzQJl30u2KlZpcVP1sDH+MDzb7M1VtBjpIDd3eSVDVrOuvpePRP6ruweuxvZyBKdGJPbeIcx2dVk8b9y93Oo4P+IdjPZBCqK/+MNDjK7ji2mI9+VC9c1d+GFTd0U1Tvmk9E2BvJxP9LEJWu/ad1AEBmTS8CCHd+DimL1rH4GDMS6XL6OnG7mbyD8hoKgPURAMIQAjEoqe4hh0CWnAog9Jkpl/sdH8jxw== 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=o2Z1qSNycH0fho0gM8U9mm0PRk1/xx3Q4lMbwVju/5c=; b=CgYzQTKgvJ4LlvdwnQztLtD1T7jYkHhHX3GaSC9v5W6deHQFaml+p2jLjeUSLYLxfXWpOSdy7afur3bOCBZqWfdRIzQRTmpxxuGf7YOXGHIpqJNiVNcQe/UwGKBcgga84Q6ieLasyrmJ8GrRRFDx5uz1V+zP7zBE4L3xiS5OnJ3EVQLk+cwdNLwNhMbfT661W1HsEnHk0+KwfSiWDSYsTFFAglYcM4YHOVqJIpkrhLCdYRNkRNLzbvtlBUw3Ge0iluxeZ30yx7h8bvjpP4Kgg2vpplop7Z08w67/V8Jd+EMLXJtyeq/Qf6EOMaRpS2tgNvtt8ZwMh0DGPsFcM+HRcg== 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=o2Z1qSNycH0fho0gM8U9mm0PRk1/xx3Q4lMbwVju/5c=; b=uf2lIMX0fiHzUtkU3qVGfKXeG07zFg7/rYe6CgtsczCykS8tmbYmj7mARRGxVJJ1I1/6BLWsw6Q/xYbH4aAArgxIaFLF+gB8vhlSeSfrcbotTYRDvDYZ6/fwIfSb+HanPNSnLF5b5LPAmoU353P0fnNTOQfvdittbun/EUrdUhI= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SJ0PR10MB5549.namprd10.prod.outlook.com (2603:10b6:a03:3d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Wed, 1 Jan 2025 18:10:19 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%2]) with mapi id 15.20.8293.000; Wed, 1 Jan 2025 18:10:19 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, Naohiro.Aota@wdc.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v5 09/10] btrfs: enable RAID1 balancing configuration via modprobe parameter Date: Thu, 2 Jan 2025 02:06:38 +0800 Message-ID: <0878345c55203627eb5dcf0e29d5101c29f49c6b.1735748715.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: BMXPR01CA0090.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:54::30) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SJ0PR10MB5549:EE_ X-MS-Office365-Filtering-Correlation-Id: ec0d01d2-1bb8-4175-3e36-08dd2a8f8ce9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: cBzT6R03m9HpqxkldNOzJlWcepjnDMQZQYcSKcqcoToQZv7zolIVmUsdR5WhhClFAE30nnSIzBTYrC1kij+DrrxWFzWuHMEKb9fo3AScTQtHJ1/fiF8Eun9LWv+0YbPHpp60fB7X/7On493IGnW00puJtY8S/gdguJin3+a08Pe8G56OewTffMW4amjnJL5ALHl+y7JDDjXH6yxD14lUFi7ywZubDAAO2qp/jVOHcMF9+Yov0e4VKG+bLTZMKIhkNItCHqCBFNJY5F85dvVpO8/qEtHDX12V5fRQ/b1aRnrg11v9i/GKvC0KgHcDUnQFJL9pPaYeffHDB+UB5YYLhsLXy0P75Ba9F4wkg7JHJu7hIxwtL6qNgXX/JQkm3IJAY3doJWHQ6CqFBcI7zZBNtEkiR6/On4XuA2XnUwfBf2RE6IezcdDrYVWrfcgkSsigVTNb/SXLd85aMIgTkBG05SGZk3UhRblHJxIXIWSc+yAXUqkSo1dOVBDvKKMFQjFUSyrQZeOlAGdadVXvZ/T3YJiCS/UJMdnb1P+fpDwB5YDd7+rqvfjiLymyMLdLKffFLzpa56i1e9RsQhKqAIH33+UHcRxskgrtxEY5iOXJG/+MBGehSDDn1BcUeo3wxA8VwwLlrvUuAnJpwOEtLSenluOv7KDVS/+rD3pfpmW4bkgYtGJR+ZC+LfLDLMsoOj8BL62Id2hpwSASQ+M6eEgIyh4mFdBtiAgpi3BX6kvyuPRcd4HhhfClGu0BDFFPZdiCqyMlmbsaeYmUbM5Y3nWkLEnrx8cotwIFYv+FwI27yXTsjYqj5Mb6B9e0C3+2qTv8nMo3jn8U/IuM8TsD8U/n89dlyL5rzblMF4/Zh96KMpDO3QLH3okw+hHa7/4RWP4GBme1i6NJW5fPq2h9DFlnVwefJFkC8EYguka5q5HQCa7K2z7Sn49w3XvhnMhS0tOvEJW8Wea/Jmycw107mmBdoL+SYy76ZEwFnAWzNDFtcX5plmEZqsFPuIJhjQVQEWBE/6RxoLsNXvesfDeG2fDlEU7SvmtXrJkK2I4ocKv8/L+I2voYSziAlLuNPGTTnQGSG1dj3PCuSrjgsHipl8SVKrepirx6wGtZYt8lzEwmdUoiQpCKal4OLXuSCpXCuew/s/3vNGf8Qstvh1OKuTcncVidoz4FFXATvlIujnOds6fvNscQJPqF+Dl0x+6PyrhbCXxEJYoFPRG8ovbAdSnlhr9XQW/RIqCL/SanScw1k7p8r7XUA+rdNG1bmS0BWj7DWw0l+hL+WuYvZl7uvpgKSTNVqXMZafAEqA43bUgJSFYMJNHO370BJw3tNSjKDpBCAOvLuxLpp321bDyQcO2m6sRCrvl+XbC5NJCV7KtPfny4Lx46ZVg7vYzMwDgRo8Jp X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VjlIMiwbZKqYR7BpkvMnNU1pbeLnm2aMMZ01say8KfO/KCFjAgeSkZ+2cazQ0mI+0QRY4TazlBdnall6ditJzbRfYh3bLwgL8G3mpEK7i+Rvq+Rw79s5PA7KpsxBKGBXxBJZRxMXs+1bg5ZDP97MPXmNKi7fv94GOMHFRj+RO1m7Au/M/3+RhOe5J/ip5Tfh4PG0YS/NXJzNY4tXdQr+FI1Eu4atkZnE0jOEAUCUJDmXlyZTG2/S44pz8Yx78GCmTR5u0j70KzFyuCWPHvn52odaMSRczW7AcDS89XzeLopN7poMr+NSuzyEMiyutzkfa5/5hLbRgWYU2XXHTqEVuowqWIUK5mXvV1Vn7E2fmcN46V0w0dQcieYzJek2qWkeRr1keudITNJTaA65NB5SsZJjPq8Hham/LxW94Fv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nhnaFLthOr13wG2oDoHl20HA2aqRtVYZocRIsZqjynGA4WAVDDECvCudRDsfqb7UgdkXSBOQesq6wz+4gxPJpPl948K26NmmmWTYgf X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: kCuLRUeCOY55Ep7pKdX11d2PYN3IzaKlQa7u35lqxWk0nLsaD+xP73Ac9Y1lv0eu9RdCT1KaYZsQGM+Be6Gyt8KE1F9lTqmR39GFOlrxp/b3VIqdYZIJ4eewzgs1BVYq3qV7fmQ9JfXzablvF+yPzcm8/E6qSM/XSyZBw8NSVdbUkGoAg9wJpIsZ21pk1I/8cLinopFpxYX2r3vpg7GPepOZ1KkBFeIIql6aKRJ3IQmzmVamUIiJBPU/YRhDt85rOJpZuXffwYiB/Zpsne2+HNNdXUSegqCQAc/YWT27hhIK6YskQ7wqZYA3Oqr/aqoHhr7i0JmAWL3JIcsSx+SFxutphBTX2bG1y4HyM0BtY8tGPOcWVIdM3moS1zRJFuLmL3F+axPky7wdw1008w6tN9NTxFpcAeBk3HA7qwa8Mu6gxvY2BlTVmrBEmH9XwdaYddpns9yIoKAHC3nffzGSOiCRRZYmQWtmV5uuUmcyJ+g5MrSzwNcN0YgudsHwG9L7gB2behal3xEwxqBYr1E5mA/EkpEbHu8ug1N87UglWiqdMD9FAdybBushr4qxWg6YlA7yHopyL8N78TxnFdLtkOldp9LWkB9VHQPJLqYJ6h4= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: ec0d01d2-1bb8-4175-3e36-08dd2a8f8ce9 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jan 2025 18:10:19.2626 (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: GusQmpEZam3GmVkgsHYVV9L6zrKWZOcaciT+zCSmDm4rDvBY3wpA81a+p/nfcyZtKf0JebNesb2JFmb4MtMing== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5549 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-01-01_08,2024-12-24_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 adultscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 spamscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501010159 X-Proofpoint-ORIG-GUID: B--op74axe7ZWr92wpedpej5BlXclL0A X-Proofpoint-GUID: B--op74axe7ZWr92wpedpej5BlXclL0A This update allows configuring the `raid1-balancing` methods using a modprobe parameter when experimental mode CONFIG_BTRFS_EXPERIMENTAL is enabled. Examples: - Set the RAID1 balancing method to round-robin with a custom `min_contiguous_read` of 4k: $ modprobe btrfs raid1-balancing=round-robin:4096 - Set the round-robin balancing method with the default `min_contiguous_read`: $ modprobe btrfs raid1-balancing=round-robin - Set the `devid` balancing method, defaulting to the latest device: $ modprobe btrfs raid1-balancing=devid Signed-off-by: Anand Jain --- fs/btrfs/super.c | 5 +++++ fs/btrfs/sysfs.c | 30 +++++++++++++++++++++++++++++- fs/btrfs/sysfs.h | 5 +++++ fs/btrfs/volumes.c | 14 +++++++++++++- 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index fb6a009c72ae..58190989a29d 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2538,6 +2538,11 @@ static const struct init_sequence mod_init_seq[] = { }, { .init_func = extent_map_init, .exit_func = extent_map_exit, +#ifdef CONFIG_BTRFS_EXPERIMENTAL + }, { + .init_func = btrfs_raid1_balancing_init, + .exit_func = NULL, +#endif }, { .init_func = ordered_data_init, .exit_func = ordered_data_exit, diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index eb23f29995e4..ac1a32af2442 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1313,7 +1313,21 @@ static const char *btrfs_read_policy_name[] = { #endif }; -static int btrfs_read_policy_to_enum(const char *str, s64 *value) +#ifdef CONFIG_BTRFS_EXPERIMENTAL +/* Global module configuration parameters */ +static char *raid1_balancing; +char *btrfs_get_raid1_balancing(void) +{ + return raid1_balancing; +} + +/* Set perm 0, disable sys/module/btrfs/parameter/raid1_balancing interface */ +module_param(raid1_balancing, charp, 0); +MODULE_PARM_DESC(raid1_balancing, +"Global read policy; pid (default), round-robin[:min_contiguous_read], devid[[:devid]|[:latest-gen]|[:oldest-gen]]"); +#endif + +int btrfs_read_policy_to_enum(const char *str, s64 *value) { char param[32] = {'\0'}; char *__maybe_unused value_str; @@ -1336,6 +1350,20 @@ static int btrfs_read_policy_to_enum(const char *str, s64 *value) return sysfs_match_string(btrfs_read_policy_name, param); } +#ifdef CONFIG_BTRFS_EXPERIMENTAL +int __init btrfs_raid1_balancing_init(void) +{ + s64 value; + + if (btrfs_read_policy_to_enum(raid1_balancing, &value) == -EINVAL) { + btrfs_err(NULL, "Invalid raid1_balancing %s", raid1_balancing); + return -EINVAL; + } + + return 0; +} +#endif + static ssize_t btrfs_read_policy_show(struct kobject *kobj, struct kobj_attribute *a, char *buf) { diff --git a/fs/btrfs/sysfs.h b/fs/btrfs/sysfs.h index e6a284c59809..e97d383b9ffc 100644 --- a/fs/btrfs/sysfs.h +++ b/fs/btrfs/sysfs.h @@ -47,5 +47,10 @@ void btrfs_sysfs_del_qgroups(struct btrfs_fs_info *fs_info); int btrfs_sysfs_add_qgroups(struct btrfs_fs_info *fs_info); void btrfs_sysfs_del_one_qgroup(struct btrfs_fs_info *fs_info, struct btrfs_qgroup *qgroup); +int btrfs_read_policy_to_enum(const char *str, s64 *value); +#ifdef CONFIG_BTRFS_EXPERIMENTAL +int __init btrfs_raid1_balancing_init(void); +char *btrfs_get_raid1_balancing(void); +#endif #endif diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index e8cccfad6ad3..e5e9b33837b8 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1299,6 +1299,7 @@ static int open_fs_devices(struct btrfs_fs_devices *fs_devices, struct btrfs_device *device; struct btrfs_device *latest_dev = NULL; struct btrfs_device *tmp_device; + s64 __maybe_unused value = 0; int ret = 0; /* Initialize the in-memory record of filesystem read count */ @@ -1333,10 +1334,21 @@ static int open_fs_devices(struct btrfs_fs_devices *fs_devices, fs_devices->latest_dev = latest_dev; fs_devices->total_rw_bytes = 0; fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_REGULAR; - fs_devices->read_policy = BTRFS_READ_POLICY_PID; #ifdef CONFIG_BTRFS_EXPERIMENTAL fs_devices->rr_min_contiguous_read = BTRFS_DEFAULT_RR_MIN_CONTIGUOUS_READ; fs_devices->read_devid = latest_dev->devid; + fs_devices->read_policy = + btrfs_read_policy_to_enum(btrfs_get_raid1_balancing(), &value); + if (fs_devices->read_policy == BTRFS_READ_POLICY_RR) + fs_devices->fs_stats = true; + if (value) { + if (fs_devices->read_policy == BTRFS_READ_POLICY_RR) + fs_devices->rr_min_contiguous_read = value; + if (fs_devices->read_policy == BTRFS_READ_POLICY_DEVID) + fs_devices->read_devid = value; + } +#else + fs_devices->read_policy = BTRFS_READ_POLICY_PID; #endif return 0; From patchwork Wed Jan 1 18:06:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13924254 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 E896E1E25FF for ; Wed, 1 Jan 2025 18:10:40 +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=1735755042; cv=fail; b=nzwFKVgtDA6bZ15qyy7zA302uT2gBXoGY79xhQ8pZBaZRjtQ/W6rhqcEqQX3Spab157RwSB+E+f5GcBH+oMicj/9Bujg8G4bsXhDKfAby44is7G+PxL2h2rL6Ig/leSt9sezabP9JVpNVGPF5aHP3DiYlFxYm7RnNR044sbHrZc= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735755042; c=relaxed/simple; bh=zHnC40sdg/DCZq/YO9ravc+0wue2FPI4sG7i4zMAG9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=qWzmc3U9V5uKtCVEnMYeRS+HhsDDhN8dFSxfRrpRndo/+JWwkedzKLA3jSTvba1DMO6mFRWYgZjhuKLcwIEMheDZO+2QvokO4As4kRUaue5LfLf/TCrhYKAE+XrrGgFz4DiVKtzEb06YFgGQ9Gh2wFByPzsNfy1R0Rkv+Edp5jM= 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=PYahCY59; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=D0XBF4LD; 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="PYahCY59"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="D0XBF4LD" Received: from pps.filterd (m0333520.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 501FloQu027566; Wed, 1 Jan 2025 18:10:31 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=SW02jPUrx5fbRPrObS/OhhI/OKc6GkMfhEpB3xrJY4w=; b= PYahCY59WUTEqIOtRGudWCHZFpoaGNaQ5/6uUKsfB+oK7+knGZrBZnld28uFmh/d tSA4yaNNWlOgvwSIXf2b9xPJLqhTsY0LLvbIL7Fwq0oejYlx5mxy4SaYuFndQeqq d/ngsEay/pUSTb2nubSd2/1je7W1+zIn/d+EdrpF08plN4vld31UvCJAEFTqj04C 6ln5Xv/4MlPHH9gpujKNLK//KB19lZ/oRAIh83ty/KB62BYl59tbS75Ei4XyzQkb umk/yir+djktIlA3JfsqQhNXI0xWqRLre6Kwp8LhvXs9mBLfGUTfm+5a1hNFZaYX Q7Zq1ZzlKyaMrP21v7UKlQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43t9chcggt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:10:30 +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 501I8f7o008823; Wed, 1 Jan 2025 18:10:30 GMT Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2046.outbound.protection.outlook.com [104.47.55.46]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43t7s7wvmc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 01 Jan 2025 18:10:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ke4oeRboxrCtZmPuUNtPcY5iaUzOyIZJ2h9o/MYRDQlxnoR5jMQDOiTAUK1IcbZcvh+SaWo73AQNojThsIMhbJDCnd0xasFRQ85vQ2Y2YrX5sZ2Jz3N8UxmxI0XbHrCxRUvDBsPQJwwwIO7wLo7Rg6h2td0x2k+YtbzF86JtrFYJ3ypM8DweLaTqy+3VoKcwl9VWxp+H2AvhJ0STFxZco+YBMMlr0qtc18DcOwOro7+GKQsmUaAnrMOhrNWCTA4MultjYpGtN5ytqG402PJSaCmYr5bMKT6cX3dDs5+aF7o1rjuyti+S7Lzg8tXpih4qeawCzOlvYzGv+Lrw6CfTYA== 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=SW02jPUrx5fbRPrObS/OhhI/OKc6GkMfhEpB3xrJY4w=; b=qkcgz0lsKLbKm6JHzmXLELG29zC2hyehvqZoRmv2KQrJJXZKUk6ltY2NpuuMEB9KTsRmzzZSoh2FA+ore5SV653nacu6xVcal4cjT8CBkeSvcbewPzVPqtnkgpPI4DbMkgtUsJYEvgaKvZ79zSmNDGC8n6T7Uv7abNEnTV3mzWBU3z42mDtnyAmkQte66zM4E5VcF5p8EqW2uiQCv5G1bAJ/2/7AsKvYFenEUld8LgMMzqa+Kq0KMIHMczxaC/3jinSKkRN7RUv/kP7OIMJuFxTdUBE4fZZa0qcXd6MibBM3LTA2K6IpJQx9ntQ9U9ew9sC9zpz0nKjwsX1JaQB/eA== 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=SW02jPUrx5fbRPrObS/OhhI/OKc6GkMfhEpB3xrJY4w=; b=D0XBF4LDopUPBLhPDUIm9y9z6FAIoMPZdlKlspzSXmdvViPiWbiwIVsTzOAHcUGW9grKdK1tEOLKL/L58p1iEwr3PiXtL8TBsDLyG/snBK9LBDMRspBPVSZYdQ3hqQITJeoo907OFen39aJQU38/0HbphpMeMyDIVuOS87b8BhI= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by SJ0PR10MB5549.namprd10.prod.outlook.com (2603:10b6:a03:3d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.12; Wed, 1 Jan 2025 18:10:24 +0000 Received: from PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65]) by PH0PR10MB5706.namprd10.prod.outlook.com ([fe80::fea:df00:2d94:cb65%2]) with mapi id 15.20.8293.000; Wed, 1 Jan 2025 18:10:24 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, Naohiro.Aota@wdc.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v5 10/10] btrfs: modload to print RAID1 balancing status Date: Thu, 2 Jan 2025 02:06:39 +0800 Message-ID: <247ada1a8d2d67be37916933ffa97ccafe96853c.1735748715.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA1P287CA0005.INDP287.PROD.OUTLOOK.COM (2603:1096:a00:35::19) To PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR10MB5706:EE_|SJ0PR10MB5549:EE_ X-MS-Office365-Filtering-Correlation-Id: a2072269-8cd3-4763-0699-08dd2a8f8ffe X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|376014|1800799024|366016; X-Microsoft-Antispam-Message-Info: YnLcsbHaVqCKBNUWh2DkMrZVNe/PP3vJ2UF4wSjWZxrgb9hlLe1PuoqSkC+ZgVQi2q6NglG+xNm3TUU9M/FAEy0Y9n91UdHQkvYCErh6Q5Fy2UXt4KRMJCK1uFQwJTjfdswVc3nCUuvlEKDMh1irR2wjECoq7IUBqat0+DSLmimH9mTkrX9bMA0eWaCbiZpAhoIpw3rYRGogLZMux1u9UWmxsSepk8ZWTu+2azPtnlCnKbs4F4HLjDKozXmWrkV+M3kqBKLDmuz0QGQZH0LkmgQDF4rCZU4tw18f6vw4/TRfLuYYY1keyEA72Uafh0YoHZXpo7Zx2CeWgaBmlWE3ZBgSImCeec3xXHJ4s+K/abeBs0zkKc62QFMxSxnF/A4RRDChEPLU+6ASGqI/8GrV63f56Oa4E4Nh2u5qZp4sEiNxyYRu/6HFcNPo36iei3dnYdVb6L836mi3EoKVPBrNASgKt+sNfttrsaf2+MMrr5m8fuQBboCTjLj1OITHm/xRaO2ndY9fOVpL1d71BkznfcnZ7+4yNNeeK4zvDXqJduCYBlrvhVT6qCpr0W8z9DrnLnj69OdYx9Rlahi/SDp8R2A40ZEyC1JAkGm1gHNPB/SQJUE2l2JOJOvGLpo7/ZYXQrrbG4ZBi5/MOGGNHFqbq7fxM2V7/pwEqq302MCpxszgHR0f8QD2DNz1WXOD03KcwIym5FPT1HsK7hhj+wMqAUgcWqIUKZ3kdBtelHRGlQMjBhpnzNigMEqowEqjsfcR9xWFjXFdDfDvxrDZ/fT5VAFZcyx+yHIzz6T8ftnRu12H5TEwl1P2fo1WjaaKKgSdTYMi2dJPzNrOlF3f3V/LxF3uxegB1rl5VToFiIJbAzsrMm+xeKol8HPHLe9kb8Y5D0T7p7ywcF57QuDaDz4NkqXh0KwLTAm6XHExcPjR9fc2cF2RXyf4GAGkhzaTqwOCV5GqD9bxH/V0TAbVYH9V+uzY7+8zVFKPf0LzZGlZOUHMoOIfyLM1RXnOKlxpHpR7yIlL3jXdbLop5nN+bHLnyTHHFgyuwzPuEMlzT7FXJKB0FovyMKhjV52Pxmsc2D83F+1Bb1EW4O1wmdqzlmArUtVAuJHdi24r8oL6J1uty6j+gXFkI5vXdTMIl4keWPKS1+R4VERmeyudcOUw6tnj5BLs2tBpOa9EGOz+9nPEepgjXowF7C3ZtD2ZwgWlgpqwRDfxlUftUA0rP7Vf2wzHrIcgnsrBL01arw+AZV1gtXRuRykD8BLR1J/qCmBHzj6VqHBgd+Uk3c6TT4jsFkwxIfd22zLHJOSAtrwHMFngHetYIwPYTKCHn1fNt0NPgYnrzeqRSHJimkUNeP53yeTckatebO59xxqGseCM/g8MrZ/0rWkNrzrtJaFPzccO5vLE X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(376014)(1800799024)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Rg4+334phfu7L0V1nc8QZJdNi6tFjW7BXpjx+oRXBX7loj2/beCLoGFqTFpTpzriubW17PdsXD2qHjGqFyJMJJ896QO/3UG6tr64vDKvT0Q0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RZ4s7OaaJ/NOdAaln7d7wew34a40dRxU= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a2072269-8cd3-4763-0699-08dd2a8f8ffe X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jan 2025 18:10:24.1877 (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: bcwi5r8ystggHfOb4puH5Il854dwCZGlSkUEEaly/jl9zDBioUpj5PTvp251dw2TpJWJURp1V+RPqkNzJfRkuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR10MB5549 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-01-01_08,2024-12-24_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 bulkscore=0 mlxscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 adultscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2501010159 X-Proofpoint-GUID: T6xdw1GpOnjwp6Egwu1QHuzwoF7LvEnl X-Proofpoint-ORIG-GUID: T6xdw1GpOnjwp6Egwu1QHuzwoF7LvEnl Modified the Btrfs loading message to include the RAID1 balancing status if the experimental feature is enabled. Signed-off-by: Anand Jain --- fs/btrfs/super.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 58190989a29d..236eec7c19cf 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2480,7 +2480,17 @@ static int __init btrfs_print_mod_info(void) ", fsverity=no" #endif ; + +#ifdef CONFIG_BTRFS_EXPERIMENTAL + if (btrfs_get_raid1_balancing() == NULL) + pr_info("Btrfs loaded%s\n", options); + else + pr_info("Btrfs loaded%s, raid1_balancing=%s\n", + options, btrfs_get_raid1_balancing()); +#else pr_info("Btrfs loaded%s\n", options); +#endif + return 0; }