Skip to contentSkip to conversation

getting ubifs to run

PATCH New Marco 2 participants 6 messages Aug 11, 2016 – Sep 2, 2016

Subsystems (4)
lore
Share & tools
lore

Marco

author
#0 lore raw

PATCH 1/1 getting ubifs to run

---
 arch/microblaze/include/asm/atomic.h | 114 +++++++++++++++++++++++++++++++++++
 arch/microblaze/include/asm/bitops.h |   8 +--
 fs/ubifs/io.c                        |   2 +-
 fs/ubifs/log.c                       |  99 ++++++++++++++++++++++++++++++
 fs/ubifs/lpt_commit.c                |  21 +++++++
 5 files changed, 239 insertions(+), 5 deletions(-)
 create mode 100644 arch/microblaze/include/asm/atomic.h
arch/microblaze/include/asm/atomic.h new file +114 -0
new file mode 100644
index 0000000..2872149
@@ -0,0 +1,114 @@
+/*
+ *  linux/include/asm-arm/atomic.h
+ *
+ *  Copyright (c) 1996 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Changelog:
+ *   27-06-1996	RMK	Created
+ *   13-04-1997	RMK	Made functions atomic!
+ *   07-12-1997	RMK	Upgraded for v2.1.
+ *   26-08-1998	PJB	Added #ifdef __KERNEL__
+ */
+#ifndef __ASM_ARM_ATOMIC_H
+#define __ASM_ARM_ATOMIC_H
+
+#ifdef CONFIG_SMP
+#error SMP not supported
+#endif
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i)	{ (i) }
+
+#ifdef __KERNEL__
+#include <asm/system.h>
+
+#define atomic_read(v)	((v)->counter)
+#define atomic_set(v,i)	(((v)->counter) = (i))
+
+
+
+
+static inline void atomic_add(int i, volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter += i;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_sub(int i, volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter -= i;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_inc(volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter += 1;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_dec(volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter -= 1;
+	local_irq_restore(flags);
+}
+
+static inline int atomic_dec_and_test(volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+	int val;
+
+	local_irq_save(flags);
+	val = v->counter;
+	v->counter = val -= 1;
+	local_irq_restore(flags);
+
+	return val == 0;
+}
+
+static inline int atomic_add_negative(int i, volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+	int val;
+
+	local_irq_save(flags);
+	val = v->counter;
+	v->counter = val += i;
+	local_irq_restore(flags);
+
+	return val < 0;
+}
+
+static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	*addr &= ~mask;
+	local_irq_restore(flags);
+}
+
+/* Atomic operations are already serializing on ARM */
+#define smp_mb__before_atomic_dec()	barrier()
+#define smp_mb__after_atomic_dec()	barrier()
+#define smp_mb__before_atomic_inc()	barrier()
+#define smp_mb__after_atomic_inc()	barrier()
+
+#endif
+#endif
arch/microblaze/include/asm/bitops.h +4 -4
index 2cab2ac..b3b17b9 100644
@@ -204,10 +204,10 @@ static inline int __test_bit(int nr, volatile void *addr)
 	return ((mask & *a) != 0);
 }
 
-#define test_bit(nr,addr) \
-(__builtin_constant_p(nr) ? \
- __constant_test_bit((nr),(addr)) : \
- __test_bit((nr),(addr)))
+static inline int test_bit(int nr, const void * addr)
+{
+	return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7));
+}
 
 #define find_first_zero_bit(addr, size) \
 	find_next_zero_bit((addr), (size), 0)
fs/ubifs/io.c +1 -1
index 51a95bb..685713e 100644
@@ -847,6 +847,7 @@ out:
 	ubifs_dump_leb(c, wbuf->lnum);
 	return err;
 }
+#endif
 
 /**
  * ubifs_write_node - write node to the media.
@@ -885,7 +886,6 @@ int ubifs_write_node(struct ubifs_info *c, void *buf, int len, int lnum,
 
 	return err;
 }
-#endif
 
 /**
  * ubifs_read_node_wbuf - read node from the media or write-buffer.
fs/ubifs/log.c +99 -0

102 lines not on this page · raw message

fs/ubifs/lpt_commit.c +21 -0
index 2df9130..61b2cc8 100644
@@ -2039,4 +2039,25 @@ static int dbg_populate_lsave(struct ubifs_info *c)
 
 	return 1;
 }
+#else
+
+int dbg_chk_lpt_free_spc(struct ubifs_info *c)
+{
+	return 0;
+}
+
+int dbg_check_ltab(struct ubifs_info *c)
+{
+	return 0;
+}
+
+int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
+{
+	return 0;
+}
+
+void ubifs_dump_lpt_lebs(const struct ubifs_info *c)
+{
+}
+
 #endif
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 getting ubifs to run

Hello Marco,

Am 11.08.2016 um 11:56 schrieb Marco:

Quoted 9 lines
---
  arch/microblaze/include/asm/atomic.h | 114 +++++++++++++++++++++++++++++++++++
  arch/microblaze/include/asm/bitops.h |   8 +--
  fs/ubifs/io.c                        |   2 +-
  fs/ubifs/log.c                       |  99 ++++++++++++++++++++++++++++++
  fs/ubifs/lpt_commit.c                |  21 +++++++
  5 files changed, 239 insertions(+), 5 deletions(-)

create mode 100644 arch/microblaze/include/asm/atomic.h

Hmm... what exactly do you fix? Can you add a commit message please?

It seems to me, you get ubifs working on microblaze arch?

And may you can split this patch into at least two pieces, one for the arch fixes, and one for the ubifs fixes?

ubifs read support works for me on some arm based plattforms ... what exactly do you fix with your fs/ubifs/* changes?

Thanks!

bye,
Heiko

Quoted 297 lines
arch/microblaze/include/asm/atomic.h new file +114 -0
new file mode 100644
index 0000000..2872149
@@ -0,0 +1,114 @@
+/*
+ *  linux/include/asm-arm/atomic.h
+ *
+ *  Copyright (c) 1996 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Changelog:
+ *   27-06-1996	RMK	Created
+ *   13-04-1997	RMK	Made functions atomic!
+ *   07-12-1997	RMK	Upgraded for v2.1.
+ *   26-08-1998	PJB	Added #ifdef __KERNEL__
+ */
+#ifndef __ASM_ARM_ATOMIC_H
+#define __ASM_ARM_ATOMIC_H
+
+#ifdef CONFIG_SMP
+#error SMP not supported
+#endif
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i)	{ (i) }
+
+#ifdef __KERNEL__
+#include <asm/system.h>
+
+#define atomic_read(v)	((v)->counter)
+#define atomic_set(v,i)	(((v)->counter) = (i))
+
+
+
+
+static inline void atomic_add(int i, volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter += i;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_sub(int i, volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter -= i;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_inc(volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter += 1;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_dec(volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter -= 1;
+	local_irq_restore(flags);
+}
+
+static inline int atomic_dec_and_test(volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+	int val;
+
+	local_irq_save(flags);
+	val = v->counter;
+	v->counter = val -= 1;
+	local_irq_restore(flags);
+
+	return val == 0;
+}
+
+static inline int atomic_add_negative(int i, volatile atomic_t *v)
+{
+	unsigned long flags = 0;
+	int val;
+
+	local_irq_save(flags);
+	val = v->counter;
+	v->counter = val += i;
+	local_irq_restore(flags);
+
+	return val < 0;
+}
+
+static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
+{
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	*addr &= ~mask;
+	local_irq_restore(flags);
+}
+
+/* Atomic operations are already serializing on ARM */
+#define smp_mb__before_atomic_dec()	barrier()
+#define smp_mb__after_atomic_dec()	barrier()
+#define smp_mb__before_atomic_inc()	barrier()
+#define smp_mb__after_atomic_inc()	barrier()
+
+#endif
+#endif
arch/microblaze/include/asm/bitops.h +4 -4
index 2cab2ac..b3b17b9 100644
@@ -204,10 +204,10 @@ static inline int __test_bit(int nr, volatile void *addr)
  	return ((mask & *a) != 0);
  }
 
-#define test_bit(nr,addr) \
-(__builtin_constant_p(nr) ? \
- __constant_test_bit((nr),(addr)) : \
- __test_bit((nr),(addr)))
+static inline int test_bit(int nr, const void * addr)
+{
+	return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7));
+}
 
  #define find_first_zero_bit(addr, size) \
  	find_next_zero_bit((addr), (size), 0)
fs/ubifs/io.c +1 -1
index 51a95bb..685713e 100644
@@ -847,6 +847,7 @@ out:
  	ubifs_dump_leb(c, wbuf->lnum);
  	return err;
  }
+#endif
 
  /**
   * ubifs_write_node - write node to the media.
@@ -885,7 +886,6 @@ int ubifs_write_node(struct ubifs_info *c, void *buf, int len, int lnum,
 
  	return err;
  }
-#endif
 
  /**
   * ubifs_read_node_wbuf - read node from the media or write-buffer.
fs/ubifs/log.c +99 -0
index a07fdef..10302b9 100644
@@ -743,3 +743,102 @@ static int dbg_check_bud_bytes(struct ubifs_info *c)
 
  	return err;
  }
+
+
+/**
+ * ubifs_commit_required - set commit state to "required".
+ * @c: UBIFS file-system description object
+ *
+ * This function is called if a commit is required but cannot be done from the
+ * calling function, so it is just flagged instead.
+ */
+void ubifs_commit_required(struct ubifs_info *c)
+{
+	spin_lock(&c->cs_lock);
+	switch (c->cmt_state) {
+	case COMMIT_RESTING:
+	case COMMIT_BACKGROUND:
+		dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+			dbg_cstate(COMMIT_REQUIRED));
+		c->cmt_state = COMMIT_REQUIRED;
+		break;
+	case COMMIT_RUNNING_BACKGROUND:
+		dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+			dbg_cstate(COMMIT_RUNNING_REQUIRED));
+		c->cmt_state = COMMIT_RUNNING_REQUIRED;
+		break;
+	case COMMIT_REQUIRED:
+	case COMMIT_RUNNING_REQUIRED:
+	case COMMIT_BROKEN:
+		break;
+	}
+	spin_unlock(&c->cs_lock);
+}
+
+/**
+ * ubifs_write_master - write master node.
+ * @c: UBIFS file-system description object
+ *
+ * This function writes the master node. Returns zero in case of success and a
+ * negative error code in case of failure. The master node is written twice to
+ * enable recovery.
+ */
+int ubifs_write_master(struct ubifs_info *c)
+{
+	int err, lnum, offs, len;
+
+	ubifs_assert(!c->ro_media && !c->ro_mount);
+	if (c->ro_error)
+		return -EROFS;
+
+	lnum = UBIFS_MST_LNUM;
+	offs = c->mst_offs + c->mst_node_alsz;
+	len = UBIFS_MST_NODE_SZ;
+
+	if (offs + UBIFS_MST_NODE_SZ > c->leb_size) {
+		err = ubifs_leb_unmap(c, lnum);
+		if (err)
+			return err;
+		offs = 0;
+	}
+
+	c->mst_offs = offs;
+	c->mst_node->highest_inum = cpu_to_le64(c->highest_inum);
+
+	err = ubifs_write_node(c, c->mst_node, len, lnum, offs);
+	if (err)
+		return err;
+
+	lnum += 1;
+
+	if (offs == 0) {
+		err = ubifs_leb_unmap(c, lnum);
+		if (err)
+			return err;
+	}
+	err = ubifs_write_node(c, c->mst_node, len, lnum, offs);
+
+	return err;
+}
+
+/**
+ * ubifs_request_bg_commit - notify the background thread to do a commit.
+ * @c: UBIFS file-system description object
+ *
+ * This function is called if the journal is full enough to make a commit
+ * worthwhile, so background thread is kicked to start it.
+ */
+void ubifs_request_bg_commit(struct ubifs_info *c)
+{
+	spin_lock(&c->cs_lock);
+	if (c->cmt_state == COMMIT_RESTING) {
+		dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+			dbg_cstate(COMMIT_BACKGROUND));
+		c->cmt_state = COMMIT_BACKGROUND;
+		spin_unlock(&c->cs_lock);
+		ubifs_wake_up_bgt(c);
+	} else
+		spin_unlock(&c->cs_lock);
+}
+
+
fs/ubifs/lpt_commit.c +21 -0
index 2df9130..61b2cc8 100644
@@ -2039,4 +2039,25 @@ static int dbg_populate_lsave(struct ubifs_info *c)
 
  	return 1;
  }
+#else
+
+int dbg_chk_lpt_free_spc(struct ubifs_info *c)
+{
+	return 0;
+}
+
+int dbg_check_ltab(struct ubifs_info *c)
+{
+	return 0;
+}
+
+int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len)
+{
+	return 0;
+}
+
+void ubifs_dump_lpt_lebs(const struct ubifs_info *c)
+{
+}
+
  #endif
Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
#2 lore raw

PATCH 1/1 getting ubifs to run

Hello Heiko,
You are right, there are two parts: the Microblaze part and the ubifs stuff.
To get u-boot compiled I added the following to the Microblaze architecture:
atomic.h based on the ARM architecture, was missing before.
Modified bitops.h to get rid of compiler warnings
The three ubifs files had #defines which didn't work for me.
With the changes of the patch I sent I can successfully load the Kernel from a ubifs partition on a Microblaze.

That were the problems:

CC fs/ubifs/ubifs.o
In file included from /home/hoefle/projects/u-boot_patch/fs/ubifs/ubifs.c:17:0:
/home/hoefle/projects/u-boot_patch/fs/ubifs/ubifs.h:35:24: fatal error: asm/atomic.h: No such file or directory

 #include <asm/atomic.h>
                        ^

compilation terminated.

/home/hoefle/projects/u-boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected 'volatile void *' but argument is of type 'const long unsigned int *'
static inline int __test_bit(int nr, volatile void *addr)

                   ^
/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h: In function 'ubifs_zn_obsolete':
/home/hoefle/projects/u-boot_patch/arch/microblaze/include/asm/bitops.h:210:18: warning: passing argument 2 of '__test_bit' discards 'const' qualifier from pointer target type
  __test_bit((nr),(addr)))
                  ^
/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h:38:11: note: in expansion of macro 'test_bit'
  return !!test_bit(OBSOLETE_ZNODE, &znode->flags);
           ^
/home/hoefle/projects/u-boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected 'volatile void *' but argument is of type 'const long unsigned int *'
 static inline int __test_bit(int nr, volatile void *addr)
                   ^
/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h: In function 'ubifs_zn_cow':
/home/hoefle/projects/u-boot_patch/arch/microblaze/include/asm/bitops.h:210:18: warning: passing argument 2 of '__test_bit' discards 'const' qualifier from pointer target type
  __test_bit((nr),(addr)))
                  ^
/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h:50:11: note: in expansion of macro 'test_bit'
  return !!test_bit(COW_ZNODE, &znode->flags);
           ^
/home/hoefle/projects/u-boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected 'volatile void *' but argument is of type 'const long unsigned int *'
 static inline int __test_bit(int nr, volatile void *addr)
                   ^

fs/built-in.o: In function `ubifs_lpt_start_commit':
/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:1232: undefined reference to dbg_chk_lpt_free_spc' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:1235: undefined reference to dbg_check_ltab' fs/built-in.o: In function `layout_cnodes':
/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:195: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:211: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:219: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:233: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:246: undefined reference to dbg_chk_lpt_sz' fs/built-in.o:/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:254: more undefined references to dbg_chk_lpt_sz' follow fs/built-in.o: In function `layout_cnodes':
/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:322: undefined reference to ubifs_dump_lpt_lebs' fs/built-in.o: In function ubifs_add_bud_to_log':
/home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:194: undefined reference to ubifs_commit_required' /home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:225: undefined reference to ubifs_request_bg_commit' /home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:265: undefined reference to ubifs_write_node' fs/built-in.o: In function ubifs_log_end_commit':
/home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:479: undefined reference to ubifs_write_master' fs/built-in.o: In function write_orph_node':
/home/hoefle/projects/u-boot_patch/fs/ubifs/orphan.c:248: undefined reference to `ubifs_write_node'

Regards,
Marco

Quoted 332 lines

-----Original Message-----
From: Heiko Schocher [mailto:hs at denx.de]
Sent: Freitag, 12. August 2016 07:05
To: Hoefle Marco <[email protected]>
Cc: monstr at monstr.eu; u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] getting ubifs to run

Hello Marco,

Am 11.08.2016 um 11:56 schrieb Marco:

Quoted 3 lines
---
  arch/microblaze/include/asm/atomic.h | 114

+++++++++++++++++++++++++++++++++++

Quoted 6 lines
  arch/microblaze/include/asm/bitops.h |   8 +--
  fs/ubifs/io.c                        |   2 +-
  fs/ubifs/log.c                       |  99 ++++++++++++++++++++++++++++++
  fs/ubifs/lpt_commit.c                |  21 +++++++
  5 files changed, 239 insertions(+), 5 deletions(-)

create mode 100644 arch/microblaze/include/asm/atomic.h

Hmm... what exactly do you fix? Can you add a commit message please?

It seems to me, you get ubifs working on microblaze arch?

And may you can split this patch into at least two pieces, one for the arch fixes, and one for the ubifs fixes?

ubifs read support works for me on some arm based plattforms ... what exactly do you fix with your fs/ubifs/* changes?

Thanks!

bye,
Heiko

arch/microblaze/include/asm/bitops.h static inline int __test_bit(int nr, volatile void

Quoted 122 lines
arch/microblaze/include/asm/atomic.h new file +109 -0
new file mode 100644
index 0000000..2872149
@@ -0,0 +1,114 @@
+/*
+ *  linux/include/asm-arm/atomic.h
+ *
+ *  Copyright (c) 1996 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or
+modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Changelog:
+ *   27-06-1996	RMK	Created
+ *   13-04-1997	RMK	Made functions atomic!
+ *   07-12-1997	RMK	Upgraded for v2.1.
+ *   26-08-1998	PJB	Added #ifdef __KERNEL__
+ */
+#ifndef __ASM_ARM_ATOMIC_H
+#define __ASM_ARM_ATOMIC_H
+
+#ifdef CONFIG_SMP
+#error SMP not supported
+#endif
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i)	{ (i) }
+
+#ifdef __KERNEL__
+#include <asm/system.h>
+
+#define atomic_read(v)	((v)->counter)
+#define atomic_set(v,i)	(((v)->counter) = (i))
+
+
+
+
+static inline void atomic_add(int i, volatile atomic_t *v) {
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter += i;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_sub(int i, volatile atomic_t *v) {
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter -= i;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_inc(volatile atomic_t *v) {
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter += 1;
+	local_irq_restore(flags);
+}
+
+static inline void atomic_dec(volatile atomic_t *v) {
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	v->counter -= 1;
+	local_irq_restore(flags);
+}
+
+static inline int atomic_dec_and_test(volatile atomic_t *v) {
+	unsigned long flags = 0;
+	int val;
+
+	local_irq_save(flags);
+	val = v->counter;
+	v->counter = val -= 1;
+	local_irq_restore(flags);
+
+	return val == 0;
+}
+
+static inline int atomic_add_negative(int i, volatile atomic_t *v) {
+	unsigned long flags = 0;
+	int val;
+
+	local_irq_save(flags);
+	val = v->counter;
+	v->counter = val += i;
+	local_irq_restore(flags);
+
+	return val < 0;
+}
+
+static inline void atomic_clear_mask(unsigned long mask, unsigned
+long *addr) {
+	unsigned long flags = 0;
+
+	local_irq_save(flags);
+	*addr &= ~mask;
+	local_irq_restore(flags);
+}
+
+/* Atomic operations are already serializing on ARM */
+#define smp_mb__before_atomic_dec()	barrier()
+#define smp_mb__after_atomic_dec()	barrier()
+#define smp_mb__before_atomic_inc()	barrier()
+#define smp_mb__after_atomic_inc()	barrier()
+
+#endif
+#endif
arch/microblaze/include/asm/bitops.h +0 -0
index 2cab2ac..b3b17b9 100644
@@ -204,10 +204,10 @@ static inline int __test_bit(int nr, volatile void

*addr)

Quoted 112 lines
arch/microblaze/include/asm/bitops.h +2 -4
  	return ((mask & *a) != 0);
  }
 
-#define test_bit(nr,addr) \
-(__builtin_constant_p(nr) ? \
- __constant_test_bit((nr),(addr)) : \
- __test_bit((nr),(addr)))
+static inline int test_bit(int nr, const void * addr) {
+	return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7)); }
 
  #define find_first_zero_bit(addr, size) \
  	find_next_zero_bit((addr), (size), 0) diff --git a/fs/ubifs/io.c

b/fs/ubifs/io.c index 51a95bb..685713e 100644

fs/ubifs/io.c +1 -1
@@ -847,6 +847,7 @@ out:
  	ubifs_dump_leb(c, wbuf->lnum);
  	return err;
  }
+#endif
 
  /**
   * ubifs_write_node - write node to the media.
@@ -885,7 +886,6 @@ int ubifs_write_node(struct ubifs_info *c, void
 *buf, int len, int lnum,
 
  	return err;
  }
-#endif
 
  /**

* ubifs_read_node_wbuf - read node from the media or write-buffer.

fs/ubifs/log.c index a07fdef..10302b9 renamed from fs/ubifs/log.c +0 -0

100644

fs/ubifs/log.c +71 -0
@@ -743,3 +743,102 @@ static int dbg_check_bud_bytes(struct ubifs_info
 *c)
 
  	return err;
  }
+
+
+/**
+ * ubifs_commit_required - set commit state to "required".
+ * @c: UBIFS file-system description object
+ *
+ * This function is called if a commit is required but cannot be done
+from the
+ * calling function, so it is just flagged instead.
+ */
+void ubifs_commit_required(struct ubifs_info *c) {
+	spin_lock(&c->cs_lock);
+	switch (c->cmt_state) {
+	case COMMIT_RESTING:
+	case COMMIT_BACKGROUND:
+		dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+			dbg_cstate(COMMIT_REQUIRED));
+		c->cmt_state = COMMIT_REQUIRED;
+		break;
+	case COMMIT_RUNNING_BACKGROUND:
+		dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+			dbg_cstate(COMMIT_RUNNING_REQUIRED));
+		c->cmt_state = COMMIT_RUNNING_REQUIRED;
+		break;
+	case COMMIT_REQUIRED:
+	case COMMIT_RUNNING_REQUIRED:
+	case COMMIT_BROKEN:
+		break;
+	}
+	spin_unlock(&c->cs_lock);
+}
+
+/**
+ * ubifs_write_master - write master node.
+ * @c: UBIFS file-system description object
+ *
+ * This function writes the master node. Returns zero in case of
+success and a
+ * negative error code in case of failure. The master node is written
+twice to
+ * enable recovery.
+ */
+int ubifs_write_master(struct ubifs_info *c) {
+	int err, lnum, offs, len;
+
+	ubifs_assert(!c->ro_media && !c->ro_mount);
+	if (c->ro_error)
+		return -EROFS;
+
+	lnum = UBIFS_MST_LNUM;
+	offs = c->mst_offs + c->mst_node_alsz;
+	len = UBIFS_MST_NODE_SZ;
+
+	if (offs + UBIFS_MST_NODE_SZ > c->leb_size) {
+		err = ubifs_leb_unmap(c, lnum);
+		if (err)
+			return err;
+		offs = 0;
+	}
+
+	c->mst_offs = offs;
+	c->mst_node->highest_inum = cpu_to_le64(c->highest_inum);
+
+	err = ubifs_write_node(c, c->mst_node, len, lnum, offs);
+	if (err)
+		return err;
+
+	lnum += 1;
+
+	if (offs == 0) {
+		err = ubifs_leb_unmap(c, lnum);

fs/ubifs/log.c static int dbg_check_bud_bytes(struct ubifs_info

Quoted 10 lines
fs/ubifs/log.c +10 -0
+		if (err)
+			return err;
+	}
+	err = ubifs_write_node(c, c->mst_node, len, lnum, offs);
+
+	return err;
+}
+
+/**
+ * ubifs_request_bg_commit - notify the background thread to do a

commit.

Quoted 36 lines

+ * @c: UBIFS file-system description object
+ *
+ * This function is called if the journal is full enough to make a

fs/ubifs/log.c +16 -0
+commit
+ * worthwhile, so background thread is kicked to start it.
+ */
+void ubifs_request_bg_commit(struct ubifs_info *c) {
+	spin_lock(&c->cs_lock);
+	if (c->cmt_state == COMMIT_RESTING) {
+		dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+			dbg_cstate(COMMIT_BACKGROUND));
+		c->cmt_state = COMMIT_BACKGROUND;
+		spin_unlock(&c->cs_lock);
+		ubifs_wake_up_bgt(c);
+	} else
+		spin_unlock(&c->cs_lock);
+}
+
+
fs/ubifs/lpt_commit.c index renamed from fs/ubifs/lpt_commit.c +0 -0

2df9130..61b2cc8 100644

fs/ubifs/lpt_commit.c +7 -0
@@ -2039,4 +2039,25 @@ static int dbg_populate_lsave(struct ubifs_info
 *c)
 
  	return 1;
  }
+#else
+
+int dbg_chk_lpt_free_spc(struct ubifs_info *c) {
+	return 0;
+}
+
+int dbg_check_ltab(struct ubifs_info *c) {

fs/ubifs/lpt_commit.c static int dbg_populate_lsave(struct ubifs_info · line 2063

Quoted 10 lines
fs/ubifs/lpt_commit.c +9 -0
+	return 0;
+}
+
+int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) {
+	return 0;
+}
+
+void ubifs_dump_lpt_lebs(const struct ubifs_info *c) { }
+
  #endif

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

#3 lore raw

PATCH 1/1 getting ubifs to run

Hello Heiko,
You are right, there are two parts: the Microblaze part and the ubifs stuff.
To get u-boot compiled I added the following to the Microblaze architecture:
atomic.h based on the ARM architecture, was missing before.
Modified bitops.h to get rid of compiler warnings
The three ubifs files had #defines which didn?t work for me.
With the changes of the patch I sent I can successfully load the Kernel from a ubifs partition on a Microblaze.

That were the problems:

CC fs/ubifs/ubifs.o
In file included from /home/hoefle/projects/u-boot_patch/fs/ubifs/ubifs.c:17:0:
/home/hoefle/projects/u-boot_patch/fs/ubifs/ubifs.h:35:24: fatal error: asm/atomic.h: No such file or directory

 #include <asm/atomic.h>
                        ^

compilation terminated.

/home/hoefle/projects/u-boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected 'volatile void *' but argument is of type 'const long unsigned int *'
static inline int __test_bit(int nr, volatile void *addr)

                   ^
/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h: In function 'ubifs_zn_obsolete':
/home/hoefle/projects/u-boot_patch/arch/microblaze/include/asm/bitops.h:210:18: warning: passing argument 2 of '__test_bit' discards 'const' qualifier from pointer target type
  __test_bit((nr),(addr)))
                  ^
/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h:38:11: note: in expansion of macro 'test_bit'
  return !!test_bit(OBSOLETE_ZNODE, &znode->flags);
           ^
/home/hoefle/projects/u-boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected 'volatile void *' but argument is of type 'const long unsigned int *'
 static inline int __test_bit(int nr, volatile void *addr)
                   ^
/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h: In function 'ubifs_zn_cow':
/home/hoefle/projects/u-boot_patch/arch/microblaze/include/asm/bitops.h:210:18: warning: passing argument 2 of '__test_bit' discards 'const' qualifier from pointer target type
  __test_bit((nr),(addr)))
                  ^
/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h:50:11: note: in expansion of macro 'test_bit'
  return !!test_bit(COW_ZNODE, &znode->flags);
           ^
/home/hoefle/projects/u-boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected 'volatile void *' but argument is of type 'const long unsigned int *'
 static inline int __test_bit(int nr, volatile void *addr)
                   ^

fs/built-in.o: In function `ubifs_lpt_start_commit':
/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:1232: undefined reference to dbg_chk_lpt_free_spc' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:1235: undefined reference to dbg_check_ltab' fs/built-in.o: In function `layout_cnodes':
/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:195: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:211: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:219: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:233: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:246: undefined reference to dbg_chk_lpt_sz' fs/built-in.o:/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:254: more undefined references to dbg_chk_lpt_sz' follow fs/built-in.o: In function `layout_cnodes':
/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:322: undefined reference to ubifs_dump_lpt_lebs' fs/built-in.o: In function ubifs_add_bud_to_log':
/home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:194: undefined reference to ubifs_commit_required' /home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:225: undefined reference to ubifs_request_bg_commit' /home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:265: undefined reference to ubifs_write_node' fs/built-in.o: In function ubifs_log_end_commit':
/home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:479: undefined reference to ubifs_write_master' fs/built-in.o: In function write_orph_node':
/home/hoefle/projects/u-boot_patch/fs/ubifs/orphan.c:248: undefined reference to `ubifs_write_node'

Regards,
Marco

Quoted 332 lines

-----Original Message-----
From: Heiko Schocher [mailto:hs at denx.de]
Sent: Freitag, 12. August 2016 07:05
To: Hoefle Marco <[email protected]>
Cc: monstr at monstr.eu; u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] getting ubifs to run

Hello Marco,

Am 11.08.2016 um 11:56 schrieb Marco:

Quoted 3 lines
---
  arch/microblaze/include/asm/atomic.h | 114

+++++++++++++++++++++++++++++++++++

Quoted 6 lines
  arch/microblaze/include/asm/bitops.h |   8 +--
  fs/ubifs/io.c                        |   2 +-
  fs/ubifs/log.c                       |  99 ++++++++++++++++++++++++++++++
  fs/ubifs/lpt_commit.c                |  21 +++++++
  5 files changed, 239 insertions(+), 5 deletions(-)

create mode 100644 arch/microblaze/include/asm/atomic.h

Hmm... what exactly do you fix? Can you add a commit message please?

It seems to me, you get ubifs working on microblaze arch?

And may you can split this patch into at least two pieces, one for the arch fixes, and one for the ubifs fixes?

ubifs read support works for me on some arm based plattforms ... what exactly do you fix with your fs/ubifs/* changes?

Thanks!

bye,
Heiko

arch/microblaze/include/asm/bitops.h static inline int __test_bit(int nr, volatile void

Quoted 122 lines
arch/microblaze/include/asm/atomic.h new file +109 -0
new file mode 100644
index 0000000..2872149
@@ -0,0 +1,114 @@
+/*
+ *  linux/include/asm-arm/atomic.h
+ *
+ *  Copyright (c) 1996 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or
+modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ *  Changelog:
+ *   27-06-1996    RMK     Created
+ *   13-04-1997    RMK     Made functions atomic!
+ *   07-12-1997    RMK     Upgraded for v2.1.
+ *   26-08-1998    PJB     Added #ifdef __KERNEL__
+ */
+#ifndef __ASM_ARM_ATOMIC_H
+#define __ASM_ARM_ATOMIC_H
+
+#ifdef CONFIG_SMP
+#error SMP not supported
+#endif
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i)     { (i) }
+
+#ifdef __KERNEL__
+#include <asm/system.h>
+
+#define atomic_read(v)     ((v)->counter)
+#define atomic_set(v,i)    (((v)->counter) = (i))
+
+
+
+
+static inline void atomic_add(int i, volatile atomic_t *v) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter += i;
+   local_irq_restore(flags);
+}
+
+static inline void atomic_sub(int i, volatile atomic_t *v) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter -= i;
+   local_irq_restore(flags);
+}
+
+static inline void atomic_inc(volatile atomic_t *v) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter += 1;
+   local_irq_restore(flags);
+}
+
+static inline void atomic_dec(volatile atomic_t *v) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter -= 1;
+   local_irq_restore(flags);
+}
+
+static inline int atomic_dec_and_test(volatile atomic_t *v) {
+   unsigned long flags = 0;
+   int val;
+
+   local_irq_save(flags);
+   val = v->counter;
+   v->counter = val -= 1;
+   local_irq_restore(flags);
+
+   return val == 0;
+}
+
+static inline int atomic_add_negative(int i, volatile atomic_t *v) {
+   unsigned long flags = 0;
+   int val;
+
+   local_irq_save(flags);
+   val = v->counter;
+   v->counter = val += i;
+   local_irq_restore(flags);
+
+   return val < 0;
+}
+
+static inline void atomic_clear_mask(unsigned long mask, unsigned
+long *addr) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   *addr &= ~mask;
+   local_irq_restore(flags);
+}
+
+/* Atomic operations are already serializing on ARM */
+#define smp_mb__before_atomic_dec()        barrier()
+#define smp_mb__after_atomic_dec() barrier()
+#define smp_mb__before_atomic_inc()        barrier()
+#define smp_mb__after_atomic_inc() barrier()
+
+#endif
+#endif
arch/microblaze/include/asm/bitops.h +0 -0
index 2cab2ac..b3b17b9 100644
@@ -204,10 +204,10 @@ static inline int __test_bit(int nr, volatile void

*addr)

Quoted 112 lines
arch/microblaze/include/asm/bitops.h +2 -4
    return ((mask & *a) != 0);
  }
 
-#define test_bit(nr,addr) \
-(__builtin_constant_p(nr) ? \
- __constant_test_bit((nr),(addr)) : \
- __test_bit((nr),(addr)))
+static inline int test_bit(int nr, const void * addr) {
+   return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7)); }
 
  #define find_first_zero_bit(addr, size) \
    find_next_zero_bit((addr), (size), 0) diff --git a/fs/ubifs/io.c

b/fs/ubifs/io.c index 51a95bb..685713e 100644

fs/ubifs/io.c +1 -1
@@ -847,6 +847,7 @@ out:
    ubifs_dump_leb(c, wbuf->lnum);
    return err;
  }
+#endif
 
  /**
   * ubifs_write_node - write node to the media.
@@ -885,7 +886,6 @@ int ubifs_write_node(struct ubifs_info *c, void
 *buf, int len, int lnum,
 
    return err;
  }
-#endif
 
  /**

* ubifs_read_node_wbuf - read node from the media or write-buffer.

fs/ubifs/log.c index a07fdef..10302b9 renamed from fs/ubifs/log.c +0 -0

100644

fs/ubifs/log.c +71 -0
@@ -743,3 +743,102 @@ static int dbg_check_bud_bytes(struct ubifs_info
 *c)
 
    return err;
  }
+
+
+/**
+ * ubifs_commit_required - set commit state to "required".
+ * @c: UBIFS file-system description object
+ *
+ * This function is called if a commit is required but cannot be done
+from the
+ * calling function, so it is just flagged instead.
+ */
+void ubifs_commit_required(struct ubifs_info *c) {
+   spin_lock(&c->cs_lock);
+   switch (c->cmt_state) {
+   case COMMIT_RESTING:
+   case COMMIT_BACKGROUND:
+           dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+                   dbg_cstate(COMMIT_REQUIRED));
+           c->cmt_state = COMMIT_REQUIRED;
+           break;
+   case COMMIT_RUNNING_BACKGROUND:
+           dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+                   dbg_cstate(COMMIT_RUNNING_REQUIRED));
+           c->cmt_state = COMMIT_RUNNING_REQUIRED;
+           break;
+   case COMMIT_REQUIRED:
+   case COMMIT_RUNNING_REQUIRED:
+   case COMMIT_BROKEN:
+           break;
+   }
+   spin_unlock(&c->cs_lock);
+}
+
+/**
+ * ubifs_write_master - write master node.
+ * @c: UBIFS file-system description object
+ *
+ * This function writes the master node. Returns zero in case of
+success and a
+ * negative error code in case of failure. The master node is written
+twice to
+ * enable recovery.
+ */
+int ubifs_write_master(struct ubifs_info *c) {
+   int err, lnum, offs, len;
+
+   ubifs_assert(!c->ro_media && !c->ro_mount);
+   if (c->ro_error)
+           return -EROFS;
+
+   lnum = UBIFS_MST_LNUM;
+   offs = c->mst_offs + c->mst_node_alsz;
+   len = UBIFS_MST_NODE_SZ;
+
+   if (offs + UBIFS_MST_NODE_SZ > c->leb_size) {
+           err = ubifs_leb_unmap(c, lnum);
+           if (err)
+                   return err;
+           offs = 0;
+   }
+
+   c->mst_offs = offs;
+   c->mst_node->highest_inum = cpu_to_le64(c->highest_inum);
+
+   err = ubifs_write_node(c, c->mst_node, len, lnum, offs);
+   if (err)
+           return err;
+
+   lnum += 1;
+
+   if (offs == 0) {
+           err = ubifs_leb_unmap(c, lnum);

fs/ubifs/log.c static int dbg_check_bud_bytes(struct ubifs_info

Quoted 10 lines
fs/ubifs/log.c +10 -0
+           if (err)
+                   return err;
+   }
+   err = ubifs_write_node(c, c->mst_node, len, lnum, offs);
+
+   return err;
+}
+
+/**
+ * ubifs_request_bg_commit - notify the background thread to do a

commit.

Quoted 36 lines

+ * @c: UBIFS file-system description object
+ *
+ * This function is called if the journal is full enough to make a

fs/ubifs/log.c +16 -0
+commit
+ * worthwhile, so background thread is kicked to start it.
+ */
+void ubifs_request_bg_commit(struct ubifs_info *c) {
+   spin_lock(&c->cs_lock);
+   if (c->cmt_state == COMMIT_RESTING) {
+           dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+                   dbg_cstate(COMMIT_BACKGROUND));
+           c->cmt_state = COMMIT_BACKGROUND;
+           spin_unlock(&c->cs_lock);
+           ubifs_wake_up_bgt(c);
+   } else
+           spin_unlock(&c->cs_lock);
+}
+
+
fs/ubifs/lpt_commit.c index renamed from fs/ubifs/lpt_commit.c +0 -0

2df9130..61b2cc8 100644

fs/ubifs/lpt_commit.c +7 -0
@@ -2039,4 +2039,25 @@ static int dbg_populate_lsave(struct ubifs_info
 *c)
 
    return 1;
  }
+#else
+
+int dbg_chk_lpt_free_spc(struct ubifs_info *c) {
+   return 0;
+}
+
+int dbg_check_ltab(struct ubifs_info *c) {

fs/ubifs/lpt_commit.c static int dbg_populate_lsave(struct ubifs_info · line 2063

Quoted 10 lines
fs/ubifs/lpt_commit.c +9 -0
+   return 0;
+}
+
+int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) {
+   return 0;
+}
+
+void ubifs_dump_lpt_lebs(const struct ubifs_info *c) { }
+
  #endif

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

#4 lore raw

PATCH 1/1 getting ubifs to run

Hello Heiko and Michal,
Do you agree that the u-boot sources need to be adapted in order to have ubifs on the Microblaze? It would be good if the changes are somehow in the mainline.
BR
Marco

Quoted 445 lines

-----Original Message-----
From: Hoefle Marco
Sent: Montag, 15. August 2016 13:55
To: u-boot at lists.denx.de; hs at denx.de
Cc: monstr at monstr.eu
Subject: WG: [U-Boot] [PATCH] getting ubifs to run

Hello Heiko,
You are right, there are two parts: the Microblaze part and the ubifs stuff. To get u-boot compiled I added the following to the Microblaze architecture:
atomic.h based on the ARM architecture, was missing before. Modified bitops.h to get rid of compiler warnings The three ubifs files had #defines which didn't work for me.
With the changes of the patch I sent I can successfully load the Kernel from a ubifs partition on a Microblaze.

That were the problems:

CC fs/ubifs/ubifs.o
In file included from /home/hoefle/projects/u- boot_patch/fs/ubifs/ubifs.c:17:0:
/home/hoefle/projects/u-boot_patch/fs/ubifs/ubifs.h:35:24: fatal error:
asm/atomic.h: No such file or directory #include <asm/atomic.h>

                        ^

compilation terminated.

/home/hoefle/projects/u- boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected 'volatile void *' but argument is of type 'const long unsigned int *'
static inline int __test_bit(int nr, volatile void *addr)

                   ^

/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h: In function 'ubifs_zn_obsolete':
/home/hoefle/projects/u- boot_patch/arch/microblaze/include/asm/bitops.h:210:18: warning: passing argument 2 of '__test_bit' discards 'const' qualifier from pointer target type
__test_bit((nr),(addr)))

                  ^
/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h:38:11: note: in
expansion of macro 'test_bit'
  return !!test_bit(OBSOLETE_ZNODE, &znode->flags);
           ^

/home/hoefle/projects/u- boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected 'volatile void *' but argument is of type 'const long unsigned int *'
static inline int __test_bit(int nr, volatile void *addr)

                   ^

/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h: In function 'ubifs_zn_cow':
/home/hoefle/projects/u- boot_patch/arch/microblaze/include/asm/bitops.h:210:18: warning: passing argument 2 of '__test_bit' discards 'const' qualifier from pointer target type
__test_bit((nr),(addr)))

                  ^
/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h:50:11: note: in
expansion of macro 'test_bit'
  return !!test_bit(COW_ZNODE, &znode->flags);
           ^

/home/hoefle/projects/u- boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected 'volatile void *' but argument is of type 'const long unsigned int *'
static inline int __test_bit(int nr, volatile void *addr)

                   ^

fs/built-in.o: In function `ubifs_lpt_start_commit':
/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:1232:
undefined reference to `dbg_chk_lpt_free_spc' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:1235:
undefined reference to `dbg_check_ltab'
fs/built-in.o: In function `layout_cnodes':
/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:195: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:211: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:219: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:233: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:246: undefined reference to dbg_chk_lpt_sz' fs/built-in.o:/home/hoefle/projects/u- boot_patch/fs/ubifs/lpt_commit.c:254: more undefined references to dbg_chk_lpt_sz' follow
fs/built-in.o: In function `layout_cnodes':
/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:322: undefined reference to `ubifs_dump_lpt_lebs'
fs/built-in.o: In function `ubifs_add_bud_to_log':
/home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:194: undefined reference to ubifs_commit_required' /home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:225: undefined reference to ubifs_request_bg_commit' /home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:265: undefined reference to `ubifs_write_node'
fs/built-in.o: In function `ubifs_log_end_commit':
/home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:479: undefined reference to `ubifs_write_master'
fs/built-in.o: In function `write_orph_node':
/home/hoefle/projects/u-boot_patch/fs/ubifs/orphan.c:248: undefined reference to `ubifs_write_node'

Regards,
Marco

Quoted 335 lines

-----Original Message-----
From: Heiko Schocher [mailto:hs at denx.de]
Sent: Freitag, 12. August 2016 07:05
To: Hoefle Marco <[email protected]>
Cc: monstr at monstr.eu; u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] getting ubifs to run

Hello Marco,

Am 11.08.2016 um 11:56 schrieb Marco:

Quoted 3 lines
---
  arch/microblaze/include/asm/atomic.h | 114

+++++++++++++++++++++++++++++++++++

Quoted 6 lines
  arch/microblaze/include/asm/bitops.h |   8 +--
  fs/ubifs/io.c                        |   2 +-
  fs/ubifs/log.c                       |  99 ++++++++++++++++++++++++++++++
  fs/ubifs/lpt_commit.c                |  21 +++++++
  5 files changed, 239 insertions(+), 5 deletions(-)

create mode 100644 arch/microblaze/include/asm/atomic.h

Hmm... what exactly do you fix? Can you add a commit message please?

It seems to me, you get ubifs working on microblaze arch?

And may you can split this patch into at least two pieces, one for the arch fixes, and one for the ubifs fixes?

ubifs read support works for me on some arm based plattforms ... what exactly do you fix with your fs/ubifs/* changes?

Thanks!

bye,
Heiko

Quoted 123 lines
arch/microblaze/include/asm/atomic.h new file +110 -0
new file mode 100644
index 0000000..2872149
@@ -0,0 +1,114 @@
+/*
+ *  linux/include/asm-arm/atomic.h
+ *
+ *  Copyright (c) 1996 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or
+modify
+ * it under the terms of the GNU General Public License version 2
+as
+ * published by the Free Software Foundation.
+ *
+ *  Changelog:
+ *   27-06-1996    RMK     Created
+ *   13-04-1997    RMK     Made functions atomic!
+ *   07-12-1997    RMK     Upgraded for v2.1.
+ *   26-08-1998    PJB     Added #ifdef __KERNEL__
+ */
+#ifndef __ASM_ARM_ATOMIC_H
+#define __ASM_ARM_ATOMIC_H
+
+#ifdef CONFIG_SMP
+#error SMP not supported
+#endif
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i)     { (i) }
+
+#ifdef __KERNEL__
+#include <asm/system.h>
+
+#define atomic_read(v)     ((v)->counter)
+#define atomic_set(v,i)    (((v)->counter) = (i))
+
+
+
+
+static inline void atomic_add(int i, volatile atomic_t *v) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter += i;
+   local_irq_restore(flags);
+}
+
+static inline void atomic_sub(int i, volatile atomic_t *v) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter -= i;
+   local_irq_restore(flags);
+}
+
+static inline void atomic_inc(volatile atomic_t *v) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter += 1;
+   local_irq_restore(flags);
+}
+
+static inline void atomic_dec(volatile atomic_t *v) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter -= 1;
+   local_irq_restore(flags);
+}
+
+static inline int atomic_dec_and_test(volatile atomic_t *v) {
+   unsigned long flags = 0;
+   int val;
+
+   local_irq_save(flags);
+   val = v->counter;
+   v->counter = val -= 1;
+   local_irq_restore(flags);
+
+   return val == 0;
+}
+
+static inline int atomic_add_negative(int i, volatile atomic_t *v) {
+   unsigned long flags = 0;
+   int val;
+
+   local_irq_save(flags);
+   val = v->counter;
+   v->counter = val += i;
+   local_irq_restore(flags);
+
+   return val < 0;
+}
+
+static inline void atomic_clear_mask(unsigned long mask, unsigned
+long *addr) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   *addr &= ~mask;
+   local_irq_restore(flags);
+}
+
+/* Atomic operations are already serializing on ARM */
+#define smp_mb__before_atomic_dec()        barrier()
+#define smp_mb__after_atomic_dec() barrier()
+#define smp_mb__before_atomic_inc()        barrier()
+#define smp_mb__after_atomic_inc() barrier()
+
+#endif
+#endif
arch/microblaze/include/asm/bitops.h +0 -0
index 2cab2ac..b3b17b9 100644
@@ -204,10 +204,10 @@ static inline int __test_bit(int nr, volatile
Quoted 1 line

void

*addr)

Quoted 113 lines
    return ((mask & *a) != 0);

}

arch/microblaze/include/asm/bitops.h +2 -4
-#define test_bit(nr,addr) \
-(__builtin_constant_p(nr) ? \
- __constant_test_bit((nr),(addr)) : \
- __test_bit((nr),(addr)))
+static inline int test_bit(int nr, const void * addr) {
+   return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7)); }
 
  #define find_first_zero_bit(addr, size) \
    find_next_zero_bit((addr), (size), 0) diff --git a/fs/ubifs/io.c

b/fs/ubifs/io.c index 51a95bb..685713e 100644

fs/ubifs/io.c +1 -1
@@ -847,6 +847,7 @@ out:
    ubifs_dump_leb(c, wbuf->lnum);
    return err;
  }
+#endif
 
  /**
   * ubifs_write_node - write node to the media.
@@ -885,7 +886,6 @@ int ubifs_write_node(struct ubifs_info *c, void
 *buf, int len, int lnum,
 
    return err;
  }
-#endif
 
  /**

* ubifs_read_node_wbuf - read node from the media or write-buffer.

fs/ubifs/log.c index a07fdef..10302b9 renamed from fs/ubifs/log.c +0 -0

100644

fs/ubifs/log.c +0 -0
@@ -743,3 +743,102 @@ static int dbg_check_bud_bytes(struct

ubifs_info
*c)

    return err;

}

fs/ubifs/log.c +71 -0
+
+
+/**
+ * ubifs_commit_required - set commit state to "required".
+ * @c: UBIFS file-system description object
+ *
+ * This function is called if a commit is required but cannot be
+done from the
+ * calling function, so it is just flagged instead.
+ */
+void ubifs_commit_required(struct ubifs_info *c) {
+   spin_lock(&c->cs_lock);
+   switch (c->cmt_state) {
+   case COMMIT_RESTING:
+   case COMMIT_BACKGROUND:
+           dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+                   dbg_cstate(COMMIT_REQUIRED));
+           c->cmt_state = COMMIT_REQUIRED;
+           break;
+   case COMMIT_RUNNING_BACKGROUND:
+           dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+                   dbg_cstate(COMMIT_RUNNING_REQUIRED));
+           c->cmt_state = COMMIT_RUNNING_REQUIRED;
+           break;
+   case COMMIT_REQUIRED:
+   case COMMIT_RUNNING_REQUIRED:
+   case COMMIT_BROKEN:
+           break;
+   }
+   spin_unlock(&c->cs_lock);
+}
+
+/**
+ * ubifs_write_master - write master node.
+ * @c: UBIFS file-system description object
+ *
+ * This function writes the master node. Returns zero in case of
+success and a
+ * negative error code in case of failure. The master node is
+written twice to
+ * enable recovery.
+ */
+int ubifs_write_master(struct ubifs_info *c) {
+   int err, lnum, offs, len;
+
+   ubifs_assert(!c->ro_media && !c->ro_mount);
+   if (c->ro_error)
+           return -EROFS;
+
+   lnum = UBIFS_MST_LNUM;
+   offs = c->mst_offs + c->mst_node_alsz;
+   len = UBIFS_MST_NODE_SZ;
+
+   if (offs + UBIFS_MST_NODE_SZ > c->leb_size) {
+           err = ubifs_leb_unmap(c, lnum);
+           if (err)
+                   return err;
+           offs = 0;
+   }
+
+   c->mst_offs = offs;
+   c->mst_node->highest_inum = cpu_to_le64(c->highest_inum);
+
+   err = ubifs_write_node(c, c->mst_node, len, lnum, offs);
+   if (err)
+           return err;
+
+   lnum += 1;
+
+   if (offs == 0) {
+           err = ubifs_leb_unmap(c, lnum);

fs/ubifs/log.c static int dbg_check_bud_bytes(struct ubifs_info *c)

Quoted 10 lines
fs/ubifs/log.c +10 -0
+           if (err)
+                   return err;
+   }
+   err = ubifs_write_node(c, c->mst_node, len, lnum, offs);
+
+   return err;
+}
+
+/**
+ * ubifs_request_bg_commit - notify the background thread to do a

commit.

Quoted 36 lines

+ * @c: UBIFS file-system description object
+ *
+ * This function is called if the journal is full enough to make a

fs/ubifs/log.c +15 -0
+commit
+ * worthwhile, so background thread is kicked to start it.
+ */
+void ubifs_request_bg_commit(struct ubifs_info *c) {
+   spin_lock(&c->cs_lock);
+   if (c->cmt_state == COMMIT_RESTING) {
+           dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+                   dbg_cstate(COMMIT_BACKGROUND));
+           c->cmt_state = COMMIT_BACKGROUND;
+           spin_unlock(&c->cs_lock);
+           ubifs_wake_up_bgt(c);
+   } else
+           spin_unlock(&c->cs_lock); }
+
+
fs/ubifs/lpt_commit.c index renamed from fs/ubifs/lpt_commit.c +0 -0

2df9130..61b2cc8 100644

fs/ubifs/lpt_commit.c +0 -0
@@ -2039,4 +2039,25 @@ static int dbg_populate_lsave(struct

ubifs_info
*c)

    return 1;

}

fs/ubifs/lpt_commit.c +7 -0
+#else
+
+int dbg_chk_lpt_free_spc(struct ubifs_info *c) {
+   return 0;
+}
+
+int dbg_check_ltab(struct ubifs_info *c) {

fs/ubifs/lpt_commit.c static int dbg_populate_lsave(struct ubifs_info *c) · line 2063

Quoted 10 lines
fs/ubifs/lpt_commit.c +9 -0
+   return 0;
+}
+
+int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) {
+   return 0;
+}
+
+void ubifs_dump_lpt_lebs(const struct ubifs_info *c) { }
+
  #endif

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

#5 lore raw

PATCH 1/1 getting ubifs to run

Hello Marco,

Am 01.09.2016 um 14:45 schrieb Hoefle Marco:

Quoted 2 lines

Hello Heiko and Michal,
Do you agree that the u-boot sources need to be adapted in order to have ubifs on the Microblaze?

As you found an error, yes!

Quoted 1 line

It would be good if the changes are somehow in the mainline.

Of course ... Hmm I wrote on"12.08.2016 07:05":

Quoted 9 lines

Hmm... what exactly do you fix? Can you add a commit message please?

It seems to me, you get ubifs working on microblaze arch?

And may you can split this patch into at least two pieces, one for the arch fixes, and one for the ubifs fixes?

ubifs read support works for me on some arm based plattforms ... what exactly do you fix with your fs/ubifs/* changes?

May I was unclear ... I am waiting for a v2 ;-)

Please split your patch into 2 pieces, write a commit message and resend them as a v2 to the list with Michal and me in CC

Thanks!

bye,
Heiko

Quoted 450 lines

BR
Marco

Quoted 445 lines

-----Original Message-----
From: Hoefle Marco
Sent: Montag, 15. August 2016 13:55
To: u-boot at lists.denx.de; hs at denx.de
Cc: monstr at monstr.eu
Subject: WG: [U-Boot] [PATCH] getting ubifs to run

Hello Heiko,
You are right, there are two parts: the Microblaze part and the ubifs stuff. To get u-boot compiled I added the following to the Microblaze architecture:
atomic.h based on the ARM architecture, was missing before. Modified bitops.h to get rid of compiler warnings The three ubifs files had #defines which didn't work for me.
With the changes of the patch I sent I can successfully load the Kernel from a ubifs partition on a Microblaze.

That were the problems:

CC fs/ubifs/ubifs.o
In file included from /home/hoefle/projects/u- boot_patch/fs/ubifs/ubifs.c:17:0:
/home/hoefle/projects/u-boot_patch/fs/ubifs/ubifs.h:35:24: fatal error:
asm/atomic.h: No such file or directory #include <asm/atomic.h>

                         ^

compilation terminated.

/home/hoefle/projects/u- boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected 'volatile void *' but argument is of type 'const long unsigned int *'
static inline int __test_bit(int nr, volatile void *addr)

                    ^

/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h: In function 'ubifs_zn_obsolete':
/home/hoefle/projects/u- boot_patch/arch/microblaze/include/asm/bitops.h:210:18: warning: passing argument 2 of '__test_bit' discards 'const' qualifier from pointer target type
__test_bit((nr),(addr)))

                   ^
/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h:38:11: note: in
expansion of macro 'test_bit'
   return !!test_bit(OBSOLETE_ZNODE, &znode->flags);
            ^

/home/hoefle/projects/u- boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected 'volatile void *' but argument is of type 'const long unsigned int *'
static inline int __test_bit(int nr, volatile void *addr)

                    ^

/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h: In function 'ubifs_zn_cow':
/home/hoefle/projects/u- boot_patch/arch/microblaze/include/asm/bitops.h:210:18: warning: passing argument 2 of '__test_bit' discards 'const' qualifier from pointer target type
__test_bit((nr),(addr)))

                   ^
/home/hoefle/projects/u-boot_patch/fs/ubifs/misc.h:50:11: note: in
expansion of macro 'test_bit'
   return !!test_bit(COW_ZNODE, &znode->flags);
            ^

/home/hoefle/projects/u- boot_patch/arch/microblaze/include/asm/bitops.h:197:19: note: expected 'volatile void *' but argument is of type 'const long unsigned int *'
static inline int __test_bit(int nr, volatile void *addr)

                    ^

fs/built-in.o: In function `ubifs_lpt_start_commit':
/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:1232:
undefined reference to `dbg_chk_lpt_free_spc' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:1235:
undefined reference to `dbg_check_ltab'
fs/built-in.o: In function `layout_cnodes':
/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:195: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:211: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:219: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:233: undefined reference to dbg_chk_lpt_sz' /home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:246: undefined reference to dbg_chk_lpt_sz' fs/built-in.o:/home/hoefle/projects/u- boot_patch/fs/ubifs/lpt_commit.c:254: more undefined references to dbg_chk_lpt_sz' follow
fs/built-in.o: In function `layout_cnodes':
/home/hoefle/projects/u-boot_patch/fs/ubifs/lpt_commit.c:322: undefined reference to `ubifs_dump_lpt_lebs'
fs/built-in.o: In function `ubifs_add_bud_to_log':
/home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:194: undefined reference to ubifs_commit_required' /home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:225: undefined reference to ubifs_request_bg_commit' /home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:265: undefined reference to `ubifs_write_node'
fs/built-in.o: In function `ubifs_log_end_commit':
/home/hoefle/projects/u-boot_patch/fs/ubifs/log.c:479: undefined reference to `ubifs_write_master'
fs/built-in.o: In function `write_orph_node':
/home/hoefle/projects/u-boot_patch/fs/ubifs/orphan.c:248: undefined reference to `ubifs_write_node'

Regards,
Marco

Quoted 335 lines

-----Original Message-----
From: Heiko Schocher [mailto:hs at denx.de]
Sent: Freitag, 12. August 2016 07:05
To: Hoefle Marco <[email protected]>
Cc: monstr at monstr.eu; u-boot at lists.denx.de
Subject: Re: [U-Boot] [PATCH] getting ubifs to run

Hello Marco,

Am 11.08.2016 um 11:56 schrieb Marco:

Quoted 3 lines
---
   arch/microblaze/include/asm/atomic.h | 114

+++++++++++++++++++++++++++++++++++

Quoted 6 lines
   arch/microblaze/include/asm/bitops.h |   8 +--
   fs/ubifs/io.c                        |   2 +-
   fs/ubifs/log.c                       |  99 ++++++++++++++++++++++++++++++
   fs/ubifs/lpt_commit.c                |  21 +++++++
   5 files changed, 239 insertions(+), 5 deletions(-)

create mode 100644 arch/microblaze/include/asm/atomic.h

Hmm... what exactly do you fix? Can you add a commit message please?

It seems to me, you get ubifs working on microblaze arch?

And may you can split this patch into at least two pieces, one for the arch fixes, and one for the ubifs fixes?

ubifs read support works for me on some arm based plattforms ... what exactly do you fix with your fs/ubifs/* changes?

Thanks!

bye,
Heiko

Quoted 123 lines
arch/microblaze/include/asm/atomic.h new file +110 -0
new file mode 100644
index 0000000..2872149
@@ -0,0 +1,114 @@
+/*
+ *  linux/include/asm-arm/atomic.h
+ *
+ *  Copyright (c) 1996 Russell King.
+ *
+ * This program is free software; you can redistribute it and/or
+modify
+ * it under the terms of the GNU General Public License version 2
+as
+ * published by the Free Software Foundation.
+ *
+ *  Changelog:
+ *   27-06-1996    RMK     Created
+ *   13-04-1997    RMK     Made functions atomic!
+ *   07-12-1997    RMK     Upgraded for v2.1.
+ *   26-08-1998    PJB     Added #ifdef __KERNEL__
+ */
+#ifndef __ASM_ARM_ATOMIC_H
+#define __ASM_ARM_ATOMIC_H
+
+#ifdef CONFIG_SMP
+#error SMP not supported
+#endif
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i)     { (i) }
+
+#ifdef __KERNEL__
+#include <asm/system.h>
+
+#define atomic_read(v)     ((v)->counter)
+#define atomic_set(v,i)    (((v)->counter) = (i))
+
+
+
+
+static inline void atomic_add(int i, volatile atomic_t *v) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter += i;
+   local_irq_restore(flags);
+}
+
+static inline void atomic_sub(int i, volatile atomic_t *v) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter -= i;
+   local_irq_restore(flags);
+}
+
+static inline void atomic_inc(volatile atomic_t *v) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter += 1;
+   local_irq_restore(flags);
+}
+
+static inline void atomic_dec(volatile atomic_t *v) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter -= 1;
+   local_irq_restore(flags);
+}
+
+static inline int atomic_dec_and_test(volatile atomic_t *v) {
+   unsigned long flags = 0;
+   int val;
+
+   local_irq_save(flags);
+   val = v->counter;
+   v->counter = val -= 1;
+   local_irq_restore(flags);
+
+   return val == 0;
+}
+
+static inline int atomic_add_negative(int i, volatile atomic_t *v) {
+   unsigned long flags = 0;
+   int val;
+
+   local_irq_save(flags);
+   val = v->counter;
+   v->counter = val += i;
+   local_irq_restore(flags);
+
+   return val < 0;
+}
+
+static inline void atomic_clear_mask(unsigned long mask, unsigned
+long *addr) {
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   *addr &= ~mask;
+   local_irq_restore(flags);
+}
+
+/* Atomic operations are already serializing on ARM */
+#define smp_mb__before_atomic_dec()        barrier()
+#define smp_mb__after_atomic_dec() barrier()
+#define smp_mb__before_atomic_inc()        barrier()
+#define smp_mb__after_atomic_inc() barrier()
+
+#endif
+#endif
arch/microblaze/include/asm/bitops.h +0 -0
index 2cab2ac..b3b17b9 100644
@@ -204,10 +204,10 @@ static inline int __test_bit(int nr, volatile
Quoted 1 line

void

*addr)

Quoted 113 lines
     return ((mask & *a) != 0);

}

arch/microblaze/include/asm/bitops.h +2 -4
-#define test_bit(nr,addr) \
-(__builtin_constant_p(nr) ? \
- __constant_test_bit((nr),(addr)) : \
- __test_bit((nr),(addr)))
+static inline int test_bit(int nr, const void * addr) {
+   return ((unsigned char *) addr)[nr >> 3] & (1U << (nr & 7)); }
 
   #define find_first_zero_bit(addr, size) \
     find_next_zero_bit((addr), (size), 0) diff --git a/fs/ubifs/io.c

b/fs/ubifs/io.c index 51a95bb..685713e 100644

fs/ubifs/io.c +1 -1
@@ -847,6 +847,7 @@ out:
     ubifs_dump_leb(c, wbuf->lnum);
     return err;
   }
+#endif
 
   /**
    * ubifs_write_node - write node to the media.
@@ -885,7 +886,6 @@ int ubifs_write_node(struct ubifs_info *c, void
 *buf, int len, int lnum,
 
     return err;
   }
-#endif
 
   /**

* ubifs_read_node_wbuf - read node from the media or write-buffer.

fs/ubifs/log.c index a07fdef..10302b9 renamed from fs/ubifs/log.c +0 -0

100644

fs/ubifs/log.c +0 -0
@@ -743,3 +743,102 @@ static int dbg_check_bud_bytes(struct

ubifs_info
*c)

     return err;

}

fs/ubifs/log.c +71 -0
+
+
+/**
+ * ubifs_commit_required - set commit state to "required".
+ * @c: UBIFS file-system description object
+ *
+ * This function is called if a commit is required but cannot be
+done from the
+ * calling function, so it is just flagged instead.
+ */
+void ubifs_commit_required(struct ubifs_info *c) {
+   spin_lock(&c->cs_lock);
+   switch (c->cmt_state) {
+   case COMMIT_RESTING:
+   case COMMIT_BACKGROUND:
+           dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+                   dbg_cstate(COMMIT_REQUIRED));
+           c->cmt_state = COMMIT_REQUIRED;
+           break;
+   case COMMIT_RUNNING_BACKGROUND:
+           dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+                   dbg_cstate(COMMIT_RUNNING_REQUIRED));
+           c->cmt_state = COMMIT_RUNNING_REQUIRED;
+           break;
+   case COMMIT_REQUIRED:
+   case COMMIT_RUNNING_REQUIRED:
+   case COMMIT_BROKEN:
+           break;
+   }
+   spin_unlock(&c->cs_lock);
+}
+
+/**
+ * ubifs_write_master - write master node.
+ * @c: UBIFS file-system description object
+ *
+ * This function writes the master node. Returns zero in case of
+success and a
+ * negative error code in case of failure. The master node is
+written twice to
+ * enable recovery.
+ */
+int ubifs_write_master(struct ubifs_info *c) {
+   int err, lnum, offs, len;
+
+   ubifs_assert(!c->ro_media && !c->ro_mount);
+   if (c->ro_error)
+           return -EROFS;
+
+   lnum = UBIFS_MST_LNUM;
+   offs = c->mst_offs + c->mst_node_alsz;
+   len = UBIFS_MST_NODE_SZ;
+
+   if (offs + UBIFS_MST_NODE_SZ > c->leb_size) {
+           err = ubifs_leb_unmap(c, lnum);
+           if (err)
+                   return err;
+           offs = 0;
+   }
+
+   c->mst_offs = offs;
+   c->mst_node->highest_inum = cpu_to_le64(c->highest_inum);
+
+   err = ubifs_write_node(c, c->mst_node, len, lnum, offs);
+   if (err)
+           return err;
+
+   lnum += 1;
+
+   if (offs == 0) {
+           err = ubifs_leb_unmap(c, lnum);

fs/ubifs/log.c static int dbg_check_bud_bytes(struct ubifs_info *c)

Quoted 10 lines
fs/ubifs/log.c +10 -0
+           if (err)
+                   return err;
+   }
+   err = ubifs_write_node(c, c->mst_node, len, lnum, offs);
+
+   return err;
+}
+
+/**
+ * ubifs_request_bg_commit - notify the background thread to do a

commit.

Quoted 36 lines

+ * @c: UBIFS file-system description object
+ *
+ * This function is called if the journal is full enough to make a

fs/ubifs/log.c +15 -0
+commit
+ * worthwhile, so background thread is kicked to start it.
+ */
+void ubifs_request_bg_commit(struct ubifs_info *c) {
+   spin_lock(&c->cs_lock);
+   if (c->cmt_state == COMMIT_RESTING) {
+           dbg_cmt("old: %s, new: %s", dbg_cstate(c->cmt_state),
+                   dbg_cstate(COMMIT_BACKGROUND));
+           c->cmt_state = COMMIT_BACKGROUND;
+           spin_unlock(&c->cs_lock);
+           ubifs_wake_up_bgt(c);
+   } else
+           spin_unlock(&c->cs_lock); }
+
+
fs/ubifs/lpt_commit.c index renamed from fs/ubifs/lpt_commit.c +0 -0

2df9130..61b2cc8 100644

fs/ubifs/lpt_commit.c +0 -0
@@ -2039,4 +2039,25 @@ static int dbg_populate_lsave(struct

ubifs_info
*c)

     return 1;

}

fs/ubifs/lpt_commit.c +7 -0
+#else
+
+int dbg_chk_lpt_free_spc(struct ubifs_info *c) {
+   return 0;
+}
+
+int dbg_check_ltab(struct ubifs_info *c) {

fs/ubifs/lpt_commit.c static int dbg_populate_lsave(struct ubifs_info *c) · line 2063

Quoted 10 lines
fs/ubifs/lpt_commit.c +9 -0
+   return 0;
+}
+
+int dbg_chk_lpt_sz(struct ubifs_info *c, int action, int len) {
+   return 0;
+}
+
+void ubifs_dump_lpt_lebs(const struct ubifs_info *c) { }
+
   #endif

--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

Signature · 2 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany