Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus-20180913' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
"Three fixes that should go into this series. This contains:

- Increase number of policies supported by blk-cgroup.

With blk-iolatency, we now have four in kernel, but we had a hard
limit of three...

- Fix regression in null_blk, where the zoned supported broke
queue_mode=0 (bio based).

- NVMe pull request, with a single fix for an issue in the rdma code"

* tag 'for-linus-20180913' of git://git.kernel.dk/linux-block:
null_blk: fix zoned support for non-rq based operation
blk-cgroup: increase number of supported policies
nvmet-rdma: fix possible bogus dereference under heavy load

+91 -38
+3 -1
block/blk-cgroup.c
··· 1510 1510 for (i = 0; i < BLKCG_MAX_POLS; i++) 1511 1511 if (!blkcg_policy[i]) 1512 1512 break; 1513 - if (i >= BLKCG_MAX_POLS) 1513 + if (i >= BLKCG_MAX_POLS) { 1514 + pr_warn("blkcg_policy_register: BLKCG_MAX_POLS too small\n"); 1514 1515 goto err_unlock; 1516 + } 1515 1517 1516 1518 /* Make sure cpd/pd_alloc_fn and cpd/pd_free_fn in pairs */ 1517 1519 if ((!pol->cpd_alloc_fn ^ !pol->cpd_free_fn) ||
+10 -7
drivers/block/null_blk.h
··· 87 87 #ifdef CONFIG_BLK_DEV_ZONED 88 88 int null_zone_init(struct nullb_device *dev); 89 89 void null_zone_exit(struct nullb_device *dev); 90 - blk_status_t null_zone_report(struct nullb *nullb, 91 - struct nullb_cmd *cmd); 92 - void null_zone_write(struct nullb_cmd *cmd); 93 - void null_zone_reset(struct nullb_cmd *cmd); 90 + blk_status_t null_zone_report(struct nullb *nullb, struct bio *bio); 91 + void null_zone_write(struct nullb_cmd *cmd, sector_t sector, 92 + unsigned int nr_sectors); 93 + void null_zone_reset(struct nullb_cmd *cmd, sector_t sector); 94 94 #else 95 95 static inline int null_zone_init(struct nullb_device *dev) 96 96 { ··· 98 98 } 99 99 static inline void null_zone_exit(struct nullb_device *dev) {} 100 100 static inline blk_status_t null_zone_report(struct nullb *nullb, 101 - struct nullb_cmd *cmd) 101 + struct bio *bio) 102 102 { 103 103 return BLK_STS_NOTSUPP; 104 104 } 105 - static inline void null_zone_write(struct nullb_cmd *cmd) {} 106 - static inline void null_zone_reset(struct nullb_cmd *cmd) {} 105 + static inline void null_zone_write(struct nullb_cmd *cmd, sector_t sector, 106 + unsigned int nr_sectors) 107 + { 108 + } 109 + static inline void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) {} 107 110 #endif /* CONFIG_BLK_DEV_ZONED */ 108 111 #endif /* __NULL_BLK_H */
+38 -7
drivers/block/null_blk_main.c
··· 1157 1157 } 1158 1158 } 1159 1159 1160 + static bool cmd_report_zone(struct nullb *nullb, struct nullb_cmd *cmd) 1161 + { 1162 + struct nullb_device *dev = cmd->nq->dev; 1163 + 1164 + if (dev->queue_mode == NULL_Q_BIO) { 1165 + if (bio_op(cmd->bio) == REQ_OP_ZONE_REPORT) { 1166 + cmd->error = null_zone_report(nullb, cmd->bio); 1167 + return true; 1168 + } 1169 + } else { 1170 + if (req_op(cmd->rq) == REQ_OP_ZONE_REPORT) { 1171 + cmd->error = null_zone_report(nullb, cmd->rq->bio); 1172 + return true; 1173 + } 1174 + } 1175 + 1176 + return false; 1177 + } 1178 + 1160 1179 static blk_status_t null_handle_cmd(struct nullb_cmd *cmd) 1161 1180 { 1162 1181 struct nullb_device *dev = cmd->nq->dev; 1163 1182 struct nullb *nullb = dev->nullb; 1164 1183 int err = 0; 1165 1184 1166 - if (req_op(cmd->rq) == REQ_OP_ZONE_REPORT) { 1167 - cmd->error = null_zone_report(nullb, cmd); 1185 + if (cmd_report_zone(nullb, cmd)) 1168 1186 goto out; 1169 - } 1170 1187 1171 1188 if (test_bit(NULLB_DEV_FL_THROTTLED, &dev->flags)) { 1172 1189 struct request *rq = cmd->rq; ··· 1251 1234 cmd->error = errno_to_blk_status(err); 1252 1235 1253 1236 if (!cmd->error && dev->zoned) { 1254 - if (req_op(cmd->rq) == REQ_OP_WRITE) 1255 - null_zone_write(cmd); 1256 - else if (req_op(cmd->rq) == REQ_OP_ZONE_RESET) 1257 - null_zone_reset(cmd); 1237 + sector_t sector; 1238 + unsigned int nr_sectors; 1239 + int op; 1240 + 1241 + if (dev->queue_mode == NULL_Q_BIO) { 1242 + op = bio_op(cmd->bio); 1243 + sector = cmd->bio->bi_iter.bi_sector; 1244 + nr_sectors = cmd->bio->bi_iter.bi_size >> 9; 1245 + } else { 1246 + op = req_op(cmd->rq); 1247 + sector = blk_rq_pos(cmd->rq); 1248 + nr_sectors = blk_rq_sectors(cmd->rq); 1249 + } 1250 + 1251 + if (op == REQ_OP_WRITE) 1252 + null_zone_write(cmd, sector, nr_sectors); 1253 + else if (op == REQ_OP_ZONE_RESET) 1254 + null_zone_reset(cmd, sector); 1258 1255 } 1259 1256 out: 1260 1257 /* Complete IO by inline, softirq or timer */
+14 -20
drivers/block/null_blk_zoned.c
··· 48 48 kvfree(dev->zones); 49 49 } 50 50 51 - static void null_zone_fill_rq(struct nullb_device *dev, struct request *rq, 52 - unsigned int zno, unsigned int nr_zones) 51 + static void null_zone_fill_bio(struct nullb_device *dev, struct bio *bio, 52 + unsigned int zno, unsigned int nr_zones) 53 53 { 54 54 struct blk_zone_report_hdr *hdr = NULL; 55 55 struct bio_vec bvec; ··· 57 57 void *addr; 58 58 unsigned int zones_to_cpy; 59 59 60 - bio_for_each_segment(bvec, rq->bio, iter) { 60 + bio_for_each_segment(bvec, bio, iter) { 61 61 addr = kmap_atomic(bvec.bv_page); 62 62 63 63 zones_to_cpy = bvec.bv_len / sizeof(struct blk_zone); ··· 84 84 } 85 85 } 86 86 87 - blk_status_t null_zone_report(struct nullb *nullb, 88 - struct nullb_cmd *cmd) 87 + blk_status_t null_zone_report(struct nullb *nullb, struct bio *bio) 89 88 { 90 89 struct nullb_device *dev = nullb->dev; 91 - struct request *rq = cmd->rq; 92 - unsigned int zno = null_zone_no(dev, blk_rq_pos(rq)); 90 + unsigned int zno = null_zone_no(dev, bio->bi_iter.bi_sector); 93 91 unsigned int nr_zones = dev->nr_zones - zno; 94 - unsigned int max_zones = (blk_rq_bytes(rq) / 95 - sizeof(struct blk_zone)) - 1; 92 + unsigned int max_zones; 96 93 94 + max_zones = (bio->bi_iter.bi_size / sizeof(struct blk_zone)) - 1; 97 95 nr_zones = min_t(unsigned int, nr_zones, max_zones); 98 - 99 - null_zone_fill_rq(nullb->dev, rq, zno, nr_zones); 96 + null_zone_fill_bio(nullb->dev, bio, zno, nr_zones); 100 97 101 98 return BLK_STS_OK; 102 99 } 103 100 104 - void null_zone_write(struct nullb_cmd *cmd) 101 + void null_zone_write(struct nullb_cmd *cmd, sector_t sector, 102 + unsigned int nr_sectors) 105 103 { 106 104 struct nullb_device *dev = cmd->nq->dev; 107 - struct request *rq = cmd->rq; 108 - sector_t sector = blk_rq_pos(rq); 109 - unsigned int rq_sectors = blk_rq_sectors(rq); 110 105 unsigned int zno = null_zone_no(dev, sector); 111 106 struct blk_zone *zone = &dev->zones[zno]; 112 107 ··· 113 118 case BLK_ZONE_COND_EMPTY: 114 119 case BLK_ZONE_COND_IMP_OPEN: 115 120 /* Writes must be at the write pointer position */ 116 - if (blk_rq_pos(rq) != zone->wp) { 121 + if (sector != zone->wp) { 117 122 cmd->error = BLK_STS_IOERR; 118 123 break; 119 124 } ··· 121 126 if (zone->cond == BLK_ZONE_COND_EMPTY) 122 127 zone->cond = BLK_ZONE_COND_IMP_OPEN; 123 128 124 - zone->wp += rq_sectors; 129 + zone->wp += nr_sectors; 125 130 if (zone->wp == zone->start + zone->len) 126 131 zone->cond = BLK_ZONE_COND_FULL; 127 132 break; ··· 132 137 } 133 138 } 134 139 135 - void null_zone_reset(struct nullb_cmd *cmd) 140 + void null_zone_reset(struct nullb_cmd *cmd, sector_t sector) 136 141 { 137 142 struct nullb_device *dev = cmd->nq->dev; 138 - struct request *rq = cmd->rq; 139 - unsigned int zno = null_zone_no(dev, blk_rq_pos(rq)); 143 + unsigned int zno = null_zone_no(dev, sector); 140 144 struct blk_zone *zone = &dev->zones[zno]; 141 145 142 146 zone->cond = BLK_ZONE_COND_EMPTY;
+25 -2
drivers/nvme/target/rdma.c
··· 66 66 67 67 struct nvmet_req req; 68 68 69 + bool allocated; 69 70 u8 n_rdma; 70 71 u32 flags; 71 72 u32 invalidate_rkey; ··· 175 174 unsigned long flags; 176 175 177 176 spin_lock_irqsave(&queue->rsps_lock, flags); 178 - rsp = list_first_entry(&queue->free_rsps, 177 + rsp = list_first_entry_or_null(&queue->free_rsps, 179 178 struct nvmet_rdma_rsp, free_list); 180 - list_del(&rsp->free_list); 179 + if (likely(rsp)) 180 + list_del(&rsp->free_list); 181 181 spin_unlock_irqrestore(&queue->rsps_lock, flags); 182 + 183 + if (unlikely(!rsp)) { 184 + rsp = kmalloc(sizeof(*rsp), GFP_KERNEL); 185 + if (unlikely(!rsp)) 186 + return NULL; 187 + rsp->allocated = true; 188 + } 182 189 183 190 return rsp; 184 191 } ··· 195 186 nvmet_rdma_put_rsp(struct nvmet_rdma_rsp *rsp) 196 187 { 197 188 unsigned long flags; 189 + 190 + if (rsp->allocated) { 191 + kfree(rsp); 192 + return; 193 + } 198 194 199 195 spin_lock_irqsave(&rsp->queue->rsps_lock, flags); 200 196 list_add_tail(&rsp->free_list, &rsp->queue->free_rsps); ··· 790 776 791 777 cmd->queue = queue; 792 778 rsp = nvmet_rdma_get_rsp(queue); 779 + if (unlikely(!rsp)) { 780 + /* 781 + * we get here only under memory pressure, 782 + * silently drop and have the host retry 783 + * as we can't even fail it. 784 + */ 785 + nvmet_rdma_post_recv(queue->dev, cmd); 786 + return; 787 + } 793 788 rsp->queue = queue; 794 789 rsp->cmd = cmd; 795 790 rsp->flags = 0;
+1 -1
include/linux/blkdev.h
··· 54 54 * Maximum number of blkcg policies allowed to be registered concurrently. 55 55 * Defined here to simplify include dependency. 56 56 */ 57 - #define BLKCG_MAX_POLS 3 57 + #define BLKCG_MAX_POLS 5 58 58 59 59 typedef void (rq_end_io_fn)(struct request *, blk_status_t); 60 60