dm-buffered: fix flush REQ_SYNC was misunderstood - it doesn't indicate that the data should be flushed to the device, it indicates that the process that submitted the bio is waiting for it. Thus, we don't need to flush cache when REQ_SYNC is received. Also, set ti->num_flush_bios, so that flush requests are sent to the target. Signed-off-by: Mikulas Patocka --- drivers/md/dm-buffered-target.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) Index: linux-2.6/drivers/md/dm-buffered-target.c =================================================================== --- linux-2.6.orig/drivers/md/dm-buffered-target.c +++ linux-2.6/drivers/md/dm-buffered-target.c @@ -19,7 +19,7 @@ #define DEFAULT_BUFFERED_BLOCK_SIZE (SECTOR_SIZE << 3) /* 4KiB */ -enum stats { S_BUFFER_SPLITS, S_PREFLUSHS, S_FUA, S_SYNCS, S_READS, +enum stats { S_BUFFER_SPLITS, S_PREFLUSHS, S_FUA, S_READS, S_PREFETCHED_READS, S_PREFETCHED_WRITES, S_END, }; /* buffered target context */ @@ -236,9 +236,8 @@ static void __process_bio(struct buffere if (unlikely(bio->bi_status)) { goto err; - } else if (bio->bi_opf & (REQ_FUA | REQ_SYNC)) { - atomic_inc((bio->bi_opf & REQ_FUA) ? - &bc->stats[S_FUA] : &bc->stats[S_SYNCS]); + } else if (bio->bi_opf & REQ_FUA) { + atomic_inc(&bc->stats[S_FUA]); bio->bi_status = errno_to_blk_status(_buffered_flush(bc)); if (unlikely(bio->bi_status)) goto err; @@ -472,9 +471,10 @@ static int buffered_ctr(struct dm_target for (i = 0; i < ARRAY_SIZE(bc->stats); i++) atomic_set(&bc->stats[i], 0); - ti->flush_supported = 1; + ti->num_flush_bios = 1; + ti->flush_supported = true; ti->num_discard_bios = 1; - ti->discards_supported = 1; + ti->discards_supported = true; ti->num_write_zeroes_bios = bc->write_zeroes ? 1 : 0; return 0; bad: @@ -562,12 +562,11 @@ static void buffered_status(struct dm_ta DMEMIT(" %s", bc->write_zeroes ? "write_zeroes" : "no_write_zeroes"); break; case STATUSTYPE_INFO: - DMEMIT("%u %llu %u/%u/%u/%u/%u/%u/%u %llu", + DMEMIT("%u %llu %u/%u/%u/%u/%u/%u %llu", bc->buffer_size, (u64)n_buffers, atomic_read(&bc->stats[S_BUFFER_SPLITS]), atomic_read(&bc->stats[S_PREFLUSHS]), atomic_read(&bc->stats[S_FUA]), - atomic_read(&bc->stats[S_SYNCS]), atomic_read(&bc->stats[S_READS]), atomic_read(&bc->stats[S_PREFETCHED_READS]), atomic_read(&bc->stats[S_PREFETCHED_WRITES]),