Skip to content

Commit 359f642

Browse files
g-edwardsaxboe
authored andcommitted
block: move bio_integrity_{intervals,bytes} into blkdev.h
This allows bio_integrity_bytes() to be called from drivers instead of open coding it. Acked-by: Martin K. Petersen <[email protected]> Signed-off-by: Greg Edwards <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent d3df0ac commit 359f642

File tree

2 files changed

+34
-22
lines changed

2 files changed

+34
-22
lines changed

block/bio-integrity.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -159,28 +159,6 @@ int bio_integrity_add_page(struct bio *bio, struct page *page,
159159
}
160160
EXPORT_SYMBOL(bio_integrity_add_page);
161161

162-
/**
163-
* bio_integrity_intervals - Return number of integrity intervals for a bio
164-
* @bi: blk_integrity profile for device
165-
* @sectors: Size of the bio in 512-byte sectors
166-
*
167-
* Description: The block layer calculates everything in 512 byte
168-
* sectors but integrity metadata is done in terms of the data integrity
169-
* interval size of the storage device. Convert the block layer sectors
170-
* to the appropriate number of integrity intervals.
171-
*/
172-
static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
173-
unsigned int sectors)
174-
{
175-
return sectors >> (bi->interval_exp - 9);
176-
}
177-
178-
static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
179-
unsigned int sectors)
180-
{
181-
return bio_integrity_intervals(bi, sectors) * bi->tuple_size;
182-
}
183-
184162
/**
185163
* bio_integrity_process - Process integrity metadata for a bio
186164
* @bio: bio to generate/verify integrity metadata for

include/linux/blkdev.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1865,6 +1865,28 @@ static inline bool integrity_req_gap_front_merge(struct request *req,
18651865
bip_next->bip_vec[0].bv_offset);
18661866
}
18671867

1868+
/**
1869+
* bio_integrity_intervals - Return number of integrity intervals for a bio
1870+
* @bi: blk_integrity profile for device
1871+
* @sectors: Size of the bio in 512-byte sectors
1872+
*
1873+
* Description: The block layer calculates everything in 512 byte
1874+
* sectors but integrity metadata is done in terms of the data integrity
1875+
* interval size of the storage device. Convert the block layer sectors
1876+
* to the appropriate number of integrity intervals.
1877+
*/
1878+
static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
1879+
unsigned int sectors)
1880+
{
1881+
return sectors >> (bi->interval_exp - 9);
1882+
}
1883+
1884+
static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
1885+
unsigned int sectors)
1886+
{
1887+
return bio_integrity_intervals(bi, sectors) * bi->tuple_size;
1888+
}
1889+
18681890
#else /* CONFIG_BLK_DEV_INTEGRITY */
18691891

18701892
struct bio;
@@ -1938,6 +1960,18 @@ static inline bool integrity_req_gap_front_merge(struct request *req,
19381960
return false;
19391961
}
19401962

1963+
static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
1964+
unsigned int sectors)
1965+
{
1966+
return 0;
1967+
}
1968+
1969+
static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
1970+
unsigned int sectors)
1971+
{
1972+
return 0;
1973+
}
1974+
19411975
#endif /* CONFIG_BLK_DEV_INTEGRITY */
19421976

19431977
struct block_device_operations {

0 commit comments

Comments
 (0)