9
0
Fork 0

Merge branch 'for-next/ubi'

Conflicts:
	drivers/mtd/ubi/cdev.c
This commit is contained in:
Sascha Hauer 2014-03-07 09:26:35 +01:00
commit cf1b29a850
9 changed files with 64 additions and 38 deletions

View File

@ -589,8 +589,8 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
ubi->fm_disabled = 1; ubi->fm_disabled = 1;
} }
ubi_msg("default fastmap pool size: %d", ubi->fm_pool.max_size); ubi_debug("default fastmap pool size: %d", ubi->fm_pool.max_size);
ubi_msg("default fastmap WL pool size: %d", ubi->fm_wl_pool.max_size); ubi_debug("default fastmap WL pool size: %d", ubi->fm_wl_pool.max_size);
#else #else
ubi->fm_disabled = 1; ubi->fm_disabled = 1;
#endif #endif
@ -630,23 +630,35 @@ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num,
ubi_msg("attached mtd%d (name \"%s\", size %llu MiB) to ubi%d", ubi_msg("attached mtd%d (name \"%s\", size %llu MiB) to ubi%d",
mtd->index, mtd->name, ubi->flash_size >> 20, ubi_num); mtd->index, mtd->name, ubi->flash_size >> 20, ubi_num);
ubi_msg("PEB size: %d bytes (%d KiB), LEB size: %d bytes", ubi_debug("PEB size: %d bytes (%d KiB), LEB size: %d bytes",
ubi->peb_size, ubi->peb_size >> 10, ubi->leb_size); ubi->peb_size, ubi->peb_size >> 10, ubi->leb_size);
ubi_msg("min./max. I/O unit sizes: %d/%d, sub-page size %d", ubi_debug("min./max. I/O unit sizes: %d/%d, sub-page size %d",
ubi->min_io_size, ubi->max_write_size, ubi->hdrs_min_io_size); ubi->min_io_size, ubi->max_write_size, ubi->hdrs_min_io_size);
ubi_msg("VID header offset: %d (aligned %d), data offset: %d", ubi_debug("VID header offset: %d (aligned %d), data offset: %d",
ubi->vid_hdr_offset, ubi->vid_hdr_aloffset, ubi->leb_start); ubi->vid_hdr_offset, ubi->vid_hdr_aloffset, ubi->leb_start);
ubi_msg("good PEBs: %d, bad PEBs: %d, corrupted PEBs: %d", ubi_debug("good PEBs: %d, bad PEBs: %d, corrupted PEBs: %d",
ubi->good_peb_count, ubi->bad_peb_count, ubi->corr_peb_count); ubi->good_peb_count, ubi->bad_peb_count, ubi->corr_peb_count);
ubi_msg("user volume: %d, internal volumes: %d, max. volumes count: %d", ubi_debug("user volume: %d, internal volumes: %d, max. volumes count: %d",
ubi->vol_count - UBI_INT_VOL_COUNT, UBI_INT_VOL_COUNT, ubi->vol_count - UBI_INT_VOL_COUNT, UBI_INT_VOL_COUNT,
ubi->vtbl_slots); ubi->vtbl_slots);
ubi_msg("max/mean erase counter: %d/%d, WL threshold: %d, image sequence number: %u", ubi_debug("max/mean erase counter: %d/%d, WL threshold: %d, image sequence number: %u",
ubi->max_ec, ubi->mean_ec, CONFIG_MTD_UBI_WL_THRESHOLD, ubi->max_ec, ubi->mean_ec, CONFIG_MTD_UBI_WL_THRESHOLD,
ubi->image_seq); ubi->image_seq);
ubi_msg("available PEBs: %d, total reserved PEBs: %d, PEBs reserved for bad PEB handling: %d", ubi_debug("available PEBs: %d, total reserved PEBs: %d, PEBs reserved for bad PEB handling: %d",
ubi->avail_pebs, ubi->rsvd_pebs, ubi->beb_rsvd_pebs); ubi->avail_pebs, ubi->rsvd_pebs, ubi->beb_rsvd_pebs);
dev_add_param_int_ro(&ubi->dev, "peb_size", ubi->peb_size, "%d");
dev_add_param_int_ro(&ubi->dev, "leb_size", ubi->leb_size, "%d");
dev_add_param_int_ro(&ubi->dev, "vid_header_offset", ubi->vid_hdr_offset, "%d");
dev_add_param_int_ro(&ubi->dev, "min_io_size", ubi->min_io_size, "%d");
dev_add_param_int_ro(&ubi->dev, "sub_page_size", ubi->hdrs_min_io_size, "%d");
dev_add_param_int_ro(&ubi->dev, "good_peb_count", ubi->good_peb_count, "%d");
dev_add_param_int_ro(&ubi->dev, "bad_peb_count", ubi->bad_peb_count, "%d");
dev_add_param_int_ro(&ubi->dev, "max_erase_counter", ubi->max_ec, "%d");
dev_add_param_int_ro(&ubi->dev, "mean_erase_counter", ubi->mean_ec, "%d");
dev_add_param_int_ro(&ubi->dev, "available_pebs", ubi->avail_pebs, "%d");
dev_add_param_int_ro(&ubi->dev, "reserved_pebs", ubi->rsvd_pebs, "%d");
/* /*
* The below lock makes sure we do not race with 'ubi_thread()' which * The below lock makes sure we do not race with 'ubi_thread()' which
* checks @ubi->thread_enabled. Otherwise we may fail to wake it up. * checks @ubi->thread_enabled. Otherwise we may fail to wake it up.

View File

@ -25,7 +25,7 @@ static ssize_t ubi_volume_cdev_read(struct cdev *cdev, void *buf, size_t size,
loff_t offp = offset; loff_t offp = offset;
int usable_leb_size = vol->usable_leb_size; int usable_leb_size = vol->usable_leb_size;
debug("%s: %zd @ 0x%08llx\n", __func__, size, offset); ubi_debug("%s: %zd @ 0x%08llx\n", __func__, size, offset);
len = size > usable_leb_size ? usable_leb_size : size; len = size > usable_leb_size ? usable_leb_size : size;
@ -38,7 +38,7 @@ static ssize_t ubi_volume_cdev_read(struct cdev *cdev, void *buf, size_t size,
err = ubi_eba_read_leb(ubi, vol, lnum, buf, off, len, 0); err = ubi_eba_read_leb(ubi, vol, lnum, buf, off, len, 0);
if (err) { if (err) {
printf("read err %x\n", err); ubi_err("read error: %s\n", strerror(-err));
break; break;
} }
off += len; off += len;
@ -68,14 +68,14 @@ static ssize_t ubi_volume_cdev_write(struct cdev* cdev, const void *buf,
if (!priv->written) { if (!priv->written) {
err = ubi_start_update(ubi, vol, vol->used_bytes); err = ubi_start_update(ubi, vol, vol->used_bytes);
if (err < 0) { if (err < 0) {
printf("Cannot start volume update\n"); ubi_err("Cannot start volume update\n");
return err; return err;
} }
} }
err = ubi_more_update_data(ubi, vol, buf, size); err = ubi_more_update_data(ubi, vol, buf, size);
if (err < 0) { if (err < 0) {
printf("Couldnt or partially wrote data \n"); ubi_err("Couldnt or partially wrote data \n");
return err; return err;
} }
@ -117,7 +117,7 @@ static int ubi_volume_cdev_close(struct cdev *cdev)
kfree(buf); kfree(buf);
if (err < 0) { if (err < 0) {
printf("Couldnt or partially wrote data \n"); ubi_err("Couldnt or partially wrote data \n");
return err; return err;
} }
} }
@ -128,7 +128,7 @@ static int ubi_volume_cdev_close(struct cdev *cdev)
err = ubi_check_volume(ubi, vol->vol_id); err = ubi_check_volume(ubi, vol->vol_id);
if (err < 0) { if (err < 0) {
printf("check failed: %s\n", strerror(err)); ubi_err("ubi volume check failed: %s\n", strerror(err));
return err; return err;
} }
@ -180,7 +180,7 @@ int ubi_volume_cdev_add(struct ubi_device *ubi, struct ubi_volume *vol)
cdev->priv = priv; cdev->priv = priv;
cdev->size = vol->used_bytes; cdev->size = vol->used_bytes;
cdev->dev = &vol->dev; cdev->dev = &vol->dev;
printf("registering %s as /dev/%s\n", vol->name, cdev->name); ubi_msg("registering %s as /dev/%s\n", vol->name, cdev->name);
ret = devfs_create(cdev); ret = devfs_create(cdev);
if (ret) { if (ret) {
kfree(priv); kfree(priv);
@ -243,7 +243,7 @@ int ubi_cdev_add(struct ubi_device *ubi)
cdev->priv = ubi; cdev->priv = ubi;
cdev->size = 0; cdev->size = 0;
printf("registering /dev/%s\n", cdev->name); ubi_msg("registering /dev/%s", cdev->name);
ret = devfs_create(cdev); ret = devfs_create(cdev);
if (ret) if (ret)
kfree(cdev->name); kfree(cdev->name);
@ -255,7 +255,7 @@ void ubi_cdev_remove(struct ubi_device *ubi)
{ {
struct cdev *cdev = &ubi->cdev; struct cdev *cdev = &ubi->cdev;
printf("removing %s\n", cdev->name); ubi_msg("removing %s", cdev->name);
devfs_remove(cdev); devfs_remove(cdev);
kfree(cdev->name); kfree(cdev->name);

View File

@ -1054,8 +1054,8 @@ int ubi_scan_fastmap(struct ubi_device *ubi, struct ubi_attach_info *ai,
ubi->fm_pool.max_size = ubi->fm->max_pool_size; ubi->fm_pool.max_size = ubi->fm->max_pool_size;
ubi->fm_wl_pool.max_size = ubi->fm->max_wl_pool_size; ubi->fm_wl_pool.max_size = ubi->fm->max_wl_pool_size;
ubi_msg("attached by fastmap"); ubi_msg("attached by fastmap");
ubi_msg("fastmap pool size: %d", ubi->fm_pool.max_size); ubi_debug("fastmap pool size: %d", ubi->fm_pool.max_size);
ubi_msg("fastmap WL pool size: %d", ubi->fm_wl_pool.max_size); ubi_debug("fastmap WL pool size: %d", ubi->fm_wl_pool.max_size);
ubi->fm_disabled = 0; ubi->fm_disabled = 0;
ubi_free_vid_hdr(ubi, vh); ubi_free_vid_hdr(ubi, vh);

View File

@ -39,6 +39,7 @@
/* UBI name used for character devices, sysfs, etc */ /* UBI name used for character devices, sysfs, etc */
#define UBI_NAME_STR "ubi" #define UBI_NAME_STR "ubi"
#define ubi_debug(fmt, ...) pr_debug("UBI: " fmt "\n", ##__VA_ARGS__)
/* Normal UBI messages */ /* Normal UBI messages */
#define ubi_msg(fmt, ...) pr_info("UBI: " fmt "\n", ##__VA_ARGS__) #define ubi_msg(fmt, ...) pr_info("UBI: " fmt "\n", ##__VA_ARGS__)
/* UBI warning messages */ /* UBI warning messages */

View File

@ -257,12 +257,12 @@ static int init_constants_early(struct ubifs_info *c)
} }
if (c->di.ro_mode) { if (c->di.ro_mode) {
ubifs_msg("read-only UBI device"); dbg_msg("read-only UBI device");
c->ro_media = 1; c->ro_media = 1;
} }
if (c->vi.vol_type == UBI_STATIC_VOLUME) { if (c->vi.vol_type == UBI_STATIC_VOLUME) {
ubifs_msg("static UBI volume - read-only mode"); dbg_msg("static UBI volume - read-only mode");
c->ro_media = 1; c->ro_media = 1;
} }
@ -540,6 +540,7 @@ static int mount_ubifs(struct ubifs_info *c)
int err, mounted_read_only = ubifs_readonly(c); int err, mounted_read_only = ubifs_readonly(c);
long long x; long long x;
size_t sz; size_t sz;
char str[128];
err = init_constants_early(c); err = init_constants_early(c);
if (err) if (err)
@ -676,18 +677,19 @@ static int mount_ubifs(struct ubifs_info *c)
ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"", ubifs_msg("mounted UBI device %d, volume %d, name \"%s\"",
c->vi.ubi_num, c->vi.vol_id, c->vi.name); c->vi.ubi_num, c->vi.vol_id, c->vi.name);
if (mounted_read_only) if (mounted_read_only)
ubifs_msg("mounted read-only"); dbg_msg("mounted read-only");
x = (long long)c->main_lebs * c->leb_size; x = (long long)c->main_lebs * c->leb_size;
ubifs_msg("file system size: %lld bytes (%lld KiB, %lld MiB, %d " c->fs_size_mb = x >> 20;
dbg_msg("file system size: %lld bytes (%lld KiB, %lld MiB, %d "
"LEBs)", x, x >> 10, x >> 20, c->main_lebs); "LEBs)", x, x >> 10, x >> 20, c->main_lebs);
x = (long long)c->log_lebs * c->leb_size + c->max_bud_bytes; x = (long long)c->log_lebs * c->leb_size + c->max_bud_bytes;
ubifs_msg("journal size: %lld bytes (%lld KiB, %lld MiB, %d " dbg_msg("journal size: %lld bytes (%lld KiB, %lld MiB, %d "
"LEBs)", x, x >> 10, x >> 20, c->log_lebs + c->max_bud_cnt); "LEBs)", x, x >> 10, x >> 20, c->log_lebs + c->max_bud_cnt);
ubifs_msg("media format: w%d/r%d (latest is w%d/r%d)", dbg_msg("media format: w%d/r%d (latest is w%d/r%d)",
c->fmt_version, c->ro_compat_version, c->fmt_version, c->ro_compat_version,
UBIFS_FORMAT_VERSION, UBIFS_RO_COMPAT_VERSION); UBIFS_FORMAT_VERSION, UBIFS_RO_COMPAT_VERSION);
ubifs_msg("default compressor: %s", ubifs_compr_name(c->default_compr)); dbg_msg("default compressor: %s", ubifs_compr_name(c->default_compr));
ubifs_msg("reserved for root: %llu bytes (%llu KiB)", dbg_msg("reserved for root: %llu bytes (%llu KiB)",
c->report_rp_size, c->report_rp_size >> 10); c->report_rp_size, c->report_rp_size >> 10);
dbg_msg("compiled on: " __DATE__ " at " __TIME__); dbg_msg("compiled on: " __DATE__ " at " __TIME__);
@ -696,6 +698,14 @@ static int mount_ubifs(struct ubifs_info *c)
c->leb_size, c->leb_size >> 10); c->leb_size, c->leb_size >> 10);
dbg_msg("data journal heads: %d", dbg_msg("data journal heads: %d",
c->jhead_cnt - NONDATA_JHEADS_CNT); c->jhead_cnt - NONDATA_JHEADS_CNT);
dev_add_param_int_ro(c->dev, "filesystem_size_mb", c->fs_size_mb, "%d");
dev_add_param_fixed(c->dev, "default_compressor", ubifs_compr_name(c->default_compr));
sprintf(str, "w%d/r%d", c->fmt_version, c->ro_compat_version);
dev_add_param_fixed(c->dev, "media_format", str);
sprintf(str, "w%d/r%d", UBIFS_FORMAT_VERSION, UBIFS_RO_COMPAT_VERSION);
dev_add_param_fixed(c->dev, "media_format_latest", str);
dbg_msg("UUID: %02X%02X%02X%02X-%02X%02X" dbg_msg("UUID: %02X%02X%02X%02X-%02X%02X"
"-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X", "-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
c->uuid[0], c->uuid[1], c->uuid[2], c->uuid[3], c->uuid[0], c->uuid[1], c->uuid[2], c->uuid[3],
@ -804,7 +814,7 @@ void ubifs_umount(struct ubifs_info *c)
ubifs_debugging_exit(c); ubifs_debugging_exit(c);
} }
struct super_block *ubifs_get_super(struct ubi_volume_desc *ubi, int silent) struct super_block *ubifs_get_super(struct device_d *dev, struct ubi_volume_desc *ubi, int silent)
{ {
struct super_block *sb; struct super_block *sb;
struct ubifs_info *c; struct ubifs_info *c;
@ -814,6 +824,8 @@ struct super_block *ubifs_get_super(struct ubi_volume_desc *ubi, int silent)
sb = xzalloc(sizeof(*sb)); sb = xzalloc(sizeof(*sb));
c = xzalloc(sizeof(struct ubifs_info)); c = xzalloc(sizeof(struct ubifs_info));
c->dev = dev;
spin_lock_init(&c->cnt_lock); spin_lock_init(&c->cnt_lock);
spin_lock_init(&c->cs_lock); spin_lock_init(&c->cs_lock);
spin_lock_init(&c->buds_lock); spin_lock_init(&c->buds_lock);

View File

@ -49,11 +49,13 @@ struct z_stream_s ubifs_zlib_stream;
/* compress.c */ /* compress.c */
#ifdef CONFIG_ZLIB
static int ubifs_deflate_decompress(const u8 *src, unsigned int slen, u8 *dst, static int ubifs_deflate_decompress(const u8 *src, unsigned int slen, u8 *dst,
unsigned int *dlen) unsigned int *dlen)
{ {
return deflate_decompress(&ubifs_zlib_stream, src, slen, dst, dlen); return deflate_decompress(&ubifs_zlib_stream, src, slen, dst, dlen);
} }
#endif
/* All UBIFS compressors */ /* All UBIFS compressors */
struct ubifs_compressor ubifs_compressors[UBIFS_COMPR_TYPES_CNT] = { struct ubifs_compressor ubifs_compressors[UBIFS_COMPR_TYPES_CNT] = {
@ -608,7 +610,7 @@ static int ubifs_probe(struct device_d *dev)
goto err_free; goto err_free;
} }
priv->sb = ubifs_get_super(priv->ubi, 0); priv->sb = ubifs_get_super(dev, priv->ubi, 0);
if (IS_ERR(priv->sb)) { if (IS_ERR(priv->sb)) {
ret = PTR_ERR(priv->sb); ret = PTR_ERR(priv->sb);
goto err; goto err;

View File

@ -470,12 +470,8 @@ static inline ino_t parent_ino(struct dentry *dentry)
#define UBIFS_VERSION 1 #define UBIFS_VERSION 1
/* Normal UBIFS messages */ /* Normal UBIFS messages */
#ifdef CONFIG_UBIFS_SILENCE_MSG
#define ubifs_msg(fmt, ...)
#else
#define ubifs_msg(fmt, ...) \ #define ubifs_msg(fmt, ...) \
pr_notice("UBIFS: " fmt "\n", ##__VA_ARGS__) pr_info("UBIFS: " fmt "\n", ##__VA_ARGS__)
#endif
/* UBIFS error messages */ /* UBIFS error messages */
#define ubifs_err(fmt, ...) \ #define ubifs_err(fmt, ...) \
pr_err("UBIFS error (pid %d): %s: " fmt "\n", 0, \ pr_err("UBIFS error (pid %d): %s: " fmt "\n", 0, \
@ -1824,6 +1820,9 @@ struct ubifs_info {
int always_chk_crc; int always_chk_crc;
struct ubifs_mount_opts mount_opts; struct ubifs_mount_opts mount_opts;
unsigned int fs_size_mb;
struct device_d *dev;
#ifdef CONFIG_UBIFS_FS_DEBUG #ifdef CONFIG_UBIFS_FS_DEBUG
struct ubifs_debug_info *dbg; struct ubifs_debug_info *dbg;
#endif #endif
@ -2140,7 +2139,7 @@ long ubifs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
#include "misc.h" #include "misc.h"
#include "key.h" #include "key.h"
struct super_block *ubifs_get_super(struct ubi_volume_desc *ubi, int silent); struct super_block *ubifs_get_super(struct device_d *dev, struct ubi_volume_desc *ubi, int silent);
void ubifs_umount(struct ubifs_info *); void ubifs_umount(struct ubifs_info *);
static inline int ubifs_readonly(struct ubifs_info *c) static inline int ubifs_readonly(struct ubifs_info *c)

View File

@ -54,7 +54,7 @@ struct param_d *dev_add_param_ip(struct device_d *dev, const char *name,
int (*get)(struct param_d *p, void *priv), int (*get)(struct param_d *p, void *priv),
IPaddr_t *ip, void *priv); IPaddr_t *ip, void *priv);
int dev_add_param_fixed(struct device_d *dev, char *name, char *value); int dev_add_param_fixed(struct device_d *dev, char *name, const char *value);
void dev_remove_param(struct param_d *p); void dev_remove_param(struct param_d *p);

View File

@ -183,7 +183,7 @@ int dev_add_param(struct device_d *dev, const char *name,
* @param name The name of the parameter * @param name The name of the parameter
* @param value The value of the parameter * @param value The value of the parameter
*/ */
int dev_add_param_fixed(struct device_d *dev, char *name, char *value) int dev_add_param_fixed(struct device_d *dev, char *name, const char *value)
{ {
struct param_d *param; struct param_d *param;
int ret; int ret;