drivers/char/mem.c: avoid OOM lockup during large reads from /dev/zero
[safe/jmp/linux-2.6] / drivers / md / dm-path-selector.c
index ac5c4bb..42c04f0 100644 (file)
@@ -9,16 +9,15 @@
  * Path selector registration.
  */
 
-#include "dm.h"
+#include <linux/device-mapper.h>
+
 #include "dm-path-selector.h"
 
 #include <linux/slab.h>
 
 struct ps_internal {
        struct path_selector_type pst;
-
        struct list_head list;
-       long use;
 };
 
 #define pst_to_psi(__pst) container_of((__pst), struct ps_internal, pst)
@@ -26,7 +25,7 @@ struct ps_internal {
 static LIST_HEAD(_path_selectors);
 static DECLARE_RWSEM(_ps_lock);
 
-struct ps_internal *__find_path_selector_type(const char *name)
+static struct ps_internal *__find_path_selector_type(const char *name)
 {
        struct ps_internal *psi;
 
@@ -44,12 +43,8 @@ static struct ps_internal *get_path_selector(const char *name)
 
        down_read(&_ps_lock);
        psi = __find_path_selector_type(name);
-       if (psi) {
-               if ((psi->use == 0) && !try_module_get(psi->pst.module))
-                       psi = NULL;
-               else
-                       psi->use++;
-       }
+       if (psi && !try_module_get(psi->pst.module))
+               psi = NULL;
        up_read(&_ps_lock);
 
        return psi;
@@ -83,24 +78,17 @@ void dm_put_path_selector(struct path_selector_type *pst)
        if (!psi)
                goto out;
 
-       if (--psi->use == 0)
-               module_put(psi->pst.module);
-
-       if (psi->use < 0)
-               BUG();
-
+       module_put(psi->pst.module);
 out:
        up_read(&_ps_lock);
 }
 
 static struct ps_internal *_alloc_path_selector(struct path_selector_type *pst)
 {
-       struct ps_internal *psi = kmalloc(sizeof(*psi), GFP_KERNEL);
+       struct ps_internal *psi = kzalloc(sizeof(*psi), GFP_KERNEL);
 
-       if (psi) {
-               memset(psi, 0, sizeof(*psi));
+       if (psi)
                psi->pst = *pst;
-       }
 
        return psi;
 }
@@ -138,11 +126,6 @@ int dm_unregister_path_selector(struct path_selector_type *pst)
                return -EINVAL;
        }
 
-       if (psi->use) {
-               up_write(&_ps_lock);
-               return -ETXTBSY;
-       }
-
        list_del(&psi->list);
 
        up_write(&_ps_lock);