History

block: hide request sector and data_len

Block low level drivers for some reason have been pretty good at abusing block layer API. Especially struct request's fields tend to get violated in all possible ways. Make it clear that low level drivers MUST NOT access or manipulate rq->sector and rq->data_len directly by prefixing them with double underscores. This change is also necessary to break build of out-of-tree codes which assume the previous block API where internal fields can be manipulated and rq->data_len carries residual count on completion. [ Impact: hide internal fields, block API change ]

Tejun Heo committed 17 years ago

Commit a2dec7b1 parent 34b7d2c4 files · +17 −16Browse files

Showing the changes to include/linux/blkdev.h (1 of 4 files). Show all

Unified · Split

include/linux/blkdev.h+5−4
@@ -166,8 +166,9 @@ struct request { · 165 unmodified lines
166 enum rq_cmd_type_bits cmd_type;166 enum rq_cmd_type_bits cmd_type;
167 unsigned long atomic_flags;167 unsigned long atomic_flags;
168 168
169 sector_t sector; /* sector cursor */169 /* the following two fields are internal, NEVER access directly */
170 unsigned int data_len; /* total data len, don't access directly */170 sector_t __sector; /* sector cursor */
171 unsigned int __data_len; /* total data len */
171 172
172 struct bio *bio;173 struct bio *bio;
173 struct bio *biotail;174 struct bio *biotail;
@@ -828,12 +829,12 @@ extern void blkdev_dequeue_request(struct request *req); · 654 unmodified lines
828 */829 */
829static inline sector_t blk_rq_pos(const struct request *rq)830static inline sector_t blk_rq_pos(const struct request *rq)
830{831{
831 return rq->sector;832 return rq->__sector;
832}833}
833 834
834static inline unsigned int blk_rq_bytes(const struct request *rq)835static inline unsigned int blk_rq_bytes(const struct request *rq)
835{836{
836 return rq->data_len;837 return rq->__data_len;
837}838}
838 839
839static inline int blk_rq_cur_bytes(const struct request *rq)840static inline int blk_rq_cur_bytes(const struct request *rq)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t