Skip to content

Commit

Permalink
ksmbd: work 11
Browse files Browse the repository at this point in the history
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
namjaejeon committed Jun 6, 2024
1 parent 54db626 commit 7d444c3
Showing 1 changed file with 2 additions and 18 deletions.
20 changes: 2 additions & 18 deletions vfs_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,8 @@ static void ksmbd_remove_durable_fd(struct ksmbd_file *fp)
write_lock(&global_ft.lock);
__ksmbd_remove_durable_fd(fp);
write_unlock(&global_ft.lock);
if (waitqueue_active(&dh_wq)) {
pr_err("%s:%d, wake up !!!!!!!!!!!!\n", __func__, __LINE__);
if (waitqueue_active(&dh_wq))
wake_up(&dh_wq);
}
}

static void __ksmbd_remove_fd(struct ksmbd_file_table *ft, struct ksmbd_file *fp)
Expand Down Expand Up @@ -793,13 +791,10 @@ static bool ksmbd_durable_scavenger_alive(void)

static void ksmbd_scavenger_dispose_dh(struct list_head *head)
{
pr_err("%s:%d\n", __func__, __LINE__);
while (!list_empty(head)) {
struct ksmbd_file *fp;

fp = list_first_entry(head, struct ksmbd_file, node);
pr_err("%s:%d, fp->durable_timeout : %u, fp->refcnt : %u, f_state : %d, fp->durable_scavenger_timeout : %u, jiffies_to_msecs : %u, fp->conn : %p\n", __func__, __LINE__,
fp->durable_timeout, atomic_read(&fp->refcount), fp->f_state, fp->durable_scavenger_timeout, jiffies_to_msecs(jiffies), fp->conn);
list_del_init(&fp->node);
__ksmbd_close_fd(NULL, fp);
}
Expand All @@ -816,28 +811,22 @@ static int ksmbd_durable_scavenger(void *dummy)

__module_get(THIS_MODULE);

pr_err("%s : %d\n", __func__, __LINE__);
set_freezable();
while (ksmbd_durable_scavenger_alive()) {
if (try_to_freeze())
continue;

found_fp_timeout = false;

pr_err("1 min_timeout : %u, jiffies_to_msecs : %u, alive : %d\n", min_timeout, jiffies_to_msecs(jiffies), ksmbd_durable_scavenger_alive());
remaining_jiffies = wait_event_timeout(dh_wq,
ksmbd_durable_scavenger_alive() == false,
__msecs_to_jiffies(min_timeout));
pr_err("2 min_timeout : %u, jiffies_to_msecs : %u, alive : %d\n", min_timeout, jiffies_to_msecs(jiffies), ksmbd_durable_scavenger_alive());
if (remaining_jiffies)
min_timeout = jiffies_to_msecs(remaining_jiffies);
else
min_timeout = DURABLE_HANDLE_MAX_TIMEOUT;
write_lock(&global_ft.lock);
idr_for_each_entry(global_ft.idr, fp, id) {
pr_err("%s:%d, fp->durable_timeout : %u, fp->refcnt : %u, f_state : %d, fp->durable_scavenger_timeout : %u, jiffies_to_msecs : %u, fp->conn : %p\n", __func__, __LINE__,
fp->durable_timeout, atomic_read(&fp->refcount), fp->f_state, fp->durable_scavenger_timeout, jiffies_to_msecs(jiffies), fp->conn);

if (!fp->durable_timeout)
continue;

Expand All @@ -848,7 +837,6 @@ static int ksmbd_durable_scavenger(void *dummy)
found_fp_timeout = true;
if (fp->durable_scavenger_timeout <=
jiffies_to_msecs(jiffies)) {
pr_err("closed!!!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");
__ksmbd_remove_durable_fd(fp);
list_add(&fp->node, &scavenger_list);
} else {
Expand Down Expand Up @@ -905,18 +893,15 @@ void ksmbd_stop_durable_scavenger(void)
if (!(server_conf.flags & KSMBD_GLOBAL_FLAG_DURABLE_HANDLE))
return;

pr_err("%s:%d\n", __func__, __LINE__);
mutex_lock(&durable_scavenger_lock);
if (!durable_scavenger_running) {
mutex_unlock(&durable_scavenger_lock);
return;
}

durable_scavenger_running = false;
if (waitqueue_active(&dh_wq)) {
pr_err("%s:%d, wake up !!!!!!!!!!!!\n", __func__, __LINE__);
if (waitqueue_active(&dh_wq))
wake_up(&dh_wq);
}
mutex_unlock(&durable_scavenger_lock);
kthread_stop(server_conf.dh_task);
}
Expand Down Expand Up @@ -982,7 +967,6 @@ void ksmbd_free_global_file_table(void)

idr_for_each_entry(global_ft.idr, fp, id) {
ksmbd_remove_durable_fd(fp);
pr_err("fp durable timeout : %u\n", fp->durable_timeout);
__ksmbd_close_fd(NULL, fp);
}

Expand Down

0 comments on commit 7d444c3

Please sign in to comment.