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
1107 sector_t zone = 0; /* Suppress gcc warning */1107 sector_t zone = 0; /* Suppress gcc warning */
1108 struct pkt_rb_node *node, *first_node;1108 struct pkt_rb_node *node, *first_node;
1109 struct rb_node *n;1109 struct rb_node *n;
1110 int wakeup;
1111 1110
1112 atomic_set(&pd->scan_queue, 0);1111 atomic_set(&pd->scan_queue, 0);
1113 1112
@@ -1179,12 +1178,14 @@ try_next_bio: · 65 unmodified lines
1179 spin_unlock(&pkt->lock);1178 spin_unlock(&pkt->lock);
1180 }1179 }
1181 /* check write congestion marks, and if bio_queue_size is1180 /* check write congestion marks, and if bio_queue_size is
1182 below, wake up any waiters */1181 * below, wake up any waiters
1183 wakeup = (pd->write_congestion_on > 01182 */
1184 && pd->bio_queue_size <= pd->write_congestion_off);1183 if (pd->congested &&
1184 pd->bio_queue_size <= pd->write_congestion_off) {
1185 pd->congested = false;
1186 wake_up_var(&pd->congested);
1187 }
1185 spin_unlock(&pd->lock);1188 spin_unlock(&pd->lock);
1186 if (wakeup)
1187 clear_bdi_congested(pd->disk->bdi, BLK_RW_ASYNC);
1188 1189
1189 pkt->sleep_time = max(PACKET_WAIT_TIME, 1);1190 pkt->sleep_time = max(PACKET_WAIT_TIME, 1);
1190 pkt_set_state(pkt, PACKET_WAITING_STATE);1191 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
2356 }2357 }
2357 spin_unlock(&pd->cdrw.active_list_lock);2358 spin_unlock(&pd->cdrw.active_list_lock);
2358 2359
2359 /*2360 /*
2360 * Test if there is enough room left in the bio work queue2361 * Test if there is enough room left in the bio work queue
2361 * (queue size >= congestion on mark).2362 * (queue size >= congestion on mark).
2362 * If not, wait till the work queue size is below the congestion off mark.2363 * 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
2364 spin_lock(&pd->lock);2365 spin_lock(&pd->lock);
2365 if (pd->write_congestion_on > 02366 if (pd->write_congestion_on > 0
2366 && pd->bio_queue_size >= pd->write_congestion_on) {2367 && pd->bio_queue_size >= pd->write_congestion_on) {
2367 set_bdi_congested(bio->bi_bdev->bd_disk->bdi, BLK_RW_ASYNC);2368 struct wait_bit_queue_entry wqe;
2368 do {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;
2369 spin_unlock(&pd->lock);2378 spin_unlock(&pd->lock);
2370 congestion_wait(BLK_RW_ASYNC, HZ);2379 schedule();
2371 spin_lock(&pd->lock);2380 spin_lock(&pd->lock);
2372 } while(pd->bio_queue_size > pd->write_congestion_off);2381 }
2373 }2382 }
2374 spin_unlock(&pd->lock);2383 spin_unlock(&pd->lock);
2375 2384
include/linux/pktcdvd.h+2−0
@@ -183,6 +183,8 @@ struct pktcdvd_device · 182 unmodified lines
183 spinlock_t lock; /* Serialize access to bio_queue */183 spinlock_t lock; /* Serialize access to bio_queue */
184 struct rb_root bio_queue; /* Work queue of bios we need to handle */184 struct rb_root bio_queue; /* Work queue of bios we need to handle */
185 int bio_queue_size; /* Number of nodes in bio_queue */185 int bio_queue_size; /* Number of nodes in bio_queue */
186 bool congested; /* Someone is waiting for bio_queue_size
187 * to drop. */
186 sector_t current_sector; /* Keep track of where the elevator is */188 sector_t current_sector; /* Keep track of where the elevator is */
187 atomic_t scan_queue; /* Set to non-zero when pkt_handle_queue */189 atomic_t scan_queue; /* Set to non-zero when pkt_handle_queue */
188 /* needs to be run. */190 /* 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