lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 14 Nov 2011 11:07:05 +0800
From:	Yongqiang Yang <xiaoqiangnk@...il.com>
To:	linux-ext4@...r.kernel.org
Cc:	tytso@....edu, Yongqiang Yang <xiaoqiangnk@...il.com>
Subject: [PATCH 1/2] ext4: teach ext4_ext_in_cache to return type of cached extent

This patch let ext4_ext_in_cache return the type of cached extent.
Now two kinds of cached extents are supported, they are delayed extent
and initialized extent respectively.

Signed-off-by: Yongqiang Yang <xiaoqiangnk@...il.com>
---
 fs/ext4/extents.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 61fa9e1..a99d123 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -2059,6 +2059,8 @@ errout:
 	return ret;
 }
 
+#define CACHE_EXTENT_HOLE		1
+#define CACHE_EXTENT_INITIALIZED	2
 /*
  * ext4_ext_in_cache()
  * Checks to see if the given block is in the cache.
@@ -2083,7 +2085,10 @@ ext4_ext_in_cache(struct inode *inode, ext4_lblk_t block,
 		ex->ee_block = cpu_to_le32(cex.ec_block);
 		ext4_ext_store_pblock(ex, cex.ec_start);
 		ex->ee_len = cpu_to_le16(cex.ec_len);
-		ret = 1;
+		if (cex.ec_start == 0)
+			ret = CACHE_EXTENT_HOLE;
+		else
+			ret = CACHE_EXTENT_INITIALIZED;
 	}
 
 	return ret;
@@ -3721,9 +3726,10 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 	trace_ext4_ext_map_blocks_enter(inode, map->m_lblk, map->m_len, flags);
 
 	/* check in cache */
-	if (!(flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT) &&
-		ext4_ext_in_cache(inode, map->m_lblk, &newex)) {
-		if (!newex.ee_start_lo && !newex.ee_start_hi) {
+	if (!(flags & EXT4_GET_BLOCKS_PUNCH_OUT_EXT)) {
+		ret = ext4_ext_in_cache(inode, map->m_lblk, &newex);
+		switch (ret) {
+		case CACHE_EXTENT_HOLE:
 			if ((sbi->s_cluster_ratio > 1) &&
 			    ext4_find_delalloc_cluster(inode, map->m_lblk, 0))
 				map->m_flags |= EXT4_MAP_FROM_CLUSTER;
@@ -3736,7 +3742,9 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
 				goto out2;
 			}
 			/* we should allocate requested block */
-		} else {
+			break;
+
+		case CACHE_EXTENT_INITIALIZED:
 			/* block is already allocated */
 			if (sbi->s_cluster_ratio > 1)
 				map->m_flags |= EXT4_MAP_FROM_CLUSTER;
-- 
1.7.5.1

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ