Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 305162
b: refs/heads/master
c: 7bf523a
h: refs/heads/master
v: v3
  • Loading branch information
Artem Bityutskiy committed May 20, 2012
1 parent 7999d59 commit bb36de5
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 55 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8056eb4ac451cdf4723ba22471899d3d18a7dcbb
refs/heads/master: 7bf523ae252d654f1fa85c5e8759f221afe1c593
8 changes: 4 additions & 4 deletions trunk/drivers/mtd/ubi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
#include <linux/random.h>
#include "ubi.h"

static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si);
static int self_check_si(struct ubi_device *ubi, struct ubi_scan_info *si);

/* Temporary variables used during scanning */
static struct ubi_ec_hdr *ech;
Expand Down Expand Up @@ -1218,7 +1218,7 @@ struct ubi_scan_info *ubi_scan(struct ubi_device *ubi)
if (seb->ec == UBI_SCAN_UNKNOWN_EC)
seb->ec = si->mean_ec;

err = paranoid_check_si(ubi, si);
err = self_check_si(ubi, si);
if (err)
goto out_vidh;

Expand Down Expand Up @@ -1326,14 +1326,14 @@ void ubi_scan_destroy_si(struct ubi_scan_info *si)
}

/**
* paranoid_check_si - check the scanning information.
* self_check_si - check the scanning information.
* @ubi: UBI device description object
* @si: scanning information
*
* This function returns zero if the scanning information is all right, and a
* negative error code if not or if an error occurred.
*/
static int paranoid_check_si(struct ubi_device *ubi, struct ubi_scan_info *si)
static int self_check_si(struct ubi_device *ubi, struct ubi_scan_info *si)
{
int pnum, err, vols_found = 0;
struct rb_node *rb1, *rb2;
Expand Down
31 changes: 14 additions & 17 deletions trunk/drivers/mtd/ubi/vmt.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <linux/export.h>
#include "ubi.h"

static int paranoid_check_volumes(struct ubi_device *ubi);
static int self_check_volumes(struct ubi_device *ubi);

static ssize_t vol_attribute_show(struct device *dev,
struct device_attribute *attr, char *buf);
Expand Down Expand Up @@ -356,8 +356,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
spin_unlock(&ubi->volumes_lock);

ubi_volume_notify(ubi, vol, UBI_VOLUME_ADDED);
if (paranoid_check_volumes(ubi))
dbg_err("check failed while creating volume %d", vol_id);
self_check_volumes(ubi);
return err;

out_sysfs:
Expand Down Expand Up @@ -457,8 +456,8 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
spin_unlock(&ubi->volumes_lock);

ubi_volume_notify(ubi, vol, UBI_VOLUME_REMOVED);
if (!no_vtbl && paranoid_check_volumes(ubi))
dbg_err("check failed while removing volume %d", vol_id);
if (!no_vtbl)
self_check_volumes(ubi);

return err;

Expand Down Expand Up @@ -584,8 +583,7 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
}

ubi_volume_notify(ubi, vol, UBI_VOLUME_RESIZED);
if (paranoid_check_volumes(ubi))
dbg_err("check failed while re-sizing volume %d", vol_id);
self_check_volumes(ubi);
return err;

out_acc:
Expand Down Expand Up @@ -634,8 +632,8 @@ int ubi_rename_volumes(struct ubi_device *ubi, struct list_head *rename_list)
}
}

if (!err && paranoid_check_volumes(ubi))
;
if (!err)
self_check_volumes(ubi);
return err;
}

Expand Down Expand Up @@ -682,8 +680,7 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol)
return err;
}

if (paranoid_check_volumes(ubi))
dbg_err("check failed while adding volume %d", vol_id);
self_check_volumes(ubi);
return err;

out_cdev:
Expand All @@ -709,13 +706,13 @@ void ubi_free_volume(struct ubi_device *ubi, struct ubi_volume *vol)
}

/**
* paranoid_check_volume - check volume information.
* self_check_volume - check volume information.
* @ubi: UBI device description object
* @vol_id: volume ID
*
* Returns zero if volume is all right and a a negative error code if not.
*/
static int paranoid_check_volume(struct ubi_device *ubi, int vol_id)
static int self_check_volume(struct ubi_device *ubi, int vol_id)
{
int idx = vol_id2idx(ubi, vol_id);
int reserved_pebs, alignment, data_pad, vol_type, name_len, upd_marker;
Expand Down Expand Up @@ -847,7 +844,7 @@ static int paranoid_check_volume(struct ubi_device *ubi, int vol_id)
return 0;

fail:
ubi_err("paranoid check failed for volume %d", vol_id);
ubi_err("self-check failed for volume %d", vol_id);
if (vol)
ubi_dump_vol_info(vol);
ubi_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id);
Expand All @@ -857,20 +854,20 @@ static int paranoid_check_volume(struct ubi_device *ubi, int vol_id)
}

/**
* paranoid_check_volumes - check information about all volumes.
* self_check_volumes - check information about all volumes.
* @ubi: UBI device description object
*
* Returns zero if volumes are all right and a a negative error code if not.
*/
static int paranoid_check_volumes(struct ubi_device *ubi)
static int self_check_volumes(struct ubi_device *ubi)
{
int i, err = 0;

if (!ubi->dbg->chk_gen)
return 0;

for (i = 0; i < ubi->vtbl_slots; i++) {
err = paranoid_check_volume(ubi, i);
err = self_check_volume(ubi, i);
if (err)
break;
}
Expand Down
10 changes: 5 additions & 5 deletions trunk/drivers/mtd/ubi/vtbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include <asm/div64.h>
#include "ubi.h"

static void paranoid_vtbl_check(const struct ubi_device *ubi);
static void self_vtbl_check(const struct ubi_device *ubi);

/* Empty volume table record */
static struct ubi_vtbl_record empty_vtbl_record;
Expand Down Expand Up @@ -107,7 +107,7 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx,
return err;
}

paranoid_vtbl_check(ubi);
self_vtbl_check(ubi);
return 0;
}

Expand Down Expand Up @@ -855,16 +855,16 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si)
}

/**
* paranoid_vtbl_check - check volume table.
* self_vtbl_check - check volume table.
* @ubi: UBI device description object
*/
static void paranoid_vtbl_check(const struct ubi_device *ubi)
static void self_vtbl_check(const struct ubi_device *ubi)
{
if (!ubi->dbg->chk_gen)
return;

if (vtbl_check(ubi, ubi->vtbl)) {
ubi_err("paranoid check failed");
ubi_err("self-check failed");
BUG();
}
}
54 changes: 26 additions & 28 deletions trunk/drivers/mtd/ubi/wl.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,11 @@ struct ubi_work {
int torture;
};

static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec);
static int paranoid_check_in_wl_tree(const struct ubi_device *ubi,
struct ubi_wl_entry *e,
struct rb_root *root);
static int paranoid_check_in_pq(const struct ubi_device *ubi,
struct ubi_wl_entry *e);
static int self_check_ec(struct ubi_device *ubi, int pnum, int ec);
static int self_check_in_wl_tree(const struct ubi_device *ubi,
struct ubi_wl_entry *e, struct rb_root *root);
static int self_check_in_pq(const struct ubi_device *ubi,
struct ubi_wl_entry *e);

/**
* wl_tree_add - add a wear-leveling entry to a WL RB-tree.
Expand Down Expand Up @@ -404,7 +403,7 @@ int ubi_wl_get_peb(struct ubi_device *ubi)
else
e = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF/2);

paranoid_check_in_wl_tree(ubi, e, &ubi->free);
self_check_in_wl_tree(ubi, e, &ubi->free);

/*
* Move the physical eraseblock to the protection queue where it will
Expand Down Expand Up @@ -441,7 +440,7 @@ static int prot_queue_del(struct ubi_device *ubi, int pnum)
if (!e)
return -ENODEV;

if (paranoid_check_in_pq(ubi, e))
if (self_check_in_pq(ubi, e))
return -ENODEV;

list_del(&e->u.list);
Expand All @@ -467,7 +466,7 @@ static int sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e,

dbg_wl("erase PEB %d, old EC %llu", e->pnum, ec);

err = paranoid_check_ec(ubi, e->pnum, e->ec);
err = self_check_ec(ubi, e->pnum, e->ec);
if (err)
return -EINVAL;

Expand Down Expand Up @@ -667,7 +666,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
e1->ec, e2->ec);
goto out_cancel;
}
paranoid_check_in_wl_tree(ubi, e1, &ubi->used);
self_check_in_wl_tree(ubi, e1, &ubi->used);
rb_erase(&e1->u.rb, &ubi->used);
dbg_wl("move PEB %d EC %d to PEB %d EC %d",
e1->pnum, e1->ec, e2->pnum, e2->ec);
Expand All @@ -676,12 +675,12 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
scrubbing = 1;
e1 = rb_entry(rb_first(&ubi->scrub), struct ubi_wl_entry, u.rb);
e2 = find_wl_entry(&ubi->free, WL_FREE_MAX_DIFF);
paranoid_check_in_wl_tree(ubi, e1, &ubi->scrub);
self_check_in_wl_tree(ubi, e1, &ubi->scrub);
rb_erase(&e1->u.rb, &ubi->scrub);
dbg_wl("scrub PEB %d to PEB %d", e1->pnum, e2->pnum);
}

paranoid_check_in_wl_tree(ubi, e2, &ubi->free);
self_check_in_wl_tree(ubi, e2, &ubi->free);
rb_erase(&e2->u.rb, &ubi->free);
ubi->move_from = e1;
ubi->move_to = e2;
Expand Down Expand Up @@ -1128,13 +1127,13 @@ int ubi_wl_put_peb(struct ubi_device *ubi, int pnum, int torture)
return 0;
} else {
if (in_wl_tree(e, &ubi->used)) {
paranoid_check_in_wl_tree(ubi, e, &ubi->used);
self_check_in_wl_tree(ubi, e, &ubi->used);
rb_erase(&e->u.rb, &ubi->used);
} else if (in_wl_tree(e, &ubi->scrub)) {
paranoid_check_in_wl_tree(ubi, e, &ubi->scrub);
self_check_in_wl_tree(ubi, e, &ubi->scrub);
rb_erase(&e->u.rb, &ubi->scrub);
} else if (in_wl_tree(e, &ubi->erroneous)) {
paranoid_check_in_wl_tree(ubi, e, &ubi->erroneous);
self_check_in_wl_tree(ubi, e, &ubi->erroneous);
rb_erase(&e->u.rb, &ubi->erroneous);
ubi->erroneous_peb_count -= 1;
ubi_assert(ubi->erroneous_peb_count >= 0);
Expand Down Expand Up @@ -1201,7 +1200,7 @@ int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum)
}

if (in_wl_tree(e, &ubi->used)) {
paranoid_check_in_wl_tree(ubi, e, &ubi->used);
self_check_in_wl_tree(ubi, e, &ubi->used);
rb_erase(&e->u.rb, &ubi->used);
} else {
int err;
Expand Down Expand Up @@ -1521,7 +1520,7 @@ void ubi_wl_close(struct ubi_device *ubi)
}

/**
* paranoid_check_ec - make sure that the erase counter of a PEB is correct.
* self_check_ec - make sure that the erase counter of a PEB is correct.
* @ubi: UBI device description object
* @pnum: the physical eraseblock number to check
* @ec: the erase counter to check
Expand All @@ -1530,7 +1529,7 @@ void ubi_wl_close(struct ubi_device *ubi)
* is equivalent to @ec, and a negative error code if not or if an error
* occurred.
*/
static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec)
static int self_check_ec(struct ubi_device *ubi, int pnum, int ec)
{
int err;
long long read_ec;
Expand All @@ -1552,7 +1551,7 @@ static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec)

read_ec = be64_to_cpu(ec_hdr->ec);
if (ec != read_ec) {
ubi_err("paranoid check failed for PEB %d", pnum);
ubi_err("self-check failed for PEB %d", pnum);
ubi_err("read EC is %lld, should be %d", read_ec, ec);
dump_stack();
err = 1;
Expand All @@ -1565,40 +1564,39 @@ static int paranoid_check_ec(struct ubi_device *ubi, int pnum, int ec)
}

/**
* paranoid_check_in_wl_tree - check that wear-leveling entry is in WL RB-tree.
* self_check_in_wl_tree - check that wear-leveling entry is in WL RB-tree.
* @ubi: UBI device description object
* @e: the wear-leveling entry to check
* @root: the root of the tree
*
* This function returns zero if @e is in the @root RB-tree and %-EINVAL if it
* is not.
*/
static int paranoid_check_in_wl_tree(const struct ubi_device *ubi,
struct ubi_wl_entry *e,
struct rb_root *root)
static int self_check_in_wl_tree(const struct ubi_device *ubi,
struct ubi_wl_entry *e, struct rb_root *root)
{
if (!ubi->dbg->chk_gen)
return 0;

if (in_wl_tree(e, root))
return 0;

ubi_err("paranoid check failed for PEB %d, EC %d, RB-tree %p ",
ubi_err("self-check failed for PEB %d, EC %d, RB-tree %p ",
e->pnum, e->ec, root);
dump_stack();
return -EINVAL;
}

/**
* paranoid_check_in_pq - check if wear-leveling entry is in the protection
* self_check_in_pq - check if wear-leveling entry is in the protection
* queue.
* @ubi: UBI device description object
* @e: the wear-leveling entry to check
*
* This function returns zero if @e is in @ubi->pq and %-EINVAL if it is not.
*/
static int paranoid_check_in_pq(const struct ubi_device *ubi,
struct ubi_wl_entry *e)
static int self_check_in_pq(const struct ubi_device *ubi,
struct ubi_wl_entry *e)
{
struct ubi_wl_entry *p;
int i;
Expand All @@ -1611,7 +1609,7 @@ static int paranoid_check_in_pq(const struct ubi_device *ubi,
if (p == e)
return 0;

ubi_err("paranoid check failed for PEB %d, EC %d, Protect queue",
ubi_err("self-check failed for PEB %d, EC %d, Protect queue",
e->pnum, e->ec);
dump_stack();
return -EINVAL;
Expand Down

0 comments on commit bb36de5

Please sign in to comment.