History

pktdvd: stop using bdi congestion framework.

The bdi congestion framework isn't widely used and should be deprecated. pktdvd makes use of it to track congestion, but this can be done entirely internally to pktdvd, so it doesn't need to use the framework. So introduce a "congested" flag. When waiting for bio_queue_size to drop, set this flag and a var_waitqueue() to wait for it. When bio_queue_size does drop and this flag is set, clear the flag and call wake_up_var(). We don't use a wait_var_event macro for the waiting as we need to set the flag and drop the spinlock before calling schedule() and while that is possible with __wait_var_event(), result is not easy to read.

NeilBrown committed 4 years ago

Commit db670971 parent 2385ebf2 files · +22 −11Browse files

Unified · Split

2 files
  1. drivers/block/pktcdvd.c +20 −11
  2. include/linux/pktcdvd.h +2 −0
drivers/block/pktcdvd.c+20−11
@@ -1107,7 +1107,6 @@ static int pkt_handle_queue(struct pktcdvd_device *pd) · 1106 unmodified lines
11071107 sector_t zone = 0; /* Suppress gcc warning */
11081108 struct pkt_rb_node *node, *first_node;
11091109 struct rb_node *n;
1110− int wakeup;
11111110
11121111 atomic_set(&pd->scan_queue, 0);
11131112
@@ -1179,12 +1178,14 @@ try_next_bio: · 65 unmodified lines
11791178 spin_unlock(&pkt->lock);
11801179 }
11811180 /* check write congestion marks, and if bio_queue_size is
1182− below, wake up any waiters */
1183− wakeup = (pd->write_congestion_on > 0
1184− && pd->bio_queue_size <= pd->write_congestion_off);
1181+ * below, wake up any waiters
1182+ */
1183+ if (pd->congested &&
1184+ pd->bio_queue_size <= pd->write_congestion_off) {
1185+ pd->congested = false;
1186+ wake_up_var(&pd->congested);
1187+ }
11851188 spin_unlock(&pd->lock);
1186− if (wakeup)
1187− clear_bdi_congested(pd->disk->bdi, BLK_RW_ASYNC);
11881189
11891190 pkt->sleep_time = max(PACKET_WAIT_TIME, 1);
11901191 pkt_set_state(pkt, PACKET_WAITING_STATE);
@@ -2356,7 +2357,7 @@ static void pkt_make_request_write(struct request_queue *q, struct bio *bio) · 1165 unmodified lines
23562357 }
23572358 spin_unlock(&pd->cdrw.active_list_lock);
23582359
2359− /*
2360+ /*
23602361 * Test if there is enough room left in the bio work queue
23612362 * (queue size >= congestion on mark).
23622363 * If not, wait till the work queue size is below the congestion off mark.
@@ -2364,12 +2365,20 @@ static void pkt_make_request_write(struct request_queue *q, struct bio *bio) · 1 unmodified line
23642365 spin_lock(&pd->lock);
23652366 if (pd->write_congestion_on > 0
23662367 && pd->bio_queue_size >= pd->write_congestion_on) {
2367− set_bdi_congested(bio->bi_bdev->bd_disk->bdi, BLK_RW_ASYNC);
2368− do {
2368+ struct wait_bit_queue_entry wqe;
2369+
2370+ init_wait_var_entry(&wqe, &pd->congested, 0);
2371+ for (;;) {
2372+ prepare_to_wait_event(__var_waitqueue(&pd->congested),
2373+ &wqe.wq_entry,
2374+ TASK_UNINTERRUPTIBLE);
2375+ if (pd->bio_queue_size <= pd->write_congestion_off)
2376+ break;
2377+ pd->congested = true;
23692378 spin_unlock(&pd->lock);
2370− congestion_wait(BLK_RW_ASYNC, HZ);
2379+ schedule();
23712380 spin_lock(&pd->lock);
2372− } while(pd->bio_queue_size > pd->write_congestion_off);
2381+ }
23732382 }
23742383 spin_unlock(&pd->lock);
23752384
include/linux/pktcdvd.h+2−0
@@ -183,6 +183,8 @@ struct pktcdvd_device · 182 unmodified lines
183183 spinlock_t lock; /* Serialize access to bio_queue */
184184 struct rb_root bio_queue; /* Work queue of bios we need to handle */
185185 int bio_queue_size; /* Number of nodes in bio_queue */
186+ bool congested; /* Someone is waiting for bio_queue_size
187+ * to drop. */
186188 sector_t current_sector; /* Keep track of where the elevator is */
187189 atomic_t scan_queue; /* Set to non-zero when pkt_handle_queue */
188190 /* needs to be run. */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t