diff mbox series

sed-opal: add support flag for SUM in status ioctl

Message ID 20230210010612.28729-1-luca.boccassi@gmail.com (mailing list archive)
State Accepted
Headers show
Series sed-opal: add support flag for SUM in status ioctl | expand

Commit Message

Luca Boccassi Feb. 10, 2023, 1:06 a.m. UTC
From: Luca Boccassi <bluca@debian.org>

Not every OPAL drive supports SUM (Single User Mode), so report this
information to userspace via the get-status ioctl so that we can adjust
the formatting options accordingly.
Tested on a kingston drive (which supports it) and a samsung one
(which does not).

Signed-off-by: Luca Boccassi <bluca@debian.org>
---
 block/sed-opal.c              | 2 ++
 include/uapi/linux/sed-opal.h | 1 +
 2 files changed, 3 insertions(+)

Comments

Luca Boccassi Feb. 16, 2023, 8:57 p.m. UTC | #1
On Fri, 10 Feb 2023 at 01:06, <luca.boccassi@gmail.com> wrote:
>
> From: Luca Boccassi <bluca@debian.org>
>
> Not every OPAL drive supports SUM (Single User Mode), so report this
> information to userspace via the get-status ioctl so that we can adjust
> the formatting options accordingly.
> Tested on a kingston drive (which supports it) and a samsung one
> (which does not).
>
> Signed-off-by: Luca Boccassi <bluca@debian.org>
> ---
>  block/sed-opal.c              | 2 ++
>  include/uapi/linux/sed-opal.h | 1 +
>  2 files changed, 3 insertions(+)
>
> diff --git a/block/sed-opal.c b/block/sed-opal.c
> index 463873f61e01..c320093c14f1 100644
> --- a/block/sed-opal.c
> +++ b/block/sed-opal.c
> @@ -487,6 +487,8 @@ static int opal_discovery0_end(struct opal_dev *dev)
>                         break;
>                 case FC_SINGLEUSER:
>                         single_user = check_sum(body->features);
> +                       if (single_user)
> +                               dev->flags |= OPAL_FL_SUM_SUPPORTED;
>                         break;
>                 case FC_GEOMETRY:
>                         check_geometry(dev, body);
> diff --git a/include/uapi/linux/sed-opal.h b/include/uapi/linux/sed-opal.h
> index 1fed3c9294fc..d7a1524023db 100644
> --- a/include/uapi/linux/sed-opal.h
> +++ b/include/uapi/linux/sed-opal.h
> @@ -144,6 +144,7 @@ struct opal_read_write_table {
>  #define OPAL_FL_LOCKED                 0x00000008
>  #define OPAL_FL_MBR_ENABLED            0x00000010
>  #define OPAL_FL_MBR_DONE               0x00000020
> +#define OPAL_FL_SUM_SUPPORTED          0x00000040
>
>  struct opal_status {
>         __u32 flags;

Hi,

Any chance for a quick review, please? Would have loved to have this
for the 6.3 merge window, it's a super simple change.
Thanks!

Kind regards,
Luca Boccassi
Luca Boccassi Feb. 16, 2023, 9:30 p.m. UTC | #2
On Thu, 16 Feb 2023 at 20:57, Luca Boccassi <bluca@debian.org> wrote:
>
> On Fri, 10 Feb 2023 at 01:06, <luca.boccassi@gmail.com> wrote:
> >
> > From: Luca Boccassi <bluca@debian.org>
> >
> > Not every OPAL drive supports SUM (Single User Mode), so report this
> > information to userspace via the get-status ioctl so that we can adjust
> > the formatting options accordingly.
> > Tested on a kingston drive (which supports it) and a samsung one
> > (which does not).
> >
> > Signed-off-by: Luca Boccassi <bluca@debian.org>
> > ---
> >  block/sed-opal.c              | 2 ++
> >  include/uapi/linux/sed-opal.h | 1 +
> >  2 files changed, 3 insertions(+)
> >
> > diff --git a/block/sed-opal.c b/block/sed-opal.c
> > index 463873f61e01..c320093c14f1 100644
> > --- a/block/sed-opal.c
> > +++ b/block/sed-opal.c
> > @@ -487,6 +487,8 @@ static int opal_discovery0_end(struct opal_dev *dev)
> >                         break;
> >                 case FC_SINGLEUSER:
> >                         single_user = check_sum(body->features);
> > +                       if (single_user)
> > +                               dev->flags |= OPAL_FL_SUM_SUPPORTED;
> >                         break;
> >                 case FC_GEOMETRY:
> >                         check_geometry(dev, body);
> > diff --git a/include/uapi/linux/sed-opal.h b/include/uapi/linux/sed-opal.h
> > index 1fed3c9294fc..d7a1524023db 100644
> > --- a/include/uapi/linux/sed-opal.h
> > +++ b/include/uapi/linux/sed-opal.h
> > @@ -144,6 +144,7 @@ struct opal_read_write_table {
> >  #define OPAL_FL_LOCKED                 0x00000008
> >  #define OPAL_FL_MBR_ENABLED            0x00000010
> >  #define OPAL_FL_MBR_DONE               0x00000020
> > +#define OPAL_FL_SUM_SUPPORTED          0x00000040
> >
> >  struct opal_status {
> >         __u32 flags;
>
> Hi,
>
> Any chance for a quick review, please? Would have loved to have this
> for the 6.3 merge window, it's a super simple change.
> Thanks!

CC'ed couple more reviewers as suggested by Christian

Kind regards,
Luca Boccassi
Jens Axboe Feb. 17, 2023, 3:08 a.m. UTC | #3
On 2/9/23 6:06 PM, luca.boccassi@gmail.com wrote:
> From: Luca Boccassi <bluca@debian.org>
> 
> Not every OPAL drive supports SUM (Single User Mode), so report this
> information to userspace via the get-status ioctl so that we can adjust
> the formatting options accordingly.
> Tested on a kingston drive (which supports it) and a samsung one
> (which does not).

Looks fine to me - Jonathan, are you still maintaining this code?
We can still get this done for 6.3. I just sent out the first
merge request, but there will be more down the line. I'll queue it
up on top for now.
Jens Axboe Feb. 17, 2023, 3:09 a.m. UTC | #4
On Fri, 10 Feb 2023 01:06:12 +0000, luca.boccassi@gmail.com wrote:
> Not every OPAL drive supports SUM (Single User Mode), so report this
> information to userspace via the get-status ioctl so that we can adjust
> the formatting options accordingly.
> Tested on a kingston drive (which supports it) and a samsung one
> (which does not).
> 
> 
> [...]

Applied, thanks!

[1/1] sed-opal: add support flag for SUM in status ioctl
      commit: 0ac12f4afb4d0a6a2c4e42b350b6b9d71b88fa35

Best regards,
diff mbox series

Patch

diff --git a/block/sed-opal.c b/block/sed-opal.c
index 463873f61e01..c320093c14f1 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -487,6 +487,8 @@  static int opal_discovery0_end(struct opal_dev *dev)
 			break;
 		case FC_SINGLEUSER:
 			single_user = check_sum(body->features);
+			if (single_user)
+				dev->flags |= OPAL_FL_SUM_SUPPORTED;
 			break;
 		case FC_GEOMETRY:
 			check_geometry(dev, body);
diff --git a/include/uapi/linux/sed-opal.h b/include/uapi/linux/sed-opal.h
index 1fed3c9294fc..d7a1524023db 100644
--- a/include/uapi/linux/sed-opal.h
+++ b/include/uapi/linux/sed-opal.h
@@ -144,6 +144,7 @@  struct opal_read_write_table {
 #define OPAL_FL_LOCKED			0x00000008
 #define OPAL_FL_MBR_ENABLED		0x00000010
 #define OPAL_FL_MBR_DONE		0x00000020
+#define OPAL_FL_SUM_SUPPORTED		0x00000040
 
 struct opal_status {
 	__u32 flags;