diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index f06b51d..39e8b4a 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -10879,19 +10879,35 @@ CancelBackup(void)
 {
 	struct stat stat_buf;
 
-	/* if the file is not there, return */
-	if (stat(BACKUP_LABEL_FILE, &stat_buf) < 0)
+	/* if the backup_label or tablespace_map file is not there, return */
+	if (stat(BACKUP_LABEL_FILE, &stat_buf) < 0 ||
+		stat(TABLESPACE_MAP, &stat_buf) < 0)
 		return;
 
-	/* remove leftover file from previously canceled backup if it exists */
+	/* remove leftover files from previously canceled backup if it exists */
 	unlink(BACKUP_LABEL_OLD);
+	unlink(TABLESPACE_MAP_OLD);
 
 	if (rename(BACKUP_LABEL_FILE, BACKUP_LABEL_OLD) == 0)
 	{
-		ereport(LOG,
-				(errmsg("online backup mode canceled"),
-				 errdetail("\"%s\" was renamed to \"%s\".",
-						   BACKUP_LABEL_FILE, BACKUP_LABEL_OLD)));
+		if (rename(TABLESPACE_MAP, TABLESPACE_MAP_OLD) == 0)
+		{
+			ereport(LOG,
+					(errmsg("online backup mode canceled"),
+					 errdetail("\"%s\" was renamed to \"%s\" and"
+							   " \"%s\" was renamed to \"%s\".",
+							   BACKUP_LABEL_FILE, BACKUP_LABEL_OLD,
+							   TABLESPACE_MAP, TABLESPACE_MAP_OLD)));
+		}
+		else
+		{
+			ereport(WARNING,
+					(errcode_for_file_access(),
+					 errmsg("online backup mode was not canceled"),
+					 errdetail("Could not rename \"%s\" to \"%s\": %m.",
+							   TABLESPACE_MAP, TABLESPACE_MAP_OLD)));
+		}
+		
 	}
 	else
 	{
@@ -10901,29 +10917,6 @@ CancelBackup(void)
 				 errdetail("Could not rename \"%s\" to \"%s\": %m.",
 						   BACKUP_LABEL_FILE, BACKUP_LABEL_OLD)));
 	}
-
-	/* if the tablespace_map file is not there, return */
-	if (stat(TABLESPACE_MAP, &stat_buf) < 0)
-		return;
-
-	/* remove leftover file from previously canceled backup if it exists */
-	unlink(TABLESPACE_MAP_OLD);
-
-	if (rename(TABLESPACE_MAP, TABLESPACE_MAP_OLD) == 0)
-	{
-		ereport(LOG,
-				(errmsg("online backup mode canceled"),
-				 errdetail("\"%s\" was renamed to \"%s\".",
-						   TABLESPACE_MAP, TABLESPACE_MAP_OLD)));
-	}
-	else
-	{
-		ereport(WARNING,
-				(errcode_for_file_access(),
-				 errmsg("online backup mode was not canceled"),
-				 errdetail("Could not rename \"%s\" to \"%s\": %m.",
-						   TABLESPACE_MAP, TABLESPACE_MAP_OLD)));
-	}
 }
 
 /*
