dm-bufio.c (f1615bbe9be4def59c3b3eaddb60722efeed16c2) | dm-bufio.c (743162013d40ca612b4cb53d3a200dff2d9ab26e) |
---|---|
1/* 2 * Copyright (C) 2009-2011 Red Hat, Inc. 3 * 4 * Author: Mikulas Patocka <mpatocka@redhat.com> 5 * 6 * This file is released under the GPL. 7 */ 8 --- 601 unchanged lines hidden (view full) --- 610 smp_mb__before_atomic(); 611 clear_bit(B_WRITING, &b->state); 612 smp_mb__after_atomic(); 613 614 wake_up_bit(&b->state, B_WRITING); 615} 616 617/* | 1/* 2 * Copyright (C) 2009-2011 Red Hat, Inc. 3 * 4 * Author: Mikulas Patocka <mpatocka@redhat.com> 5 * 6 * This file is released under the GPL. 7 */ 8 --- 601 unchanged lines hidden (view full) --- 610 smp_mb__before_atomic(); 611 clear_bit(B_WRITING, &b->state); 612 smp_mb__after_atomic(); 613 614 wake_up_bit(&b->state, B_WRITING); 615} 616 617/* |
618 * This function is called when wait_on_bit is actually waiting. 619 */ 620static int do_io_schedule(void *word) 621{ 622 io_schedule(); 623 624 return 0; 625} 626 627/* | |
628 * Initiate a write on a dirty buffer, but don't wait for it. 629 * 630 * - If the buffer is not dirty, exit. 631 * - If there some previous write going on, wait for it to finish (we can't 632 * have two writes on the same buffer simultaneously). 633 * - Submit our write and don't wait on it. We set B_WRITING indicating 634 * that there is a write in progress. 635 */ 636static void __write_dirty_buffer(struct dm_buffer *b, 637 struct list_head *write_list) 638{ 639 if (!test_bit(B_DIRTY, &b->state)) 640 return; 641 642 clear_bit(B_DIRTY, &b->state); | 618 * Initiate a write on a dirty buffer, but don't wait for it. 619 * 620 * - If the buffer is not dirty, exit. 621 * - If there some previous write going on, wait for it to finish (we can't 622 * have two writes on the same buffer simultaneously). 623 * - Submit our write and don't wait on it. We set B_WRITING indicating 624 * that there is a write in progress. 625 */ 626static void __write_dirty_buffer(struct dm_buffer *b, 627 struct list_head *write_list) 628{ 629 if (!test_bit(B_DIRTY, &b->state)) 630 return; 631 632 clear_bit(B_DIRTY, &b->state); |
643 wait_on_bit_lock(&b->state, B_WRITING, 644 do_io_schedule, TASK_UNINTERRUPTIBLE); | 633 wait_on_bit_lock_io(&b->state, B_WRITING, TASK_UNINTERRUPTIBLE); |
645 646 if (!write_list) 647 submit_io(b, WRITE, b->block, write_endio); 648 else 649 list_add_tail(&b->write_list, write_list); 650} 651 652static void __flush_write_list(struct list_head *write_list) --- 17 unchanged lines hidden (view full) --- 670 */ 671static void __make_buffer_clean(struct dm_buffer *b) 672{ 673 BUG_ON(b->hold_count); 674 675 if (!b->state) /* fast case */ 676 return; 677 | 634 635 if (!write_list) 636 submit_io(b, WRITE, b->block, write_endio); 637 else 638 list_add_tail(&b->write_list, write_list); 639} 640 641static void __flush_write_list(struct list_head *write_list) --- 17 unchanged lines hidden (view full) --- 659 */ 660static void __make_buffer_clean(struct dm_buffer *b) 661{ 662 BUG_ON(b->hold_count); 663 664 if (!b->state) /* fast case */ 665 return; 666 |
678 wait_on_bit(&b->state, B_READING, do_io_schedule, TASK_UNINTERRUPTIBLE); | 667 wait_on_bit_io(&b->state, B_READING, TASK_UNINTERRUPTIBLE); |
679 __write_dirty_buffer(b, NULL); | 668 __write_dirty_buffer(b, NULL); |
680 wait_on_bit(&b->state, B_WRITING, do_io_schedule, TASK_UNINTERRUPTIBLE); | 669 wait_on_bit_io(&b->state, B_WRITING, TASK_UNINTERRUPTIBLE); |
681} 682 683/* 684 * Find some buffer that is not held by anybody, clean it, unlink it and 685 * return it. 686 */ 687static struct dm_buffer *__get_unclaimed_buffer(struct dm_bufio_client *c) 688{ --- 336 unchanged lines hidden (view full) --- 1025 __flush_write_list(&write_list); 1026 1027 if (!b) 1028 return b; 1029 1030 if (need_submit) 1031 submit_io(b, READ, b->block, read_endio); 1032 | 670} 671 672/* 673 * Find some buffer that is not held by anybody, clean it, unlink it and 674 * return it. 675 */ 676static struct dm_buffer *__get_unclaimed_buffer(struct dm_bufio_client *c) 677{ --- 336 unchanged lines hidden (view full) --- 1014 __flush_write_list(&write_list); 1015 1016 if (!b) 1017 return b; 1018 1019 if (need_submit) 1020 submit_io(b, READ, b->block, read_endio); 1021 |
1033 wait_on_bit(&b->state, B_READING, do_io_schedule, TASK_UNINTERRUPTIBLE); | 1022 wait_on_bit_io(&b->state, B_READING, TASK_UNINTERRUPTIBLE); |
1034 1035 if (b->read_error) { 1036 int error = b->read_error; 1037 1038 dm_bufio_release(b); 1039 1040 return ERR_PTR(error); 1041 } --- 162 unchanged lines hidden (view full) --- 1204 1205 BUG_ON(test_bit(B_READING, &b->state)); 1206 1207 if (test_bit(B_WRITING, &b->state)) { 1208 if (buffers_processed < c->n_buffers[LIST_DIRTY]) { 1209 dropped_lock = 1; 1210 b->hold_count++; 1211 dm_bufio_unlock(c); | 1023 1024 if (b->read_error) { 1025 int error = b->read_error; 1026 1027 dm_bufio_release(b); 1028 1029 return ERR_PTR(error); 1030 } --- 162 unchanged lines hidden (view full) --- 1193 1194 BUG_ON(test_bit(B_READING, &b->state)); 1195 1196 if (test_bit(B_WRITING, &b->state)) { 1197 if (buffers_processed < c->n_buffers[LIST_DIRTY]) { 1198 dropped_lock = 1; 1199 b->hold_count++; 1200 dm_bufio_unlock(c); |
1212 wait_on_bit(&b->state, B_WRITING, 1213 do_io_schedule, 1214 TASK_UNINTERRUPTIBLE); | 1201 wait_on_bit_io(&b->state, B_WRITING, 1202 TASK_UNINTERRUPTIBLE); |
1215 dm_bufio_lock(c); 1216 b->hold_count--; 1217 } else | 1203 dm_bufio_lock(c); 1204 b->hold_count--; 1205 } else |
1218 wait_on_bit(&b->state, B_WRITING, 1219 do_io_schedule, 1220 TASK_UNINTERRUPTIBLE); | 1206 wait_on_bit_io(&b->state, B_WRITING, 1207 TASK_UNINTERRUPTIBLE); |
1221 } 1222 1223 if (!test_bit(B_DIRTY, &b->state) && 1224 !test_bit(B_WRITING, &b->state)) 1225 __relink_lru(b, LIST_CLEAN); 1226 1227 dm_bufio_cond_resched(); 1228 --- 87 unchanged lines hidden (view full) --- 1316 __free_buffer_wake(new); 1317 } 1318 1319 BUG_ON(!b->hold_count); 1320 BUG_ON(test_bit(B_READING, &b->state)); 1321 1322 __write_dirty_buffer(b, NULL); 1323 if (b->hold_count == 1) { | 1208 } 1209 1210 if (!test_bit(B_DIRTY, &b->state) && 1211 !test_bit(B_WRITING, &b->state)) 1212 __relink_lru(b, LIST_CLEAN); 1213 1214 dm_bufio_cond_resched(); 1215 --- 87 unchanged lines hidden (view full) --- 1303 __free_buffer_wake(new); 1304 } 1305 1306 BUG_ON(!b->hold_count); 1307 BUG_ON(test_bit(B_READING, &b->state)); 1308 1309 __write_dirty_buffer(b, NULL); 1310 if (b->hold_count == 1) { |
1324 wait_on_bit(&b->state, B_WRITING, 1325 do_io_schedule, TASK_UNINTERRUPTIBLE); | 1311 wait_on_bit_io(&b->state, B_WRITING, 1312 TASK_UNINTERRUPTIBLE); |
1326 set_bit(B_DIRTY, &b->state); 1327 __unlink_buffer(b); 1328 __link_buffer(b, new_block, LIST_DIRTY); 1329 } else { 1330 sector_t old_block; | 1313 set_bit(B_DIRTY, &b->state); 1314 __unlink_buffer(b); 1315 __link_buffer(b, new_block, LIST_DIRTY); 1316 } else { 1317 sector_t old_block; |
1331 wait_on_bit_lock(&b->state, B_WRITING, 1332 do_io_schedule, TASK_UNINTERRUPTIBLE); | 1318 wait_on_bit_lock_io(&b->state, B_WRITING, 1319 TASK_UNINTERRUPTIBLE); |
1333 /* 1334 * Relink buffer to "new_block" so that write_callback 1335 * sees "new_block" as a block number. 1336 * After the write, link the buffer back to old_block. 1337 * All this must be done in bufio lock, so that block number 1338 * change isn't visible to other threads. 1339 */ 1340 old_block = b->block; 1341 __unlink_buffer(b); 1342 __link_buffer(b, new_block, b->list_mode); 1343 submit_io(b, WRITE, new_block, write_endio); | 1320 /* 1321 * Relink buffer to "new_block" so that write_callback 1322 * sees "new_block" as a block number. 1323 * After the write, link the buffer back to old_block. 1324 * All this must be done in bufio lock, so that block number 1325 * change isn't visible to other threads. 1326 */ 1327 old_block = b->block; 1328 __unlink_buffer(b); 1329 __link_buffer(b, new_block, b->list_mode); 1330 submit_io(b, WRITE, new_block, write_endio); |
1344 wait_on_bit(&b->state, B_WRITING, 1345 do_io_schedule, TASK_UNINTERRUPTIBLE); | 1331 wait_on_bit_io(&b->state, B_WRITING, 1332 TASK_UNINTERRUPTIBLE); |
1346 __unlink_buffer(b); 1347 __link_buffer(b, old_block, b->list_mode); 1348 } 1349 1350 dm_bufio_unlock(c); 1351 dm_bufio_release(b); 1352} 1353EXPORT_SYMBOL_GPL(dm_bufio_release_move); --- 514 unchanged lines hidden --- | 1333 __unlink_buffer(b); 1334 __link_buffer(b, old_block, b->list_mode); 1335 } 1336 1337 dm_bufio_unlock(c); 1338 dm_bufio_release(b); 1339} 1340EXPORT_SYMBOL_GPL(dm_bufio_release_move); --- 514 unchanged lines hidden --- |