From d02ed6b994e6b66e03eaa3fee648279f23faffac Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Thu, 22 Dec 2011 16:12:57 +0100 Subject: UBI: make vid_hdr non-static Remove 'static' modifier from the 'vid_hdr' local variable. I do not know how it slipped in, but this is a bug and will break UBI if someone attaches 2 UBI volumes at the same time. Artem: amended teh commit message, added -stable. Signed-off-by: Richard Weinberger Signed-off-by: Artem Bityutskiy Cc: stable@kernel.org --- drivers/mtd/ubi/vtbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 4b50a3029b84..d28f60ae9f15 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -306,7 +306,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_scan_info *si, int copy, void *vtbl) { int err, tries = 0; - static struct ubi_vid_hdr *vid_hdr; + struct ubi_vid_hdr *vid_hdr; struct ubi_scan_leb *new_seb; ubi_msg("create volume table (copy #%d)", copy + 1); -- cgit v1.2.3 From a970fbd4983de569dc4e4c854a742f5ea452d69f Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Tue, 10 Jan 2012 17:57:03 +0100 Subject: UBI: use own macros for the layout volume This is a minor nicification: UBI_LAYOUT_VOLUME_TYPE and UBI_LAYOUT_VOLUME_ALIGN are currently defined but not used - use them. Signed-off-by: Richard Weinberger Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index d28f60ae9f15..118b966e0556 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -322,7 +322,7 @@ retry: goto out_free; } - vid_hdr->vol_type = UBI_VID_DYNAMIC; + vid_hdr->vol_type = UBI_LAYOUT_VOLUME_TYPE; vid_hdr->vol_id = cpu_to_be32(UBI_LAYOUT_VOLUME_ID); vid_hdr->compat = UBI_LAYOUT_VOLUME_COMPAT; vid_hdr->data_size = vid_hdr->used_ebs = @@ -632,7 +632,7 @@ static int init_volumes(struct ubi_device *ubi, const struct ubi_scan_info *si, return -ENOMEM; vol->reserved_pebs = UBI_LAYOUT_VOLUME_EBS; - vol->alignment = 1; + vol->alignment = UBI_LAYOUT_VOLUME_ALIGN; vol->vol_type = UBI_DYNAMIC_VOLUME; vol->name_len = sizeof(UBI_LAYOUT_VOLUME_NAME) - 1; memcpy(vol->name, UBI_LAYOUT_VOLUME_NAME, vol->name_len + 1); -- cgit v1.2.3 From b4a7748a1841cfa2d37a93e0066c2bd0038ada39 Mon Sep 17 00:00:00 2001 From: Richard Weinberger Date: Mon, 14 May 2012 17:55:51 +0200 Subject: UBI: Kill data type hint We do not need this feature and to our shame it even was not working and there was a bug found very recently. -- Artem Bityutskiy Without the data type hint UBI2 (fastmap) will be easier to implement. Signed-off-by: Richard Weinberger Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 118b966e0556..48ad8a2d6317 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -106,7 +106,7 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, return err; err = ubi_eba_write_leb(ubi, layout_vol, i, ubi->vtbl, 0, - ubi->vtbl_size, UBI_LONGTERM); + ubi->vtbl_size); if (err) return err; } @@ -158,7 +158,7 @@ int ubi_vtbl_rename_volumes(struct ubi_device *ubi, return err; err = ubi_eba_write_leb(ubi, layout_vol, i, ubi->vtbl, 0, - ubi->vtbl_size, UBI_LONGTERM); + ubi->vtbl_size); if (err) return err; } -- cgit v1.2.3 From 5378ace978899a25d3979b90da6d09f6da786686 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 16 May 2012 17:53:17 +0300 Subject: UBI: rename ubi_dbg_dump_vol_info I am going to remove the "UBI debugging" compilation option and make the debugging stuff to be always compiled it. This patch is a preparation which renames 'ubi_dbg_dump_vol_info()' to 'ubi_dump_vol_info()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 48ad8a2d6317..fabaa8392bd7 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -701,7 +701,7 @@ static int check_sv(const struct ubi_volume *vol, bad: ubi_err("bad scanning information, error %d", err); ubi_dbg_dump_sv(sv); - ubi_dbg_dump_vol_info(vol); + ubi_dump_vol_info(vol); return -EINVAL; } -- cgit v1.2.3 From ef98d5f459e59c36a68afaea6a512b70ce0cf681 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 16 May 2012 17:56:50 +0300 Subject: UBI: rename ubi_dbg_dump_vtbl_record I am going to remove the "UBI debugging" compilation option and make the debugging stuff to be always compiled it. This patch is a preparation which renames 'ubi_dbg_dump_vtbl_record()' to 'ubi_dump_vtbl_record()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index fabaa8392bd7..659fa003f2d7 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -197,7 +197,7 @@ static int vtbl_check(const struct ubi_device *ubi, if (be32_to_cpu(vtbl[i].crc) != crc) { ubi_err("bad CRC at record %u: %#08x, not %#08x", i, crc, be32_to_cpu(vtbl[i].crc)); - ubi_dbg_dump_vtbl_record(&vtbl[i], i); + ubi_dump_vtbl_record(&vtbl[i], i); return 1; } @@ -277,8 +277,8 @@ static int vtbl_check(const struct ubi_device *ubi, !strncmp(vtbl[i].name, vtbl[n].name, len1)) { ubi_err("volumes %d and %d have the same name" " \"%s\"", i, n, vtbl[i].name); - ubi_dbg_dump_vtbl_record(&vtbl[i], i); - ubi_dbg_dump_vtbl_record(&vtbl[n], n); + ubi_dump_vtbl_record(&vtbl[i], i); + ubi_dump_vtbl_record(&vtbl[n], n); return -EINVAL; } } @@ -288,7 +288,7 @@ static int vtbl_check(const struct ubi_device *ubi, bad: ubi_err("volume table check failed: record %d, error %d", i, err); - ubi_dbg_dump_vtbl_record(&vtbl[i], i); + ubi_dump_vtbl_record(&vtbl[i], i); return -EINVAL; } -- cgit v1.2.3 From 6fdc58043c888e9c448293bea0a0f6045419c3c8 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 16 May 2012 17:59:36 +0300 Subject: UBI: rename ubi_dbg_dump_sv I am going to remove the "UBI debugging" compilation option and make the debugging stuff to be always compiled it. This patch is a preparation which renames 'ubi_dbg_dump_sv()' to 'ubi_dump_sv()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 659fa003f2d7..8ea216e57c10 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -700,7 +700,7 @@ static int check_sv(const struct ubi_volume *vol, bad: ubi_err("bad scanning information, error %d", err); - ubi_dbg_dump_sv(sv); + ubi_dump_sv(sv); ubi_dump_vol_info(vol); return -EINVAL; } -- cgit v1.2.3 From 74321b1a2a81071760eac3fba935ab155ae4eafe Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 16 May 2012 18:09:08 +0300 Subject: UBI: remove Kconfig debugging option This patch kills the UBI debugging Kconfig option completely and makes all the debugging stuff to be always compiled-in. It was pain in the neck to maintain this useless option because all users I am aware of have debugging enabled anyway - how else will you diagnose errors otherwise? Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 8ea216e57c10..e040980000fe 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -62,11 +62,7 @@ #include #include "ubi.h" -#ifdef CONFIG_MTD_UBI_DEBUG static void paranoid_vtbl_check(const struct ubi_device *ubi); -#else -#define paranoid_vtbl_check(ubi) -#endif /* Empty volume table record */ static struct ubi_vtbl_record empty_vtbl_record; @@ -858,8 +854,6 @@ out_free: return err; } -#ifdef CONFIG_MTD_UBI_DEBUG - /** * paranoid_vtbl_check - check volume table. * @ubi: UBI device description object @@ -874,5 +868,3 @@ static void paranoid_vtbl_check(const struct ubi_device *ubi) BUG(); } } - -#endif /* CONFIG_MTD_UBI_DEBUG */ -- cgit v1.2.3 From 28f46452d3739eeea80456b0767e6f00b4086077 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 16 May 2012 18:29:54 +0300 Subject: UBI: more of clean-up terminology for self-checks We have the "sefl-check" feature in UBI, but for historical reasons many corresponding functions and commentaries in the code use term "paranoid check" instead. Let's clean this up and use "self-check" everywhere. This patch renames functions, amends messages and kills several redundant debugging messages. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index e040980000fe..217caf5a5561 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -62,7 +62,7 @@ #include #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; @@ -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; } @@ -855,16 +855,16 @@ out_free: } /** - * 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(); } } -- cgit v1.2.3 From 268d36847059dbbcdf69dbe882bf59c28225cff6 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 16 May 2012 18:39:56 +0300 Subject: UBI: get rid of dbg_err This patch removes the 'dbg_err()' macro and we now use 'ubi_err' instead. The idea of 'dbg_err()' was to compile out some error message to make the binary a bit smaller - but I think it was a bad idea. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 217caf5a5561..abb38a0d7b03 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -225,7 +225,7 @@ static int vtbl_check(const struct ubi_device *ubi, n = ubi->leb_size % alignment; if (data_pad != n) { - dbg_err("bad data_pad, has to be %d", n); + ubi_err("bad data_pad, has to be %d", n); err = 6; goto bad; } @@ -241,7 +241,7 @@ static int vtbl_check(const struct ubi_device *ubi, } if (reserved_pebs > ubi->good_peb_count) { - dbg_err("too large reserved_pebs %d, good PEBs %d", + ubi_err("too large reserved_pebs %d, good PEBs %d", reserved_pebs, ubi->good_peb_count); err = 9; goto bad; @@ -815,7 +815,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si) } else { if (sv->leb_count > UBI_LAYOUT_VOLUME_EBS) { /* This must not happen with proper UBI images */ - dbg_err("too many LEBs (%d) in layout volume", + ubi_err("too many LEBs (%d) in layout volume", sv->leb_count); return -EINVAL; } -- cgit v1.2.3 From 20a9a78f7773f3ec03ac04f2eb161e3d4edf308e Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 06:23:22 +0300 Subject: UBI: rename struct ubi_scan_leb Rename 'struct ubi_scan_leb' to 'struct ubi_ainf_leb'. This is part of the code re-structuring I am trying to do in order to add fastmap in a more logical way. Fastmap can share a lot with scanning, including the attach-time data structures, which all now have "scan" word in the name. Let's get rid of this word and use "ainf" instead which stands for "attach information". It has the same length as "scan" so re-naming is trivial. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index abb38a0d7b03..a706910cae06 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -303,7 +303,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_scan_info *si, { int err, tries = 0; struct ubi_vid_hdr *vid_hdr; - struct ubi_scan_leb *new_seb; + struct ubi_ainf_peb *new_seb; ubi_msg("create volume table (copy #%d)", copy + 1); @@ -378,7 +378,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, { int err; struct rb_node *rb; - struct ubi_scan_leb *seb; + struct ubi_ainf_peb *seb; struct ubi_vtbl_record *leb[UBI_LAYOUT_VOLUME_EBS] = { NULL, NULL }; int leb_corrupted[UBI_LAYOUT_VOLUME_EBS] = {1, 1}; -- cgit v1.2.3 From 5fb42fa8573d53fdcd87227ba8e38c397d76f131 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 06:59:30 +0300 Subject: UBI: rename struct ubi_scan_volume Rename 'struct ubi_scan_volume' to 'struct ubi_ainf_volume'. This is part of the code re-structuring I am trying to do in order to add fastmap in a more logical way. Fastmap can share a lot with scanning, including the attach-time data structures, which all now have "scan" word in the name. Let's get rid of this word and use "ainf" instead which stands for "attach information". It has the same length as "scan" so re-naming is trivial. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index a706910cae06..75df84ecad0d 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -374,7 +374,7 @@ out_free: */ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, struct ubi_scan_info *si, - struct ubi_scan_volume *sv) + struct ubi_ainf_volume *sv) { int err; struct rb_node *rb; @@ -535,7 +535,7 @@ static int init_volumes(struct ubi_device *ubi, const struct ubi_scan_info *si, const struct ubi_vtbl_record *vtbl) { int i, reserved_pebs = 0; - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; struct ubi_volume *vol; for (i = 0; i < ubi->vtbl_slots; i++) { @@ -668,7 +668,7 @@ static int init_volumes(struct ubi_device *ubi, const struct ubi_scan_info *si, * to the data read from the volume tabla, and %-EINVAL if not. */ static int check_sv(const struct ubi_volume *vol, - const struct ubi_scan_volume *sv) + const struct ubi_ainf_volume *sv) { int err; @@ -715,7 +715,7 @@ static int check_scanning_info(const struct ubi_device *ubi, struct ubi_scan_info *si) { int err, i; - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; struct ubi_volume *vol; if (si->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { @@ -779,7 +779,7 @@ static int check_scanning_info(const struct ubi_device *ubi, int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si) { int i, err; - struct ubi_scan_volume *sv; + struct ubi_ainf_volume *sv; empty_vtbl_record.crc = cpu_to_be32(0xf116c36b); -- cgit v1.2.3 From 04aa6f29d068d6b535538ebb3db5f41c7aa046f0 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 07:46:17 +0300 Subject: UBI: rename struct ubi_scan_info Rename 'struct ubi_scan_info' to 'struct ubi_attach_info'. This is part of the code re-structuring I am trying to do in order to add fastmap in a more logical way. Fastmap can share a lot with scanning, including the attach-time data structures, which all now have "scan" word in the name. Let's get rid of this word. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 75df84ecad0d..fc797ea8cffa 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -298,7 +298,7 @@ bad: * This function returns zero in case of success and a negative error code in * case of failure. */ -static int create_vtbl(struct ubi_device *ubi, struct ubi_scan_info *si, +static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, int copy, void *vtbl) { int err, tries = 0; @@ -373,7 +373,7 @@ out_free: * 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, - struct ubi_scan_info *si, + struct ubi_attach_info *si, struct ubi_ainf_volume *sv) { int err; @@ -496,7 +496,7 @@ out_free: * negative error code in case of failure. */ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, - struct ubi_scan_info *si) + struct ubi_attach_info *si) { int i; struct ubi_vtbl_record *vtbl; @@ -531,7 +531,8 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, * Returns zero in case of success and a negative error code in case of * failure. */ -static int init_volumes(struct ubi_device *ubi, const struct ubi_scan_info *si, +static int init_volumes(struct ubi_device *ubi, + const struct ubi_attach_info *si, const struct ubi_vtbl_record *vtbl) { int i, reserved_pebs = 0; @@ -712,7 +713,7 @@ bad: * information is OK and %-EINVAL if it is not. */ static int check_scanning_info(const struct ubi_device *ubi, - struct ubi_scan_info *si) + struct ubi_attach_info *si) { int err, i; struct ubi_ainf_volume *sv; @@ -776,7 +777,7 @@ static int check_scanning_info(const struct ubi_device *ubi, * or creates it if needed. Returns zero in case of success and a negative * error code in case of failure. */ -int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_scan_info *si) +int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) { int i, err; struct ubi_ainf_volume *sv; -- cgit v1.2.3 From 1d69aaeba3bb9a5cdd04b398e1ed1a408f53ac52 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 08:26:24 +0300 Subject: UBI: rename seb to aeb After re-naming the 'struct ubi_scan_leb' we should adjust all variables named 'seb' to something else, because 'seb' stands for "scanning eraseblock". Let's rename it to 'aeb' which stands for "attaching eraseblock" which is a bit more consistend and has the same length. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index fc797ea8cffa..f6f8cc5b06ad 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -303,7 +303,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, { int err, tries = 0; struct ubi_vid_hdr *vid_hdr; - struct ubi_ainf_peb *new_seb; + struct ubi_ainf_peb *new_aeb; ubi_msg("create volume table (copy #%d)", copy + 1); @@ -312,9 +312,9 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, return -ENOMEM; retry: - new_seb = ubi_scan_get_free_peb(ubi, si); - if (IS_ERR(new_seb)) { - err = PTR_ERR(new_seb); + new_aeb = ubi_scan_get_free_peb(ubi, si); + if (IS_ERR(new_aeb)) { + err = PTR_ERR(new_aeb); goto out_free; } @@ -327,12 +327,12 @@ retry: vid_hdr->sqnum = cpu_to_be64(++si->max_sqnum); /* The EC header is already there, write the VID header */ - err = ubi_io_write_vid_hdr(ubi, new_seb->pnum, vid_hdr); + err = ubi_io_write_vid_hdr(ubi, new_aeb->pnum, vid_hdr); if (err) goto write_error; /* Write the layout volume contents */ - err = ubi_io_write_data(ubi, vtbl, new_seb->pnum, 0, ubi->vtbl_size); + err = ubi_io_write_data(ubi, vtbl, new_aeb->pnum, 0, ubi->vtbl_size); if (err) goto write_error; @@ -340,9 +340,9 @@ retry: * And add it to the scanning information. Don't delete the old version * of this LEB as it will be deleted and freed in 'ubi_scan_add_used()'. */ - err = ubi_scan_add_used(ubi, si, new_seb->pnum, new_seb->ec, + err = ubi_scan_add_used(ubi, si, new_aeb->pnum, new_aeb->ec, vid_hdr, 0); - kfree(new_seb); + kfree(new_aeb); ubi_free_vid_hdr(ubi, vid_hdr); return err; @@ -352,10 +352,10 @@ write_error: * Probably this physical eraseblock went bad, try to pick * another one. */ - list_add(&new_seb->u.list, &si->erase); + list_add(&new_aeb->u.list, &si->erase); goto retry; } - kfree(new_seb); + kfree(new_aeb); out_free: ubi_free_vid_hdr(ubi, vid_hdr); return err; @@ -378,7 +378,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, { int err; struct rb_node *rb; - struct ubi_ainf_peb *seb; + struct ubi_ainf_peb *aeb; struct ubi_vtbl_record *leb[UBI_LAYOUT_VOLUME_EBS] = { NULL, NULL }; int leb_corrupted[UBI_LAYOUT_VOLUME_EBS] = {1, 1}; @@ -410,14 +410,14 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, dbg_gen("check layout volume"); /* Read both LEB 0 and LEB 1 into memory */ - ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) { - leb[seb->lnum] = vzalloc(ubi->vtbl_size); - if (!leb[seb->lnum]) { + ubi_rb_for_each_entry(rb, aeb, &sv->root, u.rb) { + leb[aeb->lnum] = vzalloc(ubi->vtbl_size); + if (!leb[aeb->lnum]) { err = -ENOMEM; goto out_free; } - err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0, + err = ubi_io_read_data(ubi, leb[aeb->lnum], aeb->pnum, 0, ubi->vtbl_size); if (err == UBI_IO_BITFLIPS || err == -EBADMSG) /* @@ -425,12 +425,12 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, * uncorrectable ECC error, but we have our own CRC and * the data will be checked later. If the data is OK, * the PEB will be scrubbed (because we set - * seb->scrub). If the data is not OK, the contents of + * aeb->scrub). If the data is not OK, the contents of * the PEB will be recovered from the second copy, and - * seb->scrub will be cleared in + * aeb->scrub will be cleared in * 'ubi_scan_add_used()'. */ - seb->scrub = 1; + aeb->scrub = 1; else if (err) goto out_free; } -- cgit v1.2.3 From 658656722fdb1e13cd4f1079ba61c2ebafcd103b Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 13:09:08 +0300 Subject: 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: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 86 +++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 43 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index f6f8cc5b06ad..9632163c05fb 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -291,14 +291,14 @@ bad: /** * create_vtbl - create a copy of volume table. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * @copy: number of the volume table copy * @vtbl: contents of the volume table * * This function returns zero in case of success and a negative error code in * 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 err, tries = 0; @@ -312,7 +312,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *si, return -ENOMEM; retry: - new_aeb = ubi_scan_get_free_peb(ubi, si); + new_aeb = ubi_scan_get_free_peb(ubi, ai); if (IS_ERR(new_aeb)) { err = PTR_ERR(new_aeb); goto out_free; @@ -324,7 +324,7 @@ retry: vid_hdr->data_size = vid_hdr->used_ebs = vid_hdr->data_pad = cpu_to_be32(0); 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 */ err = ubi_io_write_vid_hdr(ubi, new_aeb->pnum, vid_hdr); @@ -337,10 +337,10 @@ retry: 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()'. */ - 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); kfree(new_aeb); ubi_free_vid_hdr(ubi, vid_hdr); @@ -352,7 +352,7 @@ write_error: * Probably this physical eraseblock went bad, try to pick * another one. */ - list_add(&new_aeb->u.list, &si->erase); + list_add(&new_aeb->u.list, &ai->erase); goto retry; } kfree(new_aeb); @@ -365,15 +365,15 @@ out_free: /** * process_lvol - process the layout volume. * @ubi: UBI device description object - * @si: scanning information - * @sv: layout volume scanning information + * @ai: attaching information + * @sv: layout volume attaching information * * This function is responsible for reading the layout volume, ensuring it is * not corrupted, and recovering from corruptions if needed. Returns volume * 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, - struct ubi_attach_info *si, + struct ubi_attach_info *ai, struct ubi_ainf_volume *sv) { int err; @@ -449,7 +449,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, ubi->vtbl_size); if (leb_corrupted[1]) { 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) goto out_free; ubi_msg("volume table was restored"); @@ -472,7 +472,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, } 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) goto out_free; ubi_msg("volume table was restored"); @@ -490,13 +490,13 @@ out_free: /** * create_empty_lvol - create empty layout volume. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * * This function returns volume table contents in case of success and a * negative error code in case of failure. */ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, - struct ubi_attach_info *si) + struct ubi_attach_info *ai) { int i; struct ubi_vtbl_record *vtbl; @@ -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++) { int err; - err = create_vtbl(ubi, si, i, vtbl); + err = create_vtbl(ubi, ai, i, vtbl); if (err) { vfree(vtbl); return ERR_PTR(err); @@ -524,7 +524,7 @@ static struct ubi_vtbl_record *create_empty_lvol(struct ubi_device *ubi, /** * init_volumes - initialize volume information for existing volumes. * @ubi: UBI device description object - * @si: scanning information + * @ai: scanning information * @vtbl: volume table * * 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, * failure. */ 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) { int i, reserved_pebs = 0; @@ -592,7 +592,7 @@ static int init_volumes(struct ubi_device *ubi, } /* Static volumes only */ - sv = ubi_scan_find_sv(si, i); + sv = ubi_scan_find_sv(ai, i); if (!sv) { /* * No eraseblocks belonging to this volume found. We @@ -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 - * @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. */ static int check_sv(const struct ubi_volume *vol, @@ -696,50 +696,50 @@ static int check_sv(const struct ubi_volume *vol, return 0; bad: - ubi_err("bad scanning information, error %d", err); + ubi_err("bad attaching information, error %d", err); ubi_dump_sv(sv); ubi_dump_vol_info(vol); return -EINVAL; } /** - * check_scanning_info - check that scanning information. + * check_scanning_info - check that attaching information. * @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 - * 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 * information is OK and %-EINVAL if it is not. */ static int check_scanning_info(const struct ubi_device *ubi, - struct ubi_attach_info *si) + struct ubi_attach_info *ai) { int err, i; struct ubi_ainf_volume *sv; 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", - si->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots); + ai->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots); return -EINVAL; } - if (si->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT && - si->highest_vol_id < UBI_INTERNAL_VOL_START) { + if (ai->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT && + ai->highest_vol_id < UBI_INTERNAL_VOL_START) { ubi_err("too large volume ID %d found by scanning", - si->highest_vol_id); + ai->highest_vol_id); return -EINVAL; } for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) { cond_resched(); - sv = ubi_scan_find_sv(si, i); + sv = ubi_scan_find_sv(ai, i); vol = ubi->volumes[i]; if (!vol) { if (sv) - ubi_scan_rm_volume(si, sv); + ubi_scan_rm_volume(ai, sv); continue; } @@ -757,7 +757,7 @@ static int check_scanning_info(const struct ubi_device *ubi, * these eraseblocks. */ ubi_msg("finish volume %d removal", sv->vol_id); - ubi_scan_rm_volume(si, sv); + ubi_scan_rm_volume(ai, sv); } else if (sv) { err = check_sv(vol, sv); if (err) @@ -771,13 +771,13 @@ static int check_scanning_info(const struct ubi_device *ubi, /** * ubi_read_volume_table - read the volume table. * @ubi: UBI device description object - * @si: scanning information + * @ai: attaching information * * 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 * 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; struct ubi_ainf_volume *sv; @@ -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 = 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) { /* * 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) * But if flash is not empty this must be a corruption or the * MTD device just contains garbage. */ - if (si->is_empty) { - ubi->vtbl = create_empty_lvol(ubi, si); + if (ai->is_empty) { + ubi->vtbl = create_empty_lvol(ubi, ai); if (IS_ERR(ubi->vtbl)) return PTR_ERR(ubi->vtbl); } else { @@ -821,7 +821,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *si) return -EINVAL; } - ubi->vtbl = process_lvol(ubi, si, sv); + ubi->vtbl = process_lvol(ubi, ai, sv); if (IS_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) * The layout volume is OK, initialize the corresponding in-RAM data * structures. */ - err = init_volumes(ubi, si, ubi->vtbl); + err = init_volumes(ubi, ai, ubi->vtbl); if (err) 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. */ - err = check_scanning_info(ubi, si); + err = check_scanning_info(ubi, ai); if (err) goto out_free; -- cgit v1.2.3 From a9abf45f4cbd95f113874ea8c427e267c66ab92e Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 14:38:34 +0300 Subject: UBI: rename sv to av After re-naming the 'struct ubi_scan_volume' we should adjust all variables named 'sv' to something else, because 'sv' stands for "scanning volume". Let's rename it to 'av' which stands for "attaching volume" which is a bit more consistent and has the same length, which makes re-naming easy. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 72 +++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 9632163c05fb..92c44a549f51 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -366,7 +366,7 @@ out_free: * process_lvol - process the layout volume. * @ubi: UBI device description object * @ai: attaching information - * @sv: layout volume attaching information + * @av: layout volume attaching information * * This function is responsible for reading the layout volume, ensuring it is * not corrupted, and recovering from corruptions if needed. Returns volume @@ -374,7 +374,7 @@ out_free: */ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, struct ubi_attach_info *ai, - struct ubi_ainf_volume *sv) + struct ubi_ainf_volume *av) { int err; struct rb_node *rb; @@ -410,7 +410,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, dbg_gen("check layout volume"); /* Read both LEB 0 and LEB 1 into memory */ - ubi_rb_for_each_entry(rb, aeb, &sv->root, u.rb) { + ubi_rb_for_each_entry(rb, aeb, &av->root, u.rb) { leb[aeb->lnum] = vzalloc(ubi->vtbl_size); if (!leb[aeb->lnum]) { err = -ENOMEM; @@ -536,7 +536,7 @@ static int init_volumes(struct ubi_device *ubi, const struct ubi_vtbl_record *vtbl) { int i, reserved_pebs = 0; - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; struct ubi_volume *vol; for (i = 0; i < ubi->vtbl_slots; i++) { @@ -592,8 +592,8 @@ static int init_volumes(struct ubi_device *ubi, } /* Static volumes only */ - sv = ubi_scan_find_sv(ai, i); - if (!sv) { + av = ubi_scan_find_av(ai, i); + if (!av) { /* * No eraseblocks belonging to this volume found. We * don't actually know whether this static volume is @@ -605,22 +605,22 @@ static int init_volumes(struct ubi_device *ubi, continue; } - if (sv->leb_count != sv->used_ebs) { + if (av->leb_count != av->used_ebs) { /* * We found a static volume which misses several * eraseblocks. Treat it as corrupted. */ ubi_warn("static volume %d misses %d LEBs - corrupted", - sv->vol_id, sv->used_ebs - sv->leb_count); + av->vol_id, av->used_ebs - av->leb_count); vol->corrupted = 1; continue; } - vol->used_ebs = sv->used_ebs; + vol->used_ebs = av->used_ebs; vol->used_bytes = (long long)(vol->used_ebs - 1) * vol->usable_leb_size; - vol->used_bytes += sv->last_data_size; - vol->last_eb_bytes = sv->last_data_size; + vol->used_bytes += av->last_data_size; + vol->last_eb_bytes = av->last_data_size; } /* And add the layout volume */ @@ -661,35 +661,35 @@ static int init_volumes(struct ubi_device *ubi, } /** - * check_sv - check volume attaching information. + * check_av - check volume attaching information. * @vol: UBI volume description object - * @sv: volume attaching information + * @av: volume attaching information * * This function returns zero if the volume attaching information is consistent * to the data read from the volume tabla, and %-EINVAL if not. */ -static int check_sv(const struct ubi_volume *vol, - const struct ubi_ainf_volume *sv) +static int check_av(const struct ubi_volume *vol, + const struct ubi_ainf_volume *av) { int err; - if (sv->highest_lnum >= vol->reserved_pebs) { + if (av->highest_lnum >= vol->reserved_pebs) { err = 1; goto bad; } - if (sv->leb_count > vol->reserved_pebs) { + if (av->leb_count > vol->reserved_pebs) { err = 2; goto bad; } - if (sv->vol_type != vol->vol_type) { + if (av->vol_type != vol->vol_type) { err = 3; goto bad; } - if (sv->used_ebs > vol->reserved_pebs) { + if (av->used_ebs > vol->reserved_pebs) { err = 4; goto bad; } - if (sv->data_pad != vol->data_pad) { + if (av->data_pad != vol->data_pad) { err = 5; goto bad; } @@ -697,7 +697,7 @@ static int check_sv(const struct ubi_volume *vol, bad: ubi_err("bad attaching information, error %d", err); - ubi_dump_sv(sv); + ubi_dump_av(av); ubi_dump_vol_info(vol); return -EINVAL; } @@ -716,7 +716,7 @@ static int check_scanning_info(const struct ubi_device *ubi, struct ubi_attach_info *ai) { int err, i; - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; struct ubi_volume *vol; if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { @@ -735,18 +735,18 @@ static int check_scanning_info(const struct ubi_device *ubi, for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) { cond_resched(); - sv = ubi_scan_find_sv(ai, i); + av = ubi_scan_find_av(ai, i); vol = ubi->volumes[i]; if (!vol) { - if (sv) - ubi_scan_rm_volume(ai, sv); + if (av) + ubi_scan_rm_volume(ai, av); continue; } if (vol->reserved_pebs == 0) { ubi_assert(i < ubi->vtbl_slots); - if (!sv) + if (!av) continue; /* @@ -756,10 +756,10 @@ static int check_scanning_info(const struct ubi_device *ubi, * reboot while the volume was being removed. Discard * these eraseblocks. */ - ubi_msg("finish volume %d removal", sv->vol_id); - ubi_scan_rm_volume(ai, sv); - } else if (sv) { - err = check_sv(vol, sv); + ubi_msg("finish volume %d removal", av->vol_id); + ubi_scan_rm_volume(ai, av); + } else if (av) { + err = check_av(vol, av); if (err) return err; } @@ -780,7 +780,7 @@ static int check_scanning_info(const struct ubi_device *ubi, int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) { int i, err; - struct ubi_ainf_volume *sv; + struct ubi_ainf_volume *av; empty_vtbl_record.crc = cpu_to_be32(0xf116c36b); @@ -795,8 +795,8 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) ubi->vtbl_size = ubi->vtbl_slots * UBI_VTBL_RECORD_SIZE; ubi->vtbl_size = ALIGN(ubi->vtbl_size, ubi->min_io_size); - sv = ubi_scan_find_sv(ai, UBI_LAYOUT_VOLUME_ID); - if (!sv) { + av = ubi_scan_find_av(ai, UBI_LAYOUT_VOLUME_ID); + if (!av) { /* * No logical eraseblocks belonging to the layout volume were * found. This could mean that the flash is just empty. In @@ -814,14 +814,14 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) return -EINVAL; } } else { - if (sv->leb_count > UBI_LAYOUT_VOLUME_EBS) { + if (av->leb_count > UBI_LAYOUT_VOLUME_EBS) { /* This must not happen with proper UBI images */ ubi_err("too many LEBs (%d) in layout volume", - sv->leb_count); + av->leb_count); return -EINVAL; } - ubi->vtbl = process_lvol(ubi, ai, sv); + ubi->vtbl = process_lvol(ubi, ai, av); if (IS_ERR(ubi->vtbl)) return PTR_ERR(ubi->vtbl); } -- cgit v1.2.3 From 27256f5f10db46a062576d6640c8b392476395d3 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 15:31:31 +0300 Subject: UBI: rename ubi_scan_add_used The old name is not logical anymore - rename it to 'ubi_add_to_av()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 92c44a549f51..209a6dbaf741 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -338,10 +338,9 @@ retry: /* * 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_add_to_av()'. */ - err = ubi_scan_add_used(ubi, ai, new_aeb->pnum, new_aeb->ec, - vid_hdr, 0); + err = ubi_add_to_av(ubi, ai, new_aeb->pnum, new_aeb->ec, vid_hdr, 0); kfree(new_aeb); ubi_free_vid_hdr(ubi, vid_hdr); return err; @@ -428,7 +427,7 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, * aeb->scrub). If the data is not OK, the contents of * the PEB will be recovered from the second copy, and * aeb->scrub will be cleared in - * 'ubi_scan_add_used()'. + * 'ubi_add_to_av()'. */ aeb->scrub = 1; else if (err) -- cgit v1.2.3 From cd60bd4c9701b59818141573eb56c72fbf0a4061 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 15:33:20 +0300 Subject: UBI: rename ubi_scan_find_av The old name is not logical anymore - rename it to 'ubi_find_av()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 209a6dbaf741..e2644a403c02 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -591,7 +591,7 @@ static int init_volumes(struct ubi_device *ubi, } /* Static volumes only */ - av = ubi_scan_find_av(ai, i); + av = ubi_find_av(ai, i); if (!av) { /* * No eraseblocks belonging to this volume found. We @@ -734,7 +734,7 @@ static int check_scanning_info(const struct ubi_device *ubi, for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) { cond_resched(); - av = ubi_scan_find_av(ai, i); + av = ubi_find_av(ai, i); vol = ubi->volumes[i]; if (!vol) { if (av) @@ -794,7 +794,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) ubi->vtbl_size = ubi->vtbl_slots * UBI_VTBL_RECORD_SIZE; ubi->vtbl_size = ALIGN(ubi->vtbl_size, ubi->min_io_size); - av = ubi_scan_find_av(ai, UBI_LAYOUT_VOLUME_ID); + av = ubi_find_av(ai, UBI_LAYOUT_VOLUME_ID); if (!av) { /* * No logical eraseblocks belonging to the layout volume were -- cgit v1.2.3 From 33373d8ff7c1b049ba5ec057fd6b252f7270c43a Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 15:36:39 +0300 Subject: UBI: rename ubi_scan_rm_volume The old name is not logical anymore - rename it to 'ubi_remove_av()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index e2644a403c02..d8ffc7d50dc4 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -738,7 +738,7 @@ static int check_scanning_info(const struct ubi_device *ubi, vol = ubi->volumes[i]; if (!vol) { if (av) - ubi_scan_rm_volume(ai, av); + ubi_remove_av(ai, av); continue; } @@ -756,7 +756,7 @@ static int check_scanning_info(const struct ubi_device *ubi, * these eraseblocks. */ ubi_msg("finish volume %d removal", av->vol_id); - ubi_scan_rm_volume(ai, av); + ubi_remove_av(ai, av); } else if (av) { err = check_av(vol, av); if (err) -- cgit v1.2.3 From fe5d16a7e46c5c072d3c377f5b7bd07598f28b81 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 15:38:56 +0300 Subject: UBI: rename ubi_scan_get_free_peb The old name is not logical anymore - rename it to 'ubi_early_get_peb()'. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index d8ffc7d50dc4..b5a484c0bfac 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -312,7 +312,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *ai, return -ENOMEM; retry: - new_aeb = ubi_scan_get_free_peb(ubi, ai); + new_aeb = ubi_early_get_peb(ubi, ai); if (IS_ERR(new_aeb)) { err = PTR_ERR(new_aeb); goto out_free; -- cgit v1.2.3 From 2dcda46eacdb538db765bddb5fe13d0fba08557d Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 May 2012 16:12:26 +0300 Subject: UBI: amend comments after all the renamings This patch amends commentaries in scan.[ch] to match the new logic. Reminder - we did the restructuring to prepare the code for adding the fastmap. This patch also renames a couple of functions - it was too difficult to separate out that change and I decided that it is not too bad to have it in the same patch with commentaries changes. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index b5a484c0bfac..39d6b63f20a5 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -37,16 +37,15 @@ * LEB 1. This scheme guarantees recoverability from unclean reboots. * * In this UBI implementation the on-flash volume table does not contain any - * information about how many data static volumes contain. This information may - * be found from the scanning data. + * information about how much data static volumes contain. * * But it would still be beneficial to store this information in the volume * table. For example, suppose we have a static volume X, and all its physical * eraseblocks became bad for some reasons. Suppose we are attaching the - * corresponding MTD device, the scanning has found no logical eraseblocks + * corresponding MTD device, for some reason we find no logical eraseblocks * corresponding to the volume X. According to the volume table volume X does * exist. So we don't know whether it is just empty or all its physical - * eraseblocks went bad. So we cannot alarm the user about this corruption. + * eraseblocks went bad. So we cannot alarm the user properly. * * The volume table also stores so-called "update marker", which is used for * volume updates. Before updating the volume, the update marker is set, and @@ -702,16 +701,16 @@ bad: } /** - * check_scanning_info - check that attaching information. + * check_attaching_info - check that attaching information. * @ubi: UBI device description object * @ai: attaching information * * Even though we protect on-flash data by CRC checksums, we still don't trust * 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 attaching * information is OK and %-EINVAL if it is not. */ -static int check_scanning_info(const struct ubi_device *ubi, +static int check_attaching_info(const struct ubi_device *ubi, struct ubi_attach_info *ai) { int err, i; @@ -719,15 +718,14 @@ static int check_scanning_info(const struct ubi_device *ubi, struct ubi_volume *vol; if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { - ubi_err("scanning found %d volumes, maximum is %d + %d", + ubi_err("found %d volumes while attaching, maximum is %d + %d", ai->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots); return -EINVAL; } if (ai->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT && ai->highest_vol_id < UBI_INTERNAL_VOL_START) { - ubi_err("too large volume ID %d found by scanning", - ai->highest_vol_id); + ubi_err("too large volume ID %d found", ai->highest_vol_id); return -EINVAL; } @@ -749,7 +747,7 @@ static int check_scanning_info(const struct ubi_device *ubi, continue; /* - * During scanning we found a volume which does not + * During attaching we found a volume which does not * exist according to the information in the volume * table. This must have happened due to an unclean * reboot while the volume was being removed. Discard @@ -839,7 +837,7 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) * Make sure that the attaching information is consistent to the * information stored in the volume table. */ - err = check_scanning_info(ubi, ai); + err = check_attaching_info(ubi, ai); if (err) goto out_free; -- cgit v1.2.3 From 17636ef93691f5d3e9c9850b9e319e180e0b7ed1 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Mon, 3 Sep 2012 17:12:29 +0300 Subject: UBI: fix a horrible memory deallocation bug UBI was mistakingly using 'kfree()' instead of 'kmem_cache_free()' when freeing "attach eraseblock" structures in vtbl.c. Thankfully, this happened only when we were doing auto-format, so many systems were unaffected. However, there are still many users affected. It is strange, but the system did not crash and nothing bad happened when the SLUB memory allocator was used. However, in case of SLOB we observed an crash right away. This problem was introduced in 2.6.39 by commit "6c1e875 UBI: add slab cache for ubi_scan_leb objects" A note for stable trees: Because variable were renamed, this won't cleanly apply to older kernels. Changing names like this should help: 1. ai -> si 2. aeb_slab_cache -> seb_slab_cache 3. new_aeb -> new_seb Reported-by: Richard Genoud Tested-by: Richard Genoud Tested-by: Artem Bityutskiy Cc: stable@vger.kernel.org [v2.6.39+] Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index 39d6b63f20a5..f37f5dfd5ca3 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -340,7 +340,7 @@ retry: * of this LEB as it will be deleted and freed in 'ubi_add_to_av()'. */ err = ubi_add_to_av(ubi, ai, new_aeb->pnum, new_aeb->ec, vid_hdr, 0); - kfree(new_aeb); + kmem_cache_free(ai->aeb_slab_cache, new_aeb); ubi_free_vid_hdr(ubi, vid_hdr); return err; @@ -353,7 +353,7 @@ write_error: list_add(&new_aeb->u.list, &ai->erase); goto retry; } - kfree(new_aeb); + kmem_cache_free(ai->aeb_slab_cache, new_aeb); out_free: ubi_free_vid_hdr(ubi, vid_hdr); return err; -- cgit v1.2.3 From 408a719e4267c98c93976cf43087519a22699ce6 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Mon, 27 Aug 2012 14:43:54 +0300 Subject: UBI: comply with coding style Join all the split printk lines in order to stop checkpatch complaining. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index f37f5dfd5ca3..b307b990a02a 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -270,8 +270,8 @@ static int vtbl_check(const struct ubi_device *ubi, if (len1 > 0 && len1 == len2 && !strncmp(vtbl[i].name, vtbl[n].name, len1)) { - ubi_err("volumes %d and %d have the same name" - " \"%s\"", i, n, vtbl[i].name); + ubi_err("volumes %d and %d have the same name \"%s\"", + i, n, vtbl[i].name); ubi_dump_vtbl_record(&vtbl[i], i); ubi_dump_vtbl_record(&vtbl[n], n); return -EINVAL; @@ -562,8 +562,8 @@ static int init_volumes(struct ubi_device *ubi, if (vtbl[i].flags & UBI_VTBL_AUTORESIZE_FLG) { /* Auto re-size flag may be set only for one volume */ if (ubi->autoresize_vol_id != -1) { - ubi_err("more than one auto-resize volume (%d " - "and %d)", ubi->autoresize_vol_id, i); + ubi_err("more than one auto-resize volume (%d and %d)", + ubi->autoresize_vol_id, i); kfree(vol); return -EINVAL; } -- cgit v1.2.3 From 1383b0d364e7abb6c3e7b0435d253c9740000817 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Mon, 27 Aug 2012 17:14:58 +0300 Subject: UBI: print less MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit UBI currently prints a lot of information when it mounts a volume, which bothers some people. Make it less chatty - print only important information by default. Get rid of 'dbg_msg()' macro completely. Reported-by: Uwe Kleine-König Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index b307b990a02a..b2d4e97238f9 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -304,7 +304,7 @@ static int create_vtbl(struct ubi_device *ubi, struct ubi_attach_info *ai, struct ubi_vid_hdr *vid_hdr; struct ubi_ainf_peb *new_aeb; - ubi_msg("create volume table (copy #%d)", copy + 1); + dbg_gen("create volume table (copy #%d)", copy + 1); vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_KERNEL); if (!vid_hdr) -- cgit v1.2.3 From 8e9e752a8e981f35b14d53a779f9bea15703bf73 Mon Sep 17 00:00:00 2001 From: Ezequiel Garcia Date: Wed, 28 Nov 2012 09:18:29 -0300 Subject: UBI: introduce helpers dbg_chk_{io, gen} With this patch code is a bit more readable and there's no generated code or functionality impact. Furthermore, this abstracts implementation details and will allow to change ubi_debug_info in a less invasive way. Signed-off-by: Ezequiel Garcia Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vtbl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mtd/ubi/vtbl.c') diff --git a/drivers/mtd/ubi/vtbl.c b/drivers/mtd/ubi/vtbl.c index b2d4e97238f9..30f84eff6385 100644 --- a/drivers/mtd/ubi/vtbl.c +++ b/drivers/mtd/ubi/vtbl.c @@ -858,7 +858,7 @@ out_free: */ static void self_vtbl_check(const struct ubi_device *ubi) { - if (!ubi->dbg->chk_gen) + if (!ubi_dbg_chk_gen(ubi)) return; if (vtbl_check(ubi, ubi->vtbl)) { -- cgit v1.2.3