Skip to content
  1. Jun 21, 2019
  2. Jun 20, 2019
  3. Jun 17, 2019
  4. Jun 16, 2019
    • Tejun Heo's avatar
      blkcg, writeback: dead memcgs shouldn't contribute to writeback ownership arbitration · 66311422
      Tejun Heo authored
      
      
      wbc_account_io() collects information on cgroup ownership of writeback
      pages to determine which cgroup should own the inode.  Pages can stay
      associated with dead memcgs but we want to avoid attributing IOs to
      dead blkcgs as much as possible as the association is likely to be
      stale.  However, currently, pages associated with dead memcgs
      contribute to the accounting delaying and/or confusing the
      arbitration.
      
      Fix it by ignoring pages associated with dead memcgs.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Jan Kara <jack@suse.cz>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      66311422
    • Tejun Heo's avatar
      blkcg: blkcg_activate_policy() should initialize ancestors first · 71c81407
      Tejun Heo authored
      
      
      When blkcg_activate_policy() is creating blkg_policy_data for existing
      blkgs, it did in the wrong order - descendants first.  Fix it.  None
      of the existing controllers seem affected by this.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      71c81407
    • Tejun Heo's avatar
      blkcg: perpcu_ref init/exit should be done from blkg_alloc/free() · ef069b97
      Tejun Heo authored
      blkg alloc is performed as a separate step from the rest of blkg
      creation so that GFP_KERNEL allocations can be used when creating
      blkgs from configuration file writes because otherwise user actions
      may fail due to failures of opportunistic GFP_NOWAIT allocations.
      
      While making blkgs use percpu_ref, 7fcf2b03
      
       ("blkcg: change blkg
      reference counting to use percpu_ref") incorrectly added unconditional
      opportunistic percpu_ref_init() to blkg_create() breaking this
      guarantee.
      
      This patch moves percpu_ref_init() to blkg_alloc() so makes it use
      @gfp_mask that blkg_alloc() is called with.  Also, percpu_ref_exit()
      is moved to blkg_free() for consistency.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Fixes: 7fcf2b03
      
       ("blkcg: change blkg reference counting to use percpu_ref")
      Cc: Dennis Zhou <dennis@kernel.org>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      ef069b97
    • Tejun Heo's avatar
      blkcg: update blkcg_print_stat() to handle larger outputs · f539da82
      Tejun Heo authored
      
      
      Depending on the number of devices, blkcg stats can go over the
      default seqfile buf size.  seqfile normally retries with a larger
      buffer but since the ->pd_stat() addition, blkcg_print_stat() doesn't
      tell seqfile that overflow has happened and the output gets printed
      truncated.  Fix it by calling seq_commit() w/ -1 on possible
      overflows.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Fixes: 903d23f0
      
       ("blk-cgroup: allow controllers to output their own stats")
      Cc: stable@vger.kernel.org # v4.19+
      Cc: Josef Bacik <jbacik@fb.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      f539da82
    • Tejun Heo's avatar
      blk-iolatency: clear use_delay when io.latency is set to zero · 5de0073f
      Tejun Heo authored
      
      
      If use_delay was non-zero when the latency target of a cgroup was set
      to zero, it will stay stuck until io.latency is enabled on the cgroup
      again.  This keeps readahead disabled for the cgroup impacting
      performance negatively.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Josef Bacik <jbacik@fb.com>
      Fixes: d7067512
      
       ("block: introduce blk-iolatency io controller")
      Cc: stable@vger.kernel.org # v4.19+
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      5de0073f
  5. Jun 15, 2019
    • Gustavo A. R. Silva's avatar
      block: bio: Use struct_size() in kmalloc() · f1f8f292
      Gustavo A. R. Silva authored
      
      
      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 bio_map_data {
      	...
              struct iovec iov[];
      };
      
      instance = kmalloc(sizeof(sizeof(struct bio_map_data) + sizeof(struct iovec) *
                                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, iov, count), GFP_KERNEL);
      
      This code was detected with the help of Coccinelle.
      
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      f1f8f292
    • Gustavo A. R. Silva's avatar
      block: genhd: Use struct_size() helper · 78b90a2c
      Gustavo A. R. Silva authored
      
      
      Make use of the struct_size() helper instead of an open-coded version
      in order to avoid any potential type mistakes, in particular in the
      context in which this code is being used.
      
      So, replace the following form:
      
      sizeof(*new_ptbl) + target * sizeof(new_ptbl->part[0])
      
      with:
      
      struct_size(new_ptbl, part, target)
      
      Also, notice that variable size is unnecessary, hence it is removed.
      
      This code was detected with the help of Coccinelle.
      
      Signed-off-by: default avatarGustavo A. R. Silva <gustavo@embeddedor.com>
      Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
      78b90a2c