Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 21d3bdb1 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'linux-next' of git://git.infradead.org/~dedekind/ubifs-2.6

* 'linux-next' of git://git.infradead.org/~dedekind/ubifs-2.6: (29 commits)
  UBIFS: xattr bugfixes
  UBIFS: remove unneeded check
  UBIFS: few commentary fixes
  UBIFS: fix budgeting request alignment in xattr code
  UBIFS: improve arguments checking in debugging messages
  UBIFS: always set i_generation to 0
  UBIFS: correct spelling of "thrice".
  UBIFS: support splice_write
  UBIFS: minor tweaks in commit
  UBIFS: reserve more space for index
  UBIFS: print pid in dump function
  UBIFS: align inode data to eight
  UBIFS: improve budgeting checks
  UBIFS: correct orphan deletion order
  UBIFS: fix typos in comments
  UBIFS: do not union creat_sqnum and del_cmtno
  UBIFS: optimize deletions
  UBIFS: increment commit number earlier
  UBIFS: remove another unneeded function parameter
  UBIFS: remove unneeded function parameter
  ...
parents 3141eb6c c78c7e35
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ Similarly to JFFS2, UBIFS supports on-the-flight compression which makes
it possible to fit quite a lot of data to the flash.

Similarly to JFFS2, UBIFS is tolerant of unclean reboots and power-cuts.
It does not need stuff like ckfs.ext2. UBIFS automatically replays its
It does not need stuff like fsck.ext2. UBIFS automatically replays its
journal and recovers from crashes, ensuring that the on-flash data
structures are consistent.

+27 −6
Original line number Diff line number Diff line
@@ -263,8 +263,8 @@ int ubifs_calc_min_idx_lebs(struct ubifs_info *c)

	idx_size = c->old_idx_sz + c->budg_idx_growth + c->budg_uncommitted_idx;

	/* And make sure we have twice the index size of space reserved */
	idx_size <<= 1;
	/* And make sure we have thrice the index size of space reserved */
	idx_size = idx_size + (idx_size << 1);

	/*
	 * We do not maintain 'old_idx_size' as 'old_idx_lebs'/'old_idx_bytes'
@@ -388,11 +388,11 @@ static int can_use_rp(struct ubifs_info *c)
 * This function makes sure UBIFS has enough free eraseblocks for index growth
 * and data.
 *
 * When budgeting index space, UBIFS reserves twice as more LEBs as the index
 * When budgeting index space, UBIFS reserves thrice as many LEBs as the index
 * would take if it was consolidated and written to the flash. This guarantees
 * that the "in-the-gaps" commit method always succeeds and UBIFS will always
 * be able to commit dirty index. So this function basically adds amount of
 * budgeted index space to the size of the current index, multiplies this by 2,
 * budgeted index space to the size of the current index, multiplies this by 3,
 * and makes sure this does not exceed the amount of free eraseblocks.
 *
 * Notes about @c->min_idx_lebs and @c->lst.idx_lebs variables:
@@ -543,8 +543,16 @@ int ubifs_budget_space(struct ubifs_info *c, struct ubifs_budget_req *req)
	int err, idx_growth, data_growth, dd_growth;
	struct retries_info ri;

	ubifs_assert(req->new_page <= 1);
	ubifs_assert(req->dirtied_page <= 1);
	ubifs_assert(req->new_dent <= 1);
	ubifs_assert(req->mod_dent <= 1);
	ubifs_assert(req->new_ino <= 1);
	ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA);
	ubifs_assert(req->dirtied_ino <= 4);
	ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4);
	ubifs_assert(!(req->new_ino_d & 7));
	ubifs_assert(!(req->dirtied_ino_d & 7));

	data_growth = calc_data_growth(c, req);
	dd_growth = calc_dd_growth(c, req);
@@ -618,8 +626,16 @@ again:
 */
void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req)
{
	ubifs_assert(req->new_page <= 1);
	ubifs_assert(req->dirtied_page <= 1);
	ubifs_assert(req->new_dent <= 1);
	ubifs_assert(req->mod_dent <= 1);
	ubifs_assert(req->new_ino <= 1);
	ubifs_assert(req->new_ino_d <= UBIFS_MAX_INO_DATA);
	ubifs_assert(req->dirtied_ino <= 4);
	ubifs_assert(req->dirtied_ino_d <= UBIFS_MAX_INO_DATA * 4);
	ubifs_assert(!(req->new_ino_d & 7));
	ubifs_assert(!(req->dirtied_ino_d & 7));
	if (!req->recalculate) {
		ubifs_assert(req->idx_growth >= 0);
		ubifs_assert(req->data_growth >= 0);
@@ -647,7 +663,11 @@ void ubifs_release_budget(struct ubifs_info *c, struct ubifs_budget_req *req)

	ubifs_assert(c->budg_idx_growth >= 0);
	ubifs_assert(c->budg_data_growth >= 0);
	ubifs_assert(c->budg_dd_growth >= 0);
	ubifs_assert(c->min_idx_lebs < c->main_lebs);
	ubifs_assert(!(c->budg_idx_growth & 7));
	ubifs_assert(!(c->budg_data_growth & 7));
	ubifs_assert(!(c->budg_dd_growth & 7));
	spin_unlock(&c->space_lock);
}

@@ -686,9 +706,10 @@ void ubifs_convert_page_budget(struct ubifs_info *c)
void ubifs_release_dirty_inode_budget(struct ubifs_info *c,
				      struct ubifs_inode *ui)
{
	struct ubifs_budget_req req = {.dd_growth = c->inode_budget,
				       .dirtied_ino_d = ui->data_len};
	struct ubifs_budget_req req;

	memset(&req, 0, sizeof(struct ubifs_budget_req));
	req.dd_growth = c->inode_budget + ALIGN(ui->data_len, 8);
	ubifs_release_budget(c, &req);
}

+2 −1
Original line number Diff line number Diff line
@@ -74,6 +74,7 @@ static int do_commit(struct ubifs_info *c)
			goto out_up;
	}

	c->cmt_no += 1;
	err = ubifs_gc_start_commit(c);
	if (err)
		goto out_up;
@@ -115,7 +116,7 @@ static int do_commit(struct ubifs_info *c)
		goto out;

	mutex_lock(&c->mst_mutex);
	c->mst_node->cmt_no      = cpu_to_le64(++c->cmt_no);
	c->mst_node->cmt_no      = cpu_to_le64(c->cmt_no);
	c->mst_node->log_lnum    = cpu_to_le32(new_ltail_lnum);
	c->mst_node->root_lnum   = cpu_to_le32(zroot.lnum);
	c->mst_node->root_offs   = cpu_to_le32(zroot.offs);
+14 −13
Original line number Diff line number Diff line
@@ -568,8 +568,8 @@ void dbg_dump_budget_req(const struct ubifs_budget_req *req)
void dbg_dump_lstats(const struct ubifs_lp_stats *lst)
{
	spin_lock(&dbg_lock);
	printk(KERN_DEBUG "Lprops statistics: empty_lebs %d, idx_lebs  %d\n",
	       lst->empty_lebs, lst->idx_lebs);
	printk(KERN_DEBUG "(pid %d) Lprops statistics: empty_lebs %d, "
	       "idx_lebs  %d\n", current->pid, lst->empty_lebs, lst->idx_lebs);
	printk(KERN_DEBUG "\ttaken_empty_lebs %d, total_free %lld, "
	       "total_dirty %lld\n", lst->taken_empty_lebs, lst->total_free,
	       lst->total_dirty);
@@ -587,8 +587,8 @@ void dbg_dump_budg(struct ubifs_info *c)
	struct ubifs_gced_idx_leb *idx_gc;

	spin_lock(&dbg_lock);
	printk(KERN_DEBUG "Budgeting info: budg_data_growth %lld, "
	       "budg_dd_growth %lld, budg_idx_growth %lld\n",
	printk(KERN_DEBUG "(pid %d) Budgeting info: budg_data_growth %lld, "
	       "budg_dd_growth %lld, budg_idx_growth %lld\n", current->pid,
	       c->budg_data_growth, c->budg_dd_growth, c->budg_idx_growth);
	printk(KERN_DEBUG "\tdata budget sum %lld, total budget sum %lld, "
	       "freeable_cnt %d\n", c->budg_data_growth + c->budg_dd_growth,
@@ -634,7 +634,7 @@ void dbg_dump_lprops(struct ubifs_info *c)
	struct ubifs_lprops lp;
	struct ubifs_lp_stats lst;

	printk(KERN_DEBUG "Dumping LEB properties\n");
	printk(KERN_DEBUG "(pid %d) Dumping LEB properties\n", current->pid);
	ubifs_get_lp_stats(c, &lst);
	dbg_dump_lstats(&lst);

@@ -655,7 +655,7 @@ void dbg_dump_leb(const struct ubifs_info *c, int lnum)
	if (dbg_failure_mode)
		return;

	printk(KERN_DEBUG "Dumping LEB %d\n", lnum);
	printk(KERN_DEBUG "(pid %d) Dumping LEB %d\n", current->pid, lnum);

	sleb = ubifs_scan(c, lnum, 0, c->dbg_buf);
	if (IS_ERR(sleb)) {
@@ -720,8 +720,8 @@ void dbg_dump_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat)
{
	int i;

	printk(KERN_DEBUG "Dumping heap cat %d (%d elements)\n",
	       cat, heap->cnt);
	printk(KERN_DEBUG "(pid %d) Dumping heap cat %d (%d elements)\n",
	       current->pid, cat, heap->cnt);
	for (i = 0; i < heap->cnt; i++) {
		struct ubifs_lprops *lprops = heap->arr[i];

@@ -736,7 +736,7 @@ void dbg_dump_pnode(struct ubifs_info *c, struct ubifs_pnode *pnode,
{
	int i;

	printk(KERN_DEBUG "Dumping pnode:\n");
	printk(KERN_DEBUG "(pid %d) Dumping pnode:\n", current->pid);
	printk(KERN_DEBUG "\taddress %zx parent %zx cnext %zx\n",
	       (size_t)pnode, (size_t)parent, (size_t)pnode->cnext);
	printk(KERN_DEBUG "\tflags %lu iip %d level %d num %d\n",
@@ -755,7 +755,7 @@ void dbg_dump_tnc(struct ubifs_info *c)
	int level;

	printk(KERN_DEBUG "\n");
	printk(KERN_DEBUG "Dumping the TNC tree\n");
	printk(KERN_DEBUG "(pid %d) Dumping the TNC tree\n", current->pid);
	znode = ubifs_tnc_levelorder_next(c->zroot.znode, NULL);
	level = znode->level;
	printk(KERN_DEBUG "== Level %d ==\n", level);
@@ -2208,16 +2208,17 @@ int dbg_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset,
int dbg_leb_write(struct ubi_volume_desc *desc, int lnum, const void *buf,
		  int offset, int len, int dtype)
{
	int err;
	int err, failing;

	if (in_failure_mode(desc))
		return -EIO;
	if (do_fail(desc, lnum, 1))
	failing = do_fail(desc, lnum, 1);
	if (failing)
		cut_data(buf, len);
	err = ubi_leb_write(desc, lnum, buf, offset, len, dtype);
	if (err)
		return err;
	if (in_failure_mode(desc))
	if (failing)
		return -EIO;
	return 0;
}
+69 −74
Original line number Diff line number Diff line
@@ -73,7 +73,7 @@ const char *dbg_key_str1(const struct ubifs_info *c,
			 const union ubifs_key *key);

/*
 * DBGKEY macros require dbg_lock to be held, which it is in the dbg message
 * DBGKEY macros require @dbg_lock to be held, which it is in the dbg message
 * macros.
 */
#define DBGKEY(key) dbg_key_str0(c, (key))
@@ -239,34 +239,23 @@ typedef int (*dbg_leaf_callback)(struct ubifs_info *c,
				 struct ubifs_zbranch *zbr, void *priv);
typedef int (*dbg_znode_callback)(struct ubifs_info *c,
				  struct ubifs_znode *znode, void *priv);

int dbg_walk_index(struct ubifs_info *c, dbg_leaf_callback leaf_cb,
		   dbg_znode_callback znode_cb, void *priv);

/* Checking functions */

int dbg_check_lprops(struct ubifs_info *c);

int dbg_old_index_check_init(struct ubifs_info *c, struct ubifs_zbranch *zroot);
int dbg_check_old_index(struct ubifs_info *c, struct ubifs_zbranch *zroot);

int dbg_check_cats(struct ubifs_info *c);

int dbg_check_ltab(struct ubifs_info *c);

int dbg_check_synced_i_size(struct inode *inode);

int dbg_check_dir_size(struct ubifs_info *c, const struct inode *dir);

int dbg_check_tnc(struct ubifs_info *c, int extra);

int dbg_check_idx_size(struct ubifs_info *c, long long idx_size);

int dbg_check_filesystem(struct ubifs_info *c);

void dbg_check_heap(struct ubifs_info *c, struct ubifs_lpt_heap *heap, int cat,
		    int add_pos);

int dbg_check_lprops(struct ubifs_info *c);
int dbg_check_lpt_nodes(struct ubifs_info *c, struct ubifs_cnode *cnode,
			int row, int col);
@@ -329,26 +318,44 @@ static inline int dbg_change(struct ubi_volume_desc *desc, int lnum,
#else /* !CONFIG_UBIFS_FS_DEBUG */

#define UBIFS_DBG(op)
#define ubifs_assert(expr)                         ({})
#define ubifs_assert_cmt_locked(c)

/* Use "if (0)" to make compiler check arguments even if debugging is off */
#define ubifs_assert(expr)  do {                                               \
	if (0 && (expr))                                                       \
		printk(KERN_CRIT "UBIFS assert failed in %s at %u (pid %d)\n", \
		       __func__, __LINE__, current->pid);                      \
} while (0)

#define dbg_err(fmt, ...)   do {                                               \
	if (0)                                                                 \
		ubifs_err(fmt, ##__VA_ARGS__);                                 \
} while (0)

#define dbg_msg(fmt, ...) do {                                                 \
	if (0)                                                                 \
		printk(KERN_DEBUG "UBIFS DBG (pid %d): %s: " fmt "\n",         \
		       current->pid, __func__, ##__VA_ARGS__);                 \
} while (0)

#define dbg_dump_stack()
#define dbg_err(fmt, ...)                          ({})
#define dbg_msg(fmt, ...)                          ({})
#define dbg_key(c, key, fmt, ...)                  ({})

#define dbg_gen(fmt, ...)                          ({})
#define dbg_jnl(fmt, ...)                          ({})
#define dbg_tnc(fmt, ...)                          ({})
#define dbg_lp(fmt, ...)                           ({})
#define dbg_find(fmt, ...)                         ({})
#define dbg_mnt(fmt, ...)                          ({})
#define dbg_io(fmt, ...)                           ({})
#define dbg_cmt(fmt, ...)                          ({})
#define dbg_budg(fmt, ...)                         ({})
#define dbg_log(fmt, ...)                          ({})
#define dbg_gc(fmt, ...)                           ({})
#define dbg_scan(fmt, ...)                         ({})
#define dbg_rcvry(fmt, ...)                        ({})
#define ubifs_assert_cmt_locked(c)

#define dbg_gen(fmt, ...)   dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_jnl(fmt, ...)   dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_tnc(fmt, ...)   dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_lp(fmt, ...)    dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_find(fmt, ...)  dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_mnt(fmt, ...)   dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_io(fmt, ...)    dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_cmt(fmt, ...)   dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_budg(fmt, ...)  dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_log(fmt, ...)   dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_gc(fmt, ...)    dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_scan(fmt, ...)  dbg_msg(fmt, ##__VA_ARGS__)
#define dbg_rcvry(fmt, ...) dbg_msg(fmt, ##__VA_ARGS__)

#define DBGKEY(key)  ((char *)(key))
#define DBGKEY1(key) ((char *)(key))

#define dbg_ntype(type)                       ""
#define dbg_cstate(cmt_state)                 ""
@@ -368,32 +375,20 @@ static inline int dbg_change(struct ubi_volume_desc *desc, int lnum,
#define dbg_dump_index(c)                     ({})

#define dbg_walk_index(c, leaf_cb, znode_cb, priv) 0

#define dbg_old_index_check_init(c, zroot)         0
#define dbg_check_old_index(c, zroot)              0

#define dbg_check_cats(c)                          0

#define dbg_check_ltab(c)                          0

#define dbg_check_synced_i_size(inode)             0

#define dbg_check_dir_size(c, dir)                 0

#define dbg_check_tnc(c, x)                        0

#define dbg_check_idx_size(c, idx_size)            0

#define dbg_check_filesystem(c)                    0

#define dbg_check_heap(c, heap, cat, add_pos)      ({})

#define dbg_check_lprops(c)                        0
#define dbg_check_lpt_nodes(c, cnode, row, col)    0

#define dbg_force_in_the_gaps_enabled              0
#define dbg_force_in_the_gaps()                    0

#define dbg_failure_mode                           0
#define dbg_failure_mode_registration(c)           ({})
#define dbg_failure_mode_deregistration(c)         ({})
Loading