Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b11445f8 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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

Pull UBI/UBIFS fixes from Artem Bityutskiy:
 - fix for a theoretical race condition which could lead to a situation
   when UBIFS is unable to mount a file-system (Hujianyang)
 - a few fixes for the ubiblock sybsystem, error path fixes
 - the ubiblock subsystem has had the volume size change handling
   improved
 - a few fixes and nicifications in the fastmap subsystem

* tag 'upstream-3.18-rc1-v2' of git://git.infradead.org/linux-ubifs:
  UBI: Fastmap: Calc fastmap size correctly
  UBIFS: Fix trivial typo in power_cut_emulated()
  UBI: Fix trivial typo in __schedule_ubi_work
  UBI: wl: Rename cancel flag to shutdown
  UBI: ubi_eba_read_leb: Remove in vain variable assignment
  UBIFS: Align the dump messages of SB_NODE
  UBI: Fix livelock in produce_free_peb()
  UBI: return on error in rename_volumes()
  UBI: Improve comment on work_sem
  UBIFS: Remove bogus assert
  UBI: Dispatch update notification if the volume is updated
  UBI: block: Add support for the UBI_VOLUME_UPDATED notification
  UBI: block: Fix block device size setting
  UBI: block: fix dereference on uninitialized dev
  UBI: add missing kmem_cache_free() in process_pool_aeb error path
  UBIFS: fix free log space calculation
  UBIFS: fix a race condition
parents 0ef3a56b 91401a34
Loading
Loading
Loading
Loading
+25 −11
Original line number Diff line number Diff line
@@ -188,8 +188,9 @@ static int ubiblock_read_to_buf(struct ubiblock *dev, char *buffer,

	ret = ubi_read(dev->desc, leb, buffer, offset, len);
	if (ret) {
		ubi_err("%s ubi_read error %d",
			dev->gd->disk_name, ret);
		ubi_err("%s: error %d while reading from LEB %d (offset %d, "
		        "length %d)", dev->gd->disk_name, ret, leb, offset,
			len);
		return ret;
	}
	return 0;
@@ -378,7 +379,7 @@ int ubiblock_create(struct ubi_volume_info *vi)
{
	struct ubiblock *dev;
	struct gendisk *gd;
	u64 disk_capacity = ((u64)vi->size * vi->usable_leb_size) >> 9;
	u64 disk_capacity = vi->used_bytes >> 9;
	int ret;

	if ((sector_t)disk_capacity != disk_capacity)
@@ -502,13 +503,8 @@ int ubiblock_remove(struct ubi_volume_info *vi)
static int ubiblock_resize(struct ubi_volume_info *vi)
{
	struct ubiblock *dev;
	u64 disk_capacity = ((u64)vi->size * vi->usable_leb_size) >> 9;
	u64 disk_capacity = vi->used_bytes >> 9;

	if ((sector_t)disk_capacity != disk_capacity) {
		ubi_warn("%s: the volume is too big, cannot resize (%d LEBs)",
			 dev->gd->disk_name, vi->size);
		return -EFBIG;
	}
	/*
	 * Need to lock the device list until we stop using the device,
	 * otherwise the device struct might get released in
@@ -520,10 +516,20 @@ static int ubiblock_resize(struct ubi_volume_info *vi)
		mutex_unlock(&devices_mutex);
		return -ENODEV;
	}
	if ((sector_t)disk_capacity != disk_capacity) {
		mutex_unlock(&devices_mutex);
		ubi_warn("%s: the volume is too big (%d LEBs), cannot resize",
			 dev->gd->disk_name, vi->size);
		return -EFBIG;
	}

	mutex_lock(&dev->dev_mutex);

	if (get_capacity(dev->gd) != disk_capacity) {
		set_capacity(dev->gd, disk_capacity);
	ubi_msg("%s resized to %d LEBs", dev->gd->disk_name, vi->size);
		ubi_msg("%s resized to %lld bytes", dev->gd->disk_name,
			vi->used_bytes);
	}
	mutex_unlock(&dev->dev_mutex);
	mutex_unlock(&devices_mutex);
	return 0;
@@ -547,6 +553,14 @@ static int ubiblock_notify(struct notifier_block *nb,
	case UBI_VOLUME_RESIZED:
		ubiblock_resize(&nt->vi);
		break;
	case UBI_VOLUME_UPDATED:
		/*
		 * If the volume is static, a content update might mean the
		 * size (i.e. used_bytes) was also changed.
		 */
		if (nt->vi.vol_type == UBI_STATIC_VOLUME)
			ubiblock_resize(&nt->vi);
		break;
	default:
		break;
	}
+4 −2
Original line number Diff line number Diff line
@@ -425,8 +425,10 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
			break;

		err = ubi_start_update(ubi, vol, bytes);
		if (bytes == 0)
		if (bytes == 0) {
			ubi_volume_notify(ubi, vol, UBI_VOLUME_UPDATED);
			revoke_exclusive(desc, UBI_READWRITE);
		}
		break;
	}

@@ -699,7 +701,7 @@ static int rename_volumes(struct ubi_device *ubi,
		req->ents[i].name[req->ents[i].name_len] = '\0';
		n = strlen(req->ents[i].name);
		if (n != req->ents[i].name_len)
			err = -EINVAL;
			return -EINVAL;
	}

	/* Make sure volume IDs and names are unique */
+2 −3
Original line number Diff line number Diff line
@@ -441,10 +441,9 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,

	err = ubi_io_read_data(ubi, buf, pnum, offset, len);
	if (err) {
		if (err == UBI_IO_BITFLIPS) {
		if (err == UBI_IO_BITFLIPS)
			scrub = 1;
			err = 0;
		} else if (mtd_is_eccerr(err)) {
		else if (mtd_is_eccerr(err)) {
			if (vol->vol_type == UBI_DYNAMIC_VOLUME)
				goto out_unlock;
			scrub = 1;
+3 −1
Original line number Diff line number Diff line
@@ -24,7 +24,8 @@ size_t ubi_calc_fm_size(struct ubi_device *ubi)
{
	size_t size;

	size = sizeof(struct ubi_fm_hdr) + \
	size = sizeof(struct ubi_fm_sb) + \
		sizeof(struct ubi_fm_hdr) + \
		sizeof(struct ubi_fm_scan_pool) + \
		sizeof(struct ubi_fm_scan_pool) + \
		(ubi->peb_count * sizeof(struct ubi_fm_ec)) + \
@@ -330,6 +331,7 @@ static int process_pool_aeb(struct ubi_device *ubi, struct ubi_attach_info *ai,
		av = tmp_av;
	else {
		ubi_err("orphaned volume in fastmap pool!");
		kmem_cache_free(ai->aeb_slab_cache, new_aeb);
		return UBI_BAD_FASTMAP;
	}

+7 −5
Original line number Diff line number Diff line
@@ -439,7 +439,8 @@ struct ubi_debug_info {
 *	     @move_to, @move_to_put @erase_pending, @wl_scheduled, @works,
 *	     @erroneous, and @erroneous_peb_count fields
 * @move_mutex: serializes eraseblock moves
 * @work_sem: synchronizes the WL worker with use tasks
 * @work_sem: used to wait for all the scheduled works to finish and prevent
 * new works from being submitted
 * @wl_scheduled: non-zero if the wear-leveling was scheduled
 * @lookuptbl: a table to quickly find a &struct ubi_wl_entry object for any
 *             physical eraseblock
@@ -713,14 +714,15 @@ struct ubi_attach_info {
 * @torture: if the physical eraseblock has to be tortured
 * @anchor: produce a anchor PEB to by used by fastmap
 *
 * The @func pointer points to the worker function. If the @cancel argument is
 * not zero, the worker has to free the resources and exit immediately. The
 * worker has to return zero in case of success and a negative error code in
 * The @func pointer points to the worker function. If the @shutdown argument is
 * not zero, the worker has to free the resources and exit immediately as the
 * WL sub-system is shutting down.
 * The worker has to return zero in case of success and a negative error code in
 * case of failure.
 */
struct ubi_work {
	struct list_head list;
	int (*func)(struct ubi_device *ubi, struct ubi_work *wrk, int cancel);
	int (*func)(struct ubi_device *ubi, struct ubi_work *wrk, int shutdown);
	/* The below fields are only relevant to erasure works */
	struct ubi_wl_entry *e;
	int vol_id;
Loading