From patchwork Mon Dec 16 18:13:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13910198 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 2E79220767A for ; Mon, 16 Dec 2024 18:14:05 +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=1734372847; cv=fail; b=bnyG79YusMHHykvBvQQ5ZA9MPlEvhVkNQpmXDEKh1SokA+6YyRaaU4GmY/t9NntxoceqQpEVjZBdaxVjIEXFJEOvFMWaGbRhkWhjHyzK5tqkXwSZeGJ3lhh9VMxXqfIxapqpgtf1dzWS/de+uT0MoBjLORj0Hq4rvLdzkJDceUw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734372847; c=relaxed/simple; bh=6NT2QHRnfPJt27gRj3F2dY37/u1mclj7JuylMQy4/3I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=FIuNqj0X3uW0lUVLfoK7AGNJ/M8kopsHEgDtZXI+hc5rzw7MYGCNq5vsU0b7d3CfLfgr1m0ovBo2gjO2BfasFe//krxRmmsWQJzCXOQ55MHG7GFxJgUN8AO6AICNHqt9G8zA48csSX0Zi1DFz0spJ8wlg/nNGR37n0f1myY7Qis= 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=jK4dHEjn; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=z1eu/cy3; 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="jK4dHEjn"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="z1eu/cy3" 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 4BGHQh7t024115; Mon, 16 Dec 2024 18:13:56 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=2KxBn49JUOG5nsjBFXTjqA2e8itFVgNEkch0ty41lEM=; b= jK4dHEjnavJ6TGNNzwVEmDNqUnXgPJXILaigNDKjaNQVPdkhaEicgE+1iOuEDF6l S7yNf6vJCpKkLMMQYzDVt/lTCM2K4hSmYdERzgJTXXSHKH3yScQlQP9P5pWcjxjl CIorJ69jux2dXXm8ymd2NzFa00xCSfL9uQA31u5SyhdpGWe/LG1UuEEaUOCyK01l jPR6i95Le16Ig4WFotSH4jtOo1jAejG+4KdNMF+lePizNkmM2QBqqFTys0aQtkF4 UGMfpmk8DiiV5kEqIVWwPtTx99AoTsKTAeiKbCASLgUDn2xvX5QVdQePhMYy8J28 hLhXCaEq0kUMrsT5IO7JNw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h0t2byvc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:13:56 +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 4BGH6pM9032708; Mon, 16 Dec 2024 18:13:55 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2174.outbound.protection.outlook.com [104.47.56.174]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43h0fdmw3u-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:13:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mdSpFldkSMrI7cdrnsv/ycXTk6fRbprubwy5GJ+VWZOAyyQ0SptTZwAnZHHjb93h2vGDLAr8guj1ROFwLYETBsYQw+NlT3w/onXdVcctyngNhs73l1Ho0az8CaAu9NdEarlnXu8ooff406qbg6qToMp7SoKRyzTso1jbQvQeOWJ44SU5fY0Wn8QsN/3/lgp9pEVD/cZPRoKyRSYOIb73+w/65q+8ZNumhbodvNOcKWxCjC74EsdTpjzzsxHcjkiJAdJrSvIuGeuXP3p6MvhbzNnoAeLQIOM7QsDgfxcAiBApU/B9Hd+YUJdiaIqMgy9qJG6VXO6R2pztbP2l3rtL8g== 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=2KxBn49JUOG5nsjBFXTjqA2e8itFVgNEkch0ty41lEM=; b=pLFMCzXGEVh2TVNf4znpamKxLxeiVxXB0V1j4+VgXlXi/qdY1xsBJmpo7DLd7Ne7BjGotewB/SYHIdMS+JxKaJAAg8D7CRMZ6iSGeo/Mu5rCLm811kLRINXP7jgP11WsAgtXJpc0UhmVyyYJ516xC6bcv84OubNhUFOHGKAxrg9XnC+MtA+zM5Ot8LIjaV0MjfYVyFkKGD0z9emxeSjA+1RfPs38kGgLZykad5/+rDK3jCxIt/vwFHEJaxO3ew8xoHAuA+LlF3vELBv0LhPjnw6h1PKLZ2b4sVlS7aYy+d8h28362w0SQHvpl/T8xISKIbUBRGf/fH1PCMDfNlLVgw== 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=2KxBn49JUOG5nsjBFXTjqA2e8itFVgNEkch0ty41lEM=; b=z1eu/cy33EDH5fOFO1VPMFvk1VGGCBr3AIrk6fT05lwvpRzWJn7AS//3oevcn8gb7sIpqXkKtUDqq6IP3p8cUAvsJSvB+79rEps/9r4zwx4PDk7st/o3Iyq595a1NHucw9j/3FqKXuGBXvsFsoWcsW6yquRCJzEuTyTUBPfx158= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by MW4PR10MB6653.namprd10.prod.outlook.com (2603:10b6:303:22e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Mon, 16 Dec 2024 18:13:53 +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.8251.015; Mon, 16 Dec 2024 18:13:53 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v4 1/9] btrfs: initialize fs_devices->fs_info earlier Date: Tue, 17 Dec 2024 02:13:09 +0800 Message-ID: <767bd0e42792760d77b7e8225111d9c8a6f4039b.1734370092.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA0PR01CA0048.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:81::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_|MW4PR10MB6653:EE_ X-MS-Office365-Filtering-Correlation-Id: 56c8a02a-ba64-4868-6487-08dd1dfd65b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: AGKkLnm1zFpmRBJeeWq4OfXfR8+MEKX9fpMYcuynIk23BT+tzeRbDfSJ4I2SzqXU5zFHyYJ+EiBtxZOHs1bJgC/VGY6XEZ4qmTCZXcIdf6MWuNpHVNzIL1eWgGGgsnwRap7uM209uJ+foD4jezH4iqctjkudtM5Qh/4JH5zjv9cKhZSCc+hnHQrZdokea+IxaZOD9eNKT3z7kYNQrhaNyTy7bEHut65ky2ph/kf2JegauAF43PFhWIeUvDOq+WGI39fpWZLcWEQMuVDfbfruopxrzPN4bVTuOpF2yIVvMR7Phnd+zmIRODk4IMFHzxJHF/nWLrwHgmssc3ULwafzRU4fWbphoc3MQa/2diRZ0Tobl6OZchaqvfQfNumkWvauwaNmGi6vfH16uebL61Hakb37ny/iQFxCoerUfoWCIZgzhi3CrKGAk5QYqrU0eIXh9URjErOzuUe8XiKQrExRG5GH1FaQbeHHo84qKbTyAoM6vlFbZMedhVrPYpsoggljiMDipPF8gd618Hvoip7Ulp+QuLRLd9lwsL3sjTAzEwtX1tVqZpmGpivT4yuT6OrMmfdHKB8wiGytKNahK4JIGR7af2WQHWudN+1Sd4zxe5zLgSsS4HV2qkk6N9PcGcrSVMHNnvCYBNn6b1cNSzxBu/6XdPX/2LxxOmP/JdBuPSDIn9g6rf2vUcFyAA7/BlR0m2OgXjIhZdyfdfYNDJGeUQyOUdayZSqnbX2Pr+l6HxWowcpt1MCpgIdf3FQLqwNSOv2SE/cHueL+rXAWT+wMiWgloI62wVR0fRodooFk9HFWzXyKirmJEnVg/Zu4csZNRt8a/P7QCv7XoDyvrTD44BTLUSqZYxT8SpOfxfwGIGHTnQgDSKNtuqkr/eVeJq5+VxjjSP/W9+N1j2jcE2Z9aYJZxemVYEedggRAAli4T1U76oktNCw/Mrb2QPQ9iBuwKqX43HtKc3N+EGOuqiPd2suvNsXTF0g17QKdJbbFqAwyKE+hvuaPK1LengKblBsjRdE85EkgjKpnwyHKuIjeaeTqB7AE3q0/i3LV2CZWK6OVJ963M8aJ4rDTjOadJWWA2rvr0B5ZqB2/ttVXTrkKwgpsIZOYGooEJfsbPGEWR5J3NVjRAmEGDZ9ynGr3VPJyZXhLpvVg1mQ3/lV6CF8uDdrQ/ibNld0VR3Sa69K5TltpbSILGhGUzK0GYq5jQ15rG7y47YSN9+zS49syulViZyW/nq+UfkubfrTaMzou8bYsIqSAsx40CnloW0oanA+VEBtuxSoPt8eRQQmQeKLNvi9JicUgKlEOiyid33OXgfyPuRjWep+jdyWsR698evkRxXlR3ulnI1XRCMU4XfCIW5hmOqcuzk3mDzCJYZunh5lbCf4YNPT7u1z/2n36AsOs 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-Chunk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tljdxPhcv2hJXZ75WP8R371m/5/FDUwwlrklhQ1yO++CMNqGEha972rNIGLYh3oWFoNoD+H+xJ/0mX70tgCAfXOfabZ3+dDMNUGtUU8oMIH1+V+mqgnCAowVeaOOBz1bdwGByI0fxtr5V/slQVTs26hLVSM= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56c8a02a-ba64-4868-6487-08dd1dfd65b3 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 18:13:52.9841 (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: zfzwmQm/nM6HS9ZnNaEjEKrQfa9JmHnhCoSftJEKjBVTvZS7oo2IvQwtCZeQ67Ldq9zL7zSMeV1s//DAlFKbrg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6653 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=2024-12-16_08,2024-12-16_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412160152 X-Proofpoint-ORIG-GUID: entRtgaQ_h9RTRDoR32SVALcCW_u2nBd X-Proofpoint-GUID: entRtgaQ_h9RTRDoR32SVALcCW_u2nBd 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(). Signed-off-by: Anand Jain Reviewed-by: Naohiro Aota --- 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 Mon Dec 16 18:13:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13910199 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 9480877111 for ; Mon, 16 Dec 2024 18:14:11 +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=1734372854; cv=fail; b=Timm2NBPu8mBrsWbYU7uAq0DfRcsIfWlVb66b/O8SKIFNStPaguy/i55TDNIzksXWeQSrm5osUuse6LDXV7r55YlehYBT9eD1uyDFn+k3O5s9RYgz4TPvAMnODgdLoK5iQ4jtun0J0kYzaBdoMppF/kLYC7tFdERmSjD1ZLwsi8= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734372854; c=relaxed/simple; bh=b7uPh5whV7MewalyZ7zR0knjGEdFLsevpwEqHQtFTPo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=kCiZwlg34iXvnioqFUhC2bof0tMO6mvmh21S2w/VBINHE48LfiR51yST+yYqcykGyMg5qNkJMcH16E6640GFF/fuqHLVE/msHRra/zBLoB3d8dgBuAVaDq4sslwBSkmMJZ2FbfyhiEGAtHtBML7gmXHDXmf7hy5Vnfw3LWGHN9s= 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=nG2HzTkY; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=q2AM+kRH; 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="nG2HzTkY"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="q2AM+kRH" Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BGHQhGx021710; Mon, 16 Dec 2024 18:14:01 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= nG2HzTkYDL3jRR/oxF0j2jGK4E72KLcc5lnPJZ+FvhIlCwl4mt+8Wp4DPaxeWdxx I8V1Huq2u1hoeFKQnDrXPlBP6GwDQSSMsf2daTo4FVV2vXtp5GU/J9aUG50b+qtm pXp4Z3Ylu5w0clAoOYvTnvFwnFAs41Ol0NTd+0rh95bE+DPQoI2zU9SDijJN/WJP vKNG4xGKwYC1H5iV4cB3VJlrV1ARU8KaJthYO9bLUcAjpCBHOv2MgOHqSs9VlW4S +2U++o9Y+8juhRO90pzPo9uV6prN/DeVnK2S9nzts79YvqSaUCuC3R64hFsWwaSf EOoBiiSIgYd2cmdH6J9L/w== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43jaj59tq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:01 +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 4BGHPFJQ032875; Mon, 16 Dec 2024 18:14:00 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2171.outbound.protection.outlook.com [104.47.56.171]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43h0fdmw5k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=lc1+W2pHNq6Eri59pkmfrz90P3fItpxXbf7Gg+AZ+I5sxCa8qKIJ6Y8n3OdKPF0zRnN84VJwlSMIElnKNOcm+URKqMthUuFbFkOAFL8gsPfpkYdANaqCgUV0RCaNxK6m4GGCdE0LLnTEaRY1OA/UgOf9vR8h8wKWutjQ4zo25eAnUuNe2f4AzHeSdKa0hGEKlP1fg/JISMFuLoYD0cYOBmwlx4HPmzEn3VVYGpep4lwMwvEEQW314MIHqx9kgrgHnieMpIW78sSY5e4AyJNCoo4IoO/80AcMZv8u1bzpX8GHDoirbObYBEkQmtcp+93QD12bNJDLUBAKwTbxIrNhgQ== 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=UwpYMiyh6SsHUgTv0mvjnyjyn6xLkGakc4AwkM1O2WZFT3Yc6QYLLlMBtYKXOyrJVBr1zhRDcgqf2qD+MphzTfGazGVzdEKRqDnpadDEjhyaqnz8KHyDdIi3luW3wY0ZS4rNL46E7I7Kod/K4OELUgcEGq+qcAsvZBZ10BSnfpenGjIvtsuW7z7n9GIxI0GUf6SJ4/g79h9MnleM5ivqllpnSTPv+7xf0FCNFcuSrmhJWTmQOBKo9JD2h35xjOsG05XhUaXXmQOfyxG/6Oy8iVaSC4inLRBC/o8NHQPWgPKLk+lC41GwP+9J4PGNHZtxojNLJPdTcFms3K1siCa5Ug== 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=q2AM+kRHK9goZ1QK1mQ/HKkwU3ZWhv/P78IlbIC32qJW1KCwJtN0qOvRL7oeQuRtK8ulY+Yr+/HI4UIrj8/o+Pyn3FqCy/SphYYbcJ8Ydfdv3N77REzulSTIxGXwwvULR80PhxaVWXNn0Q1WPFsTVTfao0hqydgQBx5lcFYJkm8= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by MW4PR10MB6653.namprd10.prod.outlook.com (2603:10b6:303:22e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Mon, 16 Dec 2024 18:13:58 +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.8251.015; Mon, 16 Dec 2024 18:13:58 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v4 2/9] btrfs: simplify output formatting in btrfs_read_policy_show Date: Tue, 17 Dec 2024 02:13:10 +0800 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA0PR01CA0122.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:11d::16) 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_|MW4PR10MB6653:EE_ X-MS-Office365-Filtering-Correlation-Id: a7ece7e1-9717-487b-3507-08dd1dfd692c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: RFrS1b6I+RceUZTImryk4etzkLaXdciCx4Asm6yOdzE0LyaO2JrroKC95cA6QiIIABRdzfPkMr0ik+1Pl3wDeckmqyRbO6wRJICAp2j8e/8Ik5e975TEum9cjk6oAdkcsh4eUSHA8CHXNnv/ILqqU+xkqZecy3uRdlwUkOC+4r5x9HBmm4wewoHgm7f9Wuz26IzuoGmxJih+EcnlVyEfmMWuyT+z4Ae20ubuxVNuxtexLwROSoYwYXeX3/23QbpBVA4CkiuQJjWjOoLUe4osBq0y1wk552z7mIM7zJXZhbq62u3OTDceM7WBVMj+txmFXiAcnpruT/DvOrb/S3c35LR1HRxtx+TabqwjU8wrskrccVgjP89UeObSuotbNrVIJBcDqDdSqVHkwsQgncumgkIAnviMwa7sbHYSQZw0yf36rH+1KeEO0jTIZgY2dPyn7NDIg5l+3bR78qcUJ2XUBMEU1D2SbyaPgwIilMD/QbfAD2N37Pdb7MEw3cboCakDLtMyBy/i0llB77ypN50rnUeNImR0pJ+JLBqbPwYQ7c0eIsYR4YF+da3RMNUzh1lRlKfKyVxw3cFv0OA83DxKFflqbb+W9GonStzwBo5IedoMedZCD2TGijNDekGNq3M9M7FuDBeymTS02vCeeMj5cxBtux5v3+OAG991U5/GmrOM3mprg6n773GuinMPSHvqhegMBZbu9V/iq1ArE2puduGpkYT0ECgAFgvCmriyrm7R8k22zrVilqU+BeugytlePSc36nTnSqaXrUhQpEJHKzetU0MdwiZH7PSjoyd2rT22Ye9rB5guZllgJPJFdge1FbgsSDENtknaL8d0auPXuw3AC1AvojWSoYzEbpRTssYJxTvoERK24BIcS7mH3F+ul27DzltvzIPqfBb2GGFVm+I+VvHYiBLHs71NVYLO5WOWPzRkJWsBxiKU2UFmrn0iUD/1QE91zgMweMH02+XBt6wu8tYiuGwVwp81AMWpknntul80pq6uqjCTJ4epiF8wLzuEeOJmpQ9508teNO6rVBLfimwiKhDQK4bI7R+7xMuo8DMc846oCve4ks3u8k46OtR+4E+mqSTyv9TDu44H0ezjt3vUPxu0jinqJXs2UeTZmMrOkYx+ECTVSmcJjqLuu577i+HUHqyRsM4/4BDL2yJ30lEZrD0jWFZRT86cEd1ESRXGm/lYpmNIbUoAn/PgGxcy2pL2EgP+uaPz9vqsJCul7d1YIZAKevLj+7wRWXHGjPPoBK43HB31UaoeqGKh9zkmeMhcLthJPkleYSTw6ZvLTY2QGsZWYf3EVri2QszGkBWD3jVCKNc1I87OF7cSVkDFYDHmb4F8RCeHDrzpb8tOIUB5dbwVI/2ogthHPXWbnCBPqrnQ+7RGUnmYB/Cs 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: BqGiqpQ/nQgt+Nljrfv6ERWyG1ySTw9b3TyOGeXWaRexIYTY7zh9yKKhmZR5CeMgVOeoWe9KnibAxAsc2To0aeHgat3ZZlezD4FvtY4h82deXU+WGBXMLYNZbUHa8ql8rTOJzU8msjak288Cguda1MMK/VzMaPI6TXg4cF+ToQ575GfI1bhHJWZeLxx1orjZ5xhQ29M70BbVZu3ePxjAQ4UTvUADf1Rr1S7EKeksJG45kXa84P2+N8j1a4XqDkO6Pt4wmD0HQkdk5lQvT0hebov5chsp1Z1KwT/cgWT8MlPSWdR7TbIFUilGYslFXW0Csqrdk7tdzjzQUXC8+r9EJwofqZ+nrJyaNNK25Ufg0z/OWN+uLpyVG7qy5M1w+s90pcPADBgEzK65Q7+BnvAL7mP3MwIXP4ankV2ozXWGsNVTJewABNYZ0v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3Oa92Ummn+YquBn3iBcY19fBm52fk8mU9uTlNeOCMBTd/suZ8YMWI7OD3wa74b8bCS5rE5oVeRiVtd2VH8HBfNCzP/qR4P2z+t X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: ZqE5/u7EdQsNy/rv84PZcsL4aB7w0Enp22myzinrV5TwrQPry4UBCqzENjC11A+9vF9WHBIjSW87ND3zCusM75Fkuqu5i5SH6wymvWfIJw5QNBT/vLqI6M/z2n76i1ivYsL6BEesDR5Q+1SDTHHYd40selsnax+oiYIJrbeuvA+XB6ZORXeiaiSWlInuuytvpMfbG3Fga44HuQPB743GIgrciTsf8MXI60RDHlUlai23wWRBLVtAyAEEtaZmQaL1Y4J21RJgoTUbh/ujXqlEzrrowd/OOmvbDINJ7TayW9nRvLBuEkijNjiXkszIfk90leB7sYh+lYRwsBkU621yN3Txq4TzL40Pg+cB2X+eC6nOzpmKjOyV/5NW/JNHH7ETj0ri4iuNsvJKkfqL/kYKB19fx9qzey7/RrrTmk3dEa+ofR0l4uUwsw9i512/UACqOu5Pm+Mb5YYtA0fXwslN7HfPrnC+fT5TK5clNTq4WFlDDOiYRa6zvdLWZBUlb20K7Ma8c2KJdQrjZglLaQsXc+TFXX9ljXt+fzc/vEPcpaJB6i7nXtcaS/VA4dUc6GONwGmMriCqwjlFK87h7DootI2HNUtp3fJ3046OtBjBxZs= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7ece7e1-9717-487b-3507-08dd1dfd692c X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 18:13:58.6142 (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: JBx7gOKtgWo5bLp1B7bO/NnsxKy764HqV9pcFTt/bEXAgBOhMno6slHWPP7PmTKBY6OUkx7KqI4dReoPRsneJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6653 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=2024-12-16_08,2024-12-16_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412160152 X-Proofpoint-GUID: Tg1IedAr_PMV-hhTU_eMjca_p8sfz0dk X-Proofpoint-ORIG-GUID: Tg1IedAr_PMV-hhTU_eMjca_p8sfz0dk 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 Mon Dec 16 18:13:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13910201 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 B309377111 for ; Mon, 16 Dec 2024 18:14:30 +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=1734372872; cv=fail; b=hQ0GYgd7dWK7qyJ4Pk1QkYCXn1kjJSTyTQr92l88i8ZVeLAzYnb0GHlko8XRsPN11o17jGijYlFMaYq2JJH0A4ZqqxVJflSoHOIa7V+a54MAAlvswar1m8bQsLmPFZYjHiVKb9g8/hh+A9ST+ZicKpVtgz8BDvbvHsqGs8TrkuI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734372872; c=relaxed/simple; bh=catKPpZAKNrL55SbrKeY+XrctNzcXbVIuqBjUzgvLqE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=t7XEFF3e7MzjLiiFbf40Upe9joX/EwHcpue88H1FEm1kxNs09dC3XZZvwlIe6fSDmMTnWnty5Q7F7Zik3nylxNAanZwVatg1ZOUkwAfQCqWw0qch8BcYGL3Ij+EGOIcMJs4dCmWvhvfMJo+DDAIJ/2iwdnSRddV2wad5NqTH1us= 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=PHmsH5X6; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=jgclvUK8; 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="PHmsH5X6"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="jgclvUK8" 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 4BGHQilN017622; Mon, 16 Dec 2024 18:14:21 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=mjL7mbQyMpDTrW9c4b5Nk3TFldFk9/wesL1py8gk2R4=; b= PHmsH5X6eqYPOEUTOV6OHWsqqLVZZjVM7IoIGFzIfIf07OwXa2lGjJE/VLe470vm fcvtkuXHxc1InOYvzRRbDv2FPu2V2h+nJJCUKIYZawq3+ud1sOfZlr3BVp6L+wCO BsvjL/eReiHp6D2qMymssncWvz5fLuV+lQzjFMrG39iLPFYRUwSu9rGdazaoUz0+ 00MrG5xs3JHKDuI46pmaAmFbtS2b8B3zQsMPapn5OY4xdSYCzc/ipx2HDNaCThCG iI8KQri0a0aSvqgACISS697+hkpTkBBCddDLtrxVdO11RBJJFMGHpIvajwmeU4nZ ageUqwQvFJzKaVruY0+eVQ== Received: from iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta02.appoci.oracle.com [147.154.18.20]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h22ckxtq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:20 +0000 (GMT) Received: from pps.filterd (iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (8.18.1.2/8.18.1.2) with ESMTP id 4BGH0QMl018267; Mon, 16 Dec 2024 18:14:20 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2168.outbound.protection.outlook.com [104.47.59.168]) by iadpaimrmta02.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43h0f7mpy8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Dkra7QP5igdlOArN9NLjyxa6IICEKz6kEP7B3uOChoxrGUXOknHQC327RxZlo2VbZ6rnHGPDs7rmGhP7qYro0TAe/4VM/9goGWrVnf3R02cvxN9QCKGxIFXs1O1ppx5Zhcqz0JdJZ3mchI0QmK8pnyYzuPsn0/nLNamIGhI8O2O1BG1mgXjWlb0Jvt92x2HhO2Vfskb39nwY//6A/QsFlyUKUjqBGEceolqmnZyEcAd2M5JblvSCXV3z4PAy9zZXp/x+e2wEwdkf2169UdweavEB3e5dn6vWbACSvsBgszHLHRafByVi+itwDESOwN5Cfs6hCFooG5Tu2GXcpPI0xg== 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=mjL7mbQyMpDTrW9c4b5Nk3TFldFk9/wesL1py8gk2R4=; b=i7HHcR/uc3OsadYxSVIQKfMMqEfsBeXEgyRGQgqs4gYItAw3IbxyHdxkdutRNt/o/gu9gzaM3kPkxXJqzpN2RcL5o9JdS3PW7I6L9DoVtqjjqYQX7lBcteEAi/NqTRZ3D+wYF6DUELmkgXPtItRjAa9qDxutANDSvv5oLfSbKeY797WGU17PDKrtUFooflB7XihZOdFyapDuIoKLOcYnQfepikDSxMA+PE2a+1bmFYlwpMjDIJw8j3rHvJHYPEqV6oUsj09kBEYzoTHUlP9CL4a2gVNX6p6H+U+bBvpUjnphU+LWkBUCcN12HcKMXb38en86UpU28nSfBJUmt/IvCA== 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=mjL7mbQyMpDTrW9c4b5Nk3TFldFk9/wesL1py8gk2R4=; b=jgclvUK835PESngkzl1bMS/F8R2CcofHxTtLvO3/k64h0EhwLc0jL0BMid9JkEbrbJLDxRWKh4xlyCEJURFDrZAFwwgfpchwToz6V2Ej0guoAuHVj26ugMDBN3SXOTJGkF/InugjeWchQT8yorvdytxJKAt/1G+5QD4/o5rVUlo= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by BN0PR10MB4919.namprd10.prod.outlook.com (2603:10b6:408:129::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.22; Mon, 16 Dec 2024 18:14:04 +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.8251.015; Mon, 16 Dec 2024 18:14:04 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v4 3/9] btrfs: add btrfs_read_policy_to_enum helper and refactor read policy store Date: Tue, 17 Dec 2024 02:13:11 +0800 Message-ID: <9fcc9f01bdab846db231b427f98fbb3e9df7c7a5.1734370092.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: PN3PR01CA0001.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:95::7) 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_|BN0PR10MB4919:EE_ X-MS-Office365-Filtering-Correlation-Id: 48e4aac4-8409-449c-1a78-08dd1dfd6c4f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: 2mS8MWbMmlOYRrnlbpTiRkhUXVC1DuIUdyNvgAqbQJkwMpmUbMPv/LkuHFSkfdnf0shV0hYPj/I+mnQhKcYlWCRWfKlVoY6l8RmY2JylLXOxmgosHzdOyHtu9LzLHLeIPltABHM74qnV5CtCmeuaQJ1GhBmC+VmOof8CUjlCeWvgaH3znLWtSKET2p1CJYC3L0U5px5fOzC3NSA7uTYa22fMVAYmHKO0YKCf8yhRvS6LK/QP5grPFteHbdbzVdxBp659QKGwfvW60VxRYQxHxjeu5Wq7uXnBeOvu35WvyeB7VS2urWdkpXJ7UM7hLNSzGcNo0lYWI3/imfgsxWh1qe6ROw+rzBJv4qtb8muIV+E1suTa3fq0pIkR6iQWDbQkBL3TxthAF23IWPUHQNIJ6XJlVCNXw0iqp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706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: E7MBYiNpkoebnro9Yp3Uq/FieWpexxqGXBxb7+13C4KLtyQcg6+tEq/XY9jXOUn9gCHwuVL5hhjiDdjuH/PujwrZbgikjOuKeD48aHo7sLThbSwVP/OWm6YYO2uPVG/nqG3hE2NRBpMNpDaUa5M+vc686oUX0kssUFy83Mi1jTKguZ+p+V74BEE04t6SDO696xUg2H/1iu46gFKU2pnUJUXvMKP0nkYL/H5hNhhwYK5xx6OHoTboAndr9wliVuQGjoOqgtk/xEPsRw8yObV9cvaFGyezZlAde+yKuHQ3U+2AkgEX5Rf+CNldq6kFRf/YeWzendyiN+Q/c0b76LxCXXKtHvKg/C4TyzFLsTSFQIiUh+c0dEUqXxyfxmfzlBDQsNeoynzV/UG9Wzi7hmLYnJw6x/lHjJ0UwNmPDCVPAKdVNNh4cIxaaXwulhDfdw5+2xIYr6Q8Kmyje1qa86K9nn4SbiWCR7NJ8g8U52ouI14g/wKQ6Vho5z+2WdeNVbKRc5nKJF/lKFmzD7BIV18fpaQbhM4MlW0U0NaP2/UsoL1kkf+zf8US6e7SmekdxpMy6WjvLA4ksMx+xscvdl47PMDlvdNwQNrR+s0MM39g34Tmwa84leVN/DO4WttxYz+BTJoGjKiLV/2CoWh7L5CbAC++5hlpRbJOzYZWYtrlflMp2im4pFxc8ywhTwmwN82vgPOoLE5h/XLDH65hHwjWRJKYPOdPkiPVE02hp5LKahKWGTCJUA3Q1ukqDNJF48GrALUBi/IrYaQ/KJFTSVx7Gb8kWTcVBWDP7zhnuwVHGYkk+QFuYzopKQrcO2LwCL0fscP4HndNjvYKePIA0z1wD6fJVHL/Qw5DV+57/CXBMlKd0m4zkZBRSNRzdQkpe4JPCP7qPmrZ1bHn1ylOIh3HkfRwm5qSg1eXJANzwnF0fu609P6x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I2pOWVPxKDZ7sHr774ReXuGblkLRZuzvSVCNh+yV3rjfG/36ABEnCFETXku9QllYv3w9f7i2yRJtDJT9DfiMC7o8Ujb0qguKpmSelhtoKFx7KYbdGO7IR5P7BVEeDESEbVHNdStIxML9kB0dFYzgMYkH9R93ecX8hWyfI/IR/CEYeEewW+TI87zEGypXvI+Wmh4sJFF9OXVs3UcV0hbj0kVNETsg3OURBtskOKmg84i/Rx2oI/otjc+AvhJ1tL2kQY8Vmw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 48e4aac4-8409-449c-1a78-08dd1dfd6c4f X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 18:14:04.0991 (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: ape7qnfgvEp4infxODEXijFbJV5afcU7Mlvz3C0Us3d4MNQKucQ72D6IEXc5xl8yE6FGjwgBfHoOHzTLmk+U8A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR10MB4919 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=2024-12-16_08,2024-12-16_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 mlxlogscore=999 malwarescore=0 spamscore=0 bulkscore=0 suspectscore=0 mlxscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412160152 X-Proofpoint-GUID: r9tlJU4PA16fSigNfdyi6SWjzlOHDKRX X-Proofpoint-ORIG-GUID: r9tlJU4PA16fSigNfdyi6SWjzlOHDKRX 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 | 46 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index fd3c49c6c3c5..34903e5bf8d0 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1307,6 +1307,30 @@ 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'}; + int index; + bool found = false; + + if (!str || strlen(str) == 0) + return 0; + + strcpy(param, str); + + for (index = 0; index < BTRFS_NR_READ_POLICY; index++) { + if (sysfs_streq(param, btrfs_read_policy_name[index])) { + found = true; + break; + } + } + + if (found) + return index; + + return -EINVAL; +} + static ssize_t btrfs_read_policy_show(struct kobject *kobj, struct kobj_attribute *a, char *buf) { @@ -1338,21 +1362,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 == -EINVAL) + 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 Mon Dec 16 18:13:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13910200 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 9DEBB77111 for ; Mon, 16 Dec 2024 18:14:27 +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=1734372869; cv=fail; b=nn1+B1vLNsyu+0FkXQf/EH+m1vjyd7dSDvAT/yogT8dPJoIatUCyTAiITgMxxbvJEpCuZfpnh3zBwL86OTaDXvqR1aX0n91FimzLP8RQaGJCBDKBoBOwvAegZQl7tayF/ocY+QvgHisuVHGaLAAkajJtFnbP7eXfQzpNA5oWHXs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734372869; c=relaxed/simple; bh=3KLemDsLPlF5iRlc2OmMQXdf1mgTMREERAuHu76nM+E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=GfiGHgNi4dJD3EsJ+5PUoS4V3IQSULiRgAodVRWryl+1zeaNv3n2a86gCz5vEFbnqxVTPkGT/ypIijk5sQlU1pzSo0QPs8bpfRqHEvf1KgqeZXuaDyH76v0wqW/lq8RHfh3v7biY6dvuE3AaUGatbxdcBf0jYwRfq8TWFw9UIoc= 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=dnQQm8Gr; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=v3Ul3Wy3; 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="dnQQm8Gr"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="v3Ul3Wy3" 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 4BGHQkaS015201; Mon, 16 Dec 2024 18:14:18 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=2jYes4eMXhRr92kjdVgccx+y9tEC7xLjTFAqJmxrZF8=; b= dnQQm8GraWHfekW7oKxr1ZV4pNWuUkwvQnRVZQ7RVE6GfCcofjhqktc1aiE2cFq3 LB4tAd8qf5bllQUQhVbtUXP5kPyB96uTS6//PhCmUvxr5JApzP7ydZygOeQz1Z77 jI7F0rtB9GJ5tNA41VNfG+/YEj+QfAgRCQsUbJY4X3JqR6uCCxHyML/4/ff9wmVh F9F6nEsqa4WgYvwU0B8i+8IP3K5bQFSJGYjA2ZtAXCxL+1kDVfI2qG8lbaHLZ9v3 8387DQ950q1CDh98kdFNCEQHR9Lnf0z17X8thA4GuQ8saZ8YTz56B+hDicrD7de5 Id3xZKWJAGzH1wCpK4azkg== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h1w9bxc2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:17 +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 4BGI6AxV000562; Mon, 16 Dec 2024 18:14:17 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43h0f7m3gx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=GUozlItNESZGP5kxtUfvKnlGiNNA4234IewTxQM3sv8Tz+0mAPU0fPYHmYbzwzviXlnVR9vFIdLdDaiUML1ljSQ0X/PMvl7K+GC6W1qWxZZTeN6UyKLmoNbCOmslK8+27r5kf7OZKB1wjsxBKzWuEKPIWnOG4AoNLJEmfiCwDoUmHQb4bOUK+Gc7tJ6v+2lt/umPvBKcww1u48OTRn0lY5Y5E9ok8EAIH80j/M0ZDotYQulZmGf7m5tdEA1XvcbTxttVD0u+XDqJZJmlCYFmiab6V3Ad18VOpf0C2Dy9M/l6hw+WcShatWqJpE7JnJSNI4e0SkWOCMS/fLaHxsQuTQ== 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=2jYes4eMXhRr92kjdVgccx+y9tEC7xLjTFAqJmxrZF8=; b=k9XQ1CPnN9sc4SGaJXfQedbt6GZIbmpJC3pVfjNm2rEvEDC1af5qm9+z41Gq3XGs19tKkuOXHaYXhfCU5ODvOCUZvXYyArul0QG/pL5ztj4jCwNlsTxT3bC2mQ90fBpkkAZ8qU+M44IinbdNpQKoEItopPZwZy2ZwnkjOFSp3z0FSbfAD2Sui2teb1Bivk/1/sPg9eSj7jkDWhp16hEDornNNm/2ibqCD8v013F4GCvExdqbBy+akPjle7tW5iq7w2SIn204vsADGnNiMVKGkeoCPnCFcQClv9xfdfYoFiuBnLmNck3wauODHVq5TejRP/pAowi6bn9ajoGE4TBLpw== 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=2jYes4eMXhRr92kjdVgccx+y9tEC7xLjTFAqJmxrZF8=; b=v3Ul3Wy3j+sfIQWfHmAolloXLsrOC5qyRATPAXQwRcnheu83eVeyK2EOIAdzFSrgR1YkifEqku3Mlzc/IiRccZ2Vu14wNPM/bkVOhzOF/OsN1jqnbYJqndgtBkmu3axjSgixC+q8Ryxx1FUMZXuZELsXefT8Oi46kYzCIi7lXt4= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by MW4PR10MB6653.namprd10.prod.outlook.com (2603:10b6:303:22e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Mon, 16 Dec 2024 18:14:13 +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.8251.015; Mon, 16 Dec 2024 18:14:13 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v4 4/9] btrfs: handle value associated with raid1 balancing parameter Date: Tue, 17 Dec 2024 02:13:12 +0800 Message-ID: <693ce8f83742af1fe22cf6adfc819379bdd275b8.1734370092.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA0PR01CA0036.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:81::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_|MW4PR10MB6653:EE_ X-MS-Office365-Filtering-Correlation-Id: 83c0e674-f43e-4471-2717-08dd1dfd71d3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: /AQqSnLdLPTFpPnAHGAwiNCCTZHiMl+MAlwyCSTxNmggSvzdheTFWya+3V59QjXcu949n3YdWKO9sqxdK00GL3ONuRw6hCcYOwJCOaUp3iGozNrBdOwkEw6H13a84Js6EqUJqy5W3yak49sNZ8qrtVj1Y52zMqRGOs03U7KtQK3f9ZRQvYvSXU4xUEaiFglKk/CQcQTsisny4fDwrXdtHEsnUUNqZg30RdI27jw2wToOWyPijTSY5Vc3yZn+0W6/RBi5X11RVsh7xpXLNmgG60BgRA1Oda9e1vY+l+rqYKJsmO153N7MYEvTERY78vDXzcVgY8EelkSl2Xl9VGbB4vKB0bUabiADix0BVYhQD1dedVlhicXx8CfWzlRnSP5/McxYEZMWVWSCjZlPiGP1jf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PM;H:PH0PR10MB5706.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Wd/nHTVUkS8naiZrxUYqmA24ej3+9aAkrLsloYZN43gAPXxKmTpvWyEvK5bOOf51LDv24VPI5U2/GgIiLeY3r8OCLM4K4kntceOmQc/Nc2Wm/8IeXxu44LxAfh+TxGG7X/0TdLhxPaKPOV0lK/m6goDoC88WE/Z5/tpfU6cjaxc6VpS/McTfPRJHy6rP/C2h5iWjcw/Ut6fLHXhFlux1ERC4Y4E4K25ax73Zm5O8if1JAdXwq7Kxrf3cBhrbjtcqessYyghHwZCMYLzKDQ9Qw0eL0vA21D7ZPPhpxC33ppekx1Rj9+/Gzf+OKTFhAkeJCceTZKlPL2IIl7kkz+NZwPJRDmk11PHM2zW1eSVZ/nLVaxvUM8U0ZSRdTnmTNhBRQJN6ifZhGwjKhbQmnb14fJlH3pRsa26izJkeYk20LbJcOfHtlqlpUdAujaH4u9y40j8H+EWBOOGv/9DyqdILf/B4C7s/Ia8hTYDSGmwMzIoy7LGMSUIMynVn/vAExeBfcOiEy7GarhIg+f9Y8gjSvV/cR2S8jnDtqIqGtM7WBVe9bPUL30DvKSkeT7ErtU+y1OVCLvcJm9TOMN81rXRrqZUtCxan+FlIJpRsO3W8m9wdsDDx1zVGTPxzbrSc2Smi972Gv8gns+QvmwXI5kDBbvdw5J0qys0kuj4zX8iiLtUG36D62oYhHOmOShDeGNkZhC1AG+XGBrLGXaFhbHJyauBB8VmdVobkEb1AZ9kzwZ1zJwLC/QiggsqPjGqjZ39FhsrRLAH22InJ0ncizBWR37zSm3UXQykDap9IWHnC18qBx0YWyL+wY5WNXDU1qmGNZ/BAGGFQ1Vb7NCwW3JyrloCjyRF9j9+HgpeAomY+BfAVS71HeQpRZKf8iw/ukWa4oEOoG32YyQPdXrd5TPCEETJDFu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ZkX5qLJ9sntw07qjYmjUn+nghuvWcd7MQu5QEDDz/1S7h9KWIk6+jphMnWKKrhUyqRSLhvroCQJC8hCXHUnrqxYMubNCdfnj5ZjiwbvJZNbtby5/Tqslk4+Vh4gtWf2ZZMarDfujRv0IqyAYwK55ptjmPON/C2fMW9Uau1uauTDTgK0i3klZIBTvNq4+P2i/c7SDXPLVMk1tpyCBW79ouB/yajjVYTCzv55iGwS9wCnPyEggQmtIBHzErJ3xwZwI9/2TnfaUTMHZaywYX1gyq3yUBx4eTiIpNRvpZMg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 83c0e674-f43e-4471-2717-08dd1dfd71d3 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 18:14:13.3257 (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: 2ey3/3uGv4GFcMMf2+RxFXjzmCmSDeknyuvMeRyZ3KYy7M0rT+Pho5limAHR4ftr42dGZNsFByZp0RMJIpZA0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6653 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=2024-12-16_08,2024-12-16_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412160152 X-Proofpoint-GUID: v6MndPaJOlZMdiSCtEigtUecbkKv_NNz X-Proofpoint-ORIG-GUID: v6MndPaJOlZMdiSCtEigtUecbkKv_NNz 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 34903e5bf8d0..9c7bedf974d2 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1307,9 +1307,10 @@ 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; int index; bool found = false; @@ -1318,6 +1319,16 @@ static int btrfs_read_policy_to_enum(const char *str) strcpy(param, str); +#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 + for (index = 0; index < BTRFS_NR_READ_POLICY; index++) { if (sysfs_streq(param, btrfs_read_policy_name[index])) { found = true; @@ -1363,8 +1374,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 == -EINVAL) return -EINVAL; From patchwork Mon Dec 16 18:13:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13910202 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 197FC2054E9 for ; Mon, 16 Dec 2024 18:14:30 +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=1734372872; cv=fail; b=ABI5olcXItdW2tjqYJu1pwdVLIMkDsdzrWgOmyCoDG26PENpoyhG/pO6D5QlCpqsSZS7om5JFgjtXIzSeGICpI9cyr6ssytR+WSxQ8mKctkvDx3fdhg8kD8LGlr97QogvS508QtIxrBU7n2Ucw7HKAMlpI+FLRI1WSOuvT8MkqA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734372872; c=relaxed/simple; bh=SgcbRuYdkD3XMMt/ZiWy9OrxJsIVEFQmTotppzu9+KI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=JZ09aHWuHEbmqCY4U8mirT38wiPbxFGunp2GMH/GPhIQ0P4marJsGe0QNrexvVrOiuPfzW0JevsFcY8UAZ83NQhPyx4Z8aR9b6e/d0mle/aJQF4mCmwo9g7zhSRrpa3M5AyS6vTJcv0hqJxlK07TCOl+bbJv6SIVmOIaZ6OUXAo= 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=Z6gxGUZM; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=L1YpnDyQ; 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="Z6gxGUZM"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="L1YpnDyQ" 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 4BGHQiEZ017639; Mon, 16 Dec 2024 18:14:21 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=MILC98Mrjy2KCnitCb/x8NaI95pCfbn4EPNY3As8Lew=; b= Z6gxGUZMuZdzwdygt6QnXf5EoH3pHJVCHHm37Sc7m7UxTsPDnXncbav9xu2s1I07 DDR2ctbD/TwblWtJSVVE8650ZBIzu2fmT/V1zXduTNVLfs6aMJWbjehh+FAO1xzQ UkGWJqhMR0XbWxOkQFdEuLJfp5HMLPOHiOW8tnd1KsBcSujBNMuZjb7RPABtNfZt 9zhtowVjwphYxFTHlTLpDi9z7BBOOC8Zos9dNBPg/CCFYcpo7tP+PgYeao9SPKSE xQmnm/oSDTKXEZcNn1eVo8BVWSPiToVChj/onntYmCUKmy2XzHydbERk3ZyCfttz O09j/uAkgQWN2q4TItQu2A== Received: from iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta01.appoci.oracle.com [130.35.100.223]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h22ckxts-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:21 +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 4BGHLoPi035378; Mon, 16 Dec 2024 18:14:20 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2168.outbound.protection.outlook.com [104.47.56.168]) by iadpaimrmta01.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43h0f7dgck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:20 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=nLX60jYchc+IzDo4RQZu68wbFIcE75olqfIDpgWHtjS+Dc+dB4r7eNU5XcJUF+hW0fivDcqJcHtGkFjafEZq/+JWDLQGtBdsjkALuz4G8a15X2prv32FGDlpD5HoOqcqi+vanJDFhy0AL3o1z0WhTKV/eMNhzzxWM8cTR2PFRSzMlvLAcaPj/KqQlEqK9awtTaHs9dDFvANJOMrtLrr4yuevY4aguJeD/gtp0eg/tlpNlmr4ErvU4mVOSSdW1bkGY9ciUguUD+V20dEJOJezQm09ls9sf8SiUy100TpGP+2GFli87FY99Sey3qwMpxIVT7BN53xqtWW33kSRFWquUw== 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=MILC98Mrjy2KCnitCb/x8NaI95pCfbn4EPNY3As8Lew=; b=QB3y8a4xqeWkmxveeCWIAS/V2hYDk3Q2+XFOLjt4YbSUfInImAdHMAQufpIVJSTBLcrsyTQU4ab0zH7qXsk1RRYxi+FVKWz1Rotv2ezu5M+YgGsMMitJFhEDJzEvQgfGF0DjgyQz5Z6sIUUrQfR0H4NdWYmzXO/lR4/mALhz+UzoITkjzfpXyLyj7IY4y2FRMi8NYPDPCGtevlMxO4LKF4COMUYWdHs5clCtxTzKj6myTd5mEiGdWAOvlPeKqyIL8Jh82FJTTb7OeR77GEXAY4qiRvyQk95gDXcmu4VGHOyj8/gt6hInXF3Atw0CHp++58kB7mKPNJ3//0828MXDjw== 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=MILC98Mrjy2KCnitCb/x8NaI95pCfbn4EPNY3As8Lew=; b=L1YpnDyQs7d4uO8sdxknrugbiXGUBqAokdAZXKygljnKBlIqpvrr/kR33ZbmrbuUk6Lv+UIT6o/9zMzIp5FxcYSqVWrvhxJudxjosYsLrzhJCmNh/gCHT2wa3OM5NpQgLsRWH6Nut/1PznW4zIjoh1BLOMxC70X7TZcO1HgAX7k= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by MW4PR10MB6653.namprd10.prod.outlook.com (2603:10b6:303:22e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Mon, 16 Dec 2024 18:14:18 +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.8251.015; Mon, 16 Dec 2024 18:14:18 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v4 5/9] btrfs: introduce RAID1 round-robin read balancing Date: Tue, 17 Dec 2024 02:13:13 +0800 Message-ID: <90934f391bc1c9772f9e3a7902cf9d04f3b0d14a.1734370092.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: BMXP287CA0020.INDP287.PROD.OUTLOOK.COM (2603:1096:b00:2c::28) 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_|MW4PR10MB6653:EE_ X-MS-Office365-Filtering-Correlation-Id: c76f4be5-1471-46db-36b1-08dd1dfd74dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: kQivxDvJQDJXBvTxWrxMuRMTZ3TbXEsWmIVnhgmYGhKbhbsXMYB0SkDapAvlJVrS1KvT0zxQ/tZM4lhlX1IZc5lqIgxuO6UXR8i/QG8rW0lVECebuB15jMeqvNTI9A/b+svSNBigvr3klC4JyCNs+nefNi+iX5IAb83pWy9++rBxG5UMrwYa7r5vpSgDxPQi02X/e5H04ZBay7H9Z+88PqLscphHPY9u74n+hZFtSZ7qFPg7ov2FvYs5NUcK6IYjM91vFaz/hX8N000eALiF0speE5Nua2+MqX0Bmm1bdcZGqrr3BIZjij6t24TK4kHsmgtsm0X8iOtYmE5tluJ+UDNrGQJlqyz7IAORcCjtAIhs4kziZq9q8ui30u9Di8FC+X/sbxTrZlf60ZKoEsjhd/yFvGCWCsEiDlAEBuSR3iJ9NYHItdmbU/USjdQd24lezxrT4jyAawiBRqpt+LL0VJFGgFybPdgF82pStqE1unppbZFcn4lxbcB69/TbC39S4E1/Vd5mr0g2UU0KGTeZOucHgHr6NkaDoI3luYfCDbS/q7nHVvBXeoBen4MzEtiqX3Ufn2n+jQZc0DY5cdPaQ2GHb+NmM+yeCyic941KdYBDVDdaYUXtkpNodTgpO+Py+ipKJTc6XJec4U9oDvwKJB1GgKQtjkVIfFItj4KKJpg6hVWJbwTxxuA+a1oNc3Jnk1/EX3laSHIwpRVbXcyhdSlMQD6TFMdVXvMWwZGOvnuNGRVM+nIn2uJdVbiQlaeHBwSviZ6ICtd33tJ4nVlPJ4HGGGZqcvOHUL7pkVBwUfalOzpdC0Zs8TWRJMCNZ92V/KsJLO2LcpkWDpuEcJdWL/vi6vXmDbspDqBSULlATCb6bMiTL+9Aq+pPoHy+xNWMKPHxVemcRPbpV9xDuMvJADgHQtehiuvdB5gxRP6C2F0tJOI9by5tH7N1lLDf1pEcyaU5mKrHFBZCNKAbS2pEcs6oHdVNPj1gWm+dWlgAHowptKsJxOY0l2U9laf8jhrkbNdTR5MTlB5yMd9B1DQGwhdrgTSwgtOP3FCa5RaLXOU6JMON+Q1eYYUOZ2tQEPVijy7tnkYQjk1iGOkafXMRPZhUePztR1FRl6o/oebkiUTNU6D7ybAmtxg8tnMAEkZCnBPMH+p0UDOHxwoH/YWfvZamMOjd7F3Fc1g7Jk9dvni9l/zyQqe3HSoM1YERhsnCe5+msRUobaBXSwK6zrKgZKF3p05eBbW33516yhSTCcoaHFmYHkkVCReb8wpAk5y3q8L6C2e+vLJxGJcpjOeTm13h6jDkkxEKk9iMNGqNhutJXKFOg8yoWEop1YAzmvfrkGANVE21DZvb5oHTC4mTA0Scqpy4UxnU5YUVt56Kj1oPSZOeENhDkP7xirlgMqcx 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)(366016)(376014)(1800799024);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: U6dvWVxZb+TEkvGmlXvUCoA1JsSJTRQFtAmAlMCdINdkQMLhgcKOeYf8VPo8lxjuxQkL8URuNJTYZOnRpFvwCmPCEotb/W4AR0PvUi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vKHRwnEmtyBeYwlVBsibw2O0eGE= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: c76f4be5-1471-46db-36b1-08dd1dfd74dd X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 18:14:18.4360 (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: RvNbDuVI5rBiDMIt5VTCJrXMjA3YL+0rhMQAl8PbyIThuc8BOUyF5Lz9//vhSiOn++4DN84PbZoS6u3CfywHFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR10MB6653 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=2024-12-16_08,2024-12-16_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 mlxscore=0 spamscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 phishscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412160152 X-Proofpoint-GUID: x9IVo_lq78uiWlzBcZyR7Z1qXOzpiRhe X-Proofpoint-ORIG-GUID: x9IVo_lq78uiWlzBcZyR7Z1qXOzpiRhe 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 256 KiB. Signed-off-by: Anand Jain --- fs/btrfs/sysfs.c | 44 +++++++++++++++++++++++++++- fs/btrfs/volumes.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++ fs/btrfs/volumes.h | 11 +++++++ 3 files changed, 127 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 9c7bedf974d2..b0e1fb787ce6 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) { @@ -1359,6 +1364,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", + fs_devices->rr_min_contiguous_read); +#endif + if (i == policy) ret += sysfs_emit_at(buf, ret, "]"); } @@ -1380,6 +1391,37 @@ static ssize_t btrfs_read_policy_store(struct kobject *kobj, if (index == -EINVAL) return -EINVAL; +#ifdef CONFIG_BTRFS_EXPERIMENTAL + 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); + atomic_set(&fs_devices->total_reads, 0); + + btrfs_info(fs_devices->fs_info, "read policy set to '%s:%lld'", + btrfs_read_policy_name[index], value); + + } + + 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 fe5ceea2ba0b..77c3b66d56a0 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1328,6 +1328,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; } @@ -5959,6 +5962,71 @@ 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_fs_devices *fs_devices; + struct btrfs_device *device; + int read_cycle; + int index; + int ret_stripe; + int total_reads; + int reads_per_dev = 0; + + device = map->stripes[first].dev; + + fs_devices = device->fs_devices; + reads_per_dev = fs_devices->rr_min_contiguous_read >> SECTOR_SHIFT; + 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); + + total_reads = atomic_inc_return(&fs_devices->total_reads); + read_cycle = total_reads / 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) @@ -5988,6 +6056,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 3a416b1bc24c..b7b130ce0b10 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -296,6 +296,8 @@ enum btrfs_chunk_allocation_policy { BTRFS_CHUNK_ALLOC_ZONED, }; +#define BTRFS_DEFAULT_RR_MIN_CONTIGUOUS_READ (SZ_256K) +#define BTRFS_RAID1_MAX_MIRRORS (4) /* * Read policies for mirrored block group profiles, read picks the stripe based * on these policies. @@ -303,6 +305,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, }; @@ -431,6 +437,11 @@ struct btrfs_fs_devices { enum btrfs_read_policy read_policy; #ifdef CONFIG_BTRFS_EXPERIMENTAL + /* IO stat, read counter. */ + atomic_t total_reads; + /* 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 Mon Dec 16 18:13:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13910203 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 836DA207651 for ; Mon, 16 Dec 2024 18:14:35 +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=1734372877; cv=fail; b=VuX/PzRTVSgpOXU1sNTgn6R+I7YP/uHzrHzIJF753vtLMNnGf2HxRdSOXZh4Z6V7EPWbsDHmkWvwq56PD6TZiD95DWw3gJptew8jsNtdJEqcFE2foTqS2nMI3agu0OUhaDU15S5bhwKsyX0YVjvD+61GJrH1doCJJdmcDFLZMrI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734372877; c=relaxed/simple; bh=4rDYMkl5elHHPniqdzXbZjlTLtoVuqwA5zt0LySk2z8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=gOvTUBi4KHalkdVCrX7vkzj/UAjz05KNMDZ5NX3GwBj+e7byiLUr67NuTQrgm+Ee19HfWMBkUadAsKBuQc0fLldWRLN3Ec7ENiE3eMGwgtnMVZfTxvib6FEu3mxV8KiZkMVWyRt5b/S26ER/TzHHP6E+WxQwfQDrupva3FnWoxo= 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=fcPEIF3T; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=xAG8fxrb; 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="fcPEIF3T"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="xAG8fxrb" 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 4BGHQtYA015434; Mon, 16 Dec 2024 18:14: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=jYj64u+dgtu7QMYvM/n2JuUdjPwcI21a14QeObnaXZQ=; b= fcPEIF3TVziN3STBE8n9DU2bcNQh893HZ+ZcB7jHalBONLx7OOmtqOjRRVGMqb3d 8EG485wremE7H9N+wGfnql0dIwh0h/w7HoNLLu4OxEMWEOdfxwo2sFDgkAd+TNIg 886DakDT8hAkSbl1kDG5wFZH7biZ4Hk7wC3MJxLWdUxUMcuBexVEpVRQrDNJQjIv 6jzDvWgwM3VFWpbM5AgItoU4+JXbergVtsKES0UKz9gQ8V9anoo9mncIMX/gTze6 ofyGrGWbRfX+LEXVvTUZ0oltzUxCKvEwsZRRkZpkOTXhkbSiA9ZARc1GCDgQgUVb HyoZ+zWWwbPfo23IJdJHAQ== Received: from phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta01.appoci.oracle.com [138.1.114.2]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h1w9bxck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:25 +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 4BGHIotZ000776; Mon, 16 Dec 2024 18:14:25 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2177.outbound.protection.outlook.com [104.47.55.177]) by phxpaimrmta01.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43h0f7m3mt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=DtgLtB96PMyVCgVGwncA+/rhAcG/W0RvID6smLmphXsDrFxzuxdsCpWllfBfdqF+wMDmLdbAe/XVrTWjmDyAmVMYVNSryRR3IVi6MpwBh66ChAnPIoPVwvR9wOJfRcQ2kKLKLUi6VADywnSoZFmoNX2QD0KQexCs9fL1y8RgXJJ4R1wMRmWGbT6caQg1HLIDJoG9TIcgosS65zjLNZFq7B+9sGlNVm0xMmagKIsveMTQzKC4baOYRUc+cu1Fcv3seFeHqyOLgiGOi23D4rSBRnpiR0ZWsISuRLV4DQ9KLnnzPToSYP561gTHDT/nf3XDuFqpf+e206BvNdJ19exTgA== 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=jYj64u+dgtu7QMYvM/n2JuUdjPwcI21a14QeObnaXZQ=; b=TMPtdhrxOry3dMpd9oy+UsRy8vBDIdUbPcbI31ArzCGKP8/vl6vqn8fmnZCMcirtZSHXhfiWMlquTE0F0JW3hPsrreMhDQg4wKJUSayx+xVfUuucVmNExdhbKktWppQugSmO0KnFr4uN5WTT1nL+lkFPMJsmH00RR2Teeitd4hNsCeODnOQLFdYhs8N1RMhB4Bv5IO2CLcNW5yrOApEpFCJWwelnuB4NLJc8XWCB24LPqzHA+AhaSlXqR/IqNcZ5U58o0EfbqGwILsXhNGy72IF6DStO4DRuDNOgTuqeFP/Y0EIMWym/023dQjnEGbo/3oYfE7D5EXWGFeByFQb+6Q== 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=jYj64u+dgtu7QMYvM/n2JuUdjPwcI21a14QeObnaXZQ=; b=xAG8fxrbbHuvDXyx24EbrHvdTl5IDIYqNAqE0LHDPsaY5G2MJNtDdqvjgr1nfh/qOBpvzaM5fiMNB1ZDiNRne3wykk3zswhzQlDF1b7yRioYr10hvhSoAeYpdu0bsL1yz0KN6HxrKc92uuDvkZU3AZAzf3eawwZdY2GxbYmxILQ= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DM4PR10MB8220.namprd10.prod.outlook.com (2603:10b6:8:1cc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.20; Mon, 16 Dec 2024 18:14:23 +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.8251.015; Mon, 16 Dec 2024 18:14:23 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v4 6/9] btrfs: add RAID1 preferred read device Date: Tue, 17 Dec 2024 02:13:14 +0800 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MAXPR01CA0101.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::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_|DM4PR10MB8220:EE_ X-MS-Office365-Filtering-Correlation-Id: 560362c2-e277-4060-d4a7-08dd1dfd77b2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: SRr+u2ADvtVggD+Hg1hYaHjAhdxe23jK9VHZ/2d/xVmVp/3KYbk1Kyoj4oJ3iDuBR3pAMreaKUVV+8eOX6TPT/TKKgABfcypqSNPWaQKVC4uBLIDEnz2j/LRIg429K/D57kGBdoO/8fSIEyPOcVT7GIWbolDDZry9hb3KJN/kKCs6+dgc2FCnEt3ijoaAN+pPZ0bbbOg3hm9fWXxCD7qkcqCkVqnCanqIBrzSwfSyau+sZfBREunV90LOznyhWPkxlu7qR4K5C629UUtnpgnfBYqrD+1CcR82scZMCRmxhncHhkZ5ibxVJAOBdLkULDmR8oFLDWZob029xlRRxB+cxvkVtyOe82aqthNTDYSIM4qYihxey9Tb2FXFeRARQMUOYCd+C/0FXdyfgDculI8mM+BFe/9Hhmt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ook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: o3A+m7oTbxCqRZByWFqrrn34i+LmzCkUQbJsq+CleOtZegb+L0GpvFJZlsSRtz18bFAF6eW0/52d+yRr4F2Vrr8hgTV7RPtFbD1+w8gidhLWBMJY68nIva1JM3IPjqDjuFOF6tjpYmohoZrdDkp0Cw4SwYQYGHjx04eRlUokMnb/jdCuqZg4RRxDTpk1UMxozFvSlbVKmpG4wxnMW3VVtgYT/i4EjhzQx0Qk5dHXUYuZf2QaD3xT9lBd2+qzqbkoG/VTU76houpdIcE7pUAQ6xFCNHEAm5lCQt6lxlOA4X0ipEuDyaWoIbUsOm5we+jzAoXAb3Yg/qkDp3UfXlw9NBf9b9j8uRz3u+LE0ATYnKEeFV6dastRK8q2ApFVQfZBlsxUgJn1zmEe3cDQNFKzgXaixJRlBGcjGQ03mzFpY64bHk1ishZs6Dc1LrAHMcRucqe1j4A/6LELRoMZZUueec1VGJ9oljTpMEk4yifb4OMaej6rAhfLhz4ibQE4Z98WryFXKpWkS7BMqtEytSWVxYvGvKrOOE9NollxPnuHRs+xOuEHEq+EgG4ZRLKpbmoMzReKVyK89htecdPyiyJQElHHP6YXODZnXGIUZg0jgovZ5RqKfKYov6KYmCMk8S8jbJ4sTOyuVSK51pGqXs4Hp3eFToCIYwSCWIsBPycMN9bmd6jQDXMZ5bdLjDYrG/3IyxxiEQIEkvBkJjNaKe1fVODxCdvfeh8nuJlMuCc7COEvH+jTWPPgI///Pryx+cgD3e/CSMdKoD3H6Zgx6GGjB8voNss2Nt1MQFe4m1nCOmVzlcMug0VttZkuDsAoHOVCpWkRrPO/BTjlcFfM1YLedR684cH+j0BUlENhz5sCS2umOWmgOMH8NXim0CynAYJa3uNx/uwppaUthc60Oih9X15GLuxChbVcafINlpUYXt6J4t3wqHZCJ0TrIdfedIrkcSCcbwlkQxhyKcsp/kDkV4D9YZRyAfNAZMDRlPycAUxGevObkIRLIVig5sarL9YBMfJnWMrx5jOskh12paFy8sLih50e7QwlTcnHzxqNc4EkmjnKVrfjGJLvD6xmLjQ49ugNe5avlf+SQFCVrYbXolQe2tcy6Jg/MLe5MXPgDWDdR5wVD0tFTXLEuyeWG1pQZhqcOfyTsh5d08QAe3S1wzsNVBnhsDCbub873zOWW+PtROOoxCustYlouZQpoR//aYamywYTByWx/75BnlqN/hmEuYmlvU9uSJW1D7hMNIVTiNoU6NFE6EqrWMFxd8NjPUHH1VAmFikMscnDpnlWgkAQUnevTbUAGggMoKBOYbwUieoH7x1DolSjcAC+a4W23rkf1YqSbMCF06jyoODcHz3HSGeaPxLICZprWqOb23g/UZclE9oZSJAsbsPFj1syTb8N/DZ3Z9tVo84oxNxqT3Txp2S6W8vGmQigyjkNajlDLW9M7zbvLq/gJcT5JEulTAe7LzUl+A5nJf5OmgS7LVyl+ppt+gUMPfvcstaFYtye3swfHg/OLgADZntNOLRxqZiUfmk1bPciFzYIptlrYjdZt8NT1n7qS1P2hXy5gYvYFCVIybcu+s7v6wwiKyPz X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: qtLpypM1qelJsxRSg11VqDpKxurhur3KI9Y+kVHXRl/JDIaC9cnU3P0AjURKi3tmt2fEm2VfjdW9HYyZitHQufIou1kk+I5+vt3FKF//NGgBGBdIfKH0GoWDTK5IWMu8MinZnKPXcCDiCWbjmmmxw+gbFJQVOTWpoxRybSfr/5woopgkH7Q85ohkaaElrffJZzVyJfGuOyAyF9O/5bMoITIzkquYwz7Ecnv/ul4ijd9iZbcSc3q6XGTAKz/J8DH5y6eTdgeUNEcVk90Oin0t7oCgNAJYW3anlbVp6nBOxKrBN0MdNR0rrwwAlmqROJJ/3cfLWH26BIISr3nM8xuqHBnxVI15lWQcibU6vTLYBcyeHokxUnsUdF/UOhHPAx7JiWu7nbsl5Q0+xzln62pVL1xb4MmvCOJHxzd+KU69t0RL1sGkf6WR8rQfdan1hga18o3FWTjwN5B/K3FJD/OGlIpGqm5ZBAlaV8S5qvHtrTbx7NFbv1HRm485+QvYCCEq/VLsJ5c8V08ZImSFd9/N5BUO06pHWIfaPDPmUp0xqURMn4CHlTjKm/YuKR3C8z+jA0xSS6hGon6kFnTHGwM0bC/f1fqG63FpkXtYhUTx+Rg= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 560362c2-e277-4060-d4a7-08dd1dfd77b2 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 18:14:23.1873 (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: 5j3bv3sVv7LFY96lOgs6rwPpBOL79EC4HgKLnfBfgrU2rP9lb6+5wrtKWs9PYITNzjnkFuMVFX/Mc8pUAvMxTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB8220 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=2024-12-16_08,2024-12-16_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 malwarescore=0 phishscore=0 mlxscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412160152 X-Proofpoint-GUID: j9I6ydFRlskSXD0jw3I3TK7EZLRwpgFq X-Proofpoint-ORIG-GUID: j9I6ydFRlskSXD0jw3I3TK7EZLRwpgFq 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 b0e1fb787ce6..b4b24a16a50c 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 }; @@ -1368,8 +1369,11 @@ static ssize_t btrfs_read_policy_show(struct kobject *kobj, if (i == BTRFS_READ_POLICY_RR) ret += sysfs_emit_at(buf, ret, ":%d", fs_devices->rr_min_contiguous_read); -#endif + if (i == BTRFS_READ_POLICY_DEVID) + ret += sysfs_emit_at(buf, ret, ":%llu", + fs_devices->read_devid); +#endif if (i == policy) ret += sysfs_emit_at(buf, ret, "]"); } @@ -1421,6 +1425,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 77c3b66d56a0..ee2dd7e461b3 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1330,6 +1330,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; @@ -5963,6 +5964,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; @@ -6060,6 +6078,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 b7b130ce0b10..62812f4231dd 100644 --- a/fs/btrfs/volumes.h +++ b/fs/btrfs/volumes.h @@ -308,6 +308,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, }; @@ -442,6 +444,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 Mon Dec 16 18:13:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13910204 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 8F327207669 for ; Mon, 16 Dec 2024 18:14:39 +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=1734372881; cv=fail; b=agVD/URC+9Li3WHLIsMsdqXBJpeXlmYPj4FZukUGVhKnq5Zv78ikm6sqBy4AgZ042BymE2jDpz4hVFdIqO9NXvmknAdCLbfTO97dO5BsCQJXv3f6ekJdYoWm7Q/2k3W+VdB+ume+3fC4pjKQg+mhRx/drS6fedTJ0dJtph09mdA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734372881; c=relaxed/simple; bh=8vgfFShkER6knPnhAas0XZX9pVV+P7Rar21OrcpqY1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=cKZE9XrkxTqGzGovj32ARtAkL9qVx+ZSuBe63Ov6QYryDNdxn9fjciBRkGBzYgYzLUmn5VByEL4vXv02ILMHiKbBwsQ/Dguy5+il3pRAOSixZXf66oy6FoWGzRtuRZ2yr1kiOKM86rlJnaKqm7aSIMcj15SKcCrKfHYhxLDLIUw= 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=g3tU2FNm; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=TM9XwTcd; 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="g3tU2FNm"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="TM9XwTcd" Received: from pps.filterd (m0246617.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4BGHQjLr010956; Mon, 16 Dec 2024 18:14:30 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= g3tU2FNm4/gcLrqtkKBEoqwMj4KVRB3JLOYkj88HURj3wuViQFhJWGECqyIbOCaD D06In6CR6nZjh0FTxSsVk2fUtqIMFG+CN8hfoqMUSE3SI9qw+Sb0oFkZWG5mCFTq 0NvKbZCdPfeHvrW26NpFv/11GZKDnMp7bKU49Ygx8cgWdYJ5RKzEeDSpr6wZmQST dGc7lnTU2K2Xmyq6XrA1W5/AopCQb+Bx8+UvcxfFv9+M9ErZLfoBsdY2jadH5UfF y8GiORGHktpxUx1BCZhID8q6kxBCt3wSll15x1ZGX1DWn5k16DB1GP8qbpDWBy44 mv3evrPKXcc+vyV7nLwMDw== Received: from phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta03.appoci.oracle.com [138.1.37.129]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h2jt403e-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:29 +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 4BGHP9C8011058; Mon, 16 Dec 2024 18:14:29 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by phxpaimrmta03.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43h0f7b8et-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=gdLd5cj7FIFP4DqKKS4u9DWIlqfmFY/3FKGxEq3KzYZfGOZ+6Max6/Vs7cW6R6pvUcdCmI8Ca4SP8aBVMRCwdXrWnMHNLqEK/3s9sGUjnqKeJPpdBPgTkdWNnJfKbVBWDdL5esCUog4KPQOsf/ay293r5n8QquaFvSJhT1DgYjqR/p5bJY9GPTV6C9eNAz24kv6d9krooadnwEOvNt/GEvA+B4u8f5p/fUBg+hoVP3QzQ+Vl7gZtYv46UNlZnBsdEljW2goh9peHYQHMZjlMCSC45mtJSo8uFlGGH0h3jBFw4INLVpFXSUcpdMl+xzXqszZp+Mu2cMwFO7LiPag7Yg== 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=gJpfqraGa/zIx1+yZ2UZNB4rrtZl3bHvmZm6KxR6oLj/G9nK1gUn0dd3Dq0oDAfurdBrg4xiYBEYgqrO/uBtukXbnIiAhmim8h1VOHY/VLEf0aR0nFy2bB3bCe3Z3QHkYylLiVqMmNpZ/L+fRxvxR0ZvVfDH0wQH6JEbrB9AEEQMpVZ40SzsRN0T44P8sFnVP7K7Uolz5rMV1LEtnsit+AGGyEE8frpZ7EmZL40RMgcYPIUTyCg8kBZpnZL01uibPaHOSePNW99CQ6vNKtNJZEBj8xvJ7Cm3Ld1B9+aeBj+ZAgvxyHkqrygabcdadDU/F/XUReJ0Epr/isjeg0hwbw== 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=TM9XwTcdFSZJ+b8KEn6VKu53ECIwtW8PEEaddFRdVLTreAUxbm6Yg2+4DxndtnGmQD7RcLLkf0Mx6i47eGE1GFMCeai5UB9HcZwtdyeM0cQA0rRUhpLWoDyo31lCRMTnM8tufE8l3JhlAv84i1LjyiSHDb2TIHreqkizCjH7n38= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DM4PR10MB8220.namprd10.prod.outlook.com (2603:10b6:8:1cc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.20; Mon, 16 Dec 2024 18:14:27 +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.8251.015; Mon, 16 Dec 2024 18:14:27 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v4 7/9] btrfs: expose experimental mode in module information Date: Tue, 17 Dec 2024 02:13:15 +0800 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MAXPR01CA0110.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:5d::28) 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_|DM4PR10MB8220:EE_ X-MS-Office365-Filtering-Correlation-Id: 2e5cd3c6-93e2-4c3b-f652-08dd1dfd7a6b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: yHzFny0ZAvvvifOQTPJU8oVEv4HgR0PTDUvtUXoxeGZ5yc8rBT8zvODUpB0Py3hpexkktudM8veXmXudEJg2+sOYLS/vSmrpiAZj/KETW+wD2Ywnu7qA7i1Y78gvKU0DaYHwzBkSectEaqP2/MizxwmTOlluj/DsL/r7Hxbzqx6EGJt3cGuxof1/Z+aSkzspQd01UJFbDyecf9KnN4m+2gypb65kxUempzf3A5sCcmPvfWW23p0XgNdDyNczqjYbdFFmbl+0YroVGCBzzKq6LKKdRbcWcJO6QNTKW34/mQMZ+bezqsudIAzlsL+dtz+f+qy4HtaUYXtDP+OKpjDfjJjMue+BQ31+H1wkqaKb6UVJoA1ioMuikicB9yCTI6fTLumQIB37gEt5FU/1EyoW3Qs/c8XXckFk0LrvQt3NABUXqzv3Ztpy2PQI+tgI0LhRnuIq+xS2YIbUjSZIrzOolIrEudC/PYsY6Vj+2ec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QNAPoSLmpSyWCyIbg5neRT/NoyPUo50+QzYcNkEl0zjN0wuK1ulgZ1qnzY4YFw7P2wT/yz/6h4+M6nbQt64OHy0GMp9z4yRMQhHWaMXE5khU0iIc00bQ9DRdvgt9BZkZHR4wDkf/iTqbEyPhtpkWq6fg1mU191IFDpYGdmAwjOAHtVQ4Bnd+wCLS7zciCQgxPGrgeBxBCPUian+lNw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2e5cd3c6-93e2-4c3b-f652-08dd1dfd7a6b X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 18:14:27.5241 (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: 8YtlduAWpUwui00K5cX9pOsJ+LEz0iCgF5OmXd0fs1esCyYG30uTCYMO8ASUWmvI0ajkIoMvibHPvhrcmN834Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB8220 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=2024-12-16_08,2024-12-16_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 suspectscore=0 mlxscore=0 spamscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412160152 X-Proofpoint-GUID: 2FU46wfsV-9UOeuA7OKZaaiiiDGxpJWr X-Proofpoint-ORIG-GUID: 2FU46wfsV-9UOeuA7OKZaaiiiDGxpJWr 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 Mon Dec 16 18:13:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13910205 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 138901119A for ; Mon, 16 Dec 2024 18:14:44 +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=1734372886; cv=fail; b=ExDQChpbnvq5kCIB8I6cymublFhdz/mP71iDSwuRx+PxagmLiDkvhhdyPT5zvsmobk4++QFSo1H/5DbNYMUd6f1GHdjkINFhIVb9SMjFf9yx9DbtnzDQ+MtsmL+q5azNAP0SfTGLtZ123AUdaBEX+rb7UCD8DOWuKef8feR8zvw= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734372886; c=relaxed/simple; bh=jixQ6eXGbbBrL5gTjEggyrqR1arsvmannpBZNiZg0ng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=pgLACMKKaawVUi7gP0x5vr7VB9qCV1RFAzmDDFZZcD5Z6f3LwLcFr1fVjkzr8M/79p4H9V2PWXXryx7zFbOOF7/BPZMQH2yCDMkh77e9pUD4WEtpOROdE6fuRaPnvAxcR5bEaijG17bFb9DLsbKpn+uNtsufcaq/2jQlfYB+tik= 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=TBti3Du2; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=rS86iyU3; 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="TBti3Du2"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="rS86iyU3" 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 4BGHQtYD015434; Mon, 16 Dec 2024 18:14:35 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=RsqfTHbA2pzjYDDhHJnCvvSZhZitlR0humcKeNXm8PI=; b= TBti3Du2qLtqJukTpsZ4ilUJk0+uFvLFT4j84OwHn2IYv138QObhbrp2ZVOKbV8k /MxIPYkZWQtDZ2X2U9wtZKc1KuxYT9CqNv+4UO6OTwXwzjsdVcRfxweoF/EFexgT GsacoyoO5MwyxsneNarvhm3lkPYHEnKVBQ0PDcV5bCIOONBxA0xDi+TKBirZc5+g vsepaF1s2j0XFN2SxURfDlZ71bgYL4NOkRGy054WyNG1ED0B+Mcn+rHWrkUNOQG4 y/gsyqgYfQAyclTUYX41iulIv4Oc+sreNk4bh+9dRTWxx++7YtyZt4dx6RlGDQuL ACyCm4FfWUjMljM8Q03iXg== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h1w9bxd3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:35 +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 4BGGsuuX032823; Mon, 16 Dec 2024 18:14:33 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2176.outbound.protection.outlook.com [104.47.59.176]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 43h0fdmwr9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Gu9Wqu0ls8aifwsLNt8bbeZJLONHDo0jOvU8GxATeV+lLjpwA9j0lznOp/Fr0bGAYg6l5l8BDZDH3v8hlBnLedEG3KBZAGc7PXAxP+1bPJhc2OYM7hY47bAspl4FUq9emsrnQTSZfCsafggxKXHRER5qzJLPceDF7vOK+Xx5BXvtau4NHRZ113LegfIYWan5P8hCj4w2hK82OdlwhJw+yQOl3JyayecKIspZvZUYcHzuJEQhZKoEuo71rxjB+f4waGMnMaAZixt7TGm+MH07xnkUMC+GjXBy5QGnTxWF7GheSCT9naDm5Ptn+i8FpTuc3twWTZsHwIelEkAN412OoQ== 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=RsqfTHbA2pzjYDDhHJnCvvSZhZitlR0humcKeNXm8PI=; b=NAcA+N0LSWlu11wB95egzXrxa5Jzs34npvRS6nBcQeGpFt9JYqCC3Nr19HIHWwG0iAtobUi01s0qBXhXLi81emJMq2CgvychU3+ydYNS5ntNOF9rFaOmliJzslvaohDboJ2HxP+5Sg9CMrug2ctxw/4shZLNtYEn4+kJUgFnCxZkqgw38zgeM5p8IaF/HbIIQwmC25PpShvh1BfZfHSMekhCdlcsG+eV4RZTIElPBh6Ffqz8FElEzNwhtt7KljAhr1q4rDtuyVqDXCCMvYmNqKJpdks2lr0GV5gYz8nLxFxd0EUcw45ik4xlMdp3jNSW/J6wpKgGuus9wYDgmHblgg== 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=RsqfTHbA2pzjYDDhHJnCvvSZhZitlR0humcKeNXm8PI=; b=rS86iyU3YvqVlEORGPyU2h77rBqFUAbcE7WG9mNWEi7hEgzg2IAQ6O2P2NQQIBk5tyU8Rfg2RnOpbRZ8fvIeB27TMX6ZyvVK0GAHP+pmUbj3FmgAMBGIlkA4UJjfFdbtwsCA7fHOyqhDWxdkoo1OLtw3GYSwa/CjdH0H7ZPWd1c= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DM4PR10MB8220.namprd10.prod.outlook.com (2603:10b6:8:1cc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.20; Mon, 16 Dec 2024 18:14:32 +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.8251.015; Mon, 16 Dec 2024 18:14:32 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v4 8/9] btrfs: enable RAID1 balancing configuration via modprobe parameter Date: Tue, 17 Dec 2024 02:13:16 +0800 Message-ID: <160fc9158a79d972f0a0b6bab0c417c6728c7f98.1734370093.git.anand.jain@oracle.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA0PR01CA0067.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:ad::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_|DM4PR10MB8220:EE_ X-MS-Office365-Filtering-Correlation-Id: d7d9bad1-af77-44bc-745c-08dd1dfd7d1d X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: R3GukB32/6sbHsefST3Ot94Z+fC7R95GMdPw5UyMI6hi5aJIBIK68EYtFV3CJry4qhLPDM95tN3dYJplZ5upEjKGw5DZoXVxjS+aY3urx2Ebtr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3pRTFu5rgccHrX0NjDKyK1GwTwQdYDumnYTK/b5PL9HdJUZqLeSwP13WOo2cZXH0kNmlXT+Gkz9whJfigO7bgVjpQprWCF4oT0veDrkXr8zjxQuP923S9t6O2E/6k097iu+3TDEz7cIDxxZ1lTSpj55V1LvAB93/LL15BIdjKPXIfJ1VyRfxqYL4KOYvSF0N9B+VEgJ6gZVMp5UdHO8EA+q31+lxJMiJnXCCyprZ26 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AJLeeokrksMTJhe1bOc39YeDgXdukjkZm0tgPuW+lgJvSv4Z8GbYWWwrJB4VaovKY/S7tgbxj85hysL2ptiCe6HFkEMirrHqBRgjkKUhRKxy0EhOjYdUS7hzyolqb329bTqPUdGel4qKB69tDxSXj9x4UDqWs4fLPJl7N7WTIZe8pzCCdr2ssKWnOvA1h9SdtSuSIDLysYG0b60/1rx+uR3ERswuvYegoCUVMsD4ucnRSn1qeaarR5FdR7Gk73Zif4RlB8en1h9AiPxBJwUiKpZWvtl9qiGVqYj9RJwQrj9z/Wefcj/Jecri5MMKGTXqwVmh06Brx7sIT+jlnAtlZRp8EE22oawOqc/biLNITV5XsHFuMj6edR3m0bC1v3HQgj9x/J7kMY9Saxe7qlgSNQglAEgm8deR57PrxXcaOlVAU0D7rKB4xMxKgG9G4gU8UOEt/YKmxFMKOExwgsW2IRTz/kw12SMV8RNPz1Q3R7BD/7Ah7335Ih12M+fk3Wo8L2HgNFS8XdHNYqctVKmvcP0uU1v4AXMvmpaFZhhXelZJbv7MHBKm3H0e40ZydIMT1DBpxHQwaeh+kym7HnMpdhZ9LdPYKd4BIxRQQOyxuMsXdTOK77orOIjlCYfjtIu7nyt7OHuHg3T4TOVi82ZklITe7vzIxL0DZ9vX9rQ227ZbR3AA+QXwbgCB6J/zw9lrKIwUk7XFzmpClxCMcJBqqnUfLtvaDspDIEbfg2eia2qwNj4gOx9EfUaa47F8wQrog+UTfFzE9AQSDa5HPDyOJUMAjhJiO5Qgf1gFl9qJ3wP+cGvm+spPlGVf2yP48LyOk4gPthhta+L6cGlZxBbXOFGlWypyWzicu8OWRbxp+pzT1/Jd7HLJOKd46lDWzdnFju19wZ/fdy7a2HfPL76uo+Wa2eAGzwMJByblo/DKLFuWu/yVtjWYanXxWjUZ+f/u3zWrPzZ5A9j4HiUUi9KFksLT/bMspobwXiEUBIcgbli32CLAYv/jGOD+Y51baoSp6CcUIYgFofK4ukz6/DvPGVrg8VFx6eDiSXlXAui//MLakUdMFFQeLOXn2JZRqyZznwIEQivcXSsKaas+2HIBAm/n4O7uogzjtOuFmTzIGjXHL4XG56fUzyaEAJxl7qm+0lCeIarvb5RJURDlgiyUS97cm4OnK87FpBhy7UbTDVqIQjVvRTZoLmhBScEL4A1eqvqhtUh7pTLLPdSdc+3M+8akHiYU8pUNRdsibhL5GiZDkDqYo+lUw4PRXqpIWb7R0paD2mkJ+wcaLtxRmw7stEKRXb/Qca2XJCSip5ovD9+59wk26X3cwnfMFs9HQbhhZYikWToOI9wC8D542E2NTeVPbtMKZfqcMoYQQXMUpinzI112Jw44evN4TRvEBkdaD6kqBJI6ikXdGscmejwGJjDltb653Jb+vqJTEaWklRo1EOBL7WZArEBbpddRxR/pukt9sQEnKFmtH302ceeZaqEiuBjVbykp9rAgQRWxqdyzE7sDtappZPsP6eeKAlDLggbRDJVgBlZRZyFkki/BPL6rqHaYb6Ojvn76bCNSA5FjFZ47e4EvGQeHWTyLXKnC X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 3s/qqW0Xmb2var8LuQEYiU8CjI7Na/nfxVSzUFrSRzBsc0i4rH/JK9LPgJeJElEikOsUssnMlMfd436gewq4RGyKUW8PQQdNJ6TLKQMjwh5NOIhL/Rw1QkSeXeIfcrY2LRoA/qWiTh0Xj2yxtPd9ckjSxVb53MxnQG2ZdBrYdsvyJDRQB/VakG1R7ETpd3WQBEXoBWuN2a4mJVtBCziHOrqF41ge1G1ocTjHi5sZStM4hVdTNe3MLf2jvN5yvO4B1THIZONr80wPJBhx5Sp9T6F1vA7Sh7N2nWhm+LTpMlj4L027lulv3bXsHwyr7jbuH38p8i27X0PJ5LGtStYqi19rzBd6KiZJt5PEAnNukBrxOp8P22MgqfHw1QHuQaa3LXDuKCc3x7qfnlombYvGm7Ik4JeC/87gUpnzq6E4ATDhN9h7Khqslo+w1UBvVYONgaBP04SvOTzaj/noOvo7tZOyyILoTDmel8eqy5njFKhrrSs4pTkFF5mXw9J11Z5WWitgMrPzEd+O/8jv131nQw2Yj+aOuv6akMbvZr0fZflCxDCynAtAkaGjQ1tzhD+xjqsOLDyymGQooeO8xHoE2lNHk+EUwH9/Yl7oS7fmc2s= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7d9bad1-af77-44bc-745c-08dd1dfd7d1d X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 18:14:32.2575 (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: Ep1WFsU7rMFHnKvEJmi70RiYlTwiHhldajETTlcfY4I+SeDig2qo5nMwSYI8kP8ZfdmW78dzFaUOz/LpZ6MbDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB8220 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=2024-12-16_08,2024-12-16_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 spamscore=0 suspectscore=0 adultscore=0 bulkscore=0 mlxscore=0 mlxlogscore=999 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412160152 X-Proofpoint-GUID: Gntp_Y2UedGIkTLLNcUxpHoSF1r364gq X-Proofpoint-ORIG-GUID: Gntp_Y2UedGIkTLLNcUxpHoSF1r364gq 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 192k: $ modprobe btrfs raid1-balancing=round-robin:196608 - Set the round-robin balancing method with the default `min_contiguous_read` of 256k: $ 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 | 28 +++++++++++++++++++++++++++- fs/btrfs/sysfs.h | 5 +++++ fs/btrfs/volumes.c | 5 ++++- 4 files changed, 41 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 b4b24a16a50c..dc10908556f8 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; @@ -1348,6 +1362,18 @@ static int btrfs_read_policy_to_enum(const char *str, s64 *value) return -EINVAL; } +#ifdef CONFIG_BTRFS_EXPERIMENTAL +int __init btrfs_raid1_balancing_init(void) +{ + if (btrfs_read_policy_to_enum(raid1_balancing, NULL) == -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 ee2dd7e461b3..3cf4fc06d261 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -1327,10 +1327,13 @@ 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(), NULL); +#else + fs_devices->read_policy = BTRFS_READ_POLICY_PID; #endif return 0; From patchwork Mon Dec 16 18:13:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 13910206 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 346F3206F19 for ; Mon, 16 Dec 2024 18:14:49 +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=1734372890; cv=fail; b=Whk0PObMr3aW5r0R+sy/WNXXsl1mclo6YcyNxBkS2SAq9MeD0e76sQZeq1JRfsnMD66HfClVxken69TNKX08DknldCt2XyzvjRv3Hkm512WswoNE0Ds0sjnB/u8nzeunCbm7k8gRAFos9tmc5O9APZft007BqfCkcEDXA+VxgEs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734372890; c=relaxed/simple; bh=ldOPgLr/5Xo7nwhjGDIOQ0EvvsrL+y59D337Phc+ECs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=mAHkfJaSs/RT69Hwh+JwkVyVUKmVK0cu1zouoCUads8s8d0rPcGc8w9wVeGQCFdyiVbdNuXyeZPXsF/hdA+xKggfD+UoXrkTeM9QBGVxssHRqB9MXyvIewfweViRSQrpwqWcWY+/fHYHnGYPb10QgXK8SXz9GCNYV1qLfSI7wYU= 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=gmXYOBFj; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b=ciQ+ZsfU; 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="gmXYOBFj"; dkim=pass (1024-bit key) header.d=oracle.onmicrosoft.com header.i=@oracle.onmicrosoft.com header.b="ciQ+ZsfU" 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 4BGHQk3l015221; Mon, 16 Dec 2024 18:14:40 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=6jFA3VJpjbDfj5Y+/+R8Z2f9p8a+t0min/dwJhv4/UM=; b= gmXYOBFj5A7caktphlEfmW2smTfsXWSpGYRwH94l45yiCsDMoTYS7tUdik+wJovb RDBLrPP9Bt35FMf7bE4JSoajCHodCnNBDdsMX8bpxPTnfuNxGVHwi69xaS+qFpYA vEJ+c+CMb/ylIPlnUhIuxCmO9nqoriQJTvwDs6DlkMos+gVvEHA8V/gD4oRNWuK5 VD1cBxVpPATvw/e6UG/n6uirnOdD6uFo1JgCnufgXo4BpyuPEuUjdjHnaOs3VvEC KBF/PaXkGIWzub3fk0GZXG9deLzBY7NtIsxSi58/538EyQxFxSBQP/8gVVUGsU0h b8Kpxv38sawq8gDfPb+DMQ== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 43h1w9bxda-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:39 +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 4BGHBQKd006433; Mon, 16 Dec 2024 18:14:39 GMT Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2170.outbound.protection.outlook.com [104.47.59.170]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 43h0f8bwjx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Dec 2024 18:14:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bZ6dzQIxCysFs4JQhyjLPjzkKoGQdrXwUHjfE95IxgJ5XQRl5Xd/yfN636PooWldjfCiXOjKAiIWEXCmhAuCbH6meOhctVr1EynMtxCylljO53zMaxiKzo73OBJLncoj5y1po7oHAEM24meqCs0mhS3FbiBp1MZHOSzXC6V1FdVqSaBK7aPzJvJ7hIzPKgF14DW6o70h5/GOy9tUyYvbOMzkXp2RJQrAMHccs0IVkXN6S7th2tmlWpynuOLpqXrW9MY9ZDws7UFh20UwntvaZu2RCbDhLUBtL7ALG3nIolZdrtIX64k2CmCzUxdGPct3DKvaX/ILE/mRxO9KvHga8g== 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=6jFA3VJpjbDfj5Y+/+R8Z2f9p8a+t0min/dwJhv4/UM=; b=sDj/YQE4ymuqGV9hmJ5lTWBkoS5ZdqSJ8ibGe2JYqWALR0LaGHMju7VOP9zSTFw7TEbIcEbGMKsrUsm68caTzOQvxLUpEuHbRZkRNV1EKuZVskiIEkeCN2oKY4oCkm2ODXYC9MqPs44kku8yszRxPvSBW5U1ToR6QpP9CnPc84o+mqC2KuxLNY3xHCnGKmvuFtRP9vrtZkSlyJOhwkGI9czB8mF8tIXelSsi8RX3MqBIWhnYOkhh/qmep35Z73OdjS/JAEeaWhDAjL1znyENS0xdHLyMS2m5yvbEyxbyOjHYsuy44f5wiMNYqphy8ClOMWPulZQBhGp1fEmQVV5+Gg== 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=6jFA3VJpjbDfj5Y+/+R8Z2f9p8a+t0min/dwJhv4/UM=; b=ciQ+ZsfUaZbm2Q2xMjnJ6k+CrvEtl4bqnYYhX9F+7s83LXJNmPZSLhudWyOX5Wn3kQdYgLJglMMpgn+C50QzNsd0mmGD1I+N8ZhdsfTz/yE4zelZKzJa+IcysYFj2zlmidw1idF+I1XbnwVfOEs6BrsqptEum2CPO5ptry8Z0nc= Received: from PH0PR10MB5706.namprd10.prod.outlook.com (2603:10b6:510:148::10) by DM4PR10MB8220.namprd10.prod.outlook.com (2603:10b6:8:1cc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8207.20; Mon, 16 Dec 2024 18:14:37 +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.8251.015; Mon, 16 Dec 2024 18:14:37 +0000 From: Anand Jain To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.com, wqu@suse.com, hrx@bupt.moe, waxhead@dirtcellar.net Subject: [PATCH v4 9/9] btrfs: modload to print RAID1 balancing status Date: Tue, 17 Dec 2024 02:13:17 +0800 Message-ID: X-Mailer: git-send-email 2.47.0 In-Reply-To: References: X-ClientProxiedBy: MA0PR01CA0074.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:ad::7) 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_|DM4PR10MB8220:EE_ X-MS-Office365-Filtering-Correlation-Id: 92426d84-851a-4600-7f3b-08dd1dfd8015 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|366016; X-Microsoft-Antispam-Message-Info: VMZ+d7uBoROn6VTQ/87yH3E2VVcBUcG237MF4n1QaV6MZfCgllLKvOUXSPrZzGwr1v0cl70H1HgShhvQ+fWIGRxn0ec6sGc7rshjDk5y9u8t77tLFKA7PZTK7sNQQkBxQGDqz6QquwKr0/LJwijD8HXwEN5oR+/3wInU7dFHOU1HIgEGfc8sfk1SR0w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Dlew24b8iQlivSZzlxBdWAGw9rTL0H0wos7vpe+mVcpvONhzc8kt1AA4Y/rqQKnugZ9XoU/CyWmNsaJqnoqj0ZLQj8enj8Jr9IQ/H+9SzGrv51UBgx0 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)(1800799024)(376014)(366016);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pDDXra99aOlv9AJ2lNs1/JSjlbQSPGsjzaPKAuVmFZpdOP1ohgCeg4ElQuR5r7oSeRTW+S/NE+YNgC9l6rKJ3MlGXtqxu4+RcPhpF62m/2Xsvrg+MapuET0JEmLrejioNspSC1pQSINBtgaozRTYF1jZOEynsU0b/VtQB9IYuN3EHXSdMuhuT0LmSDYos8f3LhOc4bpqOXwSnwqJ5LAjDyBZP30SnkME7XSeNlywYGUVHS05SQaR7JWdsQl8+dRwNviGkBYE97xViZBPqw9SwwcRN4HUDbJ7pwiZ0mhjmi1OQEY1ZqofKxZcxayDYfwsMFdRcljIN9I1CWwzQ98sCIzd/RDj4uCSm6GsPwpkknnqzvIXnZOQNj4valjZJd8BixLu9dPOOzJGmtN9ocFvd/yLSMJm2OQCd0BW6I+bLCk2dcW5Vn8FSDClJ2Dx/WL7N3cKvtUEA4iJjqMg9o6w+NRO0au0e3W5u1XVxTbUXjL04JuFVrNuGxGpveqrb6zIT/ZAtNEf+libpkmj8/lOP9RkMb6y2l+2uYIf1O+g0jw+DYVQpg/sFgiUhjpP8JdKbIUbw0BbjjYLgsIqTTlq1sWaESSQ8/r9PzYYfXklrlIMAWiVkh3AfhjhsFNxCjZnTqByPEMAewuuI0rAhP7WH7Pd5daDWUGaky1wXQO6ulMjk5ZutBe8j45z25pgkNIWncgEa8WJTAWQ12deoyujynTgDT0l0kFdwft8eW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BYBEHbTLBa/kE3GxIVQAd/CzbCib+6QjQlion3FTUurYOkV03irFBDY71+7FeWYKhZUQYPw3xu/EZIwsR+Mx+vQlxgSKesoamSztgLKvUS9U4vBHM8X2qZdL6HlKNLwvGeUOjcDyMjFbGB3qYdkSNSqwlp9YCYdw5dJqv/5+2M1Uz6DP3NzwQHfLKpHjZGQ2PFvfH3Mt3YqxgTYUou6DxR16rH9B8pTIXGHLRf+MHOsXUE3WnwtePA0q0tCR8SSIkpDiPi5aWjekrx2CbQAeBRd8Z8H0NGGybOc6rhhs5nVn4KEOfQdyUohOXC47EpURyZqQ5duoGWevq8wyxIXSDNaQdjDHQoJoSM0cBOOxpfwA7Kl6NbgdZZBuJLAnFjSKiFH/ebvXWZ6VNAOodsT0hY4Ar5iW+FkTcU2bHfgObbhJJ1X+ydKhVno1x6a7LYlBzKChlrzwWn8AFxfNoY/uARhqU9X5wuw= X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92426d84-851a-4600-7f3b-08dd1dfd8015 X-MS-Exchange-CrossTenant-AuthSource: PH0PR10MB5706.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2024 18:14:37.0381 (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: oVI0nfx8ESTGpzRtzKafBUrm2lJ1KWgZczMsRWNvVZ6aI9n/ZqVDri4fx72PzyHVdBvtWTF2AsOyK+bzVSSu9w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR10MB8220 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=2024-12-16_08,2024-12-16_01,2024-11-22_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 phishscore=0 malwarescore=0 bulkscore=0 spamscore=0 mlxlogscore=999 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2411120000 definitions=main-2412160152 X-Proofpoint-GUID: _HjeNDIJUhBfe3elEcWlryI8PSY7P9J0 X-Proofpoint-ORIG-GUID: _HjeNDIJUhBfe3elEcWlryI8PSY7P9J0 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 58190989a29d..573e8e1a2b24 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 ; - pr_info("Btrfs loaded%s\n", options); + +#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; }