[PATCH 23/29] vfs: make the string hashes salt the hash

2018-07-05 Thread Sebastian Huber
From: Linus Torvalds 

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 
Cc: George Spelvin 
Cc: Al Viro 
Signed-off-by: Linus Torvalds 

1   1   cpukit/libfs/src/jffs2/src/dir-rtems.c
2   1   cpukit/libfs/src/jffs2/src/os-rtems.h
1   1   cpukit/libfs/src/jffs2/src/readinode.c
1   1   cpukit/libfs/src/jffs2/src/scan.c
2   2   cpukit/libfs/src/jffs2/src/write.c

diff --git a/cpukit/libfs/src/jffs2/src/dir-rtems.c 
b/cpukit/libfs/src/jffs2/src/dir-rtems.c
index 8d3c3bdc2c..9fa70bcec4 100644
--- a/cpukit/libfs/src/jffs2/src/dir-rtems.c
+++ b/cpukit/libfs/src/jffs2/src/dir-rtems.c
@@ -30,7 +30,7 @@ struct _inode *jffs2_lookup(struct _inode *dir_i, const 
unsigned char *name, siz
struct jffs2_inode_info *dir_f;
struct jffs2_full_dirent *fd = NULL, *fd_list;
uint32_t ino = 0;
-   uint32_t hash = full_name_hash(name, namelen);
+   uint32_t hash = full_name_hash(NULL, name, namelen);
struct _inode *inode = NULL;
 
D1(printk("jffs2_lookup()\n"));
diff --git a/cpukit/libfs/src/jffs2/src/os-rtems.h 
b/cpukit/libfs/src/jffs2/src/os-rtems.h
index ab4f6d72bf..db1be61e67 100644
--- a/cpukit/libfs/src/jffs2/src/os-rtems.h
+++ b/cpukit/libfs/src/jffs2/src/os-rtems.h
@@ -41,9 +41,10 @@
 struct _inode;
 struct super_block;
 
-static inline unsigned int full_name_hash(const unsigned char * name, size_t 
len) {
+static inline unsigned int full_name_hash(const void *salt, const unsigned 
char * name, size_t len) {
 
uint32_t hash = 0;
+   (void)salt;
while (len--) {
hash = (hash << 4) | (hash >> 28);
hash ^= *(name++);
diff --git a/cpukit/libfs/src/jffs2/src/readinode.c 
b/cpukit/libfs/src/jffs2/src/readinode.c
index ba1ad6a22f..7a897b670d 100644
--- a/cpukit/libfs/src/jffs2/src/readinode.c
+++ b/cpukit/libfs/src/jffs2/src/readinode.c
@@ -683,7 +683,7 @@ static inline int read_direntry(struct jffs2_sb_info *c, 
struct jffs2_raw_node_r
}
}
 
-   fd->nhash = full_name_hash(fd->name, rd->nsize);
+   fd->nhash = full_name_hash(NULL, fd->name, rd->nsize);
fd->next = NULL;
fd->name[rd->nsize] = '\0';
 
diff --git a/cpukit/libfs/src/jffs2/src/scan.c 
b/cpukit/libfs/src/jffs2/src/scan.c
index 10bf007819..177a0cdd3f 100644
--- a/cpukit/libfs/src/jffs2/src/scan.c
+++ b/cpukit/libfs/src/jffs2/src/scan.c
@@ -1103,7 +1103,7 @@ static int jffs2_scan_dirent_node(struct jffs2_sb_info 
*c, struct jffs2_eraseblo
fd->next = NULL;
fd->version = je32_to_cpu(rd->version);
fd->ino = je32_to_cpu(rd->ino);
-   fd->nhash = full_name_hash(fd->name, checkedlen);
+   fd->nhash = full_name_hash(NULL, fd->name, checkedlen);
fd->type = rd->type;
jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
 
diff --git a/cpukit/libfs/src/jffs2/src/write.c 
b/cpukit/libfs/src/jffs2/src/write.c
index ac3ec295d5..3d49ec05ca 100644
--- a/cpukit/libfs/src/jffs2/src/write.c
+++ b/cpukit/libfs/src/jffs2/src/write.c
@@ -247,7 +247,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct 
jffs2_sb_info *c, struct jff
 
fd->version = je32_to_cpu(rd->version);
fd->ino = je32_to_cpu(rd->ino);
-   fd->nhash = full_name_hash(name, namelen);
+   fd->nhash = full_name_hash(NULL, name, namelen);
fd->type = rd->type;
memcpy(fd->name, name, namelen);
fd->name[namelen]=0;
@@ -600,7 +600,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct 
jffs2_inode_info *dir_f,
jffs2_add_fd_to_list(c, fd, &dir_f->dents);
mutex_unlock(&dir_f->sem);
} else {
-   uint32_t nhash = full_name_hash(name, namelen);
+   uint32_t nhash = full_name_hash(NULL, name, namelen);
 
fd = dir_f->dents;
/* We don't actually want to reserve any space, but we do
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 22/29] mm, fs: get rid of PAGE_CACHE_* and page_cache_{get, release} macros

2018-07-05 Thread Sebastian Huber
From: "Kirill A. Shutemov" 

PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
ago with promise that one day it will be possible to implement page
cache with bigger chunks than PAGE_SIZE.

This promise never materialized.  And unlikely will.

We have many places where PAGE_CACHE_SIZE assumed to be equal to
PAGE_SIZE.  And it's constant source of confusion on whether
PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
especially on the border between fs and mm.

Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
breakage to be doable.

Let's stop pretending that pages in page cache are special.  They are
not.

The changes are pretty straight-forward:

 -  << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

 -  >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> ;

 - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};

 - page_cache_get() -> get_page();

 - page_cache_release() -> put_page();

This patch contains automated changes generated with coccinelle using
script below.  For some reason, coccinelle doesn't patch header files.
I've called spatch for them manually.

The only adjustment after coccinelle is revert of changes to
PAGE_CAHCE_ALIGN definition: we are going to drop it later.

There are few places in the code where coccinelle didn't reach.  I'll
fix them manually in a separate patch.  Comments and documentation also
will be addressed with the separate patch.

virtual patch

@@
expression E;
@@
- E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E

@@
expression E;
@@
- E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
+ E

@@
@@
- PAGE_CACHE_SHIFT
+ PAGE_SHIFT

@@
@@
- PAGE_CACHE_SIZE
+ PAGE_SIZE

@@
@@
- PAGE_CACHE_MASK
+ PAGE_MASK

@@
expression E;
@@
- PAGE_CACHE_ALIGN(E)
+ PAGE_ALIGN(E)

@@
expression E;
@@
- page_cache_get(E)
+ get_page(E)

@@
expression E;
@@
- page_cache_release(E)
+ put_page(E)

Signed-off-by: Kirill A. Shutemov 
Acked-by: Michal Hocko 
Signed-off-by: Linus Torvalds 

4   4   cpukit/libfs/src/jffs2/src/debug.c
4   4   cpukit/libfs/src/jffs2/src/gc.c
4   4   cpukit/libfs/src/jffs2/src/nodelist.c
4   3   cpukit/libfs/src/jffs2/src/write.c

diff --git a/cpukit/libfs/src/jffs2/src/debug.c 
b/cpukit/libfs/src/jffs2/src/debug.c
index a5ff32240f..4ddaa42400 100644
--- a/cpukit/libfs/src/jffs2/src/debug.c
+++ b/cpukit/libfs/src/jffs2/src/debug.c
@@ -97,15 +97,15 @@ __jffs2_dbg_fragtree_paranoia_check_nolock(struct 
jffs2_inode_info *f)
   rather than mucking around with actually reading the 
node
   and checking the compression type, which is the real 
way
   to tell a hole node. */
-   if (frag->ofs & (PAGE_CACHE_SIZE-1) && frag_prev(frag)
-   && frag_prev(frag)->size < 
PAGE_CACHE_SIZE && frag_prev(frag)->node) {
+   if (frag->ofs & (PAGE_SIZE-1) && frag_prev(frag)
+   && frag_prev(frag)->size < PAGE_SIZE && 
frag_prev(frag)->node) {
JFFS2_ERROR("REF_PRISTINE node at 0x%08x had a 
previous non-hole frag in the same page. Tell dwmw2.\n",
ref_offset(fn->raw));
bitched = 1;
}
 
-   if ((frag->ofs+frag->size) & (PAGE_CACHE_SIZE-1) && 
frag_next(frag)
-   && frag_next(frag)->size < 
PAGE_CACHE_SIZE && frag_next(frag)->node) {
+   if ((frag->ofs+frag->size) & (PAGE_SIZE-1) && 
frag_next(frag)
+   && frag_next(frag)->size < PAGE_SIZE && 
frag_next(frag)->node) {
JFFS2_ERROR("REF_PRISTINE node at 0x%08x 
(%08x-%08x) had a following non-hole frag in the same page. Tell dwmw2.\n",
   ref_offset(fn->raw), frag->ofs, 
frag->ofs+frag->size);
bitched = 1;
diff --git a/cpukit/libfs/src/jffs2/src/gc.c b/cpukit/libfs/src/jffs2/src/gc.c
index 6206c47fb9..f557075ab8 100644
--- a/cpukit/libfs/src/jffs2/src/gc.c
+++ b/cpukit/libfs/src/jffs2/src/gc.c
@@ -554,7 +554,7 @@ static int jffs2_garbage_collect_live(struct jffs2_sb_info 
*c,  struct jffs2_era
goto upnout;
}
/* We found a datanode. Do the GC */
-   if((start >> PAGE_CACHE_SHIFT) < ((end-1) >> PAGE_CACHE_SHIFT)) 
{
+   if((start >> PAGE_SHIFT) < ((end-1) >> PAGE_SHIFT)) {
/* It crosses a page boundary. Therefore, it must be a 
hole. */
ret = jffs2_garbage_collect_hole(c, jeb, f, fn, start, 
end);
} else {
@@ -1200,8 +1200,8 @@ static int jffs2_garbage_collect_dnode(struct 
jffs2_sb_info *c, struct jffs2_era
struct jffs2_node_frag *frag;
uint32_t min, max;
 
-   min = start & ~(PAGE_

[PATCH 19/29] jffs2: Fix page lock / f->sem deadlock

2018-07-05 Thread Sebastian Huber
From: David Woodhouse 

With this fix, all code paths should now be obtaining the page lock before
f->sem.

Reported-by: Szabó Tamás 
Tested-by: Thomas Betker 
Signed-off-by: David Woodhouse 
Cc: sta...@vger.kernel.org

10  7   cpukit/libfs/src/jffs2/src/gc.c

diff --git a/cpukit/libfs/src/jffs2/src/gc.c b/cpukit/libfs/src/jffs2/src/gc.c
index 22963dc3a6..2c945e7621 100644
--- a/cpukit/libfs/src/jffs2/src/gc.c
+++ b/cpukit/libfs/src/jffs2/src/gc.c
@@ -1304,14 +1304,17 @@ static int jffs2_garbage_collect_dnode(struct 
jffs2_sb_info *c, struct jffs2_era
BUG_ON(start > orig_start);
}
 
-   /* First, use readpage() to read the appropriate page into the page 
cache */
-   /* Q: What happens if we actually try to GC the _same_ page for which 
commit_write()
-*triggered garbage collection in the first place?
-* A: I _think_ it's OK. read_cache_page shouldn't deadlock, we'll 
write out the
-*page OK. We'll actually write it out again in commit_write, which 
is a little
-*suboptimal, but at least we're correct.
-*/
+   /* The rules state that we must obtain the page lock *before* f->sem, so
+* drop f->sem temporarily. Since we also hold c->alloc_sem, nothing's
+* actually going to *change* so we're safe; we only allow reading.
+*
+* It is important to note that jffs2_write_begin() will ensure that its
+* page is marked Uptodate before allocating space. That means that if 
we
+* end up here trying to GC the *same* page that jffs2_write_begin() is
+* trying to write out, read_cache_page() will not deadlock. */
+   mutex_unlock(&f->sem);
pg_ptr = jffs2_gc_fetch_page(c, f, start, &pg);
+   mutex_lock(&f->sem);
 
if (IS_ERR(pg_ptr)) {
pr_warn("read_cache_page() returned error: %ld\n",
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[PATCH 24/29] jffs2: Remove jffs2_{get,set,remove}xattr macros

2018-07-05 Thread Sebastian Huber
From: Andreas Gruenbacher 

When CONFIG_JFFS2_FS_XATTR is off, jffs2_xattr_handlers is defined as
NULL. With sb->s_xattr == NULL, the generic_{get,set,remove}xattr
functions produce the same result as setting the {get,set,remove}xattr
inode operations to NULL, so there is no need for these macros.

Signed-off-by: Andreas Gruenbacher 
Signed-off-by: Al Viro 

0   6   cpukit/libfs/src/jffs2/src/xattr.h

diff --git a/cpukit/libfs/src/jffs2/src/xattr.h 
b/cpukit/libfs/src/jffs2/src/xattr.h
index 467ff376ee..720007b2fd 100644
--- a/cpukit/libfs/src/jffs2/src/xattr.h
+++ b/cpukit/libfs/src/jffs2/src/xattr.h
@@ -99,9 +99,6 @@ extern const struct xattr_handler jffs2_user_xattr_handler;
 extern const struct xattr_handler jffs2_trusted_xattr_handler;
 
 extern ssize_t jffs2_listxattr(struct dentry *, char *, size_t);
-#define jffs2_getxattr generic_getxattr
-#define jffs2_setxattr generic_setxattr
-#define jffs2_removexattr  generic_removexattr
 
 #else
 
@@ -116,9 +113,6 @@ extern ssize_t jffs2_listxattr(struct dentry *, char *, 
size_t);
 
 #define jffs2_xattr_handlers   NULL
 #define jffs2_listxattrNULL
-#define jffs2_getxattr NULL
-#define jffs2_setxattr NULL
-#define jffs2_removexattr  NULL
 
 #endif /* CONFIG_JFFS2_FS_XATTR */
 
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 00/29] Update JFFS2 port to Linux v4.17

2018-07-05 Thread Sebastian Huber
This patch series adds all JFFS2 changes made by the Linux upstream from Linux
v3.11 to v4.17 to the RTEMS port.  See also:

https://devel.rtems.org/ticket/3465

Ajesh Kunhipurayil Vijayan (1):
  jffs2: Fix crash due to truncation of csize

Al Viro (1):
  kill wbuf_queued/wbuf_dwork_lock

Andreas Gruenbacher (1):
  jffs2: Remove jffs2_{get,set,remove}xattr macros

Boris Brezillon (2):
  mtd: Stop assuming mtd_erase() is asynchronous
  mtd: Unconditionally update ->fail_addr and ->addr in part_erase()

Brian Norris (1):
  jffs2: fix unbalanced locking

Chen Jie (1):
  jffs2: fix handling of corrupted summary length

Christoph Hellwig (1):
  jffs2: use generic posix ACL infrastructure

Cody P Schafer (1):
  fs/jffs2: use rbtree postorder iteration helper instead of opencoding

Colin Ian King (1):
  jffs2: fix spelling mistake: "requestied" -> "requested"

David Woodhouse (3):
  jffs2: Fix page lock / f->sem deadlock
  Fix directory hardlinks from deleted directories
  jffs2: Improve post-mount CRC scan efficiency

Geert Uytterhoeven (1):
  jffs2: Drop bogus if in comment

Ingo Molnar (1):
  sched/headers: Prepare to move signal wakeup & sigpending methods from
 into 

Kamlakant Patel (1):
  jffs2: Fix segmentation fault found in stress test

Kirill A. Shutemov (1):
  mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros

Li Zefan (2):
  jffs2: remove from wait queue after schedule()
  jffs2: avoid soft-lockup in jffs2_reserve_space_gc()

Linus Torvalds (1):
  vfs: make the string hashes salt the hash

Rickard Strandqvist (1):
  jffs2: compr_rubin: Remove unused function

Sebastian Huber (5):
  score: Add postorder tree iteration support
  linux: Install 
  linux: Simplify 
  linux: Add rbtree_postorder_for_each_entry_safe()
  jffs2: Add README

Tetsuo Handa (1):
  tree wide: use kvfree() than conditional kfree()/vfree()

Wei Fang (1):
  jffs2: fix a memleak in read_direntry()

Yinghai Lu (1):
  initramfs: support initramfs that is bigger than 2GiB

 cpukit/headers.am  |   1 +
 cpukit/include/linux/rbtree.h  | 141 ++
 cpukit/include/rtems/score/rbtree.h|  66 +++
 cpukit/libfs/src/jffs2/README  |  35 
 cpukit/libfs/src/jffs2/include/linux/mm.h  |   0
 cpukit/libfs/src/jffs2/include/linux/rbtree.h  | 133 -
 .../libfs/src/jffs2/include/linux/sched/signal.h   |   0
 cpukit/libfs/src/jffs2/include/linux/slab.h|   1 +
 cpukit/libfs/src/jffs2/src/acl.h   |   7 +-
 cpukit/libfs/src/jffs2/src/build.c |  83 ++---
 cpukit/libfs/src/jffs2/src/compr_rtime.c   |   4 +-
 cpukit/libfs/src/jffs2/src/compr_rubin.c   |   5 -
 cpukit/libfs/src/jffs2/src/compr_zlib.c|   7 +-
 cpukit/libfs/src/jffs2/src/debug.c |   8 +-
 cpukit/libfs/src/jffs2/src/dir-rtems.c |   2 +-
 cpukit/libfs/src/jffs2/src/erase.c |  37 +---
 cpukit/libfs/src/jffs2/src/gc.c|  89 +
 cpukit/libfs/src/jffs2/src/jffs2_fs_sb.h   |   4 +-
 cpukit/libfs/src/jffs2/src/nodelist.c  |  36 +---
 cpukit/libfs/src/jffs2/src/nodelist.h  |   8 +-
 cpukit/libfs/src/jffs2/src/nodemgmt.c  |  20 +-
 cpukit/libfs/src/jffs2/src/os-rtems.h  |   3 +-
 cpukit/libfs/src/jffs2/src/readinode.c |  69 ++-
 cpukit/libfs/src/jffs2/src/scan.c  |   7 +-
 cpukit/libfs/src/jffs2/src/write.c |  11 +-
 cpukit/libfs/src/jffs2/src/xattr.h |   6 -
 cpukit/score/Makefile.am   |   1 +
 cpukit/score/src/rbtreepostorder.c |  81 
 testsuites/sptests/sprbtree01/init.c   | 206 +
 29 files changed, 722 insertions(+), 349 deletions(-)
 create mode 100644 cpukit/include/linux/rbtree.h
 create mode 100644 cpukit/libfs/src/jffs2/README
 create mode 100644 cpukit/libfs/src/jffs2/include/linux/mm.h
 delete mode 100644 cpukit/libfs/src/jffs2/include/linux/rbtree.h
 create mode 100644 cpukit/libfs/src/jffs2/include/linux/sched/signal.h
 create mode 100644 cpukit/score/src/rbtreepostorder.c

-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 07/29] jffs2: remove from wait queue after schedule()

2018-07-05 Thread Sebastian Huber
From: Li Zefan 

@wait is a local variable, so if we don't remove it from the wait queue
list, later wake_up() may end up accessing invalid memory.

This was spotted by eyes.

Signed-off-by: Li Zefan 
Cc: David Woodhouse 
Cc: Artem Bityutskiy 
Cc: 
Signed-off-by: Andrew Morton 
Signed-off-by: Brian Norris 

1   0   cpukit/libfs/src/jffs2/src/nodemgmt.c

diff --git a/cpukit/libfs/src/jffs2/src/nodemgmt.c 
b/cpukit/libfs/src/jffs2/src/nodemgmt.c
index 40fa34c692..6cb8dc4d6f 100644
--- a/cpukit/libfs/src/jffs2/src/nodemgmt.c
+++ b/cpukit/libfs/src/jffs2/src/nodemgmt.c
@@ -181,6 +181,7 @@ int jffs2_reserve_space(struct jffs2_sb_info *c, uint32_t 
minsize,
spin_unlock(&c->erase_completion_lock);
 
schedule();
+   remove_wait_queue(&c->erase_wait, 
&wait);
} else
spin_unlock(&c->erase_completion_lock);
} else if (ret)
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 09/29] jffs2: Fix segmentation fault found in stress test

2018-07-05 Thread Sebastian Huber
From: Kamlakant Patel 

Creating a large file on a JFFS2 partition sometimes crashes with this call
trace:

[  306.476000] CPU 13 Unable to handle kernel paging request at virtual address 
c000dfff8002, epc == c03a80a8, ra == c03a8044
[  306.488000] Oops[#1]:
[  306.488000] Cpu 13
[  306.492000] $ 0   :   8008 
8007
[  306.50] $ 4   : c000dfff8002 009f c000e0007cde 
c000ee95fa58
[  306.508000] $ 8   : 0001 8008 0001 
8002
[  306.516000] $12   : 7fa9 ff0e ff0f 
80e55930aebb92bb
[  306.524000] $16   : c000e000 c000ee95fa5c c000efc8 
c09edd70
[  306.532000] $20   : c2b6 c000ee95fa58  
c000efc8
[  306.54] $24   :  0004
[  306.548000] $28   : c000ee95 c000ee95f738  
c03a8044
[  306.556000] Hi: 000574a5
[  306.56] Lo: 6193b7a7e903d8c9
[  306.564000] epc   : c03a80a8 jffs2_rtime_compress+0x98/0x198
[  306.568000] Tainted: GW
[  306.572000] ra: c03a8044 jffs2_rtime_compress+0x34/0x198
[  306.58] Status: 5000f8e3KX SX UX KERNEL EXL IE
[  306.584000] Cause : 0088
[  306.588000] BadVA : c000dfff8002
[  306.592000] PrId  : 000c1100 (Netlogic XLP)
[  306.596000] Modules linked in:
[  306.596000] Process dd (pid: 170, threadinfo=c000ee95, 
task=c000ee6e0858, tls=00c47490)
[  306.608000] Stack : 7c547f377ddc7ee4 7ffc7f967f5d7fae 7f617f507fc37ff4 
7e7d7f817f487f5f
7d8e7fec7ee87eb3 7e977ff27eec7f9e 7d677ec67f917f67 7f3d7e457f017ed7
7fd37f517f867eb2 7fed7fd17ca57e1d 7e5f7fe87f257f77 7fd77f0d7ede7fdb
7fba7fef7e197f99 7fde7fe07ee37eb5 7f5c7f8c7fc67f65 7f457fb87f847e93
7f737f3e7d137cd9 7f8e7e9c7fc47d25 7dbb7fac7fb67e52 7ff17f627da97f64
7f6b7df77ffa7ec5 80057ef17f357fb3 7f767fa27dfc7fd5 7fe37e8e7fd07e53
7e227fcf7efb7fa1 7f547e787fa87fcc 7fcb7fc57f5a7ffb 7fc07f6c7ea97e80
7e2d7ed17e587ee0 7fb17f9d7feb7f31 7f607e797e887faa 7f757fdd7c607ff3
7e877e657ef37fbd 7ec17fd67fe67ff7 7ff67f797ff87dc4 7eef7f3a7c337fa6
7fe57fc97ed87f4b 7ebe7f097f0b8003 7fe97e2a7d997cba 7f587f987f3c7fa9
...
[  306.676000] Call Trace:
[  306.68] [] jffs2_rtime_compress+0x98/0x198
[  306.684000] [] jffs2_selected_compress+0x110/0x230
[  306.692000] [] jffs2_compress+0x5c/0x388
[  306.696000] [] jffs2_write_inode_range+0xd8/0x388
[  306.704000] [] jffs2_write_end+0x16c/0x2d0
[  306.708000] [] generic_file_buffered_write+0xf8/0x2b8
[  306.716000] [] __generic_file_aio_write+0x1ac/0x350
[  306.72] [] generic_file_aio_write+0x80/0x168
[  306.728000] [] do_sync_write+0x94/0xf8
[  306.732000] [] vfs_write+0xa4/0x1a0
[  306.736000] [] SyS_write+0x50/0x90
[  306.744000] [] handle_sys+0x180/0x1a0
[  306.748000]
[  306.748000]
Code: 020b202d  0205282d  90a5 <9084> 14a40038    0060602d  
282d  016c5823
[  306.76] ---[ end trace 79dd088435be02d0 ]---
Segmentation fault

This crash is caused because the 'positions' is declared as an array of signed
short. The value of position is in the range 0..65535, and will be converted
to a negative number when the position is greater than 32767 and causes a
corruption and crash. Changing the definition to 'unsigned short' fixes this
issue

Signed-off-by: Jayachandran C 
Signed-off-by: Kamlakant Patel 
Cc: 
Signed-off-by: Brian Norris 

2   2   cpukit/libfs/src/jffs2/src/compr_rtime.c

diff --git a/cpukit/libfs/src/jffs2/src/compr_rtime.c 
b/cpukit/libfs/src/jffs2/src/compr_rtime.c
index 98d7ccd3a1..c8313ed234 100644
--- a/cpukit/libfs/src/jffs2/src/compr_rtime.c
+++ b/cpukit/libfs/src/jffs2/src/compr_rtime.c
@@ -38,7 +38,7 @@ uint16_t rtems_jffs2_compressor_rtime_compress(
uint32_t *dstlen
 )
 {
-   short positions[256];
+   unsigned short positions[256];
int outpos = 0;
int pos=0;
 
@@ -86,7 +86,7 @@ int rtems_jffs2_compressor_rtime_decompress(
uint32_t destlen
 )
 {
-   short positions[256];
+   unsigned short positions[256];
int outpos = 0;
int pos=0;
 
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 21/29] jffs2: Improve post-mount CRC scan efficiency

2018-07-05 Thread Sebastian Huber
From: David Woodhouse 

We need to finish doing the CRC checks before we can allow writes to
happen, and we currently process the inodes in order. This means a call
to jffs2_get_ino_cache() for each possible inode# up to c->highest_ino.

There may be a lot of lookups which fail, if the inode# space is used
sparsely. And the inode# space is *often* used sparsely, if a file
system contains a lot of stuff that was put there in the original
image, followed by lots of creation and deletion of new files.

Instead of processing them numerically with a lookup each time, just
walk the hash buckets instead.

[fix locking typo reported by Dan Carpenter]
Signed-off-by: David Woodhouse 

42  22  cpukit/libfs/src/jffs2/src/gc.c
1   1   cpukit/libfs/src/jffs2/src/jffs2_fs_sb.h
2   2   cpukit/libfs/src/jffs2/src/nodemgmt.c

diff --git a/cpukit/libfs/src/jffs2/src/gc.c b/cpukit/libfs/src/jffs2/src/gc.c
index 2c945e7621..6206c47fb9 100644
--- a/cpukit/libfs/src/jffs2/src/gc.c
+++ b/cpukit/libfs/src/jffs2/src/gc.c
@@ -136,37 +136,59 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
if (mutex_lock_interruptible(&c->alloc_sem))
return -EINTR;
 
+
for (;;) {
+   /* We can't start doing GC until we've finished checking
+  the node CRCs etc. */
+   int bucket, want_ino;
+
spin_lock(&c->erase_completion_lock);
if (!c->unchecked_size)
break;
-
-   /* We can't start doing GC yet. We haven't finished checking
-  the node CRCs etc. Do it now. */
-
-   /* checked_ino is protected by the alloc_sem */
-   if (c->checked_ino > c->highest_ino && xattr) {
-   pr_crit("Checked all inodes but still 0x%x bytes of 
unchecked space?\n",
-   c->unchecked_size);
-   jffs2_dbg_dump_block_lists_nolock(c);
-   spin_unlock(&c->erase_completion_lock);
-   mutex_unlock(&c->alloc_sem);
-   return -ENOSPC;
-   }
-
spin_unlock(&c->erase_completion_lock);
 
if (!xattr)
xattr = jffs2_verify_xattr(c);
 
spin_lock(&c->inocache_lock);
+   /* Instead of doing the inodes in numeric order, doing a lookup
+* in the hash for each possible number, just walk the hash
+* buckets of *existing* inodes. This means that we process
+* them out-of-order, but it can be a lot faster if there's
+* a sparse inode# space. Which there often is. */
+   want_ino = c->check_ino;
+   for (bucket = c->check_ino % c->inocache_hashsize ; bucket < 
c->inocache_hashsize; bucket++) {
+   for (ic = c->inocache_list[bucket]; ic; ic = ic->next) {
+   if (ic->ino < want_ino)
+   continue;
+
+   if (ic->state != INO_STATE_CHECKEDABSENT &&
+   ic->state != INO_STATE_PRESENT)
+   goto got_next; /* with inocache_lock 
held */
+
+   jffs2_dbg(1, "Skipping ino #%u already 
checked\n",
+ ic->ino);
+   }
+   want_ino = 0;
+   }
 
-   ic = jffs2_get_ino_cache(c, c->checked_ino++);
+   /* Point c->check_ino past the end of the last bucket. */
+   c->check_ino = ((c->highest_ino + c->inocache_hashsize + 1) &
+   ~c->inocache_hashsize) - 1;
 
-   if (!ic) {
-   spin_unlock(&c->inocache_lock);
-   continue;
-   }
+   spin_unlock(&c->inocache_lock);
+
+   pr_crit("Checked all inodes but still 0x%x bytes of unchecked 
space?\n",
+   c->unchecked_size);
+   jffs2_dbg_dump_block_lists_nolock(c);
+   mutex_unlock(&c->alloc_sem);
+   return -ENOSPC;
+
+   got_next:
+   /* For next time round the loop, we want c->checked_ino to 
indicate
+* the *next* one we want to check. And since we're walking the
+* buckets rather than doing it sequentially, it's: */
+   c->check_ino = ic->ino + c->inocache_hashsize;
 
if (!ic->pino_nlink) {
jffs2_dbg(1, "Skipping check of ino #%d with nlink/pino 
zero\n",
@@ -178,8 +200,6 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
switch(ic->state) {
case INO_STATE_CHECKEDABSENT:
case INO_STATE_PRESENT:
-   jffs2_dbg(1, "Skipping ino #%u already checked\n",
- ic->ino)

[PATCH 25/29] sched/headers: Prepare to move signal wakeup & sigpending methods from into

2018-07-05 Thread Sebastian Huber
From: Ingo Molnar 

Fix up affected files that include this signal functionality via sched.h.

Acked-by: Linus Torvalds 
Cc: Mike Galbraith 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: linux-ker...@vger.kernel.org
Signed-off-by: Ingo Molnar 

0   0   cpukit/libfs/src/jffs2/include/linux/sched/signal.h
1   1   cpukit/libfs/src/jffs2/src/nodemgmt.c

diff --git a/cpukit/libfs/src/jffs2/include/linux/sched/signal.h 
b/cpukit/libfs/src/jffs2/include/linux/sched/signal.h
new file mode 100644
index 00..e69de29bb2
diff --git a/cpukit/libfs/src/jffs2/src/nodemgmt.c 
b/cpukit/libfs/src/jffs2/src/nodemgmt.c
index d57142826c..8c181288b9 100644
--- a/cpukit/libfs/src/jffs2/src/nodemgmt.c
+++ b/cpukit/libfs/src/jffs2/src/nodemgmt.c
@@ -16,7 +16,7 @@
 #include 
 #include 
 #include 
-#include  /* For cond_resched() */
+#include 
 #include "nodelist.h"
 #include "debug.h"
 
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 01/29] score: Add postorder tree iteration support

2018-07-05 Thread Sebastian Huber
Update #3465.

66  0   cpukit/include/rtems/score/rbtree.h
1   0   cpukit/score/Makefile.am
81  0   cpukit/score/src/rbtreepostorder.c
184 0   testsuites/sptests/sprbtree01/init.c

diff --git a/cpukit/include/rtems/score/rbtree.h 
b/cpukit/include/rtems/score/rbtree.h
index 15a3bc8913..fea3d13695 100644
--- a/cpukit/include/rtems/score/rbtree.h
+++ b/cpukit/include/rtems/score/rbtree.h
@@ -558,6 +558,72 @@ RTEMS_INLINE_ROUTINE void *_RBTree_Find_inline(
   return NULL;
 }
 
+/**
+ * @brief Returns the container of the first node of the specified red-black
+ * tree in postorder.
+ *
+ * Postorder traversal may be used to delete all nodes of a red-black tree.
+ *
+ * @param the_rbtree The red-black tree control.
+ * @param offset The offset to the red-black tree node in the container 
structure.
+ *
+ * @retval NULL The red-black tree is empty.
+ * @retval container The container of the first node of the specified red-black
+ *   tree in postorder.
+ *
+ * @see _RBTree_Postorder_next().
+ *
+ * @code
+ * #include 
+ *
+ * typedef struct {
+ *   int data;
+ *   RBTree_Node Node;
+ * } Container_Control;
+ *
+ * void visit( Container_Control *the_container );
+ *
+ * void postorder_traversal( RBTree_Control *the_rbtree )
+ * {
+ *   Container_Control *the_container;
+ *
+ *   the_container = _RBTree_Postorder_first(
+ * the_rbtree,
+ * offsetof( Container_Control, Node )
+ *   );
+ *
+ *   while ( the_container != NULL ) {
+ * visit( the_container );
+ *
+ * the_container = _RBTree_Postorder_next(
+ *   &the_container->Node,
+ *   offsetof( Container_Control, Node )
+ * );
+ *   }
+ * }
+ * @endcode
+ */
+void *_RBTree_Postorder_first(
+  const RBTree_Control *the_rbtree,
+  size_toffset
+);
+
+/**
+ * @brief Returns the container of the next node in postorder.
+ *
+ * @param the_node The red-black tree node.  The node must not be NULL.
+ * @param offset The offset to the red-black tree node in the container 
structure.
+ *
+ * @retval NULL The node is NULL or there is no next node in postorder.
+ * @retval container The container of the next node in postorder.
+ *
+ * @see _RBTree_Postorder_first().
+ */
+void *_RBTree_Postorder_next(
+  const RBTree_Node *the_node,
+  size_t offset
+);
+
 /**@}*/
 
 #ifdef __cplusplus
diff --git a/cpukit/score/Makefile.am b/cpukit/score/Makefile.am
index b7ce16c299..e345f77daa 100644
--- a/cpukit/score/Makefile.am
+++ b/cpukit/score/Makefile.am
@@ -157,6 +157,7 @@ libscore_a_SOURCES += src/freechain.c
 libscore_a_SOURCES += \
 src/rbtreeextract.c \
 src/rbtreeinsert.c src/rbtreeiterate.c src/rbtreenext.c
+libscore_a_SOURCES += src/rbtreepostorder.c
 libscore_a_SOURCES += src/rbtreereplace.c
 
 ## THREAD_C_FILES
diff --git a/cpukit/score/src/rbtreepostorder.c 
b/cpukit/score/src/rbtreepostorder.c
new file mode 100644
index 00..26555c8848
--- /dev/null
+++ b/cpukit/score/src/rbtreepostorder.c
@@ -0,0 +1,81 @@
+/**
+ * @file
+ *
+ * @ingroup ScoreRBTree
+ *
+ * @brief _RBTree_Postorder_first() and _RBTree_Postorder_next()
+ * implementation.
+ */
+
+/*
+ * Copyright (c) 2018 embedded brains GmbH.  All rights reserved.
+ *
+ *  embedded brains GmbH
+ *  Dornierstr. 4
+ *  82178 Puchheim
+ *  Germany
+ *  
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.org/license/LICENSE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include 
+
+static void *_RBTree_Postorder_dive_left(
+  const RBTree_Node *the_node,
+  size_t offset
+)
+{
+  while ( true ) {
+if ( _RBTree_Left( the_node ) != NULL ) {
+  the_node = _RBTree_Left( the_node );
+} else if ( _RBTree_Right( the_node ) != NULL ) {
+  the_node = _RBTree_Right( the_node );
+} else {
+  return (void *) ( (uintptr_t) the_node - offset );
+}
+  }
+}
+
+void *_RBTree_Postorder_next(
+  const RBTree_Node *the_node,
+  size_t offset
+)
+{
+  const RBTree_Node *parent;
+
+  parent = _RBTree_Parent( the_node );
+  if ( parent == NULL ) {
+return NULL;
+  }
+
+  if (
+the_node == _RBTree_Left( parent )
+  && _RBTree_Right( parent ) != NULL
+  ) {
+return _RBTree_Postorder_dive_left( _RBTree_Right( parent ), offset );
+  }
+
+  return (void *) ( (uintptr_t) parent - offset );
+}
+
+void *_RBTree_Postorder_first(
+  const RBTree_Control *the_rbtree,
+  size_toffset
+)
+{
+  const RBTree_Node *the_node;
+
+  the_node = _RBTree_Root( the_rbtree );
+  if ( the_node == NULL ) {
+return NULL;
+  }
+
+  return _RBTree_Postorder_dive_left( the_node, offset );
+}
diff --git a/testsuites/sptests/sprbtree01/init.c 
b/testsuites/sptests/sprbtree01/init.c
index cbd6c8f9e1..7a969cfa4a 100644
--- a/testsuites/sptests/sprbtree01/init.c
+++ b/testsuites/sptests/sprbtree01/init.c
@@ -63,6 +63,8 @@ static test_node node_array[100];
 
 #define BLACK RB_BLACK
 
+#d

[PATCH 28/29] mtd: Unconditionally update ->fail_addr and ->addr in part_erase()

2018-07-05 Thread Sebastian Huber
From: Boris Brezillon 

->fail_addr and ->addr can be updated no matter the result of
parent->_erase(), we just need to remove the code doing the same thing
in mtd_erase_callback() to avoid adjusting those fields twice.

Note that this can be done because all MTD users have been converted to
not pass an erase_info->callback() and are thus only taking the
->addr_fail and ->addr fields into account after part_erase() has
returned.

While we're at it, get rid of the erase_info->mtd field which was only
needed to let mtd_erase_callback() get the partition device back.

Signed-off-by: Boris Brezillon 
Reviewed-by: Richard Weinberger 

0   1   cpukit/libfs/src/jffs2/src/erase.c

diff --git a/cpukit/libfs/src/jffs2/src/erase.c 
b/cpukit/libfs/src/jffs2/src/erase.c
index 973d3ab87e..9afaea 100644
--- a/cpukit/libfs/src/jffs2/src/erase.c
+++ b/cpukit/libfs/src/jffs2/src/erase.c
@@ -61,7 +61,6 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
 
memset(instr, 0, sizeof(*instr));
 
-   instr->mtd = c->mtd;
instr->addr = jeb->offset;
instr->len = c->sector_size;
 
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 02/29] linux: Install

2018-07-05 Thread Sebastian Huber
This makes it possible to test this API.

Update #3465.

1   0   cpukit/headers.am
0   0   cpukit/{libfs/src/jffs2 => }/include/linux/rbtree.h

diff --git a/cpukit/headers.am b/cpukit/headers.am
index 2315db1e7d..fb6e1fc009 100644
--- a/cpukit/headers.am
+++ b/cpukit/headers.am
@@ -58,6 +58,7 @@ include_linuxdir = $(includedir)/linux
 include_linux_HEADERS =
 include_linux_HEADERS += include/linux/i2c-dev.h
 include_linux_HEADERS += include/linux/i2c.h
+include_linux_HEADERS += include/linux/rbtree.h
 
 include_linux_spidir = $(includedir)/linux/spi
 include_linux_spi_HEADERS =
diff --git a/cpukit/libfs/src/jffs2/include/linux/rbtree.h 
b/cpukit/include/linux/rbtree.h
similarity index 100%
rename from cpukit/libfs/src/jffs2/include/linux/rbtree.h
rename to cpukit/include/linux/rbtree.h
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 26/29] jffs2: fix spelling mistake: "requestied" -> "requested"

2018-07-05 Thread Sebastian Huber
From: Colin Ian King 

trivial fix to spelling mistake in JFFS2_ERROR message

Signed-off-by: Colin Ian King 
[Brian: also fix 'an' -> 'a']
Signed-off-by: Brian Norris 

1   1   cpukit/libfs/src/jffs2/src/readinode.c

diff --git a/cpukit/libfs/src/jffs2/src/readinode.c 
b/cpukit/libfs/src/jffs2/src/readinode.c
index 7a897b670d..519b0d6618 100644
--- a/cpukit/libfs/src/jffs2/src/readinode.c
+++ b/cpukit/libfs/src/jffs2/src/readinode.c
@@ -1375,7 +1375,7 @@ int jffs2_do_read_inode(struct jffs2_sb_info *c, struct 
jffs2_inode_info *f,
jffs2_add_ino_cache(c, f->inocache);
}
if (!f->inocache) {
-   JFFS2_ERROR("requestied to read an nonexistent ino %u\n", ino);
+   JFFS2_ERROR("requested to read a nonexistent ino %u\n", ino);
return -ENOENT;
}
 
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 11/29] initramfs: support initramfs that is bigger than 2GiB

2018-07-05 Thread Sebastian Huber
From: Yinghai Lu 

Now with 64bit bzImage and kexec tools, we support ramdisk that size is
bigger than 2g, as we could put it above 4G.

Found compressed initramfs image could not be decompressed properly.  It
turns out that image length is int during decompress detection, and it
will become < 0 when length is more than 2G.  Furthermore, during
decompressing len as int is used for inbuf count, that has problem too.

Change len to long, that should be ok as on 32 bit platform long is
32bits.

Tested with following compressed initramfs image as root with kexec.
gzip, bzip2, xz, lzma, lzop, lz4.
run time for populate_rootfs():
   sizename   Nehalem-EX  Westmere-EX  Ivybridge-EX
 9034400256 root_img :   26s   24s  30s
 3561095057 root_img.lz4 :   28s   27s  27s
 3459554629 root_img.lzo :   29s   29s  28s
 3219399480 root_img.gz  :   64s   62s  49s
 2251594592 root_img.xz  :  262s  260s 183s
 2226366598 root_img.lzma:  386s  376s 277s
 2901482513 root_img.bz2 :  635s  599s

Signed-off-by: Yinghai Lu 
Cc: "H. Peter Anvin" 
Cc: Ingo Molnar 
Cc: Rashika Kheria 
Cc: Josh Triplett 
Cc: Kyungsik Lee 
Cc: P J P 
Cc: Al Viro 
Cc: Tetsuo Handa 
Cc: "Daniel M. Weeks" 
Cc: Alexandre Courbot 
Cc: Jan Beulich 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 

4   3   cpukit/libfs/src/jffs2/src/compr_zlib.c

diff --git a/cpukit/libfs/src/jffs2/src/compr_zlib.c 
b/cpukit/libfs/src/jffs2/src/compr_zlib.c
index ec640c125a..6f5d0d3956 100644
--- a/cpukit/libfs/src/jffs2/src/compr_zlib.c
+++ b/cpukit/libfs/src/jffs2/src/compr_zlib.c
@@ -74,11 +74,12 @@ uint16_t rtems_jffs2_compressor_zlib_compress(
 
while (def_strm->total_out < *dstlen - STREAM_END_SPACE && 
def_strm->total_in < *sourcelen) {
def_strm->avail_out = *dstlen - (def_strm->total_out + 
STREAM_END_SPACE);
-   def_strm->avail_in = 
min((unsigned)(*sourcelen-def_strm->total_in), def_strm->avail_out);
-   jffs2_dbg(1, "calling deflate with avail_in %d, avail_out %d\n",
+   def_strm->avail_in = min_t(unsigned long,
+   (*sourcelen-def_strm->total_in), def_strm->avail_out);
+   jffs2_dbg(1, "calling deflate with avail_in %ld, avail_out 
%ld\n",
  def_strm->avail_in, def_strm->avail_out);
ret = zlib_deflate(def_strm, Z_PARTIAL_FLUSH);
-   jffs2_dbg(1, "deflate returned with avail_in %d, avail_out %d, 
total_in %ld, total_out %ld\n",
+   jffs2_dbg(1, "deflate returned with avail_in %ld, avail_out 
%ld, total_in %ld, total_out %ld\n",
  def_strm->avail_in, def_strm->avail_out,
  def_strm->total_in, def_strm->total_out);
if (ret != Z_OK) {
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 27/29] mtd: Stop assuming mtd_erase() is asynchronous

2018-07-05 Thread Sebastian Huber
From: Boris Brezillon 

None of the mtd->_erase() implementations work in an asynchronous manner,
so let's simplify MTD users that call mtd_erase(). All they need to do
is check the value returned by mtd_erase() and assume that != 0 means
failure.

Signed-off-by: Boris Brezillon 
Reviewed-by: Richard Weinberger 

5   31  cpukit/libfs/src/jffs2/src/erase.c

diff --git a/cpukit/libfs/src/jffs2/src/erase.c 
b/cpukit/libfs/src/jffs2/src/erase.c
index 323848cc75..973d3ab87e 100644
--- a/cpukit/libfs/src/jffs2/src/erase.c
+++ b/cpukit/libfs/src/jffs2/src/erase.c
@@ -23,14 +23,6 @@
 #include 
 #include "nodelist.h"
 
-struct erase_priv_struct {
-   struct jffs2_eraseblock *jeb;
-   struct jffs2_sb_info *c;
-};
-
-#ifndef __ECOS
-static void jffs2_erase_callback(struct erase_info *);
-#endif
 static void jffs2_erase_failed(struct jffs2_sb_info *c, struct 
jffs2_eraseblock *jeb, uint32_t bad_offset);
 static void jffs2_erase_succeeded(struct jffs2_sb_info *c, struct 
jffs2_eraseblock *jeb);
 static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct 
jffs2_eraseblock *jeb);
@@ -53,7 +45,7 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
jffs2_dbg(1, "%s(): erase block %#08x (range %#08x-%#08x)\n",
  __func__,
  jeb->offset, jeb->offset, jeb->offset + c->sector_size);
-   instr = kmalloc(sizeof(struct erase_info) + sizeof(struct 
erase_priv_struct), GFP_KERNEL);
+   instr = kmalloc(sizeof(struct erase_info), GFP_KERNEL);
if (!instr) {
pr_warn("kmalloc for struct erase_info in jffs2_erase_block 
failed. Refiling block for later\n");
mutex_lock(&c->erase_free_sem);
@@ -72,15 +64,13 @@ static void jffs2_erase_block(struct jffs2_sb_info *c,
instr->mtd = c->mtd;
instr->addr = jeb->offset;
instr->len = c->sector_size;
-   instr->callback = jffs2_erase_callback;
-   instr->priv = (unsigned long)(&instr[1]);
-
-   ((struct erase_priv_struct *)instr->priv)->jeb = jeb;
-   ((struct erase_priv_struct *)instr->priv)->c = c;
 
ret = mtd_erase(c->mtd, instr);
-   if (!ret)
+   if (!ret) {
+   jffs2_erase_succeeded(c, jeb);
+   kfree(instr);
return;
+   }
 
bad_offset = instr->fail_addr;
kfree(instr);
@@ -216,22 +206,6 @@ static void jffs2_erase_failed(struct jffs2_sb_info *c, 
struct jffs2_eraseblock
wake_up(&c->erase_wait);
 }
 
-#ifndef __ECOS
-static void jffs2_erase_callback(struct erase_info *instr)
-{
-   struct erase_priv_struct *priv = (void *)instr->priv;
-
-   if(instr->state != MTD_ERASE_DONE) {
-   pr_warn("Erase at 0x%08llx finished, but state != 
MTD_ERASE_DONE. State is 0x%x instead.\n",
-   (unsigned long long)instr->addr, instr->state);
-   jffs2_erase_failed(priv->c, priv->jeb, instr->fail_addr);
-   } else {
-   jffs2_erase_succeeded(priv->c, priv->jeb);
-   }
-   kfree(instr);
-}
-#endif /* !__ECOS */
-
 /* Hmmm. Maybe we should accept the extra space it takes and make
this a standard doubly-linked list? */
 static inline void jffs2_remove_node_refs_from_ino_list(struct jffs2_sb_info 
*c,
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 05/29] fs/jffs2: use rbtree postorder iteration helper instead of opencoding

2018-07-05 Thread Sebastian Huber
From: Cody P Schafer 

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 
Cc: Michel Lespinasse 
Cc: Jan Kara 
Cc: David Woodhouse 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 

2   26  cpukit/libfs/src/jffs2/src/nodelist.c
3   23  cpukit/libfs/src/jffs2/src/readinode.c

diff --git a/cpukit/libfs/src/jffs2/src/nodelist.c 
b/cpukit/libfs/src/jffs2/src/nodelist.c
index f0ad570b6f..caf7a5614c 100644
--- a/cpukit/libfs/src/jffs2/src/nodelist.c
+++ b/cpukit/libfs/src/jffs2/src/nodelist.c
@@ -566,25 +566,10 @@ struct jffs2_node_frag *jffs2_lookup_node_frag(struct 
rb_root *fragtree, uint32_
they're killed. */
 void jffs2_kill_fragtree(struct rb_root *root, struct jffs2_sb_info *c)
 {
-   struct jffs2_node_frag *frag;
-   struct jffs2_node_frag *parent;
-
-   if (!root->rb_node)
-   return;
+   struct jffs2_node_frag *frag, *next;
 
dbg_fragtree("killing\n");
-
-   frag = (rb_entry(root->rb_node, struct jffs2_node_frag, rb));
-   while(frag) {
-   if (frag->rb.rb_left) {
-   frag = frag_left(frag);
-   continue;
-   }
-   if (frag->rb.rb_right) {
-   frag = frag_right(frag);
-   continue;
-   }
-
+   rbtree_postorder_for_each_entry_safe(frag, next, root, rb) {
if (frag->node && !(--frag->node->frags)) {
/* Not a hole, and it's the final remaining frag
   of this node. Free the node */
@@ -593,17 +578,8 @@ void jffs2_kill_fragtree(struct rb_root *root, struct 
jffs2_sb_info *c)
 
jffs2_free_full_dnode(frag->node);
}
-   parent = frag_parent(frag);
-   if (parent) {
-   if (frag_left(parent) == frag)
-   parent->rb.rb_left = NULL;
-   else
-   parent->rb.rb_right = NULL;
-   }
 
jffs2_free_node_frag(frag);
-   frag = parent;
-
cond_resched();
}
 }
diff --git a/cpukit/libfs/src/jffs2/src/readinode.c 
b/cpukit/libfs/src/jffs2/src/readinode.c
index 9147169a0a..70da35a246 100644
--- a/cpukit/libfs/src/jffs2/src/readinode.c
+++ b/cpukit/libfs/src/jffs2/src/readinode.c
@@ -552,33 +552,13 @@ static int jffs2_build_inode_fragtree(struct 
jffs2_sb_info *c,
 
 static void jffs2_free_tmp_dnode_info_list(struct rb_root *list)
 {
-   struct rb_node *this;
-   struct jffs2_tmp_dnode_info *tn;
-
-   this = list->rb_node;
+   struct jffs2_tmp_dnode_info *tn, *next;
 
-   /* Now at bottom of tree */
-   while (this) {
-   if (this->rb_left)
-   this = this->rb_left;
-   else if (this->rb_right)
-   this = this->rb_right;
-   else {
-   tn = rb_entry(this, struct jffs2_tmp_dnode_info, rb);
+   rbtree_postorder_for_each_entry_safe(tn, next, list, rb) {
jffs2_free_full_dnode(tn->fn);
jffs2_free_tmp_dnode_info(tn);
-
-   this = rb_parent(this);
-   if (!this)
-   break;
-
-   if (this->rb_left == &tn->rb)
-   this->rb_left = NULL;
-   else if (this->rb_right == &tn->rb)
-   this->rb_right = NULL;
-   else BUG();
-   }
}
+
*list = RB_ROOT;
 }
 
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 10/29] jffs2: Fix crash due to truncation of csize

2018-07-05 Thread Sebastian Huber
From: Ajesh Kunhipurayil Vijayan 

mounting JFFS2 partition sometimes crashes with this call trace:

[ 1322.24] Kernel bug detected[#1]:
[ 1322.244000] Cpu 2
[ 1322.244000] $ 0   :  0018 3ff00070 
0001
[ 1322.252000] $ 4   :  c000f3980150  
0001
[ 1322.26] $ 8   : c09cd5f8 0001 0088 
c000ed300de8
[ 1322.268000] $12   : e5e19d9c5f613a45 c046d464  
66227ba5ea67b74e
[ 1322.276000] $16   : c000f1769c00 c000ed1e0200 c000f3980150 

[ 1322.284000] $20   : c000f3a8 fffc c000ed2cfbd8 
c000f39818f0
[ 1322.292000] $24   : 0004 
[ 1322.30] $28   : c000ed2c c000ed2cfab8 0001 
c039c0b0
[ 1322.308000] Hi: 023c
[ 1322.312000] Lo: 0003f802
[ 1322.316000] epc   : c039a9f8 check_tn_node+0x88/0x3b0
[ 1322.32] Not tainted
[ 1322.324000] ra: c039c0b0 
jffs2_do_read_inode_internal+0x1250/0x1e48
[ 1322.332000] Status: 5400f8e3KX SX UX KERNEL EXL IE
[ 1322.336000] Cause : 00800034
[ 1322.34] PrId  : 000c1004 (Netlogic XLP)
[ 1322.344000] Modules linked in:
[ 1322.348000] Process jffs2_gcd_mtd7 (pid: 264, threadinfo=c000ed2c, 
task=c000f0e68dd8, tls=)
[ 1322.356000] Stack : c000f1769e30 c000ed010780 c000ed010780 
c000ed30
c000f1769c00 c000f3980150 c000f3a8 fffc
c000ed2cfbd8 c039c0b0 c09c6340 1000
0dec c016c9d8 c000f39805a0 c000f3980180
0086   
00010dec c000f1769d98 c000ed2cfb18 0001
0001 0044 c000f3a8 c000f1769c00
c000f3d207a8 c000f1769d98 c000f1769de0 c076f9c0
0009   c039cf90
0017 c013fbdc 0001 00010003e61c
...
[ 1322.424000] Call Trace:
[ 1322.428000] [] check_tn_node+0x88/0x3b0
[ 1322.432000] [] jffs2_do_read_inode_internal+0x1250/0x1e48
[ 1322.44] [] jffs2_do_crccheck_inode+0x70/0xd0
[ 1322.448000] [] jffs2_garbage_collect_pass+0x160/0x870
[ 1322.452000] [] jffs2_garbage_collect_thread+0xdc/0x1f0
[ 1322.46] [] kthread+0xb8/0xc0
[ 1322.464000] [] kernel_thread_helper+0x10/0x18
[ 1322.472000]
[ 1322.472000]
Code: 67bd0050  94a4002c  2c830001 <00038036> de050218  2403fffc  0080a82d  
00431824  24630044
[ 1322.48] ---[ end trace b052bb90e97dfbf5 ]---

The variable csize in structure jffs2_tmp_dnode_info is of type uint16_t, but it
is used to hold the compressed data length(csize) which is declared as uint32_t.
So, when the value of csize exceeds 16bits, it gets truncated when assigned to
tn->csize. This is causing a kernel BUG.
Changing the definition of csize in jffs2_tmp_dnode_info to uint32_t fixes the 
issue.

Signed-off-by: Ajesh Kunhipurayil Vijayan 
Signed-off-by: Kamlakant Patel 
Cc: 
Signed-off-by: Brian Norris 

1   1   cpukit/libfs/src/jffs2/src/nodelist.h

diff --git a/cpukit/libfs/src/jffs2/src/nodelist.h 
b/cpukit/libfs/src/jffs2/src/nodelist.h
index 001ac31a52..a94d3ef32b 100644
--- a/cpukit/libfs/src/jffs2/src/nodelist.h
+++ b/cpukit/libfs/src/jffs2/src/nodelist.h
@@ -231,7 +231,7 @@ struct jffs2_tmp_dnode_info
uint32_t version;
uint32_t data_crc;
uint32_t partial_crc;
-   uint16_t csize;
+   uint32_t csize;
uint16_t overlapped;
 };
 
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 13/29] jffs2: Drop bogus if in comment

2018-07-05 Thread Sebastian Huber
From: Geert Uytterhoeven 

Signed-off-by: Geert Uytterhoeven 
Cc: David Woodhouse 
Cc: linux-...@lists.infradead.org
Signed-off-by: Brian Norris 

1   1   cpukit/libfs/src/jffs2/src/readinode.c

diff --git a/cpukit/libfs/src/jffs2/src/readinode.c 
b/cpukit/libfs/src/jffs2/src/readinode.c
index 70da35a246..3314a61885 100644
--- a/cpukit/libfs/src/jffs2/src/readinode.c
+++ b/cpukit/libfs/src/jffs2/src/readinode.c
@@ -226,7 +226,7 @@ static int jffs2_add_tn_to_tree(struct jffs2_sb_info *c,
 
dbg_readinode("insert fragment %#04x-%#04x, ver %u at %08x\n", 
tn->fn->ofs, fn_end, tn->version, ref_offset(tn->fn->raw));
 
-   /* If a node has zero dsize, we only have to keep if it if it might be 
the
+   /* If a node has zero dsize, we only have to keep it if it might be the
   node with highest version -- i.e. the one which will end up as 
f->metadata.
   Note that such nodes won't be REF_UNCHECKED since there are no data 
to
   check anyway. */
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 17/29] jffs2: fix a memleak in read_direntry()

2018-07-05 Thread Sebastian Huber
From: Wei Fang 

Need to free the memory allocated for 'fd' if failed to read all
of the remainder name.

Signed-off-by: Wei Fang 
Signed-off-by: Brian Norris 

5   1   cpukit/libfs/src/jffs2/src/readinode.c

diff --git a/cpukit/libfs/src/jffs2/src/readinode.c 
b/cpukit/libfs/src/jffs2/src/readinode.c
index 69ab7709f8..ba1ad6a22f 100644
--- a/cpukit/libfs/src/jffs2/src/readinode.c
+++ b/cpukit/libfs/src/jffs2/src/readinode.c
@@ -669,8 +669,12 @@ static inline int read_direntry(struct jffs2_sb_info *c, 
struct jffs2_raw_node_r
 
err = jffs2_flash_read(c, (ref_offset(ref)) + read,
rd->nsize - already, &read, &fd->name[already]);
-   if (unlikely(read != rd->nsize - already) && likely(!err))
+   if (unlikely(read != rd->nsize - already) && likely(!err)) {
+   jffs2_free_full_dirent(fd);
+   JFFS2_ERROR("short read: wanted %d bytes, got %zd\n",
+   rd->nsize - already, read);
return -EIO;
+   }
 
if (unlikely(err)) {
JFFS2_ERROR("read remainder of name: error %d\n", err);
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 16/29] jffs2: fix unbalanced locking

2018-07-05 Thread Sebastian Huber
From: Brian Norris 

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 
Cc: David Woodhouse 
Cc: Artem Bityutskiy 
Cc: Andrew Morton 
Signed-off-by: Brian Norris 

4   23  cpukit/libfs/src/jffs2/src/readinode.c

diff --git a/cpukit/libfs/src/jffs2/src/readinode.c 
b/cpukit/libfs/src/jffs2/src/readinode.c
index 3314a61885..69ab7709f8 100644
--- a/cpukit/libfs/src/jffs2/src/readinode.c
+++ b/cpukit/libfs/src/jffs2/src/readinode.c
@@ -1212,17 +1212,13 @@ static int jffs2_do_read_inode_internal(struct 
jffs2_sb_info *c,
JFFS2_ERROR("failed to read from flash: error %d, %zd of %zd 
bytes read\n",
ret, retlen, sizeof(*latest_node));
/* FIXME: If this fails, there seems to be a memory leak. Find 
it. */
-   mutex_unlock(&f->sem);
-   jffs2_do_clear_inode(c, f);
-   return ret?ret:-EIO;
+   return ret ? ret : -EIO;
}
 
crc = crc32(0, latest_node, sizeof(*latest_node)-8);
if (crc != je32_to_cpu(latest_node->node_crc)) {
JFFS2_ERROR("CRC failed for read_inode of inode %u at physical 
location 0x%x\n",
f->inocache->ino, ref_offset(rii.latest_ref));
-   mutex_unlock(&f->sem);
-   jffs2_do_clear_inode(c, f);
return -EIO;
}
 
@@ -1259,16 +1255,11 @@ static int jffs2_do_read_inode_internal(struct 
jffs2_sb_info *c,
 * keep in RAM to facilitate quick follow symlink
 * operation. */
uint32_t csize = je32_to_cpu(latest_node->csize);
-   if (csize > JFFS2_MAX_NAME_LEN) {
-   mutex_unlock(&f->sem);
-   jffs2_do_clear_inode(c, f);
+   if (csize > JFFS2_MAX_NAME_LEN)
return -ENAMETOOLONG;
-   }
f->target = kmalloc(csize + 1, GFP_KERNEL);
if (!f->target) {
JFFS2_ERROR("can't allocate %u bytes of memory 
for the symlink target path cache\n", csize);
-   mutex_unlock(&f->sem);
-   jffs2_do_clear_inode(c, f);
return -ENOMEM;
}
 
@@ -1280,8 +1271,6 @@ static int jffs2_do_read_inode_internal(struct 
jffs2_sb_info *c,
ret = -EIO;
kfree(f->target);
f->target = NULL;
-   mutex_unlock(&f->sem);
-   jffs2_do_clear_inode(c, f);
return ret;
}
 
@@ -1298,15 +1287,11 @@ static int jffs2_do_read_inode_internal(struct 
jffs2_sb_info *c,
if (f->metadata) {
JFFS2_ERROR("Argh. Special inode #%u with mode 0%o had 
metadata node\n",
   f->inocache->ino, 
jemode_to_cpu(latest_node->mode));
-   mutex_unlock(&f->sem);
-   jffs2_do_clear_inode(c, f);
return -EIO;
}
if (!frag_first(&f->fragtree)) {
JFFS2_ERROR("Argh. Special inode #%u with mode 0%o has 
no fragments\n",
   f->inocache->ino, 
jemode_to_cpu(latest_node->mode));
-   mutex_unlock(&f->sem);
-   jffs2_do_clear_inode(c, f);
return -EIO;
}
/* ASSERT: f->fraglist != NULL */
@@ -1314,8 +1299,6 @@ static int jffs2_do_read_inode_internal(struct 
jffs2_sb_info *c,
JFFS2_ERROR("Argh. Special inode #%u with mode 0x%x had 
more than one node\n",
   f->inocache->ino, 
jemode_to_cpu(latest_node->mode));
/* FIXME: Deal with it - check crc32, check for 
duplicate node, check times and discard the older one */
-   mutex_unlock(&f->sem);
-   jffs2_do_clear_inode(c, f);
return -EIO;
}
/* OK. We're happy */
@@ -1409,10 +1392,8 @@ int jffs2_do_crccheck_inode(struct jffs2_sb_info *c, 
struct jffs2_inode_cache *i
f->inocache = ic;
 
ret = jffs2_do_read_inode_internal(c, f, &n);
-   

[PATCH 12/29] kill wbuf_queued/wbuf_dwork_lock

2018-07-05 Thread Sebastian Huber
From: Al Viro 

schedule_delayed_work() happening when the work is already pending is
a cheap no-op.  Don't bother with ->wbuf_queued logics - it's both
broken (cancelling ->wbuf_dwork leaves it set, as spotted by Jeff Harris)
and pointless.  It's cheaper to let schedule_delayed_work() handle that
case.

Reported-by: Jeff Harris 
Tested-by: Jeff Harris 
Cc: sta...@vger.kernel.org
Signed-off-by: Al Viro 

0   2   cpukit/libfs/src/jffs2/src/jffs2_fs_sb.h

diff --git a/cpukit/libfs/src/jffs2/src/jffs2_fs_sb.h 
b/cpukit/libfs/src/jffs2/src/jffs2_fs_sb.h
index 413ef89c2d..046fee8b6e 100644
--- a/cpukit/libfs/src/jffs2/src/jffs2_fs_sb.h
+++ b/cpukit/libfs/src/jffs2/src/jffs2_fs_sb.h
@@ -134,8 +134,6 @@ struct jffs2_sb_info {
struct rw_semaphore wbuf_sem;   /* Protects the write buffer */
 
struct delayed_work wbuf_dwork; /* write-buffer write-out work */
-   int wbuf_queued;/* non-zero delayed work is queued */
-   spinlock_t wbuf_dwork_lock; /* protects wbuf_dwork and and 
wbuf_queued */
 
unsigned char *oobbuf;
int oobavail; /* How many bytes are available for JFFS2 in OOB */
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 08/29] jffs2: avoid soft-lockup in jffs2_reserve_space_gc()

2018-07-05 Thread Sebastian Huber
From: Li Zefan 

We triggered soft-lockup under stress test on 2.6.34 kernel.

BUG: soft lockup - CPU#1 stuck for 60009ms! [lockf2.test:14488]
...
[] (jffs2_do_reserve_space+0x420/0x440 [jffs2])
[] (jffs2_reserve_space_gc+0x34/0x78 [jffs2])
[] (jffs2_garbage_collect_dnode.isra.3+0x264/0x478 [jffs2])
[] (jffs2_garbage_collect_pass+0x9c0/0xe4c [jffs2])
[] (jffs2_reserve_space+0x104/0x2a8 [jffs2])
[] (jffs2_write_inode_range+0x5c/0x4d4 [jffs2])
[] (jffs2_write_end+0x198/0x2c0 [jffs2])
[] (generic_file_buffered_write+0x158/0x200)
[] (__generic_file_aio_write+0x3a4/0x414)
[] (generic_file_aio_write+0x5c/0xbc)
[] (do_sync_write+0x98/0xd4)
[] (vfs_write+0xa8/0x150)
[] (sys_write+0x3c/0xc0)]

Fix this by adding a cond_resched() in the while loop.

[a...@linux-foundation.org: don't initialize `ret']
Signed-off-by: Li Zefan 
Cc: David Woodhouse 
Cc: Artem Bityutskiy 
Cc: 
Signed-off-by: Andrew Morton 
Signed-off-by: Brian Norris 

9   4   cpukit/libfs/src/jffs2/src/nodemgmt.c

diff --git a/cpukit/libfs/src/jffs2/src/nodemgmt.c 
b/cpukit/libfs/src/jffs2/src/nodemgmt.c
index 6cb8dc4d6f..012a4f30d0 100644
--- a/cpukit/libfs/src/jffs2/src/nodemgmt.c
+++ b/cpukit/libfs/src/jffs2/src/nodemgmt.c
@@ -214,20 +214,25 @@ out:
 int jffs2_reserve_space_gc(struct jffs2_sb_info *c, uint32_t minsize,
   uint32_t *len, uint32_t sumsize)
 {
-   int ret = -EAGAIN;
+   int ret;
minsize = PAD(minsize);
 
jffs2_dbg(1, "%s(): Requested 0x%x bytes\n", __func__, minsize);
 
-   spin_lock(&c->erase_completion_lock);
-   while(ret == -EAGAIN) {
+   while (true) {
+   spin_lock(&c->erase_completion_lock);
ret = jffs2_do_reserve_space(c, minsize, len, sumsize);
if (ret) {
jffs2_dbg(1, "%s(): looping, ret is %d\n",
  __func__, ret);
}
+   spin_unlock(&c->erase_completion_lock);
+
+   if (ret == -EAGAIN)
+   cond_resched();
+   else
+   break;
}
-   spin_unlock(&c->erase_completion_lock);
if (!ret)
ret = jffs2_prealloc_raw_node_refs(c, c->nextblock, 1);
 
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 14/29] jffs2: compr_rubin: Remove unused function

2018-07-05 Thread Sebastian Huber
From: Rickard Strandqvist 

Remove the function pulledbits() that is not used anywhere.

This was partially found by using a static code analysis program called 
cppcheck.

Signed-off-by: Rickard Strandqvist 
Reviewed-by: Richard Weinberger 
Signed-off-by: Brian Norris 

0   5   cpukit/libfs/src/jffs2/src/compr_rubin.c

diff --git a/cpukit/libfs/src/jffs2/src/compr_rubin.c 
b/cpukit/libfs/src/jffs2/src/compr_rubin.c
index 424891cab4..91a1f354f5 100644
--- a/cpukit/libfs/src/jffs2/src/compr_rubin.c
+++ b/cpukit/libfs/src/jffs2/src/compr_rubin.c
@@ -86,11 +86,6 @@ static inline int pullbit(struct pushpull *pp)
return bit;
 }
 
-static inline int pulledbits(struct pushpull *pp)
-{
-   return pp->ofs;
-}
-
 
 static void init_rubin(struct rubin_state *rs, int div, int *bits)
 {
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 29/29] jffs2: Add README

2018-07-05 Thread Sebastian Huber
Add README to document the corrspending Linux version and the update
procedure.

Close #3465.

35  0   cpukit/libfs/src/jffs2/README

diff --git a/cpukit/libfs/src/jffs2/README b/cpukit/libfs/src/jffs2/README
new file mode 100644
index 00..7d9c9f41b2
--- /dev/null
+++ b/cpukit/libfs/src/jffs2/README
@@ -0,0 +1,35 @@
+This directory contains a port of the JFFS2 file system from Linux v4.17.
+
+To update to a newer Linux version use this command in a Git clone of Linux to
+generate the relevant patches:
+
+  git format-patch v4.17..v9.99 --
+include/uapi/linux/jffs2.h \
+fs/jffs2/LICENCE \
+fs/jffs2/acl.h \
+fs/jffs2/build.c \
+fs/jffs2/compr.c \
+fs/jffs2/compr.h \
+fs/jffs2/compr_rtime.c \
+fs/jffs2/compr_rubin.c \
+fs/jffs2/compr_zlib.c \
+fs/jffs2/debug.c \
+fs/jffs2/debug.h \
+fs/jffs2/erase.c \
+fs/jffs2/gc.c \
+fs/jffs2/jffs2_fs_i.h \
+fs/jffs2/jffs2_fs_sb.h \
+fs/jffs2/nodelist.c \
+fs/jffs2/nodelist.h \
+fs/jffs2/nodemgmt.c \
+fs/jffs2/read.c \
+fs/jffs2/readinode.c \
+fs/jffs2/scan.c \
+fs/jffs2/summary.h \
+fs/jffs2/write.c \
+fs/jffs2/xattr.h
+
+The patches need a transformation of file paths from Linux to RTEMS:
+
+  sed -i 's%/include/uapi%/cpukit/libfs/src/jffs2/include%g' 00*
+  sed -i 's%/fs/jffs2%/cpukit/libfs/src/jffs2/src%g' 00*
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 06/29] jffs2: use generic posix ACL infrastructure

2018-07-05 Thread Sebastian Huber
From: Christoph Hellwig 

Also don't bother to set up a .get_acl method for symlinks as we do not
support access control (ACLs or even mode bits) for symlinks in Linux.

Signed-off-by: Christoph Hellwig 
Signed-off-by: Al Viro 

2   5   cpukit/libfs/src/jffs2/src/acl.h

diff --git a/cpukit/libfs/src/jffs2/src/acl.h b/cpukit/libfs/src/jffs2/src/acl.h
index 9b477246f2..2e2b5745c3 100644
--- a/cpukit/libfs/src/jffs2/src/acl.h
+++ b/cpukit/libfs/src/jffs2/src/acl.h
@@ -27,17 +27,14 @@ struct jffs2_acl_header {
 #ifdef CONFIG_JFFS2_FS_POSIX_ACL
 
 struct posix_acl *jffs2_get_acl(struct inode *inode, int type);
-extern int jffs2_acl_chmod(struct inode *);
+int jffs2_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 extern int jffs2_init_acl_pre(struct inode *, struct inode *, umode_t *);
 extern int jffs2_init_acl_post(struct inode *);
 
-extern const struct xattr_handler jffs2_acl_access_xattr_handler;
-extern const struct xattr_handler jffs2_acl_default_xattr_handler;
-
 #else
 
 #define jffs2_get_acl  (NULL)
-#define jffs2_acl_chmod(inode) (0)
+#define jffs2_set_acl  (NULL)
 #define jffs2_init_acl_pre(dir_i,inode,mode)   (0)
 #define jffs2_init_acl_post(inode) (0)
 
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 15/29] jffs2: fix handling of corrupted summary length

2018-07-05 Thread Sebastian Huber
From: Chen Jie 

sm->offset maybe wrong but magic maybe right, the offset do not have CRC.

Badness at c00c7580 [verbose debug info unavailable]
NIP: c00c7580 LR: c00c718c CTR: 0014
REGS: df07bb40 TRAP: 0700   Not tainted  (2.6.34.13-WR4.3.0.0_standard)
MSR: 00029000   CR: 22084f84  XER: 
TASK = df84d6e0[908] 'mount' THREAD: df07a000
GPR00: 0001 df07bbf0 df84d6e0  0001  df07bb58 0041
GPR08: 0041 c0638860  0010 22084f88 100636c8 df814ff8 
GPR16: df84d6e0 dfa558cc c05adb90 0048 c0452d30  000240d0 40d0
GPR24: 0014 c05ae734 c05be2e0  0001   c05ae730
NIP [c00c7580] __alloc_pages_nodemask+0x4d0/0x638
LR [c00c718c] __alloc_pages_nodemask+0xdc/0x638
Call Trace:
[df07bbf0] [c00c718c] __alloc_pages_nodemask+0xdc/0x638 (unreliable)
[df07bc90] [c00c7708] __get_free_pages+0x20/0x48
[df07bca0] [c00f4a40] __kmalloc+0x15c/0x1ec
[df07bcd0] [c01fc880] jffs2_scan_medium+0xa58/0x14d0
[df07bd70] [c01ff38c] jffs2_do_mount_fs+0x1f4/0x6b4
[df07bdb0] [c020144c] jffs2_do_fill_super+0xa8/0x260
[df07bdd0] [c020230c] jffs2_fill_super+0x104/0x184
[df07be00] [c0335814] get_sb_mtd_aux+0x9c/0xec
[df07be20] [c033596c] get_sb_mtd+0x84/0x1e8
[df07be60] [c0201ed0] jffs2_get_sb+0x1c/0x2c
[df07be70] [c0103898] vfs_kern_mount+0x78/0x1e8
[df07bea0] [c0103a58] do_kern_mount+0x40/0x100
[df07bec0] [c011fe90] do_mount+0x240/0x890
[df07bf10] [c0120570] sys_mount+0x90/0xd8
[df07bf40] [c00110d8] ret_from_syscall+0x0/0x4

=== Exception: c01 at 0xff61a34
LR = 0x100135f0
Instruction dump:
3885 3860 48010f41 4bfffe1c 4bfc2d15 4bfffe8c 72e90200 4082fc28
3d20c064 39298860 8809000d 6801 <0f00> 2f80 419efc0c 3801
mount: mounting /dev/mtdblock3 on /common failed: Input/output error

Signed-off-by: Chen Jie 
Cc: 
Signed-off-by: Andrew Morton 
Signed-off-by: David Woodhouse 

5   0   cpukit/libfs/src/jffs2/src/scan.c

diff --git a/cpukit/libfs/src/jffs2/src/scan.c 
b/cpukit/libfs/src/jffs2/src/scan.c
index 1cfa548335..10bf007819 100644
--- a/cpukit/libfs/src/jffs2/src/scan.c
+++ b/cpukit/libfs/src/jffs2/src/scan.c
@@ -513,6 +513,10 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, 
struct jffs2_eraseblo
sumlen = c->sector_size - 
je32_to_cpu(sm->offset);
sumptr = buf + buf_size - sumlen;
 
+   /* sm->offset maybe wrong but MAGIC maybe right 
*/
+   if (sumlen > c->sector_size)
+   goto full_scan;
+
/* Now, make sure the summary itself is 
available */
if (sumlen > buf_size) {
/* Need to kmalloc for this. */
@@ -547,6 +551,7 @@ static int jffs2_scan_eraseblock (struct jffs2_sb_info *c, 
struct jffs2_eraseblo
}
}
 
+full_scan:
buf_ofs = jeb->offset;
 
if (!buf_size) {
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 18/29] tree wide: use kvfree() than conditional kfree()/vfree()

2018-07-05 Thread Sebastian Huber
From: Tetsuo Handa 

There are many locations that do

  if (memory_was_allocated_by_vmalloc)
vfree(ptr);
  else
kfree(ptr);

but kvfree() can handle both kmalloc()ed memory and vmalloc()ed memory
using is_vmalloc_addr().  Unless callers have special reasons, we can
replace this branch with kvfree().  Please check and reply if you found
problems.

Signed-off-by: Tetsuo Handa 
Acked-by: Michal Hocko 
Acked-by: Jan Kara 
Acked-by: Russell King 
Reviewed-by: Andreas Dilger 
Acked-by: "Rafael J. Wysocki" 
Acked-by: David Rientjes 
Cc: "Luck, Tony" 
Cc: Oleg Drokin 
Cc: Boris Petkov 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 

0   0   cpukit/libfs/src/jffs2/include/linux/mm.h
1   0   cpukit/libfs/src/jffs2/include/linux/slab.h
2   6   cpukit/libfs/src/jffs2/src/build.c

diff --git a/cpukit/libfs/src/jffs2/include/linux/mm.h 
b/cpukit/libfs/src/jffs2/include/linux/mm.h
new file mode 100644
index 00..e69de29bb2
diff --git a/cpukit/libfs/src/jffs2/include/linux/slab.h 
b/cpukit/libfs/src/jffs2/include/linux/slab.h
index 00ddbb274a..532586e210 100644
--- a/cpukit/libfs/src/jffs2/include/linux/slab.h
+++ b/cpukit/libfs/src/jffs2/include/linux/slab.h
@@ -8,6 +8,7 @@
 #define kzalloc(x, y) calloc(1, x)
 #define kmalloc(x, y) malloc(x)
 #define kfree(x) free(x)
+#define kvfree(x) free(x)
 #define vmalloc(x) malloc(x)
 #define vfree(x) free(x)
 
diff --git a/cpukit/libfs/src/jffs2/src/build.c 
b/cpukit/libfs/src/jffs2/src/build.c
index b16f2c9fe7..cbc424283c 100644
--- a/cpukit/libfs/src/jffs2/src/build.c
+++ b/cpukit/libfs/src/jffs2/src/build.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include  /* kvfree() */
 #include "nodelist.h"
 
 static void jffs2_build_remove_unlinked_inode(struct jffs2_sb_info *,
@@ -385,12 +386,7 @@ int jffs2_do_mount_fs(struct jffs2_sb_info *c)
return 0;
 
  out_free:
-#ifndef __ECOS
-   if (jffs2_blocks_use_vmalloc(c))
-   vfree(c->blocks);
-   else
-#endif
-   kfree(c->blocks);
+   kvfree(c->blocks);
 
return ret;
 }
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH 03/29] linux: Simplify

2018-07-05 Thread Sebastian Huber
Remove the placeholder struct rb_node and use RBTree_Node directly via
some C pre-processor defines to adjust the member names.

Update #3465.

37  45  cpukit/include/linux/rbtree.h
2   2   cpukit/libfs/src/jffs2/src/readinode.c

diff --git a/cpukit/include/linux/rbtree.h b/cpukit/include/linux/rbtree.h
index 2268434939..e1da2c7b9a 100644
--- a/cpukit/include/linux/rbtree.h
+++ b/cpukit/include/linux/rbtree.h
@@ -17,40 +17,36 @@
 
 #include 
 
-struct rb_node {
-  struct rb_node *rb_left;
-  struct rb_node *rb_right;
-  struct rb_node *rb_parent;
-  int rb_color;
-};
-
-RTEMS_STATIC_ASSERT(
-  sizeof( struct rb_node ) == sizeof( RBTree_Node ),
-  rb_node_size
-);
-
-RTEMS_STATIC_ASSERT(
-  offsetof( struct rb_node, rb_left ) == offsetof( RBTree_Node, Node.rbe_left 
),
-  rb_node_left
-);
+#define rb_node RBTree_Node
 
-RTEMS_STATIC_ASSERT(
-  offsetof( struct rb_node, rb_right ) == offsetof( RBTree_Node, 
Node.rbe_right ),
-  rb_node_right
-);
+#define rb_left Node.rbe_left
 
-RTEMS_STATIC_ASSERT(
-  offsetof( struct rb_node, rb_parent ) == offsetof( RBTree_Node, 
Node.rbe_parent ),
-  rb_node_parent
-);
-
-RTEMS_STATIC_ASSERT(
-  offsetof( struct rb_node, rb_color ) == offsetof( RBTree_Node, 
Node.rbe_color ),
-  rb_node_color
-);
+#define rb_right Node.rbe_right
 
+/*
+ * Getting rid of this placeholder structure is a bit difficult.  The use of
+ * this placeholder struct may lead to bugs with link-time optimization due to
+ * a strict aliasing violation.
+ *
+ * A common use of this API is a direct access of the rb_node member to get the
+ * root node of the tree. So, this cannot be changed.
+ *
+ * The red-black tree implementation is provided by  and we have
+ *
+ * struct RBTree_Control {
+ *   struct RBTree_Node *rbh_root;
+ * };
+ *
+ * The member name rbh_root is fixed by the  API.  To use
+ * RBTree_Control directly we would need two defines:
+ *
+ * #define rb_root RBTree_Control
+ * #define rb_node rbh_root
+ *
+ * We already have an rb_node define to RBTree_Node, see above.
+ */
 struct rb_root {
-  struct rb_node *rb_node;
+  RBTree_Node *rb_node;
 };
 
 RTEMS_STATIC_ASSERT(
@@ -70,32 +66,32 @@ RTEMS_STATIC_ASSERT(
 
 static inline void rb_insert_color( struct rb_node *node, struct rb_root *root)
 {
-  _RBTree_Insert_color( (RBTree_Control *) root, (RBTree_Node *) node );
+  _RBTree_Insert_color( (RBTree_Control *) root, node );
 }
 
 static inline void rb_erase( struct rb_node *node, struct rb_root *root )
 {
-  _RBTree_Extract( (RBTree_Control *) root, (RBTree_Node *) node );
+  _RBTree_Extract( (RBTree_Control *) root, node );
 }
 
 static inline struct rb_node *rb_next( struct rb_node *node )
 {
-  return (struct rb_node *) _RBTree_Successor( (RBTree_Node *) node );
+  return _RBTree_Successor( node );
 }
 
 static inline struct rb_node *rb_prev( struct rb_node *node )
 {
-  return (struct rb_node *) _RBTree_Predecessor( (RBTree_Node *) node );
+  return _RBTree_Predecessor( node );
 }
 
 static inline struct rb_node *rb_first( struct rb_root *root )
 {
-  return (struct rb_node *) _RBTree_Minimum( (RBTree_Control *) root );
+  return _RBTree_Minimum( (RBTree_Control *) root );
 }
 
 static inline struct rb_node *rb_last( struct rb_root *root )
 {
-  return (struct rb_node *) _RBTree_Maximum( (RBTree_Control *) root );
+  return _RBTree_Maximum( (RBTree_Control *) root );
 }
 
 static inline void rb_replace_node(
@@ -106,8 +102,8 @@ static inline void rb_replace_node(
 {
   _RBTree_Replace_node(
 (RBTree_Control *) root,
-(RBTree_Node *) victim,
-(RBTree_Node *) replacement
+victim,
+replacement
   );
 }
 
@@ -117,17 +113,13 @@ static inline void rb_link_node(
   struct rb_node **link
 )
 {
-  _RBTree_Initialize_node( (RBTree_Node *) node );
-  _RBTree_Add_child(
-(RBTree_Node *) node,
-(RBTree_Node *) parent,
-(RBTree_Node **) link
-  );
+  _RBTree_Initialize_node( node );
+  _RBTree_Add_child( node, parent, link );
 }
 
 static inline struct rb_node *rb_parent( struct rb_node *node )
 {
-  return (struct rb_node *) _RBTree_Parent( (RBTree_Node *) node );
+  return _RBTree_Parent( node );
 }
 
 #endif /* _LINUX_RBTREE_H */
diff --git a/cpukit/libfs/src/jffs2/src/readinode.c 
b/cpukit/libfs/src/jffs2/src/readinode.c
index a166da9c69..9147169a0a 100644
--- a/cpukit/libfs/src/jffs2/src/readinode.c
+++ b/cpukit/libfs/src/jffs2/src/readinode.c
@@ -422,8 +422,8 @@ static void eat_last(struct rb_root *root, struct rb_node 
*node)
node->rb_left->__rb_parent_color = node->__rb_parent_color;
 #else /* __rtems__ */
{
-   node->rb_left->rb_parent = node->rb_parent;
-   node->rb_left->rb_color = node->rb_color;
+   node->rb_left->Node.rbe_parent = node->Node.rbe_parent;
+   node->rb_left->Node.rbe_color = node->Node.rbe_color;
}
 #endif /* __rtems__ */
 }
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mai

[PATCH 04/29] linux: Add rbtree_postorder_for_each_entry_safe()

2018-07-05 Thread Sebastian Huber
Update #3465.

16  0   cpukit/include/linux/rbtree.h
22  0   testsuites/sptests/sprbtree01/init.c

diff --git a/cpukit/include/linux/rbtree.h b/cpukit/include/linux/rbtree.h
index e1da2c7b9a..53c777e8c1 100644
--- a/cpukit/include/linux/rbtree.h
+++ b/cpukit/include/linux/rbtree.h
@@ -122,4 +122,20 @@ static inline struct rb_node *rb_parent( struct rb_node 
*node )
   return _RBTree_Parent( node );
 }
 
+#define rbtree_postorder_for_each_entry_safe( node, next, root, field ) \
+  for ( \
+node = _RBTree_Postorder_first( \
+  (RBTree_Control *) root, \
+  (size_t) ( (char *) &node->field - (char *) node ) \
+); \
+node != NULL && ( \
+  next = _RBTree_Postorder_next( \
+&node->field, \
+(size_t) ( (char *) &node->field - (char *) node ) \
+  ), \
+  node != NULL \
+); \
+node = next \
+  )
+
 #endif /* _LINUX_RBTREE_H */
diff --git a/testsuites/sptests/sprbtree01/init.c 
b/testsuites/sptests/sprbtree01/init.c
index 7a969cfa4a..fd45a3654a 100644
--- a/testsuites/sptests/sprbtree01/init.c
+++ b/testsuites/sptests/sprbtree01/init.c
@@ -14,6 +14,8 @@
 #include 
 #include 
 
+#include 
+
 const char rtems_test_name[] = "SPRBTREE 1";
 
 /* forward declarations to avoid warnings */
@@ -1911,6 +1913,7 @@ static void postorder_tree_check(
 )
 {
   test_node *node;
+  test_node *next;
   size_t i;
 
   node = _RBTree_Postorder_first( tree, offsetof( test_node, Node ) );
@@ -1921,6 +1924,25 @@ static void postorder_tree_check(
   }
 
   rtems_test_assert( node == NULL );
+
+  i = 0;
+  next = NULL;
+
+  rbtree_postorder_for_each_entry_safe( node, next, tree, Node ) {
+rtems_test_assert( node == &node_array[ i ] );
+
+if ( i < pt->node_count - 1 ) {
+  rtems_test_assert( next == &node_array[ i + 1 ] );
+} else {
+  rtems_test_assert( next == NULL );
+}
+
+++i;
+  }
+
+  rtems_test_assert( i == pt->node_count );
+  rtems_test_assert( node == NULL );
+  rtems_test_assert( next == NULL );
 }
 
 static void test_rbtree_postorder( void )
-- 
2.13.7

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Properties of ChangeLog/Commit Messages

2018-07-05 Thread Joel Sherrill
Hi

Richard Kenner (old GCC maintainer) listed these in a post and I thought it
was worth passing along:

=
In other words, there are three levels (of information in ChangeLog
entries) here:

(1) What the code currently does
(2) How we changed the code from what it did to what it does
(3) Why we made the change

#1 is always in the code and #2 is always in the ChangeLog.  #3
*should* be in the ChangeLog, but isn't always.  However #2 is very
useful information.

This is especially valuable because it gives the intent of the change in
the case where an error was made (say, some part of the change was missed).
It's much harder to figure out intent from even the diff and certainly
impossible from the code itself.
===

Richard is right that the commit message/ChangeLog is supposed to
provide insight into the why of the change. Referencing a PR can be
part of that.

--joel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

jffs2 changes and Coverity issue in porting code

2018-07-05 Thread Joel Sherrill
Hi

By any chance, do any of the jffs2 updates pick up changes
to that method in the porting layer which Coverity thought
had an issue?

I know the code is the same across multiple OSes and you
didn't invent or modify it porting jffs2 to RTEMS. Just curious
if the situation might have changed.

--joel
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

[GSoC - x86_64] Minimal BSP to review

2018-07-05 Thread Amaan Cheval
Hi!

I've made a pull-request that's nearly complete on Github:
https://github.com/AmaanC/rtems-gsoc18/pull/1/

I'd appreciate a review before I squash it into 2 commits (1. minimal
BSP reaching Init task, and 2. adding the NS16550 console driver) and
submit the squashed patches to devel@ after this review.

I'll work on a blog post summarizing the work so far and the BSP
specific user documentation in the meantime.

Cheers,
Amaan
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [GSoC - x86_64] Minimal BSP to review

2018-07-05 Thread Sebastian Huber

Hello Amaan,

I think it is quite confusing to review the individual commit. I will 
review the final patch set.


Just one thing:

x86_64-rtems5-ld --verbose | head -n 20
GNU ld (GNU Binutils) 2.30
  Supported emulations:
   elf_x86_64
   elf_i386
   elf_iamcu
   elf32_x86_64
   elf_l1om
   elf_k1om
using internal linker script:
==
/* Script for -z combreloc: combine and sort reloc sections */
/* Copyright (C) 2014-2018 Free Software Foundation, Inc.
   Copying and distribution of this script, with or without modification,
   are permitted in any medium without royalty provided the copyright
   notice and this notice are preserved.  */
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
  "elf64-x86-64")
OUTPUT_ARCH(i386:x86-64)
ENTRY(_start)
SEARCH_DIR("/build/rtems/5/x86_64-rtems5/lib");

Please add the FSF notice to your file if necessary.

--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [GSoC - x86_64] Minimal BSP to review

2018-07-05 Thread Amaan Cheval
Hi!

Yeah, the individual commits aren't logical at all. I just thought we
could review the actual code contents (in the "files changed" tab) on
Github (https://github.com/AmaanC/rtems-gsoc18/pull/1/files). Is this
what you meant by "final patchset"?

Once this PR is polished up sufficiently, I can submit the squashed,
rebased commits to devel - that way we maintain the commit history for
how things progressed temporally, and still have the logical commits
we want upstream.

If you'd prefer, I can squash on Github too (it just means I'd then
for a brief period not have the "daily" commit branch we aim to have
for GSoC, as I'd have to rebase to make changes instead of adding new
commits to the daily branch to indicate more "work done"). Let me know
if you prefer this!

Thanks for catching the missing copyright in linkcmds!

On Thu, Jul 5, 2018 at 7:16 PM, Sebastian Huber
 wrote:
> Hello Amaan,
>
> I think it is quite confusing to review the individual commit. I will review
> the final patch set.
>
> Just one thing:
>
> x86_64-rtems5-ld --verbose | head -n 20
> GNU ld (GNU Binutils) 2.30
>   Supported emulations:
>elf_x86_64
>elf_i386
>elf_iamcu
>elf32_x86_64
>elf_l1om
>elf_k1om
> using internal linker script:
> ==
> /* Script for -z combreloc: combine and sort reloc sections */
> /* Copyright (C) 2014-2018 Free Software Foundation, Inc.
>Copying and distribution of this script, with or without modification,
>are permitted in any medium without royalty provided the copyright
>notice and this notice are preserved.  */
> OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
>   "elf64-x86-64")
> OUTPUT_ARCH(i386:x86-64)
> ENTRY(_start)
> SEARCH_DIR("/build/rtems/5/x86_64-rtems5/lib");
>
> Please add the FSF notice to your file if necessary.
>
> --
> Sebastian Huber, embedded brains GmbH
>
> Address : Dornierstr. 4, D-82178 Puchheim, Germany
> Phone   : +49 89 189 47 41-16
> Fax : +49 89 189 47 41-09
> E-Mail  : sebastian.hu...@embedded-brains.de
> PGP : Public key available on request.
>
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: Gcov support in Covoar

2018-07-05 Thread Vijay Kumar Banerjee
I think that the whole gcov support needs to be reworked.
I was looking into how llvm outputs their gcov data in gcda file
format here
https://github.com/llvm-mirror/compiler-rt/blob/master/lib/profile/GCDAProfiling.c

I need some help in understanding the workflow of how covoar
gets the trace input and how that is dumped into a gcda file.

What files are involved in the process (other than GcovData.cc and
GcovFunctionData.cc ) and what are their roles ?

I feel that this is very difficult to be able to do the whole work within
the GSoC period and the work will go on post GSoC as well.
So we need to set milestones specific to GSoC and then continue
from there post GSoC.

On 5 July 2018 at 00:50, Joel Sherrill  wrote:

>
>
> On Wed, Jul 4, 2018, 1:46 PM Vijay Kumar Banerjee <
> vijaykumar9...@gmail.com> wrote:
>
>> On 4 July 2018 at 22:37, Joel Sherrill  wrote:
>>
>>>
>>>
>>> On Wed, Jul 4, 2018, 3:06 AM Chris Johns  wrote:
>>>


 On 4/7/18 5:55 pm, Vijay Kumar Banerjee wrote:
 > On 4 July 2018 at 13:09, Chris Johns >>> > > wrote:
 >
 > On 4/7/18 5:38 pm, Chris Johns wrote:
 > > On 4/7/18 4:52 pm, Vijay Kumar Banerjee wrote:
 > >>
 > >> I'm starting this thread for discussions on the gcov support
 > >> in covoar.
 > >>
 > >> Current status is that the code in it (like in GcovData.cc)
 remained untouched
 > >> for a long time and it had not been updated after the source
 tree reorganization
 > >> which is why it runs into segmentation
 > >> fault while trying to find the source files.
 > >>
 > >> Joel was suggesting to copy the file gcov-io.h from the gcc
 > >> source after a license discussion here.
 > >
 > > What license the file's license?
 >
 > Sorry .. What is the file's license?
 >
 > GPL version 3

 This license is not suitable.

>>>
>>> It has the runtime exception and is the only file that defines the
>>> format of gcno and (need to double-check) gcda file. It does not
>>> contaminate anything.
>>>
>>> I don't see anyway to interpret gcno or write gcda data otherwise.
>>>
>>> How does llvm address this? Don't that have the same issue?
>>>
>>> llvm defines it in GCOV.h file in llvm/ProfileData/ under the license
>> it's mentioned there that it's distributed under University of Illinois
>> Open Source License
>> https://github.com/llvm-mirror/llvm/blob/master/
>> include/llvm/ProfileData/GCOV.h
>> 
>>
>
> That would be the preferred way to get this header. Is it technically
> acceptable?
>
> Chris.. license acceptable to you?
>
>>
>> Ultimately we have two file formats that we have to deal with that GCC
>>> for sure defines and llvm might also.
>>>
>>>
 > > We are aiming to have all code under the RTEMS Tools under a
 BSD or compatible
 > > license. Are there other options that have a more suitable
 license?

>>>
>>> Llvm would be the only option but this has the rules time exception like
>>> the RTEMS historical license so it non-viral.
>>>
>>> A hack would be to ensure they are installed with the RTEMS GCC by the
>>> RSB. But that would be lifting a file out of the GCC source and  one from
>>> the build tree that are normally not installed. We could ask about GCC
>>> doing that.
>>>
>>> > >
 > > Also, could you please explain how gcov fits into the coverage
 testing?
 > >
 >
 > gcov is a test coverage program by gcc that generates
 statement-by-statement
 > profiling.
 > (https://gcc.gnu.org/onlinedocs/gcc/Gcov-Intro.html)

 Yes.

 > once we're able to generate gcov reports we can run graphical tools
 like lcov or
 > gcovr to generate html and xml reports with detailed coverage data.
 > an example of lcov report:
 > http://ltp.sourceforge.net/coverage/lcov/output/example/
 methods/iterate.c.gcov.html
 >

 Do you want to export gcov files from the other trace formats we handle?

>>>
>>> Gcov reads gcda files for execution information. Rather than the
>>> executable being instrumented and writing this during execution (libgcov),
>>> covoar generates gcda files for unmodified executables using simulator
>>> trace information. But you have to read gcno files and write gcda files.
>>>
>>>
>>>
 How does this fit into the RTEMS Tester tool?

>>>
>>> If you want to run gcov or lcov on uninstrumented executables, then
>>> covoar has to read gcno and write gcda files. And we have to then run gcov
>>> or lcov as normal.
>>>
>>> It is the path to another report format.
>>>

 Chris
 ___
 devel mailing list
 devel@rtems.org
 http://lists.rtems.org/mailman/listinfo/devel
>>>
>>>
>>
___
devel ma

Re: [PATCH v3] coverage : Add support to run coverage in supported bsp without extra options

2018-07-05 Thread Vijay Kumar Banerjee
Hello Chris,

If you find some time, please review this patch.
It's a small patch but it's important since it affects how the command
will look like.

please review if this patch is alright or we need to have a different
approach.

Thanks
On 3 July 2018 at 20:30, Vijay Kumar Banerjee 
wrote:

> Close #3440
> ---
>  tester/rt/test.py| 21 ++---
>  tester/rtems/testing/bsps/leon3-qemu-cov.ini |  1 +
>  2 files changed, 15 insertions(+), 7 deletions(-)
>
> diff --git a/tester/rt/test.py b/tester/rt/test.py
> index 9214ad6..5d25d82 100644
> --- a/tester/rt/test.py
> +++ b/tester/rt/test.py
> @@ -232,7 +232,7 @@ def run(command_path = None):
>  '--filter': 'Glob that executables must match
> to run (default: ' +
>default_exefilter + ')',
>  '--stacktrace': 'Dump a stack trace on a user
> termination (^C)',
> -'--coverage':   'Perform coverage analysis of
> test executables.'}
> +'--coverage-sets':  'Perform coverage analysis for
> specific sets.'}
>  mailer.append_options(optargs)
>  opts = options.load(sys.argv,
>  optargs = optargs,
> @@ -283,14 +283,21 @@ def run(command_path = None):
>  raise error.general('RTEMS BSP not provided or an invalid
> option')
>  bsp = config.load(bsp[1], opts)
>  bsp_config = opts.defaults.expand(opts.defaults['tester'])
> -coverage_enabled = opts.find_arg('--coverage')
> +coverage_sets = opts.find_arg('--coverage-sets')
> +try:
> +coverage_enabled = opts.defaults.get('coverage')
> +except:
> +coverage_enabled = False
>  if coverage_enabled:
>  cov_trace = 'cov' in debug_trace.split(',')
> -if len(coverage_enabled) == 2:
> -coverage_runner = coverage.coverage_run(opts.defaults,
> -executables,
> -symbol_set =
> coverage_enabled[1],
> -trace = cov_trace)
> +if coverage_sets:
> +if len(coverage_sets) != 2:
> +raise error.general('No sets provided in
> --coverage-sets')
> +else:
> +coverage_runner = coverage.coverage_run(opts.
> defaults,
> +executables,
> +symbol_set =
> coverage_sets[1],
> +trace =
> cov_trace)
>  else:
>  coverage_runner = coverage.coverage_run(opts.defaults,
>  executables,
> diff --git a/tester/rtems/testing/bsps/leon3-qemu-cov.ini
> b/tester/rtems/testing/bsps/leon3-qemu-cov.ini
> index 2f89117..6462448 100644
> --- a/tester/rtems/testing/bsps/leon3-qemu-cov.ini
> +++ b/tester/rtems/testing/bsps/leon3-qemu-cov.ini
> @@ -38,3 +38,4 @@ target= sparc-rtems5
>  tester= %{_rtscripts}/qemu.cfg
>  bsp_qemu_opts = %{qemu_opts_base} -M leon3_generic
>  bsp_qemu_cov_opts = -exec-trace %{test_executable}.cov
> +coverage  = True
> --
> 2.14.4
>
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [GSoC - x86_64] Minimal BSP to review

2018-07-05 Thread Gedare Bloom
On Thu, Jul 5, 2018 at 10:02 AM, Amaan Cheval  wrote:
> Hi!
>
> Yeah, the individual commits aren't logical at all. I just thought we
> could review the actual code contents (in the "files changed" tab) on
> Github (https://github.com/AmaanC/rtems-gsoc18/pull/1/files). Is this
> what you meant by "final patchset"?
>
> Once this PR is polished up sufficiently, I can submit the squashed,
> rebased commits to devel - that way we maintain the commit history for
> how things progressed temporally, and still have the logical commits
> we want upstream.
>
> If you'd prefer, I can squash on Github too (it just means I'd then
> for a brief period not have the "daily" commit branch we aim to have
> for GSoC, as I'd have to rebase to make changes instead of adding new
> commits to the daily branch to indicate more "work done"). Let me know
> if you prefer this!
>

You can do your squash/fixup on a new branch, and then restart your
daily when needed. It is OK for the merger period to have less code
activity.

I took a quick look and commented on your github.

> Thanks for catching the missing copyright in linkcmds!
>
> On Thu, Jul 5, 2018 at 7:16 PM, Sebastian Huber
>  wrote:
>> Hello Amaan,
>>
>> I think it is quite confusing to review the individual commit. I will review
>> the final patch set.
>>
>> Just one thing:
>>
>> x86_64-rtems5-ld --verbose | head -n 20
>> GNU ld (GNU Binutils) 2.30
>>   Supported emulations:
>>elf_x86_64
>>elf_i386
>>elf_iamcu
>>elf32_x86_64
>>elf_l1om
>>elf_k1om
>> using internal linker script:
>> ==
>> /* Script for -z combreloc: combine and sort reloc sections */
>> /* Copyright (C) 2014-2018 Free Software Foundation, Inc.
>>Copying and distribution of this script, with or without modification,
>>are permitted in any medium without royalty provided the copyright
>>notice and this notice are preserved.  */
>> OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
>>   "elf64-x86-64")
>> OUTPUT_ARCH(i386:x86-64)
>> ENTRY(_start)
>> SEARCH_DIR("/build/rtems/5/x86_64-rtems5/lib");
>>
>> Please add the FSF notice to your file if necessary.
>>
>> --
>> Sebastian Huber, embedded brains GmbH
>>
>> Address : Dornierstr. 4, D-82178 Puchheim, Germany
>> Phone   : +49 89 189 47 41-16
>> Fax : +49 89 189 47 41-09
>> E-Mail  : sebastian.hu...@embedded-brains.de
>> PGP : Public key available on request.
>>
>> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
>>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Re: [PATCH] Rework to minimize and eventually eliminate RTEMS use of bsp_specs

2018-07-05 Thread Amaan Cheval
Hey, Joel!

The x86_64 BSP currently uses an empty bsp_specs file contingent on
(at least the x86-64 parts of) this email thread's patch making it
upstream to GCC, and making their way into the RSB.

2 options:
- 1. Make the upstream GCC commit (at least the parts adding
rtemself64.h, editing config.gcc, and "#if 0"ing out
gcc/config/rtems.h)
- 2. Use a bsp_specs in the new BSP for the merge now, and empty it out later

I can test and send you an x86_64 specific patch for GCC if you'd
like. Or if you prefer to have all the work together, we can go with
#2.

Let me know!

On Sat, May 19, 2018 at 3:17 AM, Joel Sherrill  wrote:
> Thanks. I will try to deal with this Monday.
>
> My specs patches are not ready to push to gcc so I need to focus on
> just the parts to make x86_64 right.
>
> On Fri, May 18, 2018 at 3:41 PM, Amaan Cheval 
> wrote:
>>
>> To be clear, I applied this patch (with my fixes) on the 7.3 release
>> through the RSB to test, not on GCC's master branch.
>>
>> > to add i386/rtemself64.h
>>
>> What you sent in this email thread adds rtemself64.h already. Do you
>> mean you'd like to split the commits up or something?
>>
>> The only changes I made on top of yours were:
>>
>> - Readd "rtems.h" to config.gcc
>> - Fix comments
>>
>> I've attached the patch file I used within the RSB here (sorry if you
>> meant a patch of _just_ the fixes I made on top of yours, this is just
>> the cumulative diff I used to patch GCC 7.3 to test).
>>
>> Regards,
>>
>> On Fri, May 18, 2018 at 7:00 PM, Joel Sherrill  wrote:
>> >
>> >
>> >
>> > On Fri, May 18, 2018 at 1:38 AM, Amaan Cheval 
>> > wrote:
>> >>
>> >> I just compiled my local fixed copy (adding rtems.h back in) and
>> >> there's good news! With the patch, the x86_64 compile stub works with
>> >> a blank bsp_specs file!
>> >
>> >
>> > Awesome!
>> >
>> > Can you send me your changes as a patch? I am thinking I need to make
>> > sure we agree on what the gcc master for x86_64-rtems looks like.
>> >
>> > Apparently I owe committing a patch to add i386/rtemself64.h since it is
>> > missing on the master. And the comment is wrong.  What else?
>> >
>> >> On Fri, May 18, 2018 at 12:59 AM, Amaan Cheval 
>> >> wrote:
>> >> > Hey!
>> >> >
>> >> > Thanks so much for sharing this, it's quite useful to put your
>> >> > earlier
>> >> > email[1] about minimzing the bsp_specs in context.
>> >> >
>> >> > From looking ahead a bit without testing (still compiling), the patch
>> >> > may need an ENDFILE_SPEC definition as well for "crtend.o" (it
>> >> > defines
>> >> > __TMC_END__ which crtbegin.o has left undefined for eg.) and possibly
>> >> > "crtn.o", at least to eliminate the x86_64 port's bsp_specs entirely
>> >> > (see here[2]).
>> >>
>> >> Just noticed that ENDFILE_SPEC already includes crtend in i386elf.h,
>> >> so there's no need for this change.
>> >>
>> >> >
>> >> > I've also left some comments inline below.
>> >> >
>> >> > +1 on upstreaming this into GCC (making sure it also backports to 7.3
>> >> > for simplicity, so we don't need to write a 7.3-specific patch for
>> >> > the
>> >> > RSB as well) with a few additons (at least for the x86_64 target, to
>> >> > try to have an empty bsp_specs to begin with).
>> >> >
>> >> > [1] https://lists.rtems.org/pipermail/devel/2018-May/021430.html
>> >> > [2]
>> >> >
>> >> > https://github.com/AmaanC/rtems-gsoc18/blob/ac/daily-01-compile-stub/bsps/x86_64/amd64/start/bsp_specs
>> >> >
>> >> > On Wed, May 16, 2018 at 8:46 PM, Joel Sherrill 
>> >> > wrote:
>> >> >> ---
>> >> >>  gcc/config.gcc|  2 +-
>> >> >>  gcc/config/arm/rtems.h|  4 
>> >> >>  gcc/config/bfin/rtems.h   |  4 
>> >> >>  gcc/config/i386/rtemself.h|  6 +-
>> >> >>  gcc/config/i386/rtemself64.h  | 39
>> >> >> +++
>> >> >>  gcc/config/m68k/rtemself.h|  4 
>> >> >>  gcc/config/microblaze/rtems.h |  4 
>> >> >>  gcc/config/mips/rtems.h   |  4 
>> >> >>  gcc/config/moxie/rtems.h  |  4 
>> >> >>  gcc/config/nios2/rtems.h  |  4 
>> >> >>  gcc/config/riscv/rtems.h  |  4 
>> >> >>  gcc/config/rs6000/rtems.h |  5 +
>> >> >>  gcc/config/rtems.h|  6 +-
>> >> >>  gcc/config/sh/rtems.h |  4 
>> >> >>  gcc/config/sh/rtemself.h  |  4 
>> >> >>  gcc/config/sparc/rtemself.h   |  4 
>> >> >>  gcc/config/v850/rtems.h   |  4 
>> >> >>  17 files changed, 103 insertions(+), 3 deletions(-)
>> >> >>  create mode 100644 gcc/config/i386/rtemself64.h
>> >> >>
>> >> >> diff --git a/gcc/config.gcc b/gcc/config.gcc
>> >> >> index d509800..de27e5c 100644
>> >> >> --- a/gcc/config.gcc
>> >> >> +++ b/gcc/config.gcc
>> >> >> @@ -1499,7 +1499,7 @@ x86_64-*-elf*)
>> >> >> tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h
>> >> >> newlib-stdint.h i386/i386elf.h i386/x86-64.h"
>> >> >> ;;
>> >> >>  x86_64-*-rtems*)
>> >> >> -   tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h
>> >> >

Re: jffs2 changes and Coverity issue in porting code

2018-07-05 Thread Sebastian Huber

Hello Joel,

On 05/07/18 17:52, Joel Sherrill wrote:

Hi

By any chance, do any of the jffs2 updates pick up changes
to that method in the porting layer which Coverity thought
had an issue?

I know the code is the same across multiple OSes and you
didn't invent or modify it porting jffs2 to RTEMS. Just curious
if the situation might have changed.


you mean this one:

https://lists.rtems.org/pipermail/devel/2014-November/009331.html

The eCos upstream seems to be dead. So, we have to fix this on our own. 
Would it be possible to run Coverity with the latest RTEMS?


--
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail  : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel