Skip to content

Commit 290e916

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 290e916

3 files changed

Lines changed: 331 additions & 208 deletions

File tree

libnvme/src/nvme/private.h

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -202,20 +202,20 @@ struct libnvme_path { // !generate-accessors
202202

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

207207
struct libnvme_ctrl *c;
208208
struct libnvme_ns *n;
209209

210210
char *name;
211211
char *sysfs_dir;
212-
char *ana_state; // !access:none
213-
char *numa_nodes; // !access:none
212+
char *ana_state; // !access:read=custom,write=none
213+
char *numa_nodes; // !access:read=custom,write=none
214214
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
215+
int queue_depth; // !access:read=custom,write=none
216+
long multipath_failover_count; // !access:read=custom,write=none
217+
long command_retry_count; // !access:read=custom,write=none
218+
long command_error_count; // !access:read=custom,write=none
219219
};
220220

221221
struct libnvme_ns_head {
@@ -236,12 +236,12 @@ struct libnvme_ns { // !generate-accessors
236236

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

241241
struct libnvme_transport_handle *hdl;
242242
__u32 nsid;
243243
char *name;
244-
char *generic_name; // !access:none
244+
char *generic_name; // !access:read=custom,write=none
245245
char *sysfs_dir;
246246

247247
int lba_shift;
@@ -255,10 +255,10 @@ struct libnvme_ns { // !generate-accessors
255255
unsigned char uuid[NVME_UUID_LEN];
256256
enum nvme_csi csi;
257257

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
258+
long command_retry_count; // !access:read=custom,write=none
259+
long command_error_count; // !access:read=custom,write=none
260+
long requeue_no_usable_path_count; // !access:read=custom,write=none
261+
long fail_no_available_path_count; // !access:read=custom,write=none
262262
};
263263

264264
struct libnvme_ctrl { // !generate-accessors
@@ -269,38 +269,38 @@ struct libnvme_ctrl { // !generate-accessors
269269

270270
struct libnvme_global_ctx *ctx;
271271
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
272+
char *name; // !access:read=generated,write=none
273+
char *sysfs_dir; // !access:read=generated,write=none
274+
char *address; // !access:read=custom,write=none
275+
char *firmware; // !access:read=generated,write=none
276+
char *model; // !access:read=generated,write=none
277+
char *state; // !access:read=custom,write=none
278+
char *numa_node; // !access:read=generated,write=none
279+
char *queue_count; // !access:read=generated,write=none
280+
char *serial; // !access:read=generated,write=none
281+
char *sqsize; // !access:read=generated,write=none
282+
char *transport; // !access:read=generated,write=none
283+
char *subsysnqn; // !access:read=generated,write=none
284+
char *traddr; // !access:read=generated,write=none
285+
char *trsvcid; // !access:read=generated,write=none
286286
char *dhchap_host_key;
287287
char *dhchap_ctrl_key;
288288
char *keyring;
289289
char *tls_key_identity;
290290
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
291+
char *cntrltype; // !access:read=generated,write=none
292+
char *cntlid; // !access:read=generated,write=none
293+
char *dctype; // !access:read=generated,write=none
294+
char *phy_slot; // !access:read=generated,write=none
295+
char *host_traddr; // !access:read=generated,write=none
296+
char *host_iface; // !access:read=generated,write=none
297297
bool discovery_ctrl;
298298
bool unique_discovery_ctrl;
299299
bool discovered;
300300
bool persistent;
301-
long command_error_count; // !access:none
302-
long reset_count; // !access:none
303-
long reconnect_count; // !access:none
301+
long command_error_count; // !access:read=custom,write=none
302+
long reset_count; // !access:read=custom,write=none
303+
long reconnect_count; // !access:read=custom,write=none
304304
struct libnvme_fabrics_config cfg;
305305
};
306306

@@ -310,27 +310,27 @@ struct libnvme_subsystem { // !generate-accessors
310310
struct list_head namespaces;
311311
struct libnvme_host *h;
312312

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
313+
char *name; // !access:read=generated,write=none
314+
char *sysfs_dir; // !access:read=generated,write=none
315+
char *subsysnqn; // !access:read=generated,write=none
316+
char *model; // !access:read=generated,write=none
317+
char *serial; // !access:read=generated,write=none
318+
char *firmware; // !access:read=generated,write=none
319+
char *subsystype; // !access:read=generated,write=none
320320
char *application;
321-
char *iopolicy; // !access:none
321+
char *iopolicy; // !access:read=custom,write=none
322322
};
323323

324324
struct libnvme_host { // !generate-accessors
325325
struct list_node entry;
326326
struct list_head subsystems;
327327
struct libnvme_global_ctx *ctx;
328328

329-
char *hostnqn; // !access:readonly
330-
char *hostid; // !access:readonly
329+
char *hostnqn; // !access:read=generated,write=none
330+
char *hostid; // !access:read=generated,write=none
331331
char *dhchap_host_key;
332332
char *hostsymname;
333-
bool pdc_enabled; // !access:none
333+
bool pdc_enabled; // !access:read=none,write=custom
334334
bool pdc_enabled_valid; /* set if pdc_enabled doesn't have an undefined
335335
* value */
336336
};

0 commit comments

Comments
 (0)