Merge branch 'for-linus' of git://git.kernel.dk/linux-block
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 23 Oct 2015 22:20:57 +0000 (07:20 +0900)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 23 Oct 2015 22:20:57 +0000 (07:20 +0900)
Pull block layer fixes from Jens Axboe:
 "A final set of fixes for 4.3.

  It is (again) bigger than I would have liked, but it's all been
  through the testing mill and has been carefully reviewed by multiple
  parties.  Each fix is either a regression fix for this cycle, or is
  marked stable.  You can scold me at KS.  The pull request contains:

   - Three simple fixes for NVMe, fixing regressions since 4.3.  From
     Arnd, Christoph, and Keith.

   - A single xen-blkfront fix from Cathy, fixing a NULL dereference if
     an error is returned through the staste change callback.

   - Fixup for some bad/sloppy code in nbd that got introduced earlier
     in this cycle.  From Markus Pargmann.

   - A blk-mq tagset use-after-free fix from Junichi.

   - A backing device lifetime fix from Tejun, fixing a crash.

   - And finally, a set of regression/stable fixes for cgroup writeback
     from Tejun"

* 'for-linus' of git://git.kernel.dk/linux-block:
  writeback: remove broken rbtree_postorder_for_each_entry_safe() usage in cgwb_bdi_destroy()
  NVMe: Fix memory leak on retried commands
  block: don't release bdi while request_queue has live references
  nvme: use an integer value to Linux errno values
  blk-mq: fix use-after-free in blk_mq_free_tag_set()
  nvme: fix 32-bit build warning
  writeback: fix incorrect calculation of available memory for memcg domains
  writeback: memcg dirty_throttle_control should be initialized with wb->memcg_completions
  writeback: bdi_writeback iteration must not skip dying ones
  writeback: fix bdi_writeback iteration in wakeup_dirtytime_writeback()
  writeback: laptop_mode_timer_fn() needs rcu_read_lock() around bdi_writeback iteration
  nbd: Add locking for tasks
  xen-blkfront: check for null drvdata in blkback_changed (XenbusStateClosing)

1  2 
mm/memcontrol.c

diff --combined mm/memcontrol.c
index d9b5c817dce8e0a99aab1853eafc572e5b70015f,882c10cfd0ba4037faab3e071169ed8f08d669d7..c57c4423c68837d14816c5ff230435e1567e7c20
@@@ -3387,7 -3387,6 +3387,7 @@@ static int __mem_cgroup_usage_register_
        ret = page_counter_memparse(args, "-1", &threshold);
        if (ret)
                return ret;
 +      threshold <<= PAGE_SHIFT;
  
        mutex_lock(&memcg->thresholds_lock);
  
@@@ -3741,44 -3740,43 +3741,43 @@@ struct wb_domain *mem_cgroup_wb_domain(
  /**
   * mem_cgroup_wb_stats - retrieve writeback related stats from its memcg
   * @wb: bdi_writeback in question
-  * @pavail: out parameter for number of available pages
+  * @pfilepages: out parameter for number of file pages
+  * @pheadroom: out parameter for number of allocatable pages according to memcg
   * @pdirty: out parameter for number of dirty pages
   * @pwriteback: out parameter for number of pages under writeback
   *
-  * Determine the numbers of available, dirty, and writeback pages in @wb's
-  * memcg.  Dirty and writeback are self-explanatory.  Available is a bit
-  * more involved.
+  * Determine the numbers of file, headroom, dirty, and writeback pages in
+  * @wb's memcg.  File, dirty and writeback are self-explanatory.  Headroom
+  * is a bit more involved.
   *
-  * A memcg's headroom is "min(max, high) - used".  The available memory is
-  * calculated as the lowest headroom of itself and the ancestors plus the
-  * number of pages already being used for file pages.  Note that this
-  * doesn't consider the actual amount of available memory in the system.
-  * The caller should further cap *@pavail accordingly.
+  * A memcg's headroom is "min(max, high) - used".  In the hierarchy, the
+  * headroom is calculated as the lowest headroom of itself and the
+  * ancestors.  Note that this doesn't consider the actual amount of
+  * available memory in the system.  The caller should further cap
+  * *@pheadroom accordingly.
   */
- void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pavail,
-                        unsigned long *pdirty, unsigned long *pwriteback)
+ void mem_cgroup_wb_stats(struct bdi_writeback *wb, unsigned long *pfilepages,
+                        unsigned long *pheadroom, unsigned long *pdirty,
+                        unsigned long *pwriteback)
  {
        struct mem_cgroup *memcg = mem_cgroup_from_css(wb->memcg_css);
        struct mem_cgroup *parent;
-       unsigned long head_room = PAGE_COUNTER_MAX;
-       unsigned long file_pages;
  
        *pdirty = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_DIRTY);
  
        /* this should eventually include NR_UNSTABLE_NFS */
        *pwriteback = mem_cgroup_read_stat(memcg, MEM_CGROUP_STAT_WRITEBACK);
+       *pfilepages = mem_cgroup_nr_lru_pages(memcg, (1 << LRU_INACTIVE_FILE) |
+                                                    (1 << LRU_ACTIVE_FILE));
+       *pheadroom = PAGE_COUNTER_MAX;
  
-       file_pages = mem_cgroup_nr_lru_pages(memcg, (1 << LRU_INACTIVE_FILE) |
-                                                   (1 << LRU_ACTIVE_FILE));
        while ((parent = parent_mem_cgroup(memcg))) {
                unsigned long ceiling = min(memcg->memory.limit, memcg->high);
                unsigned long used = page_counter_read(&memcg->memory);
  
-               head_room = min(head_room, ceiling - min(ceiling, used));
+               *pheadroom = min(*pheadroom, ceiling - min(ceiling, used));
                memcg = parent;
        }
-       *pavail = file_pages + head_room;
  }
  
  #else /* CONFIG_CGROUP_WRITEBACK */