Skip to content

Commit bac02cb

Browse files
committed
ksmbd: work 1
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent 8fbbe5d commit bac02cb

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

oplock.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ static void free_opinfo_rcu(struct rcu_head *rcu)
139139
{
140140
struct oplock_info *opinfo = container_of(rcu, struct oplock_info, rcu);
141141

142+
pr_err("%s:%d, opinfo : %p, refcount : %d\n", __func__, __LINE__, opinfo, atomic_read(&opinfo->refcount));
142143
if (!atomic_dec_and_test(&opinfo->refcount))
143144
return;
144145

@@ -166,6 +167,7 @@ static struct oplock_info *opinfo_get_list(struct ksmbd_inode *ci)
166167
opinfo = list_first_entry_or_null(&ci->m_op_list, struct oplock_info,
167168
op_entry);
168169
if (opinfo) {
170+
pr_err("%s:%d\n", __func__, __LINE__);
169171
if (opinfo->conn == NULL ||
170172
!atomic_inc_not_zero(&opinfo->refcount))
171173
opinfo = NULL;
@@ -186,6 +188,11 @@ void opinfo_put(struct oplock_info *opinfo)
186188
if (!opinfo)
187189
return;
188190

191+
pr_err("%s:%d, opinfo : %p, refcount : %d\n", __func__, __LINE__, opinfo, atomic_read(&opinfo->refcount));
192+
// if (!atomic_dec_and_test(&opinfo->refcount))
193+
// return;
194+
195+
// pr_err("%s:%d, call rcu opinfo : %p, refcount : %d\n", __func__, __LINE__, opinfo, atomic_read(&opinfo->refcount));
189196
call_rcu(&opinfo->rcu, free_opinfo_rcu);
190197
}
191198

@@ -1211,6 +1218,7 @@ int find_same_lease_key(struct ksmbd_session *sess, struct ksmbd_inode *ci,
12111218
found:
12121219
rcu_read_lock();
12131220
list_for_each_entry_rcu(opinfo, &lb->lease_list, lease_entry) {
1221+
pr_err("%s:%d\n", __func__, __LINE__);
12141222
if (!atomic_inc_not_zero(&opinfo->refcount))
12151223
continue;
12161224
rcu_read_unlock();
@@ -1324,6 +1332,7 @@ void smb_send_parent_lease_break_noti(struct ksmbd_file *fp,
13241332
(!(lctx->flags & SMB2_LEASE_FLAG_PARENT_LEASE_KEY_SET_LE) ||
13251333
!compare_guid_key(opinfo, fp->conn->ClientGUID,
13261334
lctx->parent_lease_key))) {
1335+
pr_err("%s:%d\n", __func__, __LINE__);
13271336
if (!atomic_inc_not_zero(&opinfo->refcount))
13281337
continue;
13291338

@@ -1363,6 +1372,7 @@ void smb_lazy_parent_lease_break_close(struct ksmbd_file *fp)
13631372
continue;
13641373

13651374
if (opinfo->o_lease->state != SMB2_OPLOCK_LEVEL_NONE) {
1375+
pr_err("%s:%d\n", __func__, __LINE__);
13661376
if (!atomic_inc_not_zero(&opinfo->refcount))
13671377
continue;
13681378

@@ -1515,6 +1525,7 @@ int smb_grant_oplock(struct ksmbd_work *work, int req_op_level, u64 pid,
15151525

15161526
return 0;
15171527
err_out:
1528+
pr_err("%s:%d\n", __func__, __LINE__);
15181529
free_opinfo(opinfo);
15191530
return err;
15201531
}
@@ -1558,20 +1569,27 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp,
15581569
struct ksmbd_inode *ci;
15591570
struct ksmbd_conn *conn = work->conn;
15601571

1572+
// return;
1573+
15611574
if (!test_share_config_flag(work->tcon->share_conf,
15621575
KSMBD_SHARE_FLAG_OPLOCKS))
15631576
return;
15641577

15651578
ci = fp->f_ci;
15661579
op = opinfo_get(fp);
1567-
1580+
#if 0
15681581
down_read(&ci->m_lock);
15691582
list_for_each_entry(brk_op, &ci->m_op_list, op_entry) {
15701583
if (brk_op->conn == NULL)
15711584
continue;
15721585

1573-
if (!atomic_inc_not_zero(&brk_op->refcount))
1586+
pr_err("%s:%d, brk_op : %p, refcount : %d\n", __func__, __LINE__, brk_op, atomic_read(&brk_op->refcount));
1587+
rcu_read_lock();
1588+
if (!atomic_inc_not_zero(&brk_op->refcount)) {
1589+
rcu_read_unlock();
15741590
continue;
1591+
}
1592+
rcu_read_unlock();
15751593

15761594
if (ksmbd_conn_releasing(brk_op->conn)) {
15771595
opinfo_put(brk_op);
@@ -1636,10 +1654,14 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp,
16361654
brk_op->open_trunc = is_trunc;
16371655
oplock_break(brk_op, SMB2_OPLOCK_LEVEL_NONE, NULL);
16381656
next:
1639-
opinfo_put(brk_op);
1657+
pr_err("%s:%d, brk_op : %p refcount : %d\n", __func__, __LINE__, brk_op, atomic_read(&brk_op->refcount));
1658+
// opinfo_put(brk_op);
1659+
atomic_dec(&brk_op->refcount);
16401660
}
16411661
up_read(&ci->m_lock);
1642-
1662+
#endif
1663+
if (op)
1664+
pr_err("%s:%d, op : %p refcount : %d\n", __func__, __LINE__, op, atomic_read(&op->refcount));
16431665
if (op)
16441666
opinfo_put(op);
16451667
}
@@ -2061,6 +2083,7 @@ struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn,
20612083
found:
20622084
rcu_read_lock();
20632085
list_for_each_entry_rcu(opinfo, &lt->lease_list, lease_entry) {
2086+
pr_err("%s:%d\n", __func__, __LINE__);
20642087
if (!atomic_inc_not_zero(&opinfo->refcount))
20652088
continue;
20662089
rcu_read_unlock();

0 commit comments

Comments
 (0)