Skip to contentSkip to conversation

reiser4: block deallocation fixes.

RFC PATCH In review Ivan Shapovalov 2 participants 8 messages Sep 8, 2014

lore
Share & tools
lore
#0 lore raw

v2 cover reiser4: block deallocation fixes.

Actually, the idea of converting immediate allocations into deferred when discard is enabled was flawed. Deferred deallocations ignore block stage and additional flags, while some immediate deallocations use non-standard stage/flags which do not match what's done by reiser4_post_write_back_hook().

While at it, I've removed specifications of block stage in deferred deallocations. It is not used anyway. This is first commit.

Next commit does the following. Actually, most of the immediate deallocations do not need to be considered for discarding: these are deallocations done in error paths, and respective blocks are never written between their allocation and deallocation. Two exceptions are deallocations in wandering log code. In these cases, blocks are allocated, then written, then deallocated without BA_DEFER. I've just made these deallocations explicitly deferred, which is OK because they have a suitable block stage.

Last commit actually removes wrong code, again making immediate deallocations always immediate.

Ivan Shapovalov (3):
reiser4: deferred (BA_DEFER) deallocations do not make use of target stage.
reiser4: mark final deallocations in wandering log code as deferred.
reiser4: block_alloc: get rid of discard-related hack in reiser4_dealloc_blocks().

 fs/reiser4/block_alloc.c  |  9 +++++++--
 fs/reiser4/plugin/txmod.c | 15 +++++----------
 fs/reiser4/wander.c       |  6 +++---
 3 files changed, 15 insertions(+), 15 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

RFC PATCH v2 1/3 reiser4: deferred (BA_DEFER) deallocations do not make use of target stage.

...so remove it (set to 0) in all cases to avoid confusion.

---
 fs/reiser4/block_alloc.c  |  6 ++++++
 fs/reiser4/plugin/txmod.c | 15 +++++----------
 2 files changed, 11 insertions(+), 10 deletions(-)
fs/reiser4/block_alloc.c +6 -0
index 324b11c..6e7030a 100644
@@ -1010,6 +1010,12 @@ reiser4_dealloc_blocks(const reiser4_block_nr * start,
 
 	if ((flags & BA_DEFER) ||
 	    reiser4_is_set(reiser4_get_current_sb(), REISER4_DISCARD)) {
+		/*
+		 * These blocks will be later deallocated by apply_dset().
+		 * It is equivalent to a non-deferred deallocation with target
+		 * stage BLOCK_NOT_COUNTED.
+		 */
+
 		/* store deleted block numbers in the atom's deferred delete set
 		   for further actual deletion */
 		do {
fs/reiser4/plugin/txmod.c +5 -10
index 63d461f..5982b4c 100644
@@ -287,8 +287,7 @@ static int forward_relocate_unformatted(flush_pos_t *flush_pos,
 		 * on relocating - free nodes which are going to be
 		 * relocated
 		 */
-		reiser4_dealloc_blocks(&start, &allocated,
-				       BLOCK_ALLOCATED, BA_DEFER);
+		reiser4_dealloc_blocks(&start, &allocated, 0, BA_DEFER);
 
 	/* assign new block numbers to protected nodes */
 	assign_real_blocknrs(flush_pos, oid, index, allocated, first_allocated);
@@ -386,16 +385,13 @@ static squeeze_result squeeze_relocate_unformatted(znode *left,
 	result = put_unit_to_end(left, key, &copy_extent);
 
 	if (result == -E_NODE_FULL) {
-		int target_block_stage;
 		/*
 		 * free blocks which were just allocated
 		 */
-		target_block_stage =
-			(state ==
-			 ALLOCATED_EXTENT) ? BLOCK_FLUSH_RESERVED :
-			BLOCK_UNALLOCATED;
 		reiser4_dealloc_blocks(&first_allocated, &allocated,
-				       target_block_stage,
+				       (state == ALLOCATED_EXTENT)
+				       ? BLOCK_FLUSH_RESERVED
+				       : BLOCK_UNALLOCATED,
 				       BA_PERMANENT);
 		/*
 		 * rewind the preceder
@@ -408,8 +404,7 @@ static squeeze_result squeeze_relocate_unformatted(znode *left,
 		/*
 		 * free nodes which were relocated
 		 */
-		reiser4_dealloc_blocks(&start, &allocated,
-				       BLOCK_ALLOCATED, BA_DEFER);
+		reiser4_dealloc_blocks(&start, &allocated, 0, BA_DEFER);
 	}
 	/*
 	 * assign new block numbers to protected nodes
Signature · 1 line
2.1.0
#2 lore raw

RFC PATCH v2 2/3 reiser4: mark final deallocations in wandering log code as deferred.

In reply to Ivan Shapovalov

Now there is a clear semantic distinction between deferred and immediate deallocations. Deferred mode is used to deallocate blocks that were previously written, immediate mode is used to deallocate "just allocated" blocks in error paths or if some previously allocated blocks turn out to be unneeded.

This way, we may get rid of discard-related hack in the deallocation routine, i. e. treating immediate deallocations as deferred (which messes up block accounting). This is done in the next commit.

---
 fs/reiser4/wander.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
fs/reiser4/wander.c +3 -3
index 04ddec6..fd5954a 100644
@@ -482,8 +482,8 @@ static void dealloc_tx_list(struct commit_handle *ch)
 		jnode *cur = list_entry(ch->tx_list.next, jnode, capture_link);
 		list_del(&cur->capture_link);
 		ON_DEBUG(INIT_LIST_HEAD(&cur->capture_link));
-		reiser4_dealloc_block(jnode_get_block(cur), BLOCK_NOT_COUNTED,
-				      BA_FORMATTED);
+		reiser4_dealloc_block(jnode_get_block(cur), 0,
+				      BA_DEFER | BA_FORMATTED);
 
 		unpin_jnode_data(cur);
 		reiser4_drop_io_head(cur);
@@ -502,7 +502,7 @@ dealloc_wmap_actor(txn_atom * atom UNUSED_ARG,
 	assert("zam-500", *b != 0);
 	assert("zam-501", !reiser4_blocknr_is_fake(b));
 
-	reiser4_dealloc_block(b, BLOCK_NOT_COUNTED, BA_FORMATTED);
+	reiser4_dealloc_block(b, 0, BA_DEFER | BA_FORMATTED);
 	return 0;
 }
 
Signature · 1 line
2.1.0
#3 lore raw

RFC PATCH v2 3/3 reiser4: block_alloc: get rid of discard-related hack in reiser4_dealloc_blocks().

In reply to Ivan Shapovalov

When discard was enabled, immediate deallocations were made deferred in order to record these extents in the atom's delete set and, consequently, allow their discarding.

However, this is wrong in the following way. Immediate deallocations make use of target allocation stage and ancillary flags like BA_PERMANENT and BA_FORMATTED. By converting immediate deallocations to deferred, these flags are essentially dropped, and application of deferred deallocations in reiser4_post_write_back_hook() uses an equivalent of BLOCK_NOT_COUNTED stage and BA_FORMATTED flag.

Dropping this hack does not hinder efficiency of the discard procedure, because immediate deallocations are now used only to deallocate "just allocated" and not yet written blocks, which actually do not need to be discarded.

---
 fs/reiser4/block_alloc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/reiser4/block_alloc.c +1 -2
index 6e7030a..fee1c18 100644
@@ -1008,8 +1008,7 @@ reiser4_dealloc_blocks(const reiser4_block_nr * start,
 		spin_unlock_reiser4_super(sbinfo);
 	}
 
-	if ((flags & BA_DEFER) ||
-	    reiser4_is_set(reiser4_get_current_sb(), REISER4_DISCARD)) {
+	if (flags & BA_DEFER) {
 		/*
 		 * These blocks will be later deallocated by apply_dset().
 		 * It is equivalent to a non-deferred deallocation with target
Signature · 1 line
2.1.0
#4 lore raw
In reply to Ivan Shapovalov

Ok, I'll include this to the 3.15.2-reiser4-basic-discard-support.patch

As to 3.16: unfortunately the ancient bug, which leads to non-deleted directories raised the head in 3.16. I don't want to release buggy stuff. So let's work around the stable 3.15 for now..

Thanks,
Edward.

Quoted 29 lines · Ivan Shapovalov

Actually, the idea of converting immediate allocations into deferred when discard is enabled was flawed. Deferred deallocations ignore block stage and additional flags, while some immediate deallocations use non-standard stage/flags which do not match what's done by reiser4_post_write_back_hook().

While at it, I've removed specifications of block stage in deferred deallocations. It is not used anyway. This is first commit.

Next commit does the following. Actually, most of the immediate deallocations do not need to be considered for discarding: these are deallocations done in error paths, and respective blocks are never written between their allocation and deallocation. Two exceptions are deallocations in wandering log code. In these cases, blocks are allocated, then written, then deallocated without BA_DEFER. I've just made these deallocations explicitly deferred, which is OK because they have a suitable block stage.

Last commit actually removes wrong code, again making immediate deallocations always immediate.

Ivan Shapovalov (3):
reiser4: deferred (BA_DEFER) deallocations do not make use of target stage.
reiser4: mark final deallocations in wandering log code as deferred.
reiser4: block_alloc: get rid of discard-related hack in reiser4_dealloc_blocks().

  fs/reiser4/block_alloc.c  |  9 +++++++--
  fs/reiser4/plugin/txmod.c | 15 +++++----------
  fs/reiser4/wander.c       |  6 +++---
  3 files changed, 15 insertions(+), 15 deletions(-)
#5 lore raw
Quoted 1 line · Edward Shishkin

Ok, I'll include this to the 3.15.2-reiser4-basic-discard-support.patch

Good, at least this is done...

Quoted 4 lines

As to 3.16: unfortunately the ancient bug, which leads to non-deleted directories raised the head in 3.16. I don't want to release buggy stuff. So let's work around the stable 3.15 for now..

Uhm, what relation does that bug have to 3.16? Does it manifest itself more often?

Signature · 1 line
Ivan Shapovalov / intelfx /
#6 lore raw
Quoted 8 lines · Ivan Shapovalov
Quoted 1 line · Edward Shishkin

Ok, I'll include this to the 3.15.2-reiser4-basic-discard-support.patch

Good, at least this is done...

Quoted 3 lines

As to 3.16: unfortunately the ancient bug, which leads to non-deleted directories raised the head in 3.16. I don't want to release buggy stuff. So let's work around the stable 3.15 for now..

Uhm, what relation does that bug have to 3.16? Does it manifest itself more often?

I can reproduce it in 3.10, 3.16.
I can not in 3.11 - 3.15..

#7 lore raw
Quoted 6 lines · Edward Shishkin

[..]

Quoted 1 line

Uhm, what relation does that bug have to 3.16? Does it manifest itself more often?

I can reproduce it in 3.10, 3.16.
I can not in 3.11 - 3.15..

Hm. Never encountered such bug.

That said, do you have any plans on fixing that? ;) Or will we just sit with 3.15 and wait for a kernel when it suddenly stops appearing?

Signature · 1 line
Ivan Shapovalov / intelfx /