]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge remote-tracking branch 'ubifs/linux-next'
authorStephen Rothwell <sfr@canb.auug.org.au>
Thu, 5 Nov 2015 00:18:58 +0000 (11:18 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 5 Nov 2015 00:18:58 +0000 (11:18 +1100)
drivers/mtd/ubi/attach.c
drivers/mtd/ubi/eba.c
drivers/mtd/ubi/fastmap-wl.c
drivers/mtd/ubi/fastmap.c
drivers/mtd/ubi/gluebi.c
drivers/mtd/ubi/ubi-media.h
fs/ubifs/debug.c
fs/ubifs/lpt.c
fs/ubifs/recovery.c
fs/ubifs/tnc.c
fs/ubifs/ubifs.h

index 68eea5befaf12c96db4063a32ab81c20a8abfd96..c1aaf0336cf2e389386b4a6f7c87a8609652b474 100644 (file)
@@ -1209,9 +1209,7 @@ static void destroy_ai(struct ubi_attach_info *ai)
                }
        }
 
-       if (ai->aeb_slab_cache)
-               kmem_cache_destroy(ai->aeb_slab_cache);
-
+       kmem_cache_destroy(ai->aeb_slab_cache);
        kfree(ai);
 }
 
index 51bca035cd83c5b60d8912d22f358984f13abe1f..5b9834cf2820f184577345b74993868149bdc985 100644 (file)
@@ -1358,7 +1358,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
                                        continue;
 
                                ubi_err(ubi, "LEB:%i:%i is PEB:%i instead of %i!",
-                                       vol->vol_id, i, fm_eba[i][j],
+                                       vol->vol_id, j, fm_eba[i][j],
                                        scan_eba[i][j]);
                                ubi_assert(0);
                        }
index b2a665398bcaf41225f6a9cbe858e8df209c3b89..30d3999dddbae93a6fd362c3bcd8fa40e0e6c8f1 100644 (file)
@@ -171,6 +171,30 @@ void ubi_refill_pools(struct ubi_device *ubi)
        spin_unlock(&ubi->wl_lock);
 }
 
+/**
+ * produce_free_peb - produce a free physical eraseblock.
+ * @ubi: UBI device description object
+ *
+ * This function tries to make a free PEB by means of synchronous execution of
+ * pending works. This may be needed if, for example the background thread is
+ * disabled. Returns zero in case of success and a negative error code in case
+ * of failure.
+ */
+static int produce_free_peb(struct ubi_device *ubi)
+{
+       int err;
+
+       while (!ubi->free.rb_node && ubi->works_count) {
+               dbg_wl("do one work synchronously");
+               err = do_work(ubi);
+
+               if (err)
+                       return err;
+       }
+
+       return 0;
+}
+
 /**
  * ubi_wl_get_peb - get a physical eraseblock.
  * @ubi: UBI device description object
@@ -213,6 +237,11 @@ again:
                }
                retried = 1;
                up_read(&ubi->fm_eba_sem);
+               ret = produce_free_peb(ubi);
+               if (ret < 0) {
+                       down_read(&ubi->fm_eba_sem);
+                       goto out;
+               }
                goto again;
        }
 
index 4aa2fd8633e769b0ae6b09ecf3e267031a00c1f3..0e6bfaf850f3d5cb11a621aa7a96b1b5440699f5 100644 (file)
@@ -775,7 +775,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
                for (j = 0; j < be32_to_cpu(fm_eba->reserved_pebs); j++) {
                        int pnum = be32_to_cpu(fm_eba->pnum[j]);
 
-                       if ((int)be32_to_cpu(fm_eba->pnum[j]) < 0)
+                       if (pnum < 0)
                                continue;
 
                        aeb = NULL;
index b93807b4c45966f2b3cdeef1e55c4c237e1bbd3c..cb7c075f2144969d5f416d440060455ee2904933 100644 (file)
@@ -112,8 +112,8 @@ static int gluebi_get_device(struct mtd_info *mtd)
                 * The MTD device is already referenced and this is just one
                 * more reference. MTD allows many users to open the same
                 * volume simultaneously and do not distinguish between
-                * readers/writers/exclusive openers as UBI does. So we do not
-                * open the UBI volume again - just increase the reference
+                * readers/writers/exclusive/meta openers as UBI does. So we do
+                * not open the UBI volume again - just increase the reference
                 * counter and return.
                 */
                gluebi->refcnt += 1;
index d0d072e7ccd2f78fa1ee6df63934308bffe43177..22ed3f627506c4e2b4daee328b97fa8dbfce3896 100644 (file)
@@ -500,7 +500,7 @@ struct ubi_fm_volhdr {
 /* struct ubi_fm_volhdr is followed by one struct ubi_fm_eba records */
 
 /**
- * struct ubi_fm_eba - denotes an association beween a PEB and LEB
+ * struct ubi_fm_eba - denotes an association between a PEB and LEB
  * @magic: EBA table magic number
  * @reserved_pebs: number of table entries
  * @pnum: PEB number of LEB (LEB is the index)
index 4c46a9865fa74b71d77e68273866c0f7a0849a18..595ca0debe1170c36c6b21af3d51226872db7939 100644 (file)
@@ -2573,7 +2573,7 @@ int dbg_leb_write(struct ubifs_info *c, int lnum, const void *buf,
 {
        int err, failing;
 
-       if (c->dbg->pc_happened)
+       if (dbg_is_power_cut(c))
                return -EROFS;
 
        failing = power_cut_emulated(c, lnum, 1);
@@ -2595,7 +2595,7 @@ int dbg_leb_change(struct ubifs_info *c, int lnum, const void *buf,
 {
        int err;
 
-       if (c->dbg->pc_happened)
+       if (dbg_is_power_cut(c))
                return -EROFS;
        if (power_cut_emulated(c, lnum, 1))
                return -EROFS;
@@ -2611,7 +2611,7 @@ int dbg_leb_unmap(struct ubifs_info *c, int lnum)
 {
        int err;
 
-       if (c->dbg->pc_happened)
+       if (dbg_is_power_cut(c))
                return -EROFS;
        if (power_cut_emulated(c, lnum, 0))
                return -EROFS;
@@ -2627,7 +2627,7 @@ int dbg_leb_map(struct ubifs_info *c, int lnum)
 {
        int err;
 
-       if (c->dbg->pc_happened)
+       if (dbg_is_power_cut(c))
                return -EROFS;
        if (power_cut_emulated(c, lnum, 0))
                return -EROFS;
index dc9f27e9d61be5b8586af0025d95a0dc305afecc..9a517109da0feda2ac19ba4781072ab4ab4aad31 100644 (file)
@@ -1498,11 +1498,10 @@ static struct ubifs_nnode *dirty_cow_nnode(struct ubifs_info *c,
        }
 
        /* nnode is being committed, so copy it */
-       n = kmalloc(sizeof(struct ubifs_nnode), GFP_NOFS);
+       n = kmemdup(nnode, sizeof(struct ubifs_nnode), GFP_NOFS);
        if (unlikely(!n))
                return ERR_PTR(-ENOMEM);
 
-       memcpy(n, nnode, sizeof(struct ubifs_nnode));
        n->cnext = NULL;
        __set_bit(DIRTY_CNODE, &n->flags);
        __clear_bit(COW_CNODE, &n->flags);
@@ -1549,11 +1548,10 @@ static struct ubifs_pnode *dirty_cow_pnode(struct ubifs_info *c,
        }
 
        /* pnode is being committed, so copy it */
-       p = kmalloc(sizeof(struct ubifs_pnode), GFP_NOFS);
+       p = kmemdup(pnode, sizeof(struct ubifs_pnode), GFP_NOFS);
        if (unlikely(!p))
                return ERR_PTR(-ENOMEM);
 
-       memcpy(p, pnode, sizeof(struct ubifs_pnode));
        p->cnext = NULL;
        __set_bit(DIRTY_CNODE, &p->flags);
        __clear_bit(COW_CNODE, &p->flags);
index 695fc71d5244c6e0a24b2bb5ac80b9c72e421e28..2a1f0bc836be9df3398cf8a489a54be0a3bb4ec5 100644 (file)
@@ -789,7 +789,7 @@ struct ubifs_scan_leb *ubifs_recover_leb(struct ubifs_info *c, int lnum,
 corrupted_rescan:
        /* Re-scan the corrupted data with verbose messages */
        ubifs_err(c, "corruption %d", ret);
-       ubifs_scan_a_node(c, buf, len, lnum, offs, 1);
+       ubifs_scan_a_node(c, buf, len, lnum, offs, 0);
 corrupted:
        ubifs_scanned_corruption(c, lnum, offs, buf);
        err = -EUCLEAN;
index 957f5757f3742bf07cdb6747b27b60b8ff2bf97a..fa9a20cc60d6744e13ef7cc2f788f0fda0861d58 100644 (file)
@@ -198,11 +198,10 @@ static struct ubifs_znode *copy_znode(struct ubifs_info *c,
 {
        struct ubifs_znode *zn;
 
-       zn = kmalloc(c->max_znode_sz, GFP_NOFS);
+       zn = kmemdup(znode, c->max_znode_sz, GFP_NOFS);
        if (unlikely(!zn))
                return ERR_PTR(-ENOMEM);
 
-       memcpy(zn, znode, c->max_znode_sz);
        zn->cnext = NULL;
        __set_bit(DIRTY_ZNODE, &zn->flags);
        __clear_bit(COW_ZNODE, &zn->flags);
index de759022f3d636d74a62445ab33bd2b9b0e48dac..6ef2415aad9dd4fe452321d0e0ff231733e806c1 100644 (file)
@@ -858,9 +858,9 @@ struct ubifs_compressor {
  * @mod_dent: non-zero if the operation removes or modifies an existing
  *            directory entry
  * @new_ino: non-zero if the operation adds a new inode
- * @new_ino_d: now much data newly created inode contains
+ * @new_ino_d: how much data newly created inode contains
  * @dirtied_ino: how many inodes the operation makes dirty
- * @dirtied_ino_d: now much data dirtied inode contains
+ * @dirtied_ino_d: how much data dirtied inode contains
  * @idx_growth: how much the index will supposedly grow
  * @data_growth: how much new data the operation will supposedly add
  * @dd_growth: how much data that makes other data dirty the operation will