*/
*keep_locked = false;
+ if (fsp->current_lock_count > 0) {
+ /*
+ * Remove the byte-range locks under the glock
+ */
+ *keep_locked = true;
+ }
+
+ if (fh_get_refcount(fsp->fh) > 1) {
+ return;
+ }
+
if (fsp->oplock_type != NO_OPLOCK) {
ok = remove_share_oplock(lck, fsp);
if (!ok) {
return status;
}
+ locking_close_file(fsp, close_type);
+
+ if (fh_get_refcount(fsp->fh) > 1) {
+ goto done;
+ }
+
/* Remove the oplock before potentially deleting the file. */
if (fsp->oplock_type != NO_OPLOCK) {
release_file_oplock(fsp);
the same handle we only have one share mode. Ensure we only remove
the share mode on the last close. */
- if (fh_get_refcount(fsp->fh) == 1) {
- /* Should we return on error here... ? */
- tmp = close_remove_share_mode(fsp, close_type);
- status = ntstatus_keeperror(status, tmp);
- }
-
- locking_close_file(fsp, close_type);
+ tmp = close_remove_share_mode(fsp, close_type);
+ status = ntstatus_keeperror(status, tmp);
/*
* Ensure pending modtime is set before closing underlying fd.