From patchwork Sun May 7 17:55:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6IOh546u5paH?= X-Patchwork-Id: 13233875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18682C77B7D for ; Sun, 7 May 2023 17:55:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231535AbjEGRzq (ORCPT ); Sun, 7 May 2023 13:55:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230450AbjEGRzp (ORCPT ); Sun, 7 May 2023 13:55:45 -0400 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2079.outbound.protection.outlook.com [40.92.98.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12AF32724 for ; Sun, 7 May 2023 10:55:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=V4dtIRlhgXaOHMXeDmjCzNDNCx26eS+mZNKjM6UPQvz5/NnnDmFaJD241dvFj0bwxnAj3hWv8a7tpJMvpiuZn9H/rkpPpjL5zzqj9nJ874a+MB2fU2HCEvYyLas+hTohcymP5xurSWLy3SPjnRHUUS09elWwcievquCich8BtRMViI+YV7GYuV/aovGSsDfzx5yxNpa1oZpwDMoleAcu+L23g/t32jJTvf4zDa7r2dlKUU+DpSeuHaGyYmj51eyVgo+8K0tnoKbexBvszoAsGcUEulMk9/ro/92kug0NjRkBT7+8oczwNJhI2QwHvHk72wn5rre65nNkke2IAJn3Rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=1wcnDqUQNlL9ErpFI02tqLpa8uPA4XEgOkocBF/y4A4=; b=gWNwkaY3Z05yp4c5MDU9ppuKpK8L4MEeJoRAs/cNLQpHJRMXYRnEgHES4giSOTn7vjJsKwBe6AxRet+3tnxD1psP/FhO6IC68nBIe6oiu5U0FJCLvjuZSNf+FuiKqPqPktW0jawqMTiixvnyeagOfhZMPAcbRx5qnRVLutpd549zfEs3rHpxKv+FCyEQzZVm9V0/7LkWGrZGeycSBtASi0mEk7+Ref7PeVvof2XYH52b9e7lkUiDYJVYeDWAI/u8F80BylOn4t8OLV+Kal/km6t2tIJ3GeJCyCVFmK0B0s7e7kE5C8nlCqWxivZruZNe7kxpyw0fiQ9rmkexIvjwig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1wcnDqUQNlL9ErpFI02tqLpa8uPA4XEgOkocBF/y4A4=; b=gdFdgQhWbwZvQorYQIRckyTZPsuUgtBiJpZ3e1Ip+2GGUaCirwVGyd5G6piWiTs7U7+voYVCqs7NxyR05/I74zM8G4DzBbFByz98cHkDbhxFGWVSMd9zyWQgq/fboRVwUnmxubB2VNuX4dv8KZuo9QkeTMXfdWlunxj/rJwpqI0g4AGgHm4hWm+RHsQkZPsscYTBhwSfT1LJDKnRZNFbn6PkrnCjCvyx0pTfN0qF7coeQGU486UhbdW76oeni08gN/tiNioSe1HjdpBp9pMjYlrCDO6qySGogW+tcdz5TvMl8dPh1SNkedxixP5dgmmwDjr/A8PI7U5EGGBCBz3Ecg== Received: from TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::14) by OS3P286MB2567.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1fa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Sun, 7 May 2023 17:55:40 +0000 Received: from TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM ([fe80::d9fd:1e8f:2bf4:e44]) by TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM ([fe80::d9fd:1e8f:2bf4:e44%6]) with mapi id 15.20.6363.032; Sun, 7 May 2023 17:55:40 +0000 From: Hu Weiwen To: ceph-devel@vger.kernel.org, Xiubo Li , Ilya Dryomov Cc: Venky Shankar , Hu Weiwen Subject: [PATCH 1/3] ceph: refactor mds_namespace comparing Date: Mon, 8 May 2023 01:55:01 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [JhdFp3A4Ic87ldqm/7nU1a6frjcXngtC] X-ClientProxiedBy: BY5PR16CA0033.namprd16.prod.outlook.com (2603:10b6:a03:1a0::46) To TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::14) X-Microsoft-Original-Message-ID: <20230507175503.2271-1-huww98@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCP286MB2066:EE_|OS3P286MB2567:EE_ X-MS-Office365-Filtering-Correlation-Id: 8beab207-b3be-4dc7-4aed-08db4f244514 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B5IrkVdKPZCsZRWgxcDKeExkGGL4SKUmYqsXOmAjkJSEvqC0tiVpdCaaTfD0EIorHqQ+lyZkH6w+CehSFEjTfyG3d6eVc0wqZDvDUy+pmcBgj/92G1bFTXAzJqm7/GAwNEutI0zdUOEBNaEIdPHrnHgp7cJ4vx7JfILxVUZpcViQQxfFbauB8zpP2iHWX5tCgF0wY5afib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ZdF7TMLbWsdmbHSodD5Y8shdy4UajPDR9G0sBhxIdnZj/TD+k85HztDhuPfX5OPaK/96lbC32qkDymUWwaQTOyZXFreT9/MYKhDlpYVN1U4JrnJDfue7KENKlVgSifGQUY5jOtN+WfnYTXEDS2Qb3AvxPa3rn6La43yT7+KNRFVWQhuhLeKG7KgwUo+a5gktS1zgj3shGbBhfJw7M8GT0xlaWq19O5LYltLJgENYQAYcE3kkHkwSxxEHVV6mqOw8HbwCqQZnEVhUEAeocKHjgOEzmTZAVIfcdIAH0kGJkEMm8he4Aj8lrpH7AaIvQbfAhVmSrlutGx8iOMG80r7Q3uvZyQdR+sF07oC2pl9ONq+lFeEY5a+Nd35HhZsBAISLSbNU1FaXxdu6EA2JUAhqHBSxkK+tnFhGHCQm2bJh83tgEqILm+MpUDJwe849JCIBt00h3k8hm8x+Twm+9+6vGlFSJfvLAknbOewhXRVEjVIzE+ikVVZEnwd0GxOzNtz2CaQcmtN3fWeTq2jU23RVMZ1x1oSNW2XNmmEDcVibQaUed9Uf/VLAmS2vWQRDYUHXw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8beab207-b3be-4dc7-4aed-08db4f244514 X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2023 17:55:40.7076 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB2567 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Hu Weiwen Same logic, slightly less code. Make the following changes easier. Signed-off-by: Hu Weiwen Reviewed-by: Milind Changire --- fs/ceph/super.c | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 3fc48b43cab0..4e1f4031e888 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -235,18 +235,10 @@ static void canonicalize_path(char *path) path[j] = '\0'; } -/* - * Check if the mds namespace in ceph_mount_options matches - * the passed in namespace string. First time match (when - * ->mds_namespace is NULL) is treated specially, since - * ->mds_namespace needs to be initialized by the caller. - */ -static int namespace_equals(struct ceph_mount_options *fsopt, - const char *namespace, size_t len) +/* check if s1 (null terminated) equals to s2 (with length len2) */ +static int strstrn_equals(const char *s1, const char *s2, size_t len2) { - return !(fsopt->mds_namespace && - (strlen(fsopt->mds_namespace) != len || - strncmp(fsopt->mds_namespace, namespace, len))); + return !strncmp(s1, s2, len2) && strlen(s1) == len2; } static int ceph_parse_old_source(const char *dev_name, const char *dev_name_end, @@ -297,12 +289,13 @@ static int ceph_parse_new_source(const char *dev_name, const char *dev_name_end, ++fs_name_start; /* start of file system name */ len = dev_name_end - fs_name_start; - if (!namespace_equals(fsopt, fs_name_start, len)) + if (!fsopt->mds_namespace) { + fsopt->mds_namespace = kstrndup(fs_name_start, len, GFP_KERNEL); + if (!fsopt->mds_namespace) + return -ENOMEM; + } else if (!strstrn_equals(fsopt->mds_namespace, fs_name_start, len)) { return invalfc(fc, "Mismatching mds_namespace"); - kfree(fsopt->mds_namespace); - fsopt->mds_namespace = kstrndup(fs_name_start, len, GFP_KERNEL); - if (!fsopt->mds_namespace) - return -ENOMEM; + } dout("file system (mds namespace) '%s'\n", fsopt->mds_namespace); fsopt->new_dev_syntax = true; @@ -417,11 +410,12 @@ static int ceph_parse_mount_param(struct fs_context *fc, param->string = NULL; break; case Opt_mds_namespace: - if (!namespace_equals(fsopt, param->string, strlen(param->string))) + if (!fsopt->mds_namespace) { + fsopt->mds_namespace = param->string; + param->string = NULL; + } else if (strcmp(fsopt->mds_namespace, param->string)) { return invalfc(fc, "Mismatching mds_namespace"); - kfree(fsopt->mds_namespace); - fsopt->mds_namespace = param->string; - param->string = NULL; + } break; case Opt_recover_session: mode = result.uint_32; From patchwork Sun May 7 17:55:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6IOh546u5paH?= X-Patchwork-Id: 13233876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B002C77B7C for ; Sun, 7 May 2023 17:56:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231574AbjEGR4A (ORCPT ); Sun, 7 May 2023 13:56:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231589AbjEGRz6 (ORCPT ); Sun, 7 May 2023 13:55:58 -0400 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2078.outbound.protection.outlook.com [40.92.98.78]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE6BA2D5A for ; Sun, 7 May 2023 10:55:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dvpVGKdYyiFslaUvb0urfeaHAy7aoGQEfhf2sZuBj4BbNPdU53iky0ENdT5NlDRhU6vGgKmyAtaNSrtUl+BvX5bpQfiwcTiN7iYm3D9UmRLOJOZigKCkj7QQZnbxH95f8kiQozOmVTaA4g/iaJjzGrwoMtffcNrn5zrH9dh9M5WSw6djduId8d9V9h24Upxl0mWj8gzaA7AMceJAVoXaUqVIrwZMidwjRO9EWLgAAWsBt9ynzm578piKfg9Bdpn5vV2Rri1CmQ31JST8qXE0aO9P3SlFDGy5j7JQ+TcxeJONi0ZFqI49dsTX/xiqDAdI/LhCsi9U7Gc5ROlOds2R/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=dljNDeKBZpr8V9Y2xjpt41bszf2ggxqge9/3DaLellM=; b=WEwDfy8ch7ykJH/IaP3CxNK21oTW+BZt93UhYKL2tgENxRNpP9dSpbg/WufQk7lPZERJhp2YwdJjWR6hNjP3G0sazkDoz0BooRDUmMqzAjKiM7+3hoHnl6o08vJPh2tb7rJ5I4ZBtHECf7jpmFfl1ybwrWx8rUh5CLcDLph9Nk7YmBkOUGp1jjMS42zmjun3NijIVmUa7NdcqZpw22crhd9yvyGLtd7b7Ugz01zm4hDU1aZOxuE3CfUp4brgwtiQjgIch/UH5D+EynrTTlxWZNW/Jo7PgaH/XPgVD//cofvK0cNQlOYrsdopUVCab/vw30FX3XRxhxMAMpxtXAnX2w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dljNDeKBZpr8V9Y2xjpt41bszf2ggxqge9/3DaLellM=; b=ESuU5mcg4fD+nsRDaSDe9av49dAIqeodXPi/dLY17CR6LM3MOHurv9tt3f5I78T5bNQ1uABw7iG8XF891/5o3AV5GO6mYLhjrcPu5JzQSRCt2WQqqt8GrOHCDLie9d/in+hV2k8rmfr3NeJF0JRK9JrhhYqdBmodtyKX8SQKyZOwOOaCuxcBbD+S78JoN5KJuM9kQzv/PvRPZD8lFDVpw3NeM8WW6fsXoTF2cehKDftv2ONG5Md+vbDSjz4wB/lVd01aGOnFReUfrLT7PtU+qoyYdpmPz9fl1OS+/ExRRC87CnhC6HASRNbOJp0snAYSV+ao+x4UrIhwFUMb9u3T6g== Received: from TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::14) by OS3P286MB2567.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1fa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Sun, 7 May 2023 17:55:53 +0000 Received: from TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM ([fe80::d9fd:1e8f:2bf4:e44]) by TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM ([fe80::d9fd:1e8f:2bf4:e44%6]) with mapi id 15.20.6363.032; Sun, 7 May 2023 17:55:53 +0000 From: Hu Weiwen To: ceph-devel@vger.kernel.org, Xiubo Li , Ilya Dryomov Cc: Venky Shankar , Hu Weiwen Subject: [PATCH 2/3] ceph: save name and fsid in mount source Date: Mon, 8 May 2023 01:55:02 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [DrpjcnO5JzNGwxT7AVaZDez40YW26uez] X-ClientProxiedBy: BY5PR16CA0033.namprd16.prod.outlook.com (2603:10b6:a03:1a0::46) To TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::14) X-Microsoft-Original-Message-ID: <20230507175503.2271-2-huww98@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCP286MB2066:EE_|OS3P286MB2567:EE_ X-MS-Office365-Filtering-Correlation-Id: a401ee80-3b2a-4663-cf1f-08db4f244cce X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1dmCNUf4xnHAPSGfacaop2COJUYlAUUonmnSSTypGFw8+wO/CdZC5k+zMYIok/9B+XBE72aNEI+xzY7E/W7tkCnGKhUs7WuScCk/rgAFRrckSWT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Pws+E4mk/MezeXVmGTmhSntAAhPM+Ph5wrmFJKNghHBpDTxLzRYv0RI+uJwuFQLvaa8gqYt9FXucs0uM8zeOwabnSWGRERsbCyU4ceEKHOKvXhFpxR8ZRAXmFg17ZLzWehSuklo5VwfXY0eKZVIF5RbSHiN2yY3SN66pHswLxm0tyK+64s77HFr+AZASti0ZN0hBNJ/kulMVSqoXywa7uQ8k4VVkFuXgPwM8qkLHAou0M6NM0V7njqi4MEakMoh0VFQvFOsuqkZMfRCRybRxytWvdAhy/G02Q1r+DO5WcVmjsI61c7NAhQ5CIwfNZprRBUMYtwJP7k6VD5BaQpUbXylRrOi1nfHW7WwT5aZgJLNa/ClMGF/YPwZPNYKMjp3kj5wpT7mby6jAPYBU/cjYP9RhV12C9DW83rtlt+zNCaAGToufu+GJyKHLhFN/foYGo3XbOyUeaUMlGUiinQD4IoFXUSO2RAYprSsCh8lV5Tq7U0be1pqOQ4Remy011Wpz/ckNl/l2Anzh11PgeCRbf/lYx9f1q6zMG6OjRA2YXguht/sCsAFVfCIgciu3sSnfVdSmlmg7DLozXOo621gMHcxcOkhXAyVVO3GSGhaa7GQQGABMskoA3ThBt+KdKirtrOU7LtyoE1eWCZKJmr1ox+2YMmuP7msDdb1KMWixmbB1qUmYg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a401ee80-3b2a-4663-cf1f-08db4f244cce X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2023 17:55:53.5514 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB2567 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Hu Weiwen We have name and fsid in the new device syntax. It is confusing that the kernel accept these info but do not take them into account when connecting to the cluster. Although the mount.ceph helper program will extract the name from device spec and pass it as name options, these changes are still useful if we don't have that program installed, or if we want to call `mount()' directly. Signed-off-by: Hu Weiwen --- fs/ceph/super.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/fs/ceph/super.c b/fs/ceph/super.c index 4e1f4031e888..74636b9383b8 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -267,6 +267,7 @@ static int ceph_parse_new_source(const char *dev_name, const char *dev_name_end, struct ceph_fsid fsid; struct ceph_parse_opts_ctx *pctx = fc->fs_private; struct ceph_mount_options *fsopt = pctx->opts; + struct ceph_options *copts = pctx->copts; char *fsid_start, *fs_name_start; if (*dev_name_end != '=') { @@ -285,6 +286,12 @@ static int ceph_parse_new_source(const char *dev_name, const char *dev_name_end, if (ceph_parse_fsid(fsid_start, &fsid)) return invalfc(fc, "Invalid FSID"); + if (!(copts->flags & CEPH_OPT_FSID)) { + copts->fsid = fsid; + copts->flags |= CEPH_OPT_FSID; + } else if (ceph_fsid_compare(&fsid, &copts->fsid)) { + return invalfc(fc, "Mismatching cluster FSID"); + } ++fs_name_start; /* start of file system name */ len = dev_name_end - fs_name_start; @@ -298,6 +305,16 @@ static int ceph_parse_new_source(const char *dev_name, const char *dev_name_end, } dout("file system (mds namespace) '%s'\n", fsopt->mds_namespace); + len = fsid_start - dev_name - 1; + if (!copts->name) { + copts->name = kstrndup(dev_name, len, GFP_KERNEL); + if (!copts->name) + return -ENOMEM; + } else if (!strstrn_equals(copts->name, dev_name, len)) { + return invalfc(fc, "Mismatching cephx name"); + } + dout("cephx name '%s'\n", copts->name); + fsopt->new_dev_syntax = true; return 0; } From patchwork Sun May 7 17:55:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?6IOh546u5paH?= X-Patchwork-Id: 13233877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD675C77B7D for ; Sun, 7 May 2023 17:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230450AbjEGR4I (ORCPT ); Sun, 7 May 2023 13:56:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231589AbjEGR4G (ORCPT ); Sun, 7 May 2023 13:56:06 -0400 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2031.outbound.protection.outlook.com [40.92.98.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A74392D50 for ; Sun, 7 May 2023 10:56:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hbqHueXb9DH/3kplGHCn0zS8Sren8SdC6m60olKWAEtgvsRvSDRNIA9o7Z/yVNYzK0PoKzSqDTmtOCDRSOFon/m0G401l38miULmxl8sBSENiC9Rk4OAxwVuHFfo7OeeiZuyPvrCvi9Ksef1YN5CRr9z2wgqShos2Y835KYGrroos4wYYuYQIRz2/BdyDBWwcvzvbEt89GQjEE4tB3dldyOHBx5JtttXQGgipXpwGwsZUNyZM0yPsU7czN7+sdei31aYkoKfVzaJJdC0MGi9q2ys50ufvYd22hm1glZq8IAT2DR/SSjdrft2ZIn70AXfTpWK4ooRqNiz46Z7I2hdjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=SRDtaGdt2/6sK6FxdX5m8CKiWIGMeoS8voZ9oV98+4Y=; b=cLSeqEXfuz8u9gSGtLFQnKAs6jdFj25pbSpFd+BTBYTUoup7hW56tmfcDUhgIZBxsm8odZw5dyovyuAw0RhPkntLj37RQ9lmhe67KJrsIyKOK/l2fNeHS7NTqbpkcQrGkJYahrg+vnH7ccmatas3skxtzembG9OEygVqSOgVr/txJkiYjthSBt3auJnCB2+mydQ7JTZ5p6pQKUBxHM0LkOhlwEOEXVRgi83hl+PQneF0jJbBQlMcROtPmbHk1xR8P1YNceOlAq6l1XbobngPtkpBufWANTDKFFnboJHy5pN4jPE2tQ0ky+Wb57hS9D80VKqjwEpgluzdpL0c6LViHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SRDtaGdt2/6sK6FxdX5m8CKiWIGMeoS8voZ9oV98+4Y=; b=kFlQIJEJt/z7bHl7gRG6ZLWumetPZw2mZPqv539TGKLsaEGR/6aAfFV583GBvvBFcVacsIjQf05JgZdyIR6HmnjfR+6Y+4f3yIssx6gxZ+ISvjGz6RtxDyMfh0XCpGOOnWejMPJ9j3gaR5ZsfVB37uW5wk4cVtJ+hQOWQ8DSEtsoVvLGY7PmYcLp90TyRSo/GvgNK1zbtxP4ix8mtzylTUqnHJPkHlQtJZXIaoDbTpvSsMyZWYJSb+NEMlnhQqYOUTaXdhjno8SEEfXOhlg7kXw1j/xNwQoe1mvvj6kkJ2ldRituODCCJgF32hINkEMzEx7NEWvCQ75xIw3k8mccsQ== Received: from TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::14) by OS3P286MB2567.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:1fa::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Sun, 7 May 2023 17:56:01 +0000 Received: from TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM ([fe80::d9fd:1e8f:2bf4:e44]) by TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM ([fe80::d9fd:1e8f:2bf4:e44%6]) with mapi id 15.20.6363.032; Sun, 7 May 2023 17:56:01 +0000 From: Hu Weiwen To: ceph-devel@vger.kernel.org, Xiubo Li , Ilya Dryomov Cc: Venky Shankar , Hu Weiwen Subject: [PATCH 3/3] libceph: reject mismatching name and fsid Date: Mon, 8 May 2023 01:55:03 +0800 Message-ID: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: X-TMN: [jSPRQhFXM6Ozvf5IyVDEVUjzzzOs80bP] X-ClientProxiedBy: BY5PR16CA0033.namprd16.prod.outlook.com (2603:10b6:a03:1a0::46) To TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:152::14) X-Microsoft-Original-Message-ID: <20230507175503.2271-3-huww98@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYCP286MB2066:EE_|OS3P286MB2567:EE_ X-MS-Office365-Filtering-Correlation-Id: 783528b9-459d-45d4-d749-08db4f24519c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E/natYHQCywiIz5yIxly+7xYgoSicy6tWELAZ2z99YgRcprDtiGyhoFxjnYT8HmiWAT7IQxkPMrA9RIKpYTZuG+hvZLwQdjdelppw05H5K+/rMWAbnAaL4JGeVfaL5xRqembs5UzG9u14u+JlJUg8QCJCsw65GHwQiTkEtb9j+HEAPtgyRQEVrnxgXa3OLLkiS4Q03NRQwoc56YFfzYk/ODGztcM6tdX++Flz8BJ/SIXt1xP3Sx2Bm2qZ6fzh1ErDurF4rTqSp0t9ERIEY4GHgv4paPGW2C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jTXZRFhL8r44n+Bt0Qi202LIuM6Z5D1rGD2OwQgzirSc5y1LufoUDwLufijzegFHoZdzxdF/NEb+dWpj8wrE5W7wcF8EgMAOMVy8LLwFuOgrJUtEBmDYRNfrD7FO7FiquopK6YZPmGNuiRRBtUPyLA+fKGTnQtXpgZi2ONJcpAoEs9b949DnRBFzDUZznCVyKodRtVHo7FmJsJxFCW8eBvfaMZu2trt/4l+jCxrz5F3s7bl3BIuKN7TYDLmxMZDIUWyqwGYlTOcV80CMPr2a61ZxMsjWeBIp7IBnqJ5d+KzB8AVw2S90c+mFDV5GPp86vhClPBQEsPBHMEFVITcVjIjI4mjyPjzZauMUDqLnyeCZxfpk8MOQs3y7UzyfdA+JTMBja/sEUO/+6kLtnaYDkOIXKQjtefmGvpoltqEQeEIaLZBDXqUpjlMiv/shN9ko+tTKMGlkIK0MscWYimW0T6pT4ox+v4amrBUkVuhAhix434l+wo+GKgbprQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 783528b9-459d-45d4-d749-08db4f24519c X-MS-Exchange-CrossTenant-AuthSource: TYCP286MB2066.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 May 2023 17:56:01.6165 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB2567 Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org From: Hu Weiwen These are present in the device spec of cephfs. So they should be treated as immutable. Also reject `mount()' calls where options and device spec are inconsistent. Signed-off-by: Hu Weiwen --- net/ceph/ceph_common.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/net/ceph/ceph_common.c b/net/ceph/ceph_common.c index 4c6441536d55..c59c5ccc23a8 100644 --- a/net/ceph/ceph_common.c +++ b/net/ceph/ceph_common.c @@ -440,17 +440,33 @@ int ceph_parse_param(struct fs_parameter *param, struct ceph_options *opt, break; case Opt_fsid: - err = ceph_parse_fsid(param->string, &opt->fsid); + { + struct ceph_fsid fsid; + + err = ceph_parse_fsid(param->string, &fsid); if (err) { error_plog(&log, "Failed to parse fsid: %d", err); return err; } - opt->flags |= CEPH_OPT_FSID; + + if (!(opt->flags & CEPH_OPT_FSID)) { + opt->fsid = fsid; + opt->flags |= CEPH_OPT_FSID; + } else if (ceph_fsid_compare(&opt->fsid, &fsid)) { + error_plog(&log, "fsid already set to %pU", + &opt->fsid); + return -EINVAL; + } break; + } case Opt_name: - kfree(opt->name); - opt->name = param->string; - param->string = NULL; + if (!opt->name) { + opt->name = param->string; + param->string = NULL; + } else if (strcmp(opt->name, param->string)) { + error_plog(&log, "name already set to %s", opt->name); + return -EINVAL; + } break; case Opt_secret: ceph_crypto_key_destroy(opt->key);