|
@@ -377,9 +377,11 @@ static void
|
|
|
smb2_set_fid(struct cifsFileInfo *cfile, struct cifs_fid *fid, __u32 oplock)
|
|
|
{
|
|
|
struct cifsInodeInfo *cinode = CIFS_I(cfile->dentry->d_inode);
|
|
|
+ struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server;
|
|
|
+
|
|
|
cfile->fid.persistent_fid = fid->persistent_fid;
|
|
|
cfile->fid.volatile_fid = fid->volatile_fid;
|
|
|
- smb2_set_oplock_level(cinode, oplock);
|
|
|
+ server->ops->set_oplock_level(cinode, oplock);
|
|
|
cinode->can_cache_brlcks = CIFS_CACHE_WRITE(cinode);
|
|
|
}
|
|
|
|
|
@@ -648,7 +650,71 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon,
|
|
|
return rc;
|
|
|
}
|
|
|
|
|
|
-struct smb_version_operations smb21_operations = {
|
|
|
+static 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;
|
|
|
+}
|
|
|
+
|
|
|
+static void
|
|
|
+smb21_set_oplock_level(struct cifsInodeInfo *cinode, __u32 oplock)
|
|
|
+{
|
|
|
+ char message[5] = {0};
|
|
|
+
|
|
|
+ oplock &= 0xFF;
|
|
|
+ if (oplock == SMB2_OPLOCK_LEVEL_NOCHANGE)
|
|
|
+ return;
|
|
|
+
|
|
|
+ cinode->oplock = 0;
|
|
|
+ if (oplock & SMB2_LEASE_READ_CACHING_HE) {
|
|
|
+ cinode->oplock |= CIFS_CACHE_READ_FLG;
|
|
|
+ strcat(message, "R");
|
|
|
+ }
|
|
|
+ if (oplock & SMB2_LEASE_HANDLE_CACHING_HE) {
|
|
|
+ cinode->oplock |= CIFS_CACHE_HANDLE_FLG;
|
|
|
+ strcat(message, "H");
|
|
|
+ }
|
|
|
+ if (oplock & SMB2_LEASE_WRITE_CACHING_HE) {
|
|
|
+ cinode->oplock |= CIFS_CACHE_WRITE_FLG;
|
|
|
+ strcat(message, "W");
|
|
|
+ }
|
|
|
+ if (!cinode->oplock)
|
|
|
+ strcat(message, "None");
|
|
|
+ cifs_dbg(FYI, "%s Lease granted on inode %p\n", message,
|
|
|
+ &cinode->vfs_inode);
|
|
|
+}
|
|
|
+
|
|
|
+static bool
|
|
|
+smb2_is_read_op(__u32 oplock)
|
|
|
+{
|
|
|
+ return oplock == SMB2_OPLOCK_LEVEL_II;
|
|
|
+}
|
|
|
+
|
|
|
+static bool
|
|
|
+smb21_is_read_op(__u32 oplock)
|
|
|
+{
|
|
|
+ return (oplock & SMB2_LEASE_READ_CACHING_HE) &&
|
|
|
+ !(oplock & SMB2_LEASE_WRITE_CACHING_HE);
|
|
|
+}
|
|
|
+
|
|
|
+struct smb_version_operations smb20_operations = {
|
|
|
.compare_fids = smb2_compare_fids,
|
|
|
.setup_request = smb2_setup_request,
|
|
|
.setup_async_request = smb2_setup_async_request,
|
|
@@ -713,8 +779,78 @@ struct smb_version_operations smb21_operations = {
|
|
|
.set_lease_key = smb2_set_lease_key,
|
|
|
.new_lease_key = smb2_new_lease_key,
|
|
|
.calc_signature = smb2_calc_signature,
|
|
|
+ .is_read_op = smb2_is_read_op,
|
|
|
+ .set_oplock_level = smb2_set_oplock_level,
|
|
|
};
|
|
|
|
|
|
+struct smb_version_operations smb21_operations = {
|
|
|
+ .compare_fids = smb2_compare_fids,
|
|
|
+ .setup_request = smb2_setup_request,
|
|
|
+ .setup_async_request = smb2_setup_async_request,
|
|
|
+ .check_receive = smb2_check_receive,
|
|
|
+ .add_credits = smb2_add_credits,
|
|
|
+ .set_credits = smb2_set_credits,
|
|
|
+ .get_credits_field = smb2_get_credits_field,
|
|
|
+ .get_credits = smb2_get_credits,
|
|
|
+ .get_next_mid = smb2_get_next_mid,
|
|
|
+ .read_data_offset = smb2_read_data_offset,
|
|
|
+ .read_data_length = smb2_read_data_length,
|
|
|
+ .map_error = map_smb2_to_linux_error,
|
|
|
+ .find_mid = smb2_find_mid,
|
|
|
+ .check_message = smb2_check_message,
|
|
|
+ .dump_detail = smb2_dump_detail,
|
|
|
+ .clear_stats = smb2_clear_stats,
|
|
|
+ .print_stats = smb2_print_stats,
|
|
|
+ .is_oplock_break = smb2_is_valid_oplock_break,
|
|
|
+ .need_neg = smb2_need_neg,
|
|
|
+ .negotiate = smb2_negotiate,
|
|
|
+ .negotiate_wsize = smb2_negotiate_wsize,
|
|
|
+ .negotiate_rsize = smb2_negotiate_rsize,
|
|
|
+ .sess_setup = SMB2_sess_setup,
|
|
|
+ .logoff = SMB2_logoff,
|
|
|
+ .tree_connect = SMB2_tcon,
|
|
|
+ .tree_disconnect = SMB2_tdis,
|
|
|
+ .is_path_accessible = smb2_is_path_accessible,
|
|
|
+ .can_echo = smb2_can_echo,
|
|
|
+ .echo = SMB2_echo,
|
|
|
+ .query_path_info = smb2_query_path_info,
|
|
|
+ .get_srv_inum = smb2_get_srv_inum,
|
|
|
+ .query_file_info = smb2_query_file_info,
|
|
|
+ .set_path_size = smb2_set_path_size,
|
|
|
+ .set_file_size = smb2_set_file_size,
|
|
|
+ .set_file_info = smb2_set_file_info,
|
|
|
+ .mkdir = smb2_mkdir,
|
|
|
+ .mkdir_setinfo = smb2_mkdir_setinfo,
|
|
|
+ .rmdir = smb2_rmdir,
|
|
|
+ .unlink = smb2_unlink,
|
|
|
+ .rename = smb2_rename_path,
|
|
|
+ .create_hardlink = smb2_create_hardlink,
|
|
|
+ .query_symlink = smb2_query_symlink,
|
|
|
+ .open = smb2_open_file,
|
|
|
+ .set_fid = smb2_set_fid,
|
|
|
+ .close = smb2_close_file,
|
|
|
+ .flush = smb2_flush_file,
|
|
|
+ .async_readv = smb2_async_readv,
|
|
|
+ .async_writev = smb2_async_writev,
|
|
|
+ .sync_read = smb2_sync_read,
|
|
|
+ .sync_write = smb2_sync_write,
|
|
|
+ .query_dir_first = smb2_query_dir_first,
|
|
|
+ .query_dir_next = smb2_query_dir_next,
|
|
|
+ .close_dir = smb2_close_dir,
|
|
|
+ .calc_smb_size = smb2_calc_size,
|
|
|
+ .is_status_pending = smb2_is_status_pending,
|
|
|
+ .oplock_response = smb2_oplock_response,
|
|
|
+ .queryfs = smb2_queryfs,
|
|
|
+ .mand_lock = smb2_mand_lock,
|
|
|
+ .mand_unlock_range = smb2_unlock_range,
|
|
|
+ .push_mand_locks = smb2_push_mandatory_locks,
|
|
|
+ .get_lease_key = smb2_get_lease_key,
|
|
|
+ .set_lease_key = smb2_set_lease_key,
|
|
|
+ .new_lease_key = smb2_new_lease_key,
|
|
|
+ .calc_signature = smb2_calc_signature,
|
|
|
+ .is_read_op = smb21_is_read_op,
|
|
|
+ .set_oplock_level = smb21_set_oplock_level,
|
|
|
+};
|
|
|
|
|
|
struct smb_version_operations smb30_operations = {
|
|
|
.compare_fids = smb2_compare_fids,
|
|
@@ -783,6 +919,8 @@ struct smb_version_operations smb30_operations = {
|
|
|
.new_lease_key = smb2_new_lease_key,
|
|
|
.generate_signingkey = generate_smb3signingkey,
|
|
|
.calc_signature = smb3_calc_signature,
|
|
|
+ .is_read_op = smb21_is_read_op,
|
|
|
+ .set_oplock_level = smb21_set_oplock_level,
|
|
|
};
|
|
|
|
|
|
struct smb_version_values smb20_values = {
|
|
@@ -800,7 +938,6 @@ struct smb_version_values smb20_values = {
|
|
|
.cap_unix = 0,
|
|
|
.cap_nt_find = SMB2_NT_FIND,
|
|
|
.cap_large_files = SMB2_LARGE_FILES,
|
|
|
- .oplock_read = SMB2_OPLOCK_LEVEL_II,
|
|
|
.signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
|
|
|
.signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
|
|
|
};
|
|
@@ -820,7 +957,6 @@ struct smb_version_values smb21_values = {
|
|
|
.cap_unix = 0,
|
|
|
.cap_nt_find = SMB2_NT_FIND,
|
|
|
.cap_large_files = SMB2_LARGE_FILES,
|
|
|
- .oplock_read = SMB2_OPLOCK_LEVEL_II,
|
|
|
.signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
|
|
|
.signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
|
|
|
};
|
|
@@ -840,7 +976,6 @@ struct smb_version_values smb30_values = {
|
|
|
.cap_unix = 0,
|
|
|
.cap_nt_find = SMB2_NT_FIND,
|
|
|
.cap_large_files = SMB2_LARGE_FILES,
|
|
|
- .oplock_read = SMB2_OPLOCK_LEVEL_II,
|
|
|
.signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
|
|
|
.signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
|
|
|
};
|
|
@@ -860,7 +995,6 @@ struct smb_version_values smb302_values = {
|
|
|
.cap_unix = 0,
|
|
|
.cap_nt_find = SMB2_NT_FIND,
|
|
|
.cap_large_files = SMB2_LARGE_FILES,
|
|
|
- .oplock_read = SMB2_OPLOCK_LEVEL_II,
|
|
|
.signing_enabled = SMB2_NEGOTIATE_SIGNING_ENABLED | SMB2_NEGOTIATE_SIGNING_REQUIRED,
|
|
|
.signing_required = SMB2_NEGOTIATE_SIGNING_REQUIRED,
|
|
|
};
|