All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luo Meng <luomeng12@huawei.com>
To: <agk@redhat.com>, <snitzer@redhat.com>, <dm-devel@redhat.com>,
	<ejt@redhat.com>
Cc: luomeng12@huawei.com, yukuai3@huawei.com
Subject: [dm-devel] [PTACH] Revert "dm space maps: don't reset space map allocation cursor when committing"
Date: Mon, 28 Feb 2022 22:13:54 +0800	[thread overview]
Message-ID: <20220228141354.1091687-1-luomeng12@huawei.com> (raw)

This reverts commit 5faafc77f7de69147d1e818026b9a0cbf036a7b2.

This commit 5faafc77f7de ("dm space maps: don't reset space map allocation
cursor when committing") change the way to find free block.

But when use ramdisk(not support discard) for thin-pool,and storage
over-commitment. Then constantly create and delete file, can find block
in thin-pool, but can't find block in ramdisk.

So need revert this patch.

Fixes: 5faafc77f7de ("dm space maps: don't reset space map allocation cursor when committing")
Signed-off-by: Luo Meng <luomeng12@huawei.com>
---
 drivers/md/persistent-data/dm-space-map-disk.c     | 9 +--------
 drivers/md/persistent-data/dm-space-map-metadata.c | 9 +--------
 2 files changed, 2 insertions(+), 16 deletions(-)

diff --git a/drivers/md/persistent-data/dm-space-map-disk.c b/drivers/md/persistent-data/dm-space-map-disk.c
index d0a8d5e73c28..17afbebd9244 100644
--- a/drivers/md/persistent-data/dm-space-map-disk.c
+++ b/drivers/md/persistent-data/dm-space-map-disk.c
@@ -134,14 +134,6 @@ static int sm_disk_new_block(struct dm_space_map *sm, dm_block_t *b)
 	 * Any block we allocate has to be free in both the old and current ll.
 	 */
 	r = sm_ll_find_common_free_block(&smd->old_ll, &smd->ll, smd->begin, smd->ll.nr_blocks, b);
-	if (r == -ENOSPC) {
-		/*
-		 * There's no free block between smd->begin and the end of the metadata device.
-		 * We search before smd->begin in case something has been freed.
-		 */
-		r = sm_ll_find_common_free_block(&smd->old_ll, &smd->ll, 0, smd->begin, b);
-	}
-
 	if (r)
 		return r;
 
@@ -164,6 +156,7 @@ static int sm_disk_commit(struct dm_space_map *sm)
 		return r;
 
 	memcpy(&smd->old_ll, &smd->ll, sizeof(smd->old_ll));
+	smd->begin = 0;
 	smd->nr_allocated_this_transaction = 0;
 
 	return 0;
diff --git a/drivers/md/persistent-data/dm-space-map-metadata.c b/drivers/md/persistent-data/dm-space-map-metadata.c
index 392ae26134a4..42920e930dbd 100644
--- a/drivers/md/persistent-data/dm-space-map-metadata.c
+++ b/drivers/md/persistent-data/dm-space-map-metadata.c
@@ -453,14 +453,6 @@ static int sm_metadata_new_block_(struct dm_space_map *sm, dm_block_t *b)
 	 * Any block we allocate has to be free in both the old and current ll.
 	 */
 	r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, smm->begin, smm->ll.nr_blocks, b);
-	if (r == -ENOSPC) {
-		/*
-		 * There's no free block between smm->begin and the end of the metadata device.
-		 * We search before smm->begin in case something has been freed.
-		 */
-		r = sm_ll_find_common_free_block(&smm->old_ll, &smm->ll, 0, smm->begin, b);
-	}
-
 	if (r)
 		return r;
 
@@ -512,6 +504,7 @@ static int sm_metadata_commit(struct dm_space_map *sm)
 		return r;
 
 	memcpy(&smm->old_ll, &smm->ll, sizeof(smm->old_ll));
+	smm->begin = 0;
 	smm->allocated_this_transaction = 0;
 
 	return 0;
-- 
2.31.1


--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


             reply	other threads:[~2022-03-01  7:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-28 14:13 Luo Meng [this message]
2022-02-28 15:37 ` [dm-devel] Revert "dm space maps: don't reset space map allocation cursor when committing" Mike Snitzer
2022-03-01 14:07   ` luomeng
2022-03-01 16:06     ` Edward Thornber
2022-03-08  4:03       ` luomeng

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220228141354.1091687-1-luomeng12@huawei.com \
    --to=luomeng12@huawei.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=ejt@redhat.com \
    --cc=snitzer@redhat.com \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.