ReactOS  0.4.14-dev-556-g4c5b21f
btrfs_drv.h File Reference
#include <ntifs.h>
#include <ntddk.h>
#include <mountmgr.h>
#include <windef.h>
#include <wdm.h>
#include <stdio.h>
#include <stdarg.h>
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
#include <emmintrin.h>
#include "btrfs.h"
#include "btrfsioctl.h"
Include dependency graph for btrfs_drv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _FILE_ID_128
 
struct  _DUPLICATE_EXTENTS_DATA
 
struct  _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER
 
struct  _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER
 
struct  _fcb_nonpaged
 
struct  extent
 
struct  hardlink
 
struct  dir_child
 
struct  xattr
 
struct  _fcb
 
struct  file_ref_nonpaged
 
struct  _file_ref
 
struct  send_info
 
struct  _ccb
 
struct  tree_holder
 
struct  _tree_data
 
struct  tree_nonpaged
 
struct  _tree
 
struct  root_nonpaged
 
struct  _root
 
struct  batch_item
 
struct  batch_root
 
struct  traverse_ptr
 
struct  _root_cache
 
struct  space
 
struct  device
 
struct  range_lock
 
struct  partial_stripe
 
struct  chunk
 
struct  changed_extent
 
struct  changed_extent_ref
 
struct  sys_chunk
 
struct  calc_job
 
struct  drv_calc_thread
 
struct  drv_calc_threads
 
struct  mount_options
 
struct  balance_info
 
struct  scrub_error
 
struct  scrub_info
 
struct  _device_extension
 
struct  control_device_extension
 
struct  bus_device_extension
 
struct  volume_child
 
struct  _volume_device_extension
 
struct  pdo_device_extension
 
struct  uid_map
 
struct  gid_map
 
struct  write_data_stripe
 
struct  _write_data_context
 
struct  tree_write
 
struct  name_bit
 
struct  rollback_space
 
struct  rollback_extent
 
struct  rollback_item
 
struct  ea_item
 
struct  FSRTL_ADVANCED_FCB_HEADER_NEW
 
struct  _LDR_DATA_TABLE_ENTRY
 
struct  _PEB_LDR_DATA
 
struct  _RTL_USER_PROCESS_PARAMETERS
 
struct  _PEB
 

Macros

#define _WIN32_WINNT   0x0601
 
#define NTDDI_VERSION   0x06020000
 
#define _CRT_SECURE_NO_WARNINGS
 
#define _NO_CRT_STDIO_INLINE
 
#define UNUSED(x)   (void)(x)
 
#define BTRFS_NODE_TYPE_CCB   0x2295
 
#define BTRFS_NODE_TYPE_FCB   0x2296
 
#define ALLOC_TAG   0x7442484D
 
#define ALLOC_TAG_ZLIB   0x7A42484D
 
#define UID_NOBODY   65534
 
#define GID_NOBODY   65534
 
#define EA_NTACL   "security.NTACL"
 
#define EA_NTACL_HASH   0x45922146
 
#define EA_DOSATTRIB   "user.DOSATTRIB"
 
#define EA_DOSATTRIB_HASH   0x914f9939
 
#define EA_REPARSE   "user.reparse"
 
#define EA_REPARSE_HASH   0xfabad1fe
 
#define EA_EA   "user.EA"
 
#define EA_EA_HASH   0x8270dd43
 
#define EA_CASE_SENSITIVE   "user.casesensitive"
 
#define EA_CASE_SENSITIVE_HASH   0x1a9d97d4
 
#define EA_PROP_COMPRESSION   "btrfs.compression"
 
#define EA_PROP_COMPRESSION_HASH   0x20ccdf69
 
#define MAX_EXTENT_SIZE   0x8000000
 
#define COMPRESSED_EXTENT_SIZE   0x20000
 
#define READ_AHEAD_GRANULARITY   COMPRESSED_EXTENT_SIZE
 
#define IO_REPARSE_TAG_LXSS_SYMLINK   0xa000001d
 
#define IO_REPARSE_TAG_LXSS_SOCKET   0x80000023
 
#define IO_REPARSE_TAG_LXSS_FIFO   0x80000024
 
#define IO_REPARSE_TAG_LXSS_CHARDEV   0x80000025
 
#define IO_REPARSE_TAG_LXSS_BLOCKDEV   0x80000026
 
#define BTRFS_VOLUME_PREFIX   L"\\Device\\Btrfs{"
 
#define try   if (1)
 
#define except(x)   if (0 && (x))
 
#define finally   if (1)
 
#define FILE_SUPPORTS_BLOCK_REFCOUNTING   0x08000000
 
#define FILE_SUPPORTS_POSIX_UNLINK_RENAME   0x00000400
 
#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL   0x00020000
 
#define FSCTL_DUPLICATE_EXTENTS_TO_FILE   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 209, METHOD_BUFFERED, FILE_WRITE_ACCESS)
 
#define FSCTL_GET_INTEGRITY_INFORMATION   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, FILE_ANY_ACCESS)
 
#define FSCTL_SET_INTEGRITY_INFORMATION   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
 
#define __drv_aliasesMem
 
#define _Requires_lock_held_(a)
 
#define _Requires_exclusive_lock_held_(a)
 
#define _Releases_lock_(a)
 
#define _Out_writes_bytes_opt_(a)
 
#define _Pre_satisfies_(a)
 
#define _Post_satisfies_(a)
 
#define _Releases_exclusive_lock_(a)
 
#define _Dispatch_type_(a)
 
#define _Create_lock_level_(a)
 
#define _Lock_level_order_(a, b)
 
#define _Has_lock_level_(a)
 
#define _Requires_lock_not_held_(a)
 
#define _Acquires_exclusive_lock_(a)
 
#define _Acquires_shared_lock_(a)
 
#define VCB_TYPE_FS   1
 
#define VCB_TYPE_CONTROL   2
 
#define VCB_TYPE_VOLUME   3
 
#define VCB_TYPE_PDO   4
 
#define VCB_TYPE_BUS   5
 
#define BALANCE_OPTS_DATA   0
 
#define BALANCE_OPTS_METADATA   1
 
#define BALANCE_OPTS_SYSTEM   2
 
#define keycmp(key1, key2)
 
#define acquire_chunk_lock(c, Vcb)   ExAcquireResourceExclusiveLite(&(c)->lock, true)
 
#define release_chunk_lock(c, Vcb)   ExReleaseResourceLite(&(c)->lock)
 
#define funcname   __func__
 
#define TRACE(s, ...)
 
#define WARN(s, ...)
 
#define FIXME(s, ...)   DbgPrint("Btrfs FIXME : %s : " s, funcname, ##__VA_ARGS__)
 
#define ERR(s, ...)   DbgPrint("Btrfs ERR : %s : " s, funcname, ##__VA_ARGS__)
 
#define makedev(major, minor)   (((minor) & 0xFF) | (((major) & 0xFFF) << 8) | (((uint64_t)((minor) & ~0xFF)) << 12) | (((uint64_t)((major) & ~0xFFF)) << 32))
 
#define FSRTL_FCB_HEADER_V2   2
 
#define increase_fileref_refcount(fileref)   InterlockedIncrement(&fileref->refcount)
 
#define int3   asm("int3;")
 
#define hex_digit(c)   ((c) <= 9) ? ((c) + '0') : ((c) - 10 + 'a')
 
#define __S_IFMT   0170000 /* These bits determine file type. */
 
#define __S_IFDIR   0040000 /* Directory. */
 
#define __S_IFCHR   0020000 /* Character device. */
 
#define __S_IFBLK   0060000 /* Block device. */
 
#define __S_IFREG   0100000 /* Regular file. */
 
#define __S_IFIFO   0010000 /* FIFO. */
 
#define __S_IFLNK   0120000 /* Symbolic link. */
 
#define __S_IFSOCK   0140000 /* Socket. */
 
#define __S_ISTYPE(mode, mask)   (((mode) & __S_IFMT) == (mask))
 
#define S_ISDIR(mode)   __S_ISTYPE((mode), __S_IFDIR)
 
#define S_IRUSR   0000400
 
#define S_IWUSR   0000200
 
#define S_IXUSR   0000100
 
#define S_IRGRP   (S_IRUSR >> 3)
 
#define S_IWGRP   (S_IWUSR >> 3)
 
#define S_IXGRP   (S_IXUSR >> 3)
 
#define S_IROTH   (S_IRGRP >> 3)
 
#define S_IWOTH   (S_IWGRP >> 3)
 
#define S_IXOTH   (S_IXGRP >> 3)
 
#define S_ISUID   0004000
 
#define S_ISGID   0002000
 
#define S_ISVTX   0001000
 
#define major(rdev)   ((((rdev) >> 8) & 0xFFF) | ((uint32_t)((rdev) >> 32) & ~0xFFF))
 
#define minor(rdev)   (((rdev) & 0xFF) | ((uint32_t)((rdev) >> 12) & ~0xFF))
 
#define CC_ENABLE_DISK_IO_ACCOUNTING   0x00000010
 

Typedefs

typedef struct _FILE_ID_128 FILE_ID_128
 
typedef struct _FILE_ID_128PFILE_ID_128
 
typedef struct _DUPLICATE_EXTENTS_DATA DUPLICATE_EXTENTS_DATA
 
typedef struct _DUPLICATE_EXTENTS_DATAPDUPLICATE_EXTENTS_DATA
 
typedef struct _FSCTL_GET_INTEGRITY_INFORMATION_BUFFER FSCTL_GET_INTEGRITY_INFORMATION_BUFFER
 
typedef struct _FSCTL_GET_INTEGRITY_INFORMATION_BUFFERPFSCTL_GET_INTEGRITY_INFORMATION_BUFFER
 
typedef struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFER FSCTL_SET_INTEGRITY_INFORMATION_BUFFER
 
typedef struct _FSCTL_SET_INTEGRITY_INFORMATION_BUFFERPFSCTL_SET_INTEGRITY_INFORMATION_BUFFER
 
typedef struct _fcb_nonpaged fcb_nonpaged
 
typedef struct _fcb fcb
 
typedef struct _file_ref file_ref
 
typedef struct _ccb ccb
 
typedef struct _tree_data tree_data
 
typedef struct _tree tree
 
typedef struct _root root
 
typedef struct _root_cache root_cache
 
typedef struct _device_extension device_extension
 
typedef struct _volume_device_extension volume_device_extension
 
typedef struct pdo_device_extension pdo_device_extension
 
typedef struct _write_data_context write_data_context
 
typedef BOOLEAN(__stdcalltPsIsDiskCountersEnabled) ()
 
typedef VOID(__stdcalltPsUpdateDiskCounters) (PEPROCESS Process, ULONG64 BytesRead, ULONG64 BytesWritten, ULONG ReadOperationCount, ULONG WriteOperationCount, ULONG FlushOperationCount)
 
typedef BOOLEAN(__stdcalltCcCopyWriteEx) (PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, PVOID Buffer, PETHREAD IoIssuerThread)
 
typedef BOOLEAN(__stdcalltCcCopyReadEx) (PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PETHREAD IoIssuerThread)
 
typedef VOID(__stdcalltCcSetAdditionalCacheAttributesEx) (PFILE_OBJECT FileObject, ULONG Flags)
 
typedef VOID(__stdcalltFsRtlUpdateDiskCounters) (ULONG64 BytesRead, ULONG64 BytesWritten)
 
typedef NTSTATUS(__stdcalltIoUnregisterPlugPlayNotificationEx) (PVOID NotificationEntry)
 
typedef NTSTATUS(__stdcalltFsRtlGetEcpListFromIrp) (PIRP Irp, PECP_LIST *EcpList)
 
typedef NTSTATUS(__stdcalltFsRtlGetNextExtraCreateParameter) (PECP_LIST EcpList, PVOID CurrentEcpContext, LPGUID NextEcpType, PVOID *NextEcpContext, ULONG *NextEcpContextSize)
 
typedef NTSTATUS(__stdcalltFsRtlValidateReparsePointBuffer) (ULONG BufferLength, PREPARSE_DATA_BUFFER ReparseBuffer)
 
typedef BOOLEAN(__stdcalltFsRtlCheckLockForOplockRequest) (PFILE_LOCK FileLock, PLARGE_INTEGER AllocationSize)
 
typedef BOOLEAN(__stdcalltFsRtlAreThereCurrentOrInProgressFileLocks) (PFILE_LOCK FileLock)
 
typedef struct _LDR_DATA_TABLE_ENTRY LDR_DATA_TABLE_ENTRY
 
typedef struct _LDR_DATA_TABLE_ENTRYPLDR_DATA_TABLE_ENTRY
 
typedef struct _PEB_LDR_DATA PEB_LDR_DATA
 
typedef struct _PEB_LDR_DATAPPEB_LDR_DATA
 
typedef struct _RTL_USER_PROCESS_PARAMETERS RTL_USER_PROCESS_PARAMETERS
 
typedef struct _RTL_USER_PROCESS_PARAMETERSPRTL_USER_PROCESS_PARAMETERS
 
typedef VOID(NTAPIPPS_POST_PROCESS_INIT_ROUTINE) (VOID)
 
typedef struct _PEB PEB
 
typedef struct _PEBPPEB
 

Enumerations

enum  prop_compression_type { PropCompression_None, PropCompression_Zlib, PropCompression_LZO, PropCompression_ZSTD }
 
enum  batch_operation {
  Batch_Delete, Batch_DeleteInode, Batch_DeleteDirItem, Batch_DeleteInodeRef,
  Batch_DeleteInodeExtRef, Batch_DeleteXattr, Batch_DeleteExtentData, Batch_DeleteFreeSpace,
  Batch_Insert, Batch_SetXattr, Batch_DirItem, Batch_InodeRef,
  Batch_InodeExtRef
}
 
enum  write_data_status {
  WriteDataStatus_Pending, WriteDataStatus_Success, WriteDataStatus_Error, WriteDataStatus_Cancelling,
  WriteDataStatus_Cancelled, WriteDataStatus_Ignore
}
 
enum  rollback_type { ROLLBACK_INSERT_EXTENT, ROLLBACK_DELETE_EXTENT, ROLLBACK_ADD_SPACE, ROLLBACK_SUBTRACT_SPACE }
 

Functions

 _Create_lock_level_ (tree_lock) _Create_lock_level_(fcb_lock) _Lock_level_order_(tree_lock
 
 _Requires_lock_not_held_ (Vcb->fcb_lock) _Acquires_shared_lock_(Vcb -> fcb_lock) static __inline void acquire_fcb_lock_shared(device_extension *Vcb)
 
 _Requires_lock_held_ (Vcb->fcb_lock) _Releases_lock_(Vcb -> fcb_lock) static __inline void release_fcb_lock(device_extension *Vcb)
 
static __inline voidmap_user_buffer (PIRP Irp, ULONG priority)
 
static __inline uint64_t unix_time_to_win (BTRFS_TIME *t)
 
static __inline void win_time_to_unix (LARGE_INTEGER t, BTRFS_TIME *out)
 
_Post_satisfies_ static stripe __inline void get_raid0_offset (_In_ uint64_t off, _In_ uint64_t stripe_length, _In_ uint16_t num_stripes, _Out_ uint64_t *stripeoff, _Out_ uint16_t *stripe)
 
static __inline uint64_t make_file_id (root *r, uint64_t inode)
 
 _Post_satisfies_ (return >=n) __inline static uint64_t sector_align(_In_ uint64_t n
 
static __inline bool is_subvol_readonly (root *r, PIRP Irp)
 
static __inline uint16_t get_extent_data_len (uint8_t type)
 
static __inline uint32_t get_extent_data_refcount (uint8_t type, void *data)
 
_Ret_maybenull_ devicefind_device_from_uuid (_In_ device_extension *Vcb, _In_ BTRFS_UUID *uuid)
 
 _Success_ (return) bool get_file_attributes_from_xattr(_In_reads_bytes_(len) char *val
 
ULONG get_file_attributes (_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_ root *r, _In_ uint64_t inode, _In_ uint8_t type, _In_ bool dotfile, _In_ bool ignore_xa, _In_opt_ PIRP Irp)
 
void free_fcb (_Inout_ fcb *fcb)
 
void free_fileref (_Inout_ file_ref *fr)
 
void protect_superblocks (_Inout_ chunk *c)
 
bool is_top_level (_In_ PIRP Irp)
 
NTSTATUS create_root (_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_ uint64_t id, _Out_ root **rootptr, _In_ bool no_tree, _In_ uint64_t offset, _In_opt_ PIRP Irp)
 
void uninit (_In_ device_extension *Vcb)
 
NTSTATUS dev_ioctl (_In_ PDEVICE_OBJECT DeviceObject, _In_ ULONG ControlCode, _In_reads_bytes_opt_(InputBufferSize) PVOID InputBuffer, _In_ ULONG InputBufferSize, _Out_writes_bytes_opt_(OutputBufferSize) PVOID OutputBuffer, _In_ ULONG OutputBufferSize, _In_ bool Override, _Out_opt_ IO_STATUS_BLOCK *iosb)
 
bool is_file_name_valid (_In_ PUNICODE_STRING us, _In_ bool posix, _In_ bool stream)
 
void send_notification_fileref (_In_ file_ref *fileref, _In_ ULONG filter_match, _In_ ULONG action, _In_opt_ PUNICODE_STRING stream)
 
void queue_notification_fcb (_In_ file_ref *fileref, _In_ ULONG filter_match, _In_ ULONG action, _In_opt_ PUNICODE_STRING stream)
 
void mark_fcb_dirty (_In_ fcb *fcb)
 
void mark_fileref_dirty (_In_ file_ref *fileref)
 
NTSTATUS delete_fileref (_In_ file_ref *fileref, _In_opt_ PFILE_OBJECT FileObject, _In_ bool make_orphan, _In_opt_ PIRP Irp, _In_ LIST_ENTRY *rollback)
 
void chunk_lock_range (_In_ device_extension *Vcb, _In_ chunk *c, _In_ uint64_t start, _In_ uint64_t length)
 
void chunk_unlock_range (_In_ device_extension *Vcb, _In_ chunk *c, _In_ uint64_t start, _In_ uint64_t length)
 
void init_device (_In_ device_extension *Vcb, _Inout_ device *dev, _In_ bool get_nums)
 
void init_file_cache (_In_ PFILE_OBJECT FileObject, _In_ CC_FILE_SIZES *ccfs)
 
NTSTATUS sync_read_phys (_In_ PDEVICE_OBJECT DeviceObject, _In_ PFILE_OBJECT FileObject, _In_ uint64_t StartingOffset, _In_ ULONG Length, _Out_writes_bytes_(Length) PUCHAR Buffer, _In_ bool override)
 
NTSTATUS get_device_pnp_name (_In_ PDEVICE_OBJECT DeviceObject, _Out_ PUNICODE_STRING pnp_name, _Out_ const GUID **guid)
 
void log_device_error (_In_ device_extension *Vcb, _Inout_ device *dev, _In_ int error)
 
NTSTATUS find_chunk_usage (_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_opt_ PIRP Irp)
 
 _Function_class_ (DRIVER_ADD_DEVICE) NTSTATUS __stdcall AddDevice(PDRIVER_OBJECT DriverObject
 
void reap_fcb (fcb *fcb)
 
void reap_fcbs (device_extension *Vcb)
 
void reap_fileref (device_extension *Vcb, file_ref *fr)
 
void reap_filerefs (device_extension *Vcb, file_ref *fr)
 
uint64_t chunk_estimate_phys_size (device_extension *Vcb, chunk *c, uint64_t u)
 
NTSTATUS utf8_to_utf16 (WCHAR *dest, ULONG dest_max, ULONG *dest_len, char *src, ULONG src_len)
 
NTSTATUS utf16_to_utf8 (char *dest, ULONG dest_max, ULONG *dest_len, WCHAR *src, ULONG src_len)
 
uint32_t get_num_of_processors ()
 
_Ret_maybenull_ rootfind_default_subvol (_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_opt_ PIRP Irp)
 
void do_shutdown (PIRP Irp)
 
void init_fast_io_dispatch (FAST_IO_DISPATCH **fiod)
 
uint32_t calc_crc32c (_In_ uint32_t seed, _In_reads_bytes_(msglen) uint8_t *msg, _In_ ULONG msglen)
 
NTSTATUS find_item (_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_ root *r, _Out_ traverse_ptr *tp, _In_ const KEY *searchkey, _In_ bool ignore, _In_opt_ PIRP Irp)
 
NTSTATUS find_item_to_level (device_extension *Vcb, root *r, traverse_ptr *tp, const KEY *searchkey, bool ignore, uint8_t level, PIRP Irp)
 
bool find_next_item (_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, const traverse_ptr *tp, traverse_ptr *next_tp, bool ignore, PIRP Irp)
 
bool find_prev_item (_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, const traverse_ptr *tp, traverse_ptr *prev_tp, PIRP Irp)
 
void free_trees (device_extension *Vcb)
 
NTSTATUS insert_tree_item (_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_ root *r, _In_ uint64_t obj_id, _In_ uint8_t obj_type, _In_ uint64_t offset, _In_reads_bytes_opt_(size) _When_(return >=0, __drv_aliasesMem) void *data, _In_ uint16_t size, _Out_opt_ traverse_ptr *ptp, _In_opt_ PIRP Irp)
 
NTSTATUS delete_tree_item (_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _Inout_ traverse_ptr *tp)
 
void free_tree (tree *t)
 
NTSTATUS load_tree (device_extension *Vcb, uint64_t addr, uint8_t *buf, root *r, tree **pt)
 
NTSTATUS do_load_tree (device_extension *Vcb, tree_holder *th, root *r, tree *t, tree_data *td, PIRP Irp)
 
void clear_rollback (LIST_ENTRY *rollback)
 
void do_rollback (device_extension *Vcb, LIST_ENTRY *rollback)
 
void free_trees_root (device_extension *Vcb, root *r)
 
void add_rollback (_In_ LIST_ENTRY *rollback, _In_ enum rollback_type type, _In_ __drv_aliasesMem void *ptr)
 
NTSTATUS commit_batch_list (_Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, LIST_ENTRY *batchlist, PIRP Irp)
 
void clear_batch_list (device_extension *Vcb, LIST_ENTRY *batchlist)
 
NTSTATUS skip_to_difference (device_extension *Vcb, traverse_ptr *tp, traverse_ptr *tp2, bool *ended1, bool *ended2)
 
NTSTATUS remove_drive_letter (PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath)
 
 _Function_class_ (KSTART_ROUTINE) void __stdcall mountmgr_thread(_In_ void *context)
 
 _Function_class_ (DRIVER_NOTIFICATION_CALLBACK_ROUTINE) NTSTATUS __stdcall pnp_notification(PVOID NotificationStructure
 
void disk_arrival (PDRIVER_OBJECT DriverObject, PUNICODE_STRING devpath)
 
void volume_arrival (PDRIVER_OBJECT DriverObject, PUNICODE_STRING devpath)
 
void volume_removal (PDRIVER_OBJECT DriverObject, PUNICODE_STRING devpath)
 
void remove_volume_child (_Inout_ _Requires_exclusive_lock_held_(_Curr_->child_lock) _Releases_exclusive_lock_(_Curr_->child_lock) _In_ volume_device_extension *vde, _In_ volume_child *vc, _In_ bool skip_dev)
 
void init_cache ()
 
NTSTATUS write_file (device_extension *Vcb, PIRP Irp, bool wait, bool deferred_write)
 
NTSTATUS write_file2 (device_extension *Vcb, PIRP Irp, LARGE_INTEGER offset, void *buf, ULONG *length, bool paging_io, bool no_cache, bool wait, bool deferred_write, bool write_irp, LIST_ENTRY *rollback)
 
NTSTATUS truncate_file (fcb *fcb, uint64_t end, PIRP Irp, LIST_ENTRY *rollback)
 
NTSTATUS extend_file (fcb *fcb, file_ref *fileref, uint64_t end, bool prealloc, PIRP Irp, LIST_ENTRY *rollback)
 
NTSTATUS excise_extents (device_extension *Vcb, fcb *fcb, uint64_t start_data, uint64_t end_data, PIRP Irp, LIST_ENTRY *rollback)
 
chunkget_chunk_from_address (device_extension *Vcb, uint64_t address)
 
NTSTATUS alloc_chunk (device_extension *Vcb, uint64_t flags, chunk **pc, bool full_size)
 
NTSTATUS write_data (_In_ device_extension *Vcb, _In_ uint64_t address, _In_reads_bytes_(length) void *data, _In_ uint32_t length, _In_ write_data_context *wtc, _In_opt_ PIRP Irp, _In_opt_ chunk *c, _In_ bool file_write, _In_ uint64_t irp_offset, _In_ ULONG priority)
 
NTSTATUS write_data_complete (device_extension *Vcb, uint64_t address, void *data, uint32_t length, PIRP Irp, chunk *c, bool file_write, uint64_t irp_offset, ULONG priority)
 
void free_write_data_stripes (write_data_context *wtc)
 
 _Dispatch_type_ (IRP_MJ_WRITE) _Function_class_(DRIVER_DISPATCH) NTSTATUS __stdcall drv_write(IN PDEVICE_OBJECT DeviceObject
 
 _Requires_lock_held_ (c->lock) _When_(return !=0
 
 _Releases_lock_ (c->lock)) bool insert_extent_chunk(_In_ device_extension *Vcb
 
NTSTATUS do_write_file (fcb *fcb, uint64_t start_data, uint64_t end_data, void *data, PIRP Irp, bool file_write, uint32_t irp_offset, LIST_ENTRY *rollback)
 
NTSTATUS write_compressed (fcb *fcb, uint64_t start_data, uint64_t end_data, void *data, PIRP Irp, LIST_ENTRY *rollback)
 
bool find_data_address_in_chunk (device_extension *Vcb, chunk *c, uint64_t length, uint64_t *address)
 
void get_raid56_lock_range (chunk *c, uint64_t address, uint64_t length, uint64_t *lockaddr, uint64_t *locklen)
 
NTSTATUS calc_csum (_In_ device_extension *Vcb, _In_reads_bytes_(sectors *Vcb->superblock.sector_size) uint8_t *data, _In_ uint32_t sectors, _Out_writes_bytes_(sectors *sizeof(uint32_t)) uint32_t *csum)
 
void add_insert_extent_rollback (LIST_ENTRY *rollback, fcb *fcb, extent *ext)
 
NTSTATUS add_extent_to_fcb (_In_ fcb *fcb, _In_ uint64_t offset, _In_reads_bytes_(edsize) EXTENT_DATA *ed, _In_ uint16_t edsize, _In_ bool unique, _In_opt_ _When_(return >=0, __drv_aliasesMem) uint32_t *csum, _In_ LIST_ENTRY *rollback)
 
void add_extent (_In_ fcb *fcb, _In_ LIST_ENTRY *prevextle, _In_ __drv_aliasesMem extent *newext)
 
 _Dispatch_type_ (IRP_MJ_DIRECTORY_CONTROL) _Function_class_(DRIVER_DISPATCH) NTSTATUS __stdcall drv_directory_control(IN PDEVICE_OBJECT DeviceObject
 
ULONG get_reparse_tag (device_extension *Vcb, root *subvol, uint64_t inode, uint8_t type, ULONG atts, bool lxss, PIRP Irp)
 
ULONG get_reparse_tag_fcb (fcb *fcb)
 
 _Dispatch_type_ (IRP_MJ_QUERY_SECURITY) _Function_class_(DRIVER_DISPATCH) NTSTATUS __stdcall drv_query_security(IN PDEVICE_OBJECT DeviceObject
 
 _Dispatch_type_ (IRP_MJ_SET_SECURITY) _Function_class_(DRIVER_DISPATCH) NTSTATUS __stdcall drv_set_security(IN PDEVICE_OBJECT DeviceObject
 
void fcb_get_sd (fcb *fcb, struct _fcb *parent, bool look_for_xattr, PIRP Irp)
 
void add_user_mapping (WCHAR *sidstring, ULONG sidstringlength, uint32_t uid)
 
void add_group_mapping (WCHAR *sidstring, ULONG sidstringlength, uint32_t gid)
 
uint32_t sid_to_uid (PSID sid)
 
NTSTATUS uid_to_sid (uint32_t uid, PSID *sid)
 
NTSTATUS fcb_get_new_sd (fcb *fcb, file_ref *parfileref, ACCESS_STATE *as)
 
void find_gid (struct _fcb *fcb, struct _fcb *parfcb, PSECURITY_SUBJECT_CONTEXT subjcont)
 
 _Dispatch_type_ (IRP_MJ_SET_INFORMATION) _Function_class_(DRIVER_DISPATCH) NTSTATUS __stdcall drv_set_information(IN PDEVICE_OBJECT DeviceObject
 
 _Dispatch_type_ (IRP_MJ_QUERY_INFORMATION) _Function_class_(DRIVER_DISPATCH) NTSTATUS __stdcall drv_query_information(IN PDEVICE_OBJECT DeviceObject
 
 _Dispatch_type_ (IRP_MJ_QUERY_EA) _Function_class_(DRIVER_DISPATCH) NTSTATUS __stdcall drv_query_ea(IN PDEVICE_OBJECT DeviceObject
 
 _Dispatch_type_ (IRP_MJ_SET_EA) _Function_class_(DRIVER_DISPATCH) NTSTATUS __stdcall drv_set_ea(IN PDEVICE_OBJECT DeviceObject
 
bool has_open_children (file_ref *fileref)
 
NTSTATUS stream_set_end_of_file_information (device_extension *Vcb, uint16_t end, fcb *fcb, file_ref *fileref, bool advance_only)
 
NTSTATUS fileref_get_filename (file_ref *fileref, PUNICODE_STRING fn, USHORT *name_offset, ULONG *preqlen)
 
void insert_dir_child_into_hash_lists (fcb *fcb, dir_child *dc)
 
void remove_dir_child_from_hash_lists (fcb *fcb, dir_child *dc)
 
NTSTATUS get_reparse_point (PDEVICE_OBJECT DeviceObject, PFILE_OBJECT FileObject, void *buffer, DWORD buflen, ULONG_PTR *retlen)
 
NTSTATUS set_reparse_point2 (fcb *fcb, REPARSE_DATA_BUFFER *rdb, ULONG buflen, ccb *ccb, file_ref *fileref, PIRP Irp, LIST_ENTRY *rollback)
 
NTSTATUS set_reparse_point (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS delete_reparse_point (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
 _Dispatch_type_ (IRP_MJ_CREATE) _Function_class_(DRIVER_DISPATCH) NTSTATUS __stdcall drv_create(IN PDEVICE_OBJECT DeviceObject
 
NTSTATUS open_fileref (_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lock_held_(_Curr_->fcb_lock) _In_ device_extension *Vcb, _Out_ file_ref **pfr, _In_ PUNICODE_STRING fnus, _In_opt_ file_ref *related, _In_ bool parent, _Out_opt_ USHORT *parsed, _Out_opt_ ULONG *fn_offset, _In_ POOL_TYPE pooltype, _In_ bool case_sensitive, _In_opt_ PIRP Irp)
 
NTSTATUS open_fcb (_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lock_held_(_Curr_->fcb_lock) device_extension *Vcb, root *subvol, uint64_t inode, uint8_t type, PANSI_STRING utf8, bool always_add_hl, fcb *parent, fcb **pfcb, POOL_TYPE pooltype, PIRP Irp)
 
NTSTATUS load_csum (_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, uint32_t *csum, uint64_t start, uint64_t length, PIRP Irp)
 
NTSTATUS load_dir_children (_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, fcb *fcb, bool ignore_size, PIRP Irp)
 
NTSTATUS add_dir_child (fcb *fcb, uint64_t inode, bool subvol, PANSI_STRING utf8, PUNICODE_STRING name, uint8_t type, dir_child **pdc)
 
NTSTATUS open_fileref_child (_Requires_lock_held_(_Curr_->tree_lock) _Requires_exclusive_lock_held_(_Curr_->fcb_lock) _In_ device_extension *Vcb, _In_ file_ref *sf, _In_ PUNICODE_STRING name, _In_ bool case_sensitive, _In_ bool lastpart, _In_ bool streampart, _In_ POOL_TYPE pooltype, _Out_ file_ref **psf2, _In_opt_ PIRP Irp)
 
fcbcreate_fcb (device_extension *Vcb, POOL_TYPE pool_type)
 
NTSTATUS find_file_in_dir (PUNICODE_STRING filename, fcb *fcb, root **subvol, uint64_t *inode, dir_child **pdc, bool case_sensitive)
 
uint32_t inherit_mode (fcb *parfcb, bool is_dir)
 
file_refcreate_fileref (device_extension *Vcb)
 
NTSTATUS open_fileref_by_inode (_Requires_exclusive_lock_held_(_Curr_->fcb_lock) device_extension *Vcb, root *subvol, uint64_t inode, file_ref **pfr, PIRP Irp)
 
NTSTATUS fsctl_request (PDEVICE_OBJECT DeviceObject, PIRP *Pirp, uint32_t type)
 
void do_unlock_volume (device_extension *Vcb)
 
void trim_whole_device (device *dev)
 
void flush_subvol_fcbs (root *subvol)
 
bool fcb_is_inline (fcb *fcb)
 
NTSTATUS dismount_volume (device_extension *Vcb, bool shutdown, PIRP Irp)
 
NTSTATUS do_write (device_extension *Vcb, PIRP Irp)
 
NTSTATUS get_tree_new_address (device_extension *Vcb, tree *t, PIRP Irp, LIST_ENTRY *rollback)
 
NTSTATUS flush_fcb (fcb *fcb, bool cache, LIST_ENTRY *batchlist, PIRP Irp)
 
NTSTATUS write_data_phys (_In_ PDEVICE_OBJECT device, _In_ PFILE_OBJECT fileobj, _In_ uint64_t address, _In_reads_bytes_(length) void *data, _In_ uint32_t length)
 
bool is_tree_unique (device_extension *Vcb, tree *t, PIRP Irp)
 
NTSTATUS do_tree_writes (device_extension *Vcb, LIST_ENTRY *tree_writes, bool no_free)
 
void add_checksum_entry (device_extension *Vcb, uint64_t address, ULONG length, uint32_t *csum, PIRP Irp)
 
bool find_metadata_address_in_chunk (device_extension *Vcb, chunk *c, uint64_t *address)
 
void add_trim_entry_avoid_sb (device_extension *Vcb, device *dev, uint64_t address, uint64_t size)
 
NTSTATUS insert_tree_item_batch (LIST_ENTRY *batchlist, device_extension *Vcb, root *r, uint64_t objid, uint8_t objtype, uint64_t offset, _In_opt_ _When_(return >=0, __drv_aliasesMem) void *data, uint16_t datalen, enum batch_operation operation)
 
NTSTATUS flush_partial_stripe (device_extension *Vcb, chunk *c, partial_stripe *ps)
 
NTSTATUS update_dev_item (device_extension *Vcb, device *device, PIRP Irp)
 
 _Dispatch_type_ (IRP_MJ_READ) _Function_class_(DRIVER_DISPATCH) NTSTATUS __stdcall drv_read(PDEVICE_OBJECT DeviceObject
 
NTSTATUS read_data (_In_ device_extension *Vcb, _In_ uint64_t addr, _In_ uint32_t length, _In_reads_bytes_opt_(length *sizeof(uint32_t)/Vcb->superblock.sector_size) uint32_t *csum, _In_ bool is_tree, _Out_writes_bytes_(length) uint8_t *buf, _In_opt_ chunk *c, _Out_opt_ chunk **pc, _In_opt_ PIRP Irp, _In_ uint64_t generation, _In_ bool file_read, _In_ ULONG priority)
 
NTSTATUS read_file (fcb *fcb, uint8_t *data, uint64_t start, uint64_t length, ULONG *pbr, PIRP Irp)
 
NTSTATUS read_stream (fcb *fcb, uint8_t *data, uint64_t start, ULONG length, ULONG *pbr)
 
NTSTATUS do_read (PIRP Irp, bool wait, ULONG *bytes_read)
 
NTSTATUS check_csum (device_extension *Vcb, uint8_t *data, uint32_t sectors, uint32_t *csum)
 
void raid6_recover2 (uint8_t *sectors, uint16_t num_stripes, ULONG sector_size, uint16_t missing1, uint16_t missing2, uint8_t *out)
 
 _Dispatch_type_ (IRP_MJ_PNP) _Function_class_(DRIVER_DISPATCH) NTSTATUS __stdcall drv_pnp(PDEVICE_OBJECT DeviceObject
 
NTSTATUS pnp_surprise_removal (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS pnp_query_remove_device (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS load_cache_chunk (device_extension *Vcb, chunk *c, PIRP Irp)
 
NTSTATUS clear_free_space_cache (device_extension *Vcb, LIST_ENTRY *batchlist, PIRP Irp)
 
NTSTATUS allocate_cache (device_extension *Vcb, bool *changed, PIRP Irp, LIST_ENTRY *rollback)
 
NTSTATUS update_chunk_caches (device_extension *Vcb, PIRP Irp, LIST_ENTRY *rollback)
 
NTSTATUS update_chunk_caches_tree (device_extension *Vcb, PIRP Irp)
 
NTSTATUS add_space_entry (LIST_ENTRY *list, LIST_ENTRY *list_size, uint64_t offset, uint64_t size)
 
void space_list_add (chunk *c, uint64_t address, uint64_t length, LIST_ENTRY *rollback)
 
void space_list_add2 (LIST_ENTRY *list, LIST_ENTRY *list_size, uint64_t address, uint64_t length, chunk *c, LIST_ENTRY *rollback)
 
void space_list_subtract (chunk *c, bool deleting, uint64_t address, uint64_t length, LIST_ENTRY *rollback)
 
void space_list_subtract2 (LIST_ENTRY *list, LIST_ENTRY *list_size, uint64_t address, uint64_t length, chunk *c, LIST_ENTRY *rollback)
 
NTSTATUS load_stored_free_space_cache (device_extension *Vcb, chunk *c, bool load_only, PIRP Irp)
 
NTSTATUS increase_extent_refcount_data (device_extension *Vcb, uint64_t address, uint64_t size, uint64_t root, uint64_t inode, uint64_t offset, uint32_t refcount, PIRP Irp)
 
NTSTATUS decrease_extent_refcount_data (device_extension *Vcb, uint64_t address, uint64_t size, uint64_t root, uint64_t inode, uint64_t offset, uint32_t refcount, bool superseded, PIRP Irp)
 
NTSTATUS decrease_extent_refcount_tree (device_extension *Vcb, uint64_t address, uint64_t size, uint64_t root, uint8_t level, PIRP Irp)
 
uint64_t get_extent_refcount (device_extension *Vcb, uint64_t address, uint64_t size, PIRP Irp)
 
bool is_extent_unique (device_extension *Vcb, uint64_t address, uint64_t size, PIRP Irp)
 
NTSTATUS increase_extent_refcount (device_extension *Vcb, uint64_t address, uint64_t size, uint8_t type, void *data, KEY *firstitem, uint8_t level, PIRP Irp)
 
uint64_t get_extent_flags (device_extension *Vcb, uint64_t address, PIRP Irp)
 
void update_extent_flags (device_extension *Vcb, uint64_t address, uint64_t flags, PIRP Irp)
 
NTSTATUS update_changed_extent_ref (device_extension *Vcb, chunk *c, uint64_t address, uint64_t size, uint64_t root, uint64_t objid, uint64_t offset, int32_t count, bool no_csum, bool superseded, PIRP Irp)
 
void add_changed_extent_ref (chunk *c, uint64_t address, uint64_t size, uint64_t root, uint64_t objid, uint64_t offset, uint32_t count, bool no_csum)
 
uint64_t find_extent_shared_tree_refcount (device_extension *Vcb, uint64_t address, uint64_t parent, PIRP Irp)
 
uint32_t find_extent_shared_data_refcount (device_extension *Vcb, uint64_t address, uint64_t parent, PIRP Irp)
 
NTSTATUS decrease_extent_refcount (device_extension *Vcb, uint64_t address, uint64_t size, uint8_t type, void *data, KEY *firstitem, uint8_t level, uint64_t parent, bool superseded, PIRP Irp)
 
uint64_t get_extent_data_ref_hash2 (uint64_t root, uint64_t objid, uint64_t offset)
 
NTSTATUS do_read_job (PIRP Irp)
 
NTSTATUS do_write_job (device_extension *Vcb, PIRP Irp)
 
bool add_thread_job (device_extension *Vcb, PIRP Irp)
 
void read_registry (PUNICODE_STRING regpath, bool refresh)
 
NTSTATUS registry_mark_volume_mounted (BTRFS_UUID *uuid)
 
NTSTATUS registry_mark_volume_unmounted (BTRFS_UUID *uuid)
 
NTSTATUS registry_load_volume_options (device_extension *Vcb)
 
void watch_registry (HANDLE regh)
 
NTSTATUS zlib_decompress (uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen)
 
NTSTATUS lzo_decompress (uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, uint32_t inpageoff)
 
NTSTATUS zstd_decompress (uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen)
 
NTSTATUS write_compressed_bit (fcb *fcb, uint64_t start_data, uint64_t end_data, void *data, bool *compressed, PIRP Irp, LIST_ENTRY *rollback)
 
void galois_double (uint8_t *data, uint32_t len)
 
void galois_divpower (uint8_t *data, uint8_t div, uint32_t readlen)
 
uint8_t gpow2 (uint8_t e)
 
uint8_t gmul (uint8_t a, uint8_t b)
 
uint8_t gdiv (uint8_t a, uint8_t b)
 
 _Dispatch_type_ (IRP_MJ_DEVICE_CONTROL) _Function_class_(DRIVER_DISPATCH) NTSTATUS __stdcall drv_device_control(IN PDEVICE_OBJECT DeviceObject
 
NTSTATUS add_calc_job (device_extension *Vcb, uint8_t *data, uint32_t sectors, uint32_t *csum, calc_job **pcj)
 
void free_calc_job (calc_job *cj)
 
NTSTATUS start_balance (device_extension *Vcb, void *data, ULONG length, KPROCESSOR_MODE processor_mode)
 
NTSTATUS query_balance (device_extension *Vcb, void *data, ULONG length)
 
NTSTATUS pause_balance (device_extension *Vcb, KPROCESSOR_MODE processor_mode)
 
NTSTATUS resume_balance (device_extension *Vcb, KPROCESSOR_MODE processor_mode)
 
NTSTATUS stop_balance (device_extension *Vcb, KPROCESSOR_MODE processor_mode)
 
NTSTATUS look_for_balance_item (_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb)
 
NTSTATUS remove_device (device_extension *Vcb, void *data, ULONG length, KPROCESSOR_MODE processor_mode)
 
NTSTATUS vol_create (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_close (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_read (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_write (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_query_information (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_set_information (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_query_ea (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_set_ea (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_flush_buffers (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_query_volume_information (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_set_volume_information (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_cleanup (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_directory_control (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_file_system_control (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_lock_control (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_device_control (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_shutdown (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_query_security (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_set_security (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
void add_volume_device (superblock *sb, PUNICODE_STRING devpath, uint64_t length, ULONG disk_num, ULONG part_num)
 
NTSTATUS mountmgr_add_drive_letter (PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath)
 
void free_vol (volume_device_extension *vde)
 
NTSTATUS start_scrub (device_extension *Vcb, KPROCESSOR_MODE processor_mode)
 
NTSTATUS query_scrub (device_extension *Vcb, KPROCESSOR_MODE processor_mode, void *data, ULONG length)
 
NTSTATUS pause_scrub (device_extension *Vcb, KPROCESSOR_MODE processor_mode)
 
NTSTATUS resume_scrub (device_extension *Vcb, KPROCESSOR_MODE processor_mode)
 
NTSTATUS stop_scrub (device_extension *Vcb, KPROCESSOR_MODE processor_mode)
 
NTSTATUS send_subvol (device_extension *Vcb, void *data, ULONG datalen, PFILE_OBJECT FileObject, PIRP Irp)
 
NTSTATUS read_send_buffer (device_extension *Vcb, PFILE_OBJECT FileObject, void *data, ULONG datalen, ULONG_PTR *retlen, KPROCESSOR_MODE processor_mode)
 
NTSTATUS __stdcall compat_FsRtlValidateReparsePointBuffer (IN ULONG BufferLength, IN PREPARSE_DATA_BUFFER ReparseBuffer)
 
void __stdcall check_system_root (PDRIVER_OBJECT DriverObject, PVOID Context, ULONG Count)
 
static __inline POPLOCK fcb_oplock (fcb *fcb)
 
static __inline FAST_IO_POSSIBLE fast_io_possible (fcb *fcb)
 
static __inline void print_open_trees (device_extension *Vcb)
 
static __inline bool write_fcb_compressed (fcb *fcb)
 
static __inline void do_xor (uint8_t *buf1, uint8_t *buf2, uint32_t len)
 
static __inline uint64_t fcb_alloc_size (fcb *fcb)
 
PEPROCESS __stdcall PsGetThreadProcess (_In_ PETHREAD Thread)
 

Variables

_In_ uint64_t a
 
return n
 
_In_ uint16_t len
 
_In_ uint16_t _Out_ ULONGatts
 
PDEVICE_OBJECT PhysicalDeviceObject
 
bool have_sse2
 
uint32_t mount_compress
 
uint32_t mount_compress_force
 
uint32_t mount_compress_type
 
uint32_t mount_zlib_level
 
uint32_t mount_zstd_level
 
uint32_t mount_flush_interval
 
uint32_t mount_max_inline
 
uint32_t mount_skip_balance
 
uint32_t mount_no_barrier
 
uint32_t mount_no_trim
 
uint32_t mount_clear_cache
 
uint32_t mount_allow_degraded
 
uint32_t mount_readonly
 
uint32_t mount_no_root_dir
 
uint32_t no_pnp
 
static const char lxuid [] = "$LXUID"
 
static const char lxgid [] = "$LXGID"
 
static const char lxmod [] = "$LXMOD"
 
static const char lxdev [] = "$LXDEV"
 
PVOID Context
 
CACHE_MANAGER_CALLBACKS cache_callbacks
 
IN PIRP Irp
 
_In_ fcb _In_ chunkc
 
_In_ fcb _In_ chunk _In_ uint64_t start_data
 
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t length
 
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool prealloc
 
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ voiddata
 
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRYrollback
 
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t compression = compression
 
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t _In_ uint64_t decoded_size = decoded_size
 
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t _In_ uint64_t _In_ bool file_write
 
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY _In_ uint8_t _In_ uint64_t _In_ bool _In_ uint64_t irp_offset
 

Macro Definition Documentation

◆ __drv_aliasesMem

#define __drv_aliasesMem

Definition at line 189 of file btrfs_drv.h.

◆ __S_IFBLK

#define __S_IFBLK   0060000 /* Block device. */

Definition at line 1733 of file btrfs_drv.h.

◆ __S_IFCHR

#define __S_IFCHR   0020000 /* Character device. */

Definition at line 1732 of file btrfs_drv.h.

◆ __S_IFDIR

#define __S_IFDIR   0040000 /* Directory. */

Definition at line 1731 of file btrfs_drv.h.

◆ __S_IFIFO

#define __S_IFIFO   0010000 /* FIFO. */

Definition at line 1735 of file btrfs_drv.h.

◆ __S_IFLNK

#define __S_IFLNK   0120000 /* Symbolic link. */

Definition at line 1736 of file btrfs_drv.h.

◆ __S_IFMT

#define __S_IFMT   0170000 /* These bits determine file type. */

Definition at line 1730 of file btrfs_drv.h.

◆ __S_IFREG

#define __S_IFREG   0100000 /* Regular file. */

Definition at line 1734 of file btrfs_drv.h.

◆ __S_IFSOCK

#define __S_IFSOCK   0140000 /* Socket. */

Definition at line 1737 of file btrfs_drv.h.

◆ __S_ISTYPE

#define __S_ISTYPE (   mode,
  mask 
)    (((mode) & __S_IFMT) == (mask))

Definition at line 1738 of file btrfs_drv.h.

◆ _Acquires_exclusive_lock_

#define _Acquires_exclusive_lock_ (   a)

Definition at line 202 of file btrfs_drv.h.

◆ _Acquires_shared_lock_

#define _Acquires_shared_lock_ (   a)

Definition at line 203 of file btrfs_drv.h.

◆ _Create_lock_level_

#define _Create_lock_level_ (   a)

Definition at line 198 of file btrfs_drv.h.

◆ _CRT_SECURE_NO_WARNINGS

#define _CRT_SECURE_NO_WARNINGS

Definition at line 26 of file btrfs_drv.h.

◆ _Dispatch_type_

#define _Dispatch_type_ (   a)

Definition at line 197 of file btrfs_drv.h.

◆ _Has_lock_level_

#define _Has_lock_level_ (   a)

Definition at line 200 of file btrfs_drv.h.

◆ _Lock_level_order_

#define _Lock_level_order_ (   a,
  b 
)

Definition at line 199 of file btrfs_drv.h.

◆ _NO_CRT_STDIO_INLINE

#define _NO_CRT_STDIO_INLINE

Definition at line 27 of file btrfs_drv.h.

◆ _Out_writes_bytes_opt_

#define _Out_writes_bytes_opt_ (   a)

Definition at line 193 of file btrfs_drv.h.

◆ _Post_satisfies_

#define _Post_satisfies_ (   a)

Definition at line 195 of file btrfs_drv.h.

◆ _Pre_satisfies_

#define _Pre_satisfies_ (   a)

Definition at line 194 of file btrfs_drv.h.

◆ _Releases_exclusive_lock_

#define _Releases_exclusive_lock_ (   a)

Definition at line 196 of file btrfs_drv.h.

◆ _Releases_lock_

#define _Releases_lock_ (   a)

Definition at line 192 of file btrfs_drv.h.

◆ _Requires_exclusive_lock_held_

#define _Requires_exclusive_lock_held_ (   a)

Definition at line 191 of file btrfs_drv.h.

◆ _Requires_lock_held_

#define _Requires_lock_held_ (   a)

Definition at line 190 of file btrfs_drv.h.

◆ _Requires_lock_not_held_

#define _Requires_lock_not_held_ (   a)

Definition at line 201 of file btrfs_drv.h.

◆ _WIN32_WINNT

#define _WIN32_WINNT   0x0601

Definition at line 24 of file btrfs_drv.h.

◆ acquire_chunk_lock

#define acquire_chunk_lock (   c,
  Vcb 
)    ExAcquireResourceExclusiveLite(&(c)->lock, true)

Definition at line 1104 of file btrfs_drv.h.

◆ ALLOC_TAG

#define ALLOC_TAG   0x7442484D

Definition at line 91 of file btrfs_drv.h.

◆ ALLOC_TAG_ZLIB

#define ALLOC_TAG_ZLIB   0x7A42484D

Definition at line 92 of file btrfs_drv.h.

◆ BALANCE_OPTS_DATA

#define BALANCE_OPTS_DATA   0

Definition at line 670 of file btrfs_drv.h.

◆ BALANCE_OPTS_METADATA

#define BALANCE_OPTS_METADATA   1

Definition at line 671 of file btrfs_drv.h.

◆ BALANCE_OPTS_SYSTEM

#define BALANCE_OPTS_SYSTEM   2

Definition at line 672 of file btrfs_drv.h.

◆ BTRFS_NODE_TYPE_CCB

#define BTRFS_NODE_TYPE_CCB   0x2295

Definition at line 88 of file btrfs_drv.h.

◆ BTRFS_NODE_TYPE_FCB

#define BTRFS_NODE_TYPE_FCB   0x2296

Definition at line 89 of file btrfs_drv.h.

◆ BTRFS_VOLUME_PREFIX

#define BTRFS_VOLUME_PREFIX   L"\\Device\\Btrfs{"

Definition at line 127 of file btrfs_drv.h.

◆ CC_ENABLE_DISK_IO_ACCOUNTING

#define CC_ENABLE_DISK_IO_ACCOUNTING   0x00000010

Definition at line 1822 of file btrfs_drv.h.

◆ COMPRESSED_EXTENT_SIZE

#define COMPRESSED_EXTENT_SIZE   0x20000

Definition at line 116 of file btrfs_drv.h.

◆ EA_CASE_SENSITIVE

#define EA_CASE_SENSITIVE   "user.casesensitive"

Definition at line 109 of file btrfs_drv.h.

◆ EA_CASE_SENSITIVE_HASH

#define EA_CASE_SENSITIVE_HASH   0x1a9d97d4

Definition at line 110 of file btrfs_drv.h.

◆ EA_DOSATTRIB

#define EA_DOSATTRIB   "user.DOSATTRIB"

Definition at line 100 of file btrfs_drv.h.

◆ EA_DOSATTRIB_HASH

#define EA_DOSATTRIB_HASH   0x914f9939

Definition at line 101 of file btrfs_drv.h.

◆ EA_EA

#define EA_EA   "user.EA"

Definition at line 106 of file btrfs_drv.h.

◆ EA_EA_HASH

#define EA_EA_HASH   0x8270dd43

Definition at line 107 of file btrfs_drv.h.

◆ EA_NTACL

#define EA_NTACL   "security.NTACL"

Definition at line 97 of file btrfs_drv.h.

◆ EA_NTACL_HASH

#define EA_NTACL_HASH   0x45922146

Definition at line 98 of file btrfs_drv.h.

◆ EA_PROP_COMPRESSION

#define EA_PROP_COMPRESSION   "btrfs.compression"

Definition at line 112 of file btrfs_drv.h.

◆ EA_PROP_COMPRESSION_HASH

#define EA_PROP_COMPRESSION_HASH   0x20ccdf69

Definition at line 113 of file btrfs_drv.h.

◆ EA_REPARSE

#define EA_REPARSE   "user.reparse"

Definition at line 103 of file btrfs_drv.h.

◆ EA_REPARSE_HASH

#define EA_REPARSE_HASH   0xfabad1fe

Definition at line 104 of file btrfs_drv.h.

◆ ERR

#define ERR (   s,
  ... 
)    DbgPrint("Btrfs ERR : %s : " s, funcname, ##__VA_ARGS__)

Definition at line 1196 of file btrfs_drv.h.

◆ except

#define except (   x)    if (0 && (x))

Definition at line 135 of file btrfs_drv.h.

◆ FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL

#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL   0x00020000

Definition at line 154 of file btrfs_drv.h.

◆ FILE_SUPPORTS_BLOCK_REFCOUNTING

#define FILE_SUPPORTS_BLOCK_REFCOUNTING   0x08000000

Definition at line 146 of file btrfs_drv.h.

◆ FILE_SUPPORTS_POSIX_UNLINK_RENAME

#define FILE_SUPPORTS_POSIX_UNLINK_RENAME   0x00000400

Definition at line 150 of file btrfs_drv.h.

◆ finally

#define finally   if (1)

Definition at line 136 of file btrfs_drv.h.

◆ FIXME

#define FIXME (   s,
  ... 
)    DbgPrint("Btrfs FIXME : %s : " s, funcname, ##__VA_ARGS__)

Definition at line 1195 of file btrfs_drv.h.

◆ FSCTL_DUPLICATE_EXTENTS_TO_FILE

#define FSCTL_DUPLICATE_EXTENTS_TO_FILE   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 209, METHOD_BUFFERED, FILE_WRITE_ACCESS)

Definition at line 168 of file btrfs_drv.h.

◆ FSCTL_GET_INTEGRITY_INFORMATION

#define FSCTL_GET_INTEGRITY_INFORMATION   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, FILE_ANY_ACCESS)

Definition at line 184 of file btrfs_drv.h.

◆ FSCTL_SET_INTEGRITY_INFORMATION

#define FSCTL_SET_INTEGRITY_INFORMATION   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)

Definition at line 185 of file btrfs_drv.h.

◆ FSRTL_FCB_HEADER_V2

#define FSRTL_FCB_HEADER_V2   2

Definition at line 1607 of file btrfs_drv.h.

◆ funcname

#define funcname   __func__

Definition at line 1141 of file btrfs_drv.h.

◆ GID_NOBODY

#define GID_NOBODY   65534

Definition at line 95 of file btrfs_drv.h.

◆ hex_digit

#define hex_digit (   c)    ((c) <= 9) ? ((c) + '0') : ((c) - 10 + 'a')

Definition at line 1725 of file btrfs_drv.h.

◆ increase_fileref_refcount

#define increase_fileref_refcount (   fileref)    InterlockedIncrement(&fileref->refcount)

Definition at line 1716 of file btrfs_drv.h.

◆ int3

#define int3   asm("int3;")

Definition at line 1722 of file btrfs_drv.h.

◆ IO_REPARSE_TAG_LXSS_BLOCKDEV

#define IO_REPARSE_TAG_LXSS_BLOCKDEV   0x80000026

Definition at line 125 of file btrfs_drv.h.

◆ IO_REPARSE_TAG_LXSS_CHARDEV

#define IO_REPARSE_TAG_LXSS_CHARDEV   0x80000025

Definition at line 124 of file btrfs_drv.h.

◆ IO_REPARSE_TAG_LXSS_FIFO

#define IO_REPARSE_TAG_LXSS_FIFO   0x80000024

Definition at line 123 of file btrfs_drv.h.

◆ IO_REPARSE_TAG_LXSS_SOCKET

#define IO_REPARSE_TAG_LXSS_SOCKET   0x80000023

Definition at line 122 of file btrfs_drv.h.

◆ IO_REPARSE_TAG_LXSS_SYMLINK

#define IO_REPARSE_TAG_LXSS_SYMLINK   0xa000001d

Definition at line 120 of file btrfs_drv.h.

◆ keycmp

#define keycmp (   key1,
  key2 
)
Value:
((key1.obj_id < key2.obj_id) ? -1 :\
((key1.obj_id > key2.obj_id) ? 1 :\
((key1.obj_type < key2.obj_type) ? -1 :\
((key1.obj_type > key2.obj_type) ? 1 :\
((key1.offset < key2.offset) ? -1 :\
((key1.offset > key2.offset) ? 1 :\
0))))))
GLuint64EXT GLuint GLuint GLenum GLenum GLuint GLuint GLenum GLuint GLuint key1
Definition: glext.h:10608

Definition at line 991 of file btrfs_drv.h.

◆ major

#define major (   rdev)    ((((rdev) >> 8) & 0xFFF) | ((uint32_t)((rdev) >> 32) & ~0xFFF))

Definition at line 1798 of file btrfs_drv.h.

◆ makedev

#define makedev (   major,
  minor 
)    (((minor) & 0xFF) | (((major) & 0xFFF) << 8) | (((uint64_t)((minor) & ~0xFF)) << 12) | (((uint64_t)((major) & ~0xFFF)) << 32))

Definition at line 1589 of file btrfs_drv.h.

◆ MAX_EXTENT_SIZE

#define MAX_EXTENT_SIZE   0x8000000

Definition at line 115 of file btrfs_drv.h.

◆ minor

#define minor (   rdev)    (((rdev) & 0xFF) | ((uint32_t)((rdev) >> 12) & ~0xFF))

Definition at line 1799 of file btrfs_drv.h.

◆ NTDDI_VERSION

#define NTDDI_VERSION   0x06020000

Definition at line 25 of file btrfs_drv.h.

◆ READ_AHEAD_GRANULARITY

#define READ_AHEAD_GRANULARITY   COMPRESSED_EXTENT_SIZE

Definition at line 118 of file btrfs_drv.h.

◆ release_chunk_lock

#define release_chunk_lock (   c,
  Vcb 
)    ExReleaseResourceLite(&(c)->lock)

Definition at line 1105 of file btrfs_drv.h.

◆ S_IRGRP

#define S_IRGRP   (S_IRUSR >> 3)

Definition at line 1762 of file btrfs_drv.h.

◆ S_IROTH

#define S_IROTH   (S_IRGRP >> 3)

Definition at line 1774 of file btrfs_drv.h.

◆ S_IRUSR

#define S_IRUSR   0000400

Definition at line 1745 of file btrfs_drv.h.

◆ S_ISDIR

#define S_ISDIR (   mode)    __S_ISTYPE((mode), __S_IFDIR)

Definition at line 1741 of file btrfs_drv.h.

◆ S_ISGID

#define S_ISGID   0002000

Definition at line 1790 of file btrfs_drv.h.

◆ S_ISUID

#define S_ISUID   0004000

Definition at line 1786 of file btrfs_drv.h.

◆ S_ISVTX

#define S_ISVTX   0001000

Definition at line 1794 of file btrfs_drv.h.

◆ S_IWGRP

#define S_IWGRP   (S_IWUSR >> 3)

Definition at line 1766 of file btrfs_drv.h.

◆ S_IWOTH

#define S_IWOTH   (S_IWGRP >> 3)

Definition at line 1778 of file btrfs_drv.h.

◆ S_IWUSR

#define S_IWUSR   0000200

Definition at line 1749 of file btrfs_drv.h.

◆ S_IXGRP

#define S_IXGRP   (S_IXUSR >> 3)

Definition at line 1770 of file btrfs_drv.h.

◆ S_IXOTH

#define S_IXOTH   (S_IXGRP >> 3)

Definition at line 1782 of file btrfs_drv.h.

◆ S_IXUSR

#define S_IXUSR   0000100

Definition at line 1753 of file btrfs_drv.h.

◆ TRACE

#define TRACE (   s,
  ... 
)

Definition at line 1193 of file btrfs_drv.h.

◆ try

#define try   if (1)

Definition at line 134 of file btrfs_drv.h.

◆ UID_NOBODY

#define UID_NOBODY   65534

Definition at line 94 of file btrfs_drv.h.

◆ UNUSED

#define UNUSED (   x)    (void)(x)

Definition at line 86 of file btrfs_drv.h.

◆ VCB_TYPE_BUS

#define VCB_TYPE_BUS   5

Definition at line 668 of file btrfs_drv.h.

◆ VCB_TYPE_CONTROL

#define VCB_TYPE_CONTROL   2

Definition at line 665 of file btrfs_drv.h.

◆ VCB_TYPE_FS

#define VCB_TYPE_FS   1

Definition at line 664 of file btrfs_drv.h.

◆ VCB_TYPE_PDO

#define VCB_TYPE_PDO   4

Definition at line 667 of file btrfs_drv.h.

◆ VCB_TYPE_VOLUME

#define VCB_TYPE_VOLUME   3

Definition at line 666 of file btrfs_drv.h.

◆ WARN

#define WARN (   s,
  ... 
)

Definition at line 1194 of file btrfs_drv.h.

Typedef Documentation

◆ ccb

typedef struct _ccb ccb

◆ device_extension

◆ DUPLICATE_EXTENTS_DATA

◆ fcb

Definition at line 1314 of file btrfs_drv.h.

◆ fcb_nonpaged

◆ FILE_ID_128

◆ file_ref

◆ FSCTL_GET_INTEGRITY_INFORMATION_BUFFER

◆ FSCTL_SET_INTEGRITY_INFORMATION_BUFFER

◆ LDR_DATA_TABLE_ENTRY

◆ pdo_device_extension

◆ PDUPLICATE_EXTENTS_DATA

◆ PEB

typedef struct _PEB PEB

◆ PEB_LDR_DATA

◆ PFILE_ID_128

◆ PFSCTL_GET_INTEGRITY_INFORMATION_BUFFER

◆ PFSCTL_SET_INTEGRITY_INFORMATION_BUFFER

◆ PLDR_DATA_TABLE_ENTRY

◆ PPEB

typedef struct _PEB* PPEB

◆ PPEB_LDR_DATA

◆ PPS_POST_PROCESS_INIT_ROUTINE

typedef VOID(NTAPI * PPS_POST_PROCESS_INIT_ROUTINE) (VOID)

Definition at line 1882 of file btrfs_drv.h.

◆ PRTL_USER_PROCESS_PARAMETERS

◆ root

typedef struct _root root

◆ root_cache

◆ RTL_USER_PROCESS_PARAMETERS

◆ tCcCopyReadEx

◆ tCcCopyWriteEx

Definition at line 1815 of file btrfs_drv.h.

◆ tCcSetAdditionalCacheAttributesEx

typedef VOID(__stdcall * tCcSetAdditionalCacheAttributesEx) (PFILE_OBJECT FileObject, ULONG Flags)

Definition at line 1830 of file btrfs_drv.h.

◆ tFsRtlAreThereCurrentOrInProgressFileLocks

typedef BOOLEAN(__stdcall * tFsRtlAreThereCurrentOrInProgressFileLocks) (PFILE_LOCK FileLock)

Definition at line 1845 of file btrfs_drv.h.

◆ tFsRtlCheckLockForOplockRequest

typedef BOOLEAN(__stdcall * tFsRtlCheckLockForOplockRequest) (PFILE_LOCK FileLock, PLARGE_INTEGER AllocationSize)

Definition at line 1843 of file btrfs_drv.h.

◆ tFsRtlGetEcpListFromIrp

typedef NTSTATUS(__stdcall * tFsRtlGetEcpListFromIrp) (PIRP Irp, PECP_LIST *EcpList)

Definition at line 1836 of file btrfs_drv.h.

◆ tFsRtlGetNextExtraCreateParameter

Definition at line 1838 of file btrfs_drv.h.

◆ tFsRtlUpdateDiskCounters

typedef VOID(__stdcall * tFsRtlUpdateDiskCounters) (ULONG64 BytesRead, ULONG64 BytesWritten)

Definition at line 1832 of file btrfs_drv.h.

◆ tFsRtlValidateReparsePointBuffer

typedef NTSTATUS(__stdcall * tFsRtlValidateReparsePointBuffer) (ULONG BufferLength, PREPARSE_DATA_BUFFER ReparseBuffer)

Definition at line 1841 of file btrfs_drv.h.

◆ tIoUnregisterPlugPlayNotificationEx

typedef NTSTATUS(__stdcall * tIoUnregisterPlugPlayNotificationEx) (PVOID NotificationEntry)

Definition at line 1834 of file btrfs_drv.h.

◆ tPsIsDiskCountersEnabled

typedef BOOLEAN(__stdcall * tPsIsDiskCountersEnabled) ()

Definition at line 1810 of file btrfs_drv.h.

◆ tPsUpdateDiskCounters

typedef VOID(__stdcall * tPsUpdateDiskCounters) (PEPROCESS Process, ULONG64 BytesRead, ULONG64 BytesWritten, ULONG ReadOperationCount, ULONG WriteOperationCount, ULONG FlushOperationCount)

Definition at line 1812 of file btrfs_drv.h.

◆ tree

typedef struct _tree tree

◆ tree_data

◆ volume_device_extension

◆ write_data_context

Enumeration Type Documentation

◆ batch_operation

Enumerator
Batch_Delete 
Batch_DeleteInode 
Batch_DeleteDirItem 
Batch_DeleteInodeRef 
Batch_DeleteInodeExtRef 
Batch_DeleteXattr 
Batch_DeleteExtentData 
Batch_DeleteFreeSpace 
Batch_Insert 
Batch_SetXattr 
Batch_DirItem 
Batch_InodeRef 
Batch_InodeExtRef 

Definition at line 470 of file btrfs_drv.h.

◆ prop_compression_type

Enumerator
PropCompression_None 
PropCompression_Zlib 
PropCompression_LZO 
PropCompression_ZSTD 

Definition at line 263 of file btrfs_drv.h.

◆ rollback_type

Enumerator
ROLLBACK_INSERT_EXTENT 
ROLLBACK_DELETE_EXTENT 
ROLLBACK_ADD_SPACE 
ROLLBACK_SUBTRACT_SPACE 

Definition at line 1224 of file btrfs_drv.h.

◆ write_data_status

Enumerator
WriteDataStatus_Pending 
WriteDataStatus_Success 
WriteDataStatus_Error 
WriteDataStatus_Cancelling 
WriteDataStatus_Cancelled 
WriteDataStatus_Ignore 

Definition at line 889 of file btrfs_drv.h.

Function Documentation

◆ _Create_lock_level_()

_Create_lock_level_ ( tree_lock  )

◆ _Dispatch_type_() [1/12]

_Dispatch_type_ ( IRP_MJ_WRITE  )

◆ _Dispatch_type_() [2/12]

_Dispatch_type_ ( IRP_MJ_DIRECTORY_CONTROL  )

◆ _Dispatch_type_() [3/12]

_Dispatch_type_ ( IRP_MJ_QUERY_SECURITY  )

◆ _Dispatch_type_() [4/12]

_Dispatch_type_ ( IRP_MJ_SET_SECURITY  )

◆ _Dispatch_type_() [5/12]

_Dispatch_type_ ( IRP_MJ_SET_INFORMATION  )

◆ _Dispatch_type_() [6/12]

_Dispatch_type_ ( IRP_MJ_QUERY_INFORMATION  )

◆ _Dispatch_type_() [7/12]

_Dispatch_type_ ( IRP_MJ_QUERY_EA  )

◆ _Dispatch_type_() [8/12]

_Dispatch_type_ ( IRP_MJ_SET_EA  )

◆ _Dispatch_type_() [9/12]

_Dispatch_type_ ( IRP_MJ_CREATE  )

◆ _Dispatch_type_() [10/12]

_Dispatch_type_ ( IRP_MJ_READ  )

◆ _Dispatch_type_() [11/12]

_Dispatch_type_ ( IRP_MJ_PNP  )

◆ _Dispatch_type_() [12/12]

_Dispatch_type_ ( IRP_MJ_DEVICE_CONTROL  )

◆ _Function_class_() [1/3]

_Function_class_ ( DRIVER_ADD_DEVICE  )

◆ _Function_class_() [2/3]

_Function_class_ ( KSTART_ROUTINE  )

Definition at line 3046 of file balance.c.

3047  {
3049  LIST_ENTRY chunks;
3050  LIST_ENTRY* le;
3051  uint64_t num_chunks[3], okay_metadata_chunks = 0, okay_data_chunks = 0, okay_system_chunks = 0;
3052  uint64_t old_data_flags = 0, old_metadata_flags = 0, old_system_flags = 0;
3053  NTSTATUS Status;
3054 
3055  Vcb->balance.balance_num++;
3056 
3057  Vcb->balance.stopping = false;
3058  KeInitializeEvent(&Vcb->balance.finished, NotificationEvent, false);
3059 
3060  if (Vcb->balance.opts[BALANCE_OPTS_DATA].flags & BTRFS_BALANCE_OPTS_ENABLED && Vcb->balance.opts[BALANCE_OPTS_DATA].flags & BTRFS_BALANCE_OPTS_CONVERT) {
3061  old_data_flags = Vcb->data_flags;
3062  Vcb->data_flags = BLOCK_FLAG_DATA | (Vcb->balance.opts[BALANCE_OPTS_DATA].convert == BLOCK_FLAG_SINGLE ? 0 : Vcb->balance.opts[BALANCE_OPTS_DATA].convert);
3063 
3065  }
3066 
3067  if (Vcb->balance.opts[BALANCE_OPTS_METADATA].flags & BTRFS_BALANCE_OPTS_ENABLED && Vcb->balance.opts[BALANCE_OPTS_METADATA].flags & BTRFS_BALANCE_OPTS_CONVERT) {
3068  old_metadata_flags = Vcb->metadata_flags;
3069  Vcb->metadata_flags = BLOCK_FLAG_METADATA | (Vcb->balance.opts[BALANCE_OPTS_METADATA].convert == BLOCK_FLAG_SINGLE ? 0 : Vcb->balance.opts[BALANCE_OPTS_METADATA].convert);
3070  }
3071 
3072  if (Vcb->balance.opts[BALANCE_OPTS_SYSTEM].flags & BTRFS_BALANCE_OPTS_ENABLED && Vcb->balance.opts[BALANCE_OPTS_SYSTEM].flags & BTRFS_BALANCE_OPTS_CONVERT) {
3073  old_system_flags = Vcb->system_flags;
3074  Vcb->system_flags = BLOCK_FLAG_SYSTEM | (Vcb->balance.opts[BALANCE_OPTS_SYSTEM].convert == BLOCK_FLAG_SINGLE ? 0 : Vcb->balance.opts[BALANCE_OPTS_SYSTEM].convert);
3075  }
3076 
3077  if (Vcb->superblock.incompat_flags & BTRFS_INCOMPAT_FLAGS_MIXED_GROUPS) {
3078  if (Vcb->balance.opts[BALANCE_OPTS_DATA].flags & BTRFS_BALANCE_OPTS_ENABLED)
3079  RtlCopyMemory(&Vcb->balance.opts[BALANCE_OPTS_METADATA], &Vcb->balance.opts[BALANCE_OPTS_DATA], sizeof(btrfs_balance_opts));
3080  else if (Vcb->balance.opts[BALANCE_OPTS_METADATA].flags & BTRFS_BALANCE_OPTS_ENABLED)
3081  RtlCopyMemory(&Vcb->balance.opts[BALANCE_OPTS_DATA], &Vcb->balance.opts[BALANCE_OPTS_METADATA], sizeof(btrfs_balance_opts));
3082  }
3083 
3084  num_chunks[0] = num_chunks[1] = num_chunks[2] = 0;
3085  Vcb->balance.total_chunks = Vcb->balance.chunks_left = 0;
3086 
3087  InitializeListHead(&chunks);
3088 
3089  // FIXME - what are we supposed to do with limit_start?
3090 
3091  if (!Vcb->readonly) {
3092  if (!Vcb->balance.removing && !Vcb->balance.shrinking) {
3094  if (!NT_SUCCESS(Status)) {
3095  ERR("add_balance_item returned %08x\n", Status);
3096  Vcb->balance.status = Status;
3097  goto end;
3098  }
3099  } else {
3100  if (Vcb->need_write) {
3101  Status = do_write(Vcb, NULL);
3102 
3103  free_trees(Vcb);
3104 
3105  if (!NT_SUCCESS(Status)) {
3106  ERR("do_write returned %08x\n", Status);
3107  Vcb->balance.status = Status;
3108  goto end;
3109  }
3110  }
3111  }
3112  }
3113 
3114  KeWaitForSingleObject(&Vcb->balance.event, Executive, KernelMode, false, NULL);
3115 
3116  if (Vcb->balance.stopping)
3117  goto end;
3118 
3119  ExAcquireResourceSharedLite(&Vcb->chunk_lock, true);
3120 
3121  le = Vcb->chunks.Flink;
3122  while (le != &Vcb->chunks) {
3124  uint8_t sort;
3125 
3127 
3128  if (c->chunk_item->type & BLOCK_FLAG_DATA)
3130  else if (c->chunk_item->type & BLOCK_FLAG_METADATA)
3132  else if (c->chunk_item->type & BLOCK_FLAG_SYSTEM)
3134  else {
3135  ERR("unexpected chunk type %I64x\n", c->chunk_item->type);
3137  break;
3138  }
3139 
3140  if ((!(Vcb->balance.opts[sort].flags & BTRFS_BALANCE_OPTS_LIMIT) || num_chunks[sort] < Vcb->balance.opts[sort].limit_end) &&
3142  InsertTailList(&chunks, &c->list_entry_balance);
3143 
3144  num_chunks[sort]++;
3145  Vcb->balance.total_chunks++;
3146  Vcb->balance.chunks_left++;
3147  } else if (sort == BALANCE_OPTS_METADATA)
3148  okay_metadata_chunks++;
3149  else if (sort == BALANCE_OPTS_DATA)
3150  okay_data_chunks++;
3151  else if (sort == BALANCE_OPTS_SYSTEM)
3152  okay_system_chunks++;
3153 
3154  if (!c->cache_loaded) {
3156 
3157  if (!NT_SUCCESS(Status)) {
3158  ERR("load_cache_chunk returned %08x\n", Status);
3159  Vcb->balance.status = Status;
3161  ExReleaseResourceLite(&Vcb->chunk_lock);
3162  goto end;
3163  }
3164  }
3165 
3167 
3168  le = le->Flink;
3169  }
3170 
3171  ExReleaseResourceLite(&Vcb->chunk_lock);
3172 
3173  // If we're doing a full balance, try and allocate a new chunk now, before we mess things up
3174  if (okay_metadata_chunks == 0 || okay_data_chunks == 0 || okay_system_chunks == 0) {
3175  bool consolidated = false;
3176  chunk* c;
3177 
3178  if (okay_metadata_chunks == 0) {
3179  ExAcquireResourceExclusiveLite(&Vcb->chunk_lock, true);
3180 
3181  Status = alloc_chunk(Vcb, Vcb->metadata_flags, &c, true);
3182  if (NT_SUCCESS(Status))
3183  c->balance_num = Vcb->balance.balance_num;
3184  else if (Status != STATUS_DISK_FULL || consolidated) {
3185  ERR("alloc_chunk returned %08x\n", Status);
3186  ExReleaseResourceLite(&Vcb->chunk_lock);
3187  Vcb->balance.status = Status;
3188  goto end;
3189  }
3190 
3191  ExReleaseResourceLite(&Vcb->chunk_lock);
3192 
3193  if (Status == STATUS_DISK_FULL) {
3194  Status = try_consolidation(Vcb, Vcb->metadata_flags, &c);
3195  if (!NT_SUCCESS(Status)) {
3196  ERR("try_consolidation returned %08x\n", Status);
3197  Vcb->balance.status = Status;
3198  goto end;
3199  } else
3200  c->balance_num = Vcb->balance.balance_num;
3201 
3202  consolidated = true;
3203 
3204  if (Vcb->balance.stopping)
3205  goto end;
3206  }
3207  }
3208 
3209  if (okay_data_chunks == 0) {
3210  ExAcquireResourceExclusiveLite(&Vcb->chunk_lock, true);
3211 
3212  Status = alloc_chunk(Vcb, Vcb->data_flags, &c, true);
3213  if (NT_SUCCESS(Status))
3214  c->balance_num = Vcb->balance.balance_num;
3215  else if (Status != STATUS_DISK_FULL || consolidated) {
3216  ERR("alloc_chunk returned %08x\n", Status);
3217  ExReleaseResourceLite(&Vcb->chunk_lock);
3218  Vcb->balance.status = Status;
3219  goto end;
3220  }
3221 
3222  ExReleaseResourceLite(&Vcb->chunk_lock);
3223 
3224  if (Status == STATUS_DISK_FULL) {
3225  Status = try_consolidation(Vcb, Vcb->data_flags, &c);
3226  if (!NT_SUCCESS(Status)) {
3227  ERR("try_consolidation returned %08x\n", Status);
3228  Vcb->balance.status = Status;
3229  goto end;
3230  } else
3231  c->balance_num = Vcb->balance.balance_num;
3232 
3233  consolidated = true;
3234 
3235  if (Vcb->balance.stopping)
3236  goto end;
3237  }
3238  }
3239 
3240  if (okay_system_chunks == 0) {
3241  ExAcquireResourceExclusiveLite(&Vcb->chunk_lock, true);
3242 
3243  Status = alloc_chunk(Vcb, Vcb->system_flags, &c, true);
3244  if (NT_SUCCESS(Status))
3245  c->balance_num = Vcb->balance.balance_num;
3246  else if (Status != STATUS_DISK_FULL || consolidated) {
3247  ERR("alloc_chunk returned %08x\n", Status);
3248  ExReleaseResourceLite(&Vcb->chunk_lock);
3249  Vcb->balance.status = Status;
3250  goto end;
3251  }
3252 
3253  ExReleaseResourceLite(&Vcb->chunk_lock);
3254 
3255  if (Status == STATUS_DISK_FULL) {
3256  Status = try_consolidation(Vcb, Vcb->system_flags, &c);
3257  if (!NT_SUCCESS(Status)) {
3258  ERR("try_consolidation returned %08x\n", Status);
3259  Vcb->balance.status = Status;
3260  goto end;
3261  } else
3262  c->balance_num = Vcb->balance.balance_num;
3263 
3264  consolidated = true;
3265 
3266  if (Vcb->balance.stopping)
3267  goto end;
3268  }
3269  }
3270  }
3271 
3272  ExAcquireResourceSharedLite(&Vcb->chunk_lock, true);
3273 
3274  le = chunks.Flink;
3275  while (le != &chunks) {
3276  chunk* c = CONTAINING_RECORD(le, chunk, list_entry_balance);
3277 
3278  c->reloc = true;
3279 
3280  le = le->Flink;
3281  }
3282 
3283  ExReleaseResourceLite(&Vcb->chunk_lock);
3284 
3285  // do data chunks before metadata
3286  le = chunks.Flink;
3287  while (le != &chunks) {
3288  chunk* c = CONTAINING_RECORD(le, chunk, list_entry_balance);
3289  LIST_ENTRY* le2 = le->Flink;
3290 
3291  if (c->chunk_item->type & BLOCK_FLAG_DATA) {
3292  bool changed;
3293 
3294  do {
3295  changed = false;
3296 
3297  Status = balance_data_chunk(Vcb, c, &changed);
3298  if (!NT_SUCCESS(Status)) {
3299  ERR("balance_data_chunk returned %08x\n", Status);
3300  Vcb->balance.status = Status;
3301  goto end;
3302  }
3303 
3304  KeWaitForSingleObject(&Vcb->balance.event, Executive, KernelMode, false, NULL);
3305 
3306  if (Vcb->readonly)
3307  Vcb->balance.stopping = true;
3308 
3309  if (Vcb->balance.stopping)
3310  break;
3311  } while (changed);
3312 
3313  c->changed = true;
3314  c->space_changed = true;
3315  }
3316 
3317  if (Vcb->balance.stopping)
3318  goto end;
3319 
3320  if (c->chunk_item->type & BLOCK_FLAG_DATA &&
3321  (!(Vcb->balance.opts[BALANCE_OPTS_METADATA].flags & BTRFS_BALANCE_OPTS_ENABLED) || !(c->chunk_item->type & BLOCK_FLAG_METADATA))) {
3322  RemoveEntryList(&c->list_entry_balance);
3323  c->list_entry_balance.Flink = NULL;
3324 
3325  Vcb->balance.chunks_left--;
3326  }
3327 
3328  le = le2;
3329  }
3330 
3331  // do metadata chunks
3332  while (!IsListEmpty(&chunks)) {
3333  chunk* c;
3334  bool changed;
3335 
3336  le = RemoveHeadList(&chunks);
3337  c = CONTAINING_RECORD(le, chunk, list_entry_balance);
3338 
3339  if (c->chunk_item->type & BLOCK_FLAG_METADATA || c->chunk_item->type & BLOCK_FLAG_SYSTEM) {
3340  do {
3341  Status = balance_metadata_chunk(Vcb, c, &changed);
3342  if (!NT_SUCCESS(Status)) {
3343  ERR("balance_metadata_chunk returned %08x\n", Status);
3344  Vcb->balance.status = Status;
3345  goto end;
3346  }
3347 
3348  KeWaitForSingleObject(&Vcb->balance.event, Executive, KernelMode, false, NULL);
3349 
3350  if (Vcb->readonly)
3351  Vcb->balance.stopping = true;
3352 
3353  if (Vcb->balance.stopping)
3354  break;
3355  } while (changed);
3356 
3357  c->changed = true;
3358  c->space_changed = true;
3359  }
3360 
3361  if (Vcb->balance.stopping)
3362  break;
3363 
3364  c->list_entry_balance.Flink = NULL;
3365 
3366  Vcb->balance.chunks_left--;
3367  }
3368 
3369 end:
3370  if (!Vcb->readonly) {
3371  if (Vcb->balance.stopping || !NT_SUCCESS(Vcb->balance.status)) {
3372  le = chunks.Flink;
3373  while (le != &chunks) {
3374  chunk* c = CONTAINING_RECORD(le, chunk, list_entry_balance);
3375  c->reloc = false;
3376 
3377  le = le->Flink;
3378  c->list_entry_balance.Flink = NULL;
3379  }
3380 
3381  if (old_data_flags != 0)
3382  Vcb->data_flags = old_data_flags;
3383 
3384  if (old_metadata_flags != 0)
3385  Vcb->metadata_flags = old_metadata_flags;
3386 
3387  if (old_system_flags != 0)
3388  Vcb->system_flags = old_system_flags;
3389  }
3390 
3391  if (Vcb->balance.removing) {
3392  device* dev = NULL;
3393 
3394  ExAcquireResourceExclusiveLite(&Vcb->tree_lock, true);
3395 
3396  le = Vcb->devices.Flink;
3397  while (le != &Vcb->devices) {
3398  device* dev2 = CONTAINING_RECORD(le, device, list_entry);
3399 
3400  if (dev2->devitem.dev_id == Vcb->balance.opts[0].devid) {
3401  dev = dev2;
3402  break;
3403  }
3404 
3405  le = le->Flink;
3406  }
3407 
3408  if (dev) {
3409  if (Vcb->balance.chunks_left == 0) {
3411 
3412  if (!NT_SUCCESS(Status)) {
3413  ERR("finish_removing_device returned %08x\n", Status);
3414  dev->reloc = false;
3415  }
3416  } else
3417  dev->reloc = false;
3418  }
3419 
3420  ExReleaseResourceLite(&Vcb->tree_lock);
3421  } else if (Vcb->balance.shrinking) {
3422  device* dev = NULL;
3423 
3424  ExAcquireResourceExclusiveLite(&Vcb->tree_lock, true);
3425 
3426  le = Vcb->devices.Flink;
3427  while (le != &Vcb->devices) {
3428  device* dev2 = CONTAINING_RECORD(le, device, list_entry);
3429 
3430  if (dev2->devitem.dev_id == Vcb->balance.opts[0].devid) {
3431  dev = dev2;
3432  break;
3433  }
3434 
3435  le = le->Flink;
3436  }
3437 
3438  if (!dev) {
3439  ERR("could not find device %I64x\n", Vcb->balance.opts[0].devid);
3440  Vcb->balance.status = STATUS_INTERNAL_ERROR;
3441  }
3442 
3443  if (Vcb->balance.stopping || !NT_SUCCESS(Vcb->balance.status)) {
3444  if (dev) {
3446  if (!NT_SUCCESS(Status))
3447  WARN("regenerate_space_list returned %08x\n", Status);
3448  }
3449  } else {
3450  uint64_t old_size;
3451 
3452  old_size = dev->devitem.num_bytes;
3453  dev->devitem.num_bytes = Vcb->balance.opts[0].drange_start;
3454 
3456  if (!NT_SUCCESS(Status)) {
3457  ERR("update_dev_item returned %08x\n", Status);
3458  dev->devitem.num_bytes = old_size;
3459  Vcb->balance.status = Status;
3460 
3462  if (!NT_SUCCESS(Status))
3463  WARN("regenerate_space_list returned %08x\n", Status);
3464  } else {
3465  Vcb->superblock.total_bytes -= old_size - dev->devitem.num_bytes;
3466 
3467  Status = do_write(Vcb, NULL);
3468  if (!NT_SUCCESS(Status))
3469  ERR("do_write returned %08x\n", Status);
3470 
3471  free_trees(Vcb);
3472  }
3473  }
3474 
3475  ExReleaseResourceLite(&Vcb->tree_lock);
3476 
3477  if (!Vcb->balance.stopping && NT_SUCCESS(Vcb->balance.status))
3479  } else {
3481  if (!NT_SUCCESS(Status)) {
3482  ERR("remove_balance_item returned %08x\n", Status);
3483  goto end;
3484  }
3485  }
3486 
3487  if (Vcb->trim && !Vcb->options.no_trim) {
3488  ExAcquireResourceExclusiveLite(&Vcb->tree_lock, true);
3489 
3490  le = Vcb->devices.Flink;
3491  while (le != &Vcb->devices) {
3492  device* dev2 = CONTAINING_RECORD(le, device, list_entry);
3493 
3494  if (dev2->devobj && !dev2->readonly && dev2->trim)
3495  trim_unalloc_space(Vcb, dev2);
3496 
3497  le = le->Flink;
3498  }
3499 
3500  ExReleaseResourceLite(&Vcb->tree_lock);
3501  }
3502  }
3503 
3504  ZwClose(Vcb->balance.thread);
3505  Vcb->balance.thread = NULL;
3506 
3507  KeSetEvent(&Vcb->balance.finished, 0, false);
3508 }
static bool should_balance_chunk(device_extension *Vcb, uint8_t sort, chunk *c)
Definition: balance.c:2224
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define BALANCE_OPTS_SYSTEM
Definition: btrfs_drv.h:672
Definition: http.c:6597
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
_STLP_MOVE_TO_STD_NAMESPACE void sort(_RandomAccessIter __first, _RandomAccessIter __last)
Definition: _algo.c:993
NTSTATUS do_write(device_extension *Vcb, PIRP Irp)
Definition: flushthread.c:7667
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:518
#define WARN(fmt,...)
Definition: debug.h:111
LONG NTSTATUS
Definition: precomp.h:26
release_chunk_lock(c, Vcb)
bool readonly
Definition: btrfs_drv.h:523
GLuint GLuint end
Definition: gl.h:1545
#define InsertTailList(ListHead, Entry)
static NTSTATUS balance_metadata_chunk(device_extension *Vcb, chunk *c, bool *changed)
Definition: balance.c:1103
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define BLOCK_FLAG_SINGLE
Definition: btrfsioctl.h:140
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:451
static NTSTATUS try_consolidation(device_extension *Vcb, uint64_t flags, chunk **newchunk)
Definition: balance.c:2901
#define BTRFS_BALANCE_OPTS_CONVERT
Definition: btrfsioctl.h:137
Definition: devices.h:37
#define BTRFS_INCOMPAT_FLAGS_MIXED_GROUPS
Definition: btrfs.h:108
#define BLOCK_FLAG_SYSTEM
Definition: shellext.h:76
bool trim
Definition: btrfs_drv.h:525
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
void free_trees(device_extension *Vcb)
Definition: treefuncs.c:793
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define FSRTL_VOLUME_CHANGE_SIZE
Definition: fsrtltypes.h:101
static NTSTATUS add_balance_item(device_extension *Vcb)
Definition: balance.c:2377
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
static NTSTATUS regenerate_space_list(device_extension *Vcb, device *dev)
Definition: balance.c:2996
NTSTATUS NTAPI FsRtlNotifyVolumeEvent(IN PFILE_OBJECT FileObject, IN ULONG EventCode)
Definition: pnp.c:38
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1425
#define BTRFS_BALANCE_OPTS_LIMIT
Definition: btrfsioctl.h:134
const GLubyte * c
Definition: glext.h:8905
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
NTSTATUS update_dev_item(device_extension *Vcb, device *device, PIRP Irp)
Definition: flushthread.c:4057
#define BTRFS_BALANCE_OPTS_ENABLED
Definition: btrfsioctl.h:129
#define BLOCK_FLAG_METADATA
Definition: shellext.h:77
uint64_t dev_id
Definition: btrfs.h:162
Definition: typedefs.h:117
BYTE uint8_t
Definition: msvideo1.c:66
Status
Definition: gdiplustypes.h:24
NTSTATUS load_cache_chunk(device_extension *Vcb, chunk *c, PIRP Irp)
Definition: free-space.c:979
#define ERR(fmt,...)
Definition: debug.h:109
static NTSTATUS remove_balance_item(device_extension *Vcb)
Definition: balance.c:2450
static NTSTATUS balance_data_chunk(device_extension *Vcb, chunk *c, bool *changed)
Definition: balance.c:1674
UINT64 uint64_t
Definition: types.h:77
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define acquire_chunk_lock(c, Vcb)
Definition: btrfs_drv.h:1104
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
Definition: list.h:27
DEV_ITEM devitem
Definition: btrfs_drv.h:520
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
#define BLOCK_FLAG_DATA
Definition: shellext.h:75
static NTSTATUS finish_removing_device(_Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, device *dev)
Definition: balance.c:2585
#define STATUS_DISK_FULL
Definition: udferr_usr.h:155
static void trim_unalloc_space(_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, device *dev)
Definition: balance.c:2801
#define c
Definition: ke_i.h:80
#define BALANCE_OPTS_METADATA
Definition: btrfs_drv.h:671
NTSTATUS alloc_chunk(device_extension *Vcb, uint64_t flags, chunk **pc, bool full_size)
Definition: write.c:361
#define BALANCE_OPTS_DATA
Definition: btrfs_drv.h:670

◆ _Function_class_() [3/3]

_Function_class_ ( DRIVER_NOTIFICATION_CALLBACK_ROUTINE  )

◆ _Post_satisfies_()

_Post_satisfies_ ( return >=  n)

◆ _Releases_lock_()

_Releases_lock_ ( c->  lock)

◆ _Requires_lock_held_() [1/2]

_Requires_lock_held_ ( Vcb->  fcb_lock) -> fcb_lock) static __inline void release_fcb_lock(device_extension* Vcb)

Definition at line 946 of file btrfs_drv.h.

948  {
949  ExReleaseResourceLite(&Vcb->fcb_lock);
950 }
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817

◆ _Requires_lock_held_() [2/2]

_Requires_lock_held_ ( c->  lock)
pure virtual

◆ _Requires_lock_not_held_()

_Requires_lock_not_held_ ( Vcb->  fcb_lock) -> fcb_lock) static __inline void acquire_fcb_lock_shared(device_extension* Vcb)

Definition at line 934 of file btrfs_drv.h.

936  {
937  ExAcquireResourceSharedLite(&Vcb->fcb_lock, true);
938 }
#define Vcb
Definition: cdprocs.h:1425
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885

◆ _Success_()

_Success_ ( return  )

◆ add_calc_job()

NTSTATUS add_calc_job ( device_extension Vcb,
uint8_t data,
uint32_t  sectors,
uint32_t csum,
calc_job **  pcj 
)

Definition at line 22 of file calcthread.c.

22  {
23  calc_job* cj;
24 
26  if (!cj) {
27  ERR("out of memory\n");
29  }
30 
31  cj->data = data;
32  cj->sectors = sectors;
33  cj->csum = csum;
34  cj->pos = 0;
35  cj->done = 0;
36  cj->refcount = 1;
37  KeInitializeEvent(&cj->event, NotificationEvent, false);
38 
39  ExAcquireResourceExclusiveLite(&Vcb->calcthreads.lock, true);
40 
41  InsertTailList(&Vcb->calcthreads.job_list, &cj->list_entry);
42 
43  KeSetEvent(&Vcb->calcthreads.event, 0, false);
44  KeClearEvent(&Vcb->calcthreads.event);
45 
46  ExReleaseResourceLite(&Vcb->calcthreads.lock);
47 
48  *pcj = cj;
49 
50  return STATUS_SUCCESS;
51 }
_In_ ULONG cj
Definition: winddi.h:3540
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ ULONG * pcj
Definition: winddi.h:3642
#define InsertTailList(ListHead, Entry)
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define ALLOC_TAG
Definition: btrfs_drv.h:91
uint32_t * csum
Definition: write.c:2821
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ERR(fmt,...)
Definition: debug.h:109
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
__u8 sectors[2]
Definition: mkdosfs.c:366
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by calc_csum(), and check_csum().

◆ add_changed_extent_ref()

void add_changed_extent_ref ( chunk c,
uint64_t  address,
uint64_t  size,
uint64_t  root,
uint64_t  objid,
uint64_t  offset,
uint32_t  count,
bool  no_csum 
)

Definition at line 2075 of file extent-tree.c.

2075  {
2076  changed_extent* ce;
2077  changed_extent_ref* cer;
2078  LIST_ENTRY* le;
2079 
2080  ce = get_changed_extent_item(c, address, size, no_csum);
2081 
2082  if (!ce) {
2083  ERR("get_changed_extent_item failed\n");
2084  return;
2085  }
2086 
2087  le = ce->refs.Flink;
2088  while (le != &ce->refs) {
2090 
2091  if (cer->type == TYPE_EXTENT_DATA_REF && cer->edr.root == root && cer->edr.objid == objid && cer->edr.offset == offset) {
2092  ce->count += count;
2093  cer->edr.count += count;
2094  return;
2095  }
2096 
2097  le = le->Flink;
2098  }
2099 
2101 
2102  if (!cer) {
2103  ERR("out of memory\n");
2104  return;
2105  }
2106 
2107  cer->type = TYPE_EXTENT_DATA_REF;
2108  cer->edr.root = root;
2109  cer->edr.objid = objid;
2110  cer->edr.offset = offset;
2111  cer->edr.count = count;
2112 
2113  InsertTailList(&ce->refs, &cer->list_entry);
2114 
2115  ce->count += count;
2116 }
uint64_t offset
Definition: btrfs.h:397
LIST_ENTRY list_entry
Definition: btrfs_drv.h:610
GLuint GLuint GLsizei count
Definition: gl.h:1545
struct _root root
uint64_t objid
Definition: btrfs.h:396
GLintptr offset
Definition: glext.h:5920
#define InsertTailList(ListHead, Entry)
#define ALLOC_TAG
Definition: btrfs_drv.h:91
EXTENT_DATA_REF edr
Definition: btrfs_drv.h:606
uint32_t count
Definition: btrfs.h:398
uint64_t count
Definition: btrfs_drv.h:593
uint64_t root
Definition: btrfs.h:395
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define TYPE_EXTENT_DATA_REF
Definition: btrfs.h:34
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
GLsizeiptr size
Definition: glext.h:5919
const GLubyte * c
Definition: glext.h:8905
GLuint address
Definition: glext.h:9393
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Definition: typedefs.h:117
#define ERR(fmt,...)
Definition: debug.h:109
LIST_ENTRY refs
Definition: btrfs_drv.h:597
static changed_extent * get_changed_extent_item(chunk *c, uint64_t address, uint64_t size, bool no_csum)
Definition: extent-tree.c:1915
Definition: list.h:27

Referenced by rationalize_extents().

◆ add_checksum_entry()

void add_checksum_entry ( device_extension Vcb,
uint64_t  address,
ULONG  length,
uint32_t csum,
PIRP  Irp 
)

Definition at line 2555 of file flushthread.c.

2555  {
2556  KEY searchkey;
2557  traverse_ptr tp, next_tp;
2558  NTSTATUS Status;
2559  uint64_t startaddr, endaddr;
2560  ULONG len;
2561  uint32_t* checksums;
2562  RTL_BITMAP bmp;
2563  ULONG* bmparr;
2564  ULONG runlength, index;
2565 
2566  TRACE("(%p, %I64x, %x, %p, %p)\n", Vcb, address, length, csum, Irp);
2567 
2568  searchkey.obj_id = EXTENT_CSUM_ID;
2569  searchkey.obj_type = TYPE_EXTENT_CSUM;
2570  searchkey.offset = address;
2571 
2572  // FIXME - create checksum_root if it doesn't exist at all
2573 
2574  Status = find_item(Vcb, Vcb->checksum_root, &tp, &searchkey, false, Irp);
2575  if (Status == STATUS_NOT_FOUND) { // tree is completely empty
2576  if (csum) { // not deleted
2577  ULONG length2 = length;
2578  uint64_t off = address;
2579  uint32_t* data = csum;
2580 
2581  do {
2582  uint16_t il = (uint16_t)min(length2, MAX_CSUM_SIZE / sizeof(uint32_t));
2583 
2584  checksums = ExAllocatePoolWithTag(PagedPool, il * sizeof(uint32_t), ALLOC_TAG);
2585  if (!checksums) {
2586  ERR("out of memory\n");
2587  return;
2588  }
2589 
2590  RtlCopyMemory(checksums, data, il * sizeof(uint32_t));
2591 
2592  Status = insert_tree_item(Vcb, Vcb->checksum_root, EXTENT_CSUM_ID, TYPE_EXTENT_CSUM, off, checksums,
2593  il * sizeof(uint32_t), NULL, Irp);
2594  if (!NT_SUCCESS(Status)) {
2595  ERR("insert_tree_item returned %08x\n", Status);
2596  ExFreePool(checksums);
2597  return;
2598  }
2599 
2600  length2 -= il;
2601 
2602  if (length2 > 0) {
2603  off += il * Vcb->superblock.sector_size;
2604  data += il;
2605  }
2606  } while (length2 > 0);
2607  }
2608  } else if (!NT_SUCCESS(Status)) {
2609  ERR("find_item returned %08x\n", Status);
2610  return;
2611  } else {
2612  uint32_t tplen;
2613 
2614  // FIXME - check entry is TYPE_EXTENT_CSUM?
2615 
2616  if (tp.item->key.offset < address && tp.item->key.offset + (tp.item->size * Vcb->superblock.sector_size / sizeof(uint32_t)) >= address)
2617  startaddr = tp.item->key.offset;
2618  else
2619  startaddr = address;
2620 
2621  searchkey.obj_id = EXTENT_CSUM_ID;
2622  searchkey.obj_type = TYPE_EXTENT_CSUM;
2623  searchkey.offset = address + (length * Vcb->superblock.sector_size);
2624 
2625  Status = find_item(Vcb, Vcb->checksum_root, &tp, &searchkey, false, Irp);
2626  if (!NT_SUCCESS(Status)) {
2627  ERR("find_item returned %08x\n", Status);
2628  return;
2629  }
2630 
2631  tplen = tp.item->size / sizeof(uint32_t);
2632 
2633  if (tp.item->key.offset + (tplen * Vcb->superblock.sector_size) >= address + (length * Vcb->superblock.sector_size))
2634  endaddr = tp.item->key.offset + (tplen * Vcb->superblock.sector_size);
2635  else
2636  endaddr = address + (length * Vcb->superblock.sector_size);
2637 
2638  TRACE("cs starts at %I64x (%x sectors)\n", address, length);
2639  TRACE("startaddr = %I64x\n", startaddr);
2640  TRACE("endaddr = %I64x\n", endaddr);
2641 
2642  len = (ULONG)((endaddr - startaddr) / Vcb->superblock.sector_size);
2643 
2644  checksums = ExAllocatePoolWithTag(PagedPool, sizeof(uint32_t) * len, ALLOC_TAG);
2645  if (!checksums) {
2646  ERR("out of memory\n");
2647  return;
2648  }
2649 
2650  bmparr = ExAllocatePoolWithTag(PagedPool, sizeof(ULONG) * ((len/8)+1), ALLOC_TAG);
2651  if (!bmparr) {
2652  ERR("out of memory\n");
2653  ExFreePool(checksums);
2654  return;
2655  }
2656 
2657  RtlInitializeBitMap(&bmp, bmparr, len);
2658  RtlSetAllBits(&bmp);
2659 
2660  searchkey.obj_id = EXTENT_CSUM_ID;
2661  searchkey.obj_type = TYPE_EXTENT_CSUM;
2662  searchkey.offset = address;
2663 
2664  Status = find_item(Vcb, Vcb->checksum_root, &tp, &searchkey, false, Irp);
2665  if (!NT_SUCCESS(Status)) {
2666  ERR("find_item returned %08x\n", Status);
2667  ExFreePool(checksums);
2668  ExFreePool(bmparr);
2669  return;
2670  }
2671 
2672  // set bit = free space, cleared bit = allocated sector
2673 
2674  while (tp.item->key.offset < endaddr) {
2675  if (tp.item->key.offset >= startaddr) {
2676  if (tp.item->size > 0) {
2677  ULONG itemlen = (ULONG)min((len - (tp.item->key.offset - startaddr) / Vcb->superblock.sector_size) * sizeof(uint32_t), tp.item->size);
2678 
2679  RtlCopyMemory(&checksums[(tp.item->key.offset - startaddr) / Vcb->superblock.sector_size], tp.item->data, itemlen);
2680  RtlClearBits(&bmp, (ULONG)((tp.item->key.offset - startaddr) / Vcb->superblock.sector_size), itemlen / sizeof(uint32_t));
2681  }
2682 
2684  if (!NT_SUCCESS(Status)) {
2685  ERR("delete_tree_item returned %08x\n", Status);
2686  ExFreePool(checksums);
2687  ExFreePool(bmparr);
2688  return;
2689  }
2690  }
2691 
2692  if (find_next_item(Vcb, &tp, &next_tp, false, Irp)) {
2693  tp = next_tp;
2694  } else
2695  break;
2696  }
2697 
2698  if (!csum) { // deleted
2699  RtlSetBits(&bmp, (ULONG)((address - startaddr) / Vcb->superblock.sector_size), length);
2700  } else {
2701  RtlCopyMemory(&checksums[(address - startaddr) / Vcb->superblock.sector_size], csum, length * sizeof(uint32_t));
2702  RtlClearBits(&bmp, (ULONG)((address - startaddr) / Vcb->superblock.sector_size), length);
2703  }
2704 
2705  runlength = RtlFindFirstRunClear(&bmp, &index);
2706 
2707  while (runlength != 0) {
2708  if (index >= len)
2709  break;
2710 
2711  if (index + runlength >= len) {
2712  runlength = len - index;
2713 
2714  if (runlength == 0)
2715  break;
2716  }
2717 
2718  do {
2719  uint16_t rl;
2720  uint64_t off;
2721  uint32_t* data;
2722 
2723  if (runlength * sizeof(uint32_t) > MAX_CSUM_SIZE)
2724  rl = MAX_CSUM_SIZE / sizeof(uint32_t);
2725  else
2726  rl = (uint16_t)runlength;
2727 
2729  if (!data) {
2730  ERR("out of memory\n");
2731  ExFreePool(bmparr);
2732  ExFreePool(checksums);
2733  return;
2734  }
2735 
2736  RtlCopyMemory(data, &checksums[index], sizeof(uint32_t) * rl);
2737 
2738  off = startaddr + UInt32x32To64(index, Vcb->superblock.sector_size);
2739 
2740  Status = insert_tree_item(Vcb, Vcb->checksum_root, EXTENT_CSUM_ID, TYPE_EXTENT_CSUM, off, data, sizeof(uint32_t) * rl, NULL, Irp);
2741  if (!NT_SUCCESS(Status)) {
2742  ERR("insert_tree_item returned %08x\n", Status);
2743  ExFreePool(data);
2744  ExFreePool(bmparr);
2745  ExFreePool(checksums);
2746  return;
2747  }
2748 
2749  runlength -= rl;
2750  index += rl;
2751  } while (runlength > 0);
2752 
2753  runlength = RtlFindNextForwardRunClear(&bmp, index, &index);
2754  }
2755 
2756  ExFreePool(bmparr);
2757  ExFreePool(checksums);
2758  }
2759 }
uint64_t obj_id
Definition: btrfs.h:128
NTSYSAPI void WINAPI RtlClearBits(PRTL_BITMAP, ULONG, ULONG)
#define MAX_CSUM_SIZE
Definition: flushthread.c:23
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
uint8_t obj_type
Definition: btrfs.h:129
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
uint16_t size
Definition: btrfs_drv.h:415
unsigned short int uint16_t
Definition: acefiex.h:54
#define uint16_t
Definition: nsiface.idl:60
uint64_t offset
Definition: btrfs.h:130
uint8_t * data
Definition: btrfs_drv.h:416
#define TYPE_EXTENT_CSUM
Definition: btrfs.h:27
#define ALLOC_TAG
Definition: btrfs_drv.h:91
NTSYSAPI ULONG WINAPI RtlFindNextForwardRunClear(PCRTL_BITMAP, ULONG, PULONG)
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2855
uint32_t * csum
Definition: write.c:2821
static LONG find_item(PropertyBag *This, LPCOLESTR name)
Definition: propertybag.c:110
#define STATUS_NOT_FOUND
Definition: shellext.h:72
#define TRACE(s)
Definition: solgame.cpp:4
bool find_next_item(_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, const traverse_ptr *tp, traverse_ptr *next_tp, bool ignore, PIRP Irp)
Definition: treefuncs.c:592
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define Vcb
Definition: cdprocs.h:1425
GLuint address
Definition: glext.h:9393
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
BITMAP bmp
Definition: alphablend.c:62
NTSTATUS insert_tree_item(_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_ root *r, _In_ uint64_t obj_id, _In_ uint8_t obj_type, _In_ uint64_t offset, _In_reads_bytes_opt_(size) _When_(return >=0, __drv_aliasesMem) void *data, _In_ uint16_t size, _Out_opt_ traverse_ptr *ptp, _In_opt_ PIRP Irp)
Definition: treefuncs.c:857
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
tree_data * item
Definition: btrfs_drv.h:502
#define index(s, c)
Definition: various.h:29
GLenum GLsizei len
Definition: glext.h:6722
static void startaddr(void)
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
Definition: btrfs.h:127
#define EXTENT_CSUM_ID
Definition: btrfs.h:85
UINT64 uint64_t
Definition: types.h:77
NTSYSAPI ULONG NTAPI RtlFindFirstRunClear(_In_ PRTL_BITMAP BitMapHeader, _Out_ PULONG StartingIndex)
#define min(a, b)
Definition: monoChain.cc:55
UINT32 uint32_t
Definition: types.h:75
Definition: fs.h:216
NTSYSAPI void WINAPI RtlSetAllBits(PRTL_BITMAP)
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
#define uint32_t
Definition: nsiface.idl:61
#define UInt32x32To64(a, b)
Definition: intsafe.h:258
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
NTSTATUS delete_tree_item(_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _Inout_ traverse_ptr *tp)
Definition: treefuncs.c:989
off
Definition: i386-dis.c:3909

Referenced by balance_data_chunk(), decrease_extent_refcount(), flush_fcb(), and rationalize_extents().

◆ add_dir_child()

NTSTATUS add_dir_child ( fcb fcb,
uint64_t  inode,
bool  subvol,
PANSI_STRING  utf8,
PUNICODE_STRING  name,
uint8_t  type,
dir_child **  pdc 
)

Definition at line 1830 of file create.c.

1830  {
1831  NTSTATUS Status;
1832  dir_child* dc;
1833  bool locked;
1834 
1836  if (!dc) {
1837  ERR("out of memory\n");
1839  }
1840 
1841  dc->utf8.Buffer = ExAllocatePoolWithTag(PagedPool, utf8->Length, ALLOC_TAG);
1842  if (!dc->utf8.Buffer) {
1843  ERR("out of memory\n");
1844  ExFreePool(dc);
1846  }
1847 
1848  dc->name.Buffer = ExAllocatePoolWithTag(PagedPool, name->Length, ALLOC_TAG);
1849  if (!dc->name.Buffer) {
1850  ERR("out of memory\n");
1851  ExFreePool(dc->utf8.Buffer);
1852  ExFreePool(dc);
1854  }
1855 
1856  dc->key.obj_id = inode;
1857  dc->key.obj_type = subvol ? TYPE_ROOT_ITEM : TYPE_INODE_ITEM;
1858  dc->key.offset = subvol ? 0xffffffffffffffff : 0;
1859  dc->type = type;
1860  dc->fileref = NULL;
1861 
1862  dc->utf8.Length = dc->utf8.MaximumLength = utf8->Length;
1863  RtlCopyMemory(dc->utf8.Buffer, utf8->Buffer, utf8->Length);
1864 
1865  dc->name.Length = dc->name.MaximumLength = name->Length;
1866  RtlCopyMemory(dc->name.Buffer, name->Buffer, name->Length);
1867 
1868  Status = RtlUpcaseUnicodeString(&dc->name_uc, name, true);
1869  if (!NT_SUCCESS(Status)) {
1870  ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
1871  ExFreePool(dc->utf8.Buffer);
1872  ExFreePool(dc->name.Buffer);
1873  ExFreePool(dc);
1874  return Status;
1875  }
1876 
1877  dc->hash = calc_crc32c(0xffffffff, (uint8_t*)dc->name.Buffer, dc->name.Length);
1878  dc->hash_uc = calc_crc32c(0xffffffff, (uint8_t*)dc->name_uc.Buffer, dc->name_uc.Length);
1879 
1880  locked = ExIsResourceAcquiredExclusive(&fcb->nonpaged->dir_children_lock);
1881 
1882  if (!locked)
1883  ExAcquireResourceExclusiveLite(&fcb->nonpaged->dir_children_lock, true);
1884 
1886  dc->index = 2;
1887  else {
1888  dir_child* dc2 = CONTAINING_RECORD(fcb->dir_children_index.Blink, dir_child, list_entry_index);
1889 
1890  dc->index = max(2, dc2->index + 1);
1891  }
1892 
1893  InsertTailList(&fcb->dir_children_index, &dc->list_entry_index);
1894 
1896 
1897  if (!locked)
1898  ExReleaseResourceLite(&fcb->nonpaged->dir_children_lock);
1899 
1900  *pdc = dc;
1901 
1902  return STATUS_SUCCESS;
1903 }
#define max(a, b)
Definition: svc.c:63
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
Iosb Status
Definition: create.c:4311
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
LONG NTSTATUS
Definition: precomp.h:26
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
static uint32_t calc_crc32c(uint32_t seed, uint8_t *msg, ULONG msglen)
Definition: recv.cpp:134
Definition: fs.h:78
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define ALLOC_TAG
Definition: btrfs_drv.h:91
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY dir_children_index
Definition: btrfs_drv.h:310
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
uint64_t index
Definition: btrfs_drv.h:248
#define TYPE_INODE_ITEM
Definition: btrfs.h:19
BYTE uint8_t
Definition: msvideo1.c:66
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
struct _fcb_nonpaged * nonpaged
Definition: btrfs_drv.h:280
#define TYPE_ROOT_ITEM
Definition: btrfs.h:28
void insert_dir_child_into_hash_lists(fcb *fcb, dir_child *dc)
Definition: fileinfo.c:1417
Definition: name.c:38
static const WCHAR dc[]
#define ExIsResourceAcquiredExclusive
Definition: exfuncs.h:347
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by create_subvol(), do_create_snapshot(), file_create2(), mknod(), and set_link_information().

◆ add_extent()

void add_extent ( _In_ fcb fcb,
_In_ LIST_ENTRY prevextle,
_In_ __drv_aliasesMem extent newext 
)

Definition at line 2351 of file write.c.

2351  {
2352  LIST_ENTRY* le = prevextle->Flink;
2353 
2354  while (le != &fcb->extents) {
2356 
2357  if (ext->offset >= newext->offset) {
2358  InsertHeadList(ext->list_entry.Blink, &newext->list_entry);
2359  return;
2360  }
2361 
2362  le = le->Flink;
2363  }
2364 
2365  InsertTailList(&fcb->extents, &newext->list_entry);
2366 }
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
#define InsertTailList(ListHead, Entry)
char ext[3]
Definition: mkdosfs.c:358
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
LIST_ENTRY extents
Definition: btrfs_drv.h:296
Definition: typedefs.h:117
Definition: list.h:27

Referenced by do_write_file_prealloc(), duplicate_extents(), and excise_extents().

◆ add_extent_to_fcb()

NTSTATUS add_extent_to_fcb ( _In_ fcb fcb,
_In_ uint64_t  offset,
_In_reads_bytes_(edsize) EXTENT_DATA ed,
_In_ uint16_t  edsize,
_In_ bool  unique,
_In_opt_ _When_(return >=0, __drv_aliasesMem) uint32_t csum,
_In_ LIST_ENTRY rollback 
)

Definition at line 2720 of file write.c.

2721  {
2722  extent* ext;
2723  LIST_ENTRY* le;
2724 
2726  if (!ext) {
2727  ERR("out of memory\n");
2729  }
2730 
2731  ext->offset = offset;
2732  ext->datalen = edsize;
2733  ext->unique = unique;
2734  ext->ignore = false;
2735  ext->inserted = true;
2736  ext->csum = csum;
2737 
2738  RtlCopyMemory(&ext->extent_data, ed, edsize);
2739 
2740  le = fcb->extents.Flink;
2741  while (le != &fcb->extents) {
2742  extent* oldext = CONTAINING_RECORD(le, extent, list_entry);
2743 
2744  if (oldext->offset >= offset) {
2745  InsertHeadList(le->Blink, &ext->list_entry);
2746  goto end;
2747  }
2748 
2749  le = le->Flink;
2750  }
2751 
2752  InsertTailList(&fcb->extents, &ext->list_entry);
2753 
2754 end:
2756 
2757  return STATUS_SUCCESS;
2758 }
void add_insert_extent_rollback(LIST_ENTRY *rollback, fcb *fcb, extent *ext)
Definition: write.c:2701
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
GLintptr offset
Definition: glext.h:5920
GLuint GLuint end
Definition: gl.h:1545
#define InsertTailList(ListHead, Entry)
#define ALLOC_TAG
Definition: btrfs_drv.h:91
uint64_t offset
Definition: btrfs_drv.h:224
#define offsetof(TYPE, MEMBER)
char ext[3]
Definition: mkdosfs.c:358
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
uint32_t * csum
Definition: write.c:2821
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY * rollback
Definition: write.c:2814
LIST_ENTRY extents
Definition: btrfs_drv.h:296
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Definition: typedefs.h:117
uint16_t edsize
Definition: write.c:2820
#define ERR(fmt,...)
Definition: debug.h:109
ed2 offset
Definition: write.c:2845
Definition: list.h:27
_ForwardIter unique(_ForwardIter __first, _ForwardIter __last)
Definition: _algo.h:298
return STATUS_SUCCESS
Definition: btrfs.c:2938
EXTENT_DATA * ed
Definition: write.c:2818

Referenced by duplicate_extents(), extend_file(), rename_stream_to_file(), truncate_file(), write_file2(), and zero_data().

◆ add_group_mapping()

void add_group_mapping ( WCHAR sidstring,
ULONG  sidstringlength,
uint32_t  gid 
)

Definition at line 145 of file security.c.

145  {
146  unsigned int i, np;
147  uint8_t numdashes;
148  uint64_t val;
149  ULONG sidsize;
150  sid_header* sid;
151  gid_map* gm;
152 
153  if (sidstringlength < 4 || sidstring[0] != 'S' || sidstring[1] != '-' || sidstring[2] != '1' || sidstring[3] != '-') {
154  ERR("invalid SID\n");
155  return;
156  }
157 
158  sidstring = &sidstring[4];
159  sidstringlength -= 4;
160 
161  numdashes = 0;
162  for (i = 0; i < sidstringlength; i++) {
163  if (sidstring[i] == '-') {
164  numdashes++;
165  sidstring[i] = 0;
166  }
167  }
168 
169  sidsize = 8 + (numdashes * 4);
171  if (!sid) {
172  ERR("out of memory\n");
173  return;
174  }
175 
176  sid->revision = 0x01;
177  sid->elements = numdashes;
178 
179  np = 0;
180  while (sidstringlength > 0) {
181  val = 0;
182  i = 0;
183  while (sidstring[i] != '-' && i < sidstringlength) {
184  if (sidstring[i] >= '0' && sidstring[i] <= '9') {
185  val *= 10;
186  val += sidstring[i] - '0';
187  } else
188  break;
189 
190  i++;
191  }
192 
193  i++;
194  TRACE("val = %u, i = %u, ssl = %u\n", (uint32_t)val, i, sidstringlength);
195 
196  if (np == 0) {
197  sid->auth[0] = (uint8_t)((val & 0xff0000000000) >> 40);
198  sid->auth[1] = (uint8_t)((val & 0xff00000000) >> 32);
199  sid->auth[2] = (uint8_t)((val & 0xff000000) >> 24);
200  sid->auth[3] = (uint8_t)((val & 0xff0000) >> 16);
201  sid->auth[4] = (uint8_t)((val & 0xff00) >> 8);
202  sid->auth[5] = val & 0xff;
203  } else
204  sid->nums[np-1] = (uint32_t)val;
205 
206  np++;
207 
208  if (sidstringlength > i) {
209  sidstringlength -= i;
210 
211  sidstring = &sidstring[i];
212  } else
213  break;
214  }
215 
217  if (!gm) {
218  ERR("out of memory\n");
219  ExFreePool(sid);
220  return;
221  }
222 
223  gm->sid = sid;
224  gm->gid = gid;
225 
227 }
FT_UInt sid
Definition: cffcmap.c:139
#define InsertTailList(ListHead, Entry)
PSID sid
Definition: btrfs_drv.h:885
#define ALLOC_TAG
Definition: btrfs_drv.h:91
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
LIST_ENTRY listentry
Definition: btrfs_drv.h:884
BYTE uint8_t
Definition: msvideo1.c:66
#define ERR(fmt,...)
Definition: debug.h:109
uint32_t gid
Definition: btrfs_drv.h:886
UINT64 uint64_t
Definition: types.h:77
#define uint8_t
Definition: nsiface.idl:59
LIST_ENTRY gid_map_list
Definition: btrfs.c:72
UINT32 uint32_t
Definition: types.h:75
unsigned int ULONG
Definition: retypes.h:1
#define uint32_t
Definition: nsiface.idl:61
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by read_group_mappings().

◆ add_insert_extent_rollback()

void add_insert_extent_rollback ( LIST_ENTRY rollback,
fcb fcb,
extent ext 
)

Definition at line 2701 of file write.c.

2701  {
2702  rollback_extent* re;
2703 
2705  if (!re) {
2706  ERR("out of memory\n");
2707  return;
2708  }
2709 
2710  re->fcb = fcb;
2711  re->ext = ext;
2712 
2714 }
#define ALLOC_TAG
Definition: btrfs_drv.h:91
char ext[3]
Definition: mkdosfs.c:358
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY * rollback
Definition: write.c:2814
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ERR(fmt,...)
Definition: debug.h:109
extent * ext
Definition: btrfs_drv.h:1221
_In_ fcb * fcb
Definition: write.c:2814
void add_rollback(_In_ LIST_ENTRY *rollback, _In_ enum rollback_type type, _In_ __drv_aliasesMem void *ptr)
Definition: treefuncs.c:836

Referenced by add_extent_to_fcb(), and do_write_file_prealloc().

◆ add_rollback()

void add_rollback ( _In_ LIST_ENTRY rollback,
_In_ enum rollback_type  type,
_In_ __drv_aliasesMem void ptr 
)

Definition at line 836 of file treefuncs.c.

836  {
837  rollback_item* ri;
838 
840  if (!ri) {
841  ERR("out of memory\n");
842  return;
843  }
844 
845  ri->type = type;
846  ri->ptr = ptr;
848 }
enum rollback_type type
Definition: btrfs_drv.h:1232
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define InsertTailList(ListHead, Entry)
#define ALLOC_TAG
Definition: btrfs_drv.h:91
static PVOID ptr
Definition: dispmode.c:27
LIST_ENTRY list_entry
Definition: btrfs_drv.h:1234
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ERR(fmt,...)
Definition: debug.h:109
_In_ fcb _In_ chunk _In_ uint64_t _In_ uint64_t _In_ bool _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY * rollback
Definition: btrfs_drv.h:1314

Referenced by add_insert_extent_rollback(), add_rollback_space(), and remove_fcb_extent().

◆ add_space_entry()

NTSTATUS add_space_entry ( LIST_ENTRY list,
LIST_ENTRY list_size,
uint64_t  offset,
uint64_t  size 
)

Definition at line 189 of file free-space.c.

189  {
190  space* s;
191 
193 
194  if (!s) {
195  ERR("out of memory\n");
197  }
198 
199  s->address = offset;
200  s->size = size;
201 
202  if (IsListEmpty(list))
203  InsertTailList(list, &s->list_entry);
204  else {
206 
207  if (s2->address < offset)
208  InsertTailList(list, &s->list_entry);
209  else {
210  LIST_ENTRY* le;
211 
212  le = list->Flink;
213  while (le != list) {
215 
216  if (s2->address > offset) {
217  InsertTailList(le, &s->list_entry);
218  goto size;
219  }
220 
221  le = le->Flink;
222  }
223  }
224  }
225 
226 size:
227  if (!list_size)
228  return STATUS_SUCCESS;
229 
230  if (IsListEmpty(list_size))
231  InsertTailList(list_size, &s->list_entry_size);
232  else {
233  space* s2 = CONTAINING_RECORD(list_size->Blink, space, list_entry_size);
234 
235  if (s2->size >= size)
236  InsertTailList(list_size, &s->list_entry_size);
237  else {
238  LIST_ENTRY* le;
239 
240  le = list_size->Flink;
241  while (le != list_size) {
242  s2 = CONTAINING_RECORD(le, space, list_entry_size);
243 
244  if (s2->size <= size) {
245  InsertHeadList(le->Blink, &s->list_entry_size);
246  return STATUS_SUCCESS;
247  }
248 
249  le = le->Flink;
250  }
251  }
252  }
253 
254  return STATUS_SUCCESS;
255 }
struct S2 s2
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
GLintptr offset
Definition: glext.h:5920
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define ALLOC_TAG
Definition: btrfs_drv.h:91
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
GLsizeiptr size
Definition: glext.h:5919
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
GLdouble s
Definition: gl.h:2039
Definition: _list.h:228
Definition: typedefs.h:117
#define ERR(fmt,...)
Definition: debug.h:109
Definition: list.h:27
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by add_device(), find_disk_holes(), load_free_space_bitmap(), load_stored_free_space_cache(), and load_stored_free_space_tree().

◆ add_thread_job()

bool add_thread_job ( device_extension Vcb,
PIRP  Irp 
)

Definition at line 109 of file worker-thread.c.

109  {
110  job_info* ji;
111 
113  if (!ji) {
114  ERR("out of memory\n");
115  return false;
116  }
117 
118  ji->Vcb = Vcb;
119  ji->Irp = Irp;
120 
121  if (!Irp->MdlAddress) {
122  PMDL Mdl;
124  ULONG len;
126 
127  if (IrpSp->MajorFunction == IRP_MJ_READ) {
128  op = IoWriteAccess;
129  len = IrpSp->Parameters.Read.Length;
130  } else if (IrpSp->MajorFunction == IRP_MJ_WRITE) {
131  op =