From fd9c1bc4528d39bd1696d01f66e9aa9b723c9fbb Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Thu, 29 Aug 2024 15:32:12 +0900 Subject: [PATCH] ksmbd: test 2 Signed-off-by: Namjae Jeon --- oplock.c | 37 ++++++++++++++++--------------------- vfs_cache.c | 4 ++-- vfs_cache.h | 2 +- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/oplock.c b/oplock.c index 9e91b45b..c440ebc7 100644 --- a/oplock.c +++ b/oplock.c @@ -152,7 +152,7 @@ static struct oplock_info *opinfo_get_list(struct ksmbd_inode *ci) return NULL; down_read(&ci->m_lock); - opinfo = list_first_or_null_rcu(&ci->m_op_list, struct oplock_info, + opinfo = list_first_entry(&ci->m_op_list, struct oplock_info, op_entry); if (opinfo) { if (opinfo->conn == NULL || @@ -466,7 +466,7 @@ void close_id_del_oplock(struct ksmbd_file *fp) opinfo_del(opinfo); - rcu_assign_pointer(fp->f_opinfo, NULL); + fp->f_opinfo = NULL; if (opinfo->op_state == OPLOCK_ACK_WAIT) { opinfo->op_state = OPLOCK_CLOSING; wake_up_interruptible_all(&opinfo->oplock_q); @@ -1174,14 +1174,14 @@ void destroy_lease_table(struct ksmbd_conn *conn) SMB2_CLIENT_GUID_SIZE)) continue; again: - rcu_read_lock(); - list_for_each_entry_rcu(opinfo, &lb->lease_list, + spin_lock(&lb->lb_lock); + list_for_each_entry(opinfo, &lb->lease_list, lease_entry) { - rcu_read_unlock(); lease_del_list(opinfo); + spin_unlock(&lb->lb_lock); goto again; } - rcu_read_unlock(); + spin_unlock(&lb->lb_lock); list_del(&lb->l_entry); kfree(lb); } @@ -1214,11 +1214,10 @@ int find_same_lease_key(struct ksmbd_session *sess, struct ksmbd_inode *ci, return 0; found: - rcu_read_lock(); - list_for_each_entry_rcu(opinfo, &lb->lease_list, lease_entry) { + spin_lock(&lb->lb_lock); + list_for_each_entry(opinfo, &lb->lease_list, lease_entry) { if (!atomic_inc_not_zero(&opinfo->refcount)) continue; - rcu_read_unlock(); if (opinfo->o_fp->f_ci == ci) goto op_next; err = compare_guid_key(opinfo, sess->ClientGUID, @@ -1228,13 +1227,13 @@ int find_same_lease_key(struct ksmbd_session *sess, struct ksmbd_inode *ci, ksmbd_debug(OPLOCK, "found same lease key is already used in other files\n"); opinfo_put(opinfo); + spin_unlock(&lb->lb_lock); goto out; } op_next: opinfo_put(opinfo); - rcu_read_lock(); } - rcu_read_unlock(); + spin_unlock(&lb->lb_lock); out: read_unlock(&lease_list_lock); @@ -1352,9 +1351,7 @@ void smb_lazy_parent_lease_break_close(struct ksmbd_file *fp) struct oplock_info *opinfo; struct ksmbd_inode *p_ci = NULL; - rcu_read_lock(); - opinfo = rcu_dereference(fp->f_opinfo); - rcu_read_unlock(); + opinfo = fp->f_opinfo; if (!opinfo || !opinfo->is_lease || opinfo->o_lease->version != 2) return; @@ -1509,7 +1506,7 @@ int smb_grant_oplock(struct ksmbd_work *work, int req_op_level, u64 pid, set_oplock_level(opinfo, req_op_level, lctx); out: - rcu_assign_pointer(fp->f_opinfo, opinfo); + fp->f_opinfo = opinfo; opinfo->o_fp = fp; opinfo_count_inc(fp); @@ -2057,11 +2054,10 @@ struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn, return NULL; found: - rcu_read_lock(); - list_for_each_entry_rcu(opinfo, <->lease_list, lease_entry) { + spin_lock(<->lb_lock); + list_for_each_entry(opinfo, <->lease_list, lease_entry) { if (!atomic_inc_not_zero(&opinfo->refcount)) continue; - rcu_read_unlock(); if (!opinfo->op_state || opinfo->op_state == OPLOCK_CLOSING) goto op_next; if (!(opinfo->o_lease->state & @@ -2073,16 +2069,15 @@ struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn, if (ret) { ksmbd_debug(OPLOCK, "found opinfo\n"); ret_op = opinfo; + spin_unlock(<->lb_lock); goto out; } op_next: opinfo_put(opinfo); - rcu_read_lock(); } - rcu_read_unlock(); + spin_unlock(<->lb_lock); out: - read_unlock(&lease_list_lock); return ret_op; } diff --git a/vfs_cache.c b/vfs_cache.c index c5218533..83f0b0bc 100644 --- a/vfs_cache.c +++ b/vfs_cache.c @@ -920,7 +920,7 @@ static bool session_fd_check(struct ksmbd_tree_connect *tcon, conn = fp->conn; ci = fp->f_ci; down_write(&ci->m_lock); - list_for_each_entry_rcu(op, &ci->m_op_list, op_entry) { + list_for_each_entry(op, &ci->m_op_list, op_entry) { if (op->conn != conn) continue; op->conn = NULL; @@ -1037,7 +1037,7 @@ int ksmbd_reopen_durable_fd(struct ksmbd_work *work, struct ksmbd_file *fp) ci = fp->f_ci; down_write(&ci->m_lock); - list_for_each_entry_rcu(op, &ci->m_op_list, op_entry) { + list_for_each_entry(op, &ci->m_op_list, op_entry) { if (op->conn) continue; op->conn = fp->conn; diff --git a/vfs_cache.h b/vfs_cache.h index 323772b3..305a758e 100644 --- a/vfs_cache.h +++ b/vfs_cache.h @@ -76,7 +76,7 @@ struct ksmbd_file { struct ksmbd_inode *f_ci; struct ksmbd_inode *f_parent_ci; - struct oplock_info __rcu *f_opinfo; + struct oplock_info *f_opinfo; struct ksmbd_conn *conn; struct ksmbd_tree_connect *tcon;