cgroup: fix memory leak in cgroup_get_sb()
[sfrench/cifs-2.6.git] / mm / backing-dev.c
index f50a2811f9dc86b876d24e75333558583c075f1d..e8644b1e5527df1069f968d17d1893fa0dc3e5fa 100644 (file)
@@ -5,6 +5,41 @@
 #include <linux/sched.h>
 #include <linux/module.h>
 
+int bdi_init(struct backing_dev_info *bdi)
+{
+       int i;
+       int err;
+
+       for (i = 0; i < NR_BDI_STAT_ITEMS; i++) {
+               err = percpu_counter_init_irq(&bdi->bdi_stat[i], 0);
+               if (err)
+                       goto err;
+       }
+
+       bdi->dirty_exceeded = 0;
+       err = prop_local_init_percpu(&bdi->completions);
+
+       if (err) {
+err:
+               while (i--)
+                       percpu_counter_destroy(&bdi->bdi_stat[i]);
+       }
+
+       return err;
+}
+EXPORT_SYMBOL(bdi_init);
+
+void bdi_destroy(struct backing_dev_info *bdi)
+{
+       int i;
+
+       for (i = 0; i < NR_BDI_STAT_ITEMS; i++)
+               percpu_counter_destroy(&bdi->bdi_stat[i]);
+
+       prop_local_destroy_percpu(&bdi->completions);
+}
+EXPORT_SYMBOL(bdi_destroy);
+
 static wait_queue_head_t congestion_wqh[2] = {
                __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[0]),
                __WAIT_QUEUE_HEAD_INITIALIZER(congestion_wqh[1])
@@ -55,15 +90,3 @@ long congestion_wait(int rw, long timeout)
 }
 EXPORT_SYMBOL(congestion_wait);
 
-/**
- * congestion_end - wake up sleepers on a congested backing_dev_info
- * @rw: READ or WRITE
- */
-void congestion_end(int rw)
-{
-       wait_queue_head_t *wqh = &congestion_wqh[rw];
-
-       if (waitqueue_active(wqh))
-               wake_up(wqh);
-}
-EXPORT_SYMBOL(congestion_end);