提交 a4e6042f 编写于 作者: A Artem Bityutskiy 提交者: Artem Bityutskiy

UBI: rename si to ai

After re-naming the 'struct ubi_scan_info' we should adjust all variables
named 'si' to something else, because 'si' stands for "scanning info".
Let's rename it to 'ai' which stands for "attaching info" which is
a bit more consistent and has the same length, which makes re-naming easy.
Signed-off-by: NArtem Bityutskiy <Artem.Bityutskiy@linux.intel.com>
上级 2c5ec5ce
...@@ -583,32 +583,32 @@ static void free_internal_volumes(struct ubi_device *ubi) ...@@ -583,32 +583,32 @@ static void free_internal_volumes(struct ubi_device *ubi)
static int attach_by_scanning(struct ubi_device *ubi) static int attach_by_scanning(struct ubi_device *ubi)
{ {
int err; int err;
struct ubi_attach_info *si; struct ubi_attach_info *ai;
si = ubi_scan(ubi); ai = ubi_scan(ubi);
if (IS_ERR(si)) if (IS_ERR(ai))
return PTR_ERR(si); return PTR_ERR(ai);
ubi->bad_peb_count = si->bad_peb_count; ubi->bad_peb_count = ai->bad_peb_count;
ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count; ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count;
ubi->corr_peb_count = si->corr_peb_count; ubi->corr_peb_count = ai->corr_peb_count;
ubi->max_ec = si->max_ec; ubi->max_ec = ai->max_ec;
ubi->mean_ec = si->mean_ec; ubi->mean_ec = ai->mean_ec;
ubi_msg("max. sequence number: %llu", si->max_sqnum); ubi_msg("max. sequence number: %llu", ai->max_sqnum);
err = ubi_read_volume_table(ubi, si); err = ubi_read_volume_table(ubi, ai);
if (err) if (err)
goto out_si; goto out_ai;
err = ubi_wl_init_scan(ubi, si); err = ubi_wl_init_scan(ubi, ai);
if (err) if (err)
goto out_vtbl; goto out_vtbl;
err = ubi_eba_init_scan(ubi, si); err = ubi_eba_init_scan(ubi, ai);
if (err) if (err)
goto out_wl; goto out_wl;
ubi_scan_destroy_si(si); ubi_scan_destroy_ai(ai);
return 0; return 0;
out_wl: out_wl:
...@@ -616,8 +616,8 @@ static int attach_by_scanning(struct ubi_device *ubi) ...@@ -616,8 +616,8 @@ static int attach_by_scanning(struct ubi_device *ubi)
out_vtbl: out_vtbl:
free_internal_volumes(ubi); free_internal_volumes(ubi);
vfree(ubi->vtbl); vfree(ubi->vtbl);
out_si: out_ai:
ubi_scan_destroy_si(si); ubi_scan_destroy_ai(ai);
return err; return err;
} }
......
...@@ -176,7 +176,7 @@ void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx) ...@@ -176,7 +176,7 @@ void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx)
*/ */
void ubi_dump_sv(const struct ubi_ainf_volume *sv) void ubi_dump_sv(const struct ubi_ainf_volume *sv)
{ {
printk(KERN_DEBUG "Volume scanning information dump:\n"); printk(KERN_DEBUG "Volume attaching information dump:\n");
printk(KERN_DEBUG "\tvol_id %d\n", sv->vol_id); printk(KERN_DEBUG "\tvol_id %d\n", sv->vol_id);
printk(KERN_DEBUG "\thighest_lnum %d\n", sv->highest_lnum); printk(KERN_DEBUG "\thighest_lnum %d\n", sv->highest_lnum);
printk(KERN_DEBUG "\tleb_count %d\n", sv->leb_count); printk(KERN_DEBUG "\tleb_count %d\n", sv->leb_count);
...@@ -194,7 +194,7 @@ void ubi_dump_sv(const struct ubi_ainf_volume *sv) ...@@ -194,7 +194,7 @@ void ubi_dump_sv(const struct ubi_ainf_volume *sv)
*/ */
void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type) void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type)
{ {
printk(KERN_DEBUG "eraseblock scanning information dump:\n"); printk(KERN_DEBUG "eraseblock attaching information dump:\n");
printk(KERN_DEBUG "\tec %d\n", aeb->ec); printk(KERN_DEBUG "\tec %d\n", aeb->ec);
printk(KERN_DEBUG "\tpnum %d\n", aeb->pnum); printk(KERN_DEBUG "\tpnum %d\n", aeb->pnum);
if (type == 0) { if (type == 0) {
......
...@@ -1182,13 +1182,13 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, ...@@ -1182,13 +1182,13 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
* reported by real users. * reported by real users.
*/ */
static void print_rsvd_warning(struct ubi_device *ubi, static void print_rsvd_warning(struct ubi_device *ubi,
struct ubi_attach_info *si) struct ubi_attach_info *ai)
{ {
/* /*
* The 1 << 18 (256KiB) number is picked randomly, just a reasonably * The 1 << 18 (256KiB) number is picked randomly, just a reasonably
* large number to distinguish between newly flashed and used images. * large number to distinguish between newly flashed and used images.
*/ */
if (si->max_sqnum > (1 << 18)) { if (ai->max_sqnum > (1 << 18)) {
int min = ubi->beb_rsvd_level / 10; int min = ubi->beb_rsvd_level / 10;
if (!min) if (!min)
...@@ -1205,14 +1205,14 @@ static void print_rsvd_warning(struct ubi_device *ubi, ...@@ -1205,14 +1205,14 @@ static void print_rsvd_warning(struct ubi_device *ubi,
} }
/** /**
* ubi_eba_init_scan - initialize the EBA sub-system using scanning information. * ubi_eba_init_scan - initialize the EBA sub-system using attaching information.
* @ubi: UBI device description object * @ubi: UBI device description object
* @si: scanning information * @ai: attaching information
* *
* This function returns zero in case of success and a negative error code in * This function returns zero in case of success and a negative error code in
* case of failure. * case of failure.
*/ */
int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai)
{ {
int i, j, err, num_volumes; int i, j, err, num_volumes;
struct ubi_ainf_volume *sv; struct ubi_ainf_volume *sv;
...@@ -1226,7 +1226,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) ...@@ -1226,7 +1226,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
mutex_init(&ubi->alc_mutex); mutex_init(&ubi->alc_mutex);
ubi->ltree = RB_ROOT; ubi->ltree = RB_ROOT;
ubi->global_sqnum = si->max_sqnum + 1; ubi->global_sqnum = ai->max_sqnum + 1;
num_volumes = ubi->vtbl_slots + UBI_INT_VOL_COUNT; num_volumes = ubi->vtbl_slots + UBI_INT_VOL_COUNT;
for (i = 0; i < num_volumes; i++) { for (i = 0; i < num_volumes; i++) {
...@@ -1246,7 +1246,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) ...@@ -1246,7 +1246,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
for (j = 0; j < vol->reserved_pebs; j++) for (j = 0; j < vol->reserved_pebs; j++)
vol->eba_tbl[j] = UBI_LEB_UNMAPPED; vol->eba_tbl[j] = UBI_LEB_UNMAPPED;
sv = ubi_scan_find_sv(si, idx2vol_id(ubi, i)); sv = ubi_scan_find_sv(ai, idx2vol_id(ubi, i));
if (!sv) if (!sv)
continue; continue;
...@@ -1256,7 +1256,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) ...@@ -1256,7 +1256,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
* This may happen in case of an unclean reboot * This may happen in case of an unclean reboot
* during re-size. * during re-size.
*/ */
ubi_scan_move_to_list(sv, aeb, &si->erase); ubi_scan_move_to_list(sv, aeb, &ai->erase);
vol->eba_tbl[aeb->lnum] = aeb->pnum; vol->eba_tbl[aeb->lnum] = aeb->pnum;
} }
} }
...@@ -1279,7 +1279,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) ...@@ -1279,7 +1279,7 @@ int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
if (ubi->avail_pebs < ubi->beb_rsvd_level) { if (ubi->avail_pebs < ubi->beb_rsvd_level) {
/* No enough free physical eraseblocks */ /* No enough free physical eraseblocks */
ubi->beb_rsvd_pebs = ubi->avail_pebs; ubi->beb_rsvd_pebs = ubi->avail_pebs;
print_rsvd_warning(ubi, si); print_rsvd_warning(ubi, ai);
} else } else
ubi->beb_rsvd_pebs = ubi->beb_rsvd_level; ubi->beb_rsvd_pebs = ubi->beb_rsvd_level;
......
此差异已折叠。
...@@ -145,7 +145,7 @@ struct ubi_vid_hdr; ...@@ -145,7 +145,7 @@ struct ubi_vid_hdr;
/* /*
* ubi_scan_move_to_list - move a PEB from the volume tree to a list. * ubi_scan_move_to_list - move a PEB from the volume tree to a list.
* *
* @sv: volume scanning information * @sv: volume attaching information
* @aeb: scanning eraseblock information * @aeb: scanning eraseblock information
* @list: the list to move to * @list: the list to move to
*/ */
...@@ -157,19 +157,19 @@ static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *sv, ...@@ -157,19 +157,19 @@ static inline void ubi_scan_move_to_list(struct ubi_ainf_volume *sv,
list_add_tail(&aeb->u.list, list); list_add_tail(&aeb->u.list, list);
} }
int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *si, int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_attach_info *ai,
int pnum, int ec, const struct ubi_vid_hdr *vid_hdr, int pnum, int ec, const struct ubi_vid_hdr *vid_hdr,
int bitflips); int bitflips);
struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *si, struct ubi_ainf_volume *ubi_scan_find_sv(const struct ubi_attach_info *ai,
int vol_id); int vol_id);
struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv, struct ubi_ainf_peb *ubi_scan_find_aeb(const struct ubi_ainf_volume *sv,
int lnum); int lnum);
void ubi_scan_rm_volume(struct ubi_attach_info *si, struct ubi_ainf_volume *sv); void ubi_scan_rm_volume(struct ubi_attach_info *ai, struct ubi_ainf_volume *sv);
struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi, struct ubi_ainf_peb *ubi_scan_get_free_peb(struct ubi_device *ubi,
struct ubi_attach_info *si); struct ubi_attach_info *ai);
int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *si, int ubi_scan_erase_peb(struct ubi_device *ubi, const struct ubi_attach_info *ai,
int pnum, int ec); int pnum, int ec);
struct ubi_attach_info *ubi_scan(struct ubi_device *ubi); struct ubi_attach_info *ubi_scan(struct ubi_device *ubi);
void ubi_scan_destroy_si(struct ubi_attach_info *si); void ubi_scan_destroy_ai(struct ubi_attach_info *ai);
#endif /* !__UBI_SCAN_H__ */ #endif /* !__UBI_SCAN_H__ */
...@@ -489,7 +489,7 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, ...@@ -489,7 +489,7 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx,
struct ubi_vtbl_record *vtbl_rec); struct ubi_vtbl_record *vtbl_rec);
int ubi_vtbl_rename_volumes(struct ubi_device *ubi, int ubi_vtbl_rename_volumes(struct ubi_device *ubi,
struct list_head *rename_list); struct list_head *rename_list);
int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si); int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai);
/* vmt.c */ /* vmt.c */
int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req); int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req);
...@@ -529,14 +529,14 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, ...@@ -529,14 +529,14 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
int lnum, const void *buf, int len); int lnum, const void *buf, int len);
int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
struct ubi_vid_hdr *vid_hdr); struct ubi_vid_hdr *vid_hdr);
int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si); int ubi_eba_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai);
/* wl.c */ /* wl.c */
int ubi_wl_get_peb(struct ubi_device *ubi); int ubi_wl_get_peb(struct ubi_device *ubi);
int ubi_wl_put_peb(struct ubi_device *ubi, int pnum, int torture); int ubi_wl_put_peb(struct ubi_device *ubi, int pnum, int torture);
int ubi_wl_flush(struct ubi_device *ubi); int ubi_wl_flush(struct ubi_device *ubi);
int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum); int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum);
int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si); int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai);
void ubi_wl_close(struct ubi_device *ubi); void ubi_wl_close(struct ubi_device *ubi);
int ubi_thread(void *u); int ubi_thread(void *u);
......
...@@ -291,14 +291,14 @@ static int vtbl_check(const struct ubi_device *ubi, ...@@ -291,14 +291,14 @@ static int vtbl_check(const struct ubi_device *ubi,
/** /**
* create_vtbl - create a copy of volume table. * create_vtbl - create a copy of volume table.
* @ubi: UBI device description object * @ubi: UBI device description object
* @si: scanning information * @ai: attaching information
* @copy: number of the volume table copy * @copy: number of the volume table copy
* @vtbl: contents of the volume table * @vtbl: contents of the volume table
* *
* This function returns zero in case of success and a negative error code in * This function returns zero in case of success and a negative error code in
* case of failure. * case of failure.
*/ */
static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *ai,
int copy, void *vtbl) int copy, void *vtbl)
{ {
int err, tries = 0; int err, tries = 0;
...@@ -312,7 +312,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, ...@@ -312,7 +312,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si,
return -ENOMEM; return -ENOMEM;
retry: retry:
new_aeb = ubi_scan_get_free_peb(ubi, si); new_aeb = ubi_scan_get_free_peb(ubi, ai);
if (IS_ERR(new_aeb)) { if (IS_ERR(new_aeb)) {
err = PTR_ERR(new_aeb); err = PTR_ERR(new_aeb);
goto out_free; goto out_free;
...@@ -324,7 +324,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, ...@@ -324,7 +324,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si,
vid_hdr->data_size = vid_hdr->used_ebs = vid_hdr->data_size = vid_hdr->used_ebs =
vid_hdr->data_pad = cpu_to_be32(0); vid_hdr->data_pad = cpu_to_be32(0);
vid_hdr->lnum = cpu_to_be32(copy); vid_hdr->lnum = cpu_to_be32(copy);
vid_hdr->sqnum = cpu_to_be64(++si->max_sqnum); vid_hdr->sqnum = cpu_to_be64(++ai->max_sqnum);
/* The EC header is already there, write the VID header */ /* The EC header is already there, write the VID header */
err = ubi_io_write_vid_hdr(ubi, new_aeb->pnum, vid_hdr); err = ubi_io_write_vid_hdr(ubi, new_aeb->pnum, vid_hdr);
...@@ -337,10 +337,10 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, ...@@ -337,10 +337,10 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si,
goto write_error; goto write_error;
/* /*
* And add it to the scanning information. Don't delete the old version * And add it to the attaching information. Don't delete the old version
* of this LEB as it will be deleted and freed in 'ubi_scan_add_used()'. * of this LEB as it will be deleted and freed in 'ubi_scan_add_used()'.
*/ */
err = ubi_scan_add_used(ubi, si, new_aeb->pnum, new_aeb->ec, err = ubi_scan_add_used(ubi, ai, new_aeb->pnum, new_aeb->ec,
vid_hdr, 0); vid_hdr, 0);
kfree(new_aeb); kfree(new_aeb);
ubi_free_vid_hdr(ubi, vid_hdr); ubi_free_vid_hdr(ubi, vid_hdr);
...@@ -352,7 +352,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, ...@@ -352,7 +352,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si,
* Probably this physical eraseblock went bad, try to pick * Probably this physical eraseblock went bad, try to pick
* another one. * another one.
*/ */
list_add(&new_aeb->u.list, &si->erase); list_add(&new_aeb->u.list, &ai->erase);
goto retry; goto retry;
} }
kfree(new_aeb); kfree(new_aeb);
...@@ -365,15 +365,15 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, ...@@ -365,15 +365,15 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si,
/** /**
* process_lvol - process the layout volume. * process_lvol - process the layout volume.
* @ubi: UBI device description object * @ubi: UBI device description object
* @si: scanning information * @ai: attaching information
* @sv: layout volume scanning information * @sv: layout volume attaching information
* *
* This function is responsible for reading the layout volume, ensuring it is * This function is responsible for reading the layout volume, ensuring it is
* not corrupted, and recovering from corruptions if needed. Returns volume * not corrupted, and recovering from corruptions if needed. Returns volume
* table in case of success and a negative error code in case of failure. * table in case of success and a negative error code in case of failure.
*/ */
static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
struct ubi_attach_info *si, struct ubi_attach_info *ai,
struct ubi_ainf_volume *sv) struct ubi_ainf_volume *sv)
{ {
int err; int err;
...@@ -449,7 +449,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, ...@@ -449,7 +449,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
ubi->vtbl_size); ubi->vtbl_size);
if (leb_corrupted[1]) { if (leb_corrupted[1]) {
ubi_warn("volume table copy #2 is corrupted"); ubi_warn("volume table copy #2 is corrupted");
err = create_vtbl(ubi, si, 1, leb[0]); err = create_vtbl(ubi, ai, 1, leb[0]);
if (err) if (err)
goto out_free; goto out_free;
ubi_msg("volume table was restored"); ubi_msg("volume table was restored");
...@@ -472,7 +472,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, ...@@ -472,7 +472,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
} }
ubi_warn("volume table copy #1 is corrupted"); ubi_warn("volume table copy #1 is corrupted");
err = create_vtbl(ubi, si, 0, leb[1]); err = create_vtbl(ubi, ai, 0, leb[1]);
if (err) if (err)
goto out_free; goto out_free;
ubi_msg("volume table was restored"); ubi_msg("volume table was restored");
...@@ -490,13 +490,13 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, ...@@ -490,13 +490,13 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
/** /**
* create_empty_lvol - create empty layout volume. * create_empty_lvol - create empty layout volume.
* @ubi: UBI device description object * @ubi: UBI device description object
* @si: scanning information * @ai: attaching information
* *
* This function returns volume table contents in case of success and a * This function returns volume table contents in case of success and a
* negative error code in case of failure. * negative error code in case of failure.
*/ */
static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
struct ubi_attach_info *si) struct ubi_attach_info *ai)
{ {
int i; int i;
struct ubi_vtbl_record *vtbl; struct ubi_vtbl_record *vtbl;
...@@ -511,7 +511,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, ...@@ -511,7 +511,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) { for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) {
int err; int err;
err = create_vtbl(ubi, si, i, vtbl); err = create_vtbl(ubi, ai, i, vtbl);
if (err) { if (err) {
vfree(vtbl); vfree(vtbl);
return ERR_PTR(err); return ERR_PTR(err);
...@@ -524,7 +524,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, ...@@ -524,7 +524,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
/** /**
* init_volumes - initialize volume information for existing volumes. * init_volumes - initialize volume information for existing volumes.
* @ubi: UBI device description object * @ubi: UBI device description object
* @si: scanning information * @ai: scanning information
* @vtbl: volume table * @vtbl: volume table
* *
* This function allocates volume description objects for existing volumes. * This function allocates volume description objects for existing volumes.
...@@ -532,7 +532,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, ...@@ -532,7 +532,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi,
* failure. * failure.
*/ */
static int init_volumes(struct ubi_device *ubi, static int init_volumes(struct ubi_device *ubi,
const struct ubi_attach_info *si, const struct ubi_attach_info *ai,
const struct ubi_vtbl_record *vtbl) const struct ubi_vtbl_record *vtbl)
{ {
int i, reserved_pebs = 0; int i, reserved_pebs = 0;
...@@ -592,7 +592,7 @@ static int init_volumes(struct ubi_device *ubi, ...@@ -592,7 +592,7 @@ static int init_volumes(struct ubi_device *ubi,
} }
/* Static volumes only */ /* Static volumes only */
sv = ubi_scan_find_sv(si, i); sv = ubi_scan_find_sv(ai, i);
if (!sv) { if (!sv) {
/* /*
* No eraseblocks belonging to this volume found. We * No eraseblocks belonging to this volume found. We
...@@ -661,11 +661,11 @@ static int init_volumes(struct ubi_device *ubi, ...@@ -661,11 +661,11 @@ static int init_volumes(struct ubi_device *ubi,
} }
/** /**
* check_sv - check volume scanning information. * check_sv - check volume attaching information.
* @vol: UBI volume description object * @vol: UBI volume description object
* @sv: volume scanning information * @sv: volume attaching information
* *
* This function returns zero if the volume scanning information is consistent * This function returns zero if the volume attaching information is consistent
* to the data read from the volume tabla, and %-EINVAL if not. * to the data read from the volume tabla, and %-EINVAL if not.
*/ */
static int check_sv(const struct ubi_volume *vol, static int check_sv(const struct ubi_volume *vol,
...@@ -696,50 +696,50 @@ static int check_sv(const struct ubi_volume *vol, ...@@ -696,50 +696,50 @@ static int check_sv(const struct ubi_volume *vol,
return 0; return 0;
bad: bad:
ubi_err("bad scanning information, error %d", err); ubi_err("bad attaching information, error %d", err);
ubi_dump_sv(sv); ubi_dump_sv(sv);
ubi_dump_vol_info(vol); ubi_dump_vol_info(vol);
return -EINVAL; return -EINVAL;
} }
/** /**
* check_scanning_info - check that scanning information. * check_scanning_info - check that attaching information.
* @ubi: UBI device description object * @ubi: UBI device description object
* @si: scanning information * @ai: attaching information
* *
* Even though we protect on-flash data by CRC checksums, we still don't trust * Even though we protect on-flash data by CRC checksums, we still don't trust
* the media. This function ensures that scanning information is consistent to * the media. This function ensures that attaching information is consistent to
* the information read from the volume table. Returns zero if the scanning * the information read from the volume table. Returns zero if the scanning
* information is OK and %-EINVAL if it is not. * information is OK and %-EINVAL if it is not.
*/ */
static int check_scanning_info(const struct ubi_device *ubi, static int check_scanning_info(const struct ubi_device *ubi,
struct ubi_attach_info *si) struct ubi_attach_info *ai)
{ {
int err, i; int err, i;
struct ubi_ainf_volume *sv; struct ubi_ainf_volume *sv;
struct ubi_volume *vol; struct ubi_volume *vol;
if (si->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) {
ubi_err("scanning found %d volumes, maximum is %d + %d", ubi_err("scanning found %d volumes, maximum is %d + %d",
si->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots); ai->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots);
return -EINVAL; return -EINVAL;
} }
if (si->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT && if (ai->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT &&
si->highest_vol_id < UBI_INTERNAL_VOL_START) { ai->highest_vol_id < UBI_INTERNAL_VOL_START) {
ubi_err("too large volume ID %d found by scanning", ubi_err("too large volume ID %d found by scanning",
si->highest_vol_id); ai->highest_vol_id);
return -EINVAL; return -EINVAL;
} }
for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) { for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) {
cond_resched(); cond_resched();
sv = ubi_scan_find_sv(si, i); sv = ubi_scan_find_sv(ai, i);
vol = ubi->volumes[i]; vol = ubi->volumes[i];
if (!vol) { if (!vol) {
if (sv) if (sv)
ubi_scan_rm_volume(si, sv); ubi_scan_rm_volume(ai, sv);
continue; continue;
} }
...@@ -757,7 +757,7 @@ static int check_scanning_info(const struct ubi_device *ubi, ...@@ -757,7 +757,7 @@ static int check_scanning_info(const struct ubi_device *ubi,
* these eraseblocks. * these eraseblocks.
*/ */
ubi_msg("finish volume %d removal", sv->vol_id); ubi_msg("finish volume %d removal", sv->vol_id);
ubi_scan_rm_volume(si, sv); ubi_scan_rm_volume(ai, sv);
} else if (sv) { } else if (sv) {
err = check_sv(vol, sv); err = check_sv(vol, sv);
if (err) if (err)
...@@ -771,13 +771,13 @@ static int check_scanning_info(const struct ubi_device *ubi, ...@@ -771,13 +771,13 @@ static int check_scanning_info(const struct ubi_device *ubi,
/** /**
* ubi_read_volume_table - read the volume table. * ubi_read_volume_table - read the volume table.
* @ubi: UBI device description object * @ubi: UBI device description object
* @si: scanning information * @ai: attaching information
* *
* This function reads volume table, checks it, recover from errors if needed, * This function reads volume table, checks it, recover from errors if needed,
* or creates it if needed. Returns zero in case of success and a negative * or creates it if needed. Returns zero in case of success and a negative
* error code in case of failure. * error code in case of failure.
*/ */
int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
{ {
int i, err; int i, err;
struct ubi_ainf_volume *sv; struct ubi_ainf_volume *sv;
...@@ -795,7 +795,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) ...@@ -795,7 +795,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si)
ubi->vtbl_size = ubi->vtbl_slots * UBI_VTBL_RECORD_SIZE; ubi->vtbl_size = ubi->vtbl_slots * UBI_VTBL_RECORD_SIZE;
ubi->vtbl_size = ALIGN(ubi->vtbl_size, ubi->min_io_size); ubi->vtbl_size = ALIGN(ubi->vtbl_size, ubi->min_io_size);
sv = ubi_scan_find_sv(si, UBI_LAYOUT_VOLUME_ID); sv = ubi_scan_find_sv(ai, UBI_LAYOUT_VOLUME_ID);
if (!sv) { if (!sv) {
/* /*
* No logical eraseblocks belonging to the layout volume were * No logical eraseblocks belonging to the layout volume were
...@@ -805,8 +805,8 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) ...@@ -805,8 +805,8 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si)
* But if flash is not empty this must be a corruption or the * But if flash is not empty this must be a corruption or the
* MTD device just contains garbage. * MTD device just contains garbage.
*/ */
if (si->is_empty) { if (ai->is_empty) {
ubi->vtbl = create_empty_lvol(ubi, si); ubi->vtbl = create_empty_lvol(ubi, ai);
if (IS_ERR(ubi->vtbl)) if (IS_ERR(ubi->vtbl))
return PTR_ERR(ubi->vtbl); return PTR_ERR(ubi->vtbl);
} else { } else {
...@@ -821,7 +821,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) ...@@ -821,7 +821,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si)
return -EINVAL; return -EINVAL;
} }
ubi->vtbl = process_lvol(ubi, si, sv); ubi->vtbl = process_lvol(ubi, ai, sv);
if (IS_ERR(ubi->vtbl)) if (IS_ERR(ubi->vtbl))
return PTR_ERR(ubi->vtbl); return PTR_ERR(ubi->vtbl);
} }
...@@ -832,15 +832,15 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) ...@@ -832,15 +832,15 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si)
* The layout volume is OK, initialize the corresponding in-RAM data * The layout volume is OK, initialize the corresponding in-RAM data
* structures. * structures.
*/ */
err = init_volumes(ubi, si, ubi->vtbl); err = init_volumes(ubi, ai, ubi->vtbl);
if (err) if (err)
goto out_free; goto out_free;
/* /*
* Make sure that the scanning information is consistent to the * Make sure that the attaching information is consistent to the
* information stored in the volume table. * information stored in the volume table.
*/ */
err = check_scanning_info(ubi, si); err = check_scanning_info(ubi, ai);
if (err) if (err)
goto out_free; goto out_free;
......
...@@ -1373,14 +1373,14 @@ static void cancel_pending(struct ubi_device *ubi) ...@@ -1373,14 +1373,14 @@ static void cancel_pending(struct ubi_device *ubi)
} }
/** /**
* ubi_wl_init_scan - initialize the WL sub-system using scanning information. * ubi_wl_init_scan - initialize the WL sub-system using attaching information.
* @ubi: UBI device description object * @ubi: UBI device description object
* @si: scanning information * @ai: attaching information
* *
* This function returns zero in case of success, and a negative error code in * This function returns zero in case of success, and a negative error code in
* case of failure. * case of failure.
*/ */
int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *ai)
{ {
int err, i; int err, i;
struct rb_node *rb1, *rb2; struct rb_node *rb1, *rb2;
...@@ -1392,7 +1392,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) ...@@ -1392,7 +1392,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
spin_lock_init(&ubi->wl_lock); spin_lock_init(&ubi->wl_lock);
mutex_init(&ubi->move_mutex); mutex_init(&ubi->move_mutex);
init_rwsem(&ubi->work_sem); init_rwsem(&ubi->work_sem);
ubi->max_ec = si->max_ec; ubi->max_ec = ai->max_ec;
INIT_LIST_HEAD(&ubi->works); INIT_LIST_HEAD(&ubi->works);
sprintf(ubi->bgt_name, UBI_BGT_NAME_PATTERN, ubi->ubi_num); sprintf(ubi->bgt_name, UBI_BGT_NAME_PATTERN, ubi->ubi_num);
...@@ -1406,7 +1406,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) ...@@ -1406,7 +1406,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
INIT_LIST_HEAD(&ubi->pq[i]); INIT_LIST_HEAD(&ubi->pq[i]);
ubi->pq_head = 0; ubi->pq_head = 0;
list_for_each_entry_safe(aeb, tmp, &si->erase, u.list) { list_for_each_entry_safe(aeb, tmp, &ai->erase, u.list) {
cond_resched(); cond_resched();
e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL);
...@@ -1422,7 +1422,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) ...@@ -1422,7 +1422,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
} }
} }
list_for_each_entry(aeb, &si->free, u.list) { list_for_each_entry(aeb, &ai->free, u.list) {
cond_resched(); cond_resched();
e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL); e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL);
...@@ -1436,7 +1436,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si) ...@@ -1436,7 +1436,7 @@ int ubi_wl_init_scan(struct ubi_device *ubi, struct ubi_attach_info *si)
ubi->lookuptbl[e->pnum] = e; ubi->lookuptbl[e->pnum] = e;
} }
ubi_rb_for_each_entry(rb1, sv, &si->volumes, rb) { ubi_rb_for_each_entry(rb1, sv, &ai->volumes, rb) {
ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) { ubi_rb_for_each_entry(rb2, aeb, &sv->root, u.rb) {
cond_resched(); cond_resched();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册