Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp345642rdb; Thu, 5 Oct 2023 07:39:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHrGx5KU8UsicNVtACwEX/oKFVnndAKuPOFWE34H66VS/07TwVhjy+kHlOWrwrYs4GC9fGl X-Received: by 2002:a17:90b:1d88:b0:269:a96:981a with SMTP id pf8-20020a17090b1d8800b002690a96981amr4339008pjb.5.1696516747688; Thu, 05 Oct 2023 07:39:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696516747; cv=none; d=google.com; s=arc-20160816; b=Ts1JAfN7CkJ1sGkK/OnzUIGcn8wSQhWEELm4hAfDBBO7F7FKx6zMe6JqbnGv4GiLhv LpksxJStIfMapQnjgWhNiFw/ShpDiDV+6Aq2I/SuhNsm7KSxs3CIx6sIJf8FzVcBFRuw FDY0YgTfQ3lg4XDjK9cDyrspp7gMphrFWHTyH1I9mTmRUNjJwV7ZIECEFNCMC4KJXZw5 USh6xolAKhJ49M5q58pBLFY68T0djyFJOmCV/C/z5zQII2VzbNSA3nK2G7Y58qx9Mm6h 9VnhyMNFXvzQUf2SoD5zjHvg12nqGxdXJn3vEm699dTLK2fUfygwXM2fd6kMhWb7cxdW 8hPA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=H8JZiA+3dRyRGmyVexPYkU6o2QCrx7tBm/b++jQ8wX8=; fh=zcE+OJqPmldj7FltU1+Vt3WHo3tYzEofNjCIk6ErTaA=; b=T+uqBDOrFMPhw4HH2bSl+NkjDXCo+KwqRg9Es/IsutNqTvrIVmBkm1Sy6geK13LNzO HvxxKYbY56c7qLv3//KTwDaoT6Nt9mu3iayN6eFpTb38ELGlywgYWNI2SO1R04GDLGAV A3y+5UOxaRYDP9C3pWQXh+vXpVu6fVXn5SVhrtxdwrQdaQI2M9ER2IkHM3Rh3/8Cqn9B Ap2dxZWIdJccIIihW/A8uhrAeIveyuzMQ9u2LpPw5K86OTxeiEgw9bgCR7+gnb7H919A 4VaC+N7Do0Ia6IKTKnL1H3Tl06i1VsQmwfrdwzt4BNWjoNbkHpXWd3cZ4UbOVujzcFhf bM5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j1EsiQvZ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id lt24-20020a17090b355800b00276c22ca6a4si3806701pjb.147.2023.10.05.07.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:39:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=j1EsiQvZ; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 9ABFA85C6CE2; Thu, 5 Oct 2023 07:38:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237084AbjJEOi2 (ORCPT + 99 others); Thu, 5 Oct 2023 10:38:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235404AbjJEOgJ (ORCPT ); Thu, 5 Oct 2023 10:36:09 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F357144873 for ; Thu, 5 Oct 2023 07:00:34 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3AB4CC43215; Thu, 5 Oct 2023 13:59:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696514360; bh=5SmXWapcJyPZQUeif7XTx8G5LatpZwA1DoGJ9KZSHH0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=j1EsiQvZxi2OzCy8jzXh6IS84qtfOMBw8ea/qT3HyImvMlI0vOqtnTEOEgkV1P2Ms R7P6JWNUOcdaI4Qesf6+uZDVvs+InTeBeX/wpk87kXHfchAnovr1SuqU8Mox36MkFd Kv5Dk3n0rJWhKgkZR19XGzBEsZzHZpbYfRlg8zWRHxcUc7hnx3a5RvW9ivEydQgi6Z nCX6GVX4qGa3br/NzpchHu0lvpujd6ArQEPIRd6qRCwjgXXvN3BG9ShxWnnElIR73a o4qyfknOt5jVovGnPZubtlee+WMfnfcB0MqW6kVk5YMJVOhNzRrnNLf4QsgYDQEHxL cc96rJPwY9IEg== Date: Thu, 5 Oct 2023 06:59:19 -0700 From: Jakub Kicinski To: Lorenzo Bianconi Cc: Lorenzo Bianconi , Jeff Layton , linux-nfs@vger.kernel.org, neilb@suse.de, chuck.lever@oracle.com, netdev@vger.kernel.org Subject: Re: [PATCH] NFSD: convert write_threads and write_v4_end_grace to netlink commands Message-ID: <20231005065919.6001b7ca@kernel.org> In-Reply-To: References: <20231004100428.3ca993aa@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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-nfs@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:38:49 -0700 (PDT) On Thu, 5 Oct 2023 10:52:30 +0200 Lorenzo Bianconi wrote: > running ynl-regen.sh, I got the following error for the get method: > > $ ./tools/net/ynl/ynl-regen.sh > GEN kernel fs/nfsd/netlink.h > Traceback (most recent call last): > File "/home/lorenzo/workspace/nfsd-next/tools/net/ynl/ynl-gen-c.py", line 2609, in > main() > File "/home/lorenzo/workspace/nfsd-next/tools/net/ynl/ynl-gen-c.py", line 2445, in main > print_req_policy_fwd(cw, ri.struct['request'], ri=ri) > ~~~~~~~~~^^^^^^^^^^^ > KeyError: 'request' > > am I missing something? Not at all, the codegen was only handling dumps with no ops. This change seems to make it a little happier, at least it doesn't throw any exceptions. Will it work for your case? diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index 168fe612b029..593be2632f23 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -645,6 +645,33 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S self.inherited = [c_lower(x) for x in sorted(self._inherited)] +class StructNone: + def __init__(self, family, space_name): + self.family = family + self.space_name = space_name + self.attr_set = family.attr_sets[space_name] + + if family.name == c_lower(space_name): + self.render_name = f"{family.name}" + else: + self.render_name = f"{family.name}_{c_lower(space_name)}" + + self.request = False + self.reply = False + + self.attr_list = [] + self.attrs = dict() + + def __iter__(self): + yield from self.attrs + + def __getitem__(self, key): + return self.attrs[key] + + def member_list(self): + return self.attr_list + + class EnumEntry(SpecEnumEntry): def __init__(self, enum_set, yaml, prev, value_start): super().__init__(enum_set, yaml, prev, value_start) @@ -1041,9 +1068,12 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S if op_mode == 'notify': op_mode = 'do' for op_dir in ['request', 'reply']: - if op and op_dir in op[op_mode]: - self.struct[op_dir] = Struct(family, self.attr_set, - type_list=op[op_mode][op_dir]['attributes']) + if op: + if op_dir in op[op_mode]: + self.struct[op_dir] = Struct(family, self.attr_set, + type_list=op[op_mode][op_dir]['attributes']) + else: + self.struct[op_dir] = StructNone(family, self.attr_set) if op_mode == 'event': self.struct['reply'] = Struct(family, self.attr_set, type_list=op['event']['attributes']) @@ -1752,6 +1782,8 @@ _C_KW = { def print_req_type_helpers(ri): + if isinstance(ri.struct["request"], StructNone): + return print_alloc_wrapper(ri, "request") print_type_helpers(ri, "request") @@ -1773,6 +1805,8 @@ _C_KW = { def print_req_type(ri): + if isinstance(ri.struct["request"], StructNone): + return print_type(ri, "request") @@ -2515,9 +2549,8 @@ _C_KW = { if 'dump' in op: cw.p(f"/* {op.enum_name} - dump */") ri = RenderInfo(cw, parsed, args.mode, op, 'dump') - if 'request' in op['dump']: - print_req_type(ri) - print_req_type_helpers(ri) + print_req_type(ri) + print_req_type_helpers(ri) if not ri.type_consistent: print_rsp_type(ri) print_wrapped_type(ri) -- 2.41.0