Re: [PATCH v2 1/1] sed-opal: geometry feature reporting command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 11, 2023 at 11:09:31AM +0200, Ondrej Kozina wrote:
> Locking range start and locking range length
> attributes may be require to satisfy restrictions
> exposed by OPAL2 geometry feature reporting.
> 
> Geometry reporting feature is described in TCG OPAL SSC,
> section 3.1.1.4 (ALIGN, LogicalBlockSize, AlignmentGranularity
> and LowestAlignedLBA).
> 
> 4.3.5.2.1.1 RangeStart Behavior:
> 
> [ StartAlignment = (RangeStart modulo AlignmentGranularity) - LowestAlignedLBA ]
> 
> When processing a Set method or CreateRow method on the Locking
> table for a non-Global Range row, if:
> 
> a) the AlignmentRequired (ALIGN above) column in the LockingInfo
>    table is TRUE;
> b) RangeStart is non-zero; and
> c) StartAlignment is non-zero, then the method SHALL fail and
>    return an error status code INVALID_PARAMETER.
> 
> 4.3.5.2.1.2 RangeLength Behavior:
> 
> If RangeStart is zero, then
> 	[ LengthAlignment = (RangeLength modulo AlignmentGranularity) - LowestAlignedLBA ]
> 
> If RangeStart is non-zero, then
> 	[ LengthAlignment = (RangeLength modulo AlignmentGranularity) ]
> 
> When processing a Set method or CreateRow method on the Locking
> table for a non-Global Range row, if:
> 
> a) the AlignmentRequired (ALIGN above) column in the LockingInfo
>    table is TRUE;
> b) RangeLength is non-zero; and
> c) LengthAlignment is non-zero, then the method SHALL fail and
>    return an error status code INVALID_PARAMETER
> 
> In userspace we stuck to logical block size reported by general
> block device (via sysfs or ioctl), but we can not read
> 'AlignmentGranularity' or 'LowestAlignedLBA' anywhere else and
> we need to get those values from sed-opal interface otherwise
> we will not be able to report or avoid locking range setup
> INVALID_PARAMETER errors above.
> 
> Signed-off-by: Ondrej Kozina <okozina@xxxxxxxxxx>
> ---
>  block/sed-opal.c              | 29 ++++++++++++++++++++++++++++-
>  include/linux/sed-opal.h      |  1 +
>  include/uapi/linux/sed-opal.h | 13 +++++++++++++
>  3 files changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/block/sed-opal.c b/block/sed-opal.c
> index 3fc4e65db111..c18339446ef3 100644
> --- a/block/sed-opal.c
> +++ b/block/sed-opal.c
> @@ -83,8 +83,10 @@ struct opal_dev {
>  	u16 comid;
>  	u32 hsn;
>  	u32 tsn;
> -	u64 align;
> +	u64 align; /* alignment granularity */
>  	u64 lowest_lba;
> +	u32 logical_block_size;
> +	u8  align_required; /* ALIGN: 0 or 1 */
>  
>  	size_t pos;
>  	u8 *cmd;
> @@ -409,6 +411,8 @@ static void check_geometry(struct opal_dev *dev, const void *data)
>  
>  	dev->align = be64_to_cpu(geo->alignment_granularity);
>  	dev->lowest_lba = be64_to_cpu(geo->lowest_aligned_lba);
> +	dev->logical_block_size = be32_to_cpu(geo->logical_block_size);
> +	dev->align_required = geo->reserved01 & 1;

This is really ugly. Both the naming of the variable and testing against
an unnamed constant. I'd prefer if that could be fixed but otherwise,

Reviewed-by: Christian Brauner <brauner@xxxxxxxxxx>



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux