Skip to content

Commit 1a0ccef

Browse files
author
Martin Belanger
committed
libnvme: replace single-mode access annotation with a two-axis model
Replace the single-mode !access:<value> annotation with an orthogonal two-axis spec: !access:read=<mode>,write=<mode> where read and write are independent and each takes one of: generated (generator emits the accessor), custom (hand-written accessor in the public API, generator emits nothing), or none (no accessor exists). The same spec is accepted at the struct level via !generate-accessors:read=<mode>,write=<mode>, with per-axis inheritance from the struct-level default to member-level overrides. The new model lets downstream consumers (the Python-binding generator, the nvme.i consistency check) distinguish "no accessor" from "hand-written accessor", and cleanly expresses mixed cases such as "generated getter + hand-written setter" that the old one-dimensional annotation could not name. This is a clean break: the old :none / :readonly / :writeonly / :readwrite tokens are no longer recognised. See libnvme/tools/generator/generate-accessors.md for the full syntax, inheritance rules, and examples. All 47 !access: annotations in private.h are updated accordingly. The regenerated accessors.{h,c,ld} are byte-identical to the pre-change baseline. Signed-off-by: Martin Belanger <[email protected]> Assisted-by: Claude Opus 4.7 <[email protected]>
1 parent 82ce758 commit 1a0ccef

3 files changed

Lines changed: 349 additions & 225 deletions

File tree

libnvme/src/nvme/private.h

Lines changed: 65 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -196,26 +196,27 @@ struct libnvme_stat {
196196
double ts_ms; /* timestamp when the stat is updated */
197197
};
198198

199-
struct libnvme_path { // !generate-accessors
199+
struct libnvme_path { // !generate-accessors:read=custom,write=none
200200
struct list_node entry;
201201
struct list_node nentry;
202202

203203
struct libnvme_stat stat[2]; /* gendisk I/O stat */
204-
unsigned int curr_idx; /* current index into the stat[] */
205-
bool diffstat; // !access:none
204+
// curr_idx: current index into the stat[]
205+
unsigned int curr_idx; // !access:read=generated,write=generated
206+
bool diffstat; // !access:read=none
206207

207208
struct libnvme_ctrl *c;
208209
struct libnvme_ns *n;
209210

210-
char *name;
211-
char *sysfs_dir;
212-
char *ana_state; // !access:none
213-
char *numa_nodes; // !access:none
214-
int grpid;
215-
int queue_depth; // !access:none
216-
long multipath_failover_count; // !access:none
217-
long command_retry_count; // !access:none
218-
long command_error_count; // !access:none
211+
char *name; // !access:read=generated,write=generated
212+
char *sysfs_dir; // !access:read=generated,write=generated
213+
char *ana_state;
214+
char *numa_nodes;
215+
int grpid; // !access:read=generated,write=generated
216+
int queue_depth;
217+
long multipath_failover_count;
218+
long command_retry_count;
219+
long command_error_count;
219220
};
220221

221222
struct libnvme_ns_head {
@@ -236,12 +237,12 @@ struct libnvme_ns { // !generate-accessors
236237

237238
struct libnvme_stat stat[2]; /* gendisk I/O stat */
238239
unsigned int curr_idx; /* current index into the stat[] */
239-
bool diffstat; // !access:none
240+
bool diffstat; // !access:read=none,write=none
240241

241242
struct libnvme_transport_handle *hdl;
242243
__u32 nsid;
243244
char *name;
244-
char *generic_name; // !access:none
245+
char *generic_name; // !access:read=custom,write=none
245246
char *sysfs_dir;
246247

247248
int lba_shift;
@@ -255,82 +256,82 @@ struct libnvme_ns { // !generate-accessors
255256
unsigned char uuid[NVME_UUID_LEN];
256257
enum nvme_csi csi;
257258

258-
long command_retry_count; // !access:none
259-
long command_error_count; // !access:none
260-
long requeue_no_usable_path_count; // !access:none
261-
long fail_no_available_path_count; // !access:none
259+
long command_retry_count; // !access:read=custom,write=none
260+
long command_error_count; // !access:read=custom,write=none
261+
long requeue_no_usable_path_count; // !access:read=custom,write=none
262+
long fail_no_available_path_count; // !access:read=custom,write=none
262263
};
263264

264-
struct libnvme_ctrl { // !generate-accessors
265+
struct libnvme_ctrl { // !generate-accessors:read=generated,write=none
265266
struct list_node entry;
266267
struct list_head paths;
267268
struct list_head namespaces;
268269
struct libnvme_subsystem *s;
269270

270271
struct libnvme_global_ctx *ctx;
271272
struct libnvme_transport_handle *hdl;
272-
char *name; // !access:readonly
273-
char *sysfs_dir; // !access:readonly
274-
char *address; // !access:none
275-
char *firmware; // !access:readonly
276-
char *model; // !access:readonly
277-
char *state; // !access:none
278-
char *numa_node; // !access:readonly
279-
char *queue_count; // !access:readonly
280-
char *serial; // !access:readonly
281-
char *sqsize; // !access:readonly
282-
char *transport; // !access:readonly
283-
char *subsysnqn; // !access:readonly
284-
char *traddr; // !access:readonly
285-
char *trsvcid; // !access:readonly
286-
char *dhchap_host_key;
287-
char *dhchap_ctrl_key;
288-
char *keyring;
289-
char *tls_key_identity;
290-
char *tls_key;
291-
char *cntrltype; // !access:readonly
292-
char *cntlid; // !access:readonly
293-
char *dctype; // !access:readonly
294-
char *phy_slot; // !access:readonly
295-
char *host_traddr; // !access:readonly
296-
char *host_iface; // !access:readonly
297-
bool discovery_ctrl;
298-
bool unique_discovery_ctrl;
299-
bool discovered;
300-
bool persistent;
301-
long command_error_count; // !access:none
302-
long reset_count; // !access:none
303-
long reconnect_count; // !access:none
273+
char *name;
274+
char *sysfs_dir;
275+
char *address; // !access:read=custom
276+
char *firmware;
277+
char *model;
278+
char *state; // !access:read=custom
279+
char *numa_node;
280+
char *queue_count;
281+
char *serial;
282+
char *sqsize;
283+
char *transport;
284+
char *subsysnqn;
285+
char *traddr;
286+
char *trsvcid;
287+
char *dhchap_host_key; // !access:write=generated
288+
char *dhchap_ctrl_key; // !access:write=generated
289+
char *keyring; // !access:write=generated
290+
char *tls_key_identity; // !access:write=generated
291+
char *tls_key; // !access:write=generated
292+
char *cntrltype;
293+
char *cntlid;
294+
char *dctype;
295+
char *phy_slot;
296+
char *host_traddr;
297+
char *host_iface;
298+
bool discovery_ctrl; // !access:write=generated
299+
bool unique_discovery_ctrl; // !access:write=generated
300+
bool discovered; // !access:write=generated
301+
bool persistent; // !access:write=generated
302+
long command_error_count; // !access:read=custom
303+
long reset_count; // !access:read=custom
304+
long reconnect_count; // !access:read=custom
304305
struct libnvme_fabrics_config cfg;
305306
};
306307

307-
struct libnvme_subsystem { // !generate-accessors
308+
struct libnvme_subsystem { // !generate-accessors:read=generated,write=none
308309
struct list_node entry;
309310
struct list_head ctrls;
310311
struct list_head namespaces;
311312
struct libnvme_host *h;
312313

313-
char *name; // !access:readonly
314-
char *sysfs_dir; // !access:readonly
315-
char *subsysnqn; // !access:readonly
316-
char *model; // !access:readonly
317-
char *serial; // !access:readonly
318-
char *firmware; // !access:readonly
319-
char *subsystype; // !access:readonly
320-
char *application;
321-
char *iopolicy; // !access:none
314+
char *name;
315+
char *sysfs_dir;
316+
char *subsysnqn;
317+
char *model;
318+
char *serial;
319+
char *firmware;
320+
char *subsystype;
321+
char *application; // !access:write=generated
322+
char *iopolicy; // !access:read=custom
322323
};
323324

324325
struct libnvme_host { // !generate-accessors
325326
struct list_node entry;
326327
struct list_head subsystems;
327328
struct libnvme_global_ctx *ctx;
328329

329-
char *hostnqn; // !access:readonly
330-
char *hostid; // !access:readonly
330+
char *hostnqn; // !access:read=generated,write=none
331+
char *hostid; // !access:read=generated,write=none
331332
char *dhchap_host_key;
332333
char *hostsymname;
333-
bool pdc_enabled; // !access:none
334+
bool pdc_enabled; // !access:read=none,write=custom
334335
bool pdc_enabled_valid; /* set if pdc_enabled doesn't have an undefined
335336
* value */
336337
};

0 commit comments

Comments
 (0)