Skip to content

Commit b6e9a44

Browse files
namjaejeonSteve French
authored andcommitted
ksmbd: don't increment epoch if current state and request state are same
If existing lease state and request state are same, don't increment epoch in create context. Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com>
1 parent 6fc0a26 commit b6e9a44

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

fs/smb/server/oplock.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int alloc_lease(struct oplock_info *opinfo, struct lease_ctx_info *lctx)
105105
lease->is_dir = lctx->is_dir;
106106
memcpy(lease->parent_lease_key, lctx->parent_lease_key, SMB2_LEASE_KEY_SIZE);
107107
lease->version = lctx->version;
108-
lease->epoch = le16_to_cpu(lctx->epoch);
108+
lease->epoch = le16_to_cpu(lctx->epoch) + 1;
109109
INIT_LIST_HEAD(&opinfo->lease_entry);
110110
opinfo->o_lease = lease;
111111

@@ -541,6 +541,9 @@ static struct oplock_info *same_client_has_lease(struct ksmbd_inode *ci,
541541
continue;
542542
}
543543

544+
if (lctx->req_state != lease->state)
545+
lease->epoch++;
546+
544547
/* upgrading lease */
545548
if ((atomic_read(&ci->op_count) +
546549
atomic_read(&ci->sop_count)) == 1) {
@@ -1035,7 +1038,7 @@ static void copy_lease(struct oplock_info *op1, struct oplock_info *op2)
10351038
SMB2_LEASE_KEY_SIZE);
10361039
lease2->duration = lease1->duration;
10371040
lease2->flags = lease1->flags;
1038-
lease2->epoch = lease1->epoch++;
1041+
lease2->epoch = lease1->epoch;
10391042
lease2->version = lease1->version;
10401043
}
10411044

@@ -1448,7 +1451,7 @@ void create_lease_buf(u8 *rbuf, struct lease *lease)
14481451
memcpy(buf->lcontext.LeaseKey, lease->lease_key,
14491452
SMB2_LEASE_KEY_SIZE);
14501453
buf->lcontext.LeaseFlags = lease->flags;
1451-
buf->lcontext.Epoch = cpu_to_le16(++lease->epoch);
1454+
buf->lcontext.Epoch = cpu_to_le16(lease->epoch);
14521455
buf->lcontext.LeaseState = lease->state;
14531456
memcpy(buf->lcontext.ParentLeaseKey, lease->parent_lease_key,
14541457
SMB2_LEASE_KEY_SIZE);

0 commit comments

Comments
 (0)