Skip to contentSkip to conversation

blktrace: Show requests without sector

PATCH Superseded Jan Kara 3 participants 4 messages Feb 6, 2019 – Feb 7, 2019 Block layer

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

PATCH 1/1 blktrace: Show requests without sector

Currently, blktrace will not show requests that don't have any data as rq->__sector is initialized to -1 which is out of device range and thus discarded by act_log_check(). This is most notably the case for cache flush requests sent to the device. Fix the problem by making blk_rq_trace_sector() return 0 for requests without initialized sector.

---
 include/linux/blktrace_api.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
include/linux/blktrace_api.h +2 -1
index 8804753805ac..353fd8c70760 100644
@@ -116,7 +116,8 @@ extern void blk_fill_rwbs(char *rwbs, unsigned int op, int bytes);
 
 static inline sector_t blk_rq_trace_sector(struct request *rq)
 {
-	return blk_rq_is_passthrough(rq) ? 0 : blk_rq_pos(rq);
+	return (blk_rq_is_passthrough(rq) || blk_rq_pos(rq) == (sector_t)-1) ?
+		0 : blk_rq_pos(rq);
 }
 
 static inline unsigned int blk_rq_trace_nr_sectors(struct request *rq)
Signature · 1 line
2.16.4
Reviewed-by on v1 1/1
#1 lore raw

Looks good,

Signature · 6 lines
Johannes Thumshirn                            SUSE Labs Filesystems
[email protected]                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
maintainer
#2 lore raw
In reply to Jan Kara
Quoted 5 lines · Jan Kara

Currently, blktrace will not show requests that don't have any data as rq->__sector is initialized to -1 which is out of device range and thus discarded by act_log_check(). This is most notably the case for cache flush requests sent to the device. Fix the problem by making blk_rq_trace_sector() return 0 for requests without initialized sector.

Concept is fine, but man, that's not very readable. How about:

if (blk_rq_passthrough(rq) || blk_rq_pos(rq) == (sector_t) -1)

	return 0;

return blk_rq_pos(rq);

instead? Preferably with a comment on why blk_rq_pos() will be -1.

Signature · 1 line
Jens Axboe
author
#3 lore raw
Quoted 7 lines · Jens Axboe
Quoted 5 lines · Jan Kara

Currently, blktrace will not show requests that don't have any data as rq->__sector is initialized to -1 which is out of device range and thus discarded by act_log_check(). This is most notably the case for cache flush requests sent to the device. Fix the problem by making blk_rq_trace_sector() return 0 for requests without initialized sector.

Quoted 8 lines

Concept is fine, but man, that's not very readable. How about:

if (blk_rq_passthrough(rq) || blk_rq_pos(rq) == (sector_t) -1)

	return 0;

return blk_rq_pos(rq);

instead? Preferably with a comment on why blk_rq_pos() will be -1.

Good points. Will send v2 shortly. Thanks!

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR