bool got_handle_lease;
bool got_oplock;
bool have_other_lease;
+ uint32_t total_lease_types;
bool delay;
};
e_lease_type = get_lease_type(e, fsp->file_id);
}
+ if (((e_lease_type & ~state->total_lease_types) != 0) &&
+ !share_entry_stale_pid(e))
+ {
+ state->total_lease_types |= e_lease_type;
+ }
+
if (!state->got_handle_lease &&
((e_lease_type & SMB2_LEASE_HANDLE) != 0) &&
!share_entry_stale_pid(e)) {
oplock_request & ~SAMBA_PRIVATE_OPLOCK_MASK);
}
+ share_mode_flags_get(lck, NULL, NULL, &state.total_lease_types);
+
if (is_oplock_stat_open(fsp->access_mask)) {
goto grant;
}
break;
}
+ state.total_lease_types = SMB2_LEASE_NONE;
ok = share_mode_forall_entries(lck, delay_for_oplock_fn, &state);
if (!ok) {
return NT_STATUS_INTERNAL_ERROR;
granted = map_oplock_to_lease_type(oplock_type);
}
- if (granted & SMB2_LEASE_READ) {
+ state.total_lease_types |= granted;
+
+ {
uint32_t acc, sh, ls;
share_mode_flags_get(lck, &acc, &sh, &ls);
- ls |= SMB2_LEASE_READ;
+ ls = state.total_lease_types;
share_mode_flags_set(lck, acc, sh, ls, NULL);
}
DBG_DEBUG("oplock type 0x%x granted (%s%s%s)(0x%x), on file %s, "
- "requested 0x%x (%s%s%s)(0x%x)\n",
+ "requested 0x%x (%s%s%s)(0x%x) => total (%s%s%s)(0x%x)\n",
fsp->oplock_type,
granted & SMB2_LEASE_READ ? "R":"",
granted & SMB2_LEASE_WRITE ? "W":"",
requested & SMB2_LEASE_READ ? "R":"",
requested & SMB2_LEASE_WRITE ? "W":"",
requested & SMB2_LEASE_HANDLE ? "H":"",
- requested);
+ requested,
+ state.total_lease_types & SMB2_LEASE_READ ? "R":"",
+ state.total_lease_types & SMB2_LEASE_WRITE ? "W":"",
+ state.total_lease_types & SMB2_LEASE_HANDLE ? "H":"",
+ state.total_lease_types);
*poplock_type = oplock_type;
*pgranted = granted;
struct smb2_lease_key lease_key;
struct GUID client_guid;
size_t num_read_leases;
+ uint32_t total_lease_types;
};
static bool do_break_lease_to_none(struct share_mode_entry *e,
return false;
}
+ state->total_lease_types |= current_state;
+
if ((current_state & SMB2_LEASE_READ) == 0) {
return false;
}
DBG_DEBUG("e->op_type == %d\n", e->op_type);
+ state->total_lease_types |= map_oplock_to_lease_type(e->op_type);
+
if (e->op_type == NO_OPLOCK) {
return false;
}
DBG_WARNING("share_mode_forall_entries failed\n");
}
- if (state.num_read_leases == 0) {
+ {
/*
- * Lazy update here. It might be that the read lease
- * has gone in the meantime.
+ * Lazy update here. It might be that all leases
+ * have gone in the meantime.
*/
uint32_t acc, sh, ls;
share_mode_flags_get(lck, &acc, &sh, &ls);
- ls &= ~SMB2_LEASE_READ;
+ ls = state.total_lease_types;
share_mode_flags_set(lck, acc, sh, ls, NULL);
}