@@ -1085,13 +1085,18 @@ static int tracefiled(void *arg)
complete(&tctl->tctl_start);
- while (1) {
- wait_queue_entry_t __wait;
-
- pc.pc_want_daemon_pages = 0;
- collect_pages(&pc);
+ pc.pc_want_daemon_pages = 0;
+
+ while (!last_loop) {
+ wait_event_timeout(tctl->tctl_waitq,
+ ({ collect_pages(&pc);
+ !list_empty(&pc.pc_pages); }) ||
+ atomic_read(&tctl->tctl_shutdown),
+ HZ);
+ if (atomic_read(&tctl->tctl_shutdown))
+ last_loop = 1;
if (list_empty(&pc.pc_pages))
- goto end_loop;
+ continue;
filp = NULL;
down_read(&cfs_tracefile_sem);
@@ -1110,18 +1115,19 @@ static int tracefiled(void *arg)
if (!filp) {
put_pages_on_daemon_list(&pc);
__LASSERT(list_empty(&pc.pc_pages));
- goto end_loop;
+ continue;
}
list_for_each_entry_safe(tage, tmp, &pc.pc_pages, linkage) {
+ struct dentry *de = file_dentry(filp);
static loff_t f_pos;
__LASSERT_TAGE_INVARIANT(tage);
if (f_pos >= (off_t)cfs_tracefile_size)
f_pos = 0;
- else if (f_pos > i_size_read(file_inode(filp)))
- f_pos = i_size_read(file_inode(filp));
+ else if (f_pos > i_size_read(de->d_inode))
+ f_pos = i_size_read(de->d_inode);
buf = kmap(tage->page);
rc = kernel_write(filp, buf, tage->used, &f_pos);
@@ -1158,19 +1164,6 @@ static int tracefiled(void *arg)
pr_err("Lustre: There are %d pages unwritten\n", i);
}
__LASSERT(list_empty(&pc.pc_pages));
-end_loop:
- if (atomic_read(&tctl->tctl_shutdown)) {
- if (!last_loop) {
- last_loop = 1;
- continue;
- } else {
- break;
- }
- }
- init_wait(&__wait);
- add_wait_queue(&tctl->tctl_waitq, &__wait);
- schedule_timeout_interruptible(HZ);
- remove_wait_queue(&tctl->tctl_waitq, &__wait);
}
complete(&tctl->tctl_stop);
return 0;