diff options
Diffstat (limited to 'source3/include')
-rw-r--r-- | source3/include/locking.h | 20 | ||||
-rw-r--r-- | source3/include/proto.h | 26 | ||||
-rw-r--r-- | source3/include/vfs.h | 24 | ||||
-rw-r--r-- | source3/include/vfs_macros.h | 9 |
4 files changed, 74 insertions, 5 deletions
diff --git a/source3/include/locking.h b/source3/include/locking.h index b2b7236721..3fd5b94de7 100644 --- a/source3/include/locking.h +++ b/source3/include/locking.h @@ -75,4 +75,24 @@ struct lock_struct { enum brl_flavour lock_flav; }; +/**************************************************************************** + This is the structure to queue to implement blocking locks. +*****************************************************************************/ + +struct blocking_lock_record { + struct blocking_lock_record *next; + struct blocking_lock_record *prev; + struct files_struct *fsp; + struct timeval expire_time; + int lock_num; + uint64_t offset; + uint64_t count; + uint32_t lock_pid; + uint32_t blocking_pid; /* PID that blocks us. */ + enum brl_flavour lock_flav; + enum brl_type lock_type; + struct smb_request *req; + void *blr_private; /* Implementation specific. */ +}; + #endif /* _LOCKING_H_ */ diff --git a/source3/include/proto.h b/source3/include/proto.h index 34104727e9..ed2c50af2f 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -3379,8 +3379,14 @@ struct packet_struct *receive_unexpected(enum packet_type packet_type, int id, bool brl_same_context(const struct lock_context *ctx1, const struct lock_context *ctx2); +NTSTATUS brl_lock_failed(files_struct *fsp, const struct lock_struct *lock, bool blocking_lock); void brl_init(bool read_only); void brl_shutdown(void); + +NTSTATUS brl_lock_windows_default(struct byte_range_lock *br_lck, + struct lock_struct *plock, + bool blocking_lock); + NTSTATUS brl_lock(struct messaging_context *msg_ctx, struct byte_range_lock *br_lck, uint32 smbpid, @@ -3390,7 +3396,8 @@ NTSTATUS brl_lock(struct messaging_context *msg_ctx, enum brl_type lock_type, enum brl_flavour lock_flav, bool blocking_lock, - uint32 *psmbpid); + uint32 *psmbpid, + struct blocking_lock_record *blr); bool brl_unlock(struct messaging_context *msg_ctx, struct byte_range_lock *br_lck, uint32 smbpid, @@ -3398,6 +3405,9 @@ bool brl_unlock(struct messaging_context *msg_ctx, br_off start, br_off size, enum brl_flavour lock_flav); +bool brl_unlock_windows_default(struct messaging_context *msg_ctx, + struct byte_range_lock *br_lck, + const struct lock_struct *plock); bool brl_locktest(struct byte_range_lock *br_lck, uint32 smbpid, struct server_id pid, @@ -3417,7 +3427,10 @@ bool brl_lock_cancel(struct byte_range_lock *br_lck, struct server_id pid, br_off start, br_off size, - enum brl_flavour lock_flav); + enum brl_flavour lock_flav, + struct blocking_lock_record *blr); +bool brl_lock_cancel_default(struct byte_range_lock *br_lck, + struct lock_struct *plock); void brl_close_fnum(struct messaging_context *msg_ctx, struct byte_range_lock *br_lck); int brl_forall(void (*fn)(struct file_id id, struct server_id pid, @@ -3456,7 +3469,8 @@ struct byte_range_lock *do_lock(struct messaging_context *msg_ctx, enum brl_flavour lock_flav, bool blocking_lock, NTSTATUS *perr, - uint32 *plock_pid); + uint32 *plock_pid, + struct blocking_lock_record *blr); NTSTATUS do_unlock(struct messaging_context *msg_ctx, files_struct *fsp, uint32 lock_pid, @@ -3467,7 +3481,8 @@ NTSTATUS do_lock_cancel(files_struct *fsp, uint32 lock_pid, uint64_t count, uint64_t offset, - enum brl_flavour lock_flav); + enum brl_flavour lock_flav, + struct blocking_lock_record *blr); void locking_close_file(struct messaging_context *msg_ctx, files_struct *fsp); bool locking_init(void); @@ -6342,6 +6357,7 @@ void smbd_aio_complete_mid(unsigned int mid); /* The following definitions come from smbd/blocking.c */ +void process_blocking_lock_queue(void); bool push_blocking_lock_request( struct byte_range_lock *br_lck, struct smb_request *req, files_struct *fsp, @@ -6356,7 +6372,7 @@ bool push_blocking_lock_request( struct byte_range_lock *br_lck, void cancel_pending_lock_requests_by_fid(files_struct *fsp, struct byte_range_lock *br_lck); void remove_pending_lock_requests_by_mid(int mid); bool blocking_lock_was_deferred(int mid); -bool blocking_lock_cancel(files_struct *fsp, +struct blocking_lock_record *blocking_lock_cancel(files_struct *fsp, uint32 lock_pid, uint64_t offset, uint64_t count, diff --git a/source3/include/vfs.h b/source3/include/vfs.h index f944c899c6..ffa1a95ed0 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -115,6 +115,7 @@ /* Leave at 25 - not yet released. Add get_alloc_size call. -- tprouty. */ /* Leave at 25 - not yet released. Add SMB_STRUCT_STAT to readdir. - sdann */ /* Leave at 25 - not yet released. Add init_search_op call. - sdann */ +/* Leave at 25 - not yet released. Add locking calls. -- zkirsch. */ #define SMB_VFS_INTERFACE_VERSION 25 @@ -142,6 +143,7 @@ struct vfs_statvfs_struct; struct smb_request; struct ea_list; struct smb_file_time; +struct blocking_lock_record; /* Available VFS operations. These values must be in sync with vfs_ops struct @@ -218,6 +220,9 @@ typedef enum _vfs_op_type { SMB_VFS_OP_FILE_ID_CREATE, SMB_VFS_OP_STREAMINFO, SMB_VFS_OP_GET_REAL_FILENAME, + SMB_VFS_OP_BRL_LOCK_WINDOWS, + SMB_VFS_OP_BRL_UNLOCK_WINDOWS, + SMB_VFS_OP_BRL_CANCEL_WINDOWS, /* NT ACL operations. */ @@ -393,6 +398,22 @@ struct vfs_ops { TALLOC_CTX *mem_ctx, char **found_name); + NTSTATUS (*brl_lock_windows)(struct vfs_handle_struct *handle, + struct byte_range_lock *br_lck, + struct lock_struct *plock, + bool blocking_lock, + struct blocking_lock_record *blr); + + bool (*brl_unlock_windows)(struct vfs_handle_struct *handle, + struct messaging_context *msg_ctx, + struct byte_range_lock *br_lck, + const struct lock_struct *plock); + + bool (*brl_cancel_windows)(struct vfs_handle_struct *handle, + struct byte_range_lock *br_lck, + struct lock_struct *plock, + struct blocking_lock_record *blr); + /* NT ACL operations. */ NTSTATUS (*fget_nt_acl)(struct vfs_handle_struct *handle, @@ -531,6 +552,9 @@ struct vfs_ops { struct vfs_handle_struct *file_id_create; struct vfs_handle_struct *streaminfo; struct vfs_handle_struct *get_real_filename; + struct vfs_handle_struct *brl_lock_windows; + struct vfs_handle_struct *brl_unlock_windows; + struct vfs_handle_struct *brl_cancel_windows; /* NT ACL operations. */ diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index e57cbd2538..dcef63da86 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -88,6 +88,9 @@ #define SMB_VFS_FILE_ID_CREATE(conn, dev, inode) ((conn)->vfs.ops.file_id_create((conn)->vfs.handles.file_id_create, (dev), (inode))) #define SMB_VFS_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams) ((conn)->vfs.ops.streaminfo((conn)->vfs.handles.streaminfo, (fsp), (fname), (mem_ctx), (num_streams), (streams))) #define SMB_VFS_GET_REAL_FILENAME(conn, path, name, mem_ctx, found_name) ((conn)->vfs.ops.get_real_filename((conn)->vfs.handles.get_real_filename, (path), (name), (mem_ctx), (found_name))) +#define SMB_VFS_BRL_LOCK_WINDOWS(conn, br_lck, plock, blocking_lock, blr) ((conn)->vfs.ops.brl_lock_windows((conn)->vfs.handles.brl_lock_windows, (br_lck), (plock), (blocking_lock), (blr))) +#define SMB_VFS_BRL_UNLOCK_WINDOWS(conn, msg_ctx, br_lck, plock) ((conn)->vfs.ops.brl_unlock_windows((conn)->vfs.handles.brl_unlock_windows, (msg_ctx), (br_lck), (plock))) +#define SMB_VFS_BRL_CANCEL_WINDOWS(conn, br_lck, plock, blr) ((conn)->vfs.ops.brl_cancel_windows((conn)->vfs.handles.brl_cancel_windows, (br_lck), (plock), (blr))) /* NT ACL operations. */ #define SMB_VFS_FGET_NT_ACL(fsp, security_info, ppdesc) ((fsp)->conn->vfs.ops.fget_nt_acl((fsp)->conn->vfs.handles.fget_nt_acl, (fsp), (security_info), (ppdesc))) @@ -217,6 +220,9 @@ #define SMB_VFS_OPAQUE_FILE_ID_CREATE(conn, dev, inode) ((conn)->vfs.ops_opaque.file_id_create((conn)->vfs_opaque.handles.file_id_create, (dev), (inode))) #define SMB_VFS_OPAQUE_STREAMINFO(conn, fsp, fname, mem_ctx, num_streams, streams) ((conn)->vfs_opaque.ops.streaminfo((conn)->vfs_opaque.handles.streaminfo, (fsp), (fname), (mem_ctx), (num_streams), (streams))) #define SMB_VFS_OPAQUE_GET_REAL_FILENAME(conn, path, name, mem_ctx, found_name) ((conn)->vfs_opaque.ops.get_real_filename((conn)->vfs_opaque.handles.get_real_filename, (path), (name), (mem_ctx), (found_name))) +#define SMB_VFS_OPAQUE_BRL_LOCK_WINDOWS(conn, br_lck, plock, blocking_lock, blr) ((conn)->vfs_opaque.ops.brl_lock_windows((conn)->vfs_opaque.handles.brl_lock_windows, (br_lck), (plock), (blocking_lock), (blr))) +#define SMB_VFS_OPAQUE_BRL_UNLOCK_WINDOWS(conn, msg_ctx, br_lck, plock) ((conn)->vfs_opaque.ops.brl_unlock_windows((conn)->vfs_opaque.handles.brl_unlock_windows, (msg_ctx), (br_lck), (plock))) +#define SMB_VFS_OPAQUE_BRL_CANCEL_WINDOWS(conn, br_lck, plock, blr) ((conn)->vfs_opaque.ops.brl_cancel_windows((conn)->vfs_opaque.handles.brl_cancel_windows, (br_lck), (plock), (blr))) /* NT ACL operations. */ #define SMB_VFS_OPAQUE_FGET_NT_ACL(fsp, security_info, ppdesc) ((fsp)->conn->vfs_opaque.ops.fget_nt_acl((fsp)->conn->vfs_opaque.handles.fget_nt_acl, (fsp), (security_info), (ppdesc))) @@ -347,6 +353,9 @@ #define SMB_VFS_NEXT_FILE_ID_CREATE(handle, dev, inode) ((handle)->vfs_next.ops.file_id_create((handle)->vfs_next.handles.file_id_create, (dev), (inode))) #define SMB_VFS_NEXT_STREAMINFO(handle, fsp, fname, mem_ctx, num_streams, streams) ((handle)->vfs_next.ops.streaminfo((handle)->vfs_next.handles.streaminfo, (fsp), (fname), (mem_ctx), (num_streams), (streams))) #define SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name, mem_ctx, found_name) ((handle)->vfs_next.ops.get_real_filename((handle)->vfs_next.handles.get_real_filename, (path), (name), (mem_ctx), (found_name))) +#define SMB_VFS_NEXT_BRL_LOCK_WINDOWS(handle, br_lck, plock, blocking_lock, blr) ((handle)->vfs_next.ops.brl_lock_windows((handle)->vfs_next.handles.brl_lock_windows, (br_lck), (plock), (blocking_lock), (blr))) +#define SMB_VFS_NEXT_BRL_UNLOCK_WINDOWS(handle, msg_ctx, br_lck, plock) ((handle)->vfs_next.ops.brl_unlock_windows((handle)->vfs_next.handles.brl_unlock_windows, (msg_ctx), (br_lck), (plock))) +#define SMB_VFS_NEXT_BRL_CANCEL_WINDOWS(handle, br_lck, plock, blr) ((handle)->vfs_next.ops.brl_cancel_windows((handle)->vfs_next.handles.brl_cancel_windows, (br_lck), (plock), (blr))) /* NT ACL operations. */ #define SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info, ppdesc) ((handle)->vfs_next.ops.fget_nt_acl((handle)->vfs_next.handles.fget_nt_acl, (fsp), (security_info), (ppdesc))) |