[PATCH 06/14] block: Make protection interval calculation generic

2014-08-28 Thread Martin K. Petersen
Now that the protection interval has been detached from the sector size
we need to be able to handle sizes that are different from 4K and
512. Make the interval calculation generic.

Signed-off-by: Martin K. Petersen martin.peter...@oracle.com
Reviewed-by: Christoph Hellwig h...@lst.de
Reviewed-by: Sagi Grimberg sa...@mellanox.com
---
 block/bio-integrity.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index a2b3e994b55b..396244b1e774 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -197,11 +197,7 @@ EXPORT_SYMBOL(bio_integrity_enabled);
 static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
   unsigned int sectors)
 {
-   /* At this point there are only 512b or 4096b DIF/EPP devices */
-   if (bi-interval == 4096)
-   return sectors = 3;
-
-   return sectors;
+   return sectors  (ilog2(bi-interval) - 9);
 }
 
 static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
-- 
1.9.3

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/14] block: Make protection interval calculation generic

2014-08-06 Thread Sagi Grimberg

On 7/25/2014 11:34 PM, Martin K. Petersen wrote:

Now that the protection interval has been detached from the sector size
we need to be able to handle sizes that are different from 4K and
512. Make the interval calculation generic.

Signed-off-by: Martin K. Petersen martin.peter...@oracle.com
---
  block/bio-integrity.c | 6 +-
  1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 8c03c78281e9..320ce7df1a5f 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -203,11 +203,7 @@ EXPORT_SYMBOL(bio_integrity_enabled);
  static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
   unsigned int sectors)
  {
-   /* At this point there are only 512b or 4096b DIF/EPP devices */
-   if (bi-interval == 4096)
-   return sectors = 3;
-
-   return sectors;
+   return sectors  (ilog2(bi-interval) - 9);
  }

  static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,



Looks good to me,

Reviewed-by: Sagi Grimberg sa...@mellanox.com
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/14] block: Make protection interval calculation generic

2014-07-26 Thread Christoph Hellwig
On Fri, Jul 25, 2014 at 04:34:21PM -0400, Martin K. Petersen wrote:
 + return sectors  (ilog2(bi-interval) - 9);

I was going to say this should be 'SECTOR_SHIFT', but that constant
or variants of it are only defined locally in various subsystems..

Looks good,

Reviewed-by: Christoph Hellwig h...@lst.de
--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/14] block: Make protection interval calculation generic

2014-07-25 Thread Martin K. Petersen
Now that the protection interval has been detached from the sector size
we need to be able to handle sizes that are different from 4K and
512. Make the interval calculation generic.

Signed-off-by: Martin K. Petersen martin.peter...@oracle.com
---
 block/bio-integrity.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 8c03c78281e9..320ce7df1a5f 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -203,11 +203,7 @@ EXPORT_SYMBOL(bio_integrity_enabled);
 static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
   unsigned int sectors)
 {
-   /* At this point there are only 512b or 4096b DIF/EPP devices */
-   if (bi-interval == 4096)
-   return sectors = 3;
-
-   return sectors;
+   return sectors  (ilog2(bi-interval) - 9);
 }
 
 static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
-- 
1.9.3

--
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html