Improve static type checking by using the new blk_opf_t type for a function argument that represents a combination of a request operation and request flags. Rename that argument from 'op' into 'opf' to make its role more clear.
Unified · Split
| @@ -7,6 +7,7 @@ · 6 unmodified lines | ||
| 7 | 7 | #include <linux/compat.h> |
| 8 | 8 | #include <uapi/linux/blktrace_api.h> |
| 9 | 9 | #include <linux/list.h> |
| 10 | +#include <linux/blk_types.h> | |
| 10 | 11 | |
| 11 | 12 | #if defined(CONFIG_BLK_DEV_IO_TRACE) |
| 12 | 13 | |
| @@ -105,7 +106,7 @@ struct compat_blk_user_trace_setup { · 92 unmodified lines | ||
| 105 | 106 | |
| 106 | 107 | #endif |
| 107 | 108 | |
| 108 | −void blk_fill_rwbs(char *rwbs, unsigned int op); | |
| 109 | +void blk_fill_rwbs(char *rwbs, blk_opf_t opf); | |
| 109 | 110 | |
| 110 | 111 | static inline sector_t blk_rq_trace_sector(struct request *rq) |
| 111 | 112 | { |
| @@ -205,7 +205,7 @@ static const u32 ddir_act[2] = { BLK_TC_ACT(BLK_TC_READ), · 204 unmodified lines | ||
| 205 | 205 | #define BLK_TC_PREFLUSH BLK_TC_FLUSH |
| 206 | 206 | |
| 207 | 207 | /* The ilog2() calls fall out because they're constant */ |
| 208 | −#define MASK_TC_BIT(rw, __name) ((rw & REQ_ ## __name) << \ | |
| 208 | +#define MASK_TC_BIT(rw, __name) ((__force u32)(rw & REQ_ ## __name) << \ | |
| 209 | 209 | (ilog2(BLK_TC_ ## __name) + BLK_TC_SHIFT - __REQ_ ## __name)) |
| 210 | 210 | |
| 211 | 211 | /* |
| @@ -213,8 +213,8 @@ static const u32 ddir_act[2] = { BLK_TC_ACT(BLK_TC_READ), · 1 unmodified line | ||
| 213 | 213 | * blk_io_trace structure and places it in a per-cpu subbuffer. |
| 214 | 214 | */ |
| 215 | 215 | static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, |
| 216 | − int op, int op_flags, u32 what, int error, int pdu_len, | |
| 217 | − void *pdu_data, u64 cgid) | |
| 216 | + const blk_opf_t opf, u32 what, int error, | |
| 217 | + int pdu_len, void *pdu_data, u64 cgid) | |
| 218 | 218 | { |
| 219 | 219 | struct task_struct *tsk = current; |
| 220 | 220 | struct ring_buffer_event *event = NULL; |
| @@ -227,16 +227,17 @@ static void __blk_add_trace(struct blk_trace *bt, sector_t sector, int bytes, · 6 unmodified lines | ||
| 227 | 227 | int cpu; |
| 228 | 228 | bool blk_tracer = blk_tracer_enabled; |
| 229 | 229 | ssize_t cgid_len = cgid ? sizeof(cgid) : 0; |
| 230 | + const enum req_op op = opf & REQ_OP_MASK; | |
| 230 | 231 | |
| 231 | 232 | if (unlikely(bt->trace_state != Blktrace_running && !blk_tracer)) |
| 232 | 233 | return; |
| 233 | 234 | |
| 234 | 235 | what |= ddir_act[op_is_write(op) ? WRITE : READ]; |
| 235 | − what |= MASK_TC_BIT(op_flags, SYNC); | |
| 236 | − what |= MASK_TC_BIT(op_flags, RAHEAD); | |
| 237 | − what |= MASK_TC_BIT(op_flags, META); | |
| 238 | − what |= MASK_TC_BIT(op_flags, PREFLUSH); | |
| 239 | − what |= MASK_TC_BIT(op_flags, FUA); | |
| 236 | + what |= MASK_TC_BIT(opf, SYNC); | |
| 237 | + what |= MASK_TC_BIT(opf, RAHEAD); | |
| 238 | + what |= MASK_TC_BIT(opf, META); | |
| 239 | + what |= MASK_TC_BIT(opf, PREFLUSH); | |
| 240 | + what |= MASK_TC_BIT(opf, FUA); | |
| 240 | 241 | if (op == REQ_OP_DISCARD || op == REQ_OP_SECURE_ERASE) |
| 241 | 242 | what |= BLK_TC_ACT(BLK_TC_DISCARD); |
| 242 | 243 | if (op == REQ_OP_FLUSH) |
| @@ -842,9 +843,8 @@ static void blk_add_trace_rq(struct request *rq, blk_status_t error, · 599 unmodified lines | ||
| 842 | 843 | else |
| 843 | 844 | what |= BLK_TC_ACT(BLK_TC_FS); |
| 844 | 845 | |
| 845 | − __blk_add_trace(bt, blk_rq_trace_sector(rq), nr_bytes, req_op(rq), | |
| 846 | − rq->cmd_flags, what, blk_status_to_errno(error), 0, | |
| 847 | − NULL, cgid); | |
| 846 | + __blk_add_trace(bt, blk_rq_trace_sector(rq), nr_bytes, rq->cmd_flags, | |
| 847 | + what, blk_status_to_errno(error), 0, NULL, cgid); | |
| 848 | 848 | rcu_read_unlock(); |
| 849 | 849 | } |
| 850 | 850 | |
| @@ -903,7 +903,7 @@ static void blk_add_trace_bio(struct request_queue *q, struct bio *bio, · 52 unmodified lines | ||
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | __blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size, |
| 906 | − bio_op(bio), bio->bi_opf, what, error, 0, NULL, | |
| 906 | + bio->bi_opf, what, error, 0, NULL, | |
| 907 | 907 | blk_trace_bio_get_cgid(q, bio)); |
| 908 | 908 | rcu_read_unlock(); |
| 909 | 909 | } |
| @@ -949,7 +949,7 @@ static void blk_add_trace_plug(void *ignore, struct request_queue *q) · 39 unmodified lines | ||
| 949 | 949 | rcu_read_lock(); |
| 950 | 950 | bt = rcu_dereference(q->blk_trace); |
| 951 | 951 | if (bt) |
| 952 | − __blk_add_trace(bt, 0, 0, 0, 0, BLK_TA_PLUG, 0, 0, NULL, 0); | |
| 952 | + __blk_add_trace(bt, 0, 0, 0, BLK_TA_PLUG, 0, 0, NULL, 0); | |
| 953 | 953 | rcu_read_unlock(); |
| 954 | 954 | } |
| 955 | 955 | |
| @@ -969,7 +969,7 @@ static void blk_add_trace_unplug(void *ignore, struct request_queue *q, · 13 unmodified lines | ||
| 969 | 969 | else |
| 970 | 970 | what = BLK_TA_UNPLUG_TIMER; |
| 971 | 971 | |
| 972 | − __blk_add_trace(bt, 0, 0, 0, 0, what, 0, sizeof(rpdu), &rpdu, 0); | |
| 972 | + __blk_add_trace(bt, 0, 0, 0, what, 0, sizeof(rpdu), &rpdu, 0); | |
| 973 | 973 | } |
| 974 | 974 | rcu_read_unlock(); |
| 975 | 975 | } |
| @@ -985,8 +985,7 @@ static void blk_add_trace_split(void *ignore, struct bio *bio, unsigned int pdu) · 9 unmodified lines | ||
| 985 | 985 | __be64 rpdu = cpu_to_be64(pdu); |
| 986 | 986 | |
| 987 | 987 | __blk_add_trace(bt, bio->bi_iter.bi_sector, |
| 988 | − bio->bi_iter.bi_size, bio_op(bio), bio->bi_opf, | |
| 989 | − BLK_TA_SPLIT, | |
| 988 | + bio->bi_iter.bi_size, bio->bi_opf, BLK_TA_SPLIT, | |
| 990 | 989 | blk_status_to_errno(bio->bi_status), |
| 991 | 990 | sizeof(rpdu), &rpdu, |
| 992 | 991 | blk_trace_bio_get_cgid(q, bio)); |
| @@ -1022,7 +1021,7 @@ static void blk_add_trace_bio_remap(void *ignore, struct bio *bio, dev_t dev, · 29 unmodified lines | ||
| 1022 | 1021 | r.sector_from = cpu_to_be64(from); |
| 1023 | 1022 | |
| 1024 | 1023 | __blk_add_trace(bt, bio->bi_iter.bi_sector, bio->bi_iter.bi_size, |
| 1025 | − bio_op(bio), bio->bi_opf, BLK_TA_REMAP, | |
| 1024 | + bio->bi_opf, BLK_TA_REMAP, | |
| 1026 | 1025 | blk_status_to_errno(bio->bi_status), |
| 1027 | 1026 | sizeof(r), &r, blk_trace_bio_get_cgid(q, bio)); |
| 1028 | 1027 | rcu_read_unlock(); |
| @@ -1058,7 +1057,7 @@ static void blk_add_trace_rq_remap(void *ignore, struct request *rq, dev_t dev, · 29 unmodified lines | ||
| 1058 | 1057 | r.sector_from = cpu_to_be64(from); |
| 1059 | 1058 | |
| 1060 | 1059 | __blk_add_trace(bt, blk_rq_pos(rq), blk_rq_bytes(rq), |
| 1061 | − req_op(rq), rq->cmd_flags, BLK_TA_REMAP, 0, | |
| 1060 | + rq->cmd_flags, BLK_TA_REMAP, 0, | |
| 1062 | 1061 | sizeof(r), &r, blk_trace_request_get_cgid(rq)); |
| 1063 | 1062 | rcu_read_unlock(); |
| 1064 | 1063 | } |
| @@ -1084,7 +1083,7 @@ void blk_add_driver_data(struct request *rq, void *data, size_t len) · 19 unmodified lines | ||
| 1084 | 1083 | return; |
| 1085 | 1084 | } |
| 1086 | 1085 | |
| 1087 | − __blk_add_trace(bt, blk_rq_trace_sector(rq), blk_rq_bytes(rq), 0, 0, | |
| 1086 | + __blk_add_trace(bt, blk_rq_trace_sector(rq), blk_rq_bytes(rq), 0, | |
| 1088 | 1087 | BLK_TA_DRV_DATA, 0, len, data, |
| 1089 | 1088 | blk_trace_request_get_cgid(rq)); |
| 1090 | 1089 | rcu_read_unlock(); |
| @@ -1881,14 +1880,14 @@ out: · 790 unmodified lines | ||
| 1881 | 1880 | * caller with resulting string. |
| 1882 | 1881 | * |
| 1883 | 1882 | **/ |
| 1884 | −void blk_fill_rwbs(char *rwbs, unsigned int op) | |
| 1883 | +void blk_fill_rwbs(char *rwbs, blk_opf_t opf) | |
| 1885 | 1884 | { |
| 1886 | 1885 | int i = 0; |
| 1887 | 1886 | |
| 1888 | − if (op & REQ_PREFLUSH) | |
| 1887 | + if (opf & REQ_PREFLUSH) | |
| 1889 | 1888 | rwbs[i++] = 'F'; |
| 1890 | 1889 | |
| 1891 | − switch (op & REQ_OP_MASK) { | |
| 1890 | + switch (opf & REQ_OP_MASK) { | |
| 1892 | 1891 | case REQ_OP_WRITE: |
| 1893 | 1892 | rwbs[i++] = 'W'; |
| 1894 | 1893 | break; |
| @@ -1909,13 +1908,13 @@ void blk_fill_rwbs(char *rwbs, unsigned int op) · 14 unmodified lines | ||
| 1909 | 1908 | rwbs[i++] = 'N'; |
| 1910 | 1909 | } |
| 1911 | 1910 | |
| 1912 | − if (op & REQ_FUA) | |
| 1911 | + if (opf & REQ_FUA) | |
| 1913 | 1912 | rwbs[i++] = 'F'; |
| 1914 | − if (op & REQ_RAHEAD) | |
| 1913 | + if (opf & REQ_RAHEAD) | |
| 1915 | 1914 | rwbs[i++] = 'A'; |
| 1916 | − if (op & REQ_SYNC) | |
| 1915 | + if (opf & REQ_SYNC) | |
| 1917 | 1916 | rwbs[i++] = 'S'; |
| 1918 | − if (op & REQ_META) | |
| 1917 | + if (opf & REQ_META) | |
| 1919 | 1918 | rwbs[i++] = 'M'; |
| 1920 | 1919 | |
| 1921 | 1920 | rwbs[i] = '\0'; |