Whamcloud - gitweb
LU-6142 lustre: use BIT() macro where appropriate in include
[fs/lustre-release.git] / lustre / obdclass / scrub.c
index 094f928..24cb640 100644 (file)
@@ -46,7 +46,7 @@ static inline struct dt_device *scrub_obj2dev(struct dt_object *obj)
 
 static void scrub_file_to_cpu(struct scrub_file *des, struct scrub_file *src)
 {
-       memcpy(des->sf_uuid, src->sf_uuid, 16);
+       uuid_copy(&des->sf_uuid, &src->sf_uuid);
        des->sf_flags   = le64_to_cpu(src->sf_flags);
        des->sf_magic   = le32_to_cpu(src->sf_magic);
        des->sf_status  = le16_to_cpu(src->sf_status);
@@ -80,7 +80,7 @@ static void scrub_file_to_cpu(struct scrub_file *des, struct scrub_file *src)
 
 static void scrub_file_to_le(struct scrub_file *des, struct scrub_file *src)
 {
-       memcpy(des->sf_uuid, src->sf_uuid, 16);
+       uuid_copy(&des->sf_uuid, &src->sf_uuid);
        des->sf_flags   = cpu_to_le64(src->sf_flags);
        des->sf_magic   = cpu_to_le32(src->sf_magic);
        des->sf_status  = cpu_to_le16(src->sf_status);
@@ -112,18 +112,18 @@ static void scrub_file_to_le(struct scrub_file *des, struct scrub_file *src)
        memcpy(des->sf_oi_bitmap, src->sf_oi_bitmap, SCRUB_OI_BITMAP_SIZE);
 }
 
-void scrub_file_init(struct lustre_scrub *scrub, __u8 *uuid)
+void scrub_file_init(struct lustre_scrub *scrub, uuid_t uuid)
 {
        struct scrub_file *sf = &scrub->os_file;
 
        memset(sf, 0, sizeof(*sf));
-       memcpy(sf->sf_uuid, uuid, 16);
+       uuid_copy(&sf->sf_uuid, &uuid);
        sf->sf_magic = SCRUB_MAGIC_V1;
        sf->sf_status = SS_INIT;
 }
 EXPORT_SYMBOL(scrub_file_init);
 
-void scrub_file_reset(struct lustre_scrub *scrub, __u8 *uuid, __u64 flags)
+void scrub_file_reset(struct lustre_scrub *scrub, uuid_t uuid, u64 flags)
 {
        struct scrub_file *sf = &scrub->os_file;
 
@@ -131,7 +131,7 @@ void scrub_file_reset(struct lustre_scrub *scrub, __u8 *uuid, __u64 flags)
               "%#llx, add flags = %#llx\n",
               scrub->os_name, sf->sf_flags, flags);
 
-       memcpy(sf->sf_uuid, uuid, 16);
+       uuid_copy(&sf->sf_uuid, &uuid);
        sf->sf_status = SS_INIT;
        sf->sf_flags |= flags;
        sf->sf_flags &= ~SF_AUTO;
@@ -275,7 +275,6 @@ int scrub_start(int (*threadfn)(void *data), struct lustre_scrub *scrub,
                void *data, __u32 flags)
 {
        struct ptlrpc_thread *thread = &scrub->os_thread;
-       struct l_wait_info lwi = { 0 };
        struct task_struct *task;
        int rc;
        ENTRY;
@@ -290,9 +289,8 @@ again:
 
        if (unlikely(thread_is_stopping(thread))) {
                spin_unlock(&scrub->os_lock);
-               l_wait_event(thread->t_ctl_waitq,
-                            thread_is_stopped(thread),
-                            &lwi);
+               wait_event_idle(thread->t_ctl_waitq,
+                               thread_is_stopped(thread));
                goto again;
        }
        spin_unlock(&scrub->os_lock);
@@ -317,9 +315,8 @@ again:
                RETURN(rc);
        }
 
-       l_wait_event(thread->t_ctl_waitq,
-                    thread_is_running(thread) || thread_is_stopped(thread),
-                    &lwi);
+       wait_event_idle(thread->t_ctl_waitq,
+                       thread_is_running(thread) || thread_is_stopped(thread));
 
        RETURN(0);
 }
@@ -328,7 +325,6 @@ EXPORT_SYMBOL(scrub_start);
 void scrub_stop(struct lustre_scrub *scrub)
 {
        struct ptlrpc_thread *thread = &scrub->os_thread;
-       struct l_wait_info lwi = { 0 };
 
        /* os_lock: sync status between stop and scrub thread */
        spin_lock(&scrub->os_lock);
@@ -336,9 +332,8 @@ void scrub_stop(struct lustre_scrub *scrub)
                thread_set_flags(thread, SVC_STOPPING);
                spin_unlock(&scrub->os_lock);
                wake_up_all(&thread->t_ctl_waitq);
-               l_wait_event(thread->t_ctl_waitq,
-                            thread_is_stopped(thread),
-                            &lwi);
+               wait_event_idle(thread->t_ctl_waitq,
+                               thread_is_stopped(thread));
                /* Do not skip the last lock/unlock, which can guarantee that
                 * the caller cannot return until the OI scrub thread exit. */
                spin_lock(&scrub->os_lock);
@@ -479,7 +474,7 @@ void scrub_dump(struct seq_file *m, struct lustre_scrub *scrub)
 
                seq_printf(m, "run_time: %lld seconds\n"
                           "average_speed: %lld objects/sec\n"
-                          "real-time_speed: %lld objects/sec\n"
+                          "real_time_speed: %lld objects/sec\n"
                           "current_position: %llu\n"
                           "scrub_in_prior: %s\n"
                           "scrub_full_speed: %s\n"
@@ -492,9 +487,9 @@ void scrub_dump(struct seq_file *m, struct lustre_scrub *scrub)
        } else {
                if (sf->sf_run_time != 0)
                        speed = div_s64(speed, sf->sf_run_time);
-               seq_printf(m, "run_time: %ld seconds\n"
+               seq_printf(m, "run_time: %d seconds\n"
                           "average_speed: %lld objects/sec\n"
-                          "real-time_speed: N/A\n"
+                          "real_time_speed: N/A\n"
                           "current_position: N/A\n",
                           sf->sf_run_time, speed);
        }
@@ -1140,7 +1135,7 @@ int lustre_index_restore(const struct lu_env *env, struct dt_device *dev,
                GOTO(stop, rc);
 
        rc = dt_insert(env, parent_obj, (const struct dt_rec *)&ent,
-                      (const struct dt_key *)name, th, 1);
+                      (const struct dt_key *)name, th);
        dt_trans_stop(env, dev, th);
        /* Some index name may has been inserted by OSD
         * automatically when create the index object. */
@@ -1186,7 +1181,7 @@ int lustre_index_restore(const struct lu_env *env, struct dt_device *dev,
                        if (rc)
                                GOTO(stop, rc);
 
-                       rc = dt_insert(env, tgt_obj, rec, key, th, 1);
+                       rc = dt_insert(env, tgt_obj, rec, key, th);
                        if (unlikely(rc == -EEXIST))
                                rc = 0;