ReactOS  0.4.15-dev-1384-g878186b
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 "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_LX_SYMLINK   0xa000001d
 
#define IO_REPARSE_TAG_AF_UNIX   0x80000023
 
#define IO_REPARSE_TAG_LX_FIFO   0x80000024
 
#define IO_REPARSE_TAG_LX_CHR   0x80000025
 
#define IO_REPARSE_TAG_LX_BLK   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 FILE_CS_FLAG_CASE_SENSITIVE_DIR   1
 
#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 _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 MAX_HASH_SIZE   32
 
#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 __attribute__(x)
 
#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 SHA256_HASH_SIZE   32
 
#define BLAKE2_HASH_SIZE   32
 
#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  calc_thread_type {
  calc_thread_crc32c, calc_thread_xxhash, calc_thread_sha256, calc_thread_blake2,
  calc_thread_decomp_zlib, calc_thread_decomp_lzo, calc_thread_decomp_zstd, calc_thread_comp_zlib,
  calc_thread_comp_lzo, calc_thread_comp_zstd
}
 
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)
 
bool check_superblock_checksum (superblock *sb)
 
void init_fast_io_dispatch (FAST_IO_DISPATCH **fiod)
 
void calc_sha256 (uint8_t *hash, const void *input, size_t len)
 
void blake2b (void *out, size_t outlen, const void *in, size_t inlen)
 
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)
 
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)
 
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) void *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, void *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, void *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)
 
void calc_tree_checksum (device_extension *Vcb, tree_header *th)
 
 _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) void *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, void *csum)
 
void raid6_recover2 (uint8_t *sectors, uint16_t num_stripes, ULONG sector_size, uint16_t missing1, uint16_t missing2, uint8_t *out)
 
void get_tree_checksum (device_extension *Vcb, tree_header *th, void *csum)
 
bool check_tree_checksum (device_extension *Vcb, tree_header *th)
 
void get_sector_csum (device_extension *Vcb, void *buf, void *csum)
 
bool check_sector_csum (device_extension *Vcb, void *buf, void *csum)
 
 _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 (fcb *fcb, uint64_t start_data, uint64_t end_data, void *data, PIRP Irp, LIST_ENTRY *rollback)
 
NTSTATUS zlib_compress (uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, unsigned int level, unsigned int *space_left)
 
NTSTATUS lzo_compress (uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, unsigned int *space_left)
 
NTSTATUS zstd_compress (uint8_t *inbuf, uint32_t inlen, uint8_t *outbuf, uint32_t outlen, uint32_t level, unsigned int *space_left)
 
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
 
void do_calc_job (device_extension *Vcb, uint8_t *data, uint32_t sectors, void *csum)
 
NTSTATUS add_calc_job_decomp (device_extension *Vcb, uint8_t compression, void *in, unsigned int inlen, void *out, unsigned int outlen, unsigned int off, calc_job **pcj)
 
NTSTATUS add_calc_job_comp (device_extension *Vcb, uint8_t compression, void *in, unsigned int inlen, void *out, unsigned int outlen, calc_job **pcj)
 
void calc_thread_main (device_extension *Vcb, 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)
 
void boot_add_device (DEVICE_OBJECT *pdo)
 
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
 
BTRFS_UUID boot_uuid
 

Macro Definition Documentation

◆ __attribute__

Definition at line 1197 of file btrfs_drv.h.

◆ __drv_aliasesMem

#define __drv_aliasesMem

Definition at line 205 of file btrfs_drv.h.

◆ __S_IFBLK

#define __S_IFBLK   0060000 /* Block device. */

Definition at line 1802 of file btrfs_drv.h.

◆ __S_IFCHR

#define __S_IFCHR   0020000 /* Character device. */

Definition at line 1801 of file btrfs_drv.h.

◆ __S_IFDIR

#define __S_IFDIR   0040000 /* Directory. */

Definition at line 1800 of file btrfs_drv.h.

◆ __S_IFIFO

#define __S_IFIFO   0010000 /* FIFO. */

Definition at line 1804 of file btrfs_drv.h.

◆ __S_IFLNK

#define __S_IFLNK   0120000 /* Symbolic link. */

Definition at line 1805 of file btrfs_drv.h.

◆ __S_IFMT

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

Definition at line 1799 of file btrfs_drv.h.

◆ __S_IFREG

#define __S_IFREG   0100000 /* Regular file. */

Definition at line 1803 of file btrfs_drv.h.

◆ __S_IFSOCK

#define __S_IFSOCK   0140000 /* Socket. */

Definition at line 1806 of file btrfs_drv.h.

◆ __S_ISTYPE

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

Definition at line 1807 of file btrfs_drv.h.

◆ _Acquires_exclusive_lock_

#define _Acquires_exclusive_lock_ (   a)

Definition at line 215 of file btrfs_drv.h.

◆ _Acquires_shared_lock_

#define _Acquires_shared_lock_ (   a)

Definition at line 216 of file btrfs_drv.h.

◆ _Create_lock_level_

#define _Create_lock_level_ (   a)

Definition at line 211 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 210 of file btrfs_drv.h.

◆ _Has_lock_level_

#define _Has_lock_level_ (   a)

Definition at line 213 of file btrfs_drv.h.

◆ _Lock_level_order_

#define _Lock_level_order_ (   a,
  b 
)

Definition at line 212 of file btrfs_drv.h.

◆ _NO_CRT_STDIO_INLINE

#define _NO_CRT_STDIO_INLINE

Definition at line 27 of file btrfs_drv.h.

◆ _Releases_exclusive_lock_

#define _Releases_exclusive_lock_ (   a)

Definition at line 209 of file btrfs_drv.h.

◆ _Releases_lock_

#define _Releases_lock_ (   a)

Definition at line 208 of file btrfs_drv.h.

◆ _Requires_exclusive_lock_held_

#define _Requires_exclusive_lock_held_ (   a)

Definition at line 207 of file btrfs_drv.h.

◆ _Requires_lock_held_

#define _Requires_lock_held_ (   a)

Definition at line 206 of file btrfs_drv.h.

◆ _Requires_lock_not_held_

#define _Requires_lock_not_held_ (   a)

Definition at line 214 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 1137 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 701 of file btrfs_drv.h.

◆ BALANCE_OPTS_METADATA

#define BALANCE_OPTS_METADATA   1

Definition at line 702 of file btrfs_drv.h.

◆ BALANCE_OPTS_SYSTEM

#define BALANCE_OPTS_SYSTEM   2

Definition at line 703 of file btrfs_drv.h.

◆ BLAKE2_HASH_SIZE

#define BLAKE2_HASH_SIZE   32

Definition at line 1252 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 131 of file btrfs_drv.h.

◆ CC_ENABLE_DISK_IO_ACCOUNTING

#define CC_ENABLE_DISK_IO_ACCOUNTING   0x00000010

Definition at line 1891 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 1234 of file btrfs_drv.h.

◆ except

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

Definition at line 139 of file btrfs_drv.h.

◆ FILE_CS_FLAG_CASE_SENSITIVE_DIR

#define FILE_CS_FLAG_CASE_SENSITIVE_DIR   1

Definition at line 167 of file btrfs_drv.h.

◆ FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL

#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL   0x00020000

Definition at line 158 of file btrfs_drv.h.

◆ FILE_SUPPORTS_BLOCK_REFCOUNTING

#define FILE_SUPPORTS_BLOCK_REFCOUNTING   0x08000000

Definition at line 150 of file btrfs_drv.h.

◆ FILE_SUPPORTS_POSIX_UNLINK_RENAME

#define FILE_SUPPORTS_POSIX_UNLINK_RENAME   0x00000400

Definition at line 154 of file btrfs_drv.h.

◆ finally

#define finally   if (1)

Definition at line 140 of file btrfs_drv.h.

◆ FIXME

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

Definition at line 1233 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 184 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 200 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 201 of file btrfs_drv.h.

◆ FSRTL_FCB_HEADER_V2

#define FSRTL_FCB_HEADER_V2   2

Definition at line 1661 of file btrfs_drv.h.

◆ funcname

#define funcname   __func__

Definition at line 1175 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 1794 of file btrfs_drv.h.

◆ increase_fileref_refcount

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

Definition at line 1785 of file btrfs_drv.h.

◆ int3

#define int3   asm("int3;")

Definition at line 1791 of file btrfs_drv.h.

◆ IO_REPARSE_TAG_AF_UNIX

#define IO_REPARSE_TAG_AF_UNIX   0x80000023

Definition at line 124 of file btrfs_drv.h.

◆ IO_REPARSE_TAG_LX_BLK

#define IO_REPARSE_TAG_LX_BLK   0x80000026

Definition at line 127 of file btrfs_drv.h.

◆ IO_REPARSE_TAG_LX_CHR

#define IO_REPARSE_TAG_LX_CHR   0x80000025

Definition at line 126 of file btrfs_drv.h.

◆ IO_REPARSE_TAG_LX_FIFO

#define IO_REPARSE_TAG_LX_FIFO   0x80000024

Definition at line 125 of file btrfs_drv.h.

◆ IO_REPARSE_TAG_LX_SYMLINK

#define IO_REPARSE_TAG_LX_SYMLINK   0xa000001d

Definition at line 122 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 1024 of file btrfs_drv.h.

◆ major

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

Definition at line 1867 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 1643 of file btrfs_drv.h.

◆ MAX_EXTENT_SIZE

#define MAX_EXTENT_SIZE   0x8000000

Definition at line 115 of file btrfs_drv.h.

◆ MAX_HASH_SIZE

#define MAX_HASH_SIZE   32

Definition at line 224 of file btrfs_drv.h.

◆ minor

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

Definition at line 1868 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 1138 of file btrfs_drv.h.

◆ S_IRGRP

#define S_IRGRP   (S_IRUSR >> 3)

Definition at line 1831 of file btrfs_drv.h.

◆ S_IROTH

#define S_IROTH   (S_IRGRP >> 3)

Definition at line 1843 of file btrfs_drv.h.

◆ S_IRUSR

#define S_IRUSR   0000400

Definition at line 1814 of file btrfs_drv.h.

◆ S_ISDIR

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

Definition at line 1810 of file btrfs_drv.h.

◆ S_ISGID

#define S_ISGID   0002000

Definition at line 1859 of file btrfs_drv.h.

◆ S_ISUID

#define S_ISUID   0004000

Definition at line 1855 of file btrfs_drv.h.

◆ S_ISVTX

#define S_ISVTX   0001000

Definition at line 1863 of file btrfs_drv.h.

◆ S_IWGRP

#define S_IWGRP   (S_IWUSR >> 3)

Definition at line 1835 of file btrfs_drv.h.

◆ S_IWOTH

#define S_IWOTH   (S_IWGRP >> 3)

Definition at line 1847 of file btrfs_drv.h.

◆ S_IWUSR

#define S_IWUSR   0000200

Definition at line 1818 of file btrfs_drv.h.

◆ S_IXGRP

#define S_IXGRP   (S_IXUSR >> 3)

Definition at line 1839 of file btrfs_drv.h.

◆ S_IXOTH

#define S_IXOTH   (S_IXGRP >> 3)

Definition at line 1851 of file btrfs_drv.h.

◆ S_IXUSR

#define S_IXUSR   0000100

Definition at line 1822 of file btrfs_drv.h.

◆ SHA256_HASH_SIZE

#define SHA256_HASH_SIZE   32

Definition at line 1248 of file btrfs_drv.h.

◆ TRACE

#define TRACE (   s,
  ... 
)

Definition at line 1231 of file btrfs_drv.h.

◆ try

#define try   if (1)

Definition at line 138 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 699 of file btrfs_drv.h.

◆ VCB_TYPE_CONTROL

#define VCB_TYPE_CONTROL   2

Definition at line 696 of file btrfs_drv.h.

◆ VCB_TYPE_FS

#define VCB_TYPE_FS   1

Definition at line 695 of file btrfs_drv.h.

◆ VCB_TYPE_PDO

#define VCB_TYPE_PDO   4

Definition at line 698 of file btrfs_drv.h.

◆ VCB_TYPE_VOLUME

#define VCB_TYPE_VOLUME   3

Definition at line 697 of file btrfs_drv.h.

◆ WARN

#define WARN (   s,
  ... 
)

Definition at line 1232 of file btrfs_drv.h.

Typedef Documentation

◆ ccb

typedef struct _ccb ccb

◆ device_extension

◆ DUPLICATE_EXTENTS_DATA

◆ fcb

Definition at line 1357 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 1951 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 1884 of file btrfs_drv.h.

◆ tCcSetAdditionalCacheAttributesEx

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

Definition at line 1899 of file btrfs_drv.h.

◆ tFsRtlAreThereCurrentOrInProgressFileLocks

typedef BOOLEAN(__stdcall * tFsRtlAreThereCurrentOrInProgressFileLocks) (PFILE_LOCK FileLock)

Definition at line 1914 of file btrfs_drv.h.

◆ tFsRtlCheckLockForOplockRequest

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

Definition at line 1912 of file btrfs_drv.h.

◆ tFsRtlGetEcpListFromIrp

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

Definition at line 1905 of file btrfs_drv.h.

◆ tFsRtlGetNextExtraCreateParameter

Definition at line 1907 of file btrfs_drv.h.

◆ tFsRtlUpdateDiskCounters

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

Definition at line 1901 of file btrfs_drv.h.

◆ tFsRtlValidateReparsePointBuffer

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

Definition at line 1910 of file btrfs_drv.h.

◆ tIoUnregisterPlugPlayNotificationEx

typedef NTSTATUS(__stdcall * tIoUnregisterPlugPlayNotificationEx) (PVOID NotificationEntry)

Definition at line 1903 of file btrfs_drv.h.

◆ tPsIsDiskCountersEnabled

typedef BOOLEAN(__stdcall * tPsIsDiskCountersEnabled) ()

Definition at line 1879 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 1881 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 486 of file btrfs_drv.h.

◆ calc_thread_type

Enumerator
calc_thread_crc32c 
calc_thread_xxhash 
calc_thread_sha256 
calc_thread_blake2 
calc_thread_decomp_zlib 
calc_thread_decomp_lzo 
calc_thread_decomp_zstd 
calc_thread_comp_zlib 
calc_thread_comp_lzo 
calc_thread_comp_zstd 

Definition at line 636 of file btrfs_drv.h.

◆ prop_compression_type

Enumerator
PropCompression_None 
PropCompression_Zlib 
PropCompression_LZO 
PropCompression_ZSTD 

Definition at line 278 of file btrfs_drv.h.

◆ rollback_type

Enumerator
ROLLBACK_INSERT_EXTENT 
ROLLBACK_DELETE_EXTENT 
ROLLBACK_ADD_SPACE 
ROLLBACK_SUBTRACT_SPACE 

Definition at line 1267 of file btrfs_drv.h.

◆ write_data_status

Enumerator
WriteDataStatus_Pending 
WriteDataStatus_Success 
WriteDataStatus_Error 
WriteDataStatus_Cancelling 
WriteDataStatus_Cancelled 
WriteDataStatus_Ignore 

Definition at line 922 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 3051 of file balance.c.

3052  {
3054  LIST_ENTRY chunks;
3055  LIST_ENTRY* le;
3056  uint64_t num_chunks[3], okay_metadata_chunks = 0, okay_data_chunks = 0, okay_system_chunks = 0;
3057  uint64_t old_data_flags = 0, old_metadata_flags = 0, old_system_flags = 0;
3058  NTSTATUS Status;
3059 
3060  Vcb->balance.balance_num++;
3061 
3062  Vcb->balance.stopping = false;
3063  KeInitializeEvent(&Vcb->balance.finished, NotificationEvent, false);
3064 
3065  if (Vcb->balance.opts[BALANCE_OPTS_DATA].flags & BTRFS_BALANCE_OPTS_ENABLED && Vcb->balance.opts[BALANCE_OPTS_DATA].flags & BTRFS_BALANCE_OPTS_CONVERT) {
3066  old_data_flags = Vcb->data_flags;
3067  Vcb->data_flags = BLOCK_FLAG_DATA | (Vcb->balance.opts[BALANCE_OPTS_DATA].convert == BLOCK_FLAG_SINGLE ? 0 : Vcb->balance.opts[BALANCE_OPTS_DATA].convert);
3068 
3070  }
3071 
3072  if (Vcb->balance.opts[BALANCE_OPTS_METADATA].flags & BTRFS_BALANCE_OPTS_ENABLED && Vcb->balance.opts[BALANCE_OPTS_METADATA].flags & BTRFS_BALANCE_OPTS_CONVERT) {
3073  old_metadata_flags = Vcb->metadata_flags;
3074  Vcb->metadata_flags = BLOCK_FLAG_METADATA | (Vcb->balance.opts[BALANCE_OPTS_METADATA].convert == BLOCK_FLAG_SINGLE ? 0 : Vcb->balance.opts[BALANCE_OPTS_METADATA].convert);
3075  }
3076 
3077  if (Vcb->balance.opts[BALANCE_OPTS_SYSTEM].flags & BTRFS_BALANCE_OPTS_ENABLED && Vcb->balance.opts[BALANCE_OPTS_SYSTEM].flags & BTRFS_BALANCE_OPTS_CONVERT) {
3078  old_system_flags = Vcb->system_flags;
3079  Vcb->system_flags = BLOCK_FLAG_SYSTEM | (Vcb->balance.opts[BALANCE_OPTS_SYSTEM].convert == BLOCK_FLAG_SINGLE ? 0 : Vcb->balance.opts[BALANCE_OPTS_SYSTEM].convert);
3080  }
3081 
3082  if (Vcb->superblock.incompat_flags & BTRFS_INCOMPAT_FLAGS_MIXED_GROUPS) {
3083  if (Vcb->balance.opts[BALANCE_OPTS_DATA].flags & BTRFS_BALANCE_OPTS_ENABLED)
3084  RtlCopyMemory(&Vcb->balance.opts[BALANCE_OPTS_METADATA], &Vcb->balance.opts[BALANCE_OPTS_DATA], sizeof(btrfs_balance_opts));
3085  else if (Vcb->balance.opts[BALANCE_OPTS_METADATA].flags & BTRFS_BALANCE_OPTS_ENABLED)
3086  RtlCopyMemory(&Vcb->balance.opts[BALANCE_OPTS_DATA], &Vcb->balance.opts[BALANCE_OPTS_METADATA], sizeof(btrfs_balance_opts));
3087  }
3088 
3089  num_chunks[0] = num_chunks[1] = num_chunks[2] = 0;
3090  Vcb->balance.total_chunks = Vcb->balance.chunks_left = 0;
3091 
3092  InitializeListHead(&chunks);
3093 
3094  // FIXME - what are we supposed to do with limit_start?
3095 
3096  if (!Vcb->readonly) {
3097  if (!Vcb->balance.removing && !Vcb->balance.shrinking) {
3099  if (!NT_SUCCESS(Status)) {
3100  ERR("add_balance_item returned %08lx\n", Status);
3101  Vcb->balance.status = Status;
3102  goto end;
3103  }
3104  } else {
3105  if (Vcb->need_write) {
3106  Status = do_write(Vcb, NULL);
3107 
3108  free_trees(Vcb);
3109 
3110  if (!NT_SUCCESS(Status)) {
3111  ERR("do_write returned %08lx\n", Status);
3112  Vcb->balance.status = Status;
3113  goto end;
3114  }
3115  }
3116  }
3117  }
3118 
3119  KeWaitForSingleObject(&Vcb->balance.event, Executive, KernelMode, false, NULL);
3120 
3121  if (Vcb->balance.stopping)
3122  goto end;
3123 
3124  ExAcquireResourceSharedLite(&Vcb->chunk_lock, true);
3125 
3126  le = Vcb->chunks.Flink;
3127  while (le != &Vcb->chunks) {
3129  uint8_t sort;
3130 
3132 
3133  if (c->chunk_item->type & BLOCK_FLAG_DATA)
3135  else if (c->chunk_item->type & BLOCK_FLAG_METADATA)
3137  else if (c->chunk_item->type & BLOCK_FLAG_SYSTEM)
3139  else {
3140  ERR("unexpected chunk type %I64x\n", c->chunk_item->type);
3142  break;
3143  }
3144 
3145  if ((!(Vcb->balance.opts[sort].flags & BTRFS_BALANCE_OPTS_LIMIT) || num_chunks[sort] < Vcb->balance.opts[sort].limit_end) &&
3147  InsertTailList(&chunks, &c->list_entry_balance);
3148 
3149  num_chunks[sort]++;
3150  Vcb->balance.total_chunks++;
3151  Vcb->balance.chunks_left++;
3152  } else if (sort == BALANCE_OPTS_METADATA)
3153  okay_metadata_chunks++;
3154  else if (sort == BALANCE_OPTS_DATA)
3155  okay_data_chunks++;
3156  else if (sort == BALANCE_OPTS_SYSTEM)
3157  okay_system_chunks++;
3158 
3159  if (!c->cache_loaded) {
3161 
3162  if (!NT_SUCCESS(Status)) {
3163  ERR("load_cache_chunk returned %08lx\n", Status);
3164  Vcb->balance.status = Status;
3166  ExReleaseResourceLite(&Vcb->chunk_lock);
3167  goto end;
3168  }
3169  }
3170 
3172 
3173  le = le->Flink;
3174  }
3175 
3176  ExReleaseResourceLite(&Vcb->chunk_lock);
3177 
3178  // If we're doing a full balance, try and allocate a new chunk now, before we mess things up
3179  if (okay_metadata_chunks == 0 || okay_data_chunks == 0 || okay_system_chunks == 0) {
3180  bool consolidated = false;
3181  chunk* c;
3182 
3183  if (okay_metadata_chunks == 0) {
3184  ExAcquireResourceExclusiveLite(&Vcb->chunk_lock, true);
3185 
3186  Status = alloc_chunk(Vcb, Vcb->metadata_flags, &c, true);
3187  if (NT_SUCCESS(Status))
3188  c->balance_num = Vcb->balance.balance_num;
3189  else if (Status != STATUS_DISK_FULL || consolidated) {
3190  ERR("alloc_chunk returned %08lx\n", Status);
3191  ExReleaseResourceLite(&Vcb->chunk_lock);
3192  Vcb->balance.status = Status;
3193  goto end;
3194  }
3195 
3196  ExReleaseResourceLite(&Vcb->chunk_lock);
3197 
3198  if (Status == STATUS_DISK_FULL) {
3199  Status = try_consolidation(Vcb, Vcb->metadata_flags, &c);
3200  if (!NT_SUCCESS(Status)) {
3201  ERR("try_consolidation returned %08lx\n", Status);
3202  Vcb->balance.status = Status;
3203  goto end;
3204  } else
3205  c->balance_num = Vcb->balance.balance_num;
3206 
3207  consolidated = true;
3208 
3209  if (Vcb->balance.stopping)
3210  goto end;
3211  }
3212  }
3213 
3214  if (okay_data_chunks == 0) {
3215  ExAcquireResourceExclusiveLite(&Vcb->chunk_lock, true);
3216 
3217  Status = alloc_chunk(Vcb, Vcb->data_flags, &c, true);
3218  if (NT_SUCCESS(Status))
3219  c->balance_num = Vcb->balance.balance_num;
3220  else if (Status != STATUS_DISK_FULL || consolidated) {
3221  ERR("alloc_chunk returned %08lx\n", Status);
3222  ExReleaseResourceLite(&Vcb->chunk_lock);
3223  Vcb->balance.status = Status;
3224  goto end;
3225  }
3226 
3227  ExReleaseResourceLite(&Vcb->chunk_lock);
3228 
3229  if (Status == STATUS_DISK_FULL) {
3230  Status = try_consolidation(Vcb, Vcb->data_flags, &c);
3231  if (!NT_SUCCESS(Status)) {
3232  ERR("try_consolidation returned %08lx\n", Status);
3233  Vcb->balance.status = Status;
3234  goto end;
3235  } else
3236  c->balance_num = Vcb->balance.balance_num;
3237 
3238  consolidated = true;
3239 
3240  if (Vcb->balance.stopping)
3241  goto end;
3242  }
3243  }
3244 
3245  if (okay_system_chunks == 0) {
3246  ExAcquireResourceExclusiveLite(&Vcb->chunk_lock, true);
3247 
3248  Status = alloc_chunk(Vcb, Vcb->system_flags, &c, true);
3249  if (NT_SUCCESS(Status))
3250  c->balance_num = Vcb->balance.balance_num;
3251  else if (Status != STATUS_DISK_FULL || consolidated) {
3252  ERR("alloc_chunk returned %08lx\n", Status);
3253  ExReleaseResourceLite(&Vcb->chunk_lock);
3254  Vcb->balance.status = Status;
3255  goto end;
3256  }
3257 
3258  ExReleaseResourceLite(&Vcb->chunk_lock);
3259 
3260  if (Status == STATUS_DISK_FULL) {
3261  Status = try_consolidation(Vcb, Vcb->system_flags, &c);
3262  if (!NT_SUCCESS(Status)) {
3263  ERR("try_consolidation returned %08lx\n", Status);
3264  Vcb->balance.status = Status;
3265  goto end;
3266  } else
3267  c->balance_num = Vcb->balance.balance_num;
3268 
3269  consolidated = true;
3270 
3271  if (Vcb->balance.stopping)
3272  goto end;
3273  }
3274  }
3275  }
3276 
3277  ExAcquireResourceSharedLite(&Vcb->chunk_lock, true);
3278 
3279  le = chunks.Flink;
3280  while (le != &chunks) {
3281  chunk* c = CONTAINING_RECORD(le, chunk, list_entry_balance);
3282 
3283  c->reloc = true;
3284 
3285  le = le->Flink;
3286  }
3287 
3288  ExReleaseResourceLite(&Vcb->chunk_lock);
3289 
3290  // do data chunks before metadata
3291  le = chunks.Flink;
3292  while (le != &chunks) {
3293  chunk* c = CONTAINING_RECORD(le, chunk, list_entry_balance);
3294  LIST_ENTRY* le2 = le->Flink;
3295 
3296  if (c->chunk_item->type & BLOCK_FLAG_DATA) {
3297  bool changed;
3298 
3299  do {
3300  changed = false;
3301 
3302  Status = balance_data_chunk(Vcb, c, &changed);
3303  if (!NT_SUCCESS(Status)) {
3304  ERR("balance_data_chunk returned %08lx\n", Status);
3305  Vcb->balance.status = Status;
3306  goto end;
3307  }
3308 
3309  KeWaitForSingleObject(&Vcb->balance.event, Executive, KernelMode, false, NULL);
3310 
3311  if (Vcb->readonly)
3312  Vcb->balance.stopping = true;
3313 
3314  if (Vcb->balance.stopping)
3315  break;
3316  } while (changed);
3317 
3318  c->changed = true;
3319  c->space_changed = true;
3320  }
3321 
3322  if (Vcb->balance.stopping)
3323  goto end;
3324 
3325  if (c->chunk_item->type & BLOCK_FLAG_DATA &&
3326  (!(Vcb->balance.opts[BALANCE_OPTS_METADATA].flags & BTRFS_BALANCE_OPTS_ENABLED) || !(c->chunk_item->type & BLOCK_FLAG_METADATA))) {
3327  RemoveEntryList(&c->list_entry_balance);
3328  c->list_entry_balance.Flink = NULL;
3329 
3330  Vcb->balance.chunks_left--;
3331  }
3332 
3333  le = le2;
3334  }
3335 
3336  // do metadata chunks
3337  while (!IsListEmpty(&chunks)) {
3338  chunk* c;
3339  bool changed;
3340 
3341  le = RemoveHeadList(&chunks);
3342  c = CONTAINING_RECORD(le, chunk, list_entry_balance);
3343 
3344  if (c->chunk_item->type & BLOCK_FLAG_METADATA || c->chunk_item->type & BLOCK_FLAG_SYSTEM) {
3345  do {
3346  Status = balance_metadata_chunk(Vcb, c, &changed);
3347  if (!NT_SUCCESS(Status)) {
3348  ERR("balance_metadata_chunk returned %08lx\n", Status);
3349  Vcb->balance.status = Status;
3350  goto end;
3351  }
3352 
3353  KeWaitForSingleObject(&Vcb->balance.event, Executive, KernelMode, false, NULL);
3354 
3355  if (Vcb->readonly)
3356  Vcb->balance.stopping = true;
3357 
3358  if (Vcb->balance.stopping)
3359  break;
3360  } while (changed);
3361 
3362  c->changed = true;
3363  c->space_changed = true;
3364  }
3365 
3366  if (Vcb->balance.stopping)
3367  break;
3368 
3369  c->list_entry_balance.Flink = NULL;
3370 
3371  Vcb->balance.chunks_left--;
3372  }
3373 
3374 end:
3375  if (!Vcb->readonly) {
3376  if (Vcb->balance.stopping || !NT_SUCCESS(Vcb->balance.status)) {
3377  le = chunks.Flink;
3378  while (le != &chunks) {
3379  chunk* c = CONTAINING_RECORD(le, chunk, list_entry_balance);
3380  c->reloc = false;
3381 
3382  le = le->Flink;
3383  c->list_entry_balance.Flink = NULL;
3384  }
3385 
3386  if (old_data_flags != 0)
3387  Vcb->data_flags = old_data_flags;
3388 
3389  if (old_metadata_flags != 0)
3390  Vcb->metadata_flags = old_metadata_flags;
3391 
3392  if (old_system_flags != 0)
3393  Vcb->system_flags = old_system_flags;
3394  }
3395 
3396  if (Vcb->balance.removing) {
3397  device* dev = NULL;
3398 
3399  ExAcquireResourceExclusiveLite(&Vcb->tree_lock, true);
3400 
3401  le = Vcb->devices.Flink;
3402  while (le != &Vcb->devices) {
3403  device* dev2 = CONTAINING_RECORD(le, device, list_entry);
3404 
3405  if (dev2->devitem.dev_id == Vcb->balance.opts[0].devid) {
3406  dev = dev2;
3407  break;
3408  }
3409 
3410  le = le->Flink;
3411  }
3412 
3413  if (dev) {
3414  if (Vcb->balance.chunks_left == 0) {
3416 
3417  if (!NT_SUCCESS(Status)) {
3418  ERR("finish_removing_device returned %08lx\n", Status);
3419  dev->reloc = false;
3420  }
3421  } else
3422  dev->reloc = false;
3423  }
3424 
3425  ExReleaseResourceLite(&Vcb->tree_lock);
3426  } else if (Vcb->balance.shrinking) {
3427  device* dev = NULL;
3428 
3429  ExAcquireResourceExclusiveLite(&Vcb->tree_lock, true);
3430 
3431  le = Vcb->devices.Flink;
3432  while (le != &Vcb->devices) {
3433  device* dev2 = CONTAINING_RECORD(le, device, list_entry);
3434 
3435  if (dev2->devitem.dev_id == Vcb->balance.opts[0].devid) {
3436  dev = dev2;
3437  break;
3438  }
3439 
3440  le = le->Flink;
3441  }
3442 
3443  if (!dev) {
3444  ERR("could not find device %I64x\n", Vcb->balance.opts[0].devid);
3445  Vcb->balance.status = STATUS_INTERNAL_ERROR;
3446  }
3447 
3448  if (Vcb->balance.stopping || !NT_SUCCESS(Vcb->balance.status)) {
3449  if (dev) {
3451  if (!NT_SUCCESS(Status))
3452  WARN("regenerate_space_list returned %08lx\n", Status);
3453  }
3454  } else {
3455  uint64_t old_size;
3456 
3457  old_size = dev->devitem.num_bytes;
3458  dev->devitem.num_bytes = Vcb->balance.opts[0].drange_start;
3459 
3461  if (!NT_SUCCESS(Status)) {
3462  ERR("update_dev_item returned %08lx\n", Status);
3463  dev->devitem.num_bytes = old_size;
3464  Vcb->balance.status = Status;
3465 
3467  if (!NT_SUCCESS(Status))
3468  WARN("regenerate_space_list returned %08lx\n", Status);
3469  } else {
3470  Vcb->superblock.total_bytes -= old_size - dev->devitem.num_bytes;
3471 
3472  Status = do_write(Vcb, NULL);
3473  if (!NT_SUCCESS(Status))
3474  ERR("do_write returned %08lx\n", Status);
3475 
3476  free_trees(Vcb);
3477  }
3478  }
3479 
3480  ExReleaseResourceLite(&Vcb->tree_lock);
3481 
3482  if (!Vcb->balance.stopping && NT_SUCCESS(Vcb->balance.status))
3484  } else {
3486  if (!NT_SUCCESS(Status)) {
3487  ERR("remove_balance_item returned %08lx\n", Status);
3488  goto end;
3489  }
3490  }
3491 
3492  if (Vcb->trim && !Vcb->options.no_trim) {
3493  ExAcquireResourceExclusiveLite(&Vcb->tree_lock, true);
3494 
3495  le = Vcb->devices.Flink;
3496  while (le != &Vcb->devices) {
3497  device* dev2 = CONTAINING_RECORD(le, device, list_entry);
3498 
3499  if (dev2->devobj && !dev2->readonly && dev2->trim)
3500  trim_unalloc_space(Vcb, dev2);
3501 
3502  le = le->Flink;
3503  }
3504 
3505  ExReleaseResourceLite(&Vcb->tree_lock);
3506  }
3507  }
3508 
3509  ZwClose(Vcb->balance.thread);
3510  Vcb->balance.thread = NULL;
3511 
3512  KeSetEvent(&Vcb->balance.finished, 0, false);
3513 }
static bool should_balance_chunk(device_extension *Vcb, uint8_t sort, chunk *c)
Definition: balance.c:2229
#define BALANCE_OPTS_SYSTEM
Definition: btrfs_drv.h:703
Definition: http.c:7094
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:7789
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:534
#define WARN(fmt,...)
Definition: debug.h:112
LONG NTSTATUS
Definition: precomp.h:26
release_chunk_lock(c, Vcb)
bool readonly
Definition: btrfs_drv.h:539
#define InsertTailList(ListHead, Entry)
static NTSTATUS balance_metadata_chunk(device_extension *Vcb, chunk *c, bool *changed)
Definition: balance.c:1104
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:465
static NTSTATUS try_consolidation(device_extension *Vcb, uint64_t flags, chunk **newchunk)
Definition: balance.c:2906
#define BTRFS_BALANCE_OPTS_CONVERT
Definition: btrfsioctl.h:137
Definition: devices.h:37
#define BTRFS_INCOMPAT_FLAGS_MIXED_GROUPS
Definition: btrfs.h:110
#define BLOCK_FLAG_SYSTEM
Definition: shellext.h:76
bool trim
Definition: btrfs_drv.h:541
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
void free_trees(device_extension *Vcb)
Definition: treefuncs.c:794
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
Status
Definition: gdiplustypes.h:24
static NTSTATUS add_balance_item(device_extension *Vcb)
Definition: balance.c:2382
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
static NTSTATUS regenerate_space_list(device_extension *Vcb, device *dev)
Definition: balance.c:3001
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:1415
#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
GLuint GLuint end
Definition: gl.h:1545
NTSTATUS update_dev_item(device_extension *Vcb, device *device, PIRP Irp)
Definition: flushthread.c:4099
#define BTRFS_BALANCE_OPTS_ENABLED
Definition: btrfsioctl.h:129
#define BLOCK_FLAG_METADATA
Definition: shellext.h:77
uint64_t dev_id
Definition: btrfs.h:171
Definition: typedefs.h:119
BYTE uint8_t
Definition: msvideo1.c:66
NTSTATUS load_cache_chunk(device_extension *Vcb, chunk *c, PIRP Irp)
Definition: free-space.c:980
#define ERR(fmt,...)
Definition: debug.h:110
static NTSTATUS remove_balance_item(device_extension *Vcb)
Definition: balance.c:2455
static NTSTATUS balance_data_chunk(device_extension *Vcb, chunk *c, bool *changed)
Definition: balance.c:1675
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:1137
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
Definition: list.h:27
DEV_ITEM devitem
Definition: btrfs_drv.h:536
#define NULL
Definition: types.h:112
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:2590
#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:2806
#define c
Definition: ke_i.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define BALANCE_OPTS_METADATA
Definition: btrfs_drv.h:702
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:701

◆ _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 979 of file btrfs_drv.h.

981  {
982  ExReleaseResourceLite(&Vcb->fcb_lock);
983 }
#define Vcb
Definition: cdprocs.h:1415
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 967 of file btrfs_drv.h.

969  {
970  ExAcquireResourceSharedLite(&Vcb->fcb_lock, true);
971 }
#define Vcb
Definition: cdprocs.h:1415
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885

◆ _Success_()

_Success_ ( return  )

◆ add_calc_job_comp()

NTSTATUS add_calc_job_comp ( device_extension Vcb,
uint8_t  compression,
void in,
unsigned int  inlen,
void out,
unsigned int  outlen,
calc_job **  pcj 
)

Definition at line 237 of file calcthread.c.

238  {
239  calc_job* cj;
240  KIRQL irql;
241 
243  if (!cj) {
244  ERR("out of memory\n");
246  }
247 
248  cj->in = in;
249  cj->inlen = inlen;
250  cj->out = out;
251  cj->outlen = outlen;
252  cj->left = cj->not_started = 1;
253  cj->Status = STATUS_SUCCESS;
254 
255  switch (compression) {
257  cj->type = calc_thread_comp_zlib;
258  break;
259 
261  cj->type = calc_thread_comp_lzo;
262  break;
263 
265  cj->type = calc_thread_comp_zstd;
266  break;
267 
268  default:
269  ERR("unexpected compression type %x\n", compression);
270  ExFreePool(cj);
271  return STATUS_NOT_SUPPORTED;
272  }
273 
274  KeInitializeEvent(&cj->event, NotificationEvent, false);
275 
276  KeAcquireSpinLock(&Vcb->calcthreads.spinlock, &irql);
277 
278  InsertTailList(&Vcb->calcthreads.job_list, &cj->list_entry);
279 
280  KeSetEvent(&Vcb->calcthreads.event, 0, false);
281  KeClearEvent(&Vcb->calcthreads.event);
282 
283  KeReleaseSpinLock(&Vcb->calcthreads.spinlock, irql);
284 
285  *pcj = cj;
286 
287  return STATUS_SUCCESS;
288 }
return STATUS_NOT_SUPPORTED
_In_ ULONG cj
Definition: winddi.h:3540
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ ULONG * pcj
Definition: winddi.h:3642
KIRQL irql
Definition: wave.h:1
#define BTRFS_COMPRESSION_LZO
Definition: btrfs.h:63
#define BTRFS_COMPRESSION_ZSTD
Definition: btrfs.h:64
#define InsertTailList(ListHead, Entry)
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define BTRFS_COMPRESSION_ZLIB
Definition: btrfs.h:62
#define ALLOC_TAG
Definition: btrfs_drv.h:91
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define Vcb
Definition: cdprocs.h:1415
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
static FILE * out
Definition: regtests2xml.c:44
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_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
Definition: btrfs_drv.h:1357
#define ERR(fmt,...)
Definition: debug.h:110
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
GLuint in
Definition: glext.h:9616
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by write_compressed().

◆ add_calc_job_decomp()

NTSTATUS add_calc_job_decomp ( device_extension Vcb,
uint8_t  compression,
void in,
unsigned int  inlen,
void out,
unsigned int  outlen,
unsigned int  off,
calc_job **  pcj 
)

Definition at line 183 of file calcthread.c.

184  {
185  calc_job* cj;
186  KIRQL irql;
187 
189  if (!cj) {
190  ERR("out of memory\n");
192  }
193 
194  cj->in = in;
195  cj->inlen = inlen;
196  cj->out = out;
197  cj->outlen = outlen;
198  cj->off = off;
199  cj->left = cj->not_started = 1;
200  cj->Status = STATUS_SUCCESS;
201 
202  switch (compression) {
204  cj->type = calc_thread_decomp_zlib;
205  break;
206 
208  cj->type = calc_thread_decomp_lzo;
209  break;
210 
212  cj->type = calc_thread_decomp_zstd;
213  break;
214 
215  default:
216  ERR("unexpected compression type %x\n", compression);
217  ExFreePool(cj);
218  return STATUS_NOT_SUPPORTED;
219  }
220 
221  KeInitializeEvent(&cj->event, NotificationEvent, false);
222 
223  KeAcquireSpinLock(&Vcb->calcthreads.spinlock, &irql);
224 
225  InsertTailList(&Vcb->calcthreads.job_list, &cj->list_entry);
226 
227  KeSetEvent(&Vcb->calcthreads.event, 0, false);
228  KeClearEvent(&Vcb->calcthreads.event);
229 
230  KeReleaseSpinLock(&Vcb->calcthreads.spinlock, irql);
231 
232  *pcj = cj;
233 
234  return STATUS_SUCCESS;
235 }
return STATUS_NOT_SUPPORTED
_In_ ULONG cj
Definition: winddi.h:3540
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ ULONG * pcj
Definition: winddi.h:3642
KIRQL irql
Definition: wave.h:1
#define BTRFS_COMPRESSION_LZO
Definition: btrfs.h:63
#define BTRFS_COMPRESSION_ZSTD
Definition: btrfs.h:64
#define InsertTailList(ListHead, Entry)
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define BTRFS_COMPRESSION_ZLIB
Definition: btrfs.h:62
#define ALLOC_TAG
Definition: btrfs_drv.h:91
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define Vcb
Definition: cdprocs.h:1415
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
static FILE * out
Definition: regtests2xml.c:44
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_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
Definition: btrfs_drv.h:1357
#define ERR(fmt,...)
Definition: debug.h:110
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
GLuint in
Definition: glext.h:9616
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define STATUS_SUCCESS
Definition: shellext.h:65
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by read_file().

◆ 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 2076 of file extent-tree.c.

2076  {
2077  changed_extent* ce;
2078  changed_extent_ref* cer;
2079  LIST_ENTRY* le;
2080 
2081  ce = get_changed_extent_item(c, address, size, no_csum);
2082 
2083  if (!ce) {
2084  ERR("get_changed_extent_item failed\n");
2085  return;
2086  }
2087 
2088  le = ce->refs.Flink;
2089  while (le != &ce->refs) {
2091 
2092  if (cer->type == TYPE_EXTENT_DATA_REF && cer->edr.root == root && cer->edr.objid == objid && cer->edr.offset == offset) {
2093  ce->count += count;
2094  cer->edr.count += count;
2095  return;
2096  }
2097 
2098  le = le->Flink;
2099  }
2100 
2102 
2103  if (!cer) {
2104  ERR("out of memory\n");
2105  return;
2106  }
2107 
2108  cer->type = TYPE_EXTENT_DATA_REF;
2109  cer->edr.root = root;
2110  cer->edr.objid = objid;
2111  cer->edr.offset = offset;
2112  cer->edr.count = count;
2113 
2114  InsertTailList(&ce->refs, &cer->list_entry);
2115 
2116  ce->count += count;
2117 }
uint64_t offset
Definition: btrfs.h:407
LIST_ENTRY list_entry
Definition: btrfs_drv.h:626
GLuint GLuint GLsizei count
Definition: gl.h:1545
struct _root root
uint64_t objid
Definition: btrfs.h:406
#define InsertTailList(ListHead, Entry)
#define ALLOC_TAG
Definition: btrfs_drv.h:91
EXTENT_DATA_REF edr
Definition: btrfs_drv.h:622
uint32_t count
Definition: btrfs.h:408
uint64_t count
Definition: btrfs_drv.h:609
uint64_t root
Definition: btrfs.h:405
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:121
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
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:119
#define ERR(fmt,...)
Definition: debug.h:110
LIST_ENTRY refs
Definition: btrfs_drv.h:613
static changed_extent * get_changed_extent_item(chunk *c, uint64_t address, uint64_t size, bool no_csum)
Definition: extent-tree.c:1916
Definition: list.h:27

Referenced by rationalize_extents(), and write_compressed().

◆ add_checksum_entry()

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

Definition at line 2595 of file flushthread.c.

2595  {
2596  KEY searchkey;
2597  traverse_ptr tp, next_tp;
2598  NTSTATUS Status;
2599  uint64_t startaddr, endaddr;
2600  ULONG len;
2601  RTL_BITMAP bmp;
2602  ULONG* bmparr;
2603  ULONG runlength, index;
2604 
2605  TRACE("(%p, %I64x, %lx, %p, %p)\n", Vcb, address, length, csum, Irp);
2606 
2607  searchkey.obj_id = EXTENT_CSUM_ID;
2608  searchkey.obj_type = TYPE_EXTENT_CSUM;
2609  searchkey.offset = address;
2610 
2611  // FIXME - create checksum_root if it doesn't exist at all
2612 
2613  Status = find_item(Vcb, Vcb->checksum_root, &tp, &searchkey, false, Irp);
2614  if (Status == STATUS_NOT_FOUND) { // tree is completely empty
2615  if (csum) { // not deleted
2616  ULONG length2 = length;
2617  uint64_t off = address;
2618  void* data = csum;
2619 
2620  do {
2621  uint16_t il = (uint16_t)min(length2, MAX_CSUM_SIZE / Vcb->csum_size);
2622 
2623  void* checksums = ExAllocatePoolWithTag(PagedPool, il * Vcb->csum_size, ALLOC_TAG);
2624  if (!checksums) {
2625  ERR("out of memory\n");
2626  return;
2627  }
2628 
2629  RtlCopyMemory(checksums, data, il * Vcb->csum_size);
2630 
2631  Status = insert_tree_item(Vcb, Vcb->checksum_root, EXTENT_CSUM_ID, TYPE_EXTENT_CSUM, off, checksums,
2632  il * Vcb->csum_size, NULL, Irp);
2633  if (!NT_SUCCESS(Status)) {
2634  ERR("insert_tree_item returned %08lx\n", Status);
2635  ExFreePool(checksums);
2636  return;
2637  }
2638 
2639  length2 -= il;
2640 
2641  if (length2 > 0) {
2642  off += il * Vcb->superblock.sector_size;
2643  data = (uint8_t*)data + (il * Vcb->csum_size);
2644  }
2645  } while (length2 > 0);
2646  }
2647  } else if (!NT_SUCCESS(Status)) {
2648  ERR("find_item returned %08lx\n", Status);
2649  return;
2650  } else {
2651  uint32_t tplen;
2652  void* checksums;
2653 
2654  // FIXME - check entry is TYPE_EXTENT_CSUM?
2655 
2656  if (tp.item->key.offset < address && tp.item->key.offset + (tp.item->size * Vcb->superblock.sector_size / Vcb->csum_size) >= address)
2657  startaddr = tp.item->key.offset;
2658  else
2659  startaddr = address;
2660 
2661  searchkey.obj_id = EXTENT_CSUM_ID;
2662  searchkey.obj_type = TYPE_EXTENT_CSUM;
2663  searchkey.offset = address + (length * Vcb->superblock.sector_size);
2664 
2665  Status = find_item(Vcb, Vcb->checksum_root, &tp, &searchkey, false, Irp);
2666  if (!NT_SUCCESS(Status)) {
2667  ERR("find_item returned %08lx\n", Status);
2668  return;
2669  }
2670 
2671  tplen = tp.item->size / Vcb->csum_size;
2672 
2673  if (tp.item->key.offset + (tplen * Vcb->superblock.sector_size) >= address + (length * Vcb->superblock.sector_size))
2674  endaddr = tp.item->key.offset + (tplen * Vcb->superblock.sector_size);
2675  else
2676  endaddr = address + (length * Vcb->superblock.sector_size);
2677 
2678  TRACE("cs starts at %I64x (%lx sectors)\n", address, length);
2679  TRACE("startaddr = %I64x\n", startaddr);
2680  TRACE("endaddr = %I64x\n", endaddr);
2681 
2682  len = (ULONG)((endaddr - startaddr) / Vcb->superblock.sector_size);
2683 
2684  checksums = ExAllocatePoolWithTag(PagedPool, Vcb->csum_size * len, ALLOC_TAG);
2685  if (!checksums) {
2686  ERR("out of memory\n");
2687  return;
2688  }
2689 
2690  bmparr = ExAllocatePoolWithTag(PagedPool, sizeof(ULONG) * ((len/8)+1), ALLOC_TAG);
2691  if (!bmparr) {
2692  ERR("out of memory\n");
2693  ExFreePool(checksums);
2694  return;
2695  }
2696 
2697  RtlInitializeBitMap(&bmp, bmparr, len);
2698  RtlSetAllBits(&bmp);
2699 
2700  searchkey.obj_id = EXTENT_CSUM_ID;
2701  searchkey.obj_type = TYPE_EXTENT_CSUM;
2702  searchkey.offset = address;
2703 
2704  Status = find_item(Vcb, Vcb->checksum_root, &tp, &searchkey, false, Irp);
2705  if (!NT_SUCCESS(Status)) {
2706  ERR("find_item returned %08lx\n", Status);
2707  ExFreePool(checksums);
2708  ExFreePool(bmparr);
2709  return;
2710  }
2711 
2712  // set bit = free space, cleared bit = allocated sector
2713 
2714  while (tp.item->key.offset < endaddr) {
2715  if (tp.item->key.offset >= startaddr) {
2716  if (tp.item->size > 0) {
2717  ULONG itemlen = (ULONG)min((len - (tp.item->key.offset - startaddr) / Vcb->superblock.sector_size) * Vcb->csum_size, tp.item->size);
2718 
2719  RtlCopyMemory((uint8_t*)checksums + ((tp.item->key.offset - startaddr) * Vcb->csum_size / Vcb->superblock.sector_size),
2720  tp.item->data, itemlen);
2721  RtlClearBits(&bmp, (ULONG)((tp.item->key.offset - startaddr) / Vcb->superblock.sector_size), itemlen / Vcb->csum_size);
2722  }
2723 
2725  if (!NT_SUCCESS(Status)) {
2726  ERR("delete_tree_item returned %08lx\n", Status);
2727  ExFreePool(checksums);
2728  ExFreePool(bmparr);
2729  return;
2730  }
2731  }
2732 
2733  if (find_next_item(Vcb, &tp, &next_tp, false, Irp)) {
2734  tp = next_tp;
2735  } else
2736  break;
2737  }
2738 
2739  if (!csum) { // deleted
2740  RtlSetBits(&bmp, (ULONG)((address - startaddr) / Vcb->superblock.sector_size), length);
2741  } else {
2742  RtlCopyMemory((uint8_t*)checksums + ((address - startaddr) * Vcb->csum_size / Vcb->superblock.sector_size),
2743  csum, length * Vcb->csum_size);
2744  RtlClearBits(&bmp, (ULONG)((address - startaddr) / Vcb->superblock.sector_size), length);
2745  }
2746 
2747  runlength = RtlFindFirstRunClear(&bmp, &index);
2748 
2749  while (runlength != 0) {
2750  if (index >= len)
2751  break;
2752 
2753  if (index + runlength >= len) {
2754  runlength = len - index;
2755 
2756  if (runlength == 0)
2757  break;
2758  }
2759 
2760  do {
2761  uint16_t rl;
2762  uint64_t off;
2763  void* data;
2764 
2765  if (runlength * Vcb->csum_size > MAX_CSUM_SIZE)
2766  rl = (uint16_t)(MAX_CSUM_SIZE / Vcb->csum_size);
2767  else
2768  rl = (uint16_t)runlength;
2769 
2770  data = ExAllocatePoolWithTag(PagedPool, Vcb->csum_size * rl, ALLOC_TAG);
2771  if (!data) {
2772  ERR("out of memory\n");
2773  ExFreePool(bmparr);
2774  ExFreePool(checksums);
2775  return;
2776  }
2777 
2778  RtlCopyMemory(data, (uint8_t*)checksums + (Vcb->csum_size * index), Vcb->csum_size * rl);
2779 
2780  off = startaddr + UInt32x32To64(index, Vcb->superblock.sector_size);
2781 
2782  Status = insert_tree_item(Vcb, Vcb->checksum_root, EXTENT_CSUM_ID, TYPE_EXTENT_CSUM, off, data, Vcb->csum_size * rl, NULL, Irp);
2783  if (!NT_SUCCESS(Status)) {
2784  ERR("insert_tree_item returned %08lx\n", Status);
2785  ExFreePool(data);
2786  ExFreePool(bmparr);
2787  ExFreePool(checksums);
2788  return;
2789  }
2790 
2791  runlength -= rl;
2792  index += rl;
2793  } while (runlength > 0);
2794 
2795  runlength = RtlFindNextForwardRunClear(&bmp, index, &index);
2796  }
2797 
2798  ExFreePool(bmparr);
2799  ExFreePool(checksums);
2800  }
2801 }
uint64_t obj_id
Definition: btrfs.h:137
#define MAX_CSUM_SIZE
Definition: flushthread.c:25
uint8_t obj_type
Definition: btrfs.h:138
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
LONG NTSTATUS
Definition: precomp.h:26
uint16_t size
Definition: btrfs_drv.h:430
unsigned short int uint16_t
Definition: acefiex.h:54
#define uint16_t
Definition: nsiface.idl:60
uint64_t offset
Definition: btrfs.h:139
uint8_t * data
Definition: btrfs_drv.h:431
#define TYPE_EXTENT_CSUM
Definition: btrfs.h:27
#define ALLOC_TAG
Definition: btrfs_drv.h:91
_In_ PIRP Irp
Definition: csq.h:116
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
NTSYSAPI void WINAPI RtlSetAllBits(PRTL_BITMAP)
GLuint index
Definition: glext.h:6031
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2930
static LONG find_item(PropertyBag *This, LPCOLESTR name)
Definition: propertybag.c:110
Status
Definition: gdiplustypes.h:24
#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:593
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define Vcb
Definition: cdprocs.h:1415
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:858
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
tree_data * item
Definition: btrfs_drv.h:518
#define index(s, c)
Definition: various.h:29
GLenum GLsizei len
Definition: glext.h:6722
static void startaddr(void)
BYTE uint8_t
Definition: msvideo1.c:66
#define ERR(fmt,...)
Definition: debug.h:110
NTSYSAPI void WINAPI RtlClearBits(PRTL_BITMAP, ULONG, ULONG)
Definition: btrfs.h:136
#define EXTENT_CSUM_ID
Definition: btrfs.h:87
UINT64 uint64_t
Definition: types.h:77
NTSYSAPI ULONG NTAPI RtlFindFirstRunClear(_In_ PRTL_BITMAP BitMapHeader, _Out_ PULONG StartingIndex)
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
#define min(a, b)
Definition: monoChain.cc:55
#define NULL
Definition: types.h:112
UINT32 uint32_t
Definition: types.h:75
NTSYSAPI ULONG WINAPI RtlFindNextForwardRunClear(PCRTL_BITMAP, ULONG, PULONG)
Definition: fs.h:216
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define UInt32x32To64(a, b)
Definition: intsafe.h:250
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
void * csum
Definition: write.c:2807
NTSTATUS delete_tree_item(_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _Inout_ traverse_ptr *tp)
Definition: treefuncs.c:990

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 1861 of file create.c.

1861  {
1862  NTSTATUS Status;
1863  dir_child* dc;
1864  bool locked;
1865 
1867  if (!dc) {
1868  ERR("out of memory\n");
1870  }
1871 
1872  dc->utf8.Buffer = ExAllocatePoolWithTag(PagedPool, utf8->Length, ALLOC_TAG);
1873  if (!dc->utf8.Buffer) {
1874  ERR("out of memory\n");
1875  ExFreePool(dc);
1877  }
1878 
1879  dc->name.Buffer = ExAllocatePoolWithTag(PagedPool, name->Length, ALLOC_TAG);
1880  if (!dc->name.Buffer) {
1881  ERR("out of memory\n");
1882  ExFreePool(dc->utf8.Buffer);
1883  ExFreePool(dc);
1885  }
1886 
1887  dc->key.obj_id = inode;
1888  dc->key.obj_type = subvol ? TYPE_ROOT_ITEM : TYPE_INODE_ITEM;
1889  dc->key.offset = subvol ? 0xffffffffffffffff : 0;
1890  dc->type = type;
1891  dc->fileref = NULL;
1892 
1893  dc->utf8.Length = dc->utf8.MaximumLength = utf8->Length;
1894  RtlCopyMemory(dc->utf8.Buffer, utf8->Buffer, utf8->Length);
1895 
1896  dc->name.Length = dc->name.MaximumLength = name->Length;
1897  RtlCopyMemory(dc->name.Buffer, name->Buffer, name->Length);
1898 
1899  Status = RtlUpcaseUnicodeString(&dc->name_uc, name, true);
1900  if (!NT_SUCCESS(Status)) {
1901  ERR("RtlUpcaseUnicodeString returned %08lx\n", Status);
1902  ExFreePool(dc->utf8.Buffer);
1903  ExFreePool(dc->name.Buffer);
1904  ExFreePool(dc);
1905  return Status;
1906  }
1907 
1908  dc->hash = calc_crc32c(0xffffffff, (uint8_t*)dc->name.Buffer, dc->name.Length);
1909  dc->hash_uc = calc_crc32c(0xffffffff, (uint8_t*)dc->name_uc.Buffer, dc->name_uc.Length);
1910 
1911  locked = ExIsResourceAcquiredExclusive(&fcb->nonpaged->dir_children_lock);
1912 
1913  if (!locked)
1914  ExAcquireResourceExclusiveLite(&fcb->nonpaged->dir_children_lock, true);
1915 
1917  dc->index = 2;
1918  else {
1919  dir_child* dc2 = CONTAINING_RECORD(fcb->dir_children_index.Blink, dir_child, list_entry_index);
1920 
1921  dc->index = max(2, dc2->index + 1);
1922  }
1923 
1924  InsertTailList(&fcb->dir_children_index, &dc->list_entry_index);
1925 
1927 
1928  if (!locked)
1929  ExReleaseResourceLite(&fcb->nonpaged->dir_children_lock);
1930 
1931  *pdc = dc;
1932 
1933  return STATUS_SUCCESS;
1934 }
#define max(a, b)
Definition: svc.c:63
#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:4287
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
LONG NTSTATUS
Definition: precomp.h:26
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
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
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
Status
Definition: gdiplustypes.h:24
LIST_ENTRY dir_children_index
Definition: btrfs_drv.h:325
#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:263
#define TYPE_INODE_ITEM
Definition: btrfs.h:19
crc_func calc_crc32c
Definition: crc32c.c:23
BYTE uint8_t
Definition: msvideo1.c:66
#define ERR(fmt,...)
Definition: debug.h:110
struct _fcb_nonpaged * nonpaged
Definition: btrfs_drv.h:295
#define TYPE_ROOT_ITEM
Definition: btrfs.h:28
void insert_dir_child_into_hash_lists(fcb *fcb, dir_child *dc)
Definition: fileinfo.c:1417
#define NULL
Definition: types.h:112
Definition: name.c:38
static const WCHAR dc[]
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define ExIsResourceAcquiredExclusive
Definition: exfuncs.h:347
#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 2367 of file write.c.

2367  {
2368  LIST_ENTRY* le = prevextle->Flink;
2369 
2370  while (le != &fcb->extents) {
2372 
2373  if (ext->offset >= newext->offset) {
2374  InsertHeadList(ext->list_entry.Blink, &newext->list_entry);
2375  return;
2376  }
2377 
2378  le = le->Flink;
2379  }
2380 
2381  InsertTailList(&fcb->extents, &newext->list_entry);
2382 }
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:121
LIST_ENTRY extents
Definition: btrfs_drv.h:311
Definition: typedefs.h:119
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) void csum,
_In_ LIST_ENTRY rollback 
)

Definition at line 2736 of file write.c.

2737  {
2738  extent* ext;
2739  LIST_ENTRY* le;
2740 
2742  if (!ext) {
2743  ERR("out of memory\n");
2745  }
2746 
2747  ext->offset = offset;
2748  ext->datalen = edsize;
2749  ext->unique = unique;
2750  ext->ignore = false;
2751  ext->inserted = true;
2752  ext->csum = csum;
2753 
2754  RtlCopyMemory(&ext->extent_data, ed, edsize);
2755 
2756  le = fcb->extents.Flink;
2757  while (le != &fcb->extents) {
2758  extent* oldext = CONTAINING_RECORD(le, extent, list_entry);
2759 
2760  if (oldext->offset >= offset) {
2761  InsertHeadList(le->Blink, &ext->list_entry);
2762  goto end;
2763  }
2764 
2765  le = le->Flink;
2766  }
2767 
2768  InsertTailList(&fcb->extents, &ext->list_entry);
2769 
2770 end:
2772 
2773  return STATUS_SUCCESS;
2774 }
void add_insert_extent_rollback(LIST_ENTRY *rollback, fcb *fcb, extent *ext)
Definition: write.c:2717
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
#define InsertTailList(ListHead, Entry)
#define ALLOC_TAG
Definition: btrfs_drv.h:91
uint64_t offset
Definition: btrfs_drv.h:239
#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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
GLintptr offset
Definition: glext.h:5920
_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:2800
LIST_ENTRY extents
Definition: btrfs_drv.h:311
GLuint GLuint end
Definition: gl.h:1545
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Definition: typedefs.h:119
uint16_t edsize
Definition: write.c:2806
#define ERR(fmt,...)
Definition: debug.h:110
ed2 offset
Definition: write.c:2831
Definition: list.h:27
_ForwardIter unique(_ForwardIter __first, _ForwardIter __last)
Definition: _algo.h:298
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define STATUS_SUCCESS
Definition: shellext.h:65
EXTENT_DATA * ed
Definition: write.c:2804
void * csum
Definition: write.c:2807

Referenced by duplicate_extents(), extend_file(), rename_stream_to_file(), truncate_file(), write_compressed(), 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 = %lu\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 
226