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

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

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

Pull UBI/UBIFS updates from Richard Weinberger:

 - use the new fscrypt APIs

 - a fix for a Fastmap issue

 - other minor bug fixes

* tag 'upstream-4.16-rc1' of git://git.infradead.org/linux-ubifs:
  ubi: block: Fix locking for idr_alloc/idr_remove
  mtd: ubi: wl: Fix error return code in ubi_wl_init()
  ubi: Fix copy/paste error in function documentation
  ubi: Fastmap: Fix typo
  ubifs: remove error message in ubifs_xattr_get
  ubi: fastmap: Erase outdated anchor PEBs during attach
  ubifs: switch to fscrypt_prepare_setattr()
  ubifs: switch to fscrypt_prepare_lookup()
  ubifs: switch to fscrypt_prepare_rename()
  ubifs: switch to fscrypt_prepare_link()
  ubifs: switch to fscrypt_file_open()
  ubi: fastmap: Clean up the initialization of pointer p
  ubi: fastmap: Use kmem_cache_free to deallocate memory
  ubi: Fix race condition between ubi volume creation and udev
  mtd: ubi: Use 'max_bad_blocks' to compute bad_peb_limit if available
  ubifs: Fix uninitialized variable in search_dh_cookie()
parents 0a4b6e2f 7f29ae9f
Loading
Loading
Loading
Loading
+26 −16
Original line number Diff line number Diff line
@@ -99,6 +99,8 @@ struct ubiblock {

/* Linked list of all ubiblock instances */
static LIST_HEAD(ubiblock_devices);
static DEFINE_IDR(ubiblock_minor_idr);
/* Protects ubiblock_devices and ubiblock_minor_idr */
static DEFINE_MUTEX(devices_mutex);
static int ubiblock_major;

@@ -351,8 +353,6 @@ static const struct blk_mq_ops ubiblock_mq_ops = {
	.init_request	= ubiblock_init_request,
};

static DEFINE_IDR(ubiblock_minor_idr);

int ubiblock_create(struct ubi_volume_info *vi)
{
	struct ubiblock *dev;
@@ -365,14 +365,15 @@ int ubiblock_create(struct ubi_volume_info *vi)
	/* Check that the volume isn't already handled */
	mutex_lock(&devices_mutex);
	if (find_dev_nolock(vi->ubi_num, vi->vol_id)) {
		mutex_unlock(&devices_mutex);
		return -EEXIST;
		ret = -EEXIST;
		goto out_unlock;
	}
	mutex_unlock(&devices_mutex);

	dev = kzalloc(sizeof(struct ubiblock), GFP_KERNEL);
	if (!dev)
		return -ENOMEM;
	if (!dev) {
		ret = -ENOMEM;
		goto out_unlock;
	}

	mutex_init(&dev->dev_mutex);

@@ -437,14 +438,13 @@ int ubiblock_create(struct ubi_volume_info *vi)
		goto out_free_queue;
	}

	mutex_lock(&devices_mutex);
	list_add_tail(&dev->list, &ubiblock_devices);
	mutex_unlock(&devices_mutex);

	/* Must be the last step: anyone can call file ops from now on */
	add_disk(dev->gd);
	dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)",
		 dev->ubi_num, dev->vol_id, vi->name);
	mutex_unlock(&devices_mutex);
	return 0;

out_free_queue:
@@ -457,6 +457,8 @@ int ubiblock_create(struct ubi_volume_info *vi)
	put_disk(dev->gd);
out_free_dev:
	kfree(dev);
out_unlock:
	mutex_unlock(&devices_mutex);

	return ret;
}
@@ -478,30 +480,36 @@ static void ubiblock_cleanup(struct ubiblock *dev)
int ubiblock_remove(struct ubi_volume_info *vi)
{
	struct ubiblock *dev;
	int ret;

	mutex_lock(&devices_mutex);
	dev = find_dev_nolock(vi->ubi_num, vi->vol_id);
	if (!dev) {
		mutex_unlock(&devices_mutex);
		return -ENODEV;
		ret = -ENODEV;
		goto out_unlock;
	}

	/* Found a device, let's lock it so we can check if it's busy */
	mutex_lock(&dev->dev_mutex);
	if (dev->refcnt > 0) {
		mutex_unlock(&dev->dev_mutex);
		mutex_unlock(&devices_mutex);
		return -EBUSY;
		ret = -EBUSY;
		goto out_unlock_dev;
	}

	/* Remove from device list */
	list_del(&dev->list);
	mutex_unlock(&devices_mutex);

	ubiblock_cleanup(dev);
	mutex_unlock(&dev->dev_mutex);
	mutex_unlock(&devices_mutex);

	kfree(dev);
	return 0;

out_unlock_dev:
	mutex_unlock(&dev->dev_mutex);
out_unlock:
	mutex_unlock(&devices_mutex);
	return ret;
}

static int ubiblock_resize(struct ubi_volume_info *vi)
@@ -630,6 +638,7 @@ static void ubiblock_remove_all(void)
	struct ubiblock *next;
	struct ubiblock *dev;

	mutex_lock(&devices_mutex);
	list_for_each_entry_safe(dev, next, &ubiblock_devices, list) {
		/* The module is being forcefully removed */
		WARN_ON(dev->desc);
@@ -638,6 +647,7 @@ static void ubiblock_remove_all(void)
		ubiblock_cleanup(dev);
		kfree(dev);
	}
	mutex_unlock(&devices_mutex);
}

int __init ubiblock_init(void)
+11 −2
Original line number Diff line number Diff line
@@ -535,8 +535,17 @@ static int get_bad_peb_limit(const struct ubi_device *ubi, int max_beb_per1024)
	int limit, device_pebs;
	uint64_t device_size;

	if (!max_beb_per1024)
	if (!max_beb_per1024) {
		/*
		 * Since max_beb_per1024 has not been set by the user in either
		 * the cmdline or Kconfig, use mtd_max_bad_blocks to set the
		 * limit if it is supported by the device.
		 */
		limit = mtd_max_bad_blocks(ubi->mtd, 0, ubi->mtd->size);
		if (limit < 0)
			return 0;
		return limit;
	}

	/*
	 * Here we are using size of the entire flash chip and
+1 −1
Original line number Diff line number Diff line
@@ -384,7 +384,7 @@ static int leb_write_lock(struct ubi_device *ubi, int vol_id, int lnum)
}

/**
 * leb_write_lock - lock logical eraseblock for writing.
 * leb_write_trylock - try to lock logical eraseblock for writing.
 * @ubi: UBI device description object
 * @vol_id: volume ID
 * @lnum: logical eraseblock number
+1 −1
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ static void return_unused_pool_pebs(struct ubi_device *ubi,
	}
}

static int anchor_pebs_avalible(struct rb_root *root)
static int anchor_pebs_available(struct rb_root *root)
{
	struct rb_node *p;
	struct ubi_wl_entry *e;
+2 −3
Original line number Diff line number Diff line
@@ -214,9 +214,8 @@ static void assign_aeb_to_av(struct ubi_attach_info *ai,
			     struct ubi_ainf_volume *av)
{
	struct ubi_ainf_peb *tmp_aeb;
	struct rb_node **p = &ai->volumes.rb_node, *parent = NULL;
	struct rb_node **p = &av->root.rb_node, *parent = NULL;

	p = &av->root.rb_node;
	while (*p) {
		parent = *p;

@@ -1063,7 +1062,7 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
		e = kmem_cache_alloc(ubi_wl_entry_slab, GFP_KERNEL);
		if (!e) {
			while (i--)
				kfree(fm->e[i]);
				kmem_cache_free(ubi_wl_entry_slab, fm->e[i]);

			ret = -ENOMEM;
			goto free_hdr;
Loading