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

Commit 6133308a authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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

Pull UBI and UBIFS updates from Artem Bityutskiy:

UBIFS:
   * Always support xattrs    (remove the Kconfig option)
   * Always support debugging (remove the Kconfig option)
   * A fix for a memory leak on error path
   * A number of clean-ups
UBI:
   * Always support debugging (remove the Kconfig option)
   * Remove "data type" hint support
   * Huge amount of renames to prepare for the fastmap wor
   * A lot of clean-ups

* tag 'upstream-3.5-rc1' of git://git.infradead.org/linux-ubifs: (54 commits)
  UBI: modify ubi_wl_flush function to clear work queue for a lnum
  UBI: introduce UBI_ALL constant
  UBI: add lnum and vol_id to struct ubi_work
  UBI: add volume id struct ubi_ainf_peb
  UBI: add in hex the value for UBI_INTERNAL_VOL_START to comment
  UBI: rename scan.c to attach.c
  UBI: remove scan.h
  UBI: rename UBI_SCAN_UNKNOWN_EC
  UBI: move and rename attach_by_scanning
  UBI: rename _init_scan functions
  UBI: amend comments after all the renamings
  UBI: rename ubi_scan_leb_slab
  UBI: rename ubi_scan_move_to_list
  UBI: rename ubi_scan_destroy_ai
  UBI: rename ubi_scan_get_free_peb
  UBI: rename ubi_scan_rm_volume
  UBI: rename ubi_scan_find_av
  UBI: rename ubi_scan_add_used
  UBI: remove unused function
  UBI: make ubi_scan_erase_peb static and rename
  ...
parents e8650a08 62f38455
Loading
Loading
Loading
Loading
+0 −8
Original line number Original line Diff line number Diff line
@@ -52,12 +52,4 @@ config MTD_UBI_GLUEBI
	   work on top of UBI. Do not enable this unless you use legacy
	   work on top of UBI. Do not enable this unless you use legacy
	   software.
	   software.


config MTD_UBI_DEBUG
	bool "UBI debugging"
	depends on SYSFS
	select DEBUG_FS
	select KALLSYMS
	help
	  This option enables UBI debugging.

endif # MTD_UBI
endif # MTD_UBI
+2 −3
Original line number Original line Diff line number Diff line
obj-$(CONFIG_MTD_UBI) += ubi.o
obj-$(CONFIG_MTD_UBI) += ubi.o


ubi-y += vtbl.o vmt.o upd.o build.o cdev.o kapi.o eba.o io.o wl.o scan.o
ubi-y += vtbl.o vmt.o upd.o build.o cdev.o kapi.o eba.o io.o wl.o attach.o
ubi-y += misc.o
ubi-y += misc.o debug.o


ubi-$(CONFIG_MTD_UBI_DEBUG) += debug.o
obj-$(CONFIG_MTD_UBI_GLUEBI) += gluebi.o
obj-$(CONFIG_MTD_UBI_GLUEBI) += gluebi.o
+498 −472

File changed and moved.

Preview size limit exceeded, changes collapsed.

+14 −71
Original line number Original line Diff line number Diff line
@@ -27,10 +27,6 @@
 * module load parameters or the kernel boot parameters. If MTD devices were
 * module load parameters or the kernel boot parameters. If MTD devices were
 * specified, UBI does not attach any MTD device, but it is possible to do
 * specified, UBI does not attach any MTD device, but it is possible to do
 * later using the "UBI control device".
 * later using the "UBI control device".
 *
 * At the moment we only attach UBI devices by scanning, which will become a
 * bottleneck when flashes reach certain large size. Then one may improve UBI
 * and add other methods, although it does not seem to be easy to do.
 */
 */


#include <linux/err.h>
#include <linux/err.h>
@@ -554,10 +550,10 @@ static void uif_close(struct ubi_device *ubi)
}
}


/**
/**
 * free_internal_volumes - free internal volumes.
 * ubi_free_internal_volumes - free internal volumes.
 * @ubi: UBI device description object
 * @ubi: UBI device description object
 */
 */
static void free_internal_volumes(struct ubi_device *ubi)
void ubi_free_internal_volumes(struct ubi_device *ubi)
{
{
	int i;
	int i;


@@ -568,59 +564,6 @@ static void free_internal_volumes(struct ubi_device *ubi)
	}
	}
}
}


/**
 * attach_by_scanning - attach an MTD device using scanning method.
 * @ubi: UBI device descriptor
 *
 * This function returns zero in case of success and a negative error code in
 * case of failure.
 *
 * Note, currently this is the only method to attach UBI devices. Hopefully in
 * the future we'll have more scalable attaching methods and avoid full media
 * scanning. But even in this case scanning will be needed as a fall-back
 * attaching method if there are some on-flash table corruptions.
 */
static int attach_by_scanning(struct ubi_device *ubi)
{
	int err;
	struct ubi_scan_info *si;

	si = ubi_scan(ubi);
	if (IS_ERR(si))
		return PTR_ERR(si);

	ubi->bad_peb_count = si->bad_peb_count;
	ubi->good_peb_count = ubi->peb_count - ubi->bad_peb_count;
	ubi->corr_peb_count = si->corr_peb_count;
	ubi->max_ec = si->max_ec;
	ubi->mean_ec = si->mean_ec;
	ubi_msg("max. sequence number:       %llu", si->max_sqnum);

	err = ubi_read_volume_table(ubi, si);
	if (err)
		goto out_si;

	err = ubi_wl_init_scan(ubi, si);
	if (err)
		goto out_vtbl;

	err = ubi_eba_init_scan(ubi, si);
	if (err)
		goto out_wl;

	ubi_scan_destroy_si(si);
	return 0;

out_wl:
	ubi_wl_close(ubi);
out_vtbl:
	free_internal_volumes(ubi);
	vfree(ubi->vtbl);
out_si:
	ubi_scan_destroy_si(si);
	return err;
}

/**
/**
 * io_init - initialize I/O sub-system for a given UBI device.
 * io_init - initialize I/O sub-system for a given UBI device.
 * @ubi: UBI device description object
 * @ubi: UBI device description object
@@ -790,11 +733,11 @@ static int io_init(struct ubi_device *ubi)
	ubi_msg("data offset:                %d", ubi->leb_start);
	ubi_msg("data offset:                %d", ubi->leb_start);


	/*
	/*
	 * Note, ideally, we have to initialize ubi->bad_peb_count here. But
	 * Note, ideally, we have to initialize @ubi->bad_peb_count here. But
	 * unfortunately, MTD does not provide this information. We should loop
	 * unfortunately, MTD does not provide this information. We should loop
	 * over all physical eraseblocks and invoke mtd->block_is_bad() for
	 * over all physical eraseblocks and invoke mtd->block_is_bad() for
	 * each physical eraseblock. So, we skip ubi->bad_peb_count
	 * each physical eraseblock. So, we leave @ubi->bad_peb_count
	 * uninitialized and initialize it after scanning.
	 * uninitialized so far.
	 */
	 */


	return 0;
	return 0;
@@ -805,7 +748,7 @@ static int io_init(struct ubi_device *ubi)
 * @ubi: UBI device description object
 * @ubi: UBI device description object
 * @vol_id: ID of the volume to re-size
 * @vol_id: ID of the volume to re-size
 *
 *
 * This function re-sizes the volume marked by the @UBI_VTBL_AUTORESIZE_FLG in
 * This function re-sizes the volume marked by the %UBI_VTBL_AUTORESIZE_FLG in
 * the volume table to the largest possible size. See comments in ubi-header.h
 * the volume table to the largest possible size. See comments in ubi-header.h
 * for more description of the flag. Returns zero in case of success and a
 * for more description of the flag. Returns zero in case of success and a
 * negative error code in case of failure.
 * negative error code in case of failure.
@@ -881,7 +824,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
	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) {
			dbg_err("mtd%d is already attached to ubi%d",
			ubi_err("mtd%d is already attached to ubi%d",
				mtd->index, i);
				mtd->index, i);
			return -EEXIST;
			return -EEXIST;
		}
		}
@@ -907,7 +850,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
			if (!ubi_devices[ubi_num])
			if (!ubi_devices[ubi_num])
				break;
				break;
		if (ubi_num == UBI_MAX_DEVICES) {
		if (ubi_num == UBI_MAX_DEVICES) {
			dbg_err("only %d UBI devices may be created",
			ubi_err("only %d UBI devices may be created",
				UBI_MAX_DEVICES);
				UBI_MAX_DEVICES);
			return -ENFILE;
			return -ENFILE;
		}
		}
@@ -917,7 +860,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)


		/* Make sure ubi_num is not busy */
		/* Make sure ubi_num is not busy */
		if (ubi_devices[ubi_num]) {
		if (ubi_devices[ubi_num]) {
			dbg_err("ubi%d already exists", ubi_num);
			ubi_err("ubi%d already exists", ubi_num);
			return -EEXIST;
			return -EEXIST;
		}
		}
	}
	}
@@ -937,7 +880,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
	spin_lock_init(&ubi->volumes_lock);
	spin_lock_init(&ubi->volumes_lock);


	ubi_msg("attaching mtd%d to ubi%d", mtd->index, ubi_num);
	ubi_msg("attaching mtd%d to ubi%d", mtd->index, ubi_num);
	dbg_msg("sizeof(struct ubi_scan_leb) %zu", sizeof(struct ubi_scan_leb));
	dbg_msg("sizeof(struct ubi_ainf_peb) %zu", sizeof(struct ubi_ainf_peb));
	dbg_msg("sizeof(struct ubi_wl_entry) %zu", sizeof(struct ubi_wl_entry));
	dbg_msg("sizeof(struct ubi_wl_entry) %zu", sizeof(struct ubi_wl_entry));


	err = io_init(ubi);
	err = io_init(ubi);
@@ -953,9 +896,9 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
	if (err)
	if (err)
		goto out_free;
		goto out_free;


	err = attach_by_scanning(ubi);
	err = ubi_attach(ubi);
	if (err) {
	if (err) {
		dbg_err("failed to attach by scanning, error %d", err);
		ubi_err("failed to attach mtd%d, error %d", mtd->index, err);
		goto out_debugging;
		goto out_debugging;
	}
	}


@@ -1020,7 +963,7 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, int vid_hdr_offset)
	uif_close(ubi);
	uif_close(ubi);
out_detach:
out_detach:
	ubi_wl_close(ubi);
	ubi_wl_close(ubi);
	free_internal_volumes(ubi);
	ubi_free_internal_volumes(ubi);
	vfree(ubi->vtbl);
	vfree(ubi->vtbl);
out_debugging:
out_debugging:
	ubi_debugging_exit_dev(ubi);
	ubi_debugging_exit_dev(ubi);
@@ -1092,7 +1035,7 @@ int ubi_detach_mtd_dev(int ubi_num, int anyway)
	ubi_debugfs_exit_dev(ubi);
	ubi_debugfs_exit_dev(ubi);
	uif_close(ubi);
	uif_close(ubi);
	ubi_wl_close(ubi);
	ubi_wl_close(ubi);
	free_internal_volumes(ubi);
	ubi_free_internal_volumes(ubi);
	vfree(ubi->vtbl);
	vfree(ubi->vtbl);
	put_mtd_device(ubi->mtd);
	put_mtd_device(ubi->mtd);
	ubi_debugging_exit_dev(ubi);
	ubi_debugging_exit_dev(ubi);
+16 −20
Original line number Original line Diff line number Diff line
@@ -63,7 +63,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) {
		dbg_err("%d users for volume %d", users, vol->vol_id);
		ubi_err("%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;
@@ -159,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 */
		dbg_err("updating");
		ubi_err("updating");
		return -EBUSY;
		return -EBUSY;
	}
	}


@@ -178,7 +178,7 @@ static loff_t vol_cdev_llseek(struct file *file, loff_t offset, int origin)
	}
	}


	if (new_offset < 0 || new_offset > vol->used_bytes) {
	if (new_offset < 0 || new_offset > vol->used_bytes) {
		dbg_err("bad seek %lld", new_offset);
		ubi_err("bad seek %lld", new_offset);
		return -EINVAL;
		return -EINVAL;
	}
	}


@@ -216,11 +216,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) {
		dbg_err("updating");
		ubi_err("updating");
		return -EBUSY;
		return -EBUSY;
	}
	}
	if (vol->upd_marker) {
	if (vol->upd_marker) {
		dbg_err("damaged volume, update marker is set");
		ubi_err("damaged volume, update marker is set");
		return -EBADF;
		return -EBADF;
	}
	}
	if (*offp == vol->used_bytes || count == 0)
	if (*offp == vol->used_bytes || count == 0)
@@ -300,7 +300,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)) {
		dbg_err("unaligned position");
		ubi_err("unaligned position");
		return -EINVAL;
		return -EINVAL;
	}
	}


@@ -309,7 +309,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)) {
		dbg_err("unaligned write length");
		ubi_err("unaligned write length");
		return -EINVAL;
		return -EINVAL;
	}
	}


@@ -334,8 +334,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
			break;
			break;
		}
		}


		err = ubi_eba_write_leb(ubi, vol, lnum, tbuf, off, len,
		err = ubi_eba_write_leb(ubi, vol, lnum, tbuf, off, len);
					UBI_UNKNOWN);
		if (err)
		if (err)
			break;
			break;


@@ -477,9 +476,6 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
		if (req.lnum < 0 || req.lnum >= vol->reserved_pebs ||
		if (req.lnum < 0 || req.lnum >= vol->reserved_pebs ||
		    req.bytes < 0 || req.lnum >= vol->usable_leb_size)
		    req.bytes < 0 || req.lnum >= vol->usable_leb_size)
			break;
			break;
		if (req.dtype != UBI_LONGTERM && req.dtype != UBI_SHORTTERM &&
		    req.dtype != UBI_UNKNOWN)
			break;


		err = get_exclusive(desc);
		err = get_exclusive(desc);
		if (err < 0)
		if (err < 0)
@@ -518,7 +514,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
		if (err)
		if (err)
			break;
			break;


		err = ubi_wl_flush(ubi);
		err = ubi_wl_flush(ubi, UBI_ALL, UBI_ALL);
		break;
		break;
	}
	}


@@ -532,7 +528,7 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
			err = -EFAULT;
			err = -EFAULT;
			break;
			break;
		}
		}
		err = ubi_leb_map(desc, req.lnum, req.dtype);
		err = ubi_leb_map(desc, req.lnum);
		break;
		break;
	}
	}


@@ -647,8 +643,8 @@ static int verify_mkvol_req(const struct ubi_device *ubi,
	return 0;
	return 0;


bad:
bad:
	dbg_err("bad volume creation request");
	ubi_err("bad volume creation request");
	ubi_dbg_dump_mkvol_req(req);
	ubi_dump_mkvol_req(req);
	return err;
	return err;
}
}


@@ -713,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) {
				dbg_err("duplicated volume id %d",
				ubi_err("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)) {
				dbg_err("duplicated volume name \"%s\"",
				ubi_err("duplicated volume name \"%s\"",
					req->ents[i].name);
					req->ents[i].name);
				return -EINVAL;
				return -EINVAL;
			}
			}
@@ -741,7 +737,7 @@ static int rename_volumes(struct ubi_device *ubi,
		re->desc = ubi_open_volume(ubi->ubi_num, vol_id, UBI_EXCLUSIVE);
		re->desc = ubi_open_volume(ubi->ubi_num, vol_id, UBI_EXCLUSIVE);
		if (IS_ERR(re->desc)) {
		if (IS_ERR(re->desc)) {
			err = PTR_ERR(re->desc);
			err = PTR_ERR(re->desc);
			dbg_err("cannot open volume %d, error %d", vol_id, err);
			ubi_err("cannot open volume %d, error %d", vol_id, err);
			kfree(re);
			kfree(re);
			goto out_free;
			goto out_free;
		}
		}
@@ -800,7 +796,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 */
			dbg_err("cannot open volume \"%s\", error %d",
			ubi_err("cannot open volume \"%s\", error %d",
				re->new_name, err);
				re->new_name, err);
			goto out_free;
			goto out_free;
		}
		}
Loading