Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dm kcopyd: avoid useless atomic operations

The functions set_bit and clear_bit are atomic. We don't need
atomicity when making flags for dm-kcopyd. So, change them to direct
manipulation of the flags.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

authored by

Mikulas Patocka and committed by
Mike Snitzer
db2351eb 6b06dd5a

+12 -12
+10 -10
drivers/md/dm-kcopyd.c
··· 341 341 struct kcopyd_job { 342 342 struct dm_kcopyd_client *kc; 343 343 struct list_head list; 344 - unsigned long flags; 344 + unsigned flags; 345 345 346 346 /* 347 347 * Error state of the job. ··· 418 418 * constraint and sequential writes that are at the right position. 419 419 */ 420 420 list_for_each_entry(job, jobs, list) { 421 - if (job->rw == READ || !test_bit(DM_KCOPYD_WRITE_SEQ, &job->flags)) { 421 + if (job->rw == READ || !(job->flags & BIT(DM_KCOPYD_WRITE_SEQ))) { 422 422 list_del(&job->list); 423 423 return job; 424 424 } ··· 525 525 else 526 526 job->read_err = 1; 527 527 528 - if (!test_bit(DM_KCOPYD_IGNORE_ERROR, &job->flags)) { 528 + if (!(job->flags & BIT(DM_KCOPYD_IGNORE_ERROR))) { 529 529 push(&kc->complete_jobs, job); 530 530 wake(kc); 531 531 return; ··· 565 565 * If we need to write sequentially and some reads or writes failed, 566 566 * no point in continuing. 567 567 */ 568 - if (test_bit(DM_KCOPYD_WRITE_SEQ, &job->flags) && 568 + if (job->flags & BIT(DM_KCOPYD_WRITE_SEQ) && 569 569 job->master_job->write_err) { 570 570 job->write_err = job->master_job->write_err; 571 571 return -EIO; ··· 709 709 * Only dispatch more work if there hasn't been an error. 710 710 */ 711 711 if ((!job->read_err && !job->write_err) || 712 - test_bit(DM_KCOPYD_IGNORE_ERROR, &job->flags)) { 712 + job->flags & BIT(DM_KCOPYD_IGNORE_ERROR)) { 713 713 /* get the next chunk of work */ 714 714 progress = job->progress; 715 715 count = job->source.count - progress; ··· 801 801 * we need to write sequentially. If one of the destination is a 802 802 * host-aware device, then leave it to the caller to choose what to do. 803 803 */ 804 - if (!test_bit(DM_KCOPYD_WRITE_SEQ, &job->flags)) { 804 + if (!(job->flags & BIT(DM_KCOPYD_WRITE_SEQ))) { 805 805 for (i = 0; i < job->num_dests; i++) { 806 806 if (bdev_zoned_model(dests[i].bdev) == BLK_ZONED_HM) { 807 - set_bit(DM_KCOPYD_WRITE_SEQ, &job->flags); 807 + job->flags |= BIT(DM_KCOPYD_WRITE_SEQ); 808 808 break; 809 809 } 810 810 } ··· 813 813 /* 814 814 * If we need to write sequentially, errors cannot be ignored. 815 815 */ 816 - if (test_bit(DM_KCOPYD_WRITE_SEQ, &job->flags) && 817 - test_bit(DM_KCOPYD_IGNORE_ERROR, &job->flags)) 818 - clear_bit(DM_KCOPYD_IGNORE_ERROR, &job->flags); 816 + if (job->flags & BIT(DM_KCOPYD_WRITE_SEQ) && 817 + job->flags & BIT(DM_KCOPYD_IGNORE_ERROR)) 818 + job->flags &= ~BIT(DM_KCOPYD_IGNORE_ERROR); 819 819 820 820 if (from) { 821 821 job->source = *from;
+1 -1
drivers/md/dm-raid1.c
··· 364 364 365 365 /* hand to kcopyd */ 366 366 if (!errors_handled(ms)) 367 - set_bit(DM_KCOPYD_IGNORE_ERROR, &flags); 367 + flags |= BIT(DM_KCOPYD_IGNORE_ERROR); 368 368 369 369 dm_kcopyd_copy(ms->kcopyd_client, &from, ms->nr_mirrors - 1, to, 370 370 flags, recovery_complete, reg);
+1 -1
drivers/md/dm-zoned-reclaim.c
··· 134 134 dst_zone_block = dmz_start_block(zmd, dst_zone); 135 135 136 136 if (dmz_is_seq(dst_zone)) 137 - set_bit(DM_KCOPYD_WRITE_SEQ, &flags); 137 + flags |= BIT(DM_KCOPYD_WRITE_SEQ); 138 138 139 139 while (block < end_block) { 140 140 if (src_zone->dev->flags & DMZ_BDEV_DYING)