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-20180830' of git://git.kernel.dk/linux-block

Pull block fixes from Jens Axboe:
"Small collection of fixes that should go into this series. This pull
contains:

- NVMe pull request with three small fixes (via Christoph)

- Kill useless NULL check before kmem_cache_destroy (Chengguang Xu)

- Xen block driver pull request with persistent grant flushing fixes
(Juergen Gross)

- Final wbt fixes, wrapping up the changes for this series. These
have been heavily tested (me)

- cdrom info leak fix (Scott Bauer)

- ATA dma quirk for SQ201 (Linus Walleij)

- Straight forward bsg refcount_t conversion (John Pittman)"

* tag 'for-linus-20180830' of git://git.kernel.dk/linux-block:
cdrom: Fix info leak/OOB read in cdrom_ioctl_drive_status
nvmet: free workqueue object if module init fails
nvme-fcloop: Fix dropped LS's to removed target port
nvme-pci: add a memory barrier to nvme_dbbuf_update_and_check_event
block: bsg: move atomic_t ref_count variable to refcount API
block: remove unnecessary condition check
ata: ftide010: Add a quirk for SQ201
blk-wbt: remove dead code
blk-wbt: improve waking of tasks
blk-wbt: abstract out end IO completion handler
xen/blkback: remove unused pers_gnts_lock from struct xen_blkif_ring
xen/blkback: move persistent grants flags to bool
xen/blkfront: reorder tests in xlblk_init()
xen/blkfront: cleanup stale persistent grants
xen/blkback: don't keep persistent grants too long

+271 -110
+10
Documentation/ABI/testing/sysfs-driver-xen-blkback
··· 15 15 blkback. If the frontend tries to use more than 16 16 max_persistent_grants, the LRU kicks in and starts 17 17 removing 5% of max_persistent_grants every 100ms. 18 + 19 + What: /sys/module/xen_blkback/parameters/persistent_grant_unused_seconds 20 + Date: August 2018 21 + KernelVersion: 4.19 22 + Contact: Roger Pau Monné <roger.pau@citrix.com> 23 + Description: 24 + How long a persistent grant is allowed to remain 25 + allocated without being in use. The time is in 26 + seconds, 0 means indefinitely long. 27 + The default is 60 seconds.
+71 -20
block/blk-wbt.c
··· 123 123 } 124 124 } 125 125 126 - static void __wbt_done(struct rq_qos *rqos, enum wbt_flags wb_acct) 126 + static void wbt_rqw_done(struct rq_wb *rwb, struct rq_wait *rqw, 127 + enum wbt_flags wb_acct) 127 128 { 128 - struct rq_wb *rwb = RQWB(rqos); 129 - struct rq_wait *rqw; 130 129 int inflight, limit; 131 130 132 - if (!(wb_acct & WBT_TRACKED)) 133 - return; 134 - 135 - rqw = get_rq_wait(rwb, wb_acct); 136 131 inflight = atomic_dec_return(&rqw->inflight); 137 132 138 133 /* ··· 161 166 int diff = limit - inflight; 162 167 163 168 if (!inflight || diff >= rwb->wb_background / 2) 164 - wake_up(&rqw->wait); 169 + wake_up_all(&rqw->wait); 165 170 } 171 + } 172 + 173 + static void __wbt_done(struct rq_qos *rqos, enum wbt_flags wb_acct) 174 + { 175 + struct rq_wb *rwb = RQWB(rqos); 176 + struct rq_wait *rqw; 177 + 178 + if (!(wb_acct & WBT_TRACKED)) 179 + return; 180 + 181 + rqw = get_rq_wait(rwb, wb_acct); 182 + wbt_rqw_done(rwb, rqw, wb_acct); 166 183 } 167 184 168 185 /* ··· 488 481 return limit; 489 482 } 490 483 484 + struct wbt_wait_data { 485 + struct wait_queue_entry wq; 486 + struct task_struct *task; 487 + struct rq_wb *rwb; 488 + struct rq_wait *rqw; 489 + unsigned long rw; 490 + bool got_token; 491 + }; 492 + 493 + static int wbt_wake_function(struct wait_queue_entry *curr, unsigned int mode, 494 + int wake_flags, void *key) 495 + { 496 + struct wbt_wait_data *data = container_of(curr, struct wbt_wait_data, 497 + wq); 498 + 499 + /* 500 + * If we fail to get a budget, return -1 to interrupt the wake up 501 + * loop in __wake_up_common. 502 + */ 503 + if (!rq_wait_inc_below(data->rqw, get_limit(data->rwb, data->rw))) 504 + return -1; 505 + 506 + data->got_token = true; 507 + list_del_init(&curr->entry); 508 + wake_up_process(data->task); 509 + return 1; 510 + } 511 + 491 512 /* 492 513 * Block if we will exceed our limit, or if we are currently waiting for 493 514 * the timer to kick off queuing again. ··· 526 491 __acquires(lock) 527 492 { 528 493 struct rq_wait *rqw = get_rq_wait(rwb, wb_acct); 529 - DECLARE_WAITQUEUE(wait, current); 494 + struct wbt_wait_data data = { 495 + .wq = { 496 + .func = wbt_wake_function, 497 + .entry = LIST_HEAD_INIT(data.wq.entry), 498 + }, 499 + .task = current, 500 + .rwb = rwb, 501 + .rqw = rqw, 502 + .rw = rw, 503 + }; 530 504 bool has_sleeper; 531 505 532 506 has_sleeper = wq_has_sleeper(&rqw->wait); 533 507 if (!has_sleeper && rq_wait_inc_below(rqw, get_limit(rwb, rw))) 534 508 return; 535 509 536 - add_wait_queue_exclusive(&rqw->wait, &wait); 510 + prepare_to_wait_exclusive(&rqw->wait, &data.wq, TASK_UNINTERRUPTIBLE); 537 511 do { 538 - set_current_state(TASK_UNINTERRUPTIBLE); 539 - 540 - if (!has_sleeper && rq_wait_inc_below(rqw, get_limit(rwb, rw))) 512 + if (data.got_token) 541 513 break; 514 + 515 + if (!has_sleeper && 516 + rq_wait_inc_below(rqw, get_limit(rwb, rw))) { 517 + finish_wait(&rqw->wait, &data.wq); 518 + 519 + /* 520 + * We raced with wbt_wake_function() getting a token, 521 + * which means we now have two. Put our local token 522 + * and wake anyone else potentially waiting for one. 523 + */ 524 + if (data.got_token) 525 + wbt_rqw_done(rwb, rqw, wb_acct); 526 + break; 527 + } 542 528 543 529 if (lock) { 544 530 spin_unlock_irq(lock); ··· 567 511 spin_lock_irq(lock); 568 512 } else 569 513 io_schedule(); 514 + 570 515 has_sleeper = false; 571 516 } while (1); 572 517 573 - __set_current_state(TASK_RUNNING); 574 - remove_wait_queue(&rqw->wait, &wait); 518 + finish_wait(&rqw->wait, &data.wq); 575 519 } 576 520 577 521 static inline bool wbt_should_throttle(struct rq_wb *rwb, struct bio *bio) ··· 635 579 wb_timestamp(rwb, &rwb->last_issue); 636 580 return; 637 581 } 638 - 639 - if (current_is_kswapd()) 640 - flags |= WBT_KSWAPD; 641 - if (bio_op(bio) == REQ_OP_DISCARD) 642 - flags |= WBT_DISCARD; 643 582 644 583 __wbt_wait(rwb, flags, bio->bi_opf, lock); 645 584
+4 -4
block/bsg.c
··· 37 37 struct request_queue *queue; 38 38 spinlock_t lock; 39 39 struct hlist_node dev_list; 40 - atomic_t ref_count; 40 + refcount_t ref_count; 41 41 char name[20]; 42 42 int max_queue; 43 43 }; ··· 252 252 253 253 mutex_lock(&bsg_mutex); 254 254 255 - if (!atomic_dec_and_test(&bd->ref_count)) { 255 + if (!refcount_dec_and_test(&bd->ref_count)) { 256 256 mutex_unlock(&bsg_mutex); 257 257 return 0; 258 258 } ··· 290 290 291 291 bd->queue = rq; 292 292 293 - atomic_set(&bd->ref_count, 1); 293 + refcount_set(&bd->ref_count, 1); 294 294 hlist_add_head(&bd->dev_list, bsg_dev_idx_hash(iminor(inode))); 295 295 296 296 strncpy(bd->name, dev_name(rq->bsg_dev.class_dev), sizeof(bd->name) - 1); ··· 308 308 309 309 hlist_for_each_entry(bd, bsg_dev_idx_hash(minor), dev_list) { 310 310 if (bd->queue == q) { 311 - atomic_inc(&bd->ref_count); 311 + refcount_inc(&bd->ref_count); 312 312 goto found; 313 313 } 314 314 }
+1 -2
block/elevator.c
··· 895 895 spin_lock(&elv_list_lock); 896 896 if (elevator_find(e->elevator_name, e->uses_mq)) { 897 897 spin_unlock(&elv_list_lock); 898 - if (e->icq_cache) 899 - kmem_cache_destroy(e->icq_cache); 898 + kmem_cache_destroy(e->icq_cache); 900 899 return -EBUSY; 901 900 } 902 901 list_add_tail(&e->list, &elv_list);
+17 -10
drivers/ata/pata_ftide010.c
··· 256 256 .qc_issue = ftide010_qc_issue, 257 257 }; 258 258 259 - static struct ata_port_info ftide010_port_info[] = { 260 - { 261 - .flags = ATA_FLAG_SLAVE_POSS, 262 - .mwdma_mask = ATA_MWDMA2, 263 - .udma_mask = ATA_UDMA6, 264 - .pio_mask = ATA_PIO4, 265 - .port_ops = &pata_ftide010_port_ops, 266 - }, 259 + static struct ata_port_info ftide010_port_info = { 260 + .flags = ATA_FLAG_SLAVE_POSS, 261 + .mwdma_mask = ATA_MWDMA2, 262 + .udma_mask = ATA_UDMA6, 263 + .pio_mask = ATA_PIO4, 264 + .port_ops = &pata_ftide010_port_ops, 267 265 }; 268 266 269 267 #if IS_ENABLED(CONFIG_SATA_GEMINI) ··· 347 349 } 348 350 349 351 static int pata_ftide010_gemini_init(struct ftide010 *ftide, 352 + struct ata_port_info *pi, 350 353 bool is_ata1) 351 354 { 352 355 struct device *dev = ftide->dev; ··· 372 373 373 374 /* Flag port as SATA-capable */ 374 375 if (gemini_sata_bridge_enabled(sg, is_ata1)) 375 - ftide010_port_info[0].flags |= ATA_FLAG_SATA; 376 + pi->flags |= ATA_FLAG_SATA; 377 + 378 + /* This device has broken DMA, only PIO works */ 379 + if (of_machine_is_compatible("itian,sq201")) { 380 + pi->mwdma_mask = 0; 381 + pi->udma_mask = 0; 382 + } 376 383 377 384 /* 378 385 * We assume that a simple 40-wire cable is used in the PATA mode. ··· 440 435 } 441 436 #else 442 437 static int pata_ftide010_gemini_init(struct ftide010 *ftide, 438 + struct ata_port_info *pi, 443 439 bool is_ata1) 444 440 { 445 441 return -ENOTSUPP; ··· 452 446 { 453 447 struct device *dev = &pdev->dev; 454 448 struct device_node *np = dev->of_node; 455 - const struct ata_port_info pi = ftide010_port_info[0]; 449 + struct ata_port_info pi = ftide010_port_info; 456 450 const struct ata_port_info *ppi[] = { &pi, NULL }; 457 451 struct ftide010 *ftide; 458 452 struct resource *res; ··· 496 490 * are ATA0. This will also set up the cable types. 497 491 */ 498 492 ret = pata_ftide010_gemini_init(ftide, 493 + &pi, 499 494 (res->start == 0x63400000)); 500 495 if (ret) 501 496 goto err_dis_clk;
+54 -47
drivers/block/xen-blkback/blkback.c
··· 84 84 "Maximum number of grants to map persistently"); 85 85 86 86 /* 87 + * How long a persistent grant is allowed to remain allocated without being in 88 + * use. The time is in seconds, 0 means indefinitely long. 89 + */ 90 + 91 + static unsigned int xen_blkif_pgrant_timeout = 60; 92 + module_param_named(persistent_grant_unused_seconds, xen_blkif_pgrant_timeout, 93 + uint, 0644); 94 + MODULE_PARM_DESC(persistent_grant_unused_seconds, 95 + "Time in seconds an unused persistent grant is allowed to " 96 + "remain allocated. Default is 60, 0 means unlimited."); 97 + 98 + /* 87 99 * Maximum number of rings/queues blkback supports, allow as many queues as there 88 100 * are CPUs if user has not specified a value. 89 101 */ ··· 134 122 135 123 /* Number of free pages to remove on each call to gnttab_free_pages */ 136 124 #define NUM_BATCH_FREE_PAGES 10 125 + 126 + static inline bool persistent_gnt_timeout(struct persistent_gnt *persistent_gnt) 127 + { 128 + return xen_blkif_pgrant_timeout && 129 + (jiffies - persistent_gnt->last_used >= 130 + HZ * xen_blkif_pgrant_timeout); 131 + } 137 132 138 133 static inline int get_free_page(struct xen_blkif_ring *ring, struct page **page) 139 134 { ··· 255 236 } 256 237 } 257 238 258 - bitmap_zero(persistent_gnt->flags, PERSISTENT_GNT_FLAGS_SIZE); 259 - set_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags); 239 + persistent_gnt->active = true; 260 240 /* Add new node and rebalance tree. */ 261 241 rb_link_node(&(persistent_gnt->node), parent, new); 262 242 rb_insert_color(&(persistent_gnt->node), &ring->persistent_gnts); ··· 279 261 else if (gref > data->gnt) 280 262 node = node->rb_right; 281 263 else { 282 - if(test_bit(PERSISTENT_GNT_ACTIVE, data->flags)) { 264 + if (data->active) { 283 265 pr_alert_ratelimited("requesting a grant already in use\n"); 284 266 return NULL; 285 267 } 286 - set_bit(PERSISTENT_GNT_ACTIVE, data->flags); 268 + data->active = true; 287 269 atomic_inc(&ring->persistent_gnt_in_use); 288 270 return data; 289 271 } ··· 294 276 static void put_persistent_gnt(struct xen_blkif_ring *ring, 295 277 struct persistent_gnt *persistent_gnt) 296 278 { 297 - if(!test_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags)) 279 + if (!persistent_gnt->active) 298 280 pr_alert_ratelimited("freeing a grant already unused\n"); 299 - set_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags); 300 - clear_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags); 281 + persistent_gnt->last_used = jiffies; 282 + persistent_gnt->active = false; 301 283 atomic_dec(&ring->persistent_gnt_in_use); 302 284 } 303 285 ··· 389 371 struct persistent_gnt *persistent_gnt; 390 372 struct rb_node *n; 391 373 unsigned int num_clean, total; 392 - bool scan_used = false, clean_used = false; 374 + bool scan_used = false; 393 375 struct rb_root *root; 394 - 395 - if (ring->persistent_gnt_c < xen_blkif_max_pgrants || 396 - (ring->persistent_gnt_c == xen_blkif_max_pgrants && 397 - !ring->blkif->vbd.overflow_max_grants)) { 398 - goto out; 399 - } 400 376 401 377 if (work_busy(&ring->persistent_purge_work)) { 402 378 pr_alert_ratelimited("Scheduled work from previous purge is still busy, cannot purge list\n"); 403 379 goto out; 404 380 } 405 381 406 - num_clean = (xen_blkif_max_pgrants / 100) * LRU_PERCENT_CLEAN; 407 - num_clean = ring->persistent_gnt_c - xen_blkif_max_pgrants + num_clean; 408 - num_clean = min(ring->persistent_gnt_c, num_clean); 409 - if ((num_clean == 0) || 410 - (num_clean > (ring->persistent_gnt_c - atomic_read(&ring->persistent_gnt_in_use)))) 411 - goto out; 382 + if (ring->persistent_gnt_c < xen_blkif_max_pgrants || 383 + (ring->persistent_gnt_c == xen_blkif_max_pgrants && 384 + !ring->blkif->vbd.overflow_max_grants)) { 385 + num_clean = 0; 386 + } else { 387 + num_clean = (xen_blkif_max_pgrants / 100) * LRU_PERCENT_CLEAN; 388 + num_clean = ring->persistent_gnt_c - xen_blkif_max_pgrants + 389 + num_clean; 390 + num_clean = min(ring->persistent_gnt_c, num_clean); 391 + pr_debug("Going to purge at least %u persistent grants\n", 392 + num_clean); 393 + } 412 394 413 395 /* 414 396 * At this point, we can assure that there will be no calls ··· 419 401 * number of grants. 420 402 */ 421 403 422 - total = num_clean; 423 - 424 - pr_debug("Going to purge %u persistent grants\n", num_clean); 404 + total = 0; 425 405 426 406 BUG_ON(!list_empty(&ring->persistent_purge_list)); 427 407 root = &ring->persistent_gnts; ··· 428 412 BUG_ON(persistent_gnt->handle == 429 413 BLKBACK_INVALID_HANDLE); 430 414 431 - if (clean_used) { 432 - clear_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags); 415 + if (persistent_gnt->active) 433 416 continue; 434 - } 435 - 436 - if (test_bit(PERSISTENT_GNT_ACTIVE, persistent_gnt->flags)) 417 + if (!scan_used && !persistent_gnt_timeout(persistent_gnt)) 437 418 continue; 438 - if (!scan_used && 439 - (test_bit(PERSISTENT_GNT_WAS_ACTIVE, persistent_gnt->flags))) 419 + if (scan_used && total >= num_clean) 440 420 continue; 441 421 442 422 rb_erase(&persistent_gnt->node, root); 443 423 list_add(&persistent_gnt->remove_node, 444 424 &ring->persistent_purge_list); 445 - if (--num_clean == 0) 446 - goto finished; 425 + total++; 447 426 } 448 427 /* 449 - * If we get here it means we also need to start cleaning 428 + * Check whether we also need to start cleaning 450 429 * grants that were used since last purge in order to cope 451 430 * with the requested num 452 431 */ 453 - if (!scan_used && !clean_used) { 454 - pr_debug("Still missing %u purged frames\n", num_clean); 432 + if (!scan_used && total < num_clean) { 433 + pr_debug("Still missing %u purged frames\n", num_clean - total); 455 434 scan_used = true; 456 435 goto purge_list; 457 436 } 458 - finished: 459 - if (!clean_used) { 460 - pr_debug("Finished scanning for grants to clean, removing used flag\n"); 461 - clean_used = true; 462 - goto purge_list; 437 + 438 + if (total) { 439 + ring->persistent_gnt_c -= total; 440 + ring->blkif->vbd.overflow_max_grants = 0; 441 + 442 + /* We can defer this work */ 443 + schedule_work(&ring->persistent_purge_work); 444 + pr_debug("Purged %u/%u\n", num_clean, total); 463 445 } 464 - 465 - ring->persistent_gnt_c -= (total - num_clean); 466 - ring->blkif->vbd.overflow_max_grants = 0; 467 - 468 - /* We can defer this work */ 469 - schedule_work(&ring->persistent_purge_work); 470 - pr_debug("Purged %u/%u\n", (total - num_clean), total); 471 446 472 447 out: 473 448 return;
+2 -12
drivers/block/xen-blkback/common.h
··· 233 233 234 234 struct backend_info; 235 235 236 - /* Number of available flags */ 237 - #define PERSISTENT_GNT_FLAGS_SIZE 2 238 - /* This persistent grant is currently in use */ 239 - #define PERSISTENT_GNT_ACTIVE 0 240 - /* 241 - * This persistent grant has been used, this flag is set when we remove the 242 - * PERSISTENT_GNT_ACTIVE, to know that this grant has been used recently. 243 - */ 244 - #define PERSISTENT_GNT_WAS_ACTIVE 1 245 - 246 236 /* Number of requests that we can fit in a ring */ 247 237 #define XEN_BLKIF_REQS_PER_PAGE 32 248 238 ··· 240 250 struct page *page; 241 251 grant_ref_t gnt; 242 252 grant_handle_t handle; 243 - DECLARE_BITMAP(flags, PERSISTENT_GNT_FLAGS_SIZE); 253 + unsigned long last_used; 254 + bool active; 244 255 struct rb_node node; 245 256 struct list_head remove_node; 246 257 }; ··· 269 278 wait_queue_head_t pending_free_wq; 270 279 271 280 /* Tree to store persistent grants. */ 272 - spinlock_t pers_gnts_lock; 273 281 struct rb_root persistent_gnts; 274 282 unsigned int persistent_gnt_c; 275 283 atomic_t persistent_gnt_in_use;
+98 -12
drivers/block/xen-blkfront.c
··· 46 46 #include <linux/scatterlist.h> 47 47 #include <linux/bitmap.h> 48 48 #include <linux/list.h> 49 + #include <linux/workqueue.h> 49 50 50 51 #include <xen/xen.h> 51 52 #include <xen/xenbus.h> ··· 122 121 123 122 static DEFINE_MUTEX(blkfront_mutex); 124 123 static const struct block_device_operations xlvbd_block_fops; 124 + static struct delayed_work blkfront_work; 125 + static LIST_HEAD(info_list); 125 126 126 127 /* 127 128 * Maximum number of segments in indirect requests, the actual value used by ··· 219 216 /* Save uncomplete reqs and bios for migration. */ 220 217 struct list_head requests; 221 218 struct bio_list bio_list; 219 + struct list_head info_list; 222 220 }; 223 221 224 222 static unsigned int nr_minors; ··· 1763 1759 return err; 1764 1760 } 1765 1761 1762 + static void free_info(struct blkfront_info *info) 1763 + { 1764 + list_del(&info->info_list); 1765 + kfree(info); 1766 + } 1767 + 1766 1768 /* Common code used when first setting up, and when resuming. */ 1767 1769 static int talk_to_blkback(struct xenbus_device *dev, 1768 1770 struct blkfront_info *info) ··· 1890 1880 destroy_blkring: 1891 1881 blkif_free(info, 0); 1892 1882 1893 - kfree(info); 1883 + mutex_lock(&blkfront_mutex); 1884 + free_info(info); 1885 + mutex_unlock(&blkfront_mutex); 1886 + 1894 1887 dev_set_drvdata(&dev->dev, NULL); 1895 1888 1896 1889 return err; ··· 2003 1990 /* Front end dir is a number, which is used as the id. */ 2004 1991 info->handle = simple_strtoul(strrchr(dev->nodename, '/')+1, NULL, 0); 2005 1992 dev_set_drvdata(&dev->dev, info); 1993 + 1994 + mutex_lock(&blkfront_mutex); 1995 + list_add(&info->info_list, &info_list); 1996 + mutex_unlock(&blkfront_mutex); 2006 1997 2007 1998 return 0; 2008 1999 } ··· 2318 2301 if (indirect_segments <= BLKIF_MAX_SEGMENTS_PER_REQUEST) 2319 2302 indirect_segments = 0; 2320 2303 info->max_indirect_segments = indirect_segments; 2304 + 2305 + if (info->feature_persistent) { 2306 + mutex_lock(&blkfront_mutex); 2307 + schedule_delayed_work(&blkfront_work, HZ * 10); 2308 + mutex_unlock(&blkfront_mutex); 2309 + } 2321 2310 } 2322 2311 2323 2312 /* ··· 2505 2482 mutex_unlock(&info->mutex); 2506 2483 2507 2484 if (!bdev) { 2508 - kfree(info); 2485 + mutex_lock(&blkfront_mutex); 2486 + free_info(info); 2487 + mutex_unlock(&blkfront_mutex); 2509 2488 return 0; 2510 2489 } 2511 2490 ··· 2527 2502 if (info && !bdev->bd_openers) { 2528 2503 xlvbd_release_gendisk(info); 2529 2504 disk->private_data = NULL; 2530 - kfree(info); 2505 + mutex_lock(&blkfront_mutex); 2506 + free_info(info); 2507 + mutex_unlock(&blkfront_mutex); 2531 2508 } 2532 2509 2533 2510 mutex_unlock(&bdev->bd_mutex); ··· 2612 2585 dev_info(disk_to_dev(bdev->bd_disk), "releasing disk\n"); 2613 2586 xlvbd_release_gendisk(info); 2614 2587 disk->private_data = NULL; 2615 - kfree(info); 2588 + free_info(info); 2616 2589 } 2617 2590 2618 2591 out: ··· 2645 2618 .is_ready = blkfront_is_ready, 2646 2619 }; 2647 2620 2621 + static void purge_persistent_grants(struct blkfront_info *info) 2622 + { 2623 + unsigned int i; 2624 + unsigned long flags; 2625 + 2626 + for (i = 0; i < info->nr_rings; i++) { 2627 + struct blkfront_ring_info *rinfo = &info->rinfo[i]; 2628 + struct grant *gnt_list_entry, *tmp; 2629 + 2630 + spin_lock_irqsave(&rinfo->ring_lock, flags); 2631 + 2632 + if (rinfo->persistent_gnts_c == 0) { 2633 + spin_unlock_irqrestore(&rinfo->ring_lock, flags); 2634 + continue; 2635 + } 2636 + 2637 + list_for_each_entry_safe(gnt_list_entry, tmp, &rinfo->grants, 2638 + node) { 2639 + if (gnt_list_entry->gref == GRANT_INVALID_REF || 2640 + gnttab_query_foreign_access(gnt_list_entry->gref)) 2641 + continue; 2642 + 2643 + list_del(&gnt_list_entry->node); 2644 + gnttab_end_foreign_access(gnt_list_entry->gref, 0, 0UL); 2645 + rinfo->persistent_gnts_c--; 2646 + __free_page(gnt_list_entry->page); 2647 + kfree(gnt_list_entry); 2648 + } 2649 + 2650 + spin_unlock_irqrestore(&rinfo->ring_lock, flags); 2651 + } 2652 + } 2653 + 2654 + static void blkfront_delay_work(struct work_struct *work) 2655 + { 2656 + struct blkfront_info *info; 2657 + bool need_schedule_work = false; 2658 + 2659 + mutex_lock(&blkfront_mutex); 2660 + 2661 + list_for_each_entry(info, &info_list, info_list) { 2662 + if (info->feature_persistent) { 2663 + need_schedule_work = true; 2664 + mutex_lock(&info->mutex); 2665 + purge_persistent_grants(info); 2666 + mutex_unlock(&info->mutex); 2667 + } 2668 + } 2669 + 2670 + if (need_schedule_work) 2671 + schedule_delayed_work(&blkfront_work, HZ * 10); 2672 + 2673 + mutex_unlock(&blkfront_mutex); 2674 + } 2675 + 2648 2676 static int __init xlblk_init(void) 2649 2677 { 2650 2678 int ret; ··· 2707 2625 2708 2626 if (!xen_domain()) 2709 2627 return -ENODEV; 2628 + 2629 + if (!xen_has_pv_disk_devices()) 2630 + return -ENODEV; 2631 + 2632 + if (register_blkdev(XENVBD_MAJOR, DEV_NAME)) { 2633 + pr_warn("xen_blk: can't get major %d with name %s\n", 2634 + XENVBD_MAJOR, DEV_NAME); 2635 + return -ENODEV; 2636 + } 2710 2637 2711 2638 if (xen_blkif_max_segments < BLKIF_MAX_SEGMENTS_PER_REQUEST) 2712 2639 xen_blkif_max_segments = BLKIF_MAX_SEGMENTS_PER_REQUEST; ··· 2732 2641 xen_blkif_max_queues = nr_cpus; 2733 2642 } 2734 2643 2735 - if (!xen_has_pv_disk_devices()) 2736 - return -ENODEV; 2737 - 2738 - if (register_blkdev(XENVBD_MAJOR, DEV_NAME)) { 2739 - printk(KERN_WARNING "xen_blk: can't get major %d with name %s\n", 2740 - XENVBD_MAJOR, DEV_NAME); 2741 - return -ENODEV; 2742 - } 2644 + INIT_DELAYED_WORK(&blkfront_work, blkfront_delay_work); 2743 2645 2744 2646 ret = xenbus_register_frontend(&blkfront_driver); 2745 2647 if (ret) { ··· 2747 2663 2748 2664 static void __exit xlblk_exit(void) 2749 2665 { 2666 + cancel_delayed_work_sync(&blkfront_work); 2667 + 2750 2668 xenbus_unregister_driver(&blkfront_driver); 2751 2669 unregister_blkdev(XENVBD_MAJOR, DEV_NAME); 2752 2670 kfree(minors);
+1 -1
drivers/cdrom/cdrom.c
··· 2546 2546 if (!CDROM_CAN(CDC_SELECT_DISC) || 2547 2547 (arg == CDSL_CURRENT || arg == CDSL_NONE)) 2548 2548 return cdi->ops->drive_status(cdi, CDSL_CURRENT); 2549 - if (((int)arg >= cdi->capacity)) 2549 + if (arg >= cdi->capacity) 2550 2550 return -EINVAL; 2551 2551 return cdrom_slot_status(cdi, arg); 2552 2552 }
+8
drivers/nvme/host/pci.c
··· 316 316 old_value = *dbbuf_db; 317 317 *dbbuf_db = value; 318 318 319 + /* 320 + * Ensure that the doorbell is updated before reading the event 321 + * index from memory. The controller needs to provide similar 322 + * ordering to ensure the envent index is updated before reading 323 + * the doorbell. 324 + */ 325 + mb(); 326 + 319 327 if (!nvme_dbbuf_need_event(*dbbuf_ei, value, old_value)) 320 328 return false; 321 329 }
+3 -1
drivers/nvme/target/core.c
··· 1210 1210 1211 1211 error = nvmet_init_discovery(); 1212 1212 if (error) 1213 - goto out; 1213 + goto out_free_work_queue; 1214 1214 1215 1215 error = nvmet_init_configfs(); 1216 1216 if (error) ··· 1219 1219 1220 1220 out_exit_discovery: 1221 1221 nvmet_exit_discovery(); 1222 + out_free_work_queue: 1223 + destroy_workqueue(buffered_io_wq); 1222 1224 out: 1223 1225 return error; 1224 1226 }
+2 -1
drivers/nvme/target/fcloop.c
··· 311 311 struct fcloop_tport *tport = tls_req->tport; 312 312 struct nvmefc_ls_req *lsreq = tls_req->lsreq; 313 313 314 - if (tport->remoteport) 314 + if (!tport || tport->remoteport) 315 315 lsreq->done(lsreq, tls_req->status); 316 316 } 317 317 ··· 329 329 330 330 if (!rport->targetport) { 331 331 tls_req->status = -ECONNREFUSED; 332 + tls_req->tport = NULL; 332 333 schedule_work(&tls_req->work); 333 334 return ret; 334 335 }