Skip to contentSkip to conversation

ext4: remove map_from_cluster from ext4_ext_map_blocks

PATCH Applied Eric Whitney 3 participants 3 messages Mar 11, 2020 – Mar 12, 2020 ext4 file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ext4: remove map_from_cluster from ext4_ext_map_blocks

We can use the variable allocated_clusters rather than map_from_clusters to control reserved block/cluster accounting in ext4_ext_map_blocks. This eliminates a variable and associated code and improves readability a little.

---
 fs/ext4/extents.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
fs/ext4/extents.c +1 -4
index bc96529d1509..b12c9e52746c 100644
@@ -4181,7 +4181,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 	unsigned int allocated_clusters = 0;
 	struct ext4_allocation_request ar;
 	ext4_lblk_t cluster_offset;
-	bool map_from_cluster = false;
 
 	ext_debug("blocks %u/%u requested for inode %lu\n",
 		  map->m_lblk, map->m_len, inode->i_ino);
@@ -4296,7 +4295,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 	    get_implied_cluster_alloc(inode->i_sb, map, ex, path)) {
 		ar.len = allocated = map->m_len;
 		newblock = map->m_pblk;
-		map_from_cluster = true;
 		goto got_allocated_blocks;
 	}
 
@@ -4317,7 +4315,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 	    get_implied_cluster_alloc(inode->i_sb, map, ex2, path)) {
 		ar.len = allocated = map->m_len;
 		newblock = map->m_pblk;
-		map_from_cluster = true;
 		goto got_allocated_blocks;
 	}
 
@@ -4418,7 +4415,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 	 * clusters discovered to be delayed allocated.  Once allocated, a
 	 * cluster is not included in the reserved count.
 	 */
-	if (test_opt(inode->i_sb, DELALLOC) && !map_from_cluster) {
+	if (test_opt(inode->i_sb, DELALLOC) && allocated_clusters) {
 		if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) {
 			/*
 			 * When allocating delayed allocated clusters, simply
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Eric Whitney

We can use the variable allocated_clusters rather than map_from_clusters to control reserved block/cluster accounting in ext4_ext_map_blocks. This eliminates a variable and associated code and improves readability a little.

No objections there.

Quoted 42 lines
---
  fs/ext4/extents.c | 5 +----
  1 file changed, 1 insertion(+), 4 deletions(-)
fs/ext4/extents.c +1 -4
index bc96529d1509..b12c9e52746c 100644
@@ -4181,7 +4181,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
  	unsigned int allocated_clusters = 0;
  	struct ext4_allocation_request ar;
  	ext4_lblk_t cluster_offset;
-	bool map_from_cluster = false;
 
  	ext_debug("blocks %u/%u requested for inode %lu\n",
  		  map->m_lblk, map->m_len, inode->i_ino);
@@ -4296,7 +4295,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
  	    get_implied_cluster_alloc(inode->i_sb, map, ex, path)) {
  		ar.len = allocated = map->m_len;
  		newblock = map->m_pblk;
-		map_from_cluster = true;
  		goto got_allocated_blocks;
  	}
 
@@ -4317,7 +4315,6 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
  	    get_implied_cluster_alloc(inode->i_sb, map, ex2, path)) {
  		ar.len = allocated = map->m_len;
  		newblock = map->m_pblk;
-		map_from_cluster = true;
  		goto got_allocated_blocks;
  	}
 
@@ -4418,7 +4415,7 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
  	 * clusters discovered to be delayed allocated.  Once allocated, a
  	 * cluster is not included in the reserved count.
  	 */
-	if (test_opt(inode->i_sb, DELALLOC) && !map_from_cluster) {
+	if (test_opt(inode->i_sb, DELALLOC) && allocated_clusters) {
  		if (flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE) {
  			/*
  			 * When allocating delayed allocated clusters, simply
maintainer Applied
#2 lore raw
In reply to Eric Whitney
Quoted 6 lines · Eric Whitney

We can use the variable allocated_clusters rather than map_from_clusters to control reserved block/cluster accounting in ext4_ext_map_blocks. This eliminates a variable and associated code and improves readability a little.

Applied, thanks.

- Ted