Skip to content

Commit 60b7eca

Browse files
committed
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
2 parents 420d12d + 4fdd1d5 commit 60b7eca

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

drivers/mtd/ubi/wl.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,7 @@ static int do_sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e,
628628
return __erase_worker(ubi, &wl_wrk);
629629
}
630630

631+
static int ensure_wear_leveling(struct ubi_device *ubi, int nested);
631632
/**
632633
* wear_leveling_worker - wear-leveling worker function.
633634
* @ubi: UBI device description object
@@ -649,6 +650,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
649650
#endif
650651
struct ubi_wl_entry *e1, *e2;
651652
struct ubi_vid_hdr *vid_hdr;
653+
int dst_leb_clean = 0;
652654

653655
kfree(wrk);
654656
if (shutdown)
@@ -753,6 +755,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
753755

754756
err = ubi_io_read_vid_hdr(ubi, e1->pnum, vid_hdr, 0);
755757
if (err && err != UBI_IO_BITFLIPS) {
758+
dst_leb_clean = 1;
756759
if (err == UBI_IO_FF) {
757760
/*
758761
* 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,
798801
* protection queue.
799802
*/
800803
protect = 1;
804+
dst_leb_clean = 1;
801805
goto out_not_moved;
802806
}
803807
if (err == MOVE_RETRY) {
804808
scrubbing = 1;
809+
dst_leb_clean = 1;
805810
goto out_not_moved;
806811
}
807812
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,
827832
ubi->erroneous_peb_count);
828833
goto out_error;
829834
}
835+
dst_leb_clean = 1;
830836
erroneous = 1;
831837
goto out_not_moved;
832838
}
@@ -897,15 +903,24 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
897903
wl_tree_add(e1, &ubi->scrub);
898904
else
899905
wl_tree_add(e1, &ubi->used);
906+
if (dst_leb_clean) {
907+
wl_tree_add(e2, &ubi->free);
908+
ubi->free_count++;
909+
}
910+
900911
ubi_assert(!ubi->move_to_put);
901912
ubi->move_from = ubi->move_to = NULL;
902913
ubi->wl_scheduled = 0;
903914
spin_unlock(&ubi->wl_lock);
904915

905916
ubi_free_vid_hdr(ubi, vid_hdr);
906-
err = do_sync_erase(ubi, e2, vol_id, lnum, torture);
907-
if (err)
908-
goto out_ro;
917+
if (dst_leb_clean) {
918+
ensure_wear_leveling(ubi, 1);
919+
} else {
920+
err = do_sync_erase(ubi, e2, vol_id, lnum, torture);
921+
if (err)
922+
goto out_ro;
923+
}
909924

910925
mutex_unlock(&ubi->move_mutex);
911926
return 0;

fs/ubifs/key.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@
3434
* node. We use "r5" hash borrowed from reiserfs.
3535
*/
3636

37+
/*
38+
* Lot's of the key helpers require a struct ubifs_info *c as the first parameter.
39+
* But we are not using it at all currently. That's designed for future extensions of
40+
* different c->key_format. But right now, there is only one key type, UBIFS_SIMPLE_KEY_FMT.
41+
*/
42+
3743
#ifndef __UBIFS_KEY_H__
3844
#define __UBIFS_KEY_H__
3945

fs/ubifs/xattr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static int check_namespace(const struct qstr *nm)
267267

268268
if (!strncmp(nm->name, XATTR_TRUSTED_PREFIX,
269269
XATTR_TRUSTED_PREFIX_LEN)) {
270-
if (nm->name[sizeof(XATTR_TRUSTED_PREFIX) - 1] == '\0')
270+
if (nm->name[XATTR_TRUSTED_PREFIX_LEN] == '\0')
271271
return -EINVAL;
272272
type = TRUSTED_XATTR;
273273
} else if (!strncmp(nm->name, XATTR_USER_PREFIX,
@@ -277,7 +277,7 @@ static int check_namespace(const struct qstr *nm)
277277
type = USER_XATTR;
278278
} else if (!strncmp(nm->name, XATTR_SECURITY_PREFIX,
279279
XATTR_SECURITY_PREFIX_LEN)) {
280-
if (nm->name[sizeof(XATTR_SECURITY_PREFIX) - 1] == '\0')
280+
if (nm->name[XATTR_SECURITY_PREFIX_LEN] == '\0')
281281
return -EINVAL;
282282
type = SECURITY_XATTR;
283283
} else

0 commit comments

Comments
 (0)