Whamcloud - gitweb
LU-3963 obdclass: convert to linux list api
[fs/lustre-release.git] / lustre / obdclass / class_obd.c
index cb0ea79..da38c9a 100644 (file)
 # include <dt_object.h>
 # include <md_object.h>
 #endif /* HAVE_SERVER_SUPPORT */
+#include <lustre_ioctl.h>
 #include "llog_internal.h"
 
 #ifndef __KERNEL__
 /* liblustre workaround */
-cfs_atomic_t libcfs_kmemory = {0};
+atomic_t libcfs_kmemory = {0};
 #endif
 
 struct obd_device *obd_devs[MAX_OBD_DEVICES];
 EXPORT_SYMBOL(obd_devs);
-cfs_list_t obd_types;
+struct list_head obd_types;
 DEFINE_RWLOCK(obd_dev_lock);
 
 __u64 obd_max_pages = 0;
@@ -84,9 +85,7 @@ unsigned int obd_dump_on_eviction;
 EXPORT_SYMBOL(obd_dump_on_eviction);
 unsigned int obd_max_dirty_pages = 256;
 EXPORT_SYMBOL(obd_max_dirty_pages);
-cfs_atomic_t obd_unstable_pages;
-EXPORT_SYMBOL(obd_unstable_pages);
-cfs_atomic_t obd_dirty_pages;
+atomic_t obd_dirty_pages;
 EXPORT_SYMBOL(obd_dirty_pages);
 unsigned int obd_timeout = OBD_TIMEOUT_DEFAULT;   /* seconds */
 EXPORT_SYMBOL(obd_timeout);
@@ -108,7 +107,7 @@ EXPORT_SYMBOL(at_early_margin);
 int at_extra = 30;
 EXPORT_SYMBOL(at_extra);
 
-cfs_atomic_t obd_dirty_transit_pages;
+atomic_t obd_dirty_transit_pages;
 EXPORT_SYMBOL(obd_dirty_transit_pages);
 
 char obd_jobid_var[JOBSTATS_JOBID_VAR_MAX_LEN + 1] = JOBSTATS_DISABLE;
@@ -145,7 +144,8 @@ int lustre_get_jobid(char *jobid)
        /* Use process name + fsuid as jobid */
        if (strcmp(obd_jobid_var, JOBSTATS_PROCNAME_UID) == 0) {
                snprintf(jobid, JOBSTATS_JOBID_SIZE, "%s.%u",
-                        current_comm(), current_fsuid());
+                        current_comm(),
+                        from_kuid(&init_user_ns, current_fsuid()));
                RETURN(0);
        }
 
@@ -191,26 +191,13 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
                       obd_memory_sum(),
                       obd_pages_sum() << PAGE_CACHE_SHIFT,
                       obd_pages_sum(),
-                       cfs_atomic_read(&libcfs_kmemory));
+                       atomic_read(&libcfs_kmemory));
                return 1;
        }
        return 0;
 }
 EXPORT_SYMBOL(obd_alloc_fail);
 
-static inline void obd_data2conn(struct lustre_handle *conn,
-                                 struct obd_ioctl_data *data)
-{
-        memset(conn, 0, sizeof *conn);
-        conn->cookie = data->ioc_cookie;
-}
-
-static inline void obd_conn2data(struct obd_ioctl_data *data,
-                                 struct lustre_handle *conn)
-{
-        data->ioc_cookie = conn->cookie;
-}
-
 int class_resolve_dev_name(__u32 len, const char *name)
 {
         int rc;
@@ -357,12 +344,6 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
                 GOTO(out, err);
         }
 
-        case OBD_IOC_CLOSE_UUID: {
-                CDEBUG(D_IOCTL, "closing all connections to uuid %s (NOOP)\n",
-                       data->ioc_inlbuf1);
-                GOTO(out, err = 0);
-        }
-
         case OBD_IOC_GETDEVICE: {
                 int     index = data->ioc_count;
                 char    *status, *str;
@@ -392,7 +373,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
                 snprintf(str, len - sizeof(*data), "%3d %s %s %s %s %d",
                          (int)index, status, obd->obd_type->typ_name,
                          obd->obd_name, obd->obd_uuid.uuid,
-                         cfs_atomic_read(&obd->obd_refcount));
+                        atomic_read(&obd->obd_refcount));
                 err = obd_ioctl_popdata((void *)arg, data, len);
 
                 GOTO(out, err = 0);
@@ -533,7 +514,6 @@ int obd_init_checks(void)
 #define obd_init_checks() do {} while(0)
 #endif
 
-extern spinlock_t obd_types_lock;
 extern int class_procfs_init(void);
 extern int class_procfs_clean(void);
 
@@ -548,7 +528,7 @@ int init_obdclass(void)
         int lustre_register_fs(void);
 
         for (i = CAPA_SITE_CLIENT; i < CAPA_SITE_MAX; i++)
-                CFS_INIT_LIST_HEAD(&capa_list[i]);
+               INIT_LIST_HEAD(&capa_list[i]);
 #endif
 
         LCONSOLE_INFO("Lustre: Build Version: "BUILD_VERSION"\n");
@@ -580,7 +560,7 @@ int init_obdclass(void)
         if (err)
                 return err;
 
-        CFS_INIT_LIST_HEAD(&obd_types);
+       INIT_LIST_HEAD(&obd_types);
 
        err = misc_register(&obd_psdev);
        if (err) {
@@ -689,7 +669,6 @@ EXPORT_SYMBOL(obd_pages_max);
 #ifdef __KERNEL__
 static void cleanup_obdclass(void)
 {
-        int i;
         int lustre_unregister_fs(void);
         __u64 memory_leaked, pages_leaked;
         __u64 memory_max, pages_max;
@@ -698,15 +677,6 @@ static void cleanup_obdclass(void)
         lustre_unregister_fs();
 
        misc_deregister(&obd_psdev);
-       for (i = 0; i < class_devno_max(); i++) {
-               struct obd_device *obd = class_num2obd(i);
-               if (obd && obd->obd_set_up &&
-                   OBT(obd) && OBP(obd, detach)) {
-                       /* XXX should this call generic detach otherwise? */
-                       LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
-                       OBP(obd, detach)(obd);
-               }
-       }
        llog_info_fini();
 #ifdef HAVE_SERVER_SUPPORT
        lu_ucred_global_fini();