From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Dmitry Monakhov <dmonakhov@openvz.org>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Shaohua Li <shli@kernel.org>,
linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org
Subject: [PATCH 3/9] bio-integrity: fix interface for bio_integrity_trim
Date: Thu, 29 Jun 2017 11:31:10 -0700 [thread overview]
Message-ID: <20170629183116.28685-4-hch@lst.de> (raw)
In-Reply-To: <20170629183116.28685-1-hch@lst.de>
From: Dmitry Monakhov <dmonakhov@openvz.org>
bio_integrity_trim inherent it's interface from bio_trim and accept
offset and size, but this API is error prone because data offset
must always be insync with bio's data offset. That is why we have
integrity update hook in bio_advance()
So only meaningful values are: offset == 0, sectors == bio_sectors(bio)
Let's just remove them completely.
Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Dmitry Monakhov <dmonakhov@openvz.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
block/bio-integrity.c | 11 ++---------
block/bio.c | 4 ++--
drivers/md/dm.c | 2 +-
include/linux/bio.h | 5 ++---
4 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 8c2253c59edb..3a0d71199fb0 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -433,22 +433,15 @@ EXPORT_SYMBOL(bio_integrity_advance);
/**
* bio_integrity_trim - Trim integrity vector
* @bio: bio whose integrity vector to update
- * @offset: offset to first data sector
- * @sectors: number of data sectors
*
* Description: Used to trim the integrity vector in a cloned bio.
- * The ivec will be advanced corresponding to 'offset' data sectors
- * and the length will be truncated corresponding to 'len' data
- * sectors.
*/
-void bio_integrity_trim(struct bio *bio, unsigned int offset,
- unsigned int sectors)
+void bio_integrity_trim(struct bio *bio)
{
struct bio_integrity_payload *bip = bio_integrity(bio);
struct blk_integrity *bi = bdev_get_integrity(bio->bi_bdev);
- bio_integrity_advance(bio, offset << 9);
- bip->bip_iter.bi_size = bio_integrity_bytes(bi, sectors);
+ bip->bip_iter.bi_size = bio_integrity_bytes(bi, bio_sectors(bio));
}
EXPORT_SYMBOL(bio_integrity_trim);
diff --git a/block/bio.c b/block/bio.c
index 8cd995f7d3c0..7a288d344638 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1862,7 +1862,7 @@ struct bio *bio_split(struct bio *bio, int sectors,
split->bi_iter.bi_size = sectors << 9;
if (bio_integrity(split))
- bio_integrity_trim(split, 0, sectors);
+ bio_integrity_trim(split);
bio_advance(bio, split->bi_iter.bi_size);
@@ -1896,7 +1896,7 @@ void bio_trim(struct bio *bio, int offset, int size)
bio->bi_iter.bi_size = size;
if (bio_integrity(bio))
- bio_integrity_trim(bio, 0, size);
+ bio_integrity_trim(bio);
}
EXPORT_SYMBOL_GPL(bio_trim);
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 402946035308..13e714ea7a42 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1153,7 +1153,7 @@ static int clone_bio(struct dm_target_io *tio, struct bio *bio,
clone->bi_iter.bi_size = to_bytes(len);
if (unlikely(bio_integrity(bio) != NULL))
- bio_integrity_trim(clone, 0, len);
+ bio_integrity_trim(clone);
return 0;
}
diff --git a/include/linux/bio.h b/include/linux/bio.h
index 4907bea03908..8f11b659a992 100644
--- a/include/linux/bio.h
+++ b/include/linux/bio.h
@@ -727,7 +727,7 @@ extern bool bio_integrity_enabled(struct bio *bio);
extern int bio_integrity_prep(struct bio *);
extern void bio_integrity_endio(struct bio *);
extern void bio_integrity_advance(struct bio *, unsigned int);
-extern void bio_integrity_trim(struct bio *, unsigned int, unsigned int);
+extern void bio_integrity_trim(struct bio *);
extern int bio_integrity_clone(struct bio *, struct bio *, gfp_t);
extern int bioset_integrity_create(struct bio_set *, int);
extern void bioset_integrity_free(struct bio_set *);
@@ -777,8 +777,7 @@ static inline void bio_integrity_advance(struct bio *bio,
return;
}
-static inline void bio_integrity_trim(struct bio *bio, unsigned int offset,
- unsigned int sectors)
+static inline void bio_integrity_trim(struct bio *bio)
{
return;
}
--
2.11.0
next prev parent reply other threads:[~2017-06-29 18:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-29 18:31 block: T10/DIF Fixes and cleanups v5 Christoph Hellwig
2017-06-29 18:31 ` [PATCH 1/9] bio-integrity: bio_trim should truncate integrity vector accordingly Christoph Hellwig
2017-06-29 18:31 ` [PATCH 2/9] bio-integrity: bio_integrity_advance must update integrity seed Christoph Hellwig
2017-06-29 18:31 ` Christoph Hellwig [this message]
2017-06-29 18:31 ` [PATCH 4/9] bio-integrity: fold bio_integrity_enabled to bio_integrity_prep Christoph Hellwig
2017-06-29 18:31 ` [PATCH 5/9] t10-pi: Move opencoded contants to common header Christoph Hellwig
2017-06-29 18:31 ` [PATCH 6/9] block: guard bvec iteration logic Christoph Hellwig
2017-06-29 18:31 ` [PATCH 7/9] bio: add bvec_iter rewind API Christoph Hellwig
2017-06-29 18:31 ` [PATCH 8/9] bio-integrity: Restore original iterator on verify stage Christoph Hellwig
2017-06-29 18:31 ` [PATCH 9/9] bio-integrity: stop abusing bi_end_io Christoph Hellwig
2017-07-03 23:00 ` Jens Axboe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170629183116.28685-4-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=dmonakhov@openvz.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=shli@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).