Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1243128ioo; Fri, 27 May 2022 04:53:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzxnBb4m2dbchtxBKOHKAss02SWdPXaCB3OlUFkY1XLV0sC31ZiFIWstShO5tqJDfwUBuP X-Received: by 2002:a17:90a:6909:b0:1e0:cf24:3933 with SMTP id r9-20020a17090a690900b001e0cf243933mr8083210pjj.160.1653652384554; Fri, 27 May 2022 04:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653652384; cv=none; d=google.com; s=arc-20160816; b=KHZ2gFCCnSnRwP1BtMdHW4xczvWdUT/4Vt6HBh1jyVwhom+CSl0RmnO2u7LoPGw1KL hNbupp2eSK7WBlVH+cMic//D+8YESLtIluUUGQKwNybrddq+hKfhQqhsbMvVWGE3Ezvh qeMv3Wby5k7rl11W/MAWsGhwogTi4Uo2DLBzGWo5Ci9k2uKFQ05XfitjCEt7rQnRaFOx YEK6zgVh/E7v6entr1kGHD5PC+flVQY/7bliqzEOiEVvsD6PwA/agi8IgdBep/fdW+YO OKCX755BR5Bik5gSRiz8ykzNv03uuuv7nu8RYb2CMHnSAIQFz0hmDBUGMBIlzrv1teXh 2frg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=yJXqOz+uU25JvmhdChbh6XiN9Ren8ftiBWD/fyoXYhA=; b=Q/Tbou81jSnJGmRSAbH8/d531XujdS08PzU2zsECLrd2jtiSoJubZdJ4OLdEX1E451 A5uWTRR/tLfMMiVAw3YsKUUypO73Ubzwg++EJuUKijPZdza+0DHF5aGIageLBLduw8hQ r1IR9vaeGOPOPRyPQjfv1wSO8c9yUe6pHOZxhDUGcZs7erl8tqSJNpMsvKsHLOW3ErUb UF+tL4Mp5auhb7g7Oc2B/ZrUkBh7VqPEmMYaUVmmhxNJY0r59aDyuycVUwoCvLN3nr6b AEbNhjq+8Gio3gWzf9vqC9A0hASPhuKD0lZYrwvkdvYI95hWreYGIgXITTCUjnSs4/Tu qVNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="VheoLs/o"; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b6-20020a170902d50600b00162188be366si5499009plg.617.2022.05.27.04.52.45; Fri, 27 May 2022 04:53:04 -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=@redhat.com header.s=mimecast20190719 header.b="VheoLs/o"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345197AbiEZA4C (ORCPT + 99 others); Wed, 25 May 2022 20:56:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345755AbiEZAz1 (ORCPT ); Wed, 25 May 2022 20:55:27 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9D686DFE4 for ; Wed, 25 May 2022 17:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1653526524; h=from:from:reply-to:subject:subject: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=yJXqOz+uU25JvmhdChbh6XiN9Ren8ftiBWD/fyoXYhA=; b=VheoLs/oCfFZh1ZHZYdTrZ56TsdDfOuvSsfPjwnp4jD60vKvx+XUcq0/vZQ9dGNzBr0F97 sXlVPiiF5O1yejCGBYQ5FcLHWngndvQemC8qyKhQV06V0fzUNyhhV/ksmNxrCS2HlAfM4T qUIjX3gc/zH/xvSV9Z/qruNgP5IGbTE= Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-411-X18ThDBuPeOEyDoD4IBynQ-1; Wed, 25 May 2022 20:55:23 -0400 X-MC-Unique: X18ThDBuPeOEyDoD4IBynQ-1 Received: by mail-pj1-f69.google.com with SMTP id on14-20020a17090b1d0e00b001c7a548e4f7so2210323pjb.2 for ; Wed, 25 May 2022 17:55:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=yJXqOz+uU25JvmhdChbh6XiN9Ren8ftiBWD/fyoXYhA=; b=1WKApS3mCIa/9vuJO/BpjFvkw/VU/uXecjJtRs4Cd+BfhxnsrfVwJKae25o6Ck3cQQ UufuFeJs/Vy4iUS6rP1G8ZoxrG1AUBqJJThQBwvnEWSz6OxYYyhRbuFjXeJTJU1CZj46 zVqb3l3INfKADL9cKUTJbm0SWBKvXceDEQ9zS8iaQzBHuQVauTS4GzquvhUjdvuZVBJK F88Oc/qTjK5xXCKp5+x3tn55Ei00bZEnarzj0By0a9XsAgTvyOe44rYFP+ZaoTsR8YRg CtkojMibIVu5UOV6Ev/MQMay0HRbKupSh2FPx5/O1swqmLnAMHpXXTONq2O1y4+7SrGI q20w== X-Gm-Message-State: AOAM531r3VaToUL1n4kBt/uOFZRdhP5eND6tlnnQzCttAMs0ax7eqwPj 6xj8RCEf+XBdTCxQH6LScERe5gjDFx7g0NlZIypDTPNEChE/88c5PyTunKobnF2rQiY7i8RBB5l bTkQlW7bQXKIGDUtFjeWMs/rkxW1z7y2PVQtqXaPHlFCUmRi+09rwqMSZ+gymMKvfaLYvQ4rqig == X-Received: by 2002:a17:902:704a:b0:161:996e:bf4 with SMTP id h10-20020a170902704a00b00161996e0bf4mr35079486plt.118.1653526521844; Wed, 25 May 2022 17:55:21 -0700 (PDT) X-Received: by 2002:a17:902:704a:b0:161:996e:bf4 with SMTP id h10-20020a170902704a00b00161996e0bf4mr35079456plt.118.1653526521428; Wed, 25 May 2022 17:55:21 -0700 (PDT) Received: from [10.72.12.81] ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id k2-20020a170902f28200b0015e8d4eb1dcsm37852plc.38.2022.05.25.17.55.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 May 2022 17:55:20 -0700 (PDT) Subject: Re: [PATCH] ceph: use correct index when encoding client supported features To: =?UTF-8?Q?Lu=c3=ads_Henriques?= , Jeff Layton , Ilya Dryomov Cc: ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220524160627.20893-1-lhenriques@suse.de> From: Xiubo Li Message-ID: Date: Thu, 26 May 2022 08:55:15 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20220524160627.20893-1-lhenriques@suse.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,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 On 5/25/22 12:06 AM, Luís 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. When > 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 for the session features") > Signed-off-by: Luís 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, void *end) > if (count > 0) { > size_t i; > size_t size = FEATURE_BYTES(count); > + unsigned long bit; > > if (WARN_ON_ONCE(*p + 4 + size > end)) > return -ERANGE; > > ceph_encode_32(p, size); > memset(*p, 0, size); > - for (i = 0; i < count; i++) > - ((unsigned char*)(*p))[i / 8] |= BIT(feature_bits[i] % 8); > + for (i = 0; i < count; i++) { > + bit = feature_bits[i]; > + ((unsigned char *)(*p))[bit / 8] |= BIT(bit % 8); > + } > *p += 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 {} > LGTM. Just one small fix in the comment, since you have removed the 'CEPHFS_FEATURE_MAX', which makes no sense any more: 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 {         CEPHFS_FEATURE_MAX = CEPHFS_FEATURE_METRIC_COLLECT,  }; -/* - * This will always have the highest feature bit value - * as the last element of the array. - */  #define CEPHFS_FEATURES_CLIENT_SUPPORTED {     \         0, 1, 2, 3, 4, 5, 6, 7,                 \         CEPHFS_FEATURE_MIMIC,                   \ Merged into the testing branch. Thanks Luis. -- Xiubo