Commit ccb5a491 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'upstream-3.19-rc1' of git://git.infradead.org/linux-ubifs

Pull UBI/UBIFS updates from Artem Bityutskiy:
 "This includes the following UBI/UBIFS changes:
   - UBI debug messages now include the UBI device number.  This change
     is responsible for the big diffstat since it touched every
     debugging print statement.
   - An Xattr bug-fix which fixes SELinux support
   - Several error path fixes in UBI/UBIFS"

* tag 'upstream-3.19-rc1' of git://git.infradead.org/linux-ubifs:
  UBI: Fix invalid vfree()
  UBI: Fix double free after do_sync_erase()
  UBIFS: fix a couple bugs in UBIFS xattr length calculation
  UBI: vtbl: Use ubi_eba_atomic_leb_change()
  UBI: Extend UBI layer debug/messaging capabilities
  UBIFS: fix budget leak in error path
parents c05e14f7 f38aed97
...@@ -176,6 +176,7 @@ static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec) ...@@ -176,6 +176,7 @@ static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec)
/** /**
* validate_vid_hdr - check volume identifier header. * validate_vid_hdr - check volume identifier header.
* @ubi: UBI device description object
* @vid_hdr: the volume identifier header to check * @vid_hdr: the volume identifier header to check
* @av: information about the volume this logical eraseblock belongs to * @av: information about the volume this logical eraseblock belongs to
* @pnum: physical eraseblock number the VID header came from * @pnum: physical eraseblock number the VID header came from
...@@ -188,7 +189,8 @@ static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec) ...@@ -188,7 +189,8 @@ static int add_corrupted(struct ubi_attach_info *ai, int pnum, int ec)
* information in the VID header is consistent to the information in other VID * information in the VID header is consistent to the information in other VID
* headers of the same volume. * headers of the same volume.
*/ */
static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, static int validate_vid_hdr(const struct ubi_device *ubi,
const struct ubi_vid_hdr *vid_hdr,
const struct ubi_ainf_volume *av, int pnum) const struct ubi_ainf_volume *av, int pnum)
{ {
int vol_type = vid_hdr->vol_type; int vol_type = vid_hdr->vol_type;
...@@ -206,7 +208,7 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, ...@@ -206,7 +208,7 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr,
*/ */
if (vol_id != av->vol_id) { if (vol_id != av->vol_id) {
ubi_err("inconsistent vol_id"); ubi_err(ubi, "inconsistent vol_id");
goto bad; goto bad;
} }
...@@ -216,17 +218,17 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, ...@@ -216,17 +218,17 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr,
av_vol_type = UBI_VID_DYNAMIC; av_vol_type = UBI_VID_DYNAMIC;
if (vol_type != av_vol_type) { if (vol_type != av_vol_type) {
ubi_err("inconsistent vol_type"); ubi_err(ubi, "inconsistent vol_type");
goto bad; goto bad;
} }
if (used_ebs != av->used_ebs) { if (used_ebs != av->used_ebs) {
ubi_err("inconsistent used_ebs"); ubi_err(ubi, "inconsistent used_ebs");
goto bad; goto bad;
} }
if (data_pad != av->data_pad) { if (data_pad != av->data_pad) {
ubi_err("inconsistent data_pad"); ubi_err(ubi, "inconsistent data_pad");
goto bad; goto bad;
} }
} }
...@@ -234,7 +236,7 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr, ...@@ -234,7 +236,7 @@ static int validate_vid_hdr(const struct ubi_vid_hdr *vid_hdr,
return 0; return 0;
bad: bad:
ubi_err("inconsistent VID header at PEB %d", pnum); ubi_err(ubi, "inconsistent VID header at PEB %d", pnum);
ubi_dump_vid_hdr(vid_hdr); ubi_dump_vid_hdr(vid_hdr);
ubi_dump_av(av); ubi_dump_av(av);
return -EINVAL; return -EINVAL;
...@@ -336,7 +338,7 @@ int ubi_compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *aeb, ...@@ -336,7 +338,7 @@ int ubi_compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *aeb,
* support these images anymore. Well, those images still work, * support these images anymore. Well, those images still work,
* but only if no unclean reboots happened. * but only if no unclean reboots happened.
*/ */
ubi_err("unsupported on-flash UBI format"); ubi_err(ubi, "unsupported on-flash UBI format");
return -EINVAL; return -EINVAL;
} }
...@@ -377,7 +379,7 @@ int ubi_compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *aeb, ...@@ -377,7 +379,7 @@ int ubi_compare_lebs(struct ubi_device *ubi, const struct ubi_ainf_peb *aeb,
if (err == UBI_IO_BITFLIPS) if (err == UBI_IO_BITFLIPS)
bitflips = 1; bitflips = 1;
else { else {
ubi_err("VID of PEB %d header is bad, but it was OK earlier, err %d", ubi_err(ubi, "VID of PEB %d header is bad, but it was OK earlier, err %d",
pnum, err); pnum, err);
if (err > 0) if (err > 0)
err = -EIO; err = -EIO;
...@@ -507,7 +509,7 @@ int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, ...@@ -507,7 +509,7 @@ int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum,
* logical eraseblocks because there was an unclean reboot. * logical eraseblocks because there was an unclean reboot.
*/ */
if (aeb->sqnum == sqnum && sqnum != 0) { if (aeb->sqnum == sqnum && sqnum != 0) {
ubi_err("two LEBs with same sequence number %llu", ubi_err(ubi, "two LEBs with same sequence number %llu",
sqnum); sqnum);
ubi_dump_aeb(aeb, 0); ubi_dump_aeb(aeb, 0);
ubi_dump_vid_hdr(vid_hdr); ubi_dump_vid_hdr(vid_hdr);
...@@ -527,7 +529,7 @@ int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, ...@@ -527,7 +529,7 @@ int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum,
* This logical eraseblock is newer than the one * This logical eraseblock is newer than the one
* found earlier. * found earlier.
*/ */
err = validate_vid_hdr(vid_hdr, av, pnum); err = validate_vid_hdr(ubi, vid_hdr, av, pnum);
if (err) if (err)
return err; return err;
...@@ -565,7 +567,7 @@ int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum, ...@@ -565,7 +567,7 @@ int ubi_add_to_av(struct ubi_device *ubi, struct ubi_attach_info *ai, int pnum,
* attaching information. * attaching information.
*/ */
err = validate_vid_hdr(vid_hdr, av, pnum); err = validate_vid_hdr(ubi, vid_hdr, av, pnum);
if (err) if (err)
return err; return err;
...@@ -668,7 +670,8 @@ static int early_erase_peb(struct ubi_device *ubi, ...@@ -668,7 +670,8 @@ static int early_erase_peb(struct ubi_device *ubi,
* Erase counter overflow. Upgrade UBI and use 64-bit * Erase counter overflow. Upgrade UBI and use 64-bit
* erase counters internally. * erase counters internally.
*/ */
ubi_err("erase counter overflow at PEB %d, EC %d", pnum, ec); ubi_err(ubi, "erase counter overflow at PEB %d, EC %d",
pnum, ec);
return -EINVAL; return -EINVAL;
} }
...@@ -736,7 +739,7 @@ struct ubi_ainf_peb *ubi_early_get_peb(struct ubi_device *ubi, ...@@ -736,7 +739,7 @@ struct ubi_ainf_peb *ubi_early_get_peb(struct ubi_device *ubi,
return aeb; return aeb;
} }
ubi_err("no free eraseblocks"); ubi_err(ubi, "no free eraseblocks");
return ERR_PTR(-ENOSPC); return ERR_PTR(-ENOSPC);
} }
...@@ -785,9 +788,9 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr, ...@@ -785,9 +788,9 @@ static int check_corruption(struct ubi_device *ubi, struct ubi_vid_hdr *vid_hdr,
if (ubi_check_pattern(ubi->peb_buf, 0xFF, ubi->leb_size)) if (ubi_check_pattern(ubi->peb_buf, 0xFF, ubi->leb_size))
goto out_unlock; goto out_unlock;
ubi_err("PEB %d contains corrupted VID header, and the data does not contain all 0xFF", ubi_err(ubi, "PEB %d contains corrupted VID header, and the data does not contain all 0xFF",
pnum); pnum);
ubi_err("this may be a non-UBI PEB or a severe VID header corruption which requires manual inspection"); ubi_err(ubi, "this may be a non-UBI PEB or a severe VID header corruption which requires manual inspection");
ubi_dump_vid_hdr(vid_hdr); ubi_dump_vid_hdr(vid_hdr);
pr_err("hexdump of PEB %d offset %d, length %d", pr_err("hexdump of PEB %d offset %d, length %d",
pnum, ubi->leb_start, ubi->leb_size); pnum, ubi->leb_start, ubi->leb_size);
...@@ -859,7 +862,8 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -859,7 +862,8 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
bitflips = 1; bitflips = 1;
break; break;
default: default:
ubi_err("'ubi_io_read_ec_hdr()' returned unknown code %d", err); ubi_err(ubi, "'ubi_io_read_ec_hdr()' returned unknown code %d",
err);
return -EINVAL; return -EINVAL;
} }
...@@ -868,7 +872,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -868,7 +872,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
/* Make sure UBI version is OK */ /* Make sure UBI version is OK */
if (ech->version != UBI_VERSION) { if (ech->version != UBI_VERSION) {
ubi_err("this UBI version is %d, image version is %d", ubi_err(ubi, "this UBI version is %d, image version is %d",
UBI_VERSION, (int)ech->version); UBI_VERSION, (int)ech->version);
return -EINVAL; return -EINVAL;
} }
...@@ -882,7 +886,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -882,7 +886,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
* flash. Upgrade UBI and use 64-bit erase counters * flash. Upgrade UBI and use 64-bit erase counters
* internally. * internally.
*/ */
ubi_err("erase counter overflow, max is %d", ubi_err(ubi, "erase counter overflow, max is %d",
UBI_MAX_ERASECOUNTER); UBI_MAX_ERASECOUNTER);
ubi_dump_ec_hdr(ech); ubi_dump_ec_hdr(ech);
return -EINVAL; return -EINVAL;
...@@ -903,7 +907,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -903,7 +907,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
if (!ubi->image_seq) if (!ubi->image_seq)
ubi->image_seq = image_seq; ubi->image_seq = image_seq;
if (image_seq && ubi->image_seq != image_seq) { if (image_seq && ubi->image_seq != image_seq) {
ubi_err("bad image sequence number %d in PEB %d, expected %d", ubi_err(ubi, "bad image sequence number %d in PEB %d, expected %d",
image_seq, pnum, ubi->image_seq); image_seq, pnum, ubi->image_seq);
ubi_dump_ec_hdr(ech); ubi_dump_ec_hdr(ech);
return -EINVAL; return -EINVAL;
...@@ -981,7 +985,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -981,7 +985,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
return err; return err;
goto adjust_mean_ec; goto adjust_mean_ec;
default: default:
ubi_err("'ubi_io_read_vid_hdr()' returned unknown code %d", ubi_err(ubi, "'ubi_io_read_vid_hdr()' returned unknown code %d",
err); err);
return -EINVAL; return -EINVAL;
} }
...@@ -999,7 +1003,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -999,7 +1003,7 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
case UBI_COMPAT_DELETE: case UBI_COMPAT_DELETE:
if (vol_id != UBI_FM_SB_VOLUME_ID if (vol_id != UBI_FM_SB_VOLUME_ID
&& vol_id != UBI_FM_DATA_VOLUME_ID) { && vol_id != UBI_FM_DATA_VOLUME_ID) {
ubi_msg("\"delete\" compatible internal volume %d:%d found, will remove it", ubi_msg(ubi, "\"delete\" compatible internal volume %d:%d found, will remove it",
vol_id, lnum); vol_id, lnum);
} }
err = add_to_list(ai, pnum, vol_id, lnum, err = add_to_list(ai, pnum, vol_id, lnum,
...@@ -1009,13 +1013,13 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -1009,13 +1013,13 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
return 0; return 0;
case UBI_COMPAT_RO: case UBI_COMPAT_RO:
ubi_msg("read-only compatible internal volume %d:%d found, switch to read-only mode", ubi_msg(ubi, "read-only compatible internal volume %d:%d found, switch to read-only mode",
vol_id, lnum); vol_id, lnum);
ubi->ro_mode = 1; ubi->ro_mode = 1;
break; break;
case UBI_COMPAT_PRESERVE: case UBI_COMPAT_PRESERVE:
ubi_msg("\"preserve\" compatible internal volume %d:%d found", ubi_msg(ubi, "\"preserve\" compatible internal volume %d:%d found",
vol_id, lnum); vol_id, lnum);
err = add_to_list(ai, pnum, vol_id, lnum, err = add_to_list(ai, pnum, vol_id, lnum,
ec, 0, &ai->alien); ec, 0, &ai->alien);
...@@ -1024,14 +1028,14 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -1024,14 +1028,14 @@ static int scan_peb(struct ubi_device *ubi, struct ubi_attach_info *ai,
return 0; return 0;
case UBI_COMPAT_REJECT: case UBI_COMPAT_REJECT:
ubi_err("incompatible internal volume %d:%d found", ubi_err(ubi, "incompatible internal volume %d:%d found",
vol_id, lnum); vol_id, lnum);
return -EINVAL; return -EINVAL;
} }
} }
if (ec_err) if (ec_err)
ubi_warn("valid VID header but corrupted EC header at PEB %d", ubi_warn(ubi, "valid VID header but corrupted EC header at PEB %d",
pnum); pnum);
err = ubi_add_to_av(ubi, ai, pnum, ec, vidh, bitflips); err = ubi_add_to_av(ubi, ai, pnum, ec, vidh, bitflips);
if (err) if (err)
...@@ -1075,7 +1079,7 @@ static int late_analysis(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1075,7 +1079,7 @@ static int late_analysis(struct ubi_device *ubi, struct ubi_attach_info *ai)
* with the flash HW or driver. * with the flash HW or driver.
*/ */
if (ai->corr_peb_count) { if (ai->corr_peb_count) {
ubi_err("%d PEBs are corrupted and preserved", ubi_err(ubi, "%d PEBs are corrupted and preserved",
ai->corr_peb_count); ai->corr_peb_count);
pr_err("Corrupted PEBs are:"); pr_err("Corrupted PEBs are:");
list_for_each_entry(aeb, &ai->corr, u.list) list_for_each_entry(aeb, &ai->corr, u.list)
...@@ -1087,7 +1091,7 @@ static int late_analysis(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1087,7 +1091,7 @@ static int late_analysis(struct ubi_device *ubi, struct ubi_attach_info *ai)
* otherwise, only print a warning. * otherwise, only print a warning.
*/ */
if (ai->corr_peb_count >= max_corr) { if (ai->corr_peb_count >= max_corr) {
ubi_err("too many corrupted PEBs, refusing"); ubi_err(ubi, "too many corrupted PEBs, refusing");
return -EINVAL; return -EINVAL;
} }
} }
...@@ -1110,11 +1114,11 @@ static int late_analysis(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1110,11 +1114,11 @@ static int late_analysis(struct ubi_device *ubi, struct ubi_attach_info *ai)
*/ */
if (ai->maybe_bad_peb_count <= 2) { if (ai->maybe_bad_peb_count <= 2) {
ai->is_empty = 1; ai->is_empty = 1;
ubi_msg("empty MTD device detected"); ubi_msg(ubi, "empty MTD device detected");
get_random_bytes(&ubi->image_seq, get_random_bytes(&ubi->image_seq,
sizeof(ubi->image_seq)); sizeof(ubi->image_seq));
} else { } else {
ubi_err("MTD device is not UBI-formatted and possibly contains non-UBI data - refusing it"); ubi_err(ubi, "MTD device is not UBI-formatted and possibly contains non-UBI data - refusing it");
return -EINVAL; return -EINVAL;
} }
...@@ -1248,7 +1252,7 @@ static int scan_all(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -1248,7 +1252,7 @@ static int scan_all(struct ubi_device *ubi, struct ubi_attach_info *ai,
goto out_vidh; goto out_vidh;
} }
ubi_msg("scanning is finished"); ubi_msg(ubi, "scanning is finished");
/* Calculate mean erase counter */ /* Calculate mean erase counter */
if (ai->ec_count) if (ai->ec_count)
...@@ -1515,37 +1519,37 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1515,37 +1519,37 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
vols_found += 1; vols_found += 1;
if (ai->is_empty) { if (ai->is_empty) {
ubi_err("bad is_empty flag"); ubi_err(ubi, "bad is_empty flag");
goto bad_av; goto bad_av;
} }
if (av->vol_id < 0 || av->highest_lnum < 0 || if (av->vol_id < 0 || av->highest_lnum < 0 ||
av->leb_count < 0 || av->vol_type < 0 || av->used_ebs < 0 || av->leb_count < 0 || av->vol_type < 0 || av->used_ebs < 0 ||
av->data_pad < 0 || av->last_data_size < 0) { av->data_pad < 0 || av->last_data_size < 0) {
ubi_err("negative values"); ubi_err(ubi, "negative values");
goto bad_av; goto bad_av;
} }
if (av->vol_id >= UBI_MAX_VOLUMES && if (av->vol_id >= UBI_MAX_VOLUMES &&
av->vol_id < UBI_INTERNAL_VOL_START) { av->vol_id < UBI_INTERNAL_VOL_START) {
ubi_err("bad vol_id"); ubi_err(ubi, "bad vol_id");
goto bad_av; goto bad_av;
} }
if (av->vol_id > ai->highest_vol_id) { if (av->vol_id > ai->highest_vol_id) {
ubi_err("highest_vol_id is %d, but vol_id %d is there", ubi_err(ubi, "highest_vol_id is %d, but vol_id %d is there",
ai->highest_vol_id, av->vol_id); ai->highest_vol_id, av->vol_id);
goto out; goto out;
} }
if (av->vol_type != UBI_DYNAMIC_VOLUME && if (av->vol_type != UBI_DYNAMIC_VOLUME &&
av->vol_type != UBI_STATIC_VOLUME) { av->vol_type != UBI_STATIC_VOLUME) {
ubi_err("bad vol_type"); ubi_err(ubi, "bad vol_type");
goto bad_av; goto bad_av;
} }
if (av->data_pad > ubi->leb_size / 2) { if (av->data_pad > ubi->leb_size / 2) {
ubi_err("bad data_pad"); ubi_err(ubi, "bad data_pad");
goto bad_av; goto bad_av;
} }
...@@ -1557,48 +1561,48 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1557,48 +1561,48 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
leb_count += 1; leb_count += 1;
if (aeb->pnum < 0 || aeb->ec < 0) { if (aeb->pnum < 0 || aeb->ec < 0) {
ubi_err("negative values"); ubi_err(ubi, "negative values");
goto bad_aeb; goto bad_aeb;
} }
if (aeb->ec < ai->min_ec) { if (aeb->ec < ai->min_ec) {
ubi_err("bad ai->min_ec (%d), %d found", ubi_err(ubi, "bad ai->min_ec (%d), %d found",
ai->min_ec, aeb->ec); ai->min_ec, aeb->ec);
goto bad_aeb; goto bad_aeb;
} }
if (aeb->ec > ai->max_ec) { if (aeb->ec > ai->max_ec) {
ubi_err("bad ai->max_ec (%d), %d found", ubi_err(ubi, "bad ai->max_ec (%d), %d found",
ai->max_ec, aeb->ec); ai->max_ec, aeb->ec);
goto bad_aeb; goto bad_aeb;
} }
if (aeb->pnum >= ubi->peb_count) { if (aeb->pnum >= ubi->peb_count) {
ubi_err("too high PEB number %d, total PEBs %d", ubi_err(ubi, "too high PEB number %d, total PEBs %d",
aeb->pnum, ubi->peb_count); aeb->pnum, ubi->peb_count);
goto bad_aeb; goto bad_aeb;
} }
if (av->vol_type == UBI_STATIC_VOLUME) { if (av->vol_type == UBI_STATIC_VOLUME) {
if (aeb->lnum >= av->used_ebs) { if (aeb->lnum >= av->used_ebs) {
ubi_err("bad lnum or used_ebs"); ubi_err(ubi, "bad lnum or used_ebs");
goto bad_aeb; goto bad_aeb;
} }
} else { } else {
if (av->used_ebs != 0) { if (av->used_ebs != 0) {
ubi_err("non-zero used_ebs"); ubi_err(ubi, "non-zero used_ebs");
goto bad_aeb; goto bad_aeb;
} }
} }
if (aeb->lnum > av->highest_lnum) { if (aeb->lnum > av->highest_lnum) {
ubi_err("incorrect highest_lnum or lnum"); ubi_err(ubi, "incorrect highest_lnum or lnum");
goto bad_aeb; goto bad_aeb;
} }
} }
if (av->leb_count != leb_count) { if (av->leb_count != leb_count) {
ubi_err("bad leb_count, %d objects in the tree", ubi_err(ubi, "bad leb_count, %d objects in the tree",
leb_count); leb_count);
goto bad_av; goto bad_av;
} }
...@@ -1609,13 +1613,13 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1609,13 +1613,13 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
aeb = last_aeb; aeb = last_aeb;
if (aeb->lnum != av->highest_lnum) { if (aeb->lnum != av->highest_lnum) {
ubi_err("bad highest_lnum"); ubi_err(ubi, "bad highest_lnum");
goto bad_aeb; goto bad_aeb;
} }
} }
if (vols_found != ai->vols_found) { if (vols_found != ai->vols_found) {
ubi_err("bad ai->vols_found %d, should be %d", ubi_err(ubi, "bad ai->vols_found %d, should be %d",
ai->vols_found, vols_found); ai->vols_found, vols_found);
goto out; goto out;
} }
...@@ -1632,7 +1636,8 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1632,7 +1636,8 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
err = ubi_io_read_vid_hdr(ubi, aeb->pnum, vidh, 1); err = ubi_io_read_vid_hdr(ubi, aeb->pnum, vidh, 1);
if (err && err != UBI_IO_BITFLIPS) { if (err && err != UBI_IO_BITFLIPS) {
ubi_err("VID header is not OK (%d)", err); ubi_err(ubi, "VID header is not OK (%d)",
err);
if (err > 0) if (err > 0)
err = -EIO; err = -EIO;
return err; return err;
...@@ -1641,37 +1646,37 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1641,37 +1646,37 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
vol_type = vidh->vol_type == UBI_VID_DYNAMIC ? vol_type = vidh->vol_type == UBI_VID_DYNAMIC ?
UBI_DYNAMIC_VOLUME : UBI_STATIC_VOLUME; UBI_DYNAMIC_VOLUME : UBI_STATIC_VOLUME;
if (av->vol_type != vol_type) { if (av->vol_type != vol_type) {
ubi_err("bad vol_type"); ubi_err(ubi, "bad vol_type");
goto bad_vid_hdr; goto bad_vid_hdr;
} }
if (aeb->sqnum != be64_to_cpu(vidh->sqnum)) { if (aeb->sqnum != be64_to_cpu(vidh->sqnum)) {
ubi_err("bad sqnum %llu", aeb->sqnum); ubi_err(ubi, "bad sqnum %llu", aeb->sqnum);
goto bad_vid_hdr; goto bad_vid_hdr;
} }
if (av->vol_id != be32_to_cpu(vidh->vol_id)) { if (av->vol_id != be32_to_cpu(vidh->vol_id)) {
ubi_err("bad vol_id %d", av->vol_id); ubi_err(ubi, "bad vol_id %d", av->vol_id);
goto bad_vid_hdr; goto bad_vid_hdr;
} }
if (av->compat != vidh->compat) { if (av->compat != vidh->compat) {
ubi_err("bad compat %d", vidh->compat); ubi_err(ubi, "bad compat %d", vidh->compat);
goto bad_vid_hdr; goto bad_vid_hdr;
} }
if (aeb->lnum != be32_to_cpu(vidh->lnum)) { if (aeb->lnum != be32_to_cpu(vidh->lnum)) {
ubi_err("bad lnum %d", aeb->lnum); ubi_err(ubi, "bad lnum %d", aeb->lnum);
goto bad_vid_hdr; goto bad_vid_hdr;
} }
if (av->used_ebs != be32_to_cpu(vidh->used_ebs)) { if (av->used_ebs != be32_to_cpu(vidh->used_ebs)) {
ubi_err("bad used_ebs %d", av->used_ebs); ubi_err(ubi, "bad used_ebs %d", av->used_ebs);
goto bad_vid_hdr; goto bad_vid_hdr;
} }
if (av->data_pad != be32_to_cpu(vidh->data_pad)) { if (av->data_pad != be32_to_cpu(vidh->data_pad)) {
ubi_err("bad data_pad %d", av->data_pad); ubi_err(ubi, "bad data_pad %d", av->data_pad);
goto bad_vid_hdr; goto bad_vid_hdr;
} }
} }
...@@ -1680,12 +1685,13 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1680,12 +1685,13 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
continue; continue;
if (av->highest_lnum != be32_to_cpu(vidh->lnum)) { if (av->highest_lnum != be32_to_cpu(vidh->lnum)) {
ubi_err("bad highest_lnum %d", av->highest_lnum); ubi_err(ubi, "bad highest_lnum %d", av->highest_lnum);
goto bad_vid_hdr; goto bad_vid_hdr;
} }
if (av->last_data_size != be32_to_cpu(vidh->data_size)) { if (av->last_data_size != be32_to_cpu(vidh->data_size)) {
ubi_err("bad last_data_size %d", av->last_data_size); ubi_err(ubi, "bad last_data_size %d",
av->last_data_size);
goto bad_vid_hdr; goto bad_vid_hdr;
} }
} }
...@@ -1726,7 +1732,7 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1726,7 +1732,7 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
err = 0; err = 0;
for (pnum = 0; pnum < ubi->peb_count; pnum++) for (pnum = 0; pnum < ubi->peb_count; pnum++)
if (!buf[pnum]) { if (!buf[pnum]) {
ubi_err("PEB %d is not referred", pnum); ubi_err(ubi, "PEB %d is not referred", pnum);
err = 1; err = 1;
} }
...@@ -1736,18 +1742,18 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1736,18 +1742,18 @@ static int self_check_ai(struct ubi_device *ubi, struct ubi_attach_info *ai)
return 0; return 0;
bad_aeb: bad_aeb:
ubi_err("bad attaching information about LEB %d", aeb->lnum); ubi_err(ubi, "bad attaching information about LEB %d", aeb->lnum);
ubi_dump_aeb(aeb, 0); ubi_dump_aeb(aeb, 0);
ubi_dump_av(av); ubi_dump_av(av);
goto out; goto out;
bad_av: bad_av:
ubi_err("bad attaching information about volume %d", av->vol_id); ubi_err(ubi, "bad attaching information about volume %d", av->vol_id);
ubi_dump_av(av); ubi_dump_av(av);
goto out; goto out;
bad_vid_hdr: bad_vid_hdr:
ubi_err("bad attaching information about volume %d", av->vol_id); ubi_err(ubi, "bad attaching information about volume %d", av->vol_id);
ubi_dump_av(av); ubi_dump_av(av);
ubi_dump_vid_hdr(vidh); ubi_dump_vid_hdr(vidh);
......
...@@ -111,13 +111,13 @@ static int __init ubiblock_set_param(const char *val, ...@@ -111,13 +111,13 @@ static int __init ubiblock_set_param(const char *val,
len = strnlen(val, UBIBLOCK_PARAM_LEN); len = strnlen(val, UBIBLOCK_PARAM_LEN);
if (len == 0) { if (len == 0) {
ubi_warn("block: empty 'block=' parameter - ignored\n"); pr_warn("UBI: block: empty 'block=' parameter - ignored\n");
return 0; return 0;
} }
if (len == UBIBLOCK_PARAM_LEN) { if (len == UBIBLOCK_PARAM_LEN) {
ubi_err("block: parameter \"%s\" is too long, max. is %d\n", pr_err("UBI: block: parameter \"%s\" is too long, max. is %d\n",
val, UBIBLOCK_PARAM_LEN); val, UBIBLOCK_PARAM_LEN);
return -EINVAL; return -EINVAL;
} }
...@@ -188,9 +188,8 @@ static int ubiblock_read_to_buf(struct ubiblock *dev, char *buffer, ...@@ -188,9 +188,8 @@ static int ubiblock_read_to_buf(struct ubiblock *dev, char *buffer,
ret = ubi_read(dev->desc, leb, buffer, offset, len); ret = ubi_read(dev->desc, leb, buffer, offset, len);
if (ret) { if (ret) {
ubi_err("%s: error %d while reading from LEB %d (offset %d, " dev_err(disk_to_dev(dev->gd), "%d while reading from LEB %d (offset %d, length %d)",
"length %d)", dev->gd->disk_name, ret, leb, offset, ret, leb, offset, len);
len);
return ret; return ret;
} }
return 0; return 0;
...@@ -328,8 +327,8 @@ static int ubiblock_open(struct block_device *bdev, fmode_t mode) ...@@ -328,8 +327,8 @@ static int ubiblock_open(struct block_device *bdev, fmode_t mode)
dev->desc = ubi_open_volume(dev->ubi_num, dev->vol_id, UBI_READONLY); dev->desc = ubi_open_volume(dev->ubi_num, dev->vol_id, UBI_READONLY);
if (IS_ERR(dev->desc)) { if (IS_ERR(dev->desc)) {
ubi_err("%s failed to open ubi volume %d_%d", dev_err(disk_to_dev(dev->gd), "failed to open ubi volume %d_%d",
dev->gd->disk_name, dev->ubi_num, dev->vol_id); dev->ubi_num, dev->vol_id);
ret = PTR_ERR(dev->desc); ret = PTR_ERR(dev->desc);
dev->desc = NULL; dev->desc = NULL;
goto out_unlock; goto out_unlock;
...@@ -405,7 +404,7 @@ int ubiblock_create(struct ubi_volume_info *vi) ...@@ -405,7 +404,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
/* Initialize the gendisk of this ubiblock device */ /* Initialize the gendisk of this ubiblock device */
gd = alloc_disk(1); gd = alloc_disk(1);
if (!gd) { if (!gd) {
ubi_err("block: alloc_disk failed"); pr_err("UBI: block: alloc_disk failed");
ret = -ENODEV; ret = -ENODEV;
goto out_free_dev; goto out_free_dev;
} }
...@@ -421,7 +420,7 @@ int ubiblock_create(struct ubi_volume_info *vi) ...@@ -421,7 +420,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
spin_lock_init(&dev->queue_lock); spin_lock_init(&dev->queue_lock);
dev->rq = blk_init_queue(ubiblock_request, &dev->queue_lock); dev->rq = blk_init_queue(ubiblock_request, &dev->queue_lock);
if (!dev->rq) { if (!dev->rq) {
ubi_err("block: blk_init_queue failed"); dev_err(disk_to_dev(gd), "blk_init_queue failed");
ret = -ENODEV; ret = -ENODEV;
goto out_put_disk; goto out_put_disk;
} }
...@@ -446,8 +445,8 @@ int ubiblock_create(struct ubi_volume_info *vi) ...@@ -446,8 +445,8 @@ int ubiblock_create(struct ubi_volume_info *vi)
/* Must be the last step: anyone can call file ops from now on */ /* Must be the last step: anyone can call file ops from now on */
add_disk(dev->gd); add_disk(dev->gd);
ubi_msg("%s created from ubi%d:%d(%s)", dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)",
dev->gd->disk_name, dev->ubi_num, dev->vol_id, vi->name); dev->ubi_num, dev->vol_id, vi->name);
return 0; return 0;
out_free_queue: out_free_queue:
...@@ -464,7 +463,7 @@ static void ubiblock_cleanup(struct ubiblock *dev) ...@@ -464,7 +463,7 @@ static void ubiblock_cleanup(struct ubiblock *dev)
{ {
del_gendisk(dev->gd); del_gendisk(dev->gd);
blk_cleanup_queue(dev->rq); blk_cleanup_queue(dev->rq);
ubi_msg("%s released", dev->gd->disk_name); dev_info(disk_to_dev(dev->gd), "released");
put_disk(dev->gd); put_disk(dev->gd);
} }
...@@ -518,8 +517,8 @@ static int ubiblock_resize(struct ubi_volume_info *vi) ...@@ -518,8 +517,8 @@ static int ubiblock_resize(struct ubi_volume_info *vi)
} }
if ((sector_t)disk_capacity != disk_capacity) { if ((sector_t)disk_capacity != disk_capacity) {
mutex_unlock(&devices_mutex); mutex_unlock(&devices_mutex);
ubi_warn("%s: the volume is too big (%d LEBs), cannot resize", dev_warn(disk_to_dev(dev->gd), "the volume is too big (%d LEBs), cannot resize",
dev->gd->disk_name, vi->size); vi->size);
return -EFBIG; return -EFBIG;
} }
...@@ -527,8 +526,8 @@ static int ubiblock_resize(struct ubi_volume_info *vi) ...@@ -527,8 +526,8 @@ static int ubiblock_resize(struct ubi_volume_info *vi)
if (get_capacity(dev->gd) != disk_capacity) { if (get_capacity(dev->gd) != disk_capacity) {
set_capacity(dev->gd, disk_capacity); set_capacity(dev->gd, disk_capacity);
ubi_msg("%s resized to %lld bytes", dev->gd->disk_name, dev_info(disk_to_dev(dev->gd), "resized to %lld bytes",
vi->used_bytes); vi->used_bytes);
} }
mutex_unlock(&dev->dev_mutex); mutex_unlock(&dev->dev_mutex);
mutex_unlock(&devices_mutex); mutex_unlock(&devices_mutex);
...@@ -596,8 +595,8 @@ static int __init ubiblock_create_from_param(void) ...@@ -596,8 +595,8 @@ static int __init ubiblock_create_from_param(void)
desc = open_volume_desc(p->name, p->ubi_num, p->vol_id); desc = open_volume_desc(p->name, p->ubi_num, p->vol_id);
if (IS_ERR(desc)) { if (IS_ERR(desc)) {
ubi_err("block: can't open volume, err=%ld\n", pr_err("UBI: block: can't open volume, err=%ld\n",
PTR_ERR(desc)); PTR_ERR(desc));
ret = PTR_ERR(desc); ret = PTR_ERR(desc);
break; break;
} }
...@@ -607,8 +606,8 @@ static int __init ubiblock_create_from_param(void) ...@@ -607,8 +606,8 @@ static int __init ubiblock_create_from_param(void)
ret = ubiblock_create(&vi); ret = ubiblock_create(&vi);
if (ret) { if (ret) {
ubi_err("block: can't add '%s' volume, err=%d\n", pr_err("UBI: block: can't add '%s' volume, err=%d\n",
vi.name, ret); vi.name, ret);
break; break;
} }
} }
......
...@@ -166,7 +166,7 @@ int ubi_volume_notify(struct ubi_device *ubi, struct ubi_volume *vol, int ntype) ...@@ -166,7 +166,7 @@ int ubi_volume_notify(struct ubi_device *ubi, struct ubi_volume *vol, int ntype)
case UBI_VOLUME_RESIZED: case UBI_VOLUME_RESIZED:
case UBI_VOLUME_RENAMED: case UBI_VOLUME_RENAMED:
if (ubi_update_fastmap(ubi)) { if (ubi_update_fastmap(ubi)) {
ubi_err("Unable to update fastmap!"); ubi_err(ubi, "Unable to update fastmap!");
ubi_ro_mode(ubi); ubi_ro_mode(ubi);
} }
} }
...@@ -517,7 +517,7 @@ static int uif_init(struct ubi_device *ubi, int *ref) ...@@ -517,7 +517,7 @@ static int uif_init(struct ubi_device *ubi, int *ref)
*/ */
err = alloc_chrdev_region(&dev, 0, ubi->vtbl_slots + 1, ubi->ubi_name); err = alloc_chrdev_region(&dev, 0, ubi->vtbl_slots + 1, ubi->ubi_name);
if (err) { if (err) {
ubi_err("cannot register UBI character devices"); ubi_err(ubi, "cannot register UBI character devices");
return err; return err;
} }
...@@ -528,7 +528,7 @@ static int uif_init(struct ubi_device *ubi, int *ref) ...@@ -528,7 +528,7 @@ static int uif_init(struct ubi_device *ubi, int *ref)
err = cdev_add(&ubi->cdev, dev, 1); err = cdev_add(&ubi->cdev, dev, 1);
if (err) { if (err) {
ubi_err("cannot add character device"); ubi_err(ubi, "cannot add character device");
goto out_unreg; goto out_unreg;
} }
...@@ -540,7 +540,7 @@ static int uif_init(struct ubi_device *ubi, int *ref) ...@@ -540,7 +540,7 @@ static int uif_init(struct ubi_device *ubi, int *ref)
if (ubi->volumes[i]) { if (ubi->volumes[i]) {
err = ubi_add_volume(ubi, ubi->volumes[i]); err = ubi_add_volume(ubi, ubi->volumes[i]);
if (err) { if (err) {
ubi_err("cannot add volume %d", i); ubi_err(ubi, "cannot add volume %d", i);
goto out_volumes; goto out_volumes;
} }
} }
...@@ -556,7 +556,8 @@ static int uif_init(struct ubi_device *ubi, int *ref) ...@@ -556,7 +556,8 @@ static int uif_init(struct ubi_device *ubi, int *ref)
cdev_del(&ubi->cdev); cdev_del(&ubi->cdev);
out_unreg: out_unreg:
unregister_chrdev_region(ubi->cdev.dev, ubi->vtbl_slots + 1); unregister_chrdev_region(ubi->cdev.dev, ubi->vtbl_slots + 1);
ubi_err("cannot initialize UBI %s, error %d", ubi->ubi_name, err); ubi_err(ubi, "cannot initialize UBI %s, error %d",
ubi->ubi_name, err);
return err; return err;
} }
...@@ -650,7 +651,7 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024) ...@@ -650,7 +651,7 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024)
* guess we should just pick the largest region. But this is * guess we should just pick the largest region. But this is
* not implemented. * not implemented.
*/ */
ubi_err("multiple regions, not implemented"); ubi_err(ubi, "multiple regions, not implemented");
return -EINVAL; return -EINVAL;
} }
...@@ -685,7 +686,7 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024) ...@@ -685,7 +686,7 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024)
* which allows us to avoid costly division operations. * which allows us to avoid costly division operations.
*/ */
if (!is_power_of_2(ubi->min_io_size)) { if (!is_power_of_2(ubi->min_io_size)) {
ubi_err("min. I/O unit (%d) is not power of 2", ubi_err(ubi, "min. I/O unit (%d) is not power of 2",
ubi->min_io_size); ubi->min_io_size);
return -EINVAL; return -EINVAL;
} }
...@@ -702,7 +703,7 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024) ...@@ -702,7 +703,7 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024)
if (ubi->max_write_size < ubi->min_io_size || if (ubi->max_write_size < ubi->min_io_size ||
ubi->max_write_size % ubi->min_io_size || ubi->max_write_size % ubi->min_io_size ||
!is_power_of_2(ubi->max_write_size)) { !is_power_of_2(ubi->max_write_size)) {
ubi_err("bad write buffer size %d for %d min. I/O unit", ubi_err(ubi, "bad write buffer size %d for %d min. I/O unit",
ubi->max_write_size, ubi->min_io_size); ubi->max_write_size, ubi->min_io_size);
return -EINVAL; return -EINVAL;
} }
...@@ -739,7 +740,7 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024) ...@@ -739,7 +740,7 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024)
/* The shift must be aligned to 32-bit boundary */ /* The shift must be aligned to 32-bit boundary */
if (ubi->vid_hdr_shift % 4) { if (ubi->vid_hdr_shift % 4) {
ubi_err("unaligned VID header shift %d", ubi_err(ubi, "unaligned VID header shift %d",
ubi->vid_hdr_shift); ubi->vid_hdr_shift);
return -EINVAL; return -EINVAL;
} }
...@@ -749,7 +750,7 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024) ...@@ -749,7 +750,7 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024)
ubi->leb_start < ubi->vid_hdr_offset + UBI_VID_HDR_SIZE || ubi->leb_start < ubi->vid_hdr_offset + UBI_VID_HDR_SIZE ||
ubi->leb_start > ubi->peb_size - UBI_VID_HDR_SIZE || ubi->leb_start > ubi->peb_size - UBI_VID_HDR_SIZE ||
ubi->leb_start & (ubi->min_io_size - 1)) { ubi->leb_start & (ubi->min_io_size - 1)) {
ubi_err("bad VID header (%d) or data offsets (%d)", ubi_err(ubi, "bad VID header (%d) or data offsets (%d)",
ubi->vid_hdr_offset, ubi->leb_start); ubi->vid_hdr_offset, ubi->leb_start);
return -EINVAL; return -EINVAL;
} }
...@@ -769,14 +770,14 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024) ...@@ -769,14 +770,14 @@ static int io_init(struct ubi_device *ubi, int max_beb_per1024)
* read-only mode. * read-only mode.
*/ */
if (ubi->vid_hdr_offset + UBI_VID_HDR_SIZE <= ubi->hdrs_min_io_size) { if (ubi->vid_hdr_offset + UBI_VID_HDR_SIZE <= ubi->hdrs_min_io_size) {
ubi_warn("EC and VID headers are in the same minimal I/O unit, switch to read-only mode"); ubi_warn(ubi, "EC and VID headers are in the same minimal I/O unit, switch to read-only mode");
ubi->ro_mode = 1; ubi->ro_mode = 1;
} }
ubi->leb_size = ubi->peb_size - ubi->leb_start; ubi->leb_size = ubi->peb_size - ubi->leb_start;
if (!(ubi->mtd->flags & MTD_WRITEABLE)) { if (!(ubi->mtd->flags & MTD_WRITEABLE)) {
ubi_msg("MTD device %d is write-protected, attach in read-only mode", ubi_msg(ubi, "MTD device %d is write-protected, attach in read-only mode",
ubi->mtd->index); ubi->mtd->index);
ubi->ro_mode = 1; ubi->ro_mode = 1;
} }
...@@ -809,7 +810,7 @@ static int autoresize(struct ubi_device *ubi, int vol_id) ...@@ -809,7 +810,7 @@ static int autoresize(struct ubi_device *ubi, int vol_id)
int err, old_reserved_pebs = vol->reserved_pebs; int err, old_reserved_pebs = vol->reserved_pebs;
if (ubi->ro_mode) { if (ubi->ro_mode) {
ubi_warn("skip auto-resize because of R/O mode"); ubi_warn(ubi, "skip auto-resize because of R/O mode");
return 0; return 0;
} }
...@@ -830,21 +831,22 @@ static int autoresize(struct ubi_device *ubi, int vol_id) ...@@ -830,21 +831,22 @@ static int autoresize(struct ubi_device *ubi, int vol_id)
vtbl_rec = ubi->vtbl[vol_id]; vtbl_rec = ubi->vtbl[vol_id];
err = ubi_change_vtbl_record(ubi, vol_id, &vtbl_rec); err = ubi_change_vtbl_record(ubi, vol_id, &vtbl_rec);
if (err) if (err)
ubi_err("cannot clean auto-resize flag for volume %d", ubi_err(ubi, "cannot clean auto-resize flag for volume %d",
vol_id); vol_id);
} else { } else {
desc.vol = vol; desc.vol = vol;
err = ubi_resize_volume(&desc, err = ubi_resize_volume(&desc,
old_reserved_pebs + ubi->avail_pebs); old_reserved_pebs + ubi->avail_pebs);
if (err) if (err)
ubi_err("cannot auto-resize volume %d", vol_id); ubi_err(ubi, "cannot auto-resize volume %d",
vol_id);
} }
if (err) if (err)
return err; return err;
ubi_msg("volume %d (\"%s\") re-sized from %d to %d LEBs", vol_id, ubi_msg(ubi, "volume %d (\"%s\") re-sized from %d to %d LEBs",
vol->name, old_reserved_pebs, vol->reserved_pebs); vol_id, vol->name, old_reserved_pebs, vol->reserved_pebs);
return 0; return 0;
} }
...@@ -885,7 +887,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, ...@@ -885,7 +887,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
for (i = 0; i < UBI_MAX_DEVICES; i++) { for (i = 0; i < UBI_MAX_DEVICES; i++) {
ubi = ubi_devices[i]; ubi = ubi_devices[i];
if (ubi && mtd->index == ubi->mtd->index) { if (ubi && mtd->index == ubi->mtd->index) {
ubi_err("mtd%d is already attached to ubi%d", ubi_err(ubi, "mtd%d is already attached to ubi%d",
mtd->index, i); mtd->index, i);
return -EEXIST; return -EEXIST;
} }
...@@ -900,7 +902,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, ...@@ -900,7 +902,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
* no sense to attach emulated MTD devices, so we prohibit this. * no sense to attach emulated MTD devices, so we prohibit this.
*/ */
if (mtd->type == MTD_UBIVOLUME) { if (mtd->type == MTD_UBIVOLUME) {
ubi_err("refuse attaching mtd%d - it is already emulated on top of UBI", ubi_err(ubi, "refuse attaching mtd%d - it is already emulated on top of UBI",
mtd->index); mtd->index);
return -EINVAL; return -EINVAL;
} }
...@@ -911,7 +913,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, ...@@ -911,7 +913,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
if (!ubi_devices[ubi_num]) if (!ubi_devices[ubi_num])
break; break;
if (ubi_num == UBI_MAX_DEVICES) { if (ubi_num == UBI_MAX_DEVICES) {
ubi_err("only %d UBI devices may be created", ubi_err(ubi, "only %d UBI devices may be created",
UBI_MAX_DEVICES); UBI_MAX_DEVICES);
return -ENFILE; return -ENFILE;
} }
...@@ -921,7 +923,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, ...@@ -921,7 +923,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
/* Make sure ubi_num is not busy */ /* Make sure ubi_num is not busy */
if (ubi_devices[ubi_num]) { if (ubi_devices[ubi_num]) {
ubi_err("ubi%d already exists", ubi_num); ubi_err(ubi, "ubi%d already exists", ubi_num);
return -EEXIST; return -EEXIST;
} }
} }
...@@ -953,13 +955,14 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, ...@@ -953,13 +955,14 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
if (!ubi->fm_disabled && (int)mtd_div_by_eb(ubi->mtd->size, ubi->mtd) if (!ubi->fm_disabled && (int)mtd_div_by_eb(ubi->mtd->size, ubi->mtd)
<= UBI_FM_MAX_START) { <= UBI_FM_MAX_START) {
ubi_err("More than %i PEBs are needed for fastmap, sorry.", ubi_err(ubi, "More than %i PEBs are needed for fastmap, sorry.",
UBI_FM_MAX_START); UBI_FM_MAX_START);
ubi->fm_disabled = 1; ubi->fm_disabled = 1;
} }
ubi_msg("default fastmap pool size: %d", ubi->fm_pool.max_size); ubi_msg(ubi, "default fastmap pool size: %d", ubi->fm_pool.max_size);
ubi_msg("default fastmap WL pool size: %d", ubi->fm_wl_pool.max_size); ubi_msg(ubi, "default fastmap WL pool size: %d",
ubi->fm_wl_pool.max_size);
#else #else
ubi->fm_disabled = 1; ubi->fm_disabled = 1;
#endif #endif
...@@ -970,7 +973,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, ...@@ -970,7 +973,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
mutex_init(&ubi->fm_mutex); mutex_init(&ubi->fm_mutex);
init_rwsem(&ubi->fm_sem); init_rwsem(&ubi->fm_sem);
ubi_msg("attaching mtd%d to ubi%d", mtd->index, ubi_num); ubi_msg(ubi, "attaching mtd%d to ubi%d", mtd->index, ubi_num);
err = io_init(ubi, max_beb_per1024); err = io_init(ubi, max_beb_per1024);
if (err) if (err)
...@@ -989,7 +992,8 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, ...@@ -989,7 +992,8 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
#endif #endif
err = ubi_attach(ubi, 0); err = ubi_attach(ubi, 0);
if (err) { if (err) {
ubi_err("failed to attach mtd%d, error %d", mtd->index, err); ubi_err(ubi, "failed to attach mtd%d, error %d",
mtd->index, err);
goto out_free; goto out_free;
} }
...@@ -1010,28 +1014,28 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, ...@@ -1010,28 +1014,28 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
ubi->bgt_thread = kthread_create(ubi_thread, ubi, "%s", ubi->bgt_name); ubi->bgt_thread = kthread_create(ubi_thread, ubi, "%s", ubi->bgt_name);
if (IS_ERR(ubi->bgt_thread)) { if (IS_ERR(ubi->bgt_thread)) {
err = PTR_ERR(ubi->bgt_thread); err = PTR_ERR(ubi->bgt_thread);
ubi_err("cannot spawn \"%s\", error %d", ubi->bgt_name, ubi_err(ubi, "cannot spawn \"%s\", error %d",
err); ubi->bgt_name, err);
goto out_debugfs; goto out_debugfs;
} }
ubi_msg("attached mtd%d (name \"%s\", size %llu MiB) to ubi%d", ubi_msg(ubi, "attached mtd%d (name \"%s\", size %llu MiB)",
mtd->index, mtd->name, ubi->flash_size >> 20, ubi_num); mtd->index, mtd->name, ubi->flash_size >> 20);
ubi_msg("PEB size: %d bytes (%d KiB), LEB size: %d bytes", ubi_msg(ubi, "PEB size: %d bytes (%d KiB), LEB size: %d bytes",
ubi->peb_size, ubi->peb_size >> 10, ubi->leb_size); ubi->peb_size, ubi->peb_size >> 10, ubi->leb_size);
ubi_msg("min./max. I/O unit sizes: %d/%d, sub-page size %d", ubi_msg(ubi, "min./max. I/O unit sizes: %d/%d, sub-page size %d",
ubi->min_io_size, ubi->max_write_size, ubi->hdrs_min_io_size); ubi->min_io_size, ubi->max_write_size, ubi->hdrs_min_io_size);
ubi_msg("VID header offset: %d (aligned %d), data offset: %d", ubi_msg(ubi, "VID header offset: %d (aligned %d), data offset: %d",
ubi->vid_hdr_offset, ubi->vid_hdr_aloffset, ubi->leb_start); ubi->vid_hdr_offset, ubi->vid_hdr_aloffset, ubi->leb_start);
ubi_msg("good PEBs: %d, bad PEBs: %d, corrupted PEBs: %d", ubi_msg(ubi, "good PEBs: %d, bad PEBs: %d, corrupted PEBs: %d",
ubi->good_peb_count, ubi->bad_peb_count, ubi->corr_peb_count); ubi->good_peb_count, ubi->bad_peb_count, ubi->corr_peb_count);
ubi_msg("user volume: %d, internal volumes: %d, max. volumes count: %d", ubi_msg(ubi, "user volume: %d, internal volumes: %d, max. volumes count: %d",
ubi->vol_count - UBI_INT_VOL_COUNT, UBI_INT_VOL_COUNT, ubi->vol_count - UBI_INT_VOL_COUNT, UBI_INT_VOL_COUNT,
ubi->vtbl_slots); ubi->vtbl_slots);
ubi_msg("max/mean erase counter: %d/%d, WL threshold: %d, image sequence number: %u", ubi_msg(ubi, "max/mean erase counter: %d/%d, WL threshold: %d, image sequence number: %u",
ubi->max_ec, ubi->mean_ec, CONFIG_MTD_UBI_WL_THRESHOLD, ubi->max_ec, ubi->mean_ec, CONFIG_MTD_UBI_WL_THRESHOLD,
ubi->image_seq); ubi->image_seq);
ubi_msg("available PEBs: %d, total reserved PEBs: %d, PEBs reserved for bad PEB handling: %d", ubi_msg(ubi, "available PEBs: %d, total reserved PEBs: %d, PEBs reserved for bad PEB handling: %d",
ubi->avail_pebs, ubi->rsvd_pebs, ubi->beb_rsvd_pebs); ubi->avail_pebs, ubi->rsvd_pebs, ubi->beb_rsvd_pebs);
/* /*
...@@ -1100,7 +1104,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) ...@@ -1100,7 +1104,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
return -EBUSY; return -EBUSY;
} }
/* This may only happen if there is a bug */ /* This may only happen if there is a bug */
ubi_err("%s reference count %d, destroy anyway", ubi_err(ubi, "%s reference count %d, destroy anyway",
ubi->ubi_name, ubi->ref_count); ubi->ubi_name, ubi->ref_count);
} }
ubi_devices[ubi_num] = NULL; ubi_devices[ubi_num] = NULL;
...@@ -1108,7 +1112,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) ...@@ -1108,7 +1112,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
ubi_assert(ubi_num == ubi->ubi_num); ubi_assert(ubi_num == ubi->ubi_num);
ubi_notify_all(ubi, UBI_VOLUME_REMOVED, NULL); ubi_notify_all(ubi, UBI_VOLUME_REMOVED, NULL);
ubi_msg("detaching mtd%d from ubi%d", ubi->mtd->index, ubi_num); ubi_msg(ubi, "detaching mtd%d", ubi->mtd->index);
#ifdef CONFIG_MTD_UBI_FASTMAP #ifdef CONFIG_MTD_UBI_FASTMAP
/* If we don't write a new fastmap at detach time we lose all /* If we don't write a new fastmap at detach time we lose all
* EC updates that have been made since the last written fastmap. */ * EC updates that have been made since the last written fastmap. */
...@@ -1136,7 +1140,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway) ...@@ -1136,7 +1140,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
put_mtd_device(ubi->mtd); put_mtd_device(ubi->mtd);
vfree(ubi->peb_buf); vfree(ubi->peb_buf);
vfree(ubi->fm_buf); vfree(ubi->fm_buf);
ubi_msg("mtd%d is detached from ubi%d", ubi->mtd->index, ubi->ubi_num); ubi_msg(ubi, "mtd%d is detached", ubi->mtd->index);
put_device(&ubi->dev); put_device(&ubi->dev);
return 0; return 0;
} }
...@@ -1218,7 +1222,8 @@ static int __init ubi_init(void) ...@@ -1218,7 +1222,8 @@ static int __init ubi_init(void)
BUILD_BUG_ON(sizeof(struct ubi_vid_hdr) != 64); BUILD_BUG_ON(sizeof(struct ubi_vid_hdr) != 64);
if (mtd_devs > UBI_MAX_DEVICES) { if (mtd_devs > UBI_MAX_DEVICES) {
ubi_err("too many MTD devices, maximum is %d", UBI_MAX_DEVICES); pr_err("UBI error: too many MTD devices, maximum is %d",
UBI_MAX_DEVICES);
return -EINVAL; return -EINVAL;
} }
...@@ -1226,19 +1231,19 @@ static int __init ubi_init(void) ...@@ -1226,19 +1231,19 @@ static int __init ubi_init(void)
ubi_class = class_create(THIS_MODULE, UBI_NAME_STR); ubi_class = class_create(THIS_MODULE, UBI_NAME_STR);
if (IS_ERR(ubi_class)) { if (IS_ERR(ubi_class)) {
err = PTR_ERR(ubi_class); err = PTR_ERR(ubi_class);
ubi_err("cannot create UBI class"); pr_err("UBI error: cannot create UBI class");
goto out; goto out;
} }
err = class_create_file(ubi_class, &ubi_version); err = class_create_file(ubi_class, &ubi_version);
if (err) { if (err) {
ubi_err("cannot create sysfs file"); pr_err("UBI error: cannot create sysfs file");
goto out_class; goto out_class;
} }
err = misc_register(&ubi_ctrl_cdev); err = misc_register(&ubi_ctrl_cdev);
if (err) { if (err) {
ubi_err("cannot register device"); pr_err("UBI error: cannot register device");
goto out_version; goto out_version;
} }
...@@ -1265,7 +1270,8 @@ static int __init ubi_init(void) ...@@ -1265,7 +1270,8 @@ static int __init ubi_init(void)
mtd = open_mtd_device(p->name); mtd = open_mtd_device(p->name);
if (IS_ERR(mtd)) { if (IS_ERR(mtd)) {
err = PTR_ERR(mtd); err = PTR_ERR(mtd);
ubi_err("cannot open mtd %s, error %d", p->name, err); pr_err("UBI error: cannot open mtd %s, error %d",
p->name, err);
/* See comment below re-ubi_is_module(). */ /* See comment below re-ubi_is_module(). */
if (ubi_is_module()) if (ubi_is_module())
goto out_detach; goto out_detach;
...@@ -1277,7 +1283,8 @@ static int __init ubi_init(void) ...@@ -1277,7 +1283,8 @@ static int __init ubi_init(void)
p->vid_hdr_offs, p->max_beb_per1024); p->vid_hdr_offs, p->max_beb_per1024);
mutex_unlock(&ubi_devices_mutex); mutex_unlock(&ubi_devices_mutex);
if (err < 0) { if (err < 0) {
ubi_err("cannot attach mtd%d", mtd->index); pr_err("UBI error: cannot attach mtd%d",
mtd->index);
put_mtd_device(mtd); put_mtd_device(mtd);
/* /*
...@@ -1300,7 +1307,7 @@ static int __init ubi_init(void) ...@@ -1300,7 +1307,7 @@ static int __init ubi_init(void)
err = ubiblock_init(); err = ubiblock_init();
if (err) { if (err) {
ubi_err("block: cannot initialize, error %d", err); pr_err("UBI error: block: cannot initialize, error %d", err);
/* See comment above re-ubi_is_module(). */ /* See comment above re-ubi_is_module(). */
if (ubi_is_module()) if (ubi_is_module())
...@@ -1326,7 +1333,7 @@ static int __init ubi_init(void) ...@@ -1326,7 +1333,7 @@ static int __init ubi_init(void)
out_class: out_class:
class_destroy(ubi_class); class_destroy(ubi_class);
out: out:
ubi_err("cannot initialize UBI, error %d", err); pr_err("UBI error: cannot initialize UBI, error %d", err);
return err; return err;
} }
late_initcall(ubi_init); late_initcall(ubi_init);
...@@ -1365,7 +1372,7 @@ static int __init bytes_str_to_int(const char *str) ...@@ -1365,7 +1372,7 @@ static int __init bytes_str_to_int(const char *str)
result = simple_strtoul(str, &endp, 0); result = simple_strtoul(str, &endp, 0);
if (str == endp || result >= INT_MAX) { if (str == endp || result >= INT_MAX) {
ubi_err("incorrect bytes count: \"%s\"\n", str); pr_err("UBI error: incorrect bytes count: \"%s\"\n", str);
return -EINVAL; return -EINVAL;
} }
...@@ -1381,7 +1388,7 @@ static int __init bytes_str_to_int(const char *str) ...@@ -1381,7 +1388,7 @@ static int __init bytes_str_to_int(const char *str)
case '\0': case '\0':
break; break;
default: default:
ubi_err("incorrect bytes count: \"%s\"\n", str); pr_err("UBI error: incorrect bytes count: \"%s\"\n", str);
return -EINVAL; return -EINVAL;
} }
...@@ -1408,20 +1415,20 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp) ...@@ -1408,20 +1415,20 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
return -EINVAL; return -EINVAL;
if (mtd_devs == UBI_MAX_DEVICES) { if (mtd_devs == UBI_MAX_DEVICES) {
ubi_err("too many parameters, max. is %d\n", pr_err("UBI error: too many parameters, max. is %d\n",
UBI_MAX_DEVICES); UBI_MAX_DEVICES);
return -EINVAL; return -EINVAL;
} }
len = strnlen(val, MTD_PARAM_LEN_MAX); len = strnlen(val, MTD_PARAM_LEN_MAX);
if (len == MTD_PARAM_LEN_MAX) { if (len == MTD_PARAM_LEN_MAX) {
ubi_err("parameter \"%s\" is too long, max. is %d\n", pr_err("UBI error: parameter \"%s\" is too long, max. is %d\n",
val, MTD_PARAM_LEN_MAX); val, MTD_PARAM_LEN_MAX);
return -EINVAL; return -EINVAL;
} }
if (len == 0) { if (len == 0) {
pr_warn("UBI warning: empty 'mtd=' parameter - ignored\n"); pr_err("UBI warning: empty 'mtd=' parameter - ignored\n");
return 0; return 0;
} }
...@@ -1435,7 +1442,7 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp) ...@@ -1435,7 +1442,7 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
tokens[i] = strsep(&pbuf, ","); tokens[i] = strsep(&pbuf, ",");
if (pbuf) { if (pbuf) {
ubi_err("too many arguments at \"%s\"\n", val); pr_err("UBI error: too many arguments at \"%s\"\n", val);
return -EINVAL; return -EINVAL;
} }
...@@ -1455,8 +1462,8 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp) ...@@ -1455,8 +1462,8 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
int err = kstrtoint(token, 10, &p->max_beb_per1024); int err = kstrtoint(token, 10, &p->max_beb_per1024);
if (err) { if (err) {
ubi_err("bad value for max_beb_per1024 parameter: %s", pr_err("UBI error: bad value for max_beb_per1024 parameter: %s",
token); token);
return -EINVAL; return -EINVAL;
} }
} }
...@@ -1466,7 +1473,8 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp) ...@@ -1466,7 +1473,8 @@ static int __init ubi_mtd_param_parse(const char *val, struct kernel_param *kp)
int err = kstrtoint(token, 10, &p->ubi_num); int err = kstrtoint(token, 10, &p->ubi_num);
if (err) { if (err) {
ubi_err("bad value for ubi_num parameter: %s", token); pr_err("UBI error: bad value for ubi_num parameter: %s",
token);
return -EINVAL; return -EINVAL;
} }
} else } else
......
...@@ -48,13 +48,14 @@ ...@@ -48,13 +48,14 @@
/** /**
* get_exclusive - get exclusive access to an UBI volume. * get_exclusive - get exclusive access to an UBI volume.
* @ubi: UBI device description object
* @desc: volume descriptor * @desc: volume descriptor
* *
* This function changes UBI volume open mode to "exclusive". Returns previous * This function changes UBI volume open mode to "exclusive". Returns previous
* mode value (positive integer) in case of success and a negative error code * mode value (positive integer) in case of success and a negative error code
* in case of failure. * in case of failure.
*/ */
static int get_exclusive(struct ubi_volume_desc *desc) static int get_exclusive(struct ubi_device *ubi, struct ubi_volume_desc *desc)
{ {
int users, err; int users, err;
struct ubi_volume *vol = desc->vol; struct ubi_volume *vol = desc->vol;
...@@ -63,7 +64,7 @@ static int get_exclusive(struct ubi_volume_desc *desc) ...@@ -63,7 +64,7 @@ static int get_exclusive(struct ubi_volume_desc *desc)
users = vol->readers + vol->writers + vol->exclusive; users = vol->readers + vol->writers + vol->exclusive;
ubi_assert(users > 0); ubi_assert(users > 0);
if (users > 1) { if (users > 1) {
ubi_err("%d users for volume %d", users, vol->vol_id); ubi_err(ubi, "%d users for volume %d", users, vol->vol_id);
err = -EBUSY; err = -EBUSY;
} else { } else {
vol->readers = vol->writers = 0; vol->readers = vol->writers = 0;
...@@ -134,7 +135,7 @@ static int vol_cdev_release(struct inode *inode, struct file *file) ...@@ -134,7 +135,7 @@ static int vol_cdev_release(struct inode *inode, struct file *file)
vol->ubi->ubi_num, vol->vol_id, desc->mode); vol->ubi->ubi_num, vol->vol_id, desc->mode);
if (vol->updating) { if (vol->updating) {
ubi_warn("update of volume %d not finished, volume is damaged", ubi_warn(vol->ubi, "update of volume %d not finished, volume is damaged",
vol->vol_id); vol->vol_id);
ubi_assert(!vol->changing_leb); ubi_assert(!vol->changing_leb);
vol->updating = 0; vol->updating = 0;
...@@ -158,7 +159,7 @@ static loff_t vol_cdev_llseek(struct file *file, loff_t offset, int origin) ...@@ -158,7 +159,7 @@ static loff_t vol_cdev_llseek(struct file *file, loff_t offset, int origin)
if (vol->updating) { if (vol->updating) {
/* Update is in progress, seeking is prohibited */ /* Update is in progress, seeking is prohibited */
ubi_err("updating"); ubi_err(vol->ubi, "updating");
return -EBUSY; return -EBUSY;
} }
...@@ -193,11 +194,11 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count, ...@@ -193,11 +194,11 @@ static ssize_t vol_cdev_read(struct file *file, __user char *buf, size_t count,
count, *offp, vol->vol_id); count, *offp, vol->vol_id);
if (vol->updating) { if (vol->updating) {
ubi_err("updating"); ubi_err(vol->ubi, "updating");
return -EBUSY; return -EBUSY;
} }
if (vol->upd_marker) { if (vol->upd_marker) {
ubi_err("damaged volume, update marker is set"); ubi_err(vol->ubi, "damaged volume, update marker is set");
return -EBADF; return -EBADF;
} }
if (*offp == vol->used_bytes || count == 0) if (*offp == vol->used_bytes || count == 0)
...@@ -277,7 +278,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, ...@@ -277,7 +278,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
lnum = div_u64_rem(*offp, vol->usable_leb_size, &off); lnum = div_u64_rem(*offp, vol->usable_leb_size, &off);
if (off & (ubi->min_io_size - 1)) { if (off & (ubi->min_io_size - 1)) {
ubi_err("unaligned position"); ubi_err(ubi, "unaligned position");
return -EINVAL; return -EINVAL;
} }
...@@ -286,7 +287,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, ...@@ -286,7 +287,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
/* We can write only in fractions of the minimum I/O unit */ /* We can write only in fractions of the minimum I/O unit */
if (count & (ubi->min_io_size - 1)) { if (count & (ubi->min_io_size - 1)) {
ubi_err("unaligned write length"); ubi_err(ubi, "unaligned write length");
return -EINVAL; return -EINVAL;
} }
...@@ -348,7 +349,7 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf, ...@@ -348,7 +349,7 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf,
err = ubi_more_leb_change_data(ubi, vol, buf, count); err = ubi_more_leb_change_data(ubi, vol, buf, count);
if (err < 0) { if (err < 0) {
ubi_err("cannot accept more %zd bytes of data, error %d", ubi_err(ubi, "cannot accept more %zd bytes of data, error %d",
count, err); count, err);
return err; return err;
} }
...@@ -370,7 +371,7 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf, ...@@ -370,7 +371,7 @@ static ssize_t vol_cdev_write(struct file *file, const char __user *buf,
return err; return err;
if (err) { if (err) {
ubi_warn("volume %d on UBI device %d is corrupted", ubi_warn(ubi, "volume %d on UBI device %d is corrupted",
vol->vol_id, ubi->ubi_num); vol->vol_id, ubi->ubi_num);
vol->corrupted = 1; vol->corrupted = 1;
} }
...@@ -420,7 +421,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd, ...@@ -420,7 +421,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
break; break;
} }
err = get_exclusive(desc); err = get_exclusive(ubi, desc);
if (err < 0) if (err < 0)
break; break;
...@@ -456,7 +457,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd, ...@@ -456,7 +457,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
req.bytes < 0 || req.lnum >= vol->usable_leb_size) req.bytes < 0 || req.lnum >= vol->usable_leb_size)
break; break;
err = get_exclusive(desc); err = get_exclusive(ubi, desc);
if (err < 0) if (err < 0)
break; break;
...@@ -642,7 +643,7 @@ static int verify_mkvol_req(const struct ubi_device *ubi, ...@@ -642,7 +643,7 @@ static int verify_mkvol_req(const struct ubi_device *ubi,
return 0; return 0;
bad: bad:
ubi_err("bad volume creation request"); ubi_err(ubi, "bad volume creation request");
ubi_dump_mkvol_req(req); ubi_dump_mkvol_req(req);
return err; return err;
} }
...@@ -708,12 +709,12 @@ static int rename_volumes(struct ubi_device *ubi, ...@@ -708,12 +709,12 @@ static int rename_volumes(struct ubi_device *ubi,
for (i = 0; i < req->count - 1; i++) { for (i = 0; i < req->count - 1; i++) {
for (n = i + 1; n < req->count; n++) { for (n = i + 1; n < req->count; n++) {
if (req->ents[i].vol_id == req->ents[n].vol_id) { if (req->ents[i].vol_id == req->ents[n].vol_id) {
ubi_err("duplicated volume id %d", ubi_err(ubi, "duplicated volume id %d",
req->ents[i].vol_id); req->ents[i].vol_id);
return -EINVAL; return -EINVAL;
} }
if (!strcmp(req->ents[i].name, req->ents[n].name)) { if (!strcmp(req->ents[i].name, req->ents[n].name)) {
ubi_err("duplicated volume name \"%s\"", ubi_err(ubi, "duplicated volume name \"%s\"",
req->ents[i].name); req->ents[i].name);
return -EINVAL; return -EINVAL;
} }
...@@ -736,7 +737,8 @@ static int rename_volumes(struct ubi_device *ubi, ...@@ -736,7 +737,8 @@ static int rename_volumes(struct ubi_device *ubi,
re->desc = ubi_open_volume(ubi->ubi_num, vol_id, UBI_READWRITE); re->desc = ubi_open_volume(ubi->ubi_num, vol_id, UBI_READWRITE);
if (IS_ERR(re->desc)) { if (IS_ERR(re->desc)) {
err = PTR_ERR(re->desc); err = PTR_ERR(re->desc);
ubi_err("cannot open volume %d, error %d", vol_id, err); ubi_err(ubi, "cannot open volume %d, error %d",
vol_id, err);
kfree(re); kfree(re);
goto out_free; goto out_free;
} }
...@@ -795,7 +797,7 @@ static int rename_volumes(struct ubi_device *ubi, ...@@ -795,7 +797,7 @@ static int rename_volumes(struct ubi_device *ubi,
continue; continue;
/* The volume exists but busy, or an error occurred */ /* The volume exists but busy, or an error occurred */
ubi_err("cannot open volume \"%s\", error %d", ubi_err(ubi, "cannot open volume \"%s\", error %d",
re->new_name, err); re->new_name, err);
goto out_free; goto out_free;
} }
......
...@@ -43,12 +43,12 @@ void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len) ...@@ -43,12 +43,12 @@ void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len)
return; return;
err = mtd_read(ubi->mtd, addr, len, &read, buf); err = mtd_read(ubi->mtd, addr, len, &read, buf);
if (err && err != -EUCLEAN) { if (err && err != -EUCLEAN) {
ubi_err("error %d while reading %d bytes from PEB %d:%d, read %zd bytes", ubi_err(ubi, "err %d while reading %d bytes from PEB %d:%d, read %zd bytes",
err, len, pnum, offset, read); err, len, pnum, offset, read);
goto out; goto out;
} }
ubi_msg("dumping %d bytes of data from PEB %d, offset %d", ubi_msg(ubi, "dumping %d bytes of data from PEB %d, offset %d",
len, pnum, offset); len, pnum, offset);
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1); print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1);
out: out:
...@@ -238,8 +238,8 @@ int ubi_debugfs_init(void) ...@@ -238,8 +238,8 @@ int ubi_debugfs_init(void)
if (IS_ERR_OR_NULL(dfs_rootdir)) { if (IS_ERR_OR_NULL(dfs_rootdir)) {
int err = dfs_rootdir ? -ENODEV : PTR_ERR(dfs_rootdir); int err = dfs_rootdir ? -ENODEV : PTR_ERR(dfs_rootdir);
ubi_err("cannot create \"ubi\" debugfs directory, error %d\n", pr_err("UBI error: cannot create \"ubi\" debugfs directory, error %d\n",
err); err);
return err; return err;
} }
...@@ -433,7 +433,7 @@ int ubi_debugfs_init_dev(struct ubi_device *ubi) ...@@ -433,7 +433,7 @@ int ubi_debugfs_init_dev(struct ubi_device *ubi)
debugfs_remove_recursive(d->dfs_dir); debugfs_remove_recursive(d->dfs_dir);
out: out:
err = dent ? PTR_ERR(dent) : -ENODEV; err = dent ? PTR_ERR(dent) : -ENODEV;
ubi_err("cannot create \"%s\" debugfs file or directory, error %d\n", ubi_err(ubi, "cannot create \"%s\" debugfs file or directory, error %d\n",
fname, err); fname, err);
return err; return err;
} }
......
...@@ -422,7 +422,7 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, ...@@ -422,7 +422,7 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
*/ */
if (err == UBI_IO_BAD_HDR_EBADMSG || if (err == UBI_IO_BAD_HDR_EBADMSG ||
err == UBI_IO_BAD_HDR) { err == UBI_IO_BAD_HDR) {
ubi_warn("corrupted VID header at PEB %d, LEB %d:%d", ubi_warn(ubi, "corrupted VID header at PEB %d, LEB %d:%d",
pnum, vol_id, lnum); pnum, vol_id, lnum);
err = -EBADMSG; err = -EBADMSG;
} else } else
...@@ -448,7 +448,7 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, ...@@ -448,7 +448,7 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
goto out_unlock; goto out_unlock;
scrub = 1; scrub = 1;
if (!check) { if (!check) {
ubi_msg("force data checking"); ubi_msg(ubi, "force data checking");
check = 1; check = 1;
goto retry; goto retry;
} }
...@@ -459,7 +459,7 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, ...@@ -459,7 +459,7 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
if (check) { if (check) {
uint32_t crc1 = crc32(UBI_CRC32_INIT, buf, len); uint32_t crc1 = crc32(UBI_CRC32_INIT, buf, len);
if (crc1 != crc) { if (crc1 != crc) {
ubi_warn("CRC error: calculated %#08x, must be %#08x", ubi_warn(ubi, "CRC error: calculated %#08x, must be %#08x",
crc1, crc); crc1, crc);
err = -EBADMSG; err = -EBADMSG;
goto out_unlock; goto out_unlock;
...@@ -513,7 +513,8 @@ static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum, ...@@ -513,7 +513,8 @@ static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum,
return new_pnum; return new_pnum;
} }
ubi_msg("recover PEB %d, move data to PEB %d", pnum, new_pnum); ubi_msg(ubi, "recover PEB %d, move data to PEB %d",
pnum, new_pnum);
err = ubi_io_read_vid_hdr(ubi, pnum, vid_hdr, 1); err = ubi_io_read_vid_hdr(ubi, pnum, vid_hdr, 1);
if (err && err != UBI_IO_BITFLIPS) { if (err && err != UBI_IO_BITFLIPS) {
...@@ -554,7 +555,7 @@ static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum, ...@@ -554,7 +555,7 @@ static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum,
up_read(&ubi->fm_sem); up_read(&ubi->fm_sem);
ubi_wl_put_peb(ubi, vol_id, lnum, pnum, 1); ubi_wl_put_peb(ubi, vol_id, lnum, pnum, 1);
ubi_msg("data was successfully recovered"); ubi_msg(ubi, "data was successfully recovered");
return 0; return 0;
out_unlock: out_unlock:
...@@ -569,13 +570,13 @@ static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum, ...@@ -569,13 +570,13 @@ static int recover_peb(struct ubi_device *ubi, int pnum, int vol_id, int lnum,
* Bad luck? This physical eraseblock is bad too? Crud. Let's try to * Bad luck? This physical eraseblock is bad too? Crud. Let's try to
* get another one. * get another one.
*/ */
ubi_warn("failed to write to PEB %d", new_pnum); ubi_warn(ubi, "failed to write to PEB %d", new_pnum);
ubi_wl_put_peb(ubi, vol_id, lnum, new_pnum, 1); ubi_wl_put_peb(ubi, vol_id, lnum, new_pnum, 1);
if (++tries > UBI_IO_RETRIES) { if (++tries > UBI_IO_RETRIES) {
ubi_free_vid_hdr(ubi, vid_hdr); ubi_free_vid_hdr(ubi, vid_hdr);
return err; return err;
} }
ubi_msg("try again"); ubi_msg(ubi, "try again");
goto retry; goto retry;
} }
...@@ -613,7 +614,7 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, ...@@ -613,7 +614,7 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
err = ubi_io_write_data(ubi, buf, pnum, offset, len); err = ubi_io_write_data(ubi, buf, pnum, offset, len);
if (err) { if (err) {
ubi_warn("failed to write data to PEB %d", pnum); ubi_warn(ubi, "failed to write data to PEB %d", pnum);
if (err == -EIO && ubi->bad_allowed) if (err == -EIO && ubi->bad_allowed)
err = recover_peb(ubi, pnum, vol_id, lnum, buf, err = recover_peb(ubi, pnum, vol_id, lnum, buf,
offset, len); offset, len);
...@@ -654,7 +655,7 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, ...@@ -654,7 +655,7 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr); err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr);
if (err) { if (err) {
ubi_warn("failed to write VID header to LEB %d:%d, PEB %d", ubi_warn(ubi, "failed to write VID header to LEB %d:%d, PEB %d",
vol_id, lnum, pnum); vol_id, lnum, pnum);
goto write_error; goto write_error;
} }
...@@ -662,7 +663,7 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, ...@@ -662,7 +663,7 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
if (len) { if (len) {
err = ubi_io_write_data(ubi, buf, pnum, offset, len); err = ubi_io_write_data(ubi, buf, pnum, offset, len);
if (err) { if (err) {
ubi_warn("failed to write %d bytes at offset %d of LEB %d:%d, PEB %d", ubi_warn(ubi, "failed to write %d bytes at offset %d of LEB %d:%d, PEB %d",
len, offset, vol_id, lnum, pnum); len, offset, vol_id, lnum, pnum);
goto write_error; goto write_error;
} }
...@@ -698,7 +699,7 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum, ...@@ -698,7 +699,7 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
} }
vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi));
ubi_msg("try another PEB"); ubi_msg(ubi, "try another PEB");
goto retry; goto retry;
} }
...@@ -775,14 +776,14 @@ int ubi_eba_write_leb_st(struct ubi_device *ubi, struct ubi_volume *vol, ...@@ -775,14 +776,14 @@ int ubi_eba_write_leb_st(struct ubi_device *ubi, struct ubi_volume *vol,
err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr); err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr);
if (err) { if (err) {
ubi_warn("failed to write VID header to LEB %d:%d, PEB %d", ubi_warn(ubi, "failed to write VID header to LEB %d:%d, PEB %d",
vol_id, lnum, pnum); vol_id, lnum, pnum);
goto write_error; goto write_error;
} }
err = ubi_io_write_data(ubi, buf, pnum, 0, len); err = ubi_io_write_data(ubi, buf, pnum, 0, len);
if (err) { if (err) {
ubi_warn("failed to write %d bytes of data to PEB %d", ubi_warn(ubi, "failed to write %d bytes of data to PEB %d",
len, pnum); len, pnum);
goto write_error; goto write_error;
} }
...@@ -818,7 +819,7 @@ int ubi_eba_write_leb_st(struct ubi_device *ubi, struct ubi_volume *vol, ...@@ -818,7 +819,7 @@ int ubi_eba_write_leb_st(struct ubi_device *ubi, struct ubi_volume *vol,
} }
vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi));
ubi_msg("try another PEB"); ubi_msg(ubi, "try another PEB");
goto retry; goto retry;
} }
...@@ -893,14 +894,14 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, ...@@ -893,14 +894,14 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr); err = ubi_io_write_vid_hdr(ubi, pnum, vid_hdr);
if (err) { if (err) {
ubi_warn("failed to write VID header to LEB %d:%d, PEB %d", ubi_warn(ubi, "failed to write VID header to LEB %d:%d, PEB %d",
vol_id, lnum, pnum); vol_id, lnum, pnum);
goto write_error; goto write_error;
} }
err = ubi_io_write_data(ubi, buf, pnum, 0, len); err = ubi_io_write_data(ubi, buf, pnum, 0, len);
if (err) { if (err) {
ubi_warn("failed to write %d bytes of data to PEB %d", ubi_warn(ubi, "failed to write %d bytes of data to PEB %d",
len, pnum); len, pnum);
goto write_error; goto write_error;
} }
...@@ -940,7 +941,7 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, ...@@ -940,7 +941,7 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
} }
vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi)); vid_hdr->sqnum = cpu_to_be64(ubi_next_sqnum(ubi));
ubi_msg("try another PEB"); ubi_msg(ubi, "try another PEB");
goto retry; goto retry;
} }
...@@ -1063,7 +1064,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, ...@@ -1063,7 +1064,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
dbg_wl("read %d bytes of data", aldata_size); dbg_wl("read %d bytes of data", aldata_size);
err = ubi_io_read_data(ubi, ubi->peb_buf, from, 0, aldata_size); err = ubi_io_read_data(ubi, ubi->peb_buf, from, 0, aldata_size);
if (err && err != UBI_IO_BITFLIPS) { if (err && err != UBI_IO_BITFLIPS) {
ubi_warn("error %d while reading data from PEB %d", ubi_warn(ubi, "error %d while reading data from PEB %d",
err, from); err, from);
err = MOVE_SOURCE_RD_ERR; err = MOVE_SOURCE_RD_ERR;
goto out_unlock_buf; goto out_unlock_buf;
...@@ -1113,7 +1114,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, ...@@ -1113,7 +1114,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
err = ubi_io_read_vid_hdr(ubi, to, vid_hdr, 1); err = ubi_io_read_vid_hdr(ubi, to, vid_hdr, 1);
if (err) { if (err) {
if (err != UBI_IO_BITFLIPS) { if (err != UBI_IO_BITFLIPS) {
ubi_warn("error %d while reading VID header back from PEB %d", ubi_warn(ubi, "error %d while reading VID header back from PEB %d",
err, to); err, to);
if (is_error_sane(err)) if (is_error_sane(err))
err = MOVE_TARGET_RD_ERR; err = MOVE_TARGET_RD_ERR;
...@@ -1140,7 +1141,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, ...@@ -1140,7 +1141,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
err = ubi_io_read_data(ubi, ubi->peb_buf, to, 0, aldata_size); err = ubi_io_read_data(ubi, ubi->peb_buf, to, 0, aldata_size);
if (err) { if (err) {
if (err != UBI_IO_BITFLIPS) { if (err != UBI_IO_BITFLIPS) {
ubi_warn("error %d while reading data back from PEB %d", ubi_warn(ubi, "error %d while reading data back from PEB %d",
err, to); err, to);
if (is_error_sane(err)) if (is_error_sane(err))
err = MOVE_TARGET_RD_ERR; err = MOVE_TARGET_RD_ERR;
...@@ -1152,7 +1153,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to, ...@@ -1152,7 +1153,7 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
cond_resched(); cond_resched();
if (crc != crc32(UBI_CRC32_INIT, ubi->peb_buf, data_size)) { if (crc != crc32(UBI_CRC32_INIT, ubi->peb_buf, data_size)) {
ubi_warn("read data back from PEB %d and it is different", ubi_warn(ubi, "read data back from PEB %d and it is different",
to); to);
err = -EINVAL; err = -EINVAL;
goto out_unlock_buf; goto out_unlock_buf;
...@@ -1205,10 +1206,10 @@ static void print_rsvd_warning(struct ubi_device *ubi, ...@@ -1205,10 +1206,10 @@ static void print_rsvd_warning(struct ubi_device *ubi,
return; return;
} }
ubi_warn("cannot reserve enough PEBs for bad PEB handling, reserved %d, need %d", ubi_warn(ubi, "cannot reserve enough PEBs for bad PEB handling, reserved %d, need %d",
ubi->beb_rsvd_pebs, ubi->beb_rsvd_level); ubi->beb_rsvd_pebs, ubi->beb_rsvd_level);
if (ubi->corr_peb_count) if (ubi->corr_peb_count)
ubi_warn("%d PEBs are corrupted and not used", ubi_warn(ubi, "%d PEBs are corrupted and not used",
ubi->corr_peb_count); ubi->corr_peb_count);
} }
...@@ -1286,7 +1287,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap, ...@@ -1286,7 +1287,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
fm_eba[i][j] == UBI_LEB_UNMAPPED) fm_eba[i][j] == UBI_LEB_UNMAPPED)
continue; continue;
ubi_err("LEB:%i:%i is PEB:%i instead of %i!", ubi_err(ubi, "LEB:%i:%i is PEB:%i instead of %i!",
vol->vol_id, i, fm_eba[i][j], vol->vol_id, i, fm_eba[i][j],
scan_eba[i][j]); scan_eba[i][j]);
ubi_assert(0); ubi_assert(0);
...@@ -1366,10 +1367,10 @@ int ubi_eba_init(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1366,10 +1367,10 @@ int ubi_eba_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
} }
if (ubi->avail_pebs < EBA_RESERVED_PEBS) { if (ubi->avail_pebs < EBA_RESERVED_PEBS) {
ubi_err("no enough physical eraseblocks (%d, need %d)", ubi_err(ubi, "no enough physical eraseblocks (%d, need %d)",
ubi->avail_pebs, EBA_RESERVED_PEBS); ubi->avail_pebs, EBA_RESERVED_PEBS);
if (ubi->corr_peb_count) if (ubi->corr_peb_count)
ubi_err("%d PEBs are corrupted and not used", ubi_err(ubi, "%d PEBs are corrupted and not used",
ubi->corr_peb_count); ubi->corr_peb_count);
err = -ENOSPC; err = -ENOSPC;
goto out_free; goto out_free;
......
...@@ -330,7 +330,7 @@ static int process_pool_aeb(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -330,7 +330,7 @@ static int process_pool_aeb(struct ubi_device *ubi, struct ubi_attach_info *ai,
if (found) if (found)
av = tmp_av; av = tmp_av;
else { else {
ubi_err("orphaned volume in fastmap pool!"); ubi_err(ubi, "orphaned volume in fastmap pool!");
kmem_cache_free(ai->aeb_slab_cache, new_aeb); kmem_cache_free(ai->aeb_slab_cache, new_aeb);
return UBI_BAD_FASTMAP; return UBI_BAD_FASTMAP;
} }
...@@ -414,14 +414,14 @@ static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -414,14 +414,14 @@ static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai,
pnum = be32_to_cpu(pebs[i]); pnum = be32_to_cpu(pebs[i]);
if (ubi_io_is_bad(ubi, pnum)) { if (ubi_io_is_bad(ubi, pnum)) {
ubi_err("bad PEB in fastmap pool!"); ubi_err(ubi, "bad PEB in fastmap pool!");
ret = UBI_BAD_FASTMAP; ret = UBI_BAD_FASTMAP;
goto out; goto out;
} }
err = ubi_io_read_ec_hdr(ubi, pnum, ech, 0); err = ubi_io_read_ec_hdr(ubi, pnum, ech, 0);
if (err && err != UBI_IO_BITFLIPS) { if (err && err != UBI_IO_BITFLIPS) {
ubi_err("unable to read EC header! PEB:%i err:%i", ubi_err(ubi, "unable to read EC header! PEB:%i err:%i",
pnum, err); pnum, err);
ret = err > 0 ? UBI_BAD_FASTMAP : err; ret = err > 0 ? UBI_BAD_FASTMAP : err;
goto out; goto out;
...@@ -435,7 +435,7 @@ static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -435,7 +435,7 @@ static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai,
image_seq = be32_to_cpu(ech->image_seq); image_seq = be32_to_cpu(ech->image_seq);
if (image_seq && (image_seq != ubi->image_seq)) { if (image_seq && (image_seq != ubi->image_seq)) {
ubi_err("bad image seq: 0x%x, expected: 0x%x", ubi_err(ubi, "bad image seq: 0x%x, expected: 0x%x",
be32_to_cpu(ech->image_seq), ubi->image_seq); be32_to_cpu(ech->image_seq), ubi->image_seq);
ret = UBI_BAD_FASTMAP; ret = UBI_BAD_FASTMAP;
goto out; goto out;
...@@ -493,7 +493,7 @@ static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -493,7 +493,7 @@ static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai,
} }
} else { } else {
/* We are paranoid and fall back to scanning mode */ /* We are paranoid and fall back to scanning mode */
ubi_err("fastmap pool PEBs contains damaged PEBs!"); ubi_err(ubi, "fastmap pool PEBs contains damaged PEBs!");
ret = err > 0 ? UBI_BAD_FASTMAP : err; ret = err > 0 ? UBI_BAD_FASTMAP : err;
goto out; goto out;
} }
...@@ -588,7 +588,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi, ...@@ -588,7 +588,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
goto fail_bad; goto fail_bad;
if (be32_to_cpu(fmhdr->magic) != UBI_FM_HDR_MAGIC) { if (be32_to_cpu(fmhdr->magic) != UBI_FM_HDR_MAGIC) {
ubi_err("bad fastmap header magic: 0x%x, expected: 0x%x", ubi_err(ubi, "bad fastmap header magic: 0x%x, expected: 0x%x",
be32_to_cpu(fmhdr->magic), UBI_FM_HDR_MAGIC); be32_to_cpu(fmhdr->magic), UBI_FM_HDR_MAGIC);
goto fail_bad; goto fail_bad;
} }
...@@ -598,7 +598,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi, ...@@ -598,7 +598,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
if (fm_pos >= fm_size) if (fm_pos >= fm_size)
goto fail_bad; goto fail_bad;
if (be32_to_cpu(fmpl1->magic) != UBI_FM_POOL_MAGIC) { if (be32_to_cpu(fmpl1->magic) != UBI_FM_POOL_MAGIC) {
ubi_err("bad fastmap pool magic: 0x%x, expected: 0x%x", ubi_err(ubi, "bad fastmap pool magic: 0x%x, expected: 0x%x",
be32_to_cpu(fmpl1->magic), UBI_FM_POOL_MAGIC); be32_to_cpu(fmpl1->magic), UBI_FM_POOL_MAGIC);
goto fail_bad; goto fail_bad;
} }
...@@ -608,7 +608,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi, ...@@ -608,7 +608,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
if (fm_pos >= fm_size) if (fm_pos >= fm_size)
goto fail_bad; goto fail_bad;
if (be32_to_cpu(fmpl2->magic) != UBI_FM_POOL_MAGIC) { if (be32_to_cpu(fmpl2->magic) != UBI_FM_POOL_MAGIC) {
ubi_err("bad fastmap pool magic: 0x%x, expected: 0x%x", ubi_err(ubi, "bad fastmap pool magic: 0x%x, expected: 0x%x",
be32_to_cpu(fmpl2->magic), UBI_FM_POOL_MAGIC); be32_to_cpu(fmpl2->magic), UBI_FM_POOL_MAGIC);
goto fail_bad; goto fail_bad;
} }
...@@ -619,25 +619,26 @@ static int ubi_attach_fastmap(struct ubi_device *ubi, ...@@ -619,25 +619,26 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
fm->max_wl_pool_size = be16_to_cpu(fmpl2->max_size); fm->max_wl_pool_size = be16_to_cpu(fmpl2->max_size);
if (pool_size > UBI_FM_MAX_POOL_SIZE || pool_size < 0) { if (pool_size > UBI_FM_MAX_POOL_SIZE || pool_size < 0) {
ubi_err("bad pool size: %i", pool_size); ubi_err(ubi, "bad pool size: %i", pool_size);
goto fail_bad; goto fail_bad;
} }
if (wl_pool_size > UBI_FM_MAX_POOL_SIZE || wl_pool_size < 0) { if (wl_pool_size > UBI_FM_MAX_POOL_SIZE || wl_pool_size < 0) {
ubi_err("bad WL pool size: %i", wl_pool_size); ubi_err(ubi, "bad WL pool size: %i", wl_pool_size);
goto fail_bad; goto fail_bad;
} }
if (fm->max_pool_size > UBI_FM_MAX_POOL_SIZE || if (fm->max_pool_size > UBI_FM_MAX_POOL_SIZE ||
fm->max_pool_size < 0) { fm->max_pool_size < 0) {
ubi_err("bad maximal pool size: %i", fm->max_pool_size); ubi_err(ubi, "bad maximal pool size: %i", fm->max_pool_size);
goto fail_bad; goto fail_bad;
} }
if (fm->max_wl_pool_size > UBI_FM_MAX_POOL_SIZE || if (fm->max_wl_pool_size > UBI_FM_MAX_POOL_SIZE ||
fm->max_wl_pool_size < 0) { fm->max_wl_pool_size < 0) {
ubi_err("bad maximal WL pool size: %i", fm->max_wl_pool_size); ubi_err(ubi, "bad maximal WL pool size: %i",
fm->max_wl_pool_size);
goto fail_bad; goto fail_bad;
} }
...@@ -696,8 +697,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi, ...@@ -696,8 +697,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
goto fail_bad; goto fail_bad;
if (be32_to_cpu(fmvhdr->magic) != UBI_FM_VHDR_MAGIC) { if (be32_to_cpu(fmvhdr->magic) != UBI_FM_VHDR_MAGIC) {
ubi_err("bad fastmap vol header magic: 0x%x, " \ ubi_err(ubi, "bad fastmap vol header magic: 0x%x, expected: 0x%x",
"expected: 0x%x",
be32_to_cpu(fmvhdr->magic), UBI_FM_VHDR_MAGIC); be32_to_cpu(fmvhdr->magic), UBI_FM_VHDR_MAGIC);
goto fail_bad; goto fail_bad;
} }
...@@ -722,8 +722,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi, ...@@ -722,8 +722,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
goto fail_bad; goto fail_bad;
if (be32_to_cpu(fm_eba->magic) != UBI_FM_EBA_MAGIC) { if (be32_to_cpu(fm_eba->magic) != UBI_FM_EBA_MAGIC) {
ubi_err("bad fastmap EBA header magic: 0x%x, " \ ubi_err(ubi, "bad fastmap EBA header magic: 0x%x, expected: 0x%x",
"expected: 0x%x",
be32_to_cpu(fm_eba->magic), UBI_FM_EBA_MAGIC); be32_to_cpu(fm_eba->magic), UBI_FM_EBA_MAGIC);
goto fail_bad; goto fail_bad;
} }
...@@ -788,7 +787,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi, ...@@ -788,7 +787,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
int err; int err;
if (ubi_io_is_bad(ubi, tmp_aeb->pnum)) { if (ubi_io_is_bad(ubi, tmp_aeb->pnum)) {
ubi_err("bad PEB in fastmap EBA orphan list"); ubi_err(ubi, "bad PEB in fastmap EBA orphan list");
ret = UBI_BAD_FASTMAP; ret = UBI_BAD_FASTMAP;
kfree(ech); kfree(ech);
goto fail; goto fail;
...@@ -796,8 +795,8 @@ static int ubi_attach_fastmap(struct ubi_device *ubi, ...@@ -796,8 +795,8 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
err = ubi_io_read_ec_hdr(ubi, tmp_aeb->pnum, ech, 0); err = ubi_io_read_ec_hdr(ubi, tmp_aeb->pnum, ech, 0);
if (err && err != UBI_IO_BITFLIPS) { if (err && err != UBI_IO_BITFLIPS) {
ubi_err("unable to read EC header! PEB:%i " \ ubi_err(ubi, "unable to read EC header! PEB:%i err:%i",
"err:%i", tmp_aeb->pnum, err); tmp_aeb->pnum, err);
ret = err > 0 ? UBI_BAD_FASTMAP : err; ret = err > 0 ? UBI_BAD_FASTMAP : err;
kfree(ech); kfree(ech);
...@@ -908,14 +907,14 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -908,14 +907,14 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
fm->to_be_tortured[0] = 1; fm->to_be_tortured[0] = 1;
if (be32_to_cpu(fmsb->magic) != UBI_FM_SB_MAGIC) { if (be32_to_cpu(fmsb->magic) != UBI_FM_SB_MAGIC) {
ubi_err("bad super block magic: 0x%x, expected: 0x%x", ubi_err(ubi, "bad super block magic: 0x%x, expected: 0x%x",
be32_to_cpu(fmsb->magic), UBI_FM_SB_MAGIC); be32_to_cpu(fmsb->magic), UBI_FM_SB_MAGIC);
ret = UBI_BAD_FASTMAP; ret = UBI_BAD_FASTMAP;
goto free_fm_sb; goto free_fm_sb;
} }
if (fmsb->version != UBI_FM_FMT_VERSION) { if (fmsb->version != UBI_FM_FMT_VERSION) {
ubi_err("bad fastmap version: %i, expected: %i", ubi_err(ubi, "bad fastmap version: %i, expected: %i",
fmsb->version, UBI_FM_FMT_VERSION); fmsb->version, UBI_FM_FMT_VERSION);
ret = UBI_BAD_FASTMAP; ret = UBI_BAD_FASTMAP;
goto free_fm_sb; goto free_fm_sb;
...@@ -923,15 +922,16 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -923,15 +922,16 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
used_blocks = be32_to_cpu(fmsb->used_blocks); used_blocks = be32_to_cpu(fmsb->used_blocks);
if (used_blocks > UBI_FM_MAX_BLOCKS || used_blocks < 1) { if (used_blocks > UBI_FM_MAX_BLOCKS || used_blocks < 1) {
ubi_err("number of fastmap blocks is invalid: %i", used_blocks); ubi_err(ubi, "number of fastmap blocks is invalid: %i",
used_blocks);
ret = UBI_BAD_FASTMAP; ret = UBI_BAD_FASTMAP;
goto free_fm_sb; goto free_fm_sb;
} }
fm_size = ubi->leb_size * used_blocks; fm_size = ubi->leb_size * used_blocks;
if (fm_size != ubi->fm_size) { if (fm_size != ubi->fm_size) {
ubi_err("bad fastmap size: %zi, expected: %zi", fm_size, ubi_err(ubi, "bad fastmap size: %zi, expected: %zi",
ubi->fm_size); fm_size, ubi->fm_size);
ret = UBI_BAD_FASTMAP; ret = UBI_BAD_FASTMAP;
goto free_fm_sb; goto free_fm_sb;
} }
...@@ -960,7 +960,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -960,7 +960,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
ret = ubi_io_read_ec_hdr(ubi, pnum, ech, 0); ret = ubi_io_read_ec_hdr(ubi, pnum, ech, 0);
if (ret && ret != UBI_IO_BITFLIPS) { if (ret && ret != UBI_IO_BITFLIPS) {
ubi_err("unable to read fastmap block# %i EC (PEB: %i)", ubi_err(ubi, "unable to read fastmap block# %i EC (PEB: %i)",
i, pnum); i, pnum);
if (ret > 0) if (ret > 0)
ret = UBI_BAD_FASTMAP; ret = UBI_BAD_FASTMAP;
...@@ -977,7 +977,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -977,7 +977,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
* we shouldn't fail if image_seq == 0. * we shouldn't fail if image_seq == 0.
*/ */
if (image_seq && (image_seq != ubi->image_seq)) { if (image_seq && (image_seq != ubi->image_seq)) {
ubi_err("wrong image seq:%d instead of %d", ubi_err(ubi, "wrong image seq:%d instead of %d",
be32_to_cpu(ech->image_seq), ubi->image_seq); be32_to_cpu(ech->image_seq), ubi->image_seq);
ret = UBI_BAD_FASTMAP; ret = UBI_BAD_FASTMAP;
goto free_hdr; goto free_hdr;
...@@ -985,15 +985,14 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -985,15 +985,14 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
ret = ubi_io_read_vid_hdr(ubi, pnum, vh, 0); ret = ubi_io_read_vid_hdr(ubi, pnum, vh, 0);
if (ret && ret != UBI_IO_BITFLIPS) { if (ret && ret != UBI_IO_BITFLIPS) {
ubi_err("unable to read fastmap block# %i (PEB: %i)", ubi_err(ubi, "unable to read fastmap block# %i (PEB: %i)",
i, pnum); i, pnum);
goto free_hdr; goto free_hdr;
} }
if (i == 0) { if (i == 0) {
if (be32_to_cpu(vh->vol_id) != UBI_FM_SB_VOLUME_ID) { if (be32_to_cpu(vh->vol_id) != UBI_FM_SB_VOLUME_ID) {
ubi_err("bad fastmap anchor vol_id: 0x%x," \ ubi_err(ubi, "bad fastmap anchor vol_id: 0x%x, expected: 0x%x",
" expected: 0x%x",
be32_to_cpu(vh->vol_id), be32_to_cpu(vh->vol_id),
UBI_FM_SB_VOLUME_ID); UBI_FM_SB_VOLUME_ID);
ret = UBI_BAD_FASTMAP; ret = UBI_BAD_FASTMAP;
...@@ -1001,8 +1000,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -1001,8 +1000,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
} }
} else { } else {
if (be32_to_cpu(vh->vol_id) != UBI_FM_DATA_VOLUME_ID) { if (be32_to_cpu(vh->vol_id) != UBI_FM_DATA_VOLUME_ID) {
ubi_err("bad fastmap data vol_id: 0x%x," \ ubi_err(ubi, "bad fastmap data vol_id: 0x%x, expected: 0x%x",
" expected: 0x%x",
be32_to_cpu(vh->vol_id), be32_to_cpu(vh->vol_id),
UBI_FM_DATA_VOLUME_ID); UBI_FM_DATA_VOLUME_ID);
ret = UBI_BAD_FASTMAP; ret = UBI_BAD_FASTMAP;
...@@ -1016,7 +1014,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -1016,7 +1014,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
ret = ubi_io_read(ubi, ubi->fm_buf + (ubi->leb_size * i), pnum, ret = ubi_io_read(ubi, ubi->fm_buf + (ubi->leb_size * i), pnum,
ubi->leb_start, ubi->leb_size); ubi->leb_start, ubi->leb_size);
if (ret && ret != UBI_IO_BITFLIPS) { if (ret && ret != UBI_IO_BITFLIPS) {
ubi_err("unable to read fastmap block# %i (PEB: %i, " \ ubi_err(ubi, "unable to read fastmap block# %i (PEB: %i, "
"err: %i)", i, pnum, ret); "err: %i)", i, pnum, ret);
goto free_hdr; goto free_hdr;
} }
...@@ -1030,8 +1028,9 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -1030,8 +1028,9 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
fmsb2->data_crc = 0; fmsb2->data_crc = 0;
crc = crc32(UBI_CRC32_INIT, ubi->fm_buf, fm_size); crc = crc32(UBI_CRC32_INIT, ubi->fm_buf, fm_size);
if (crc != tmp_crc) { if (crc != tmp_crc) {
ubi_err("fastmap data CRC is invalid"); ubi_err(ubi, "fastmap data CRC is invalid");
ubi_err("CRC should be: 0x%x, calc: 0x%x", tmp_crc, crc); ubi_err(ubi, "CRC should be: 0x%x, calc: 0x%x",
tmp_crc, crc);
ret = UBI_BAD_FASTMAP; ret = UBI_BAD_FASTMAP;
goto free_hdr; goto free_hdr;
} }
...@@ -1067,9 +1066,10 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -1067,9 +1066,10 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
ubi->fm = fm; ubi->fm = fm;
ubi->fm_pool.max_size = ubi->fm->max_pool_size; ubi->fm_pool.max_size = ubi->fm->max_pool_size;
ubi->fm_wl_pool.max_size = ubi->fm->max_wl_pool_size; ubi->fm_wl_pool.max_size = ubi->fm->max_wl_pool_size;
ubi_msg("attached by fastmap"); ubi_msg(ubi, "attached by fastmap");
ubi_msg("fastmap pool size: %d", ubi->fm_pool.max_size); ubi_msg(ubi, "fastmap pool size: %d", ubi->fm_pool.max_size);
ubi_msg("fastmap WL pool size: %d", ubi->fm_wl_pool.max_size); ubi_msg(ubi, "fastmap WL pool size: %d",
ubi->fm_wl_pool.max_size);
ubi->fm_disabled = 0; ubi->fm_disabled = 0;
ubi_free_vid_hdr(ubi, vh); ubi_free_vid_hdr(ubi, vh);
...@@ -1077,7 +1077,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai, ...@@ -1077,7 +1077,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
out: out:
mutex_unlock(&ubi->fm_mutex); mutex_unlock(&ubi->fm_mutex);
if (ret == UBI_BAD_FASTMAP) if (ret == UBI_BAD_FASTMAP)
ubi_err("Attach by fastmap failed, doing a full scan!"); ubi_err(ubi, "Attach by fastmap failed, doing a full scan!");
return ret; return ret;
free_hdr: free_hdr:
...@@ -1273,7 +1273,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi, ...@@ -1273,7 +1273,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi,
dbg_bld("writing fastmap SB to PEB %i", new_fm->e[0]->pnum); dbg_bld("writing fastmap SB to PEB %i", new_fm->e[0]->pnum);
ret = ubi_io_write_vid_hdr(ubi, new_fm->e[0]->pnum, avhdr); ret = ubi_io_write_vid_hdr(ubi, new_fm->e[0]->pnum, avhdr);
if (ret) { if (ret) {
ubi_err("unable to write vid_hdr to fastmap SB!"); ubi_err(ubi, "unable to write vid_hdr to fastmap SB!");
goto out_kfree; goto out_kfree;
} }
...@@ -1293,7 +1293,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi, ...@@ -1293,7 +1293,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi,
new_fm->e[i]->pnum, be64_to_cpu(dvhdr->sqnum)); new_fm->e[i]->pnum, be64_to_cpu(dvhdr->sqnum));
ret = ubi_io_write_vid_hdr(ubi, new_fm->e[i]->pnum, dvhdr); ret = ubi_io_write_vid_hdr(ubi, new_fm->e[i]->pnum, dvhdr);
if (ret) { if (ret) {
ubi_err("unable to write vid_hdr to PEB %i!", ubi_err(ubi, "unable to write vid_hdr to PEB %i!",
new_fm->e[i]->pnum); new_fm->e[i]->pnum);
goto out_kfree; goto out_kfree;
} }
...@@ -1303,7 +1303,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi, ...@@ -1303,7 +1303,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi,
ret = ubi_io_write(ubi, fm_raw + (i * ubi->leb_size), ret = ubi_io_write(ubi, fm_raw + (i * ubi->leb_size),
new_fm->e[i]->pnum, ubi->leb_start, ubi->leb_size); new_fm->e[i]->pnum, ubi->leb_start, ubi->leb_size);
if (ret) { if (ret) {
ubi_err("unable to write fastmap to PEB %i!", ubi_err(ubi, "unable to write fastmap to PEB %i!",
new_fm->e[i]->pnum); new_fm->e[i]->pnum);
goto out_kfree; goto out_kfree;
} }
...@@ -1450,7 +1450,7 @@ int ubi_update_fastmap(struct ubi_device *ubi) ...@@ -1450,7 +1450,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)
ubi->fm = NULL; ubi->fm = NULL;
if (new_fm->used_blocks > UBI_FM_MAX_BLOCKS) { if (new_fm->used_blocks > UBI_FM_MAX_BLOCKS) {
ubi_err("fastmap too large"); ubi_err(ubi, "fastmap too large");
ret = -ENOSPC; ret = -ENOSPC;
goto err; goto err;
} }
...@@ -1462,7 +1462,7 @@ int ubi_update_fastmap(struct ubi_device *ubi) ...@@ -1462,7 +1462,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)
if (!tmp_e && !old_fm) { if (!tmp_e && !old_fm) {
int j; int j;
ubi_err("could not get any free erase block"); ubi_err(ubi, "could not get any free erase block");
for (j = 1; j < i; j++) for (j = 1; j < i; j++)
ubi_wl_put_fm_peb(ubi, new_fm->e[j], j, 0); ubi_wl_put_fm_peb(ubi, new_fm->e[j], j, 0);
...@@ -1478,7 +1478,7 @@ int ubi_update_fastmap(struct ubi_device *ubi) ...@@ -1478,7 +1478,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)
ubi_wl_put_fm_peb(ubi, new_fm->e[j], ubi_wl_put_fm_peb(ubi, new_fm->e[j],
j, 0); j, 0);
ubi_err("could not erase old fastmap PEB"); ubi_err(ubi, "could not erase old fastmap PEB");
goto err; goto err;
} }
...@@ -1504,7 +1504,7 @@ int ubi_update_fastmap(struct ubi_device *ubi) ...@@ -1504,7 +1504,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)
ret = erase_block(ubi, old_fm->e[0]->pnum); ret = erase_block(ubi, old_fm->e[0]->pnum);
if (ret < 0) { if (ret < 0) {
int i; int i;
ubi_err("could not erase old anchor PEB"); ubi_err(ubi, "could not erase old anchor PEB");
for (i = 1; i < new_fm->used_blocks; i++) for (i = 1; i < new_fm->used_blocks; i++)
ubi_wl_put_fm_peb(ubi, new_fm->e[i], ubi_wl_put_fm_peb(ubi, new_fm->e[i],
...@@ -1525,7 +1525,7 @@ int ubi_update_fastmap(struct ubi_device *ubi) ...@@ -1525,7 +1525,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)
} else { } else {
if (!tmp_e) { if (!tmp_e) {
int i; int i;
ubi_err("could not find any anchor PEB"); ubi_err(ubi, "could not find any anchor PEB");
for (i = 1; i < new_fm->used_blocks; i++) for (i = 1; i < new_fm->used_blocks; i++)
ubi_wl_put_fm_peb(ubi, new_fm->e[i], i, 0); ubi_wl_put_fm_peb(ubi, new_fm->e[i], i, 0);
...@@ -1555,13 +1555,13 @@ int ubi_update_fastmap(struct ubi_device *ubi) ...@@ -1555,13 +1555,13 @@ int ubi_update_fastmap(struct ubi_device *ubi)
err: err:
kfree(new_fm); kfree(new_fm);
ubi_warn("Unable to write new fastmap, err=%i", ret); ubi_warn(ubi, "Unable to write new fastmap, err=%i", ret);
ret = 0; ret = 0;
if (old_fm) { if (old_fm) {
ret = invalidate_fastmap(ubi, old_fm); ret = invalidate_fastmap(ubi, old_fm);
if (ret < 0) if (ret < 0)
ubi_err("Unable to invalidiate current fastmap!"); ubi_err(ubi, "Unable to invalidiate current fastmap!");
else if (ret) else if (ret)
ret = 0; ret = 0;
} }
......
...@@ -177,19 +177,20 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset, ...@@ -177,19 +177,20 @@ int ubi_io_read(const struct ubi_device *ubi, void *buf, int pnum, int offset,
* enabled. A corresponding message will be printed * enabled. A corresponding message will be printed
* later, when it is has been scrubbed. * later, when it is has been scrubbed.
*/ */
ubi_msg("fixable bit-flip detected at PEB %d", pnum); ubi_msg(ubi, "fixable bit-flip detected at PEB %d",
pnum);
ubi_assert(len == read); ubi_assert(len == read);
return UBI_IO_BITFLIPS; return UBI_IO_BITFLIPS;
} }
if (retries++ < UBI_IO_RETRIES) { if (retries++ < UBI_IO_RETRIES) {
ubi_warn("error %d%s while reading %d bytes from PEB %d:%d, read only %zd bytes, retry", ubi_warn(ubi, "error %d%s while reading %d bytes from PEB %d:%d, read only %zd bytes, retry",
err, errstr, len, pnum, offset, read); err, errstr, len, pnum, offset, read);
yield(); yield();
goto retry; goto retry;
} }
ubi_err("error %d%s while reading %d bytes from PEB %d:%d, read %zd bytes", ubi_err(ubi, "error %d%s while reading %d bytes from PEB %d:%d, read %zd bytes",
err, errstr, len, pnum, offset, read); err, errstr, len, pnum, offset, read);
dump_stack(); dump_stack();
...@@ -246,7 +247,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, ...@@ -246,7 +247,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
ubi_assert(len > 0 && len % ubi->hdrs_min_io_size == 0); ubi_assert(len > 0 && len % ubi->hdrs_min_io_size == 0);
if (ubi->ro_mode) { if (ubi->ro_mode) {
ubi_err("read-only mode"); ubi_err(ubi, "read-only mode");
return -EROFS; return -EROFS;
} }
...@@ -273,7 +274,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, ...@@ -273,7 +274,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
} }
if (ubi_dbg_is_write_failure(ubi)) { if (ubi_dbg_is_write_failure(ubi)) {
ubi_err("cannot write %d bytes to PEB %d:%d (emulated)", ubi_err(ubi, "cannot write %d bytes to PEB %d:%d (emulated)",
len, pnum, offset); len, pnum, offset);
dump_stack(); dump_stack();
return -EIO; return -EIO;
...@@ -282,7 +283,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, ...@@ -282,7 +283,7 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
addr = (loff_t)pnum * ubi->peb_size + offset; addr = (loff_t)pnum * ubi->peb_size + offset;
err = mtd_write(ubi->mtd, addr, len, &written, buf); err = mtd_write(ubi->mtd, addr, len, &written, buf);
if (err) { if (err) {
ubi_err("error %d while writing %d bytes to PEB %d:%d, written %zd bytes", ubi_err(ubi, "error %d while writing %d bytes to PEB %d:%d, written %zd bytes",
err, len, pnum, offset, written); err, len, pnum, offset, written);
dump_stack(); dump_stack();
ubi_dump_flash(ubi, pnum, offset, len); ubi_dump_flash(ubi, pnum, offset, len);
...@@ -338,7 +339,7 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum) ...@@ -338,7 +339,7 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)
ubi_assert(pnum >= 0 && pnum < ubi->peb_count); ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
if (ubi->ro_mode) { if (ubi->ro_mode) {
ubi_err("read-only mode"); ubi_err(ubi, "read-only mode");
return -EROFS; return -EROFS;
} }
...@@ -355,12 +356,12 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum) ...@@ -355,12 +356,12 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)
err = mtd_erase(ubi->mtd, &ei); err = mtd_erase(ubi->mtd, &ei);
if (err) { if (err) {
if (retries++ < UBI_IO_RETRIES) { if (retries++ < UBI_IO_RETRIES) {
ubi_warn("error %d while erasing PEB %d, retry", ubi_warn(ubi, "error %d while erasing PEB %d, retry",
err, pnum); err, pnum);
yield(); yield();
goto retry; goto retry;
} }
ubi_err("cannot erase PEB %d, error %d", pnum, err); ubi_err(ubi, "cannot erase PEB %d, error %d", pnum, err);
dump_stack(); dump_stack();
return err; return err;
} }
...@@ -368,17 +369,18 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum) ...@@ -368,17 +369,18 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)
err = wait_event_interruptible(wq, ei.state == MTD_ERASE_DONE || err = wait_event_interruptible(wq, ei.state == MTD_ERASE_DONE ||
ei.state == MTD_ERASE_FAILED); ei.state == MTD_ERASE_FAILED);
if (err) { if (err) {
ubi_err("interrupted PEB %d erasure", pnum); ubi_err(ubi, "interrupted PEB %d erasure", pnum);
return -EINTR; return -EINTR;
} }
if (ei.state == MTD_ERASE_FAILED) { if (ei.state == MTD_ERASE_FAILED) {
if (retries++ < UBI_IO_RETRIES) { if (retries++ < UBI_IO_RETRIES) {
ubi_warn("error while erasing PEB %d, retry", pnum); ubi_warn(ubi, "error while erasing PEB %d, retry",
pnum);
yield(); yield();
goto retry; goto retry;
} }
ubi_err("cannot erase PEB %d", pnum); ubi_err(ubi, "cannot erase PEB %d", pnum);
dump_stack(); dump_stack();
return -EIO; return -EIO;
} }
...@@ -388,7 +390,7 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum) ...@@ -388,7 +390,7 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)
return err; return err;
if (ubi_dbg_is_erase_failure(ubi)) { if (ubi_dbg_is_erase_failure(ubi)) {
ubi_err("cannot erase PEB %d (emulated)", pnum); ubi_err(ubi, "cannot erase PEB %d (emulated)", pnum);
return -EIO; return -EIO;
} }
...@@ -411,7 +413,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum) ...@@ -411,7 +413,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum)
{ {
int err, i, patt_count; int err, i, patt_count;
ubi_msg("run torture test for PEB %d", pnum); ubi_msg(ubi, "run torture test for PEB %d", pnum);
patt_count = ARRAY_SIZE(patterns); patt_count = ARRAY_SIZE(patterns);
ubi_assert(patt_count > 0); ubi_assert(patt_count > 0);
...@@ -428,7 +430,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum) ...@@ -428,7 +430,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum)
err = ubi_check_pattern(ubi->peb_buf, 0xFF, ubi->peb_size); err = ubi_check_pattern(ubi->peb_buf, 0xFF, ubi->peb_size);
if (err == 0) { if (err == 0) {
ubi_err("erased PEB %d, but a non-0xFF byte found", ubi_err(ubi, "erased PEB %d, but a non-0xFF byte found",
pnum); pnum);
err = -EIO; err = -EIO;
goto out; goto out;
...@@ -448,7 +450,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum) ...@@ -448,7 +450,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum)
err = ubi_check_pattern(ubi->peb_buf, patterns[i], err = ubi_check_pattern(ubi->peb_buf, patterns[i],
ubi->peb_size); ubi->peb_size);
if (err == 0) { if (err == 0) {
ubi_err("pattern %x checking failed for PEB %d", ubi_err(ubi, "pattern %x checking failed for PEB %d",
patterns[i], pnum); patterns[i], pnum);
err = -EIO; err = -EIO;
goto out; goto out;
...@@ -456,7 +458,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum) ...@@ -456,7 +458,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum)
} }
err = patt_count; err = patt_count;
ubi_msg("PEB %d passed torture test, do not mark it as bad", pnum); ubi_msg(ubi, "PEB %d passed torture test, do not mark it as bad", pnum);
out: out:
mutex_unlock(&ubi->buf_mutex); mutex_unlock(&ubi->buf_mutex);
...@@ -466,7 +468,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum) ...@@ -466,7 +468,7 @@ static int torture_peb(struct ubi_device *ubi, int pnum)
* has not passed because it happened on a freshly erased * has not passed because it happened on a freshly erased
* physical eraseblock which means something is wrong with it. * physical eraseblock which means something is wrong with it.
*/ */
ubi_err("read problems on freshly erased PEB %d, must be bad", ubi_err(ubi, "read problems on freshly erased PEB %d, must be bad",
pnum); pnum);
err = -EIO; err = -EIO;
} }
...@@ -542,7 +544,7 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum) ...@@ -542,7 +544,7 @@ static int nor_erase_prepare(struct ubi_device *ubi, int pnum)
* it. Supposedly the flash media or the driver is screwed up, so * it. Supposedly the flash media or the driver is screwed up, so
* return an error. * return an error.
*/ */
ubi_err("cannot invalidate PEB %d, write returned %d", pnum, err); ubi_err(ubi, "cannot invalidate PEB %d, write returned %d", pnum, err);
ubi_dump_flash(ubi, pnum, 0, ubi->peb_size); ubi_dump_flash(ubi, pnum, 0, ubi->peb_size);
return -EIO; return -EIO;
} }
...@@ -574,7 +576,7 @@ int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture) ...@@ -574,7 +576,7 @@ int ubi_io_sync_erase(struct ubi_device *ubi, int pnum, int torture)
return err; return err;
if (ubi->ro_mode) { if (ubi->ro_mode) {
ubi_err("read-only mode"); ubi_err(ubi, "read-only mode");
return -EROFS; return -EROFS;
} }
...@@ -616,7 +618,7 @@ int ubi_io_is_bad(const struct ubi_device *ubi, int pnum) ...@@ -616,7 +618,7 @@ int ubi_io_is_bad(const struct ubi_device *ubi, int pnum)
ret = mtd_block_isbad(mtd, (loff_t)pnum * ubi->peb_size); ret = mtd_block_isbad(mtd, (loff_t)pnum * ubi->peb_size);
if (ret < 0) if (ret < 0)
ubi_err("error %d while checking if PEB %d is bad", ubi_err(ubi, "error %d while checking if PEB %d is bad",
ret, pnum); ret, pnum);
else if (ret) else if (ret)
dbg_io("PEB %d is bad", pnum); dbg_io("PEB %d is bad", pnum);
...@@ -642,7 +644,7 @@ int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum) ...@@ -642,7 +644,7 @@ int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum)
ubi_assert(pnum >= 0 && pnum < ubi->peb_count); ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
if (ubi->ro_mode) { if (ubi->ro_mode) {
ubi_err("read-only mode"); ubi_err(ubi, "read-only mode");
return -EROFS; return -EROFS;
} }
...@@ -651,7 +653,7 @@ int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum) ...@@ -651,7 +653,7 @@ int ubi_io_mark_bad(const struct ubi_device *ubi, int pnum)
err = mtd_block_markbad(mtd, (loff_t)pnum * ubi->peb_size); err = mtd_block_markbad(mtd, (loff_t)pnum * ubi->peb_size);
if (err) if (err)
ubi_err("cannot mark PEB %d bad, error %d", pnum, err); ubi_err(ubi, "cannot mark PEB %d bad, error %d", pnum, err);
return err; return err;
} }
...@@ -674,32 +676,32 @@ static int validate_ec_hdr(const struct ubi_device *ubi, ...@@ -674,32 +676,32 @@ static int validate_ec_hdr(const struct ubi_device *ubi,
leb_start = be32_to_cpu(ec_hdr->data_offset); leb_start = be32_to_cpu(ec_hdr->data_offset);
if (ec_hdr->version != UBI_VERSION) { if (ec_hdr->version != UBI_VERSION) {
ubi_err("node with incompatible UBI version found: this UBI version is %d, image version is %d", ubi_err(ubi, "node with incompatible UBI version found: this UBI version is %d, image version is %d",
UBI_VERSION, (int)ec_hdr->version); UBI_VERSION, (int)ec_hdr->version);
goto bad; goto bad;
} }
if (vid_hdr_offset != ubi->vid_hdr_offset) { if (vid_hdr_offset != ubi->vid_hdr_offset) {
ubi_err("bad VID header offset %d, expected %d", ubi_err(ubi, "bad VID header offset %d, expected %d",
vid_hdr_offset, ubi->vid_hdr_offset); vid_hdr_offset, ubi->vid_hdr_offset);
goto bad; goto bad;
} }
if (leb_start != ubi->leb_start) { if (leb_start != ubi->leb_start) {
ubi_err("bad data offset %d, expected %d", ubi_err(ubi, "bad data offset %d, expected %d",
leb_start, ubi->leb_start); leb_start, ubi->leb_start);
goto bad; goto bad;
} }
if (ec < 0 || ec > UBI_MAX_ERASECOUNTER) { if (ec < 0 || ec > UBI_MAX_ERASECOUNTER) {
ubi_err("bad erase counter %lld", ec); ubi_err(ubi, "bad erase counter %lld", ec);
goto bad; goto bad;
} }
return 0; return 0;
bad: bad:
ubi_err("bad EC header"); ubi_err(ubi, "bad EC header");
ubi_dump_ec_hdr(ec_hdr); ubi_dump_ec_hdr(ec_hdr);
dump_stack(); dump_stack();
return 1; return 1;
...@@ -765,7 +767,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, ...@@ -765,7 +767,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
if (ubi_check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) { if (ubi_check_pattern(ec_hdr, 0xFF, UBI_EC_HDR_SIZE)) {
/* The physical eraseblock is supposedly empty */ /* The physical eraseblock is supposedly empty */
if (verbose) if (verbose)
ubi_warn("no EC header found at PEB %d, only 0xFF bytes", ubi_warn(ubi, "no EC header found at PEB %d, only 0xFF bytes",
pnum); pnum);
dbg_bld("no EC header found at PEB %d, only 0xFF bytes", dbg_bld("no EC header found at PEB %d, only 0xFF bytes",
pnum); pnum);
...@@ -780,7 +782,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, ...@@ -780,7 +782,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
* 0xFF bytes. Report that the header is corrupted. * 0xFF bytes. Report that the header is corrupted.
*/ */
if (verbose) { if (verbose) {
ubi_warn("bad magic number at PEB %d: %08x instead of %08x", ubi_warn(ubi, "bad magic number at PEB %d: %08x instead of %08x",
pnum, magic, UBI_EC_HDR_MAGIC); pnum, magic, UBI_EC_HDR_MAGIC);
ubi_dump_ec_hdr(ec_hdr); ubi_dump_ec_hdr(ec_hdr);
} }
...@@ -794,7 +796,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, ...@@ -794,7 +796,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
if (hdr_crc != crc) { if (hdr_crc != crc) {
if (verbose) { if (verbose) {
ubi_warn("bad EC header CRC at PEB %d, calculated %#08x, read %#08x", ubi_warn(ubi, "bad EC header CRC at PEB %d, calculated %#08x, read %#08x",
pnum, crc, hdr_crc); pnum, crc, hdr_crc);
ubi_dump_ec_hdr(ec_hdr); ubi_dump_ec_hdr(ec_hdr);
} }
...@@ -810,7 +812,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum, ...@@ -810,7 +812,7 @@ int ubi_io_read_ec_hdr(struct ubi_device *ubi, int pnum,
/* And of course validate what has just been read from the media */ /* And of course validate what has just been read from the media */
err = validate_ec_hdr(ubi, ec_hdr); err = validate_ec_hdr(ubi, ec_hdr);
if (err) { if (err) {
ubi_err("validation failed for PEB %d", pnum); ubi_err(ubi, "validation failed for PEB %d", pnum);
return -EINVAL; return -EINVAL;
} }
...@@ -884,40 +886,40 @@ static int validate_vid_hdr(const struct ubi_device *ubi, ...@@ -884,40 +886,40 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
int usable_leb_size = ubi->leb_size - data_pad; int usable_leb_size = ubi->leb_size - data_pad;
if (copy_flag != 0 && copy_flag != 1) { if (copy_flag != 0 && copy_flag != 1) {
ubi_err("bad copy_flag"); ubi_err(ubi, "bad copy_flag");
goto bad; goto bad;
} }
if (vol_id < 0 || lnum < 0 || data_size < 0 || used_ebs < 0 || if (vol_id < 0 || lnum < 0 || data_size < 0 || used_ebs < 0 ||
data_pad < 0) { data_pad < 0) {
ubi_err("negative values"); ubi_err(ubi, "negative values");
goto bad; goto bad;
} }
if (vol_id >= UBI_MAX_VOLUMES && vol_id < UBI_INTERNAL_VOL_START) { if (vol_id >= UBI_MAX_VOLUMES && vol_id < UBI_INTERNAL_VOL_START) {
ubi_err("bad vol_id"); ubi_err(ubi, "bad vol_id");
goto bad; goto bad;
} }
if (vol_id < UBI_INTERNAL_VOL_START && compat != 0) { if (vol_id < UBI_INTERNAL_VOL_START && compat != 0) {
ubi_err("bad compat"); ubi_err(ubi, "bad compat");
goto bad; goto bad;
} }
if (vol_id >= UBI_INTERNAL_VOL_START && compat != UBI_COMPAT_DELETE && if (vol_id >= UBI_INTERNAL_VOL_START && compat != UBI_COMPAT_DELETE &&
compat != UBI_COMPAT_RO && compat != UBI_COMPAT_PRESERVE && compat != UBI_COMPAT_RO && compat != UBI_COMPAT_PRESERVE &&
compat != UBI_COMPAT_REJECT) { compat != UBI_COMPAT_REJECT) {
ubi_err("bad compat"); ubi_err(ubi, "bad compat");
goto bad; goto bad;
} }
if (vol_type != UBI_VID_DYNAMIC && vol_type != UBI_VID_STATIC) { if (vol_type != UBI_VID_DYNAMIC && vol_type != UBI_VID_STATIC) {
ubi_err("bad vol_type"); ubi_err(ubi, "bad vol_type");
goto bad; goto bad;
} }
if (data_pad >= ubi->leb_size / 2) { if (data_pad >= ubi->leb_size / 2) {
ubi_err("bad data_pad"); ubi_err(ubi, "bad data_pad");
goto bad; goto bad;
} }
...@@ -929,45 +931,45 @@ static int validate_vid_hdr(const struct ubi_device *ubi, ...@@ -929,45 +931,45 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
* mapped logical eraseblocks. * mapped logical eraseblocks.
*/ */
if (used_ebs == 0) { if (used_ebs == 0) {
ubi_err("zero used_ebs"); ubi_err(ubi, "zero used_ebs");
goto bad; goto bad;
} }
if (data_size == 0) { if (data_size == 0) {
ubi_err("zero data_size"); ubi_err(ubi, "zero data_size");
goto bad; goto bad;
} }
if (lnum < used_ebs - 1) { if (lnum < used_ebs - 1) {
if (data_size != usable_leb_size) { if (data_size != usable_leb_size) {
ubi_err("bad data_size"); ubi_err(ubi, "bad data_size");
goto bad; goto bad;
} }
} else if (lnum == used_ebs - 1) { } else if (lnum == used_ebs - 1) {
if (data_size == 0) { if (data_size == 0) {
ubi_err("bad data_size at last LEB"); ubi_err(ubi, "bad data_size at last LEB");
goto bad; goto bad;
} }
} else { } else {
ubi_err("too high lnum"); ubi_err(ubi, "too high lnum");
goto bad; goto bad;
} }
} else { } else {
if (copy_flag == 0) { if (copy_flag == 0) {
if (data_crc != 0) { if (data_crc != 0) {
ubi_err("non-zero data CRC"); ubi_err(ubi, "non-zero data CRC");
goto bad; goto bad;
} }
if (data_size != 0) { if (data_size != 0) {
ubi_err("non-zero data_size"); ubi_err(ubi, "non-zero data_size");
goto bad; goto bad;
} }
} else { } else {
if (data_size == 0) { if (data_size == 0) {
ubi_err("zero data_size of copy"); ubi_err(ubi, "zero data_size of copy");
goto bad; goto bad;
} }
} }
if (used_ebs != 0) { if (used_ebs != 0) {
ubi_err("bad used_ebs"); ubi_err(ubi, "bad used_ebs");
goto bad; goto bad;
} }
} }
...@@ -975,7 +977,7 @@ static int validate_vid_hdr(const struct ubi_device *ubi, ...@@ -975,7 +977,7 @@ static int validate_vid_hdr(const struct ubi_device *ubi,
return 0; return 0;
bad: bad:
ubi_err("bad VID header"); ubi_err(ubi, "bad VID header");
ubi_dump_vid_hdr(vid_hdr); ubi_dump_vid_hdr(vid_hdr);
dump_stack(); dump_stack();
return 1; return 1;
...@@ -1020,7 +1022,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, ...@@ -1020,7 +1022,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
if (ubi_check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) { if (ubi_check_pattern(vid_hdr, 0xFF, UBI_VID_HDR_SIZE)) {
if (verbose) if (verbose)
ubi_warn("no VID header found at PEB %d, only 0xFF bytes", ubi_warn(ubi, "no VID header found at PEB %d, only 0xFF bytes",
pnum); pnum);
dbg_bld("no VID header found at PEB %d, only 0xFF bytes", dbg_bld("no VID header found at PEB %d, only 0xFF bytes",
pnum); pnum);
...@@ -1031,7 +1033,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, ...@@ -1031,7 +1033,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
} }
if (verbose) { if (verbose) {
ubi_warn("bad magic number at PEB %d: %08x instead of %08x", ubi_warn(ubi, "bad magic number at PEB %d: %08x instead of %08x",
pnum, magic, UBI_VID_HDR_MAGIC); pnum, magic, UBI_VID_HDR_MAGIC);
ubi_dump_vid_hdr(vid_hdr); ubi_dump_vid_hdr(vid_hdr);
} }
...@@ -1045,7 +1047,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, ...@@ -1045,7 +1047,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
if (hdr_crc != crc) { if (hdr_crc != crc) {
if (verbose) { if (verbose) {
ubi_warn("bad CRC at PEB %d, calculated %#08x, read %#08x", ubi_warn(ubi, "bad CRC at PEB %d, calculated %#08x, read %#08x",
pnum, crc, hdr_crc); pnum, crc, hdr_crc);
ubi_dump_vid_hdr(vid_hdr); ubi_dump_vid_hdr(vid_hdr);
} }
...@@ -1059,7 +1061,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum, ...@@ -1059,7 +1061,7 @@ int ubi_io_read_vid_hdr(struct ubi_device *ubi, int pnum,
err = validate_vid_hdr(ubi, vid_hdr); err = validate_vid_hdr(ubi, vid_hdr);
if (err) { if (err) {
ubi_err("validation failed for PEB %d", pnum); ubi_err(ubi, "validation failed for PEB %d", pnum);
return -EINVAL; return -EINVAL;
} }
...@@ -1129,7 +1131,7 @@ static int self_check_not_bad(const struct ubi_device *ubi, int pnum) ...@@ -1129,7 +1131,7 @@ static int self_check_not_bad(const struct ubi_device *ubi, int pnum)
if (!err) if (!err)
return err; return err;
ubi_err("self-check failed for PEB %d", pnum); ubi_err(ubi, "self-check failed for PEB %d", pnum);
dump_stack(); dump_stack();
return err > 0 ? -EINVAL : err; return err > 0 ? -EINVAL : err;
} }
...@@ -1154,14 +1156,14 @@ static int self_check_ec_hdr(const struct ubi_device *ubi, int pnum, ...@@ -1154,14 +1156,14 @@ static int self_check_ec_hdr(const struct ubi_device *ubi, int pnum,
magic = be32_to_cpu(ec_hdr->magic); magic = be32_to_cpu(ec_hdr->magic);
if (magic != UBI_EC_HDR_MAGIC) { if (magic != UBI_EC_HDR_MAGIC) {
ubi_err("bad magic %#08x, must be %#08x", ubi_err(ubi, "bad magic %#08x, must be %#08x",
magic, UBI_EC_HDR_MAGIC); magic, UBI_EC_HDR_MAGIC);
goto fail; goto fail;
} }
err = validate_ec_hdr(ubi, ec_hdr); err = validate_ec_hdr(ubi, ec_hdr);
if (err) { if (err) {
ubi_err("self-check failed for PEB %d", pnum); ubi_err(ubi, "self-check failed for PEB %d", pnum);
goto fail; goto fail;
} }
...@@ -1201,8 +1203,9 @@ static int self_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum) ...@@ -1201,8 +1203,9 @@ static int self_check_peb_ec_hdr(const struct ubi_device *ubi, int pnum)
crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC); crc = crc32(UBI_CRC32_INIT, ec_hdr, UBI_EC_HDR_SIZE_CRC);
hdr_crc = be32_to_cpu(ec_hdr->hdr_crc); hdr_crc = be32_to_cpu(ec_hdr->hdr_crc);
if (hdr_crc != crc) { if (hdr_crc != crc) {
ubi_err("bad CRC, calculated %#08x, read %#08x", crc, hdr_crc); ubi_err(ubi, "bad CRC, calculated %#08x, read %#08x",
ubi_err("self-check failed for PEB %d", pnum); crc, hdr_crc);
ubi_err(ubi, "self-check failed for PEB %d", pnum);
ubi_dump_ec_hdr(ec_hdr); ubi_dump_ec_hdr(ec_hdr);
dump_stack(); dump_stack();
err = -EINVAL; err = -EINVAL;
...@@ -1236,21 +1239,21 @@ static int self_check_vid_hdr(const struct ubi_device *ubi, int pnum, ...@@ -1236,21 +1239,21 @@ static int self_check_vid_hdr(const struct ubi_device *ubi, int pnum,
magic = be32_to_cpu(vid_hdr->magic); magic = be32_to_cpu(vid_hdr->magic);
if (magic != UBI_VID_HDR_MAGIC) { if (magic != UBI_VID_HDR_MAGIC) {
ubi_err("bad VID header magic %#08x at PEB %d, must be %#08x", ubi_err(ubi, "bad VID header magic %#08x at PEB %d, must be %#08x",
magic, pnum, UBI_VID_HDR_MAGIC); magic, pnum, UBI_VID_HDR_MAGIC);
goto fail; goto fail;
} }
err = validate_vid_hdr(ubi, vid_hdr); err = validate_vid_hdr(ubi, vid_hdr);
if (err) { if (err) {
ubi_err("self-check failed for PEB %d", pnum); ubi_err(ubi, "self-check failed for PEB %d", pnum);
goto fail; goto fail;
} }
return err; return err;
fail: fail:
ubi_err("self-check failed for PEB %d", pnum); ubi_err(ubi, "self-check failed for PEB %d", pnum);
ubi_dump_vid_hdr(vid_hdr); ubi_dump_vid_hdr(vid_hdr);
dump_stack(); dump_stack();
return -EINVAL; return -EINVAL;
...@@ -1288,9 +1291,9 @@ static int self_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum) ...@@ -1288,9 +1291,9 @@ static int self_check_peb_vid_hdr(const struct ubi_device *ubi, int pnum)
crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC); crc = crc32(UBI_CRC32_INIT, vid_hdr, UBI_EC_HDR_SIZE_CRC);
hdr_crc = be32_to_cpu(vid_hdr->hdr_crc); hdr_crc = be32_to_cpu(vid_hdr->hdr_crc);
if (hdr_crc != crc) { if (hdr_crc != crc) {
ubi_err("bad VID header CRC at PEB %d, calculated %#08x, read %#08x", ubi_err(ubi, "bad VID header CRC at PEB %d, calculated %#08x, read %#08x",
pnum, crc, hdr_crc); pnum, crc, hdr_crc);
ubi_err("self-check failed for PEB %d", pnum); ubi_err(ubi, "self-check failed for PEB %d", pnum);
ubi_dump_vid_hdr(vid_hdr); ubi_dump_vid_hdr(vid_hdr);
dump_stack(); dump_stack();
err = -EINVAL; err = -EINVAL;
...@@ -1329,7 +1332,7 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum, ...@@ -1329,7 +1332,7 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum,
buf1 = __vmalloc(len, GFP_NOFS, PAGE_KERNEL); buf1 = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
if (!buf1) { if (!buf1) {
ubi_err("cannot allocate memory to check writes"); ubi_err(ubi, "cannot allocate memory to check writes");
return 0; return 0;
} }
...@@ -1345,15 +1348,15 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum, ...@@ -1345,15 +1348,15 @@ static int self_check_write(struct ubi_device *ubi, const void *buf, int pnum,
if (c == c1) if (c == c1)
continue; continue;
ubi_err("self-check failed for PEB %d:%d, len %d", ubi_err(ubi, "self-check failed for PEB %d:%d, len %d",
pnum, offset, len); pnum, offset, len);
ubi_msg("data differ at position %d", i); ubi_msg(ubi, "data differ at position %d", i);
dump_len = max_t(int, 128, len - i); dump_len = max_t(int, 128, len - i);
ubi_msg("hex dump of the original buffer from %d to %d", ubi_msg(ubi, "hex dump of the original buffer from %d to %d",
i, i + dump_len); i, i + dump_len);
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
buf + i, dump_len, 1); buf + i, dump_len, 1);
ubi_msg("hex dump of the read buffer from %d to %d", ubi_msg(ubi, "hex dump of the read buffer from %d to %d",
i, i + dump_len); i, i + dump_len);
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1,
buf1 + i, dump_len, 1); buf1 + i, dump_len, 1);
...@@ -1393,20 +1396,20 @@ int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len) ...@@ -1393,20 +1396,20 @@ int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
buf = __vmalloc(len, GFP_NOFS, PAGE_KERNEL); buf = __vmalloc(len, GFP_NOFS, PAGE_KERNEL);
if (!buf) { if (!buf) {
ubi_err("cannot allocate memory to check for 0xFFs"); ubi_err(ubi, "cannot allocate memory to check for 0xFFs");
return 0; return 0;
} }
err = mtd_read(ubi->mtd, addr, len, &read, buf); err = mtd_read(ubi->mtd, addr, len, &read, buf);
if (err && !mtd_is_bitflip(err)) { if (err && !mtd_is_bitflip(err)) {
ubi_err("error %d while reading %d bytes from PEB %d:%d, read %zd bytes", ubi_err(ubi, "err %d while reading %d bytes from PEB %d:%d, read %zd bytes",
err, len, pnum, offset, read); err, len, pnum, offset, read);
goto error; goto error;
} }
err = ubi_check_pattern(buf, 0xFF, len); err = ubi_check_pattern(buf, 0xFF, len);
if (err == 0) { if (err == 0) {
ubi_err("flash region at PEB %d:%d, length %d does not contain all 0xFF bytes", ubi_err(ubi, "flash region at PEB %d:%d, length %d does not contain all 0xFF bytes",
pnum, offset, len); pnum, offset, len);
goto fail; goto fail;
} }
...@@ -1415,8 +1418,9 @@ int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len) ...@@ -1415,8 +1418,9 @@ int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset, int len)
return 0; return 0;
fail: fail:
ubi_err("self-check failed for PEB %d", pnum); ubi_err(ubi, "self-check failed for PEB %d", pnum);
ubi_msg("hex dump of the %d-%d region", offset, offset + len); ubi_msg(ubi, "hex dump of the %d-%d region",
offset, offset + len);
print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1); print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 32, 1, buf, len, 1);
err = -EINVAL; err = -EINVAL;
error: error:
......
...@@ -204,7 +204,7 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode) ...@@ -204,7 +204,7 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode)
return ERR_PTR(err); return ERR_PTR(err);
} }
if (err == 1) { if (err == 1) {
ubi_warn("volume %d on UBI device %d is corrupted", ubi_warn(ubi, "volume %d on UBI device %d is corrupted",
vol_id, ubi->ubi_num); vol_id, ubi->ubi_num);
vol->corrupted = 1; vol->corrupted = 1;
} }
...@@ -221,7 +221,7 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode) ...@@ -221,7 +221,7 @@ struct ubi_volume_desc *ubi_open_volume(int ubi_num, int vol_id, int mode)
kfree(desc); kfree(desc);
out_put_ubi: out_put_ubi:
ubi_put_device(ubi); ubi_put_device(ubi);
ubi_err("cannot open device %d, volume %d, error %d", ubi_err(ubi, "cannot open device %d, volume %d, error %d",
ubi_num, vol_id, err); ubi_num, vol_id, err);
return ERR_PTR(err); return ERR_PTR(err);
} }
...@@ -411,7 +411,7 @@ int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset, ...@@ -411,7 +411,7 @@ int ubi_leb_read(struct ubi_volume_desc *desc, int lnum, char *buf, int offset,
err = ubi_eba_read_leb(ubi, vol, lnum, buf, offset, len, check); err = ubi_eba_read_leb(ubi, vol, lnum, buf, offset, len, check);
if (err && mtd_is_eccerr(err) && vol->vol_type == UBI_STATIC_VOLUME) { if (err && mtd_is_eccerr(err) && vol->vol_type == UBI_STATIC_VOLUME) {
ubi_warn("mark volume %d as corrupted", vol_id); ubi_warn(ubi, "mark volume %d as corrupted", vol_id);
vol->corrupted = 1; vol->corrupted = 1;
} }
......
...@@ -111,7 +111,7 @@ void ubi_update_reserved(struct ubi_device *ubi) ...@@ -111,7 +111,7 @@ void ubi_update_reserved(struct ubi_device *ubi)
ubi->avail_pebs -= need; ubi->avail_pebs -= need;
ubi->rsvd_pebs += need; ubi->rsvd_pebs += need;
ubi->beb_rsvd_pebs += need; ubi->beb_rsvd_pebs += need;
ubi_msg("reserved more %d PEBs for bad PEB handling", need); ubi_msg(ubi, "reserved more %d PEBs for bad PEB handling", need);
} }
/** /**
...@@ -128,7 +128,7 @@ void ubi_calculate_reserved(struct ubi_device *ubi) ...@@ -128,7 +128,7 @@ void ubi_calculate_reserved(struct ubi_device *ubi)
ubi->beb_rsvd_level = ubi->bad_peb_limit - ubi->bad_peb_count; ubi->beb_rsvd_level = ubi->bad_peb_limit - ubi->bad_peb_count;
if (ubi->beb_rsvd_level < 0) { if (ubi->beb_rsvd_level < 0) {
ubi->beb_rsvd_level = 0; ubi->beb_rsvd_level = 0;
ubi_warn("number of bad PEBs (%d) is above the expected limit (%d), not reserving any PEBs for bad PEB handling, will use available PEBs (if any)", ubi_warn(ubi, "number of bad PEBs (%d) is above the expected limit (%d), not reserving any PEBs for bad PEB handling, will use available PEBs (if any)",
ubi->bad_peb_count, ubi->bad_peb_limit); ubi->bad_peb_count, ubi->bad_peb_limit);
} }
} }
......
...@@ -50,13 +50,14 @@ ...@@ -50,13 +50,14 @@
#define UBI_NAME_STR "ubi" #define UBI_NAME_STR "ubi"
/* Normal UBI messages */ /* Normal UBI messages */
#define ubi_msg(fmt, ...) pr_notice("UBI: " fmt "\n", ##__VA_ARGS__) #define ubi_msg(ubi, fmt, ...) pr_notice("UBI-%d: %s:" fmt "\n", \
ubi->ubi_num, __func__, ##__VA_ARGS__)
/* UBI warning messages */ /* UBI warning messages */
#define ubi_warn(fmt, ...) pr_warn("UBI warning: %s: " fmt "\n", \ #define ubi_warn(ubi, fmt, ...) pr_warn("UBI-%d warning: %s: " fmt "\n", \
__func__, ##__VA_ARGS__) ubi->ubi_num, __func__, ##__VA_ARGS__)
/* UBI error messages */ /* UBI error messages */
#define ubi_err(fmt, ...) pr_err("UBI error: %s: " fmt "\n", \ #define ubi_err(ubi, fmt, ...) pr_err("UBI-%d error: %s: " fmt "\n", \
__func__, ##__VA_ARGS__) ubi->ubi_num, __func__, ##__VA_ARGS__)
/* Background thread name pattern */ /* Background thread name pattern */
#define UBI_BGT_NAME_PATTERN "ubi_bgt%dd" #define UBI_BGT_NAME_PATTERN "ubi_bgt%dd"
...@@ -987,7 +988,7 @@ static inline void ubi_ro_mode(struct ubi_device *ubi) ...@@ -987,7 +988,7 @@ static inline void ubi_ro_mode(struct ubi_device *ubi)
{ {
if (!ubi->ro_mode) { if (!ubi->ro_mode) {
ubi->ro_mode = 1; ubi->ro_mode = 1;
ubi_warn("switch to read-only mode"); ubi_warn(ubi, "switch to read-only mode");
dump_stack(); dump_stack();
} }
} }
......
...@@ -133,6 +133,10 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol, ...@@ -133,6 +133,10 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
ubi_assert(!vol->updating && !vol->changing_leb); ubi_assert(!vol->updating && !vol->changing_leb);
vol->updating = 1; vol->updating = 1;
vol->upd_buf = vmalloc(ubi->leb_size);
if (!vol->upd_buf)
return -ENOMEM;
err = set_update_marker(ubi, vol); err = set_update_marker(ubi, vol);
if (err) if (err)
return err; return err;
...@@ -152,14 +156,12 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol, ...@@ -152,14 +156,12 @@ int ubi_start_update(struct ubi_device *ubi, struct ubi_volume *vol,
err = clear_update_marker(ubi, vol, 0); err = clear_update_marker(ubi, vol, 0);
if (err) if (err)
return err; return err;
vfree(vol->upd_buf);
vol->updating = 0; vol->updating = 0;
return 0; return 0;
} }
vol->upd_buf = vmalloc(ubi->leb_size);
if (!vol->upd_buf)
return -ENOMEM;
vol->upd_ebs = div_u64(bytes + vol->usable_leb_size - 1, vol->upd_ebs = div_u64(bytes + vol->usable_leb_size - 1,
vol->usable_leb_size); vol->usable_leb_size);
vol->upd_bytes = bytes; vol->upd_bytes = bytes;
......
...@@ -223,7 +223,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) ...@@ -223,7 +223,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
} }
if (vol_id == UBI_VOL_NUM_AUTO) { if (vol_id == UBI_VOL_NUM_AUTO) {
ubi_err("out of volume IDs"); ubi_err(ubi, "out of volume IDs");
err = -ENFILE; err = -ENFILE;
goto out_unlock; goto out_unlock;
} }
...@@ -237,7 +237,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) ...@@ -237,7 +237,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
/* Ensure that this volume does not exist */ /* Ensure that this volume does not exist */
err = -EEXIST; err = -EEXIST;
if (ubi->volumes[vol_id]) { if (ubi->volumes[vol_id]) {
ubi_err("volume %d already exists", vol_id); ubi_err(ubi, "volume %d already exists", vol_id);
goto out_unlock; goto out_unlock;
} }
...@@ -246,7 +246,8 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) ...@@ -246,7 +246,8 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
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)) { !strcmp(ubi->volumes[i]->name, req->name)) {
ubi_err("volume \"%s\" exists (ID %d)", req->name, i); ubi_err(ubi, "volume \"%s\" exists (ID %d)",
req->name, i);
goto out_unlock; goto out_unlock;
} }
...@@ -257,9 +258,10 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) ...@@ -257,9 +258,10 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
/* Reserve physical eraseblocks */ /* Reserve physical eraseblocks */
if (vol->reserved_pebs > ubi->avail_pebs) { if (vol->reserved_pebs > ubi->avail_pebs) {
ubi_err("not enough PEBs, only %d available", ubi->avail_pebs); ubi_err(ubi, "not enough PEBs, only %d available",
ubi->avail_pebs);
if (ubi->corr_peb_count) if (ubi->corr_peb_count)
ubi_err("%d PEBs are corrupted and not used", ubi_err(ubi, "%d PEBs are corrupted and not used",
ubi->corr_peb_count); ubi->corr_peb_count);
err = -ENOSPC; err = -ENOSPC;
goto out_unlock; goto out_unlock;
...@@ -314,7 +316,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) ...@@ -314,7 +316,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
dev = MKDEV(MAJOR(ubi->cdev.dev), vol_id + 1); dev = MKDEV(MAJOR(ubi->cdev.dev), vol_id + 1);
err = cdev_add(&vol->cdev, dev, 1); err = cdev_add(&vol->cdev, dev, 1);
if (err) { if (err) {
ubi_err("cannot add character device"); ubi_err(ubi, "cannot add character device");
goto out_mapping; goto out_mapping;
} }
...@@ -326,7 +328,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) ...@@ -326,7 +328,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id); dev_set_name(&vol->dev, "%s_%d", ubi->ubi_name, vol->vol_id);
err = device_register(&vol->dev); err = device_register(&vol->dev);
if (err) { if (err) {
ubi_err("cannot register device"); ubi_err(ubi, "cannot register device");
goto out_cdev; goto out_cdev;
} }
...@@ -386,7 +388,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req) ...@@ -386,7 +388,7 @@ int ubi_create_volume(struct ubi_device *ubi, struct ubi_mkvol_req *req)
kfree(vol); kfree(vol);
else else
put_device(&vol->dev); put_device(&vol->dev);
ubi_err("cannot create volume %d, error %d", vol_id, err); ubi_err(ubi, "cannot create volume %d, error %d", vol_id, err);
return err; return err;
} }
...@@ -454,7 +456,7 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl) ...@@ -454,7 +456,7 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
return err; return err;
out_err: out_err:
ubi_err("cannot remove volume %d, error %d", vol_id, err); ubi_err(ubi, "cannot remove volume %d, error %d", vol_id, err);
spin_lock(&ubi->volumes_lock); spin_lock(&ubi->volumes_lock);
ubi->volumes[vol_id] = vol; ubi->volumes[vol_id] = vol;
out_unlock: out_unlock:
...@@ -487,7 +489,7 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) ...@@ -487,7 +489,7 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
if (vol->vol_type == UBI_STATIC_VOLUME && if (vol->vol_type == UBI_STATIC_VOLUME &&
reserved_pebs < vol->used_ebs) { reserved_pebs < vol->used_ebs) {
ubi_err("too small size %d, %d LEBs contain data", ubi_err(ubi, "too small size %d, %d LEBs contain data",
reserved_pebs, vol->used_ebs); reserved_pebs, vol->used_ebs);
return -EINVAL; return -EINVAL;
} }
...@@ -516,10 +518,10 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) ...@@ -516,10 +518,10 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs)
if (pebs > 0) { if (pebs > 0) {
spin_lock(&ubi->volumes_lock); spin_lock(&ubi->volumes_lock);
if (pebs > ubi->avail_pebs) { if (pebs > ubi->avail_pebs) {
ubi_err("not enough PEBs: requested %d, available %d", ubi_err(ubi, "not enough PEBs: requested %d, available %d",
pebs, ubi->avail_pebs); pebs, ubi->avail_pebs);
if (ubi->corr_peb_count) if (ubi->corr_peb_count)
ubi_err("%d PEBs are corrupted and not used", ubi_err(ubi, "%d PEBs are corrupted and not used",
ubi->corr_peb_count); ubi->corr_peb_count);
spin_unlock(&ubi->volumes_lock); spin_unlock(&ubi->volumes_lock);
err = -ENOSPC; err = -ENOSPC;
...@@ -643,7 +645,7 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol) ...@@ -643,7 +645,7 @@ int ubi_add_volume(struct ubi_device *ubi, struct ubi_volume *vol)
dev = MKDEV(MAJOR(ubi->cdev.dev), vol->vol_id + 1); dev = MKDEV(MAJOR(ubi->cdev.dev), vol->vol_id + 1);
err = cdev_add(&vol->cdev, dev, 1); err = cdev_add(&vol->cdev, dev, 1);
if (err) { if (err) {
ubi_err("cannot add character device for volume %d, error %d", ubi_err(ubi, "cannot add character device for volume %d, error %d",
vol_id, err); vol_id, err);
return err; return err;
} }
...@@ -710,7 +712,7 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id) ...@@ -710,7 +712,7 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id)
if (!vol) { if (!vol) {
if (reserved_pebs) { if (reserved_pebs) {
ubi_err("no volume info, but volume exists"); ubi_err(ubi, "no volume info, but volume exists");
goto fail; goto fail;
} }
spin_unlock(&ubi->volumes_lock); spin_unlock(&ubi->volumes_lock);
...@@ -719,90 +721,91 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id) ...@@ -719,90 +721,91 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id)
if (vol->reserved_pebs < 0 || vol->alignment < 0 || vol->data_pad < 0 || if (vol->reserved_pebs < 0 || vol->alignment < 0 || vol->data_pad < 0 ||
vol->name_len < 0) { vol->name_len < 0) {
ubi_err("negative values"); ubi_err(ubi, "negative values");
goto fail; goto fail;
} }
if (vol->alignment > ubi->leb_size || vol->alignment == 0) { if (vol->alignment > ubi->leb_size || vol->alignment == 0) {
ubi_err("bad alignment"); ubi_err(ubi, "bad alignment");
goto fail; goto fail;
} }
n = vol->alignment & (ubi->min_io_size - 1); n = vol->alignment & (ubi->min_io_size - 1);
if (vol->alignment != 1 && n) { if (vol->alignment != 1 && n) {
ubi_err("alignment is not multiple of min I/O unit"); ubi_err(ubi, "alignment is not multiple of min I/O unit");
goto fail; goto fail;
} }
n = ubi->leb_size % vol->alignment; n = ubi->leb_size % vol->alignment;
if (vol->data_pad != n) { if (vol->data_pad != n) {
ubi_err("bad data_pad, has to be %lld", n); ubi_err(ubi, "bad data_pad, has to be %lld", n);
goto fail; goto fail;
} }
if (vol->vol_type != UBI_DYNAMIC_VOLUME && if (vol->vol_type != UBI_DYNAMIC_VOLUME &&
vol->vol_type != UBI_STATIC_VOLUME) { vol->vol_type != UBI_STATIC_VOLUME) {
ubi_err("bad vol_type"); ubi_err(ubi, "bad vol_type");
goto fail; goto fail;
} }
if (vol->upd_marker && vol->corrupted) { if (vol->upd_marker && vol->corrupted) {
ubi_err("update marker and corrupted simultaneously"); ubi_err(ubi, "update marker and corrupted simultaneously");
goto fail; goto fail;
} }
if (vol->reserved_pebs > ubi->good_peb_count) { if (vol->reserved_pebs > ubi->good_peb_count) {
ubi_err("too large reserved_pebs"); ubi_err(ubi, "too large reserved_pebs");
goto fail; goto fail;
} }
n = ubi->leb_size - vol->data_pad; n = ubi->leb_size - vol->data_pad;
if (vol->usable_leb_size != ubi->leb_size - vol->data_pad) { if (vol->usable_leb_size != ubi->leb_size - vol->data_pad) {
ubi_err("bad usable_leb_size, has to be %lld", n); ubi_err(ubi, "bad usable_leb_size, has to be %lld", n);
goto fail; goto fail;
} }
if (vol->name_len > UBI_VOL_NAME_MAX) { if (vol->name_len > UBI_VOL_NAME_MAX) {
ubi_err("too long volume name, max is %d", UBI_VOL_NAME_MAX); ubi_err(ubi, "too long volume name, max is %d",
UBI_VOL_NAME_MAX);
goto fail; goto fail;
} }
n = strnlen(vol->name, vol->name_len + 1); n = strnlen(vol->name, vol->name_len + 1);
if (n != vol->name_len) { if (n != vol->name_len) {
ubi_err("bad name_len %lld", n); ubi_err(ubi, "bad name_len %lld", n);
goto fail; goto fail;
} }
n = (long long)vol->used_ebs * vol->usable_leb_size; n = (long long)vol->used_ebs * vol->usable_leb_size;
if (vol->vol_type == UBI_DYNAMIC_VOLUME) { if (vol->vol_type == UBI_DYNAMIC_VOLUME) {
if (vol->corrupted) { if (vol->corrupted) {
ubi_err("corrupted dynamic volume"); ubi_err(ubi, "corrupted dynamic volume");
goto fail; goto fail;
} }
if (vol->used_ebs != vol->reserved_pebs) { if (vol->used_ebs != vol->reserved_pebs) {
ubi_err("bad used_ebs"); ubi_err(ubi, "bad used_ebs");
goto fail; goto fail;
} }
if (vol->last_eb_bytes != vol->usable_leb_size) { if (vol->last_eb_bytes != vol->usable_leb_size) {
ubi_err("bad last_eb_bytes"); ubi_err(ubi, "bad last_eb_bytes");
goto fail; goto fail;
} }
if (vol->used_bytes != n) { if (vol->used_bytes != n) {
ubi_err("bad used_bytes"); ubi_err(ubi, "bad used_bytes");
goto fail; goto fail;
} }
} else { } else {
if (vol->used_ebs < 0 || vol->used_ebs > vol->reserved_pebs) { if (vol->used_ebs < 0 || vol->used_ebs > vol->reserved_pebs) {
ubi_err("bad used_ebs"); ubi_err(ubi, "bad used_ebs");
goto fail; goto fail;
} }
if (vol->last_eb_bytes < 0 || if (vol->last_eb_bytes < 0 ||
vol->last_eb_bytes > vol->usable_leb_size) { vol->last_eb_bytes > vol->usable_leb_size) {
ubi_err("bad last_eb_bytes"); ubi_err(ubi, "bad last_eb_bytes");
goto fail; goto fail;
} }
if (vol->used_bytes < 0 || vol->used_bytes > n || if (vol->used_bytes < 0 || vol->used_bytes > n ||
vol->used_bytes < n - vol->usable_leb_size) { vol->used_bytes < n - vol->usable_leb_size) {
ubi_err("bad used_bytes"); ubi_err(ubi, "bad used_bytes");
goto fail; goto fail;
} }
} }
...@@ -820,7 +823,7 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id) ...@@ -820,7 +823,7 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id)
if (alignment != vol->alignment || data_pad != vol->data_pad || if (alignment != vol->alignment || data_pad != vol->data_pad ||
upd_marker != vol->upd_marker || vol_type != vol->vol_type || upd_marker != vol->upd_marker || vol_type != vol->vol_type ||
name_len != vol->name_len || strncmp(name, vol->name, name_len)) { name_len != vol->name_len || strncmp(name, vol->name, name_len)) {
ubi_err("volume info is different"); ubi_err(ubi, "volume info is different");
goto fail; goto fail;
} }
...@@ -828,7 +831,7 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id) ...@@ -828,7 +831,7 @@ static int self_check_volume(struct ubi_device *ubi, int vol_id)
return 0; return 0;
fail: fail:
ubi_err("self-check failed for volume %d", vol_id); ubi_err(ubi, "self-check failed for volume %d", vol_id);
if (vol) if (vol)
ubi_dump_vol_info(vol); ubi_dump_vol_info(vol);
ubi_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id); ubi_dump_vtbl_record(&ubi->vtbl[vol_id], vol_id);
......
...@@ -30,9 +30,12 @@ ...@@ -30,9 +30,12 @@
* eraseblock stores one volume table copy, i.e. LEB 0 and LEB 1 duplicate each * eraseblock stores one volume table copy, i.e. LEB 0 and LEB 1 duplicate each
* other. This redundancy guarantees robustness to unclean reboots. The volume * other. This redundancy guarantees robustness to unclean reboots. The volume
* table is basically an array of volume table records. Each record contains * table is basically an array of volume table records. Each record contains
* full information about the volume and protected by a CRC checksum. * full information about the volume and protected by a CRC checksum. Note,
* nowadays we use the atomic LEB change operation when updating the volume
* table, so we do not really need 2 LEBs anymore, but we preserve the older
* design for the backward compatibility reasons.
* *
* The volume table is changed, it is first changed in RAM. Then LEB 0 is * When the volume table is changed, it is first changed in RAM. Then LEB 0 is
* erased, and the updated volume table is written back to LEB 0. Then same for * erased, and the updated volume table is written back to LEB 0. Then same for
* LEB 1. This scheme guarantees recoverability from unclean reboots. * LEB 1. This scheme guarantees recoverability from unclean reboots.
* *
...@@ -96,12 +99,8 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx, ...@@ -96,12 +99,8 @@ int ubi_change_vtbl_record(struct ubi_device *ubi, int idx,
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++) {
err = ubi_eba_unmap_leb(ubi, layout_vol, i); err = ubi_eba_atomic_leb_change(ubi, layout_vol, i, ubi->vtbl,
if (err) ubi->vtbl_size);
return err;
err = ubi_eba_write_leb(ubi, layout_vol, i, ubi->vtbl, 0,
ubi->vtbl_size);
if (err) if (err)
return err; return err;
} }
...@@ -148,12 +147,8 @@ int ubi_vtbl_rename_volumes(struct ubi_device *ubi, ...@@ -148,12 +147,8 @@ int ubi_vtbl_rename_volumes(struct ubi_device *ubi,
layout_vol = ubi->volumes[vol_id2idx(ubi, UBI_LAYOUT_VOLUME_ID)]; layout_vol = ubi->volumes[vol_id2idx(ubi, UBI_LAYOUT_VOLUME_ID)];
for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) { for (i = 0; i < UBI_LAYOUT_VOLUME_EBS; i++) {
err = ubi_eba_unmap_leb(ubi, layout_vol, i); err = ubi_eba_atomic_leb_change(ubi, layout_vol, i, ubi->vtbl,
if (err) ubi->vtbl_size);
return err;
err = ubi_eba_write_leb(ubi, layout_vol, i, ubi->vtbl, 0,
ubi->vtbl_size);
if (err) if (err)
return err; return err;
} }
...@@ -190,7 +185,7 @@ static int vtbl_check(const struct ubi_device *ubi, ...@@ -190,7 +185,7 @@ static int vtbl_check(const struct ubi_device *ubi,
crc = crc32(UBI_CRC32_INIT, &vtbl[i], UBI_VTBL_RECORD_SIZE_CRC); crc = crc32(UBI_CRC32_INIT, &vtbl[i], UBI_VTBL_RECORD_SIZE_CRC);
if (be32_to_cpu(vtbl[i].crc) != crc) { if (be32_to_cpu(vtbl[i].crc) != crc) {
ubi_err("bad CRC at record %u: %#08x, not %#08x", ubi_err(ubi, "bad CRC at record %u: %#08x, not %#08x",
i, crc, be32_to_cpu(vtbl[i].crc)); i, crc, be32_to_cpu(vtbl[i].crc));
ubi_dump_vtbl_record(&vtbl[i], i); ubi_dump_vtbl_record(&vtbl[i], i);
return 1; return 1;
...@@ -224,7 +219,7 @@ static int vtbl_check(const struct ubi_device *ubi, ...@@ -224,7 +219,7 @@ static int vtbl_check(const struct ubi_device *ubi,
n = ubi->leb_size % alignment; n = ubi->leb_size % alignment;
if (data_pad != n) { if (data_pad != n) {
ubi_err("bad data_pad, has to be %d", n); ubi_err(ubi, "bad data_pad, has to be %d", n);
err = 6; err = 6;
goto bad; goto bad;
} }
...@@ -240,7 +235,7 @@ static int vtbl_check(const struct ubi_device *ubi, ...@@ -240,7 +235,7 @@ static int vtbl_check(const struct ubi_device *ubi,
} }
if (reserved_pebs > ubi->good_peb_count) { if (reserved_pebs > ubi->good_peb_count) {
ubi_err("too large reserved_pebs %d, good PEBs %d", ubi_err(ubi, "too large reserved_pebs %d, good PEBs %d",
reserved_pebs, ubi->good_peb_count); reserved_pebs, ubi->good_peb_count);
err = 9; err = 9;
goto bad; goto bad;
...@@ -270,7 +265,7 @@ static int vtbl_check(const struct ubi_device *ubi, ...@@ -270,7 +265,7 @@ static int vtbl_check(const struct ubi_device *ubi,
if (len1 > 0 && len1 == len2 && if (len1 > 0 && len1 == len2 &&
!strncmp(vtbl[i].name, vtbl[n].name, len1)) { !strncmp(vtbl[i].name, vtbl[n].name, len1)) {
ubi_err("volumes %d and %d have the same name \"%s\"", ubi_err(ubi, "volumes %d and %d have the same name \"%s\"",
i, n, vtbl[i].name); i, n, vtbl[i].name);
ubi_dump_vtbl_record(&vtbl[i], i); ubi_dump_vtbl_record(&vtbl[i], i);
ubi_dump_vtbl_record(&vtbl[n], n); ubi_dump_vtbl_record(&vtbl[n], n);
...@@ -282,7 +277,7 @@ static int vtbl_check(const struct ubi_device *ubi, ...@@ -282,7 +277,7 @@ static int vtbl_check(const struct ubi_device *ubi,
return 0; return 0;
bad: bad:
ubi_err("volume table check failed: record %d, error %d", i, err); ubi_err(ubi, "volume table check failed: record %d, error %d", i, err);
ubi_dump_vtbl_record(&vtbl[i], i); ubi_dump_vtbl_record(&vtbl[i], i);
return -EINVAL; return -EINVAL;
} }
...@@ -446,11 +441,11 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, ...@@ -446,11 +441,11 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
leb_corrupted[1] = memcmp(leb[0], leb[1], leb_corrupted[1] = memcmp(leb[0], leb[1],
ubi->vtbl_size); ubi->vtbl_size);
if (leb_corrupted[1]) { if (leb_corrupted[1]) {
ubi_warn("volume table copy #2 is corrupted"); ubi_warn(ubi, "volume table copy #2 is corrupted");
err = create_vtbl(ubi, ai, 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(ubi, "volume table was restored");
} }
/* Both LEB 1 and LEB 2 are OK and consistent */ /* Both LEB 1 and LEB 2 are OK and consistent */
...@@ -465,15 +460,15 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi, ...@@ -465,15 +460,15 @@ static struct ubi_vtbl_record *process_lvol(struct ubi_device *ubi,
} }
if (leb_corrupted[1]) { if (leb_corrupted[1]) {
/* Both LEB 0 and LEB 1 are corrupted */ /* Both LEB 0 and LEB 1 are corrupted */
ubi_err("both volume tables are corrupted"); ubi_err(ubi, "both volume tables are corrupted");
goto out_free; goto out_free;
} }
ubi_warn("volume table copy #1 is corrupted"); ubi_warn(ubi, "volume table copy #1 is corrupted");
err = create_vtbl(ubi, ai, 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(ubi, "volume table was restored");
vfree(leb[0]); vfree(leb[0]);
return leb[1]; return leb[1];
...@@ -562,7 +557,7 @@ static int init_volumes(struct ubi_device *ubi, ...@@ -562,7 +557,7 @@ static int init_volumes(struct ubi_device *ubi,
if (vtbl[i].flags & UBI_VTBL_AUTORESIZE_FLG) { if (vtbl[i].flags & UBI_VTBL_AUTORESIZE_FLG) {
/* Auto re-size flag may be set only for one volume */ /* Auto re-size flag may be set only for one volume */
if (ubi->autoresize_vol_id != -1) { if (ubi->autoresize_vol_id != -1) {
ubi_err("more than one auto-resize volume (%d and %d)", ubi_err(ubi, "more than one auto-resize volume (%d and %d)",
ubi->autoresize_vol_id, i); ubi->autoresize_vol_id, i);
kfree(vol); kfree(vol);
return -EINVAL; return -EINVAL;
...@@ -608,7 +603,7 @@ static int init_volumes(struct ubi_device *ubi, ...@@ -608,7 +603,7 @@ static int init_volumes(struct ubi_device *ubi,
* We found a static volume which misses several * We found a static volume which misses several
* eraseblocks. Treat it as corrupted. * eraseblocks. Treat it as corrupted.
*/ */
ubi_warn("static volume %d misses %d LEBs - corrupted", ubi_warn(ubi, "static volume %d misses %d LEBs - corrupted",
av->vol_id, av->used_ebs - av->leb_count); av->vol_id, av->used_ebs - av->leb_count);
vol->corrupted = 1; vol->corrupted = 1;
continue; continue;
...@@ -646,10 +641,10 @@ static int init_volumes(struct ubi_device *ubi, ...@@ -646,10 +641,10 @@ static int init_volumes(struct ubi_device *ubi,
vol->ubi = ubi; vol->ubi = ubi;
if (reserved_pebs > ubi->avail_pebs) { if (reserved_pebs > ubi->avail_pebs) {
ubi_err("not enough PEBs, required %d, available %d", ubi_err(ubi, "not enough PEBs, required %d, available %d",
reserved_pebs, ubi->avail_pebs); reserved_pebs, ubi->avail_pebs);
if (ubi->corr_peb_count) if (ubi->corr_peb_count)
ubi_err("%d PEBs are corrupted and not used", ubi_err(ubi, "%d PEBs are corrupted and not used",
ubi->corr_peb_count); ubi->corr_peb_count);
} }
ubi->rsvd_pebs += reserved_pebs; ubi->rsvd_pebs += reserved_pebs;
...@@ -660,13 +655,14 @@ static int init_volumes(struct ubi_device *ubi, ...@@ -660,13 +655,14 @@ static int init_volumes(struct ubi_device *ubi,
/** /**
* check_av - check volume attaching information. * check_av - check volume attaching information.
* @ubi: UBI device description object
* @vol: UBI volume description object * @vol: UBI volume description object
* @av: volume attaching information * @av: volume attaching information
* *
* This function returns zero if the volume attaching 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_av(const struct ubi_volume *vol, static int check_av(const struct ubi_device *ubi, const struct ubi_volume *vol,
const struct ubi_ainf_volume *av) const struct ubi_ainf_volume *av)
{ {
int err; int err;
...@@ -694,7 +690,7 @@ static int check_av(const struct ubi_volume *vol, ...@@ -694,7 +690,7 @@ static int check_av(const struct ubi_volume *vol,
return 0; return 0;
bad: bad:
ubi_err("bad attaching information, error %d", err); ubi_err(ubi, "bad attaching information, error %d", err);
ubi_dump_av(av); ubi_dump_av(av);
ubi_dump_vol_info(vol); ubi_dump_vol_info(vol);
return -EINVAL; return -EINVAL;
...@@ -718,14 +714,15 @@ static int check_attaching_info(const struct ubi_device *ubi, ...@@ -718,14 +714,15 @@ static int check_attaching_info(const struct ubi_device *ubi,
struct ubi_volume *vol; struct ubi_volume *vol;
if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) { if (ai->vols_found > UBI_INT_VOL_COUNT + ubi->vtbl_slots) {
ubi_err("found %d volumes while attaching, maximum is %d + %d", ubi_err(ubi, "found %d volumes while attaching, maximum is %d + %d",
ai->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots); ai->vols_found, UBI_INT_VOL_COUNT, ubi->vtbl_slots);
return -EINVAL; return -EINVAL;
} }
if (ai->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT && if (ai->highest_vol_id >= ubi->vtbl_slots + UBI_INT_VOL_COUNT &&
ai->highest_vol_id < UBI_INTERNAL_VOL_START) { ai->highest_vol_id < UBI_INTERNAL_VOL_START) {
ubi_err("too large volume ID %d found", ai->highest_vol_id); ubi_err(ubi, "too large volume ID %d found",
ai->highest_vol_id);
return -EINVAL; return -EINVAL;
} }
...@@ -753,10 +750,10 @@ static int check_attaching_info(const struct ubi_device *ubi, ...@@ -753,10 +750,10 @@ static int check_attaching_info(const struct ubi_device *ubi,
* reboot while the volume was being removed. Discard * reboot while the volume was being removed. Discard
* these eraseblocks. * these eraseblocks.
*/ */
ubi_msg("finish volume %d removal", av->vol_id); ubi_msg(ubi, "finish volume %d removal", av->vol_id);
ubi_remove_av(ai, av); ubi_remove_av(ai, av);
} else if (av) { } else if (av) {
err = check_av(vol, av); err = check_av(ubi, vol, av);
if (err) if (err)
return err; return err;
} }
...@@ -807,13 +804,13 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -807,13 +804,13 @@ int ubi_read_volume_table(struct ubi_device *ubi, struct ubi_attach_info *ai)
if (IS_ERR(ubi->vtbl)) if (IS_ERR(ubi->vtbl))
return PTR_ERR(ubi->vtbl); return PTR_ERR(ubi->vtbl);
} else { } else {
ubi_err("the layout volume was not found"); ubi_err(ubi, "the layout volume was not found");
return -EINVAL; return -EINVAL;
} }
} else { } else {
if (av->leb_count > UBI_LAYOUT_VOLUME_EBS) { if (av->leb_count > UBI_LAYOUT_VOLUME_EBS) {
/* This must not happen with proper UBI images */ /* This must not happen with proper UBI images */
ubi_err("too many LEBs (%d) in layout volume", ubi_err(ubi, "too many LEBs (%d) in layout volume",
av->leb_count); av->leb_count);
return -EINVAL; return -EINVAL;
} }
...@@ -862,7 +859,7 @@ static void self_vtbl_check(const struct ubi_device *ubi) ...@@ -862,7 +859,7 @@ static void self_vtbl_check(const struct ubi_device *ubi)
return; return;
if (vtbl_check(ubi, ubi->vtbl)) { if (vtbl_check(ubi, ubi->vtbl)) {
ubi_err("self-check failed"); ubi_err(ubi, "self-check failed");
BUG(); BUG();
} }
} }
...@@ -253,7 +253,7 @@ static int do_work(struct ubi_device *ubi) ...@@ -253,7 +253,7 @@ static int do_work(struct ubi_device *ubi)
*/ */
err = wrk->func(ubi, wrk, 0); err = wrk->func(ubi, wrk, 0);
if (err) if (err)
ubi_err("work failed with error code %d", err); ubi_err(ubi, "work failed with error code %d", err);
up_read(&ubi->work_sem); up_read(&ubi->work_sem);
return err; return err;
...@@ -470,8 +470,11 @@ struct ubi_wl_entry *ubi_wl_get_fm_peb(struct ubi_device *ubi, int anchor) ...@@ -470,8 +470,11 @@ struct ubi_wl_entry *ubi_wl_get_fm_peb(struct ubi_device *ubi, int anchor)
{ {
struct ubi_wl_entry *e = NULL; struct ubi_wl_entry *e = NULL;
if (!ubi->free.rb_node || (ubi->free_count - ubi->beb_rsvd_pebs < 1)) if (!ubi->free.rb_node || (ubi->free_count - ubi->beb_rsvd_pebs < 1)) {
ubi_warn(ubi, "Can't get peb for fastmap:anchor=%d, free_cnt=%d, reserved=%d",
anchor, ubi->free_count, ubi->beb_rsvd_pebs);
goto out; goto out;
}
if (anchor) if (anchor)
e = find_anchor_wl_entry(&ubi->free); e = find_anchor_wl_entry(&ubi->free);
...@@ -507,7 +510,7 @@ static int __wl_get_peb(struct ubi_device *ubi) ...@@ -507,7 +510,7 @@ static int __wl_get_peb(struct ubi_device *ubi)
retry: retry:
if (!ubi->free.rb_node) { if (!ubi->free.rb_node) {
if (ubi->works_count == 0) { if (ubi->works_count == 0) {
ubi_err("no free eraseblocks"); ubi_err(ubi, "no free eraseblocks");
ubi_assert(list_empty(&ubi->works)); ubi_assert(list_empty(&ubi->works));
return -ENOSPC; return -ENOSPC;
} }
...@@ -520,7 +523,7 @@ static int __wl_get_peb(struct ubi_device *ubi) ...@@ -520,7 +523,7 @@ static int __wl_get_peb(struct ubi_device *ubi)
e = find_mean_wl_entry(ubi, &ubi->free); e = find_mean_wl_entry(ubi, &ubi->free);
if (!e) { if (!e) {
ubi_err("no free eraseblocks"); ubi_err(ubi, "no free eraseblocks");
return -ENOSPC; return -ENOSPC;
} }
...@@ -692,7 +695,8 @@ int ubi_wl_get_peb(struct ubi_device *ubi) ...@@ -692,7 +695,8 @@ int ubi_wl_get_peb(struct ubi_device *ubi)
err = ubi_self_check_all_ff(ubi, peb, ubi->vid_hdr_aloffset, err = ubi_self_check_all_ff(ubi, peb, ubi->vid_hdr_aloffset,
ubi->peb_size - ubi->vid_hdr_aloffset); ubi->peb_size - ubi->vid_hdr_aloffset);
if (err) { if (err) {
ubi_err("new PEB %d does not contain all 0xFF bytes", peb); ubi_err(ubi, "new PEB %d does not contain all 0xFF bytes",
peb);
return err; return err;
} }
...@@ -760,7 +764,7 @@ static int sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, ...@@ -760,7 +764,7 @@ static int sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e,
* Erase counter overflow. Upgrade UBI and use 64-bit * Erase counter overflow. Upgrade UBI and use 64-bit
* erase counters internally. * erase counters internally.
*/ */
ubi_err("erase counter overflow at PEB %d, EC %llu", ubi_err(ubi, "erase counter overflow at PEB %d, EC %llu",
e->pnum, ec); e->pnum, ec);
err = -EINVAL; err = -EINVAL;
goto out_free; goto out_free;
...@@ -1137,7 +1141,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, ...@@ -1137,7 +1141,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
goto out_not_moved; goto out_not_moved;
} }
ubi_err("error %d while reading VID header from PEB %d", ubi_err(ubi, "error %d while reading VID header from PEB %d",
err, e1->pnum); err, e1->pnum);
goto out_error; goto out_error;
} }
...@@ -1181,7 +1185,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, ...@@ -1181,7 +1185,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
* UBI from trying to move it over and over again. * UBI from trying to move it over and over again.
*/ */
if (ubi->erroneous_peb_count > ubi->max_erroneous) { if (ubi->erroneous_peb_count > ubi->max_erroneous) {
ubi_err("too many erroneous eraseblocks (%d)", ubi_err(ubi, "too many erroneous eraseblocks (%d)",
ubi->erroneous_peb_count); ubi->erroneous_peb_count);
goto out_error; goto out_error;
} }
...@@ -1197,7 +1201,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, ...@@ -1197,7 +1201,7 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
/* The PEB has been successfully moved */ /* The PEB has been successfully moved */
if (scrubbing) if (scrubbing)
ubi_msg("scrubbed PEB %d (LEB %d:%d), data moved to PEB %d", ubi_msg(ubi, "scrubbed PEB %d (LEB %d:%d), data moved to PEB %d",
e1->pnum, vol_id, lnum, e2->pnum); e1->pnum, vol_id, lnum, e2->pnum);
ubi_free_vid_hdr(ubi, vid_hdr); ubi_free_vid_hdr(ubi, vid_hdr);
...@@ -1212,7 +1216,6 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, ...@@ -1212,7 +1216,6 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
err = do_sync_erase(ubi, e1, vol_id, lnum, 0); err = do_sync_erase(ubi, e1, vol_id, lnum, 0);
if (err) { if (err) {
kmem_cache_free(ubi_wl_entry_slab, e1);
if (e2) if (e2)
kmem_cache_free(ubi_wl_entry_slab, e2); kmem_cache_free(ubi_wl_entry_slab, e2);
goto out_ro; goto out_ro;
...@@ -1226,10 +1229,8 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, ...@@ -1226,10 +1229,8 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
dbg_wl("PEB %d (LEB %d:%d) was put meanwhile, erase", dbg_wl("PEB %d (LEB %d:%d) was put meanwhile, erase",
e2->pnum, vol_id, lnum); e2->pnum, vol_id, lnum);
err = do_sync_erase(ubi, e2, vol_id, lnum, 0); err = do_sync_erase(ubi, e2, vol_id, lnum, 0);
if (err) { if (err)
kmem_cache_free(ubi_wl_entry_slab, e2);
goto out_ro; goto out_ro;
}
} }
dbg_wl("done"); dbg_wl("done");
...@@ -1265,19 +1266,18 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk, ...@@ -1265,19 +1266,18 @@ static int wear_leveling_worker(struct ubi_device *ubi, struct ubi_work *wrk,
ubi_free_vid_hdr(ubi, vid_hdr); ubi_free_vid_hdr(ubi, vid_hdr);
err = do_sync_erase(ubi, e2, vol_id, lnum, torture); err = do_sync_erase(ubi, e2, vol_id, lnum, torture);
if (err) { if (err)
kmem_cache_free(ubi_wl_entry_slab, e2);
goto out_ro; goto out_ro;
}
mutex_unlock(&ubi->move_mutex); mutex_unlock(&ubi->move_mutex);
return 0; return 0;
out_error: out_error:
if (vol_id != -1) if (vol_id != -1)
ubi_err("error %d while moving PEB %d to PEB %d", ubi_err(ubi, "error %d while moving PEB %d to PEB %d",
err, e1->pnum, e2->pnum); err, e1->pnum, e2->pnum);
else else
ubi_err("error %d while moving PEB %d (LEB %d:%d) to PEB %d", ubi_err(ubi, "error %d while moving PEB %d (LEB %d:%d) to PEB %d",
err, e1->pnum, vol_id, lnum, e2->pnum); err, e1->pnum, vol_id, lnum, e2->pnum);
spin_lock(&ubi->wl_lock); spin_lock(&ubi->wl_lock);
ubi->move_from = ubi->move_to = NULL; ubi->move_from = ubi->move_to = NULL;
...@@ -1458,7 +1458,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, ...@@ -1458,7 +1458,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
return err; return err;
} }
ubi_err("failed to erase PEB %d, error %d", pnum, err); ubi_err(ubi, "failed to erase PEB %d, error %d", pnum, err);
kfree(wl_wrk); kfree(wl_wrk);
if (err == -EINTR || err == -ENOMEM || err == -EAGAIN || if (err == -EINTR || err == -ENOMEM || err == -EAGAIN ||
...@@ -1486,7 +1486,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, ...@@ -1486,7 +1486,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
/* It is %-EIO, the PEB went bad */ /* It is %-EIO, the PEB went bad */
if (!ubi->bad_allowed) { if (!ubi->bad_allowed) {
ubi_err("bad physical eraseblock %d detected", pnum); ubi_err(ubi, "bad physical eraseblock %d detected", pnum);
goto out_ro; goto out_ro;
} }
...@@ -1494,7 +1494,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, ...@@ -1494,7 +1494,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
if (ubi->beb_rsvd_pebs == 0) { if (ubi->beb_rsvd_pebs == 0) {
if (ubi->avail_pebs == 0) { if (ubi->avail_pebs == 0) {
spin_unlock(&ubi->volumes_lock); spin_unlock(&ubi->volumes_lock);
ubi_err("no reserved/available physical eraseblocks"); ubi_err(ubi, "no reserved/available physical eraseblocks");
goto out_ro; goto out_ro;
} }
ubi->avail_pebs -= 1; ubi->avail_pebs -= 1;
...@@ -1502,7 +1502,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, ...@@ -1502,7 +1502,7 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
} }
spin_unlock(&ubi->volumes_lock); spin_unlock(&ubi->volumes_lock);
ubi_msg("mark PEB %d as bad", pnum); ubi_msg(ubi, "mark PEB %d as bad", pnum);
err = ubi_io_mark_bad(ubi, pnum); err = ubi_io_mark_bad(ubi, pnum);
if (err) if (err)
goto out_ro; goto out_ro;
...@@ -1523,11 +1523,12 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk, ...@@ -1523,11 +1523,12 @@ static int erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk,
ubi->good_peb_count -= 1; ubi->good_peb_count -= 1;
ubi_calculate_reserved(ubi); ubi_calculate_reserved(ubi);
if (available_consumed) if (available_consumed)
ubi_warn("no PEBs in the reserved pool, used an available PEB"); ubi_warn(ubi, "no PEBs in the reserved pool, used an available PEB");
else if (ubi->beb_rsvd_pebs) else if (ubi->beb_rsvd_pebs)
ubi_msg("%d PEBs left in the reserve", ubi->beb_rsvd_pebs); ubi_msg(ubi, "%d PEBs left in the reserve",
ubi->beb_rsvd_pebs);
else else
ubi_warn("last PEB from the reserve was used"); ubi_warn(ubi, "last PEB from the reserve was used");
spin_unlock(&ubi->volumes_lock); spin_unlock(&ubi->volumes_lock);
return err; return err;
...@@ -1613,7 +1614,7 @@ int ubi_wl_put_peb(struct ubi_device *ubi, int vol_id, int lnum, ...@@ -1613,7 +1614,7 @@ int ubi_wl_put_peb(struct ubi_device *ubi, int vol_id, int lnum,
} else { } else {
err = prot_queue_del(ubi, e->pnum); err = prot_queue_del(ubi, e->pnum);
if (err) { if (err) {
ubi_err("PEB %d not found", pnum); ubi_err(ubi, "PEB %d not found", pnum);
ubi_ro_mode(ubi); ubi_ro_mode(ubi);
spin_unlock(&ubi->wl_lock); spin_unlock(&ubi->wl_lock);
return err; return err;
...@@ -1646,7 +1647,7 @@ int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum) ...@@ -1646,7 +1647,7 @@ int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum)
{ {
struct ubi_wl_entry *e; struct ubi_wl_entry *e;
ubi_msg("schedule PEB %d for scrubbing", pnum); ubi_msg(ubi, "schedule PEB %d for scrubbing", pnum);
retry: retry:
spin_lock(&ubi->wl_lock); spin_lock(&ubi->wl_lock);
...@@ -1678,7 +1679,7 @@ int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum) ...@@ -1678,7 +1679,7 @@ int ubi_wl_scrub_peb(struct ubi_device *ubi, int pnum)
err = prot_queue_del(ubi, e->pnum); err = prot_queue_del(ubi, e->pnum);
if (err) { if (err) {
ubi_err("PEB %d not found", pnum); ubi_err(ubi, "PEB %d not found", pnum);
ubi_ro_mode(ubi); ubi_ro_mode(ubi);
spin_unlock(&ubi->wl_lock); spin_unlock(&ubi->wl_lock);
return err; return err;
...@@ -1798,15 +1799,18 @@ int ubi_thread(void *u) ...@@ -1798,15 +1799,18 @@ int ubi_thread(void *u)
int failures = 0; int failures = 0;
struct ubi_device *ubi = u; struct ubi_device *ubi = u;
ubi_msg("background thread \"%s\" started, PID %d", ubi_msg(ubi, "background thread \"%s\" started, PID %d",
ubi->bgt_name, task_pid_nr(current)); ubi->bgt_name, task_pid_nr(current));
set_freezable(); set_freezable();
for (;;) { for (;;) {
int err; int err;
if (kthread_should_stop()) if (kthread_should_stop()) {
ubi_msg(ubi, "background thread \"%s\" should stop, PID %d",
ubi->bgt_name, task_pid_nr(current));
break; break;
}
if (try_to_freeze()) if (try_to_freeze())
continue; continue;
...@@ -1823,14 +1827,14 @@ int ubi_thread(void *u) ...@@ -1823,14 +1827,14 @@ int ubi_thread(void *u)
err = do_work(ubi); err = do_work(ubi);
if (err) { if (err) {
ubi_err("%s: work failed with error code %d", ubi_err(ubi, "%s: work failed with error code %d",
ubi->bgt_name, err); ubi->bgt_name, err);
if (failures++ > WL_MAX_FAILURES) { if (failures++ > WL_MAX_FAILURES) {
/* /*
* Too many failures, disable the thread and * Too many failures, disable the thread and
* switch to read-only mode. * switch to read-only mode.
*/ */
ubi_msg("%s: %d consecutive failures", ubi_msg(ubi, "%s: %d consecutive failures",
ubi->bgt_name, WL_MAX_FAILURES); ubi->bgt_name, WL_MAX_FAILURES);
ubi_ro_mode(ubi); ubi_ro_mode(ubi);
ubi->thread_enabled = 0; ubi->thread_enabled = 0;
...@@ -1981,10 +1985,10 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai) ...@@ -1981,10 +1985,10 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
#endif #endif
if (ubi->avail_pebs < reserved_pebs) { if (ubi->avail_pebs < reserved_pebs) {
ubi_err("no enough physical eraseblocks (%d, need %d)", ubi_err(ubi, "no enough physical eraseblocks (%d, need %d)",
ubi->avail_pebs, reserved_pebs); ubi->avail_pebs, reserved_pebs);
if (ubi->corr_peb_count) if (ubi->corr_peb_count)
ubi_err("%d PEBs are corrupted and not used", ubi_err(ubi, "%d PEBs are corrupted and not used",
ubi->corr_peb_count); ubi->corr_peb_count);
goto out_free; goto out_free;
} }
...@@ -2072,8 +2076,8 @@ static int self_check_ec(struct ubi_device *ubi, int pnum, int ec) ...@@ -2072,8 +2076,8 @@ static int self_check_ec(struct ubi_device *ubi, int pnum, int ec)
read_ec = be64_to_cpu(ec_hdr->ec); read_ec = be64_to_cpu(ec_hdr->ec);
if (ec != read_ec && read_ec - ec > 1) { if (ec != read_ec && read_ec - ec > 1) {
ubi_err("self-check failed for PEB %d", pnum); ubi_err(ubi, "self-check failed for PEB %d", pnum);
ubi_err("read EC is %lld, should be %d", read_ec, ec); ubi_err(ubi, "read EC is %lld, should be %d", read_ec, ec);
dump_stack(); dump_stack();
err = 1; err = 1;
} else } else
...@@ -2102,7 +2106,7 @@ static int self_check_in_wl_tree(const struct ubi_device *ubi, ...@@ -2102,7 +2106,7 @@ static int self_check_in_wl_tree(const struct ubi_device *ubi,
if (in_wl_tree(e, root)) if (in_wl_tree(e, root))
return 0; return 0;
ubi_err("self-check failed for PEB %d, EC %d, RB-tree %p ", ubi_err(ubi, "self-check failed for PEB %d, EC %d, RB-tree %p ",
e->pnum, e->ec, root); e->pnum, e->ec, root);
dump_stack(); dump_stack();
return -EINVAL; return -EINVAL;
...@@ -2130,7 +2134,7 @@ static int self_check_in_pq(const struct ubi_device *ubi, ...@@ -2130,7 +2134,7 @@ static int self_check_in_pq(const struct ubi_device *ubi,
if (p == e) if (p == e)
return 0; return 0;
ubi_err("self-check failed for PEB %d, EC %d, Protect queue", ubi_err(ubi, "self-check failed for PEB %d, EC %d, Protect queue",
e->pnum, e->ec); e->pnum, e->ec);
dump_stack(); dump_stack();
return -EINVAL; return -EINVAL;
......
...@@ -262,6 +262,7 @@ static int write_begin_slow(struct address_space *mapping, ...@@ -262,6 +262,7 @@ static int write_begin_slow(struct address_space *mapping,
if (err) { if (err) {
unlock_page(page); unlock_page(page);
page_cache_release(page); page_cache_release(page);
ubifs_release_budget(c, &req);
return err; return err;
} }
} }
......
...@@ -571,7 +571,11 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir, ...@@ -571,7 +571,11 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
aligned_dlen = ALIGN(dlen, 8); aligned_dlen = ALIGN(dlen, 8);
aligned_ilen = ALIGN(ilen, 8); aligned_ilen = ALIGN(ilen, 8);
len = aligned_dlen + aligned_ilen + UBIFS_INO_NODE_SZ; len = aligned_dlen + aligned_ilen + UBIFS_INO_NODE_SZ;
/* Make sure to also account for extended attributes */
len += host_ui->data_len;
dent = kmalloc(len, GFP_NOFS); dent = kmalloc(len, GFP_NOFS);
if (!dent) if (!dent)
return -ENOMEM; return -ENOMEM;
...@@ -648,7 +652,8 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir, ...@@ -648,7 +652,8 @@ int ubifs_jnl_update(struct ubifs_info *c, const struct inode *dir,
ino_key_init(c, &ino_key, dir->i_ino); ino_key_init(c, &ino_key, dir->i_ino);
ino_offs += aligned_ilen; ino_offs += aligned_ilen;
err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs, UBIFS_INO_NODE_SZ); err = ubifs_tnc_add(c, &ino_key, lnum, ino_offs,
UBIFS_INO_NODE_SZ + host_ui->data_len);
if (err) if (err)
goto out_ro; goto out_ro;
......
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