summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-05-27 21:49:29 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-27 21:49:29 -0400
commit23a3e178b9f8be3a900c7b11d795e54b4a131af0 (patch)
tree36555d6da836a1df9918313d2a1cbefba3ca2123 /drivers
parente0714ec4f9efe7b86828b0dcc077fd8f5d8e5e91 (diff)
parent1112018cefc586cba924770a2b28bff6d2f0aa5c (diff)
Merge tag 'upstream-4.7-rc1' of git://git.infradead.org/linux-ubifs
Pull UBI/UBIFS updates from Richard Weinberger: "This contains mostly cleanups and minor improvements of UBI and UBIFS" * tag 'upstream-4.7-rc1' of git://git.infradead.org/linux-ubifs: ubifs: ubifs_dump_inode: Fix dumping field bulk_read UBI: Fix static volume checks when Fastmap is used UBI: Set free_count to zero before walking through erase list UBI: Silence an unintialized variable warning UBI: Clean up return in ubi_remove_volume() UBI: Modify wrong comment in ubi_leb_map function. UBI: Don't read back all data in ubi_eba_copy_leb() UBI: Add ro-mode sysfs attribute
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/ubi/build.c5
-rw-r--r--drivers/mtd/ubi/debug.c3
-rw-r--r--drivers/mtd/ubi/eba.c47
-rw-r--r--drivers/mtd/ubi/fastmap.c1
-rw-r--r--drivers/mtd/ubi/kapi.c2
-rw-r--r--drivers/mtd/ubi/ubi.h2
-rw-r--r--drivers/mtd/ubi/vmt.c2
-rw-r--r--drivers/mtd/ubi/wl.c2
8 files changed, 32 insertions, 32 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c
index a7d1febf667a..16baeb51b2bd 100644
--- a/drivers/mtd/ubi/build.c
+++ b/drivers/mtd/ubi/build.c
@@ -149,6 +149,8 @@ static struct device_attribute dev_bgt_enabled =
149 __ATTR(bgt_enabled, S_IRUGO, dev_attribute_show, NULL); 149 __ATTR(bgt_enabled, S_IRUGO, dev_attribute_show, NULL);
150static struct device_attribute dev_mtd_num = 150static struct device_attribute dev_mtd_num =
151 __ATTR(mtd_num, S_IRUGO, dev_attribute_show, NULL); 151 __ATTR(mtd_num, S_IRUGO, dev_attribute_show, NULL);
152static struct device_attribute dev_ro_mode =
153 __ATTR(ro_mode, S_IRUGO, dev_attribute_show, NULL);
152 154
153/** 155/**
154 * ubi_volume_notify - send a volume change notification. 156 * ubi_volume_notify - send a volume change notification.
@@ -385,6 +387,8 @@ static ssize_t dev_attribute_show(struct device *dev,
385 ret = sprintf(buf, "%d\n", ubi->thread_enabled); 387 ret = sprintf(buf, "%d\n", ubi->thread_enabled);
386 else if (attr == &dev_mtd_num) 388 else if (attr == &dev_mtd_num)
387 ret = sprintf(buf, "%d\n", ubi->mtd->index); 389 ret = sprintf(buf, "%d\n", ubi->mtd->index);
390 else if (attr == &dev_ro_mode)
391 ret = sprintf(buf, "%d\n", ubi->ro_mode);
388 else 392 else
389 ret = -EINVAL; 393 ret = -EINVAL;
390 394
@@ -404,6 +408,7 @@ static struct attribute *ubi_dev_attrs[] = {
404 &dev_min_io_size.attr, 408 &dev_min_io_size.attr,
405 &dev_bgt_enabled.attr, 409 &dev_bgt_enabled.attr,
406 &dev_mtd_num.attr, 410 &dev_mtd_num.attr,
411 &dev_ro_mode.attr,
407 NULL 412 NULL
408}; 413};
409ATTRIBUTE_GROUPS(ubi_dev); 414ATTRIBUTE_GROUPS(ubi_dev);
diff --git a/drivers/mtd/ubi/debug.c b/drivers/mtd/ubi/debug.c
index c4cb15a3098c..f101a4985a7c 100644
--- a/drivers/mtd/ubi/debug.c
+++ b/drivers/mtd/ubi/debug.c
@@ -352,7 +352,8 @@ static ssize_t dfs_file_write(struct file *file, const char __user *user_buf,
352 } else if (dent == d->dfs_emulate_power_cut) { 352 } else if (dent == d->dfs_emulate_power_cut) {
353 if (kstrtoint(buf, 0, &val) != 0) 353 if (kstrtoint(buf, 0, &val) != 0)
354 count = -EINVAL; 354 count = -EINVAL;
355 d->emulate_power_cut = val; 355 else
356 d->emulate_power_cut = val;
356 goto out; 357 goto out;
357 } 358 }
358 359
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c
index 5b9834cf2820..5780dd1ba79d 100644
--- a/drivers/mtd/ubi/eba.c
+++ b/drivers/mtd/ubi/eba.c
@@ -426,8 +426,25 @@ retry:
426 pnum, vol_id, lnum); 426 pnum, vol_id, lnum);
427 err = -EBADMSG; 427 err = -EBADMSG;
428 } else { 428 } else {
429 err = -EINVAL; 429 /*
430 ubi_ro_mode(ubi); 430 * Ending up here in the non-Fastmap case
431 * is a clear bug as the VID header had to
432 * be present at scan time to have it referenced.
433 * With fastmap the story is more complicated.
434 * Fastmap has the mapping info without the need
435 * of a full scan. So the LEB could have been
436 * unmapped, Fastmap cannot know this and keeps
437 * the LEB referenced.
438 * This is valid and works as the layer above UBI
439 * has to do bookkeeping about used/referenced
440 * LEBs in any case.
441 */
442 if (ubi->fast_attach) {
443 err = -EBADMSG;
444 } else {
445 err = -EINVAL;
446 ubi_ro_mode(ubi);
447 }
431 } 448 }
432 } 449 }
433 goto out_free; 450 goto out_free;
@@ -1202,32 +1219,6 @@ int ubi_eba_copy_leb(struct ubi_device *ubi, int from, int to,
1202 } 1219 }
1203 1220
1204 cond_resched(); 1221 cond_resched();
1205
1206 /*
1207 * We've written the data and are going to read it back to make
1208 * sure it was written correctly.
1209 */
1210 memset(ubi->peb_buf, 0xFF, aldata_size);
1211 err = ubi_io_read_data(ubi, ubi->peb_buf, to, 0, aldata_size);
1212 if (err) {
1213 if (err != UBI_IO_BITFLIPS) {
1214 ubi_warn(ubi, "error %d while reading data back from PEB %d",
1215 err, to);
1216 if (is_error_sane(err))
1217 err = MOVE_TARGET_RD_ERR;
1218 } else
1219 err = MOVE_TARGET_BITFLIPS;
1220 goto out_unlock_buf;
1221 }
1222
1223 cond_resched();
1224
1225 if (crc != crc32(UBI_CRC32_INIT, ubi->peb_buf, data_size)) {
1226 ubi_warn(ubi, "read data back from PEB %d and it is different",
1227 to);
1228 err = -EINVAL;
1229 goto out_unlock_buf;
1230 }
1231 } 1222 }
1232 1223
1233 ubi_assert(vol->eba_tbl[lnum] == from); 1224 ubi_assert(vol->eba_tbl[lnum] == from);
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c
index 263b439e21a8..990898b9dc72 100644
--- a/drivers/mtd/ubi/fastmap.c
+++ b/drivers/mtd/ubi/fastmap.c
@@ -1058,6 +1058,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
1058 ubi_msg(ubi, "fastmap WL pool size: %d", 1058 ubi_msg(ubi, "fastmap WL pool size: %d",
1059 ubi->fm_wl_pool.max_size); 1059 ubi->fm_wl_pool.max_size);
1060 ubi->fm_disabled = 0; 1060 ubi->fm_disabled = 0;
1061 ubi->fast_attach = 1;
1061 1062
1062 ubi_free_vid_hdr(ubi, vh); 1063 ubi_free_vid_hdr(ubi, vh);
1063 kfree(ech); 1064 kfree(ech);
diff --git a/drivers/mtd/ubi/kapi.c b/drivers/mtd/ubi/kapi.c
index 437757c89b9e..348dbbcbedc8 100644
--- a/drivers/mtd/ubi/kapi.c
+++ b/drivers/mtd/ubi/kapi.c
@@ -705,7 +705,7 @@ int ubi_leb_map(struct ubi_volume_desc *desc, int lnum)
705 struct ubi_volume *vol = desc->vol; 705 struct ubi_volume *vol = desc->vol;
706 struct ubi_device *ubi = vol->ubi; 706 struct ubi_device *ubi = vol->ubi;
707 707
708 dbg_gen("unmap LEB %d:%d", vol->vol_id, lnum); 708 dbg_gen("map LEB %d:%d", vol->vol_id, lnum);
709 709
710 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME) 710 if (desc->mode == UBI_READONLY || vol->vol_type == UBI_STATIC_VOLUME)
711 return -EROFS; 711 return -EROFS;
diff --git a/drivers/mtd/ubi/ubi.h b/drivers/mtd/ubi/ubi.h
index dadc6a9d5755..61d4e99755a4 100644
--- a/drivers/mtd/ubi/ubi.h
+++ b/drivers/mtd/ubi/ubi.h
@@ -466,6 +466,7 @@ struct ubi_debug_info {
466 * @fm_eba_sem: allows ubi_update_fastmap() to block EBA table changes 466 * @fm_eba_sem: allows ubi_update_fastmap() to block EBA table changes
467 * @fm_work: fastmap work queue 467 * @fm_work: fastmap work queue
468 * @fm_work_scheduled: non-zero if fastmap work was scheduled 468 * @fm_work_scheduled: non-zero if fastmap work was scheduled
469 * @fast_attach: non-zero if UBI was attached by fastmap
469 * 470 *
470 * @used: RB-tree of used physical eraseblocks 471 * @used: RB-tree of used physical eraseblocks
471 * @erroneous: RB-tree of erroneous used physical eraseblocks 472 * @erroneous: RB-tree of erroneous used physical eraseblocks
@@ -574,6 +575,7 @@ struct ubi_device {
574 size_t fm_size; 575 size_t fm_size;
575 struct work_struct fm_work; 576 struct work_struct fm_work;
576 int fm_work_scheduled; 577 int fm_work_scheduled;
578 int fast_attach;
577 579
578 /* Wear-leveling sub-system's stuff */ 580 /* Wear-leveling sub-system's stuff */
579 struct rb_root used; 581 struct rb_root used;
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c
index 1ae17bb9b889..10059dfdc1b6 100644
--- a/drivers/mtd/ubi/vmt.c
+++ b/drivers/mtd/ubi/vmt.c
@@ -405,7 +405,7 @@ int ubi_remove_volume(struct ubi_volume_desc *desc, int no_vtbl)
405 if (!no_vtbl) 405 if (!no_vtbl)
406 self_check_volumes(ubi); 406 self_check_volumes(ubi);
407 407
408 return err; 408 return 0;
409 409
410out_err: 410out_err:
411 ubi_err(ubi, "cannot remove volume %d, error %d", vol_id, err); 411 ubi_err(ubi, "cannot remove volume %d, error %d", vol_id, err);
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c
index 17ec948ac40e..959c7b12e0b1 100644
--- a/drivers/mtd/ubi/wl.c
+++ b/drivers/mtd/ubi/wl.c
@@ -1534,6 +1534,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
1534 INIT_LIST_HEAD(&ubi->pq[i]); 1534 INIT_LIST_HEAD(&ubi->pq[i]);
1535 ubi->pq_head = 0; 1535 ubi->pq_head = 0;
1536 1536
1537 ubi->free_count = 0;
1537 list_for_each_entry_safe(aeb, tmp, &ai->erase, u.list) { 1538 list_for_each_entry_safe(aeb, tmp, &ai->erase, u.list) {
1538 cond_resched(); 1539 cond_resched();
1539 1540
@@ -1552,7 +1553,6 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
1552 found_pebs++; 1553 found_pebs++;
1553 } 1554 }
1554 1555
1555 ubi->free_count = 0;
1556 list_for_each_entry(aeb, &ai->free, u.list) { 1556 list_for_each_entry(aeb, &ai->free, u.list) {
1557 cond_resched(); 1557 cond_resched();
1558 1558