Skip to content

Commit b988976

Browse files
committed
Merge tag 'block-5.17-2022-02-17' of git://git.kernel.dk/linux-block
Pull block fixes from Jens Axboe: - Surprise removal fix (Christoph) - Ensure that pages are zeroed before submitted for userspace IO (Haimin) - Fix blk-wbt accounting issue with BFQ (Laibin) - Use bsize for discard granularity in loop (Ming) - Fix missing zone handling in blk_complete_request() (Pankaj) * tag 'block-5.17-2022-02-17' of git://git.kernel.dk/linux-block: block/wbt: fix negative inflight counter when remove scsi device block: fix surprise removal for drivers calling blk_set_queue_dying block-map: add __GFP_ZERO flag for alloc_page in function bio_copy_kern block: loop:use kstatfs.f_bsize of backing file to set discard granularity block: Add handling for zone append command in blk_complete_request
2 parents 2848551 + e92bc4c commit b988976

14 files changed

Lines changed: 38 additions & 19 deletions

File tree

block/bfq-iosched.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7018,6 +7018,8 @@ static void bfq_exit_queue(struct elevator_queue *e)
70187018
spin_unlock_irq(&bfqd->lock);
70197019
#endif
70207020

7021+
wbt_enable_default(bfqd->queue);
7022+
70217023
kfree(bfqd);
70227024
}
70237025

block/blk-core.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,6 @@ void blk_queue_start_drain(struct request_queue *q)
284284
wake_up_all(&q->mq_freeze_wq);
285285
}
286286

287-
void blk_set_queue_dying(struct request_queue *q)
288-
{
289-
blk_queue_flag_set(QUEUE_FLAG_DYING, q);
290-
blk_queue_start_drain(q);
291-
}
292-
EXPORT_SYMBOL_GPL(blk_set_queue_dying);
293-
294287
/**
295288
* blk_cleanup_queue - shutdown a request queue
296289
* @q: request queue to shutdown
@@ -308,7 +301,8 @@ void blk_cleanup_queue(struct request_queue *q)
308301
WARN_ON_ONCE(blk_queue_registered(q));
309302

310303
/* mark @q DYING, no new request or merges will be allowed afterwards */
311-
blk_set_queue_dying(q);
304+
blk_queue_flag_set(QUEUE_FLAG_DYING, q);
305+
blk_queue_start_drain(q);
312306

313307
blk_queue_flag_set(QUEUE_FLAG_NOMERGES, q);
314308
blk_queue_flag_set(QUEUE_FLAG_NOXMERGES, q);

block/blk-map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ static struct bio *bio_copy_kern(struct request_queue *q, void *data,
446446
if (bytes > len)
447447
bytes = len;
448448

449-
page = alloc_page(GFP_NOIO | gfp_mask);
449+
page = alloc_page(GFP_NOIO | __GFP_ZERO | gfp_mask);
450450
if (!page)
451451
goto cleanup;
452452

block/blk-mq.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,10 @@ static void blk_complete_request(struct request *req)
736736

737737
/* Completion has already been traced */
738738
bio_clear_flag(bio, BIO_TRACE_COMPLETION);
739+
740+
if (req_op(req) == REQ_OP_ZONE_APPEND)
741+
bio->bi_iter.bi_sector = req->__sector;
742+
739743
if (!is_flush)
740744
bio_endio(bio);
741745
bio = next;

block/elevator.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,6 @@ void elv_unregister_queue(struct request_queue *q)
525525
kobject_del(&e->kobj);
526526

527527
e->registered = 0;
528-
/* Re-enable throttling in case elevator disabled it */
529-
wbt_enable_default(q);
530528
}
531529
}
532530

block/genhd.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,20 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
548548
}
549549
EXPORT_SYMBOL(device_add_disk);
550550

551+
/**
552+
* blk_mark_disk_dead - mark a disk as dead
553+
* @disk: disk to mark as dead
554+
*
555+
* Mark as disk as dead (e.g. surprise removed) and don't accept any new I/O
556+
* to this disk.
557+
*/
558+
void blk_mark_disk_dead(struct gendisk *disk)
559+
{
560+
set_bit(GD_DEAD, &disk->state);
561+
blk_queue_start_drain(disk->queue);
562+
}
563+
EXPORT_SYMBOL_GPL(blk_mark_disk_dead);
564+
551565
/**
552566
* del_gendisk - remove the gendisk
553567
* @disk: the struct gendisk to remove

drivers/block/loop.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
#include <linux/ioprio.h>
8080
#include <linux/blk-cgroup.h>
8181
#include <linux/sched/mm.h>
82+
#include <linux/statfs.h>
8283

8384
#include "loop.h"
8485

@@ -774,8 +775,13 @@ static void loop_config_discard(struct loop_device *lo)
774775
granularity = 0;
775776

776777
} else {
778+
struct kstatfs sbuf;
779+
777780
max_discard_sectors = UINT_MAX >> 9;
778-
granularity = inode->i_sb->s_blocksize;
781+
if (!vfs_statfs(&file->f_path, &sbuf))
782+
granularity = sbuf.f_bsize;
783+
else
784+
max_discard_sectors = 0;
779785
}
780786

781787
if (max_discard_sectors) {

drivers/block/mtip32xx/mtip32xx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4112,7 +4112,7 @@ static void mtip_pci_remove(struct pci_dev *pdev)
41124112
"Completion workers still active!\n");
41134113
}
41144114

4115-
blk_set_queue_dying(dd->queue);
4115+
blk_mark_disk_dead(dd->disk);
41164116
set_bit(MTIP_DDF_REMOVE_PENDING_BIT, &dd->dd_flag);
41174117

41184118
/* Clean up the block layer. */

drivers/block/rbd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7185,7 +7185,7 @@ static ssize_t do_rbd_remove(struct bus_type *bus,
71857185
* IO to complete/fail.
71867186
*/
71877187
blk_mq_freeze_queue(rbd_dev->disk->queue);
7188-
blk_set_queue_dying(rbd_dev->disk->queue);
7188+
blk_mark_disk_dead(rbd_dev->disk);
71897189
}
71907190

71917191
del_gendisk(rbd_dev->disk);

drivers/block/xen-blkfront.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,7 @@ static void blkfront_closing(struct blkfront_info *info)
21262126

21272127
/* No more blkif_request(). */
21282128
blk_mq_stop_hw_queues(info->rq);
2129-
blk_set_queue_dying(info->rq);
2129+
blk_mark_disk_dead(info->gd);
21302130
set_capacity(info->gd, 0);
21312131

21322132
for_each_rinfo(info, rinfo, i) {

0 commit comments

Comments
 (0)