diff mbox series

blktrace: Show requests without sector

Message ID 20190206120440.26557-1-jack@suse.cz (mailing list archive)
State New, archived
Headers show
Series blktrace: Show requests without sector | expand

Commit Message

Jan Kara Feb. 6, 2019, 12:04 p.m. UTC
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.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 include/linux/blktrace_api.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Johannes Thumshirn Feb. 6, 2019, 12:37 p.m. UTC | #1
Looks good,
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Jens Axboe Feb. 6, 2019, 7:49 p.m. UTC | #2
On 2/6/19 5:04 AM, Jan Kara wrote:
> 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.
Jan Kara Feb. 7, 2019, 10:54 a.m. UTC | #3
On Wed 06-02-19 12:49:46, Jens Axboe wrote:
> On 2/6/19 5:04 AM, Jan Kara wrote:
> > 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.

Good points. Will send v2 shortly. Thanks!

								Honza
diff mbox series

Patch

diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
index 8804753805ac..353fd8c70760 100644
--- a/include/linux/blktrace_api.h
+++ b/include/linux/blktrace_api.h
@@ -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)