]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - include/linux/backing-dev-defs.h
KVM: Fix leak vCPU's VMCS value into other pCPU
[mirror_ubuntu-bionic-kernel.git] / include / linux / backing-dev-defs.h
index fff4cfa0c21df2117f99d93f7d6c7130d02c9d87..0e8c6647c6bde2ca15c11eb92e9bb0cee6bb0f98 100644 (file)
@@ -22,9 +22,9 @@ struct dentry;
  */
 enum wb_state {
        WB_registered,          /* bdi_register() was done */
-       WB_shutting_down,       /* wb_shutdown() in progress */
        WB_writeback_running,   /* Writeback is in progress */
        WB_has_dirty_io,        /* Dirty inodes on ->b_{dirty|io|more_io} */
+       WB_start_all,           /* nr_pages == 0 (all) work pending */
 };
 
 enum wb_congested_state {
@@ -44,6 +44,28 @@ enum wb_stat_item {
 
 #define WB_STAT_BATCH (8*(1+ilog2(nr_cpu_ids)))
 
+/*
+ * why some writeback work was initiated
+ */
+enum wb_reason {
+       WB_REASON_BACKGROUND,
+       WB_REASON_VMSCAN,
+       WB_REASON_SYNC,
+       WB_REASON_PERIODIC,
+       WB_REASON_LAPTOP_TIMER,
+       WB_REASON_FREE_MORE_MEM,
+       WB_REASON_FS_FREE_SPACE,
+       /*
+        * There is no bdi forker thread any more and works are done
+        * by emergency worker, however, this is TPs userland visible
+        * and we'll be exposing exactly the same information,
+        * so it has a mismatch name.
+        */
+       WB_REASON_FORKER_THREAD,
+
+       WB_REASON_MAX,
+};
+
 /*
  * For cgroup writeback, multiple wb's may map to the same blkcg.  Those
  * wb's can operate mostly independently but should share the congested
@@ -116,6 +138,7 @@ struct bdi_writeback {
 
        struct fprop_local_percpu completions;
        int dirty_exceeded;
+       enum wb_reason start_all_reason;
 
        spinlock_t work_lock;           /* protects work_list & dwork scheduling */
        struct list_head work_list;
@@ -165,6 +188,8 @@ struct backing_dev_info {
 #ifdef CONFIG_CGROUP_WRITEBACK
        struct radix_tree_root cgwb_tree; /* radix tree of active cgroup wbs */
        struct rb_root cgwb_congested_tree; /* their congested states */
+       struct mutex cgwb_release_mutex;  /* protect shutdown of wb structs */
+       struct rw_semaphore wb_switch_rwsem; /* no cgwb switch while syncing */
 #else
        struct bdi_writeback_congested *wb_congested;
 #endif
@@ -199,6 +224,11 @@ static inline void set_bdi_congested(struct backing_dev_info *bdi, int sync)
        set_wb_congested(bdi->wb.congested, sync);
 }
 
+struct wb_lock_cookie {
+       bool locked;
+       unsigned long flags;
+};
+
 #ifdef CONFIG_CGROUP_WRITEBACK
 
 /**
@@ -228,6 +258,14 @@ static inline void wb_get(struct bdi_writeback *wb)
  */
 static inline void wb_put(struct bdi_writeback *wb)
 {
+       if (WARN_ON_ONCE(!wb->bdi)) {
+               /*
+                * A driver bug might cause a file to be removed before bdi was
+                * initialized.
+                */
+               return;
+       }
+
        if (wb != &wb->bdi->wb)
                percpu_ref_put(&wb->refcnt);
 }