summaryrefslogtreecommitdiff
path: root/meta/recipes-devtools/e2fsprogs/e2fsprogs-1.42.8/fix-icache.patch
blob: ad4e3439f4e6cd05835bde8d39249e167c872001 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
inode.c: only update the icache for ext2_inode

We only read the cache when:

bufsize == sizeof(struct ext2_inode)

then we should only update the cache in the same condition, otherwise
there would be errors, for example:

cache[0]: cached ino 14 when bufsize = 128 by ext2fs_write_inode_full()
cache[1]: cached ino 14 when bufsize = 156 by ext2fs_read_inode_full()

Then update the cache:
cache[0]: cached ino 15 when bufsize = 156 by ext2fs_read_inode_full()

Then the ino 14 would hit the cache[1] when bufsize = 128 (but it was
cached by bufsize = 156), so there would be errors.

Note: the upstream has changed the icache lot, so this patch is
inappropriate for the upstream, we can drop this patch when we update
the package.

Upstream-Status: [Inappropriate]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 lib/ext2fs/inode.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/lib/ext2fs/inode.c b/lib/ext2fs/inode.c
--- a/lib/ext2fs/inode.c
+++ b/lib/ext2fs/inode.c
@@ -612,10 +612,12 @@ errcode_t ext2fs_read_inode_full(ext2_filsys fs, ext2_ino_t ino,
 #endif
 
 	/* Update the inode cache */
-	fs->icache->cache_last = (fs->icache->cache_last + 1) %
-		fs->icache->cache_size;
-	fs->icache->cache[fs->icache->cache_last].ino = ino;
-	fs->icache->cache[fs->icache->cache_last].inode = *inode;
+	if (bufsize == sizeof(struct ext2_inode)) {
+		fs->icache->cache_last = (fs->icache->cache_last + 1) %
+			fs->icache->cache_size;
+		fs->icache->cache[fs->icache->cache_last].ino = ino;
+		fs->icache->cache[fs->icache->cache_last].inode = *inode;
+	}
 
 	return 0;
 }
@@ -648,10 +650,12 @@ errcode_t ext2fs_write_inode_full(ext2_filsys fs, ext2_ino_t ino,
 
 	/* Check to see if the inode cache needs to be updated */
 	if (fs->icache) {
-		for (i=0; i < fs->icache->cache_size; i++) {
-			if (fs->icache->cache[i].ino == ino) {
-				fs->icache->cache[i].inode = *inode;
-				break;
+		if (bufsize == sizeof(struct ext2_inode)) {
+			for (i=0; i < fs->icache->cache_size; i++) {
+				if (fs->icache->cache[i].ino == ino) {
+					fs->icache->cache[i].inode = *inode;
+					break;
+				}
 			}
 		}
 	} else {
-- 
1.8.1.2