Skip to contentSkip to conversation

dm-thinp: fix REQ_FLUSH semantics

PATCH In review Christoph Hellwig 2 participants 3 messages Apr 27, 2011 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm-thinp: fix REQ_FLUSH semantics

REQ_FLUSH means the metadata needs to be flushed before the data payload (if there is one), not after it. And yes, this means the typical REQ_FUA|REQ_FLUSH requests imply two flushes.

drivers/md/dm-thin-prov.c +9 -1
Index: linux-2.6/drivers/md/dm-thin-prov.c
===================================================================
@@ -229,6 +229,14 @@ static void do_bios(struct thinp_c *tc,
 	block_t thinp_block, pool_block;
 
 	while ((bio = bio_list_pop(bios))) {
+		if (bio->bi_rw & REQ_FLUSH) {
+			r = commit(tc);
+			if (r < 0) {
+				bio_io_error(bio);
+				continue;
+			}
+		}
+
 		thinp_block = _sector_to_block(tc, bio->bi_sector);
 		r = thinp_metadata_lookup(tc->tpm, thinp_block, 1, &pool_block);
 		if (r == -ENODATA) {
@@ -258,7 +266,7 @@ static void do_bios(struct thinp_c *tc,
 			 * whether the overhead of tracking pending blocks
 			 * is worth it though.
 			 */
-			if ((bio->bi_rw & (REQ_FUA | REQ_FLUSH))) {
+			if (bio->bi_rw & REQ_FUA) {
 				r = commit(tc);
 				if (r < 0) {
 					bio_io_error(bio);
#1 lore raw
Quoted 3 lines · Christoph Hellwig

REQ_FLUSH means the metadata needs to be flushed before the data payload (if there is one), not after it. And yes, this means the typical REQ_FUA|REQ_FLUSH requests imply two flushes.

Not sure what you're getting at here. The bio wasn't issued until after the commit.

			if ((bio->bi_rw & (REQ_FUA | REQ_FLUSH))) {
				r = commit(tc);
				if (r < 0) {
					bio_io_error(bio);
					continue;
				}
			}

			remap_bio(tc, bio, pool_block);
			generic_make_request(bio);

- Joe

Quoted 31 lines

Index: linux-2.6/drivers/md/dm-thin-prov.c
===================================================================

drivers/md/dm-thin-prov.c +9 -1
@@ -229,6 +229,14 @@ static void do_bios(struct thinp_c *tc,
 	block_t thinp_block, pool_block;
 
 	while ((bio = bio_list_pop(bios))) {
+		if (bio->bi_rw & REQ_FLUSH) {
+			r = commit(tc);
+			if (r < 0) {
+				bio_io_error(bio);
+				continue;
+			}
+		}
+
 		thinp_block = _sector_to_block(tc, bio->bi_sector);
 		r = thinp_metadata_lookup(tc->tpm, thinp_block, 1, &pool_block);
 		if (r == -ENODATA) {
@@ -258,7 +266,7 @@ static void do_bios(struct thinp_c *tc,
 			 * whether the overhead of tracking pending blocks
 			 * is worth it though.
 			 */
-			if ((bio->bi_rw & (REQ_FUA | REQ_FLUSH))) {
+			if (bio->bi_rw & REQ_FUA) {
 				r = commit(tc);
 				if (r < 0) {
 					bio_io_error(bio);
#2 lore raw
Quoted 8 lines · Joe Thornber
Quoted 3 lines · Christoph Hellwig

REQ_FLUSH means the metadata needs to be flushed before the data payload (if there is one), not after it. And yes, this means the typical REQ_FUA|REQ_FLUSH requests imply two flushes.

Not sure what you're getting at here. The bio wasn't issued until after the commit.

Quoted 10 lines
			if ((bio->bi_rw & (REQ_FUA | REQ_FLUSH))) {
				r = commit(tc);
				if (r < 0) {
					bio_io_error(bio);
					continue;
				}
			}

			remap_bio(tc, bio, pool_block);
			generic_make_request(bio);

Indeed. Given that the metadata is on-disk and doesn't change by doing I/O to the newly mapped block always doing it before the I/O to the underlying device is fine. I thus retract this patch.