summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/jffs2/src/readinode.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* jffs2: Fix GC exit abnormallyZhe Li2023-01-121-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The log of this problem is: jffs2: Error garbage collecting node at 0x***! jffs2: No space for garbage collection. Aborting GC thread This is because GC believe that it do nothing, so it abort. After going over the image of jffs2, I find a scene that can trigger this problem stably. The scene is: there is a normal dirent node at summary-area, but abnormal at corresponding not-summary-area with error name_crc. The reason that GC exit abnormally is because it find that abnormal dirent node to GC, but when it goes to function jffs2_add_fd_to_list, it cannot meet the condition listed below: if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) So no node is marked obsolete, statistical information of erase_block do not change, which cause GC exit abnormally. The root cause of this problem is: we do not check the name_crc of the abnormal dirent node with summary is enabled. Noticed that in function jffs2_scan_dirent_node, we use function jffs2_scan_dirty_space to deal with the dirent node with error name_crc. So this patch add a checking code in function read_direntry to ensure the correctness of dirent node. If checked failed, the dirent node will be marked obsolete so GC will pass this node and this problem will be fixed. Cc: <stable@vger.kernel.org> Signed-off-by: Zhe Li <lizhe67@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
* treewide: Use fallthrough pseudo-keywordGustavo A. R. Silva2022-06-201-1/+1
| | | | | | | | | | Replace the existing /* fall through */ comments and its variants with the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary fall-through markings when it is the case. [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
* jffs2: fix use-after-free on symlink traversalAl Viro2022-06-201-1/+2
| | | | | | | | free the symlink body after the same RCU delay we have for freeing the struct inode itself, so that traversal during RCU pathwalk wouldn't step into freed memory. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
* jffs2: Avoid use of constant register variableSebastian Huber2018-10-051-0/+12
| | | | | Avoid the use of a constant register variable which is used in some conditions. This gets rid of a clang -Wsometimes-uninitialized warning.
* jffs2: fix spelling mistake: "requestied" -> "requested"Colin Ian King2018-07-161-1/+1
| | | | | | | | trivial fix to spelling mistake in JFFS2_ERROR message Signed-off-by: Colin Ian King <colin.king@canonical.com> [Brian: also fix 'an' -> 'a'] Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* vfs: make the string hashes salt the hashLinus Torvalds2018-07-161-1/+1
| | | | | | | | | | | | | | | | | | We always mixed in the parent pointer into the dentry name hash, but we did it late at lookup time. It turns out that we can simplify that lookup-time action by salting the hash with the parent pointer early instead of late. A few other users of our string hashes also wanted to mix in their own pointers into the hash, and those are updated to use the same mechanism. Hash users that don't have any particular initial salt can just use the NULL pointer as a no-salt. Cc: Vegard Nossum <vegard.nossum@oracle.com> Cc: George Spelvin <linux@sciencehorizons.net> Cc: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* jffs2: fix a memleak in read_direntry()Wei Fang2018-07-161-1/+5
| | | | | | | | Need to free the memory allocated for 'fd' if failed to read all of the remainder name. Signed-off-by: Wei Fang <fangwei1@huawei.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* jffs2: fix unbalanced lockingBrian Norris2018-07-161-23/+4
| | | | | | | | | | | | | | | | | | | Li Zefan reported an unbalanced locking issue, found by his internal debugging feature on runtime. The particular case he was looking at doesn't lead to a deadlock, as the structure that this lock is embedded in is freed on error. But we should straighten out the error handling. Because several callers of jffs2_do_read_inode_internal() / jffs2_do_read_inode() already handle the locking/unlocking and inode clearing at their own level, let's just push any unlocks/clearing down to the caller. This consistency is much easier to verify. Reported-by: Li Zefan <lizefan@huawei.com> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* jffs2: Drop bogus if in commentGeert Uytterhoeven2018-07-161-1/+1
| | | | | | | Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Cc: David Woodhouse <dwmw2@infradead.org> Cc: linux-mtd@lists.infradead.org Signed-off-by: Brian Norris <computersforpeace@gmail.com>
* fs/jffs2: use rbtree postorder iteration helper instead of opencodingCody P Schafer2018-07-161-23/+3
| | | | | | | | | | | | Use rbtree_postorder_for_each_entry_safe() to destroy the rbtree instead of opencoding an alternate postorder iteration that modifies the tree Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com> Cc: Michel Lespinasse <walken@google.com> Cc: Jan Kara <jack@suse.cz> Cc: David Woodhouse <dwmw2@infradead.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
* linux: Simplify <linux/rbtree.h>Sebastian Huber2018-07-161-2/+2
| | | | | | | Remove the placeholder struct rb_node and use RBTree_Node directly via some C pre-processor defines to adjust the member names. Update #3465.
* jffs2: Do not use command line definesSebastian Huber2018-04-301-0/+2
| | | | Update #3375.
* JFFS2: Add RTEMS supportSebastian Huber2013-09-191-0/+7
|
* JFFS2: Import from LinuxSebastian Huber2013-09-191-0/+1471
Import of Journalling Flash File System, Version 2 from Linux 3.11. This part of the Linux kernel is under a separate license which is similar to the RTEMS license. The file "cpukit/libfs/src/jffs2/include/linux/jffs2.h" is a copy of "linux-3.11/include/uapi/linux/jffs2.h". The file "LICENSE.JFFS2" is a copy of "linux-3.11/fs/jffs2/LICENCE". The files "linux-3.11/fs/jffs2/LICENCE", "linux-3.11/fs/jffs2/acl.h", "linux-3.11/fs/jffs2/build.c", "linux-3.11/fs/jffs2/compr.c", "linux-3.11/fs/jffs2/compr.h", "linux-3.11/fs/jffs2/compr_rtime.c", "linux-3.11/fs/jffs2/compr_rubin.c", "linux-3.11/fs/jffs2/compr_zlib.c", "linux-3.11/fs/jffs2/debug.c", "linux-3.11/fs/jffs2/debug.h", "linux-3.11/fs/jffs2/erase.c", "linux-3.11/fs/jffs2/gc.c", "linux-3.11/fs/jffs2/jffs2_fs_i.h", "linux-3.11/fs/jffs2/jffs2_fs_sb.h", "linux-3.11/fs/jffs2/nodelist.c", "linux-3.11/fs/jffs2/nodelist.h", "linux-3.11/fs/jffs2/nodemgmt.c", "linux-3.11/fs/jffs2/read.c", "linux-3.11/fs/jffs2/readinode.c", "linux-3.11/fs/jffs2/scan.c", "linux-3.11/fs/jffs2/summary.h", "linux-3.11/fs/jffs2/write.c", and "linux-3.11/fs/jffs2/xattr.h" are copied to "cpukit/libfs/src/jffs2/src".