diff options
author | Brian Wood <brian.j.wood@intel.com> | 2017-02-27 16:58:40 -0800 |
---|---|---|
committer | Brian Wood <brian.j.wood@intel.com> | 2017-02-28 15:35:14 -0800 |
commit | b7147432cf0d58533bd21fe594d0be1d153f91a6 (patch) | |
tree | aec042cd9c91432c09285381c5d5af85072975c9 /drivers/mtd/ubi/vmt.c | |
parent | ce7cfcfa1251122880d34fae7259309b64a78434 (diff) | |
parent | ec55e7c2bf49a426b6f8204505bd267c77554d37 (diff) | |
download | edison-v3.10-n-iot-preview-4.tar.gz |
Merge remote-tracking branch 'remotes/origin/brillo/linux-3.10.y' into Brillo-20170221-3.10_kernelandroid-n-iot-preview-4n-iot-preview-4
Conflicts:
crypto/blkcipher.c
drivers/platform/x86/intel_scu_ipcutil.c
drivers/usb/gadget/u_ether.c
fs/ext4/extents.c
net/bluetooth/sco.c
net/wireless/scan.c
Change-Id: Iaea6d22acb3da6b0477d71cf546858d35295e3d2
Diffstat (limited to 'drivers/mtd/ubi/vmt.c')
-rw-r--r-- | drivers/mtd/ubi/vmt.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index 8330703c098..96131eb34c9 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -534,13 +534,6 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) spin_unlock(&ubi->volumes_lock); } - /* Change volume table record */ - vtbl_rec = ubi->vtbl[vol_id]; - vtbl_rec.reserved_pebs = cpu_to_be32(reserved_pebs); - err = ubi_change_vtbl_record(ubi, vol_id, &vtbl_rec); - if (err) - goto out_acc; - if (pebs < 0) { for (i = 0; i < -pebs; i++) { err = ubi_eba_unmap_leb(ubi, vol, reserved_pebs + i); @@ -558,6 +551,24 @@ int ubi_resize_volume(struct ubi_volume_desc *desc, int reserved_pebs) spin_unlock(&ubi->volumes_lock); } + /* + * When we shrink a volume we have to flush all pending (erase) work. + * Otherwise it can happen that upon next attach UBI finds a LEB with + * lnum > highest_lnum and refuses to attach. + */ + if (pebs < 0) { + err = ubi_wl_flush(ubi, vol_id, UBI_ALL); + if (err) + goto out_acc; + } + + /* Change volume table record */ + vtbl_rec = ubi->vtbl[vol_id]; + vtbl_rec.reserved_pebs = cpu_to_be32(reserved_pebs); + err = ubi_change_vtbl_record(ubi, vol_id, &vtbl_rec); + if (err) + goto out_acc; + vol->reserved_pebs = reserved_pebs; if (vol->vol_type == UBI_DYNAMIC_VOLUME) { vol->used_ebs = reserved_pebs; |