Skip to content

Commit 5a65254

Browse files
namjaejeongregkh
authored andcommitted
ksmbd: add continuous availability share parameter
[ Upstream commit e9d8c2f ] If capabilities of the share is not SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY, ksmbd should not grant a persistent handle to the client. This patch add continuous availability share parameter to control it. Signed-off-by: Namjae Jeon <linkinjeon@kernel.org> Signed-off-by: Steve French <stfrench@microsoft.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 07e76ea commit 5a65254

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

fs/smb/server/ksmbd_netlink.h

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -340,23 +340,24 @@ enum KSMBD_TREE_CONN_STATUS {
340340
/*
341341
* Share config flags.
342342
*/
343-
#define KSMBD_SHARE_FLAG_INVALID (0)
344-
#define KSMBD_SHARE_FLAG_AVAILABLE BIT(0)
345-
#define KSMBD_SHARE_FLAG_BROWSEABLE BIT(1)
346-
#define KSMBD_SHARE_FLAG_WRITEABLE BIT(2)
347-
#define KSMBD_SHARE_FLAG_READONLY BIT(3)
348-
#define KSMBD_SHARE_FLAG_GUEST_OK BIT(4)
349-
#define KSMBD_SHARE_FLAG_GUEST_ONLY BIT(5)
350-
#define KSMBD_SHARE_FLAG_STORE_DOS_ATTRS BIT(6)
351-
#define KSMBD_SHARE_FLAG_OPLOCKS BIT(7)
352-
#define KSMBD_SHARE_FLAG_PIPE BIT(8)
353-
#define KSMBD_SHARE_FLAG_HIDE_DOT_FILES BIT(9)
354-
#define KSMBD_SHARE_FLAG_INHERIT_OWNER BIT(10)
355-
#define KSMBD_SHARE_FLAG_STREAMS BIT(11)
356-
#define KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS BIT(12)
357-
#define KSMBD_SHARE_FLAG_ACL_XATTR BIT(13)
358-
#define KSMBD_SHARE_FLAG_UPDATE BIT(14)
359-
#define KSMBD_SHARE_FLAG_CROSSMNT BIT(15)
343+
#define KSMBD_SHARE_FLAG_INVALID (0)
344+
#define KSMBD_SHARE_FLAG_AVAILABLE BIT(0)
345+
#define KSMBD_SHARE_FLAG_BROWSEABLE BIT(1)
346+
#define KSMBD_SHARE_FLAG_WRITEABLE BIT(2)
347+
#define KSMBD_SHARE_FLAG_READONLY BIT(3)
348+
#define KSMBD_SHARE_FLAG_GUEST_OK BIT(4)
349+
#define KSMBD_SHARE_FLAG_GUEST_ONLY BIT(5)
350+
#define KSMBD_SHARE_FLAG_STORE_DOS_ATTRS BIT(6)
351+
#define KSMBD_SHARE_FLAG_OPLOCKS BIT(7)
352+
#define KSMBD_SHARE_FLAG_PIPE BIT(8)
353+
#define KSMBD_SHARE_FLAG_HIDE_DOT_FILES BIT(9)
354+
#define KSMBD_SHARE_FLAG_INHERIT_OWNER BIT(10)
355+
#define KSMBD_SHARE_FLAG_STREAMS BIT(11)
356+
#define KSMBD_SHARE_FLAG_FOLLOW_SYMLINKS BIT(12)
357+
#define KSMBD_SHARE_FLAG_ACL_XATTR BIT(13)
358+
#define KSMBD_SHARE_FLAG_UPDATE BIT(14)
359+
#define KSMBD_SHARE_FLAG_CROSSMNT BIT(15)
360+
#define KSMBD_SHARE_FLAG_CONTINUOUS_AVAILABILITY BIT(16)
360361

361362
/*
362363
* Tree connect request flags.

fs/smb/server/smb2pdu.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,12 @@ int smb2_tree_connect(struct ksmbd_work *work)
19881988
write_unlock(&sess->tree_conns_lock);
19891989
rsp->StructureSize = cpu_to_le16(16);
19901990
out_err1:
1991-
rsp->Capabilities = 0;
1991+
if (server_conf.flags & KSMBD_GLOBAL_FLAG_DURABLE_HANDLE &&
1992+
test_share_config_flag(share,
1993+
KSMBD_SHARE_FLAG_CONTINUOUS_AVAILABILITY))
1994+
rsp->Capabilities = SMB2_SHARE_CAP_CONTINUOUS_AVAILABILITY;
1995+
else
1996+
rsp->Capabilities = 0;
19921997
rsp->Reserved = 0;
19931998
/* default manual caching */
19941999
rsp->ShareFlags = SMB2_SHAREFLAG_MANUAL_CACHING;
@@ -3502,7 +3507,9 @@ int smb2_open(struct ksmbd_work *work)
35023507
memcpy(fp->client_guid, conn->ClientGUID, SMB2_CLIENT_GUID_SIZE);
35033508

35043509
if (dh_info.type == DURABLE_REQ_V2 || dh_info.type == DURABLE_REQ) {
3505-
if (dh_info.type == DURABLE_REQ_V2 && dh_info.persistent)
3510+
if (dh_info.type == DURABLE_REQ_V2 && dh_info.persistent &&
3511+
test_share_config_flag(work->tcon->share_conf,
3512+
KSMBD_SHARE_FLAG_CONTINUOUS_AVAILABILITY))
35063513
fp->is_persistent = true;
35073514
else
35083515
fp->is_durable = true;

0 commit comments

Comments
 (0)