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
166166 enum rq_cmd_type_bits cmd_type;
167167 unsigned long atomic_flags;
168168
169− sector_t sector; /* sector cursor */
170− unsigned int data_len; /* total data len, don't access directly */
169+ /* the following two fields are internal, NEVER access directly */
170+ sector_t __sector; /* sector cursor */
171+ unsigned int __data_len; /* total data len */
171172
172173 struct bio *bio;
173174 struct bio *biotail;
@@ -828,12 +829,12 @@ extern void blkdev_dequeue_request(struct request *req); · 654 unmodified lines
828829 */
829830 static inline sector_t blk_rq_pos(const struct request *rq)
830831 {
831− return rq->sector;
832+ return rq->__sector;
832833 }
833834
834835 static inline unsigned int blk_rq_bytes(const struct request *rq)
835836 {
836− return rq->data_len;
837+ return rq->__data_len;
837838 }
838839
839840 static 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