1. 03 10月, 2020 5 次提交
    • C
      bcache: explicitly make cache_set only have single cache · 697e2349
      Coly Li 提交于
      Currently although the bcache code has a framework for multiple caches
      in a cache set, but indeed the multiple caches never completed and users
      use md raid1 for multiple copies of the cached data.
      
      This patch does the following change in struct cache_set, to explicitly
      make a cache_set only have single cache,
      - Change pointer array "*cache[MAX_CACHES_PER_SET]" to a single pointer
        "*cache".
      - Remove pointer array "*cache_by_alloc[MAX_CACHES_PER_SET]".
      - Remove "caches_loaded".
      
      Now the code looks as exactly what it does in practic: only one cache is
      used in the cache set.
      Signed-off-by: NColy Li <colyli@suse.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      697e2349
    • C
      bcache: remove 'int n' from parameter list of bch_bucket_alloc_set() · 17e4aed8
      Coly Li 提交于
      The parameter 'int n' from bch_bucket_alloc_set() is not cleared
      defined. From the code comments n is the number of buckets to alloc, but
      from the code itself 'n' is the maximum cache to iterate. Indeed all the
      locations where bch_bucket_alloc_set() is called, 'n' is alwasy 1.
      
      This patch removes the confused and unnecessary 'int n' from parameter
      list of  bch_bucket_alloc_set(), and explicitly allocates only 1 bucket
      for its caller.
      Signed-off-by: NColy Li <colyli@suse.de>
      Reviewed-by: NHannes Reinecke <hare@suse.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      17e4aed8
    • Q
      bcache: Convert to DEFINE_SHOW_ATTRIBUTE · 84e5d136
      Qinglang Miao 提交于
      Use DEFINE_SHOW_ATTRIBUTE macro to simplify the code.
      
      As inode->iprivate equals to third parameter of
      debugfs_create_file() which is NULL. So it's equivalent
      to original code logic.
      Signed-off-by: NQinglang Miao <miaoqinglang@huawei.com>
      Signed-off-by: NColy Li <colyli@suse.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      84e5d136
    • D
      bcache: check c->root with IS_ERR_OR_NULL() in mca_reserve() · 7e59c506
      Dongsheng Yang 提交于
      In mca_reserve(c) macro, we are checking root whether is NULL or not.
      But that's not enough, when we read the root node in run_cache_set(),
      if we got an error in bch_btree_node_read_done(), we will return
      ERR_PTR(-EIO) to c->root.
      
      And then we will go continue to unregister, but before calling
      unregister_shrinker(&c->shrink), there is a possibility to call
      bch_mca_count(), and we would get a crash with call trace like that:
      
      [ 2149.876008] Unable to handle kernel NULL pointer dereference at virtual address 00000000000000b5
      ... ...
      [ 2150.598931] Call trace:
      [ 2150.606439]  bch_mca_count+0x58/0x98 [escache]
      [ 2150.615866]  do_shrink_slab+0x54/0x310
      [ 2150.624429]  shrink_slab+0x248/0x2d0
      [ 2150.632633]  drop_slab_node+0x54/0x88
      [ 2150.640746]  drop_slab+0x50/0x88
      [ 2150.648228]  drop_caches_sysctl_handler+0xf0/0x118
      [ 2150.657219]  proc_sys_call_handler.isra.18+0xb8/0x110
      [ 2150.666342]  proc_sys_write+0x40/0x50
      [ 2150.673889]  __vfs_write+0x48/0x90
      [ 2150.681095]  vfs_write+0xac/0x1b8
      [ 2150.688145]  ksys_write+0x6c/0xd0
      [ 2150.695127]  __arm64_sys_write+0x24/0x30
      [ 2150.702749]  el0_svc_handler+0xa0/0x128
      [ 2150.710296]  el0_svc+0x8/0xc
      Signed-off-by: NDongsheng Yang <dongsheng.yang@easystack.cn>
      Signed-off-by: NColy Li <colyli@suse.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      7e59c506
    • C
      bcache: share register sysfs with async register · a58e88bf
      Coly Li 提交于
      Previously the experimental async registration uses a separate sysfs
      file register_async. Now the async registration code seems working well
      for a while, we can do furtuher testing with it now.
      
      This patch changes the async bcache registration shares the same sysfs
      file /sys/fs/bcache/register (and register_quiet). Async registration
      will be default behavior if BCACHE_ASYNC_REGISTRATION is set in kernel
      configure. By default, BCACHE_ASYNC_REGISTRATION is not configured yet.
      Signed-off-by: NColy Li <colyli@suse.de>
      Signed-off-by: NJens Axboe <axboe@kernel.dk>
      a58e88bf
  2. 25 9月, 2020 19 次提交
  3. 20 9月, 2020 2 次提交
  4. 12 9月, 2020 2 次提交
  5. 10 9月, 2020 1 次提交
  6. 03 9月, 2020 3 次提交
    • Y
      dm thin metadata: Fix use-after-free in dm_bm_set_read_only · 3a653b20
      Ye Bin 提交于
      The following error ocurred when testing disk online/offline:
      
      [  301.798344] device-mapper: thin: 253:5: aborting current metadata transaction
      [  301.848441] device-mapper: thin: 253:5: failed to abort metadata transaction
      [  301.849206] Aborting journal on device dm-26-8.
      [  301.850489] EXT4-fs error (device dm-26) in __ext4_new_inode:943: Journal has aborted
      [  301.851095] EXT4-fs (dm-26): Delayed block allocation failed for inode 398742 at logical offset 181 with max blocks 19 with error 30
      [  301.854476] BUG: KASAN: use-after-free in dm_bm_set_read_only+0x3a/0x40 [dm_persistent_data]
      
      Reason is:
      
       metadata_operation_failed
          abort_transaction
              dm_pool_abort_metadata
      	    __create_persistent_data_objects
      	        r = __open_or_format_metadata
      	        if (r) --> If failed will free pmd->bm but pmd->bm not set NULL
      		    dm_block_manager_destroy(pmd->bm);
          set_pool_mode
      	dm_pool_metadata_read_only(pool->pmd);
      	dm_bm_set_read_only(pmd->bm);  --> use-after-free
      
      Add checks to see if pmd->bm is NULL in dm_bm_set_read_only and
      dm_bm_set_read_write functions.  If bm is NULL it means creating the
      bm failed and so dm_bm_is_read_only must return true.
      Signed-off-by: NYe Bin <yebin10@huawei.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      3a653b20
    • Y
      dm thin metadata: Avoid returning cmd->bm wild pointer on error · 219403d7
      Ye Bin 提交于
      Maybe __create_persistent_data_objects() caller will use PTR_ERR as a
      pointer, it will lead to some strange things.
      Signed-off-by: NYe Bin <yebin10@huawei.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      219403d7
    • Y
      dm cache metadata: Avoid returning cmd->bm wild pointer on error · d16ff19e
      Ye Bin 提交于
      Maybe __create_persistent_data_objects() caller will use PTR_ERR as a
      pointer, it will lead to some strange things.
      Signed-off-by: NYe Bin <yebin10@huawei.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      d16ff19e
  7. 02 9月, 2020 7 次提交
  8. 28 8月, 2020 1 次提交
    • Y
      md/raid5: make sure stripe_size as power of two · 6af10a33
      Yufen Yu 提交于
      Commit 3b5408b9 ("md/raid5: support config stripe_size by sysfs
      entry") make stripe_size as a configurable value. It just requires
      stripe_size as multiple of 4KB.
      
      In fact, we should make sure stripe_size as power of two. Otherwise,
      stripe_shift which is the result of ilog2 can not represent the real
      stripe_size. Then, stripe_hash() and stripe_hash_locks_hash() may
      get unexpected value.
      
      Fixes: 3b5408b9 ("md/raid5: support config stripe_size by sysfs entry")
      Signed-off-by: NYufen Yu <yuyufen@huawei.com>
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      6af10a33