From: Joe Thornber <[email-masked]>

Unlock the superblock even if initial dm_bufio_write_dirty_buffers fails.

Also, remove redundant flush calls.  dm_bm_flush_and_unlock's calls to
dm_bufio_write_dirty_buffers already result in dm_bufio_issue_flush
being called.

This avoids warnings about unflushed dirty buffers from bufio.
 
Signed-off-by: Joe Thornber <[email-masked]>
Signed-off-by: Mike Snitzer <[email-masked]>
Signed-off-by: Alasdair G Kergon <[email-masked]>

---
 drivers/md/persistent-data/dm-block-manager.c |   16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

Index: linux/drivers/md/persistent-data/dm-block-manager.c
===================================================================
--- linux.orig/drivers/md/persistent-data/dm-block-manager.c
+++ linux/drivers/md/persistent-data/dm-block-manager.c
@@ -587,22 +587,14 @@ int dm_bm_flush_and_unlock(struct dm_blo
 	int r;
 
 	r = dm_bufio_write_dirty_buffers(to_bufio(bm));
-	if (unlikely(r))
-		return r;
-	r = dm_bufio_issue_flush(to_bufio(bm));
-	if (unlikely(r))
+	if (unlikely(r)) {
+		dm_bm_unlock(superblock);
 		return r;
+	}
 
 	dm_bm_unlock(superblock);
 
-	r = dm_bufio_write_dirty_buffers(to_bufio(bm));
-	if (unlikely(r))
-		return r;
-	r = dm_bufio_issue_flush(to_bufio(bm));
-	if (unlikely(r))
-		return r;
-
-	return 0;
+	return dm_bufio_write_dirty_buffers(to_bufio(bm));
 }
 
 u32 dm_bm_checksum(const void *data, size_t len, u32 init_xor)