Skip to contentSkip to conversation

ubifs: Import atomic_long operations from Linux

PATCH New Anton Habegger 1 participant 2 messages Jan 22, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 ubifs: Import atomic_long operations from Linux

This commit is a preperation for a subsequent UBIFS commit which needs atomic_long operations.

Therefor "include/asm-generic/atomic-long.h" is imported from 1860e37 Linux 3.15

---
Hello Heiko

Changes v2:
- Eliminate #ifndef __UBOOT__ as much as possible
- Added hash into commit log

As mentioned in the mail, it getting quite hard to eleminate all of __UBOOT__, since the arch specific asm/atomic.h would be needed.

 fs/ubifs/ubifs.c                  |   6 +
 fs/ubifs/ubifs.h                  |  12 +-
 include/asm-generic/atomic-long.h | 260 ++++++++++++++++++++++++++++++++++++++
 include/linux/compat.h            |   1 -
 4 files changed, 268 insertions(+), 11 deletions(-)
 create mode 100644 include/asm-generic/atomic-long.h
fs/ubifs/ubifs.c +6 -0
index 49e6f46..6dd6174 100644
@@ -150,6 +150,12 @@ static inline int crypto_comp_decompress(struct crypto_comp *tfm,
 
 	return 0;
 }
+
+/* from shrinker.c */
+
+/* Global clean znode counter (for all mounted UBIFS instances) */
+atomic_long_t ubifs_clean_zn_cnt;
+
 #endif
 
 /**
fs/ubifs/ubifs.h +2 -10
index c120261..a51b237 100644
@@ -31,6 +31,8 @@
 #include <linux/backing-dev.h>
 #include "ubifs-media.h"
 #else
+#include <asm/atomic.h>
+#include <asm-generic/atomic-long.h>
 #include <ubi_uboot.h>
 
 #include <linux/ctype.h>
@@ -63,16 +65,6 @@ struct page {
 
 void iput(struct inode *inode);
 
-/*
- * The atomic operations are used for budgeting etc which is not
- * needed for the read-only U-Boot implementation:
- */
-#define atomic_long_inc(a)
-#define atomic_long_dec(a)
-#define	atomic_long_sub(a, b)
-
-typedef unsigned long atomic_long_t;
-
 /* linux/include/time.h */
 #define NSEC_PER_SEC	1000000000L
 #define get_seconds()	0
include/asm-generic/atomic-long.h new file +260 -0

260 lines not on this page · raw message

include/linux/compat.h +0 -1
index b40133c..6eac17f 100644
@@ -262,7 +262,6 @@ typedef struct {
 
 /* from include/linux/types.h */
 
-typedef int	atomic_t;
 /**
  * struct callback_head - callback structure for use with RCU and task_work
  * @next: next update requests in a list
Signature · 1 line
1.9.1
#1 lore raw

PATCH v4 2/2 ubifs: Enable journal replay during mount

Enable ubifs_replay_journal during mount_ubifs, which was disabled before.

This commit fix an issue with unrecoverable ubifs volumes after power cut.

Therefor the gc.c is imported now from 1860e37 Linux 3.15

---
Changes for v2:
- clear formatting of patch
- use atomic_long_read

Changes for v3:
- create proper commit message
- add change log fot the patch

Changes for v4:
- add commit hash in commit log

 fs/ubifs/Makefile |   2 +-
 fs/ubifs/gc.c     | 987 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ubifs/replay.c |   4 -
 fs/ubifs/super.c  |   8 +-
 fs/ubifs/tnc.c    |   2 -
 5 files changed, 989 insertions(+), 14 deletions(-)
 create mode 100644 fs/ubifs/gc.c
fs/ubifs/Makefile +1 -1
index 8c8c6ac..5efb349 100644
@@ -12,4 +12,4 @@
 obj-y := ubifs.o io.o super.o sb.o master.o lpt.o
 obj-y += lpt_commit.o scan.o lprops.o
 obj-y += tnc.o tnc_misc.o debug.o crc16.o budget.o
-obj-y += log.o orphan.o recovery.o replay.o
+obj-y += log.o orphan.o recovery.o replay.o gc.o
fs/ubifs/gc.c new file +987 -0

987 lines not on this page · raw message

fs/ubifs/replay.c +0 -4
index 7268b37..1064cb2 100644
@@ -78,7 +78,6 @@ struct bud_entry {
 	int dirty;
 };
 
-#ifndef __UBOOT__
 /**
  * set_bud_lprops - set free and dirty space used by a bud.
  * @c: UBIFS file-system description object
@@ -432,7 +431,6 @@ static int insert_dent(struct ubifs_info *c, int lnum, int offs, int len,
 	list_add_tail(&r->list, &c->replay_list);
 	return 0;
 }
-#endif
 
 /**
  * ubifs_validate_entry - validate directory or extended attribute entry node.
@@ -466,7 +464,6 @@ int ubifs_validate_entry(struct ubifs_info *c,
 	return 0;
 }
 
-#ifndef __UBOOT__
 /**
  * is_last_bud - check if the bud is the last in the journal head.
  * @c: UBIFS file-system description object
@@ -1063,4 +1060,3 @@ out:
 	c->replaying = 0;
 	return err;
 }
-#endif
fs/ubifs/super.c +1 -7
index 01d449a..10f8fff 100644
@@ -1049,7 +1049,6 @@ static void free_orphans(struct ubifs_info *c)
 	c->orph_buf = NULL;
 }
 
-#ifndef __UBOOT__
 /**
  * free_buds - free per-bud objects.
  * @c: UBIFS file-system description object
@@ -1061,7 +1060,6 @@ static void free_buds(struct ubifs_info *c)
 	rbtree_postorder_for_each_entry_safe(bud, n, &c->buds, rb)
 		kfree(bud);
 }
-#endif
 
 /**
  * check_volume_empty - check if the UBI volume is empty.
@@ -1242,6 +1240,7 @@ static int ubifs_parse_options(struct ubifs_info *c, char *options,
 
 	return 0;
 }
+#endif
 
 /**
  * destroy_journal - destroy journal data structures.
@@ -1272,7 +1271,6 @@ static void destroy_journal(struct ubifs_info *c)
 	ubifs_tnc_close(c);
 	free_buds(c);
 }
-#endif
 
 /**
  * bu_init - initialize bulk-read information.
@@ -1502,11 +1500,9 @@ static int mount_ubifs(struct ubifs_info *c)
 	if (err)
 		goto out_lpt;
 
-#ifndef __UBOOT__
 	err = ubifs_replay_journal(c);
 	if (err)
 		goto out_journal;
-#endif
 
 	/* Calculate 'min_idx_lebs' after journal replay */
 	c->bi.min_idx_lebs = ubifs_calc_min_idx_lebs(c);
@@ -1678,10 +1674,8 @@ out_infos:
 	spin_unlock(&ubifs_infos_lock);
 out_orphans:
 	free_orphans(c);
-#ifndef __UBOOT__
 out_journal:
 	destroy_journal(c);
-#endif
 out_lpt:
 	ubifs_lpt_free(c, 0);
 out_master:
fs/ubifs/tnc.c +0 -2
index 95cae54..e20cedd 100644
@@ -2827,7 +2827,6 @@ out_unlock:
 	return ERR_PTR(err);
 }
 
-#ifndef __UBOOT__
 /**
  * tnc_destroy_cnext - destroy left-over obsolete znodes from a failed commit.
  * @c: UBIFS file-system description object
@@ -2869,7 +2868,6 @@ void ubifs_tnc_close(struct ubifs_info *c)
 	kfree(c->ilebs);
 	destroy_old_idx(c);
 }
-#endif
 
 /**
  * left_znode - get the znode to the left.
Signature · 1 line
1.9.1