Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1732038ioo; Fri, 27 May 2022 15:54:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyi4z5EagNdTLIcJabFriuxt6EuGQzGa0nUkNNU1aBQZr1qf7idVCFDwgKWOqnF4aIdxCaT X-Received: by 2002:a65:6c07:0:b0:3f2:5efb:6c7 with SMTP id y7-20020a656c07000000b003f25efb06c7mr39115977pgu.496.1653692076979; Fri, 27 May 2022 15:54:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653692076; cv=none; d=google.com; s=arc-20160816; b=lylbN9KJDjxyVowIbQjHujiGCVeT8J2lwYf4EpvPqXTD3gASoGbRd8cu1bFbCRhIyD GOkkQjAE2BQM2OrhncxBZAGY667iq/S8qAjlY4UXAm4Z4gitiA0514wAjEZP/IAuMxH7 8mGBMWjg6b04CYaa1fAORQ8+sarh51dVrsU/i+x1H7XHDrZgZ5uNLZBlkOGmSK1ldE4j AI3VeRPMaEnTe4SriElKxZAFrmRD/jqmhvpJ8Oa1RWVU+G/v+DD8nNw4wuEEUXxkILaF O9MZ5zBBq6PIlR/wwxN+m0qt+yoIXSok+oS/J3g4bIEwQCXhnFFEASyY5a48ixaHP0Bo a3/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:in-reply-to:date:references:subject:cc:to:from :dkim-signature:dkim-signature; bh=4PNcFgUhLhWREVrd3nkcrMfGa8Rtl91s/gZZxYxrErY=; b=me2MXRpN3W48Cbu2j7B+u95fQLri0PoL0aGER96eiEipd8hnY5EZJxpioUQvnhDZ6+ aWEjXgSjoXja4tgj4lbvIHuXGofjEDyf8QJ4qeIOaPkWO6G689vmc4d1D3V0XGSvtlCy i3f/u/TSQCo00G8NXJGr3n19vMMUmWXkTzWYfntTZJ8S5yRbsompNueQVocDaGvSuq9T oupK13nDWIP5Fno/OYL0zKvlGpkXwnsjgSngX3zoVaq8b6enwAgX5mNs8VXz21Ywd4A3 WVvrnloiSsWRbo7Wc6iml4pvPYv+1eLmcqnS2yTbyM57KrqZPlX06j01LYK/gi5fOCj9 AW/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="efW0VoM/"; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y28-20020a634b1c000000b003db43fa2ed3si7302856pga.713.2022.05.27.15.54.24; Fri, 27 May 2022 15:54:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="efW0VoM/"; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344433AbiE0JPx (ORCPT + 99 others); Fri, 27 May 2022 05:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236098AbiE0JPv (ORCPT ); Fri, 27 May 2022 05:15:51 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD7B2D8B; Fri, 27 May 2022 02:15:50 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 9CD141F990; Fri, 27 May 2022 09:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1653642949; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4PNcFgUhLhWREVrd3nkcrMfGa8Rtl91s/gZZxYxrErY=; b=efW0VoM/ZOnFbsB7wh1BLUOlR/w3Gb/noJyvk8GhslDhaQzHL4xqVldI7YgzuCGJ5fhAbQ Ac53qMKQ9Gmumpc8CIj09F26o0wgBuiGmcpbwZl/7reojra8yV9WysDlt+jgIS8o+MX67G meteaOONF6AoWH8wAIjJLbIP+tUMSbY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1653642949; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4PNcFgUhLhWREVrd3nkcrMfGa8Rtl91s/gZZxYxrErY=; b=il3mgRpfqvUjjTgi7eXKWBdtb8O2Jp0b1nA2zZxzUjdfcaqQzz/LcEDKqkll3eJuFHPIis F7eQ4tSZzIP75+AA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 44BAA139C4; Fri, 27 May 2022 09:15:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id sZjxDcWWkGLITgAAMHmgww (envelope-from ); Fri, 27 May 2022 09:15:49 +0000 Received: from localhost (brahms.olymp [local]) by brahms.olymp (OpenSMTPD) with ESMTPA id ba8c5f5d; Fri, 27 May 2022 09:16:27 +0000 (UTC) From: =?utf-8?Q?Lu=C3=ADs_Henriques?= To: Xiubo Li Cc: Jeff Layton , Ilya Dryomov , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] ceph: use correct index when encoding client supported features References: <20220524160627.20893-1-lhenriques@suse.de> Date: Fri, 27 May 2022 10:16:27 +0100 In-Reply-To: (Xiubo Li's message of "Thu, 26 May 2022 08:55:15 +0800") Message-ID: <87h75bwd1w.fsf@brahms.olymp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Xiubo Li writes: > On 5/25/22 12:06 AM, Lu=C3=ADs Henriques wrote: >> Feature bits have to be encoded into the correct locations. This hasn't >> been an issue so far because the only hole in the feature bits was in bit >> 10 (CEPHFS_FEATURE_RECLAIM_CLIENT), which is located in the 2nd byte. W= hen >> adding more bits that go beyond the this 2nd byte, the bug will show up. >> >> Fixes: 9ba1e224538a ("ceph: allocate the correct amount of extra bytes f= or the session features") >> Signed-off-by: Lu=C3=ADs Henriques >> --- >> fs/ceph/mds_client.c | 7 +++++-- >> fs/ceph/mds_client.h | 2 -- >> 2 files changed, 5 insertions(+), 4 deletions(-) >> >> I hope I got this code right. I found this issue when trying to add an >> extra feature bit that would go beyond bit 15 and that wasn't showing up >> on the MDS side. >> >> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c >> index 1bd3e1bb0fdf..77e742b6fd30 100644 >> --- a/fs/ceph/mds_client.c >> +++ b/fs/ceph/mds_client.c >> @@ -1220,14 +1220,17 @@ static int encode_supported_features(void **p, v= oid *end) >> if (count > 0) { >> size_t i; >> size_t size =3D FEATURE_BYTES(count); >> + unsigned long bit; >>=20=20=20 >> if (WARN_ON_ONCE(*p + 4 + size > end)) >> return -ERANGE; >>=20=20=20 >> ceph_encode_32(p, size); >> memset(*p, 0, size); >> - for (i =3D 0; i < count; i++) >> - ((unsigned char*)(*p))[i / 8] |=3D BIT(feature_bits[i] % 8); >> + for (i =3D 0; i < count; i++) { >> + bit =3D feature_bits[i]; >> + ((unsigned char *)(*p))[bit / 8] |=3D BIT(bit % 8); >> + } >> *p +=3D size; >> } else { >> if (WARN_ON_ONCE(*p + 4 > end)) >> diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h >> index 33497846e47e..12901e3a6823 100644 >> --- a/fs/ceph/mds_client.h >> +++ b/fs/ceph/mds_client.h >> @@ -45,8 +45,6 @@ enum ceph_feature_type { >> CEPHFS_FEATURE_MULTI_RECONNECT, \ >> CEPHFS_FEATURE_DELEG_INO, \ >> CEPHFS_FEATURE_METRIC_COLLECT, \ >> - \ >> - CEPHFS_FEATURE_MAX, \ >> } >> #define CEPHFS_FEATURES_CLIENT_REQUIRED {} >>=20=20=20 > > LGTM. Just one small fix in the comment, since you have removed the=20 > 'CEPHFS_FEATURE_MAX', which makes no sense any more: Ah, yeah. I missed that. Thanks! Cheers, --=20 Lu=C3=ADs > diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h > index 33497846e47e..ac49344ea79e 100644 > --- a/fs/ceph/mds_client.h > +++ b/fs/ceph/mds_client.h > @@ -33,10 +33,6 @@ enum ceph_feature_type { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 CEPHFS_FEATURE_MAX =3D CEPHFS= _FEATURE_METRIC_COLLECT, > =C2=A0}; > > -/* > - * This will always have the highest feature bit value > - * as the last element of the array. > - */ > =C2=A0#define CEPHFS_FEATURES_CLIENT_SUPPORTED {=C2=A0=C2=A0=C2=A0=C2=A0= \ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 0, 1, 2, 3, 4, 5, 6, 7,=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0 \ > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 CEPHFS_FEATURE_MIMIC,=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 \ > > Merged into the testing branch. > > Thanks Luis. > > -- Xiubo >