Commit 94784d91 authored by Artem Bityutskiy's avatar Artem Bityutskiy

UBI: bugfix in error path

When volume creation fails, we have to set ubi->volumes[vol_id]
back to NULL.

This patch also tweaks some debugging stuff.
Signed-off-by: default avatarArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
parent 7753f169
...@@ -52,7 +52,6 @@ struct ubi_scan_volume; ...@@ -52,7 +52,6 @@ struct ubi_scan_volume;
struct ubi_scan_leb; struct ubi_scan_leb;
struct ubi_mkvol_req; struct ubi_mkvol_req;
void ubi_dbg_print(int type, const char *func, const char *fmt, ...);
void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr); void ubi_dbg_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr);
void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr); void ubi_dbg_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
void ubi_dbg_dump_vol_info(const struct ubi_volume *vol); void ubi_dbg_dump_vol_info(const struct ubi_volume *vol);
...@@ -66,7 +65,6 @@ void ubi_dbg_hexdump(const void *buf, int size); ...@@ -66,7 +65,6 @@ void ubi_dbg_hexdump(const void *buf, int size);
#define dbg_msg(fmt, ...) ({}) #define dbg_msg(fmt, ...) ({})
#define ubi_dbg_dump_stack() ({}) #define ubi_dbg_dump_stack() ({})
#define ubi_dbg_print(func, fmt, ...) ({})
#define ubi_dbg_dump_ec_hdr(ec_hdr) ({}) #define ubi_dbg_dump_ec_hdr(ec_hdr) ({})
#define ubi_dbg_dump_vid_hdr(vid_hdr) ({}) #define ubi_dbg_dump_vid_hdr(vid_hdr) ({})
#define ubi_dbg_dump_vol_info(vol) ({}) #define ubi_dbg_dump_vol_info(vol) ({})
......
...@@ -228,7 +228,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) ...@@ -228,7 +228,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
for (i = 0; i < ubi->vtbl_slots; i++) for (i = 0; i < ubi->vtbl_slots; i++)
if (ubi->volumes[i] && if (ubi->volumes[i] &&
ubi->volumes[i]->name_len == req->name_len && ubi->volumes[i]->name_len == req->name_len &&
strcmp(ubi->volumes[i]->name, req->name) == 0) { !strcmp(ubi->volumes[i]->name, req->name)) {
dbg_err("volume \"%s\" exists (ID %d)", req->name, i); dbg_err("volume \"%s\" exists (ID %d)", req->name, i);
goto out_unlock; goto out_unlock;
} }
...@@ -351,6 +351,7 @@ out_acc: ...@@ -351,6 +351,7 @@ out_acc:
spin_lock(&ubi->volumes_lock); spin_lock(&ubi->volumes_lock);
ubi->rsvd_pebs -= vol->reserved_pebs; ubi->rsvd_pebs -= vol->reserved_pebs;
ubi->avail_pebs += vol->reserved_pebs; ubi->avail_pebs += vol->reserved_pebs;
ubi->volumes[vol_id] = NULL;
out_unlock: out_unlock:
spin_unlock(&ubi->volumes_lock); spin_unlock(&ubi->volumes_lock);
kfree(vol); kfree(vol);
...@@ -367,6 +368,7 @@ out_sysfs: ...@@ -367,6 +368,7 @@ out_sysfs:
spin_lock(&ubi->volumes_lock); spin_lock(&ubi->volumes_lock);
ubi->rsvd_pebs -= vol->reserved_pebs; ubi->rsvd_pebs -= vol->reserved_pebs;
ubi->avail_pebs += vol->reserved_pebs; ubi->avail_pebs += vol->reserved_pebs;
ubi->volumes[vol_id] = NULL;
spin_unlock(&ubi->volumes_lock); spin_unlock(&ubi->volumes_lock);
volume_sysfs_close(vol); volume_sysfs_close(vol);
return err; return err;
...@@ -784,7 +786,7 @@ static void paranoid_check_volume(const struct ubi_device *ubi, int vol_id) ...@@ -784,7 +786,7 @@ static void paranoid_check_volume(const struct ubi_device *ubi, int vol_id)
return; return;
fail: fail:
ubi_err("paranoid check failed"); ubi_err("paranoid check failed for volume %d", vol_id);
ubi_dbg_dump_vol_info(vol); ubi_dbg_dump_vol_info(vol);
ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); ubi_dbg_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id);
BUG(); BUG();
......
...@@ -96,9 +96,6 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, ...@@ -96,9 +96,6 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx,
vtbl_rec->crc = cpu_to_be32(crc); vtbl_rec->crc = cpu_to_be32(crc);
} }
dbg_msg("change record %d", idx);
ubi_dbg_dump_vtbl_record(vtbl_rec, idx);
mutex_lock(&ubi->vtbl_mutex); mutex_lock(&ubi->vtbl_mutex);
memcpy(&ubi->vtbl[idx], vtbl_rec, sizeof(struct ubi_vtbl_record)); memcpy(&ubi->vtbl[idx], vtbl_rec, sizeof(struct ubi_vtbl_record));
for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) { for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment