Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53ef1016 authored by Pavel Shilovsky's avatar Pavel Shilovsky Committed by Steve French
Browse files

CIFS: Store lease state itself rather than a mapped oplock value



and separate smb20_operations struct.

Signed-off-by: default avatarPavel Shilovsky <pshilovsky@samba.org>
Signed-off-by: default avatarSteve French <smfrench@gmail.com>
parent 18cceb6a
Loading
Loading
Loading
Loading
+9 −7
Original line number Diff line number Diff line
@@ -367,11 +367,13 @@ struct smb_version_operations {
	/* generate new lease key */
	void (*new_lease_key)(struct cifs_fid *fid);
	int (*generate_signingkey)(struct cifs_ses *);
	int (*calc_signature)(struct smb_rqst *rqst,
				   struct TCP_Server_Info *server);
	int (*query_mf_symlink)(const unsigned char *path, char *pbuf,
			unsigned int *pbytes_read, struct cifs_sb_info *cifs_sb,
			unsigned int xid);
	int (*calc_signature)(struct smb_rqst *, struct TCP_Server_Info *);
	int (*query_mf_symlink)(const unsigned char *, char *, unsigned int *,
				struct cifs_sb_info *, unsigned int);
	/* if we can do cache read operations */
	bool (*is_read_op)(__u32);
	/* set oplock level for the inode */
	void (*set_oplock_level)(struct cifsInodeInfo *, __u32);
};

struct smb_version_values {
@@ -389,7 +391,6 @@ struct smb_version_values {
	unsigned int	cap_unix;
	unsigned int	cap_nt_find;
	unsigned int	cap_large_files;
	unsigned int	oplock_read;
	__u16		signing_enabled;
	__u16		signing_required;
};
@@ -1036,6 +1037,7 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file);
#define CIFS_CACHE_WRITE_FLG	4

#define CIFS_CACHE_READ(cinode) (cinode->oplock & CIFS_CACHE_READ_FLG)
#define CIFS_CACHE_HANDLE(cinode) (cinode->oplock & CIFS_CACHE_HANDLE_FLG)
#define CIFS_CACHE_WRITE(cinode) (cinode->oplock & CIFS_CACHE_WRITE_FLG)

/*
@@ -1507,7 +1509,7 @@ extern mempool_t *cifs_mid_poolp;
extern struct smb_version_operations smb1_operations;
extern struct smb_version_values smb1_values;
#define SMB20_VERSION_STRING	"2.0"
/*extern struct smb_version_operations smb20_operations; */ /* not needed yet */
extern struct smb_version_operations smb20_operations;
extern struct smb_version_values smb20_values;
#define SMB21_VERSION_STRING	"2.1"
extern struct smb_version_operations smb21_operations;
+1 −1
Original line number Diff line number Diff line
@@ -1116,7 +1116,7 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol)
		break;
#ifdef CONFIG_CIFS_SMB2
	case Smb_20:
		vol->ops = &smb21_operations; /* currently identical with 2.1 */
		vol->ops = &smb20_operations;
		vol->vals = &smb20_values;
		break;
	case Smb_21:
+1 −2
Original line number Diff line number Diff line
@@ -313,8 +313,7 @@ cifs_new_fileinfo(struct cifs_fid *fid, struct file *file,
	 * If the server returned a read oplock and we have mandatory brlocks,
	 * set oplock level to None.
	 */
	if (oplock == server->vals->oplock_read &&
						cifs_has_mand_locks(cinode)) {
	if (server->ops->is_read_op(oplock) && cifs_has_mand_locks(cinode)) {
		cifs_dbg(FYI, "Reset oplock val from read to None due to mand locks\n");
		oplock = 0;
	}
+7 −1
Original line number Diff line number Diff line
@@ -912,6 +912,12 @@ cifs_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
	return rc;
}

static bool
cifs_is_read_op(__u32 oplock)
{
	return oplock == OPLOCK_READ;
}

struct smb_version_operations smb1_operations = {
	.send_cancel = send_nt_cancel,
	.compare_fids = cifs_compare_fids,
@@ -977,6 +983,7 @@ struct smb_version_operations smb1_operations = {
	.mand_unlock_range = cifs_unlock_range,
	.push_mand_locks = cifs_push_mandatory_locks,
	.query_mf_symlink = open_query_close_cifs_symlink,
	.is_read_op = cifs_is_read_op,
};

struct smb_version_values smb1_values = {
@@ -992,7 +999,6 @@ struct smb_version_values smb1_values = {
	.cap_unix = CAP_UNIX,
	.cap_nt_find = CAP_NT_SMBS | CAP_NT_FIND,
	.cap_large_files = CAP_LARGE_FILES,
	.oplock_read = OPLOCK_READ,
	.signing_enabled = SECMODE_SIGN_ENABLED,
	.signing_required = SECMODE_SIGN_REQUIRED,
};
+0 −23
Original line number Diff line number Diff line
@@ -34,29 +34,6 @@
#include "fscache.h"
#include "smb2proto.h"

void
smb2_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock)
{
	oplock &= 0xFF;
	if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
		return;
	if (oplock == SMB2_OPLOCK_LEVEL_BATCH) {
		cinode->oplock = CIFS_CACHE_READ_FLG | CIFS_CACHE_WRITE_FLG |
				 CIFS_CACHE_HANDLE_FLG;
		cifs_dbg(FYI, "Batch Oplock granted on inode %p\n",
			 &cinode->vfs_inode);
	} else if (oplock == SMB2_OPLOCK_LEVEL_EXCLUSIVE) {
		cinode->oplock = CIFS_CACHE_READ_FLG | CIFS_CACHE_WRITE_FLG;
		cifs_dbg(FYI, "Exclusive Oplock granted on inode %p\n",
			 &cinode->vfs_inode);
	} else if (oplock == SMB2_OPLOCK_LEVEL_II) {
		cinode->oplock = CIFS_CACHE_READ_FLG;
		cifs_dbg(FYI, "Level II Oplock granted on inode %p\n",
			 &cinode->vfs_inode);
	} else
		cinode->oplock = 0;
}

int
smb2_open_file(const unsigned int xid, struct cifs_open_parms *oparms,
	       __u32 *oplock, FILE_ALL_INFO *buf)
Loading