Commit 370d2662 authored by Linus Torvalds's avatar Linus Torvalds

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

Pull ubifs updates from Artem Bityutskiy:
 "This pull request includes the 'ubiblock' driver which provides R/O
  block access to UBI volumes.  It is useful for those who want to use
  squashfs on top of raw flash devices.  UBI will provide bit-flip
  handling and wear-levelling in this case (e.g., if there are other UBI
  volumes with R/W UBIFS too).

  The driver is actually pretty small and it is part of the UBI kernel
  subsystem.  Delivered by Ezequiel Garcia, along with a piece of
  documentation on the MTD web site and the user-space tool for creating
  and removing block devices"

* tag 'upstream-3.15-rc1' of git://git.infradead.org/linux-ubifs:
  UBI: block: Remove __initdata from ubiblock_param_ops
  UBI: make UBI_IOCVOLCRBLK take a parameter for future usage
  UBI: rename block device ioctls
  UBI: block: Use ENOSYS as return value when CONFIG_UBIBLOCK=n
  UBI: block: Add CONFIG_BLOCK dependency
  UBI: block: Use 'u64' for the 64-bit dividend
  UBI: block: Mark init-only symbol as __initdata
  UBI: block: do not use term "attach"
  UBI: R/O block driver on top of UBI volumes
parents d15fee81 d56030ac
......@@ -87,4 +87,20 @@ config MTD_UBI_GLUEBI
work on top of UBI. Do not enable this unless you use legacy
software.
config MTD_UBI_BLOCK
bool "Read-only block devices on top of UBI volumes"
default n
depends on BLOCK
help
This option enables read-only UBI block devices support. UBI block
devices will be layered on top of UBI volumes, which means that the
UBI driver will transparently handle things like bad eraseblocks and
bit-flips. You can put any block-oriented file system on top of UBI
volumes in read-only mode (e.g., ext4), but it is probably most
practical for read-only file systems, like squashfs.
When selected, this feature will be built in the UBI driver.
If in doubt, say "N".
endif # MTD_UBI
......@@ -3,5 +3,6 @@ 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 attach.o
ubi-y += misc.o debug.o
ubi-$(CONFIG_MTD_UBI_FASTMAP) += fastmap.o
ubi-$(CONFIG_MTD_UBI_BLOCK) += block.o
obj-$(CONFIG_MTD_UBI_GLUEBI) += gluebi.o
This diff is collapsed.
......@@ -1298,6 +1298,15 @@ static int __init ubi_init(void)
}
}
err = ubiblock_init();
if (err) {
ubi_err("block: cannot initialize, error %d", err);
/* See comment above re-ubi_is_module(). */
if (ubi_is_module())
goto out_detach;
}
return 0;
out_detach:
......@@ -1326,6 +1335,8 @@ static void __exit ubi_exit(void)
{
int i;
ubiblock_exit();
for (i = 0; i < UBI_MAX_DEVICES; i++)
if (ubi_devices[i]) {
mutex_lock(&ubi_devices_mutex);
......
......@@ -561,6 +561,26 @@ static long vol_cdev_ioctl(struct file *file, unsigned int cmd,
break;
}
/* Create a R/O block device on top of the UBI volume */
case UBI_IOCVOLCRBLK:
{
struct ubi_volume_info vi;
ubi_get_volume_info(desc, &vi);
err = ubiblock_create(&vi);
break;
}
/* Remove the R/O block device */
case UBI_IOCVOLRMBLK:
{
struct ubi_volume_info vi;
ubi_get_volume_info(desc, &vi);
err = ubiblock_remove(&vi);
break;
}
default:
err = -ENOTTY;
break;
......
......@@ -864,6 +864,26 @@ int ubi_update_fastmap(struct ubi_device *ubi);
int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
int fm_anchor);
/* block.c */
#ifdef CONFIG_MTD_UBI_BLOCK
int ubiblock_init(void);
void ubiblock_exit(void);
int ubiblock_create(struct ubi_volume_info *vi);
int ubiblock_remove(struct ubi_volume_info *vi);
#else
static inline int ubiblock_init(void) { return 0; }
static inline void ubiblock_exit(void) {}
static inline int ubiblock_create(struct ubi_volume_info *vi)
{
return -ENOSYS;
}
static inline int ubiblock_remove(struct ubi_volume_info *vi)
{
return -ENOSYS;
}
#endif
/*
* ubi_rb_for_each_entry - walk an RB-tree.
* @rb: a pointer to type 'struct rb_node' to use as a loop counter
......
......@@ -134,6 +134,16 @@
* used. A pointer to a &struct ubi_set_vol_prop_req object is expected to be
* passed. The object describes which property should be set, and to which value
* it should be set.
*
* Block devices on UBI volumes
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
* To create a R/O block device on top of an UBI volume the %UBI_IOCVOLCRBLK
* should be used. A pointer to a &struct ubi_blkcreate_req object is expected
* to be passed, which is not used and reserved for future usage.
*
* Conversely, to remove a block device the %UBI_IOCVOLRMBLK should be used,
* which takes no arguments.
*/
/*
......@@ -191,6 +201,10 @@
/* Set an UBI volume property */
#define UBI_IOCSETVOLPROP _IOW(UBI_VOL_IOC_MAGIC, 6, \
struct ubi_set_vol_prop_req)
/* Create a R/O block device on top of an UBI volume */
#define UBI_IOCVOLCRBLK _IOW(UBI_VOL_IOC_MAGIC, 7, struct ubi_blkcreate_req)
/* Remove the R/O block device */
#define UBI_IOCVOLRMBLK _IO(UBI_VOL_IOC_MAGIC, 8)
/* Maximum MTD device name length supported by UBI */
#define MAX_UBI_MTD_NAME_LEN 127
......@@ -420,4 +434,12 @@ struct ubi_set_vol_prop_req {
__u64 value;
} __packed;
/**
* struct ubi_blkcreate_req - a data structure used in block creation requests.
* @padding: reserved for future, not used, has to be zeroed
*/
struct ubi_blkcreate_req {
__s8 padding[128];
} __packed;
#endif /* __UBI_USER_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment