Skip to content

Commit ce30708

Browse files
committed
Merge tag 'block-5.12-2021-03-12-v2' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: "Mostly just random fixes all over the map. The only odd-one-out change is finally getting the rename of BIO_MAX_PAGES to BIO_MAX_VECS done. This should've been done with the multipage bvec change, but it's been left. Do it now to avoid hassles around changes piling up for the next merge window. Summary: - NVMe pull request: - one more quirk (Dmitry Monakhov) - fix max_zone_append_sectors initialization (Chaitanya Kulkarni) - nvme-fc reset/create race fix (James Smart) - fix status code on aborts/resets (Hannes Reinecke) - fix the CSS check for ZNS namespaces (Chaitanya Kulkarni) - fix a use after free in a debug printk in nvme-rdma (Lv Yunlong) - Follow-up NVMe error fix for NULL 'id' (Christoph) - Fixup for the bd_size_lock being IRQ safe, now that the offending driver has been dropped (Damien). - rsxx probe failure error return (Jia-Ju) - umem probe failure error return (Wei) - s390/dasd unbind fixes (Stefan) - blk-cgroup stats summing fix (Xunlei) - zone reset handling fix (Damien) - Rename BIO_MAX_PAGES to BIO_MAX_VECS (Christoph) - Suppress uevent trigger for hidden devices (Daniel) - Fix handling of discard on busy device (Jan) - Fix stale cache issue with zone reset (Shin'ichiro)" * tag 'block-5.12-2021-03-12-v2' of git://git.kernel.dk/linux-block: nvme: fix the nsid value to print in nvme_validate_or_alloc_ns block: Discard page cache of zone reset target range block: Suppress uevent for hidden device when removed block: rename BIO_MAX_PAGES to BIO_MAX_VECS nvme-pci: add the DISABLE_WRITE_ZEROES quirk for a Samsung PM1725a nvme-rdma: Fix a use after free in nvmet_rdma_write_data_done nvme-core: check ctrl css before setting up zns nvme-fc: fix racing controller reset and create association nvme-fc: return NVME_SC_HOST_ABORTED_CMD when a command has been aborted nvme-fc: set NVME_REQ_CANCELLED in nvme_fc_terminate_exchange() nvme: add NVME_REQ_CANCELLED flag in nvme_cancel_request() nvme: simplify error logic in nvme_validate_ns() nvme: set max_zone_append_sectors nvme_revalidate_zones block: rsxx: fix error return code of rsxx_pci_probe() block: Fix REQ_OP_ZONE_RESET_ALL handling umem: fix error return code in mm_pci_probe() blk-cgroup: Fix the recursive blkg rwstat s390/dasd: fix hanging IO request during DASD driver unbind s390/dasd: fix hanging DASD driver unbind block: Try to handle busy underlying device on discard
2 parents 9278be9 + f4f9fc2 commit ce30708

42 files changed

Lines changed: 138 additions & 79 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

block/bio.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ static struct biovec_slab {
3333
{ .nr_vecs = 16, .name = "biovec-16" },
3434
{ .nr_vecs = 64, .name = "biovec-64" },
3535
{ .nr_vecs = 128, .name = "biovec-128" },
36-
{ .nr_vecs = BIO_MAX_PAGES, .name = "biovec-max" },
36+
{ .nr_vecs = BIO_MAX_VECS, .name = "biovec-max" },
3737
};
3838

3939
static struct biovec_slab *biovec_slab(unsigned short nr_vecs)
@@ -46,7 +46,7 @@ static struct biovec_slab *biovec_slab(unsigned short nr_vecs)
4646
return &bvec_slabs[1];
4747
case 65 ... 128:
4848
return &bvec_slabs[2];
49-
case 129 ... BIO_MAX_PAGES:
49+
case 129 ... BIO_MAX_VECS:
5050
return &bvec_slabs[3];
5151
default:
5252
BUG();
@@ -151,9 +151,9 @@ static void bio_put_slab(struct bio_set *bs)
151151

152152
void bvec_free(mempool_t *pool, struct bio_vec *bv, unsigned short nr_vecs)
153153
{
154-
BIO_BUG_ON(nr_vecs > BIO_MAX_PAGES);
154+
BIO_BUG_ON(nr_vecs > BIO_MAX_VECS);
155155

156-
if (nr_vecs == BIO_MAX_PAGES)
156+
if (nr_vecs == BIO_MAX_VECS)
157157
mempool_free(bv, pool);
158158
else if (nr_vecs > BIO_INLINE_VECS)
159159
kmem_cache_free(biovec_slab(nr_vecs)->slab, bv);
@@ -186,15 +186,15 @@ struct bio_vec *bvec_alloc(mempool_t *pool, unsigned short *nr_vecs,
186186
/*
187187
* Try a slab allocation first for all smaller allocations. If that
188188
* fails and __GFP_DIRECT_RECLAIM is set retry with the mempool.
189-
* The mempool is sized to handle up to BIO_MAX_PAGES entries.
189+
* The mempool is sized to handle up to BIO_MAX_VECS entries.
190190
*/
191-
if (*nr_vecs < BIO_MAX_PAGES) {
191+
if (*nr_vecs < BIO_MAX_VECS) {
192192
struct bio_vec *bvl;
193193

194194
bvl = kmem_cache_alloc(bvs->slab, bvec_alloc_gfp(gfp_mask));
195195
if (likely(bvl) || !(gfp_mask & __GFP_DIRECT_RECLAIM))
196196
return bvl;
197-
*nr_vecs = BIO_MAX_PAGES;
197+
*nr_vecs = BIO_MAX_VECS;
198198
}
199199

200200
return mempool_alloc(pool, gfp_mask);

block/blk-cgroup-rwstat.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol,
109109

110110
lockdep_assert_held(&blkg->q->queue_lock);
111111

112+
memset(sum, 0, sizeof(*sum));
112113
rcu_read_lock();
113114
blkg_for_each_descendant_pre(pos_blkg, pos_css, blkg) {
114115
struct blkg_rwstat *rwstat;
@@ -122,7 +123,7 @@ void blkg_rwstat_recursive_sum(struct blkcg_gq *blkg, struct blkcg_policy *pol,
122123
rwstat = (void *)pos_blkg + off;
123124

124125
for (i = 0; i < BLKG_RWSTAT_NR; i++)
125-
sum->cnt[i] = blkg_rwstat_read_counter(rwstat, i);
126+
sum->cnt[i] += blkg_rwstat_read_counter(rwstat, i);
126127
}
127128
rcu_read_unlock();
128129
}

block/blk-crypto-fallback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ static bool blk_crypto_split_bio_if_needed(struct bio **bio_ptr)
219219

220220
bio_for_each_segment(bv, bio, iter) {
221221
num_sectors += bv.bv_len >> SECTOR_SHIFT;
222-
if (++i == BIO_MAX_PAGES)
222+
if (++i == BIO_MAX_VECS)
223223
break;
224224
}
225225
if (num_sectors < bio_sectors(bio)) {

block/blk-lib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ static unsigned int __blkdev_sectors_to_bio_pages(sector_t nr_sects)
296296
{
297297
sector_t pages = DIV_ROUND_UP_SECTOR_T(nr_sects, PAGE_SIZE / 512);
298298

299-
return min(pages, (sector_t)BIO_MAX_PAGES);
299+
return min(pages, (sector_t)BIO_MAX_VECS);
300300
}
301301

302302
static int __blkdev_issue_zero_pages(struct block_device *bdev,

block/blk-map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static int bio_map_user_iov(struct request *rq, struct iov_iter *iter,
249249
if (!iov_iter_count(iter))
250250
return -EINVAL;
251251

252-
bio = bio_kmalloc(gfp_mask, iov_iter_npages(iter, BIO_MAX_PAGES));
252+
bio = bio_kmalloc(gfp_mask, iov_iter_npages(iter, BIO_MAX_VECS));
253253
if (!bio)
254254
return -ENOMEM;
255255
bio->bi_opf |= req_op(rq);

block/blk-zoned.c

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ int blkdev_zone_mgmt(struct block_device *bdev, enum req_opf op,
240240
*/
241241
if (op == REQ_OP_ZONE_RESET &&
242242
blkdev_allow_reset_all_zones(bdev, sector, nr_sectors)) {
243-
bio->bi_opf = REQ_OP_ZONE_RESET_ALL;
243+
bio->bi_opf = REQ_OP_ZONE_RESET_ALL | REQ_SYNC;
244244
break;
245245
}
246246

@@ -318,6 +318,22 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
318318
return 0;
319319
}
320320

321+
static int blkdev_truncate_zone_range(struct block_device *bdev, fmode_t mode,
322+
const struct blk_zone_range *zrange)
323+
{
324+
loff_t start, end;
325+
326+
if (zrange->sector + zrange->nr_sectors <= zrange->sector ||
327+
zrange->sector + zrange->nr_sectors > get_capacity(bdev->bd_disk))
328+
/* Out of range */
329+
return -EINVAL;
330+
331+
start = zrange->sector << SECTOR_SHIFT;
332+
end = ((zrange->sector + zrange->nr_sectors) << SECTOR_SHIFT) - 1;
333+
334+
return truncate_bdev_range(bdev, mode, start, end);
335+
}
336+
321337
/*
322338
* BLKRESETZONE, BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE ioctl processing.
323339
* Called from blkdev_ioctl.
@@ -329,6 +345,7 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
329345
struct request_queue *q;
330346
struct blk_zone_range zrange;
331347
enum req_opf op;
348+
int ret;
332349

333350
if (!argp)
334351
return -EINVAL;
@@ -352,6 +369,11 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
352369
switch (cmd) {
353370
case BLKRESETZONE:
354371
op = REQ_OP_ZONE_RESET;
372+
373+
/* Invalidate the page cache, including dirty pages. */
374+
ret = blkdev_truncate_zone_range(bdev, mode, &zrange);
375+
if (ret)
376+
return ret;
355377
break;
356378
case BLKOPENZONE:
357379
op = REQ_OP_ZONE_OPEN;
@@ -366,8 +388,20 @@ int blkdev_zone_mgmt_ioctl(struct block_device *bdev, fmode_t mode,
366388
return -ENOTTY;
367389
}
368390

369-
return blkdev_zone_mgmt(bdev, op, zrange.sector, zrange.nr_sectors,
370-
GFP_KERNEL);
391+
ret = blkdev_zone_mgmt(bdev, op, zrange.sector, zrange.nr_sectors,
392+
GFP_KERNEL);
393+
394+
/*
395+
* Invalidate the page cache again for zone reset: writes can only be
396+
* direct for zoned devices so concurrent writes would not add any page
397+
* to the page cache after/during reset. The page cache may be filled
398+
* again due to concurrent reads though and dropping the pages for
399+
* these is fine.
400+
*/
401+
if (!ret && cmd == BLKRESETZONE)
402+
ret = blkdev_truncate_zone_range(bdev, mode, &zrange);
403+
404+
return ret;
371405
}
372406

373407
static inline unsigned long *blk_alloc_zone_bitmap(int node,

block/bounce.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ static struct bio *bounce_clone_bio(struct bio *bio_src)
229229
* - The point of cloning the biovec is to produce a bio with a biovec
230230
* the caller can modify: bi_idx and bi_bvec_done should be 0.
231231
*
232-
* - The original bio could've had more than BIO_MAX_PAGES biovecs; if
232+
* - The original bio could've had more than BIO_MAX_VECS biovecs; if
233233
* we tried to clone the whole thing bio_alloc_bioset() would fail.
234234
* But the clone should succeed as long as the number of biovecs we
235-
* actually need to allocate is fewer than BIO_MAX_PAGES.
235+
* actually need to allocate is fewer than BIO_MAX_VECS.
236236
*
237237
* - Lastly, bi_vcnt should not be looked at or relied upon by code
238238
* that does not own the bio - reason being drivers don't use it for
@@ -299,7 +299,7 @@ static void __blk_queue_bounce(struct request_queue *q, struct bio **bio_orig,
299299
int sectors = 0;
300300

301301
bio_for_each_segment(from, *bio_orig, iter) {
302-
if (i++ < BIO_MAX_PAGES)
302+
if (i++ < BIO_MAX_VECS)
303303
sectors += from.bv_len >> 9;
304304
if (page_to_pfn(from.bv_page) > q->limits.bounce_pfn)
305305
bounce = true;

block/genhd.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,8 @@ static void register_disk(struct device *parent, struct gendisk *disk,
534534
kobject_create_and_add("holders", &ddev->kobj);
535535
disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
536536

537-
if (disk->flags & GENHD_FL_HIDDEN) {
538-
dev_set_uevent_suppress(ddev, 0);
537+
if (disk->flags & GENHD_FL_HIDDEN)
539538
return;
540-
}
541539

542540
disk_scan_partitions(disk);
543541

drivers/block/drbd/drbd_int.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,7 @@ struct bm_extent {
13241324
* A followup commit may allow even bigger BIO sizes,
13251325
* once we thought that through. */
13261326
#define DRBD_MAX_BIO_SIZE (1U << 20)
1327-
#if DRBD_MAX_BIO_SIZE > (BIO_MAX_PAGES << PAGE_SHIFT)
1327+
#if DRBD_MAX_BIO_SIZE > (BIO_MAX_VECS << PAGE_SHIFT)
13281328
#error Architecture not supported: DRBD_MAX_BIO_SIZE > BIO_MAX_SIZE
13291329
#endif
13301330
#define DRBD_MAX_BIO_SIZE_SAFE (1U << 12) /* Works always = 4k */

drivers/block/rsxx/core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
871871
card->event_wq = create_singlethread_workqueue(DRIVER_NAME"_event");
872872
if (!card->event_wq) {
873873
dev_err(CARD_TO_DEV(card), "Failed card event setup.\n");
874+
st = -ENOMEM;
874875
goto failed_event_handler;
875876
}
876877

0 commit comments

Comments
 (0)