All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libata: fix ata_id_logical_per_physical_sectors
@ 2010-01-28 10:42 Christoph Hellwig
  2010-01-28 10:56 ` Sergei Shtylyov
  2010-01-28 12:30 ` [PATCH v2] " Christoph Hellwig
  0 siblings, 2 replies; 8+ messages in thread
From: Christoph Hellwig @ 2010-01-28 10:42 UTC (permalink / raw)
  To: jgarzik; +Cc: linux-ide, stable

The value we get from the low byte of the ATA_ID_SECTOR_SIZE word is not not
a plain multiple, but the log of it, so fix the helper to give the correct
answer.  Without this we'll get an incorrect minimal I/O size in the block
limits VPD page for 4k sector drives.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/include/linux/ata.h
===================================================================
--- linux-2.6.orig/include/linux/ata.h	2010-01-28 11:17:41.968003842 +0100
+++ linux-2.6/include/linux/ata.h	2010-01-28 11:20:02.355268610 +0100
@@ -649,7 +649,7 @@ static inline int ata_id_has_large_logic
 
 static inline u8 ata_id_logical_per_physical_sectors(const u16 *id)
 {
-	return id[ATA_ID_SECTOR_SIZE] & 0xf;
+	return 1 << (id[ATA_ID_SECTOR_SIZE] & 0xf);
 }
 
 static inline int ata_id_has_lba48(const u16 *id)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] libata: fix ata_id_logical_per_physical_sectors
  2010-01-28 10:42 [PATCH] libata: fix ata_id_logical_per_physical_sectors Christoph Hellwig
@ 2010-01-28 10:56 ` Sergei Shtylyov
  2010-01-28 10:59   ` Christoph Hellwig
  2010-01-28 12:30 ` [PATCH v2] " Christoph Hellwig
  1 sibling, 1 reply; 8+ messages in thread
From: Sergei Shtylyov @ 2010-01-28 10:56 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jgarzik, linux-ide, stable

Hello.

Christoph Hellwig wrote:

> The value we get from the low byte of the ATA_ID_SECTOR_SIZE word is not not
> a plain multiple, but the log of it, so fix the helper to give the correct
> answer.  Without this we'll get an incorrect minimal I/O size in the block
> limits VPD page for 4k sector drives.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> Index: linux-2.6/include/linux/ata.h
> ===================================================================
> --- linux-2.6.orig/include/linux/ata.h	2010-01-28 11:17:41.968003842 +0100
> +++ linux-2.6/include/linux/ata.h	2010-01-28 11:20:02.355268610 +0100
> @@ -649,7 +649,7 @@ static inline int ata_id_has_large_logic
>  
>  static inline u8 ata_id_logical_per_physical_sectors(const u16 *id)
>  {
> -	return id[ATA_ID_SECTOR_SIZE] & 0xf;
> +	return 1 << (id[ATA_ID_SECTOR_SIZE] & 0xf);
>   

   Will this still fit into u8?

WBR, Sergei



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] libata: fix ata_id_logical_per_physical_sectors
  2010-01-28 10:56 ` Sergei Shtylyov
@ 2010-01-28 10:59   ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2010-01-28 10:59 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Christoph Hellwig, jgarzik, linux-ide, stable

On Thu, Jan 28, 2010 at 01:56:21PM +0300, Sergei Shtylyov wrote:
> > static inline u8 ata_id_logical_per_physical_sectors(const u16 *id)
> > {
> >-	return id[ATA_ID_SECTOR_SIZE] & 0xf;
> >+	return 1 << (id[ATA_ID_SECTOR_SIZE] & 0xf);
> >  
> 
>   Will this still fit into u8?

Right now the only value we get in practice is 8 for 4k sector drivers
which still fits fine into an u8.  But it might indeed be safer to use a
large value.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2] libata: fix ata_id_logical_per_physical_sectors
  2010-01-28 10:42 [PATCH] libata: fix ata_id_logical_per_physical_sectors Christoph Hellwig
  2010-01-28 10:56 ` Sergei Shtylyov
@ 2010-01-28 12:30 ` Christoph Hellwig
  2010-02-03 17:37   ` Christoph Hellwig
  1 sibling, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2010-01-28 12:30 UTC (permalink / raw)
  To: jgarzik; +Cc: linux-ide, stable

The value we get from the low byte of the ATA_ID_SECTOR_SIZE word is not not
a plain multiple, but the log of it, so fix the helper to give the correct
answer.  Without this we'll get an incorrect minimal I/O size in the block
limits VPD page for 4k sector drives.

Also change the return value of ata_id_logical_per_physical_sectors to u16
for the unlikely case of very large logical sectors.

Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/include/linux/ata.h
===================================================================
--- linux-2.6.orig/include/linux/ata.h	2010-01-28 12:24:02.061016474 +0100
+++ linux-2.6/include/linux/ata.h	2010-01-28 13:26:59.270005271 +0100
@@ -647,9 +647,9 @@ static inline int ata_id_has_large_logic
 	return id[ATA_ID_SECTOR_SIZE] & (1 << 13);
 }
 
-static inline u8 ata_id_logical_per_physical_sectors(const u16 *id)
+static inline u16 ata_id_logical_per_physical_sectors(const u16 *id)
 {
-	return id[ATA_ID_SECTOR_SIZE] & 0xf;
+	return 1 << (id[ATA_ID_SECTOR_SIZE] & 0xf);
 }
 
 static inline int ata_id_has_lba48(const u16 *id)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] libata: fix ata_id_logical_per_physical_sectors
  2010-01-28 12:30 ` [PATCH v2] " Christoph Hellwig
@ 2010-02-03 17:37   ` Christoph Hellwig
  2010-02-03 17:42     ` Jeff Garzik
  2010-02-03 18:14     ` Martin K. Petersen
  0 siblings, 2 replies; 8+ messages in thread
From: Christoph Hellwig @ 2010-02-03 17:37 UTC (permalink / raw)
  To: jgarzik; +Cc: linux-ide, stable

Jeff, ping?  Without this patch the minimum I/O size for 4k drives will
be reported incorrectly, which will make paritions misaligned on modern
distros.

On Thu, Jan 28, 2010 at 01:30:11PM +0100, Christoph Hellwig wrote:
> The value we get from the low byte of the ATA_ID_SECTOR_SIZE word is not not
> a plain multiple, but the log of it, so fix the helper to give the correct
> answer.  Without this we'll get an incorrect minimal I/O size in the block
> limits VPD page for 4k sector drives.
> 
> Also change the return value of ata_id_logical_per_physical_sectors to u16
> for the unlikely case of very large logical sectors.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> 
> Index: linux-2.6/include/linux/ata.h
> ===================================================================
> --- linux-2.6.orig/include/linux/ata.h	2010-01-28 12:24:02.061016474 +0100
> +++ linux-2.6/include/linux/ata.h	2010-01-28 13:26:59.270005271 +0100
> @@ -647,9 +647,9 @@ static inline int ata_id_has_large_logic
>  	return id[ATA_ID_SECTOR_SIZE] & (1 << 13);
>  }
>  
> -static inline u8 ata_id_logical_per_physical_sectors(const u16 *id)
> +static inline u16 ata_id_logical_per_physical_sectors(const u16 *id)
>  {
> -	return id[ATA_ID_SECTOR_SIZE] & 0xf;
> +	return 1 << (id[ATA_ID_SECTOR_SIZE] & 0xf);
>  }
>  
>  static inline int ata_id_has_lba48(const u16 *id)
---end quoted text---

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] libata: fix ata_id_logical_per_physical_sectors
  2010-02-03 17:37   ` Christoph Hellwig
@ 2010-02-03 17:42     ` Jeff Garzik
  2010-02-03 18:14     ` Martin K. Petersen
  1 sibling, 0 replies; 8+ messages in thread
From: Jeff Garzik @ 2010-02-03 17:42 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-ide, stable

On 02/03/2010 12:37 PM, Christoph Hellwig wrote:
> Jeff, ping?  Without this patch the minimum I/O size for 4k drives will
> be reported incorrectly, which will make paritions misaligned on modern
> distros.

It's queued locally.  I'm waiting to push on the flush_dache_page() 
discussion for 2.6.33, but I'll make sure your patch gets pushed today 
one way or the other.

	Jeff



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] libata: fix ata_id_logical_per_physical_sectors
  2010-02-03 17:37   ` Christoph Hellwig
  2010-02-03 17:42     ` Jeff Garzik
@ 2010-02-03 18:14     ` Martin K. Petersen
  2010-02-03 18:17       ` Christoph Hellwig
  1 sibling, 1 reply; 8+ messages in thread
From: Martin K. Petersen @ 2010-02-03 18:14 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: jgarzik, linux-ide, stable

>>>>> "Christoph" == Christoph Hellwig <hch@lst.de> writes:

Christoph> Without this patch the minimum I/O size for 4k drives will be
Christoph> reported incorrectly, which will make paritions misaligned on
Christoph> modern distros.

I'm in total agreement with the patch (feel free to add my Acked-by:).

However, the minimum I/O size should still be reported correctly.  We
don't allow min_io to be smaller than physical_block_size...

[root@10 ~]# grep . /sys/block/sdc/queue/{logical_block,physical_block,minimum_io}_size
/sys/block/sdc/queue/logical_block_size:512
/sys/block/sdc/queue/physical_block_size:4096
/sys/block/sdc/queue/minimum_io_size:4096

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2] libata: fix ata_id_logical_per_physical_sectors
  2010-02-03 18:14     ` Martin K. Petersen
@ 2010-02-03 18:17       ` Christoph Hellwig
  0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2010-02-03 18:17 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: Christoph Hellwig, jgarzik, linux-ide, stable

On Wed, Feb 03, 2010 at 01:14:23PM -0500, Martin K. Petersen wrote:
> >>>>> "Christoph" == Christoph Hellwig <hch@lst.de> writes:
> 
> Christoph> Without this patch the minimum I/O size for 4k drives will be
> Christoph> reported incorrectly, which will make paritions misaligned on
> Christoph> modern distros.
> 
> I'm in total agreement with the patch (feel free to add my Acked-by:).
> 
> However, the minimum I/O size should still be reported correctly.  We
> don't allow min_io to be smaller than physical_block_size...

Indeed, I only verified it using sg_inq, not the sysfs files.


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-02-03 18:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-28 10:42 [PATCH] libata: fix ata_id_logical_per_physical_sectors Christoph Hellwig
2010-01-28 10:56 ` Sergei Shtylyov
2010-01-28 10:59   ` Christoph Hellwig
2010-01-28 12:30 ` [PATCH v2] " Christoph Hellwig
2010-02-03 17:37   ` Christoph Hellwig
2010-02-03 17:42     ` Jeff Garzik
2010-02-03 18:14     ` Martin K. Petersen
2010-02-03 18:17       ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.