* [PATCH 1/1] nvme: use macro definitions for setting reservation values
@ 2022-09-29 11:59 Max Gurtovoy
2022-09-29 18:47 ` Sagi Grimberg
2022-09-29 18:56 ` Keith Busch
0 siblings, 2 replies; 3+ messages in thread
From: Max Gurtovoy @ 2022-09-29 11:59 UTC (permalink / raw)
To: linux-nvme, sagi, hch, kbusch; +Cc: oren, chaitanyak, linux-block, Max Gurtovoy
This makes the code more readable.
Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
---
drivers/nvme/host/core.c | 12 ++++++------
include/linux/nvme.h | 12 ++++++++++++
2 files changed, 18 insertions(+), 6 deletions(-)
diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3f1a7dc2a2a3..50668e1bd9f1 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2068,17 +2068,17 @@ static char nvme_pr_type(enum pr_type type)
{
switch (type) {
case PR_WRITE_EXCLUSIVE:
- return 1;
+ return NVME_PR_WRITE_EXCLUSIVE;
case PR_EXCLUSIVE_ACCESS:
- return 2;
+ return NVME_PR_EXCLUSIVE_ACCESS;
case PR_WRITE_EXCLUSIVE_REG_ONLY:
- return 3;
+ return NVME_PR_WRITE_EXCLUSIVE_REG_ONLY;
case PR_EXCLUSIVE_ACCESS_REG_ONLY:
- return 4;
+ return NVME_PR_EXCLUSIVE_ACCESS_REG_ONLY;
case PR_WRITE_EXCLUSIVE_ALL_REGS:
- return 5;
+ return NVME_PR_WRITE_EXCLUSIVE_ALL_REGS;
case PR_EXCLUSIVE_ACCESS_ALL_REGS:
- return 6;
+ return NVME_PR_EXCLUSIVE_ACCESS_ALL_REGS;
default:
return 0;
}
diff --git a/include/linux/nvme.h b/include/linux/nvme.h
index ae53d74f3696..a925be0056f2 100644
--- a/include/linux/nvme.h
+++ b/include/linux/nvme.h
@@ -238,6 +238,18 @@ enum {
NVME_CAP_CRMS_CRIMS = 1ULL << 60,
};
+/*
+ * Reservation Type Encoding
+ */
+enum {
+ NVME_PR_WRITE_EXCLUSIVE = 1, /* Write Exclusive Reservation */
+ NVME_PR_EXCLUSIVE_ACCESS = 2, /* Exclusive Access Reservation */
+ NVME_PR_WRITE_EXCLUSIVE_REG_ONLY = 3, /* Write Exclusive - Registrants Only Reservation */
+ NVME_PR_EXCLUSIVE_ACCESS_REG_ONLY = 4, /* Exclusive Access - Registrants Only Reservation */
+ NVME_PR_WRITE_EXCLUSIVE_ALL_REGS = 5, /* Write Exclusive - All Registrants Reservation */
+ NVME_PR_EXCLUSIVE_ACCESS_ALL_REGS = 6, /* Exclusive Access - All Registrants Reservation */
+};
+
struct nvme_id_power_state {
__le16 max_power; /* centiwatts */
__u8 rsvd2;
--
2.18.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] nvme: use macro definitions for setting reservation values
2022-09-29 11:59 [PATCH 1/1] nvme: use macro definitions for setting reservation values Max Gurtovoy
@ 2022-09-29 18:47 ` Sagi Grimberg
2022-09-29 18:56 ` Keith Busch
1 sibling, 0 replies; 3+ messages in thread
From: Sagi Grimberg @ 2022-09-29 18:47 UTC (permalink / raw)
To: Max Gurtovoy, linux-nvme, hch, kbusch; +Cc: oren, chaitanyak, linux-block
> This makes the code more readable.
I find it readable as it is. But I don't particularly
care about it all that much.
> Signed-off-by: Max Gurtovoy <mgurtovoy@nvidia.com>
> ---
> drivers/nvme/host/core.c | 12 ++++++------
> include/linux/nvme.h | 12 ++++++++++++
> 2 files changed, 18 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 3f1a7dc2a2a3..50668e1bd9f1 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2068,17 +2068,17 @@ static char nvme_pr_type(enum pr_type type)
> {
> switch (type) {
> case PR_WRITE_EXCLUSIVE:
> - return 1;
> + return NVME_PR_WRITE_EXCLUSIVE;
> case PR_EXCLUSIVE_ACCESS:
> - return 2;
> + return NVME_PR_EXCLUSIVE_ACCESS;
> case PR_WRITE_EXCLUSIVE_REG_ONLY:
> - return 3;
> + return NVME_PR_WRITE_EXCLUSIVE_REG_ONLY;
> case PR_EXCLUSIVE_ACCESS_REG_ONLY:
> - return 4;
> + return NVME_PR_EXCLUSIVE_ACCESS_REG_ONLY;
> case PR_WRITE_EXCLUSIVE_ALL_REGS:
> - return 5;
> + return NVME_PR_WRITE_EXCLUSIVE_ALL_REGS;
> case PR_EXCLUSIVE_ACCESS_ALL_REGS:
> - return 6;
> + return NVME_PR_EXCLUSIVE_ACCESS_ALL_REGS;
> default:
> return 0;
> }
> diff --git a/include/linux/nvme.h b/include/linux/nvme.h
> index ae53d74f3696..a925be0056f2 100644
> --- a/include/linux/nvme.h
> +++ b/include/linux/nvme.h
> @@ -238,6 +238,18 @@ enum {
> NVME_CAP_CRMS_CRIMS = 1ULL << 60,
> };
>
> +/*
> + * Reservation Type Encoding
> + */
> +enum {
> + NVME_PR_WRITE_EXCLUSIVE = 1, /* Write Exclusive Reservation */
> + NVME_PR_EXCLUSIVE_ACCESS = 2, /* Exclusive Access Reservation */
> + NVME_PR_WRITE_EXCLUSIVE_REG_ONLY = 3, /* Write Exclusive - Registrants Only Reservation */
> + NVME_PR_EXCLUSIVE_ACCESS_REG_ONLY = 4, /* Exclusive Access - Registrants Only Reservation */
> + NVME_PR_WRITE_EXCLUSIVE_ALL_REGS = 5, /* Write Exclusive - All Registrants Reservation */
> + NVME_PR_EXCLUSIVE_ACCESS_ALL_REGS = 6, /* Exclusive Access - All Registrants Reservation */
The comments are unneeded, the enums themselves are
self-explanatory (and also mirror the pr_type enums themselves).
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1] nvme: use macro definitions for setting reservation values
2022-09-29 11:59 [PATCH 1/1] nvme: use macro definitions for setting reservation values Max Gurtovoy
2022-09-29 18:47 ` Sagi Grimberg
@ 2022-09-29 18:56 ` Keith Busch
1 sibling, 0 replies; 3+ messages in thread
From: Keith Busch @ 2022-09-29 18:56 UTC (permalink / raw)
To: Max Gurtovoy; +Cc: linux-nvme, sagi, hch, oren, chaitanyak, linux-block
On Thu, Sep 29, 2022 at 02:59:19PM +0300, Max Gurtovoy wrote:
> +/*
> + * Reservation Type Encoding
> + */
> +enum {
> + NVME_PR_WRITE_EXCLUSIVE = 1, /* Write Exclusive Reservation */
> + NVME_PR_EXCLUSIVE_ACCESS = 2, /* Exclusive Access Reservation */
> + NVME_PR_WRITE_EXCLUSIVE_REG_ONLY = 3, /* Write Exclusive - Registrants Only Reservation */
> + NVME_PR_EXCLUSIVE_ACCESS_REG_ONLY = 4, /* Exclusive Access - Registrants Only Reservation */
> + NVME_PR_WRITE_EXCLUSIVE_ALL_REGS = 5, /* Write Exclusive - All Registrants Reservation */
> + NVME_PR_EXCLUSIVE_ACCESS_ALL_REGS = 6, /* Exclusive Access - All Registrants Reservation */
> +};
The comments are unnecessary, and this would be more readable if the values
were tab aligned like 'enum pr_type'.
Otherwise looks good.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-29 18:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-29 11:59 [PATCH 1/1] nvme: use macro definitions for setting reservation values Max Gurtovoy
2022-09-29 18:47 ` Sagi Grimberg
2022-09-29 18:56 ` Keith Busch
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).