1. 06 11月, 2019 1 次提交
  2. 12 9月, 2019 1 次提交
    • M
      dm raid: fix updating of max_discard_sectors limit · c8156fc7
      Ming Lei 提交于
      Unit of 'chunk_size' is byte, instead of sector, so fix it by setting
      the queue_limits' max_discard_sectors to rs->md.chunk_sectors.  Also,
      rename chunk_size to chunk_size_bytes.
      
      Without this fix, too big max_discard_sectors is applied on the request
      queue of dm-raid, finally raid code has to split the bio again.
      
      This re-split done by raid causes the following nested clone_endio:
      
      1) one big bio 'A' is submitted to dm queue, and served as the original
      bio
      
      2) one new bio 'B' is cloned from the original bio 'A', and .map()
      is run on this bio of 'B', and B's original bio points to 'A'
      
      3) raid code sees that 'B' is too big, and split 'B' and re-submit
      the remainded part of 'B' to dm-raid queue via generic_make_request().
      
      4) now dm will handle 'B' as new original bio, then allocate a new
      clone bio of 'C' and run .map() on 'C'. Meantime C's original bio
      points to 'B'.
      
      5) suppose now 'C' is completed by raid directly, then the following
      clone_endio() is called recursively:
      
      	clone_endio(C)
      		->clone_endio(B)		#B is original bio of 'C'
      			->bio_endio(A)
      
      'A' can be big enough to make hundreds of nested clone_endio(), then
      stack can be corrupted easily.
      
      Fixes: 61697a6a ("dm: eliminate 'split_discard_bios' flag from DM target interface")
      Cc: stable@vger.kernel.org
      Signed-off-by: NMing Lei <ming.lei@redhat.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      c8156fc7
  3. 21 8月, 2019 1 次提交
  4. 15 7月, 2019 1 次提交
  5. 15 6月, 2019 1 次提交
  6. 21 2月, 2019 1 次提交
  7. 19 12月, 2018 1 次提交
  8. 19 10月, 2018 1 次提交
  9. 18 9月, 2018 1 次提交
  10. 07 9月, 2018 5 次提交
  11. 02 8月, 2018 1 次提交
  12. 23 6月, 2018 1 次提交
  13. 07 6月, 2018 1 次提交
    • K
      treewide: Use struct_size() for kmalloc()-family · acafe7e3
      Kees Cook 提交于
      One of the more common cases of allocation size calculations is finding
      the size of a structure that has a zero-sized array at the end, along
      with memory for some number of elements for that array. For example:
      
      struct foo {
          int stuff;
          void *entry[];
      };
      
      instance = kmalloc(sizeof(struct foo) + sizeof(void *) * count, GFP_KERNEL);
      
      Instead of leaving these open-coded and prone to type mistakes, we can
      now use the new struct_size() helper:
      
      instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);
      
      This patch makes the changes for kmalloc()-family (and kvmalloc()-family)
      uses. It was done via automatic conversion with manual review for the
      "CHECKME" non-standard cases noted below, using the following Coccinelle
      script:
      
      // pkey_cache = kmalloc(sizeof *pkey_cache + tprops->pkey_tbl_len *
      //                      sizeof *pkey_cache->table, GFP_KERNEL);
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      identifier VAR, ELEMENT;
      expression COUNT;
      @@
      
      - alloc(sizeof(*VAR) + COUNT * sizeof(*VAR->ELEMENT), GFP)
      + alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
      
      // mr = kzalloc(sizeof(*mr) + m * sizeof(mr->map[0]), GFP_KERNEL);
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      identifier VAR, ELEMENT;
      expression COUNT;
      @@
      
      - alloc(sizeof(*VAR) + COUNT * sizeof(VAR->ELEMENT[0]), GFP)
      + alloc(struct_size(VAR, ELEMENT, COUNT), GFP)
      
      // Same pattern, but can't trivially locate the trailing element name,
      // or variable name.
      @@
      identifier alloc =~ "kmalloc|kzalloc|kvmalloc|kvzalloc";
      expression GFP;
      expression SOMETHING, COUNT, ELEMENT;
      @@
      
      - alloc(sizeof(SOMETHING) + COUNT * sizeof(ELEMENT), GFP)
      + alloc(CHECKME_struct_size(&SOMETHING, ELEMENT, COUNT), GFP)
      Signed-off-by: NKees Cook <keescook@chromium.org>
      acafe7e3
  14. 05 4月, 2018 1 次提交
  15. 04 4月, 2018 2 次提交
  16. 07 3月, 2018 1 次提交
    • J
      dm raid: fix incorrect sync_ratio when degraded · da1e1488
      Jonathan Brassow 提交于
      Upstream commit 4102d9de ("dm raid: fix rs_get_progress()
      synchronization state/ratio") in combination with commit 7c29744e
      ("dm raid: simplify rs_get_progress()") introduced a regression by
      incorrectly reporting a sync_ratio of 0 for degraded raid sets.  This
      caused lvm2 to fail to repair raid legs automatically.
      
      Fix by identifying the degraded state by checking the MD_RECOVERY_INTR
      flag and returning mddev->recovery_cp in case it is set.
      
      MD sets recovery = [ MD_RECOVERY_RECOVER MD_RECOVERY_INTR
      MD_RECOVERY_NEEDED ] when a RAID member fails.  It then shuts down any
      sync thread that is running and leaves us with all MD_RECOVERY_* flags
      cleared.  The bug occurs if a status is requested in the short time it
      takes to shut down any sync thread and clear the flags, because we were
      keying in on the MD_RECOVERY_NEEDED - understanding it to be the initial
      phase of a “recover” sync thread.  However, this is an incorrect
      interpretation if MD_RECOVERY_INTR is also set.
      
      This also explains why the bug only happened when automatic repair was
      enabled and not a normal ‘manual’ method.  It is impossible to react
      quick enough to hit the problematic window without it being automated.
      
      Fix passes automatic repair tests.
      
      Fixes: 7c29744e ("dm raid: simplify rs_get_progress()")
      Signed-off-by: NJonathan Brassow <jbrassow@redhat.com>
      Signed-off-by: NHeinz Mauelshagen <heinzm@redhat.com>
      Signed-off-by: NMike Snitzer <snitzer@redhat.com>
      da1e1488
  17. 17 1月, 2018 1 次提交
  18. 14 12月, 2017 5 次提交
  19. 12 12月, 2017 1 次提交
    • S
      md: introduce new personality funciton start() · d5d885fd
      Song Liu 提交于
      In do_md_run(), md threads should not wake up until the array is fully
      initialized in md_run(). However, in raid5_run(), raid5-cache may wake
      up mddev->thread to flush stripes that need to be written back. This
      design doesn't break badly right now. But it could lead to bad bug in
      the future.
      
      This patch tries to resolve this problem by splitting start up work
      into two personality functions, run() and start(). Tasks that do not
      require the md threads should go into run(), while task that require
      the md threads go into start().
      
      r5l_load_log() is moved to raid5_start(), so it is not called until
      the md threads are started in do_md_run().
      Signed-off-by: NSong Liu <songliubraving@fb.com>
      Signed-off-by: NShaohua Li <shli@fb.com>
      d5d885fd
  20. 08 12月, 2017 11 次提交
  21. 17 11月, 2017 1 次提交