Commit 60b7eca1 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'upstream-4.5-rc1' of git://git.infradead.org/linux-ubifs

Pull UBI/UBIFS updates from Richard Weinberger:
 "This contains three changes - two cleanups and one UBI wear leveling
  improvement by Sebastian Siewior"

* tag 'upstream-4.5-rc1' of git://git.infradead.org/linux-ubifs:
  ubifs: Use XATTR_*_PREFIX_LEN
  UBIFS: add a comment in key.h for unused parameter
  mtd: ubi: wl: avoid erasing a PEB which is empty
parents 420d12d6 4fdd1d51
...@@ -628,6 +628,7 @@ static int do_sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, ...@@ -628,6 +628,7 @@ static int do_sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e,
return __erase_worker(ubi, &wl_wrk); return __erase_worker(ubi, &wl_wrk);
} }
static int ensure_wear_leveling(struct ubi_device *ubi, int nested);
/** /**
* wear_leveling_worker - wear-leveling worker function. * wear_leveling_worker - wear-leveling worker function.
* @ubi: UBI device description object * @ubi: UBI device description object
...@@ -649,6 +650,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, ...@@ -649,6 +650,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
#endif #endif
struct ubi_wl_entry *e1, *e2; struct ubi_wl_entry *e1, *e2;
struct ubi_vid_hdr *vid_hdr; struct ubi_vid_hdr *vid_hdr;
int dst_leb_clean = 0;
kfree(wrk); kfree(wrk);
if (shutdown) if (shutdown)
...@@ -753,6 +755,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, ...@@ -753,6 +755,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
err = ubi_io_read_vid_hdr(ubi, e1->pnum, vid_hdr, 0); err = ubi_io_read_vid_hdr(ubi, e1->pnum, vid_hdr, 0);
if (err && err != UBI_IO_BITFLIPS) { if (err && err != UBI_IO_BITFLIPS) {
dst_leb_clean = 1;
if (err == UBI_IO_FF) { if (err == UBI_IO_FF) {
/* /*
* We are trying to move PEB without a VID header. UBI * We are trying to move PEB without a VID header. UBI
...@@ -798,10 +801,12 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, ...@@ -798,10 +801,12 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
* protection queue. * protection queue.
*/ */
protect = 1; protect = 1;
dst_leb_clean = 1;
goto out_not_moved; goto out_not_moved;
} }
if (err == MOVE_RETRY) { if (err == MOVE_RETRY) {
scrubbing = 1; scrubbing = 1;
dst_leb_clean = 1;
goto out_not_moved; goto out_not_moved;
} }
if (err == MOVE_TARGET_BITFLIPS || err == MOVE_TARGET_WR_ERR || if (err == MOVE_TARGET_BITFLIPS || err == MOVE_TARGET_WR_ERR ||
...@@ -827,6 +832,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, ...@@ -827,6 +832,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
ubi->erroneous_peb_count); ubi->erroneous_peb_count);
goto out_error; goto out_error;
} }
dst_leb_clean = 1;
erroneous = 1; erroneous = 1;
goto out_not_moved; goto out_not_moved;
} }
...@@ -897,15 +903,24 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, ...@@ -897,15 +903,24 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
wl_tree_add(e1, &ubi->scrub); wl_tree_add(e1, &ubi->scrub);
else else
wl_tree_add(e1, &ubi->used); wl_tree_add(e1, &ubi->used);
if (dst_leb_clean) {
wl_tree_add(e2, &ubi->free);
ubi->free_count++;
}
ubi_assert(!ubi->move_to_put); ubi_assert(!ubi->move_to_put);
ubi->move_from = ubi->move_to = NULL; ubi->move_from = ubi->move_to = NULL;
ubi->wl_scheduled = 0; ubi->wl_scheduled = 0;
spin_unlock(&ubi->wl_lock); spin_unlock(&ubi->wl_lock);
ubi_free_vid_hdr(ubi, vid_hdr); ubi_free_vid_hdr(ubi, vid_hdr);
if (dst_leb_clean) {
ensure_wear_leveling(ubi, 1);
} else {
err = do_sync_erase(ubi, e2, vol_id, lnum, torture); err = do_sync_erase(ubi, e2, vol_id, lnum, torture);
if (err) if (err)
goto out_ro; goto out_ro;
}
mutex_unlock(&ubi->move_mutex); mutex_unlock(&ubi->move_mutex);
return 0; return 0;
......
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
* node. We use "r5" hash borrowed from reiserfs. * node. We use "r5" hash borrowed from reiserfs.
*/ */
/*
* Lot's of the key helpers require a struct ubifs_info *c as the first parameter.
* But we are not using it at all currently. That's designed for future extensions of
* different c->key_format. But right now, there is only one key type, UBIFS_SIMPLE_KEY_FMT.
*/
#ifndef __UBIFS_KEY_H__ #ifndef __UBIFS_KEY_H__
#define __UBIFS_KEY_H__ #define __UBIFS_KEY_H__
......
...@@ -267,7 +267,7 @@ static int check_namespace(const struct qstr *nm) ...@@ -267,7 +267,7 @@ static int check_namespace(const struct qstr *nm)
if (!strncmp(nm->name, XATTR_TRUSTED_PREFIX, if (!strncmp(nm->name, XATTR_TRUSTED_PREFIX,
XATTR_TRUSTED_PREFIX_LEN)) { XATTR_TRUSTED_PREFIX_LEN)) {
if (nm->name[sizeof(XATTR_TRUSTED_PREFIX) - 1] == '\0') if (nm->name[XATTR_TRUSTED_PREFIX_LEN] == '\0')
return -EINVAL; return -EINVAL;
type = TRUSTED_XATTR; type = TRUSTED_XATTR;
} else if (!strncmp(nm->name, XATTR_USER_PREFIX, } else if (!strncmp(nm->name, XATTR_USER_PREFIX,
...@@ -277,7 +277,7 @@ static int check_namespace(const struct qstr *nm) ...@@ -277,7 +277,7 @@ static int check_namespace(const struct qstr *nm)
type = USER_XATTR; type = USER_XATTR;
} else if (!strncmp(nm->name, XATTR_SECURITY_PREFIX, } else if (!strncmp(nm->name, XATTR_SECURITY_PREFIX,
XATTR_SECURITY_PREFIX_LEN)) { XATTR_SECURITY_PREFIX_LEN)) {
if (nm->name[sizeof(XATTR_SECURITY_PREFIX) - 1] == '\0') if (nm->name[XATTR_SECURITY_PREFIX_LEN] == '\0')
return -EINVAL; return -EINVAL;
type = SECURITY_XATTR; type = SECURITY_XATTR;
} else } else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment