All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] bio-integrity: add "bip_max_vcnt" into struct bio_integrity_payload
@ 2014-06-27 10:12 Gu Zheng
  2014-06-29 23:15 ` Martin K. Petersen
  0 siblings, 1 reply; 4+ messages in thread
From: Gu Zheng @ 2014-06-27 10:12 UTC (permalink / raw)
  To: Jens; +Cc: martin.petersen, linux-kernel, Kent, Andrew Morton

Commit "08778795"(block: Fix nr_vecs for inline integrity vectors) from
Martin introduces the function bip_integrity_vecs(get the useful vectors)
to fix the issue about nr_vecs for inline integrity vectors that reported
by David Milburn.
But it seems that bip_integrity_vecs() will return the wrong number if
the bio is not based on any bio_set for some reason(bio->bi_pool == NULL),
because in that case, the bip_inline_vecs[0] is malloced directly.
So here we add the bip_max_vcnt to record the count of vector slots, and
cleanup the function bip_integrity_vecs().

Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
---
 block/bio-integrity.c |   12 +++---------
 include/linux/bio.h   |    1 +
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 9e24106..bc423f7b 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -70,8 +70,10 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
 					  bs->bvec_integrity_pool);
 		if (!bip->bip_vec)
 			goto err;
+		bip->bip_max_vcnt = bvec_nr_vecs(idx);
 	} else {
 		bip->bip_vec = bip->bip_inline_vecs;
+		bip->bip_max_vcnt = inline_vecs;
 	}
 
 	bip->bip_slab = idx;
@@ -114,14 +116,6 @@ void bio_integrity_free(struct bio *bio)
 }
 EXPORT_SYMBOL(bio_integrity_free);
 
-static inline unsigned int bip_integrity_vecs(struct bio_integrity_payload *bip)
-{
-	if (bip->bip_slab == BIO_POOL_NONE)
-		return BIP_INLINE_VECS;
-
-	return bvec_nr_vecs(bip->bip_slab);
-}
-
 /**
  * bio_integrity_add_page - Attach integrity metadata
  * @bio:	bio to update
@@ -137,7 +131,7 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,
 	struct bio_integrity_payload *bip = bio->bi_integrity;
 	struct bio_vec *iv;
 
-	if (bip->bip_vcnt >= bip_integrity_vecs(bip)) {
+	if (bip->bip_vcnt >= bip->bip_max_vcnt) {
 		printk(KERN_ERR "%s: bip_vec full\n", __func__);
 		return 0;
 	}
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 5a64576..1946d72 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -299,6 +299,7 @@ struct bio_integrity_payload {
 
 	unsigned short		bip_slab;	/* slab the bip came from */
 	unsigned short		bip_vcnt;	/* # of integrity bio_vecs */
+	unsigned short		bip_max_vcnt;	/* integrity bio_vec slots */
 	unsigned		bip_owns_buf:1;	/* should free bip_buf */
 
 	struct work_struct	bip_work;	/* I/O completion */
-- 
1.7.7


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

* Re: [RFC PATCH] bio-integrity: add "bip_max_vcnt" into struct bio_integrity_payload
  2014-06-27 10:12 [RFC PATCH] bio-integrity: add "bip_max_vcnt" into struct bio_integrity_payload Gu Zheng
@ 2014-06-29 23:15 ` Martin K. Petersen
  2014-06-30  3:39   ` Gu Zheng
  0 siblings, 1 reply; 4+ messages in thread
From: Martin K. Petersen @ 2014-06-29 23:15 UTC (permalink / raw)
  To: Gu Zheng; +Cc: Jens, martin.petersen, linux-kernel, Kent, Andrew Morton

>>>>> "Gu" == Gu Zheng <guz.fnst@cn.fujitsu.com> writes:

[Sorry about the delay. I'm on vacation right now.]

Gu> But it seems that bip_integrity_vecs() will return the wrong number
Gu> if the bio is not based on any bio_set for some reason(bio->bi_pool
Gu> == NULL), because in that case, the bip_inline_vecs[0] is malloced
Gu> directly.  So here we add the bip_max_vcnt to record the count of
Gu> vector slots, and cleanup the function bip_integrity_vecs().

I'm in agreement with your fix.

However, I'm still not sure what the use case is for bios without an
associated bioset. I do not see any callers that pass in a NULL bioset.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [RFC PATCH] bio-integrity: add "bip_max_vcnt" into struct bio_integrity_payload
  2014-06-29 23:15 ` Martin K. Petersen
@ 2014-06-30  3:39   ` Gu Zheng
  2014-06-30 15:56     ` Martin K. Petersen
  0 siblings, 1 reply; 4+ messages in thread
From: Gu Zheng @ 2014-06-30  3:39 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: Jens, linux-kernel, Kent, Andrew Morton

Hi Martin,
On 06/30/2014 07:15 AM, Martin K. Petersen wrote:

>>>>>> "Gu" == Gu Zheng <guz.fnst@cn.fujitsu.com> writes:
> 
> [Sorry about the delay. I'm on vacation right now.]
> 
> Gu> But it seems that bip_integrity_vecs() will return the wrong number
> Gu> if the bio is not based on any bio_set for some reason(bio->bi_pool
> Gu> == NULL), because in that case, the bip_inline_vecs[0] is malloced
> Gu> directly.  So here we add the bip_max_vcnt to record the count of
> Gu> vector slots, and cleanup the function bip_integrity_vecs().
> 
> I'm in agreement with your fix.

Thanks.

> 
> However, I'm still not sure what the use case is for bios without an
> associated bioset. I do not see any callers that pass in a NULL bioset.

Please refer to bio_kmalloc()--alloc bio via kmalloc.
And IMO, the API(e.g. bio_alloc_bioset) is EXPORT, any guys(including
some out of mainline code, some special drivers) can alloc a bio via
kmalloc without based on associated bioset.

Regards,
Gu

> 



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

* Re: [RFC PATCH] bio-integrity: add "bip_max_vcnt" into struct bio_integrity_payload
  2014-06-30  3:39   ` Gu Zheng
@ 2014-06-30 15:56     ` Martin K. Petersen
  0 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2014-06-30 15:56 UTC (permalink / raw)
  To: Gu Zheng; +Cc: Martin K. Petersen, Jens, linux-kernel, Kent, Andrew Morton

>>>>> "Gu" == Gu Zheng <guz.fnst@cn.fujitsu.com> writes:

Gu> Please refer to bio_kmalloc()--alloc bio via kmalloc. 

OK, missed that one because it was in bio.h.

In that case we absolutely need your patch.

Acked-by: Martin K. Petersen <martin.petersen@oracle.com>

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2014-06-30 15:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-27 10:12 [RFC PATCH] bio-integrity: add "bip_max_vcnt" into struct bio_integrity_payload Gu Zheng
2014-06-29 23:15 ` Martin K. Petersen
2014-06-30  3:39   ` Gu Zheng
2014-06-30 15:56     ` Martin K. Petersen

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.