ReactOS  0.4.10-dev-358-g66981e1
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 <emmintrin.h>
#include "btrfs.h"
#include "btrfsioctl.h"
Include dependency graph for btrfs_drv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _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
 
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  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  _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_PROP_COMPRESSION   "btrfs.compression"
 
#define EA_PROP_COMPRESSION_HASH   0x20ccdf69
 
#define MAX_EXTENT_SIZE   0x8000000
 
#define COMPRESSED_EXTENT_SIZE   0x20000
 
#define READ_AHEAD_GRANULARITY   COMPRESSED_EXTENT_SIZE
 
#define IO_REPARSE_TAG_LXSS_SYMLINK   0xa000001d
 
#define 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_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL   0x00020000
 
#define FSCTL_DUPLICATE_EXTENTS_TO_FILE   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 209, METHOD_BUFFERED, FILE_WRITE_ACCESS)
 
#define FSCTL_GET_INTEGRITY_INFORMATION   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 159, METHOD_BUFFERED, FILE_ANY_ACCESS)
 
#define FSCTL_SET_INTEGRITY_INFORMATION   CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 160, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
 
#define __drv_aliasesMem
 
#define _Requires_lock_held_(a)
 
#define _Requires_exclusive_lock_held_(a)
 
#define _Releases_lock_(a)
 
#define _Out_writes_bytes_opt_(a)
 
#define _Pre_satisfies_(a)
 
#define _Post_satisfies_(a)
 
#define _Releases_exclusive_lock_(a)
 
#define _Dispatch_type_(a)
 
#define _Create_lock_level_(a)
 
#define _Lock_level_order_(a, b)
 
#define _Has_lock_level_(a)
 
#define _Requires_lock_not_held_(a)
 
#define _Acquires_exclusive_lock_(a)
 
#define _Acquires_shared_lock_(a)
 
#define VCB_TYPE_FS   1
 
#define VCB_TYPE_CONTROL   2
 
#define VCB_TYPE_VOLUME   3
 
#define VCB_TYPE_PDO   4
 
#define BALANCE_OPTS_DATA   0
 
#define BALANCE_OPTS_METADATA   1
 
#define BALANCE_OPTS_SYSTEM   2
 
#define keycmp(key1, key2)
 
#define funcname   __func__
 
#define TRACE(s,...)
 
#define WARN(s,...)
 
#define FIXME(s,...)   DbgPrint("Btrfs FIXME : %s : " s, funcname, ##__VA_ARGS__)
 
#define ERR(s,...)   DbgPrint("Btrfs ERR : %s : " s, funcname, ##__VA_ARGS__)
 
#define makedev(major, minor)   (((minor) & 0xFF) | (((major) & 0xFFF) << 8) | (((UINT64)((minor) & ~0xFF)) << 12) | (((UINT64)((major) & ~0xFFF)) << 32))
 
#define fast_io_possible(fcb)   (!FsRtlAreThereCurrentFileLocks(&fcb->lock) && !fcb->Vcb->readonly ? FastIoIsPossible : FastIoIsQuestionable)
 
#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 CC_ENABLE_DISK_IO_ACCOUNTING   0x00000010
 

Typedefs

typedef struct
_DUPLICATE_EXTENTS_DATA 
DUPLICATE_EXTENTS_DATA
 
typedef struct
_DUPLICATE_EXTENTS_DATA
PDUPLICATE_EXTENTS_DATA
 
typedef struct
_FSCTL_GET_INTEGRITY_INFORMATION_BUFFER 
FSCTL_GET_INTEGRITY_INFORMATION_BUFFER
 
typedef struct
_FSCTL_GET_INTEGRITY_INFORMATION_BUFFER
PFSCTL_GET_INTEGRITY_INFORMATION_BUFFER
 
typedef struct
_FSCTL_SET_INTEGRITY_INFORMATION_BUFFER 
FSCTL_SET_INTEGRITY_INFORMATION_BUFFER
 
typedef struct
_FSCTL_SET_INTEGRITY_INFORMATION_BUFFER
PFSCTL_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(* tPsIsDiskCountersEnabled )()
 
typedef VOID(* tPsUpdateDiskCounters )(PEPROCESS Process, ULONG64 BytesRead, ULONG64 BytesWritten, ULONG ReadOperationCount, ULONG WriteOperationCount, ULONG FlushOperationCount)
 
typedef BOOLEAN(* tCcCopyWriteEx )(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, PVOID Buffer, PETHREAD IoIssuerThread)
 
typedef BOOLEAN(* tCcCopyReadEx )(PFILE_OBJECT FileObject, PLARGE_INTEGER FileOffset, ULONG Length, BOOLEAN Wait, PVOID Buffer, PIO_STATUS_BLOCK IoStatus, PETHREAD IoIssuerThread)
 
typedef VOID(* tCcSetAdditionalCacheAttributesEx )(PFILE_OBJECT FileObject, ULONG Flags)
 
typedef VOID(* tFsRtlUpdateDiskCounters )(ULONG64 BytesRead, ULONG64 BytesWritten)
 
typedef struct
_LDR_DATA_TABLE_ENTRY 
LDR_DATA_TABLE_ENTRY
 
typedef struct
_LDR_DATA_TABLE_ENTRY
PLDR_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_PARAMETERS
PRTL_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 }
 
enum  batch_operation {
  Batch_Delete, Batch_DeleteInode, Batch_DeleteDirItem, Batch_DeleteInodeRef,
  Batch_DeleteInodeExtRef, Batch_DeleteXattr, Batch_DeleteExtentData, Batch_DeleteFreeSpace,
  Batch_Insert, Batch_SetXattr, Batch_DirItem, Batch_InodeRef,
  Batch_InodeExtRef
}
 
enum  write_data_status {
  WriteDataStatus_Pending, WriteDataStatus_Success, WriteDataStatus_Error, WriteDataStatus_Cancelling,
  WriteDataStatus_Cancelled, WriteDataStatus_Ignore
}
 
enum  rollback_type { ROLLBACK_INSERT_EXTENT, ROLLBACK_DELETE_EXTENT, ROLLBACK_ADD_SPACE, ROLLBACK_SUBTRACT_SPACE }
 

Functions

 _Create_lock_level_ (tree_lock) _Create_lock_level_(fcb_lock) _Lock_level_order_(tree_lock
 
 _Requires_lock_not_held_ (Vcb->fcb_lock) _Acquires_shared_lock_(Vcb-> fcb_lock) static __inline void acquire_fcb_lock_shared(device_extension *Vcb)
 
 _Requires_lock_held_ (Vcb->fcb_lock) _Releases_lock_(Vcb-> fcb_lock) static __inline void release_fcb_lock(device_extension *Vcb)
 
static __inline voidmap_user_buffer (PIRP Irp, ULONG priority)
 
static __inline UINT64 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 off, _In_ UINT64 stripe_length, _In_ UINT16 num_stripes, _Out_ UINT64 *stripeoff, _Out_ UINT16 *stripe)
 
static __inline UINT64 make_file_id (root *r, UINT64 inode)
 
 _Post_satisfies_ (return >=n) __inline static UINT64 sector_align(_In_ UINT64 n
 
static __inline BOOL is_subvol_readonly (root *r, PIRP Irp)
 
static __inline UINT16 get_extent_data_len (UINT8 type)
 
static __inline UINT32 get_extent_data_refcount (UINT8 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 inode, _In_ UINT8 type, _In_ BOOL dotfile, _In_ BOOL ignore_xa, _In_opt_ PIRP Irp)
 
void free_fcb (_Requires_exclusive_lock_held_(_Curr_->fcb_lock) _In_ device_extension *Vcb, _Inout_ fcb *fcb)
 
void free_fileref (_Requires_exclusive_lock_held_(_Curr_->fcb_lock) _In_ device_extension *Vcb, _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 id, _Out_ root **rootptr, _In_ BOOL no_tree, _In_ UINT64 offset, _In_opt_ PIRP Irp)
 
void uninit (_In_ device_extension *Vcb, _In_ BOOL flush)
 
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_ BOOLEAN Override, _Out_opt_ IO_STATUS_BLOCK *iosb)
 
BOOL is_file_name_valid (_In_ PUNICODE_STRING us, _In_ BOOL posix)
 
void send_notification_fileref (_In_ file_ref *fileref, _In_ ULONG filter_match, _In_ ULONG action, _In_opt_ PUNICODE_STRING stream)
 
void send_notification_fcb (_In_ file_ref *fileref, _In_ ULONG filter_match, _In_ ULONG action, _In_opt_ PUNICODE_STRING stream)
 
_Ret_z_ WCHARfile_desc (_In_ PFILE_OBJECT FileObject)
 
WCHARfile_desc_fileref (_In_ file_ref *fileref)
 
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_opt_ PIRP Irp, _In_ LIST_ENTRY *rollback)
 
void chunk_lock_range (_In_ device_extension *Vcb, _In_ chunk *c, _In_ UINT64 start, _In_ UINT64 length)
 
void chunk_unlock_range (_In_ device_extension *Vcb, _In_ chunk *c, _In_ UINT64 start, _In_ UINT64 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_ UINT64 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)
 
NTSTATUS AddDevice (PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PhysicalDeviceObject)
 
void init_fast_io_dispatch (FAST_IO_DISPATCH **fiod)
 
UINT32 calc_crc32c (_In_ UINT32 seed, _In_reads_bytes_(msglen) UINT8 *msg, _In_ ULONG msglen)
 
NTSTATUS find_item (_In_ _Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_ root *r, _Out_ traverse_ptr *tp, _In_ const KEY *searchkey, _In_ BOOL ignore, _In_opt_ PIRP Irp)
 
NTSTATUS find_item_to_level (device_extension *Vcb, root *r, traverse_ptr *tp, const KEY *searchkey, BOOL ignore, UINT8 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 obj_id, _In_ UINT8 obj_type, _In_ UINT64 offset, _In_reads_bytes_opt_(size) _When_(return >=0, __drv_aliasesMem) void *data, _In_ UINT16 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)
 
treefree_tree (tree *t)
 
NTSTATUS load_tree (device_extension *Vcb, UINT64 addr, root *r, tree **pt, UINT64 generation, PIRP Irp)
 
NTSTATUS do_load_tree (device_extension *Vcb, tree_holder *th, root *r, tree *t, tree_data *td, BOOL *loaded, 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 mountmgr_thread(_In_ void *context)
 
 _Function_class_ (DRIVER_NOTIFICATION_CALLBACK_ROUTINE) NTSTATUS 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)
 
NTSTATUS init_cache ()
 
void free_cache ()
 
NTSTATUS write_file (device_extension *Vcb, PIRP Irp, BOOLEAN wait, BOOLEAN deferred_write)
 
NTSTATUS write_file2 (device_extension *Vcb, PIRP Irp, LARGE_INTEGER offset, void *buf, ULONG *length, BOOLEAN paging_io, BOOLEAN no_cache, BOOLEAN wait, BOOLEAN deferred_write, BOOLEAN write_irp, LIST_ENTRY *rollback)
 
NTSTATUS truncate_file (fcb *fcb, UINT64 end, PIRP Irp, LIST_ENTRY *rollback)
 
NTSTATUS extend_file (fcb *fcb, file_ref *fileref, UINT64 end, BOOL prealloc, PIRP Irp, LIST_ENTRY *rollback)
 
NTSTATUS excise_extents (device_extension *Vcb, fcb *fcb, UINT64 start_data, UINT64 end_data, PIRP Irp, LIST_ENTRY *rollback)
 
chunkget_chunk_from_address (device_extension *Vcb, UINT64 address)
 
NTSTATUS alloc_chunk (device_extension *Vcb, UINT64 flags, chunk **pc, BOOL full_size)
 
NTSTATUS write_data (_In_ device_extension *Vcb, _In_ UINT64 address, _In_reads_bytes_(length) void *data, _In_ UINT32 length, _In_ write_data_context *wtc, _In_opt_ PIRP Irp, _In_opt_ chunk *c, _In_ BOOL file_write, _In_ UINT64 irp_offset, _In_ ULONG priority)
 
NTSTATUS write_data_complete (device_extension *Vcb, UINT64 address, void *data, UINT32 length, PIRP Irp, chunk *c, BOOL file_write, UINT64 irp_offset, ULONG priority)
 
void free_write_data_stripes (write_data_context *wtc)
 
 _Dispatch_type_ (IRP_MJ_WRITE) _Function_class_(DRIVER_DISPATCH) NTSTATUS 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 start_data, UINT64 end_data, void *data, PIRP Irp, BOOL file_write, UINT32 irp_offset, LIST_ENTRY *rollback)
 
NTSTATUS write_compressed (fcb *fcb, UINT64 start_data, UINT64 end_data, void *data, PIRP Irp, LIST_ENTRY *rollback)
 
BOOL find_data_address_in_chunk (device_extension *Vcb, chunk *c, UINT64 length, UINT64 *address)
 
void get_raid56_lock_range (chunk *c, UINT64 address, UINT64 length, UINT64 *lockaddr, UINT64 *locklen)
 
NTSTATUS calc_csum (_In_ device_extension *Vcb, _In_reads_bytes_(sectors *Vcb->superblock.sector_size) UINT8 *data, _In_ UINT32 sectors, _Out_writes_bytes_(sectors *sizeof(UINT32)) UINT32 *csum)
 
void add_insert_extent_rollback (LIST_ENTRY *rollback, fcb *fcb, extent *ext)
 
NTSTATUS add_extent_to_fcb (_In_ fcb *fcb, _In_ UINT64 offset, _In_reads_bytes_(edsize) EXTENT_DATA *ed, _In_ UINT16 edsize, _In_ BOOL unique, _In_opt_ _When_(return >=0, __drv_aliasesMem) UINT32 *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 drv_directory_control(IN PDEVICE_OBJECT DeviceObject
 
ULONG get_reparse_tag (device_extension *Vcb, root *subvol, UINT64 inode, UINT8 type, ULONG atts, BOOL lxss, PIRP Irp)
 
 _Dispatch_type_ (IRP_MJ_QUERY_SECURITY) _Function_class_(DRIVER_DISPATCH) NTSTATUS drv_query_security(IN PDEVICE_OBJECT DeviceObject
 
 _Dispatch_type_ (IRP_MJ_SET_SECURITY) _Function_class_(DRIVER_DISPATCH) NTSTATUS 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 uid)
 
void add_group_mapping (WCHAR *sidstring, ULONG sidstringlength, UINT32 gid)
 
UINT32 sid_to_uid (PSID sid)
 
NTSTATUS uid_to_sid (UINT32 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 drv_set_information(IN PDEVICE_OBJECT DeviceObject
 
 _Dispatch_type_ (IRP_MJ_QUERY_INFORMATION) _Function_class_(DRIVER_DISPATCH) NTSTATUS drv_query_information(IN PDEVICE_OBJECT DeviceObject
 
 _Dispatch_type_ (IRP_MJ_QUERY_EA) _Function_class_(DRIVER_DISPATCH) NTSTATUS drv_query_ea(IN PDEVICE_OBJECT DeviceObject
 
 _Dispatch_type_ (IRP_MJ_SET_EA) _Function_class_(DRIVER_DISPATCH) NTSTATUS 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 end, fcb *fcb, file_ref *fileref, BOOL advance_only)
 
NTSTATUS fileref_get_filename (file_ref *fileref, PUNICODE_STRING fn, USHORT *name_offset, ULONG *preqlen)
 
NTSTATUS open_fileref_by_inode (_Requires_exclusive_lock_held_(_Curr_->fcb_lock) device_extension *Vcb, root *subvol, UINT64 inode, file_ref **pfr, PIRP Irp)
 
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_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 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 inode, UINT8 type, PANSI_STRING utf8, fcb *parent, fcb **pfcb, POOL_TYPE pooltype, PIRP Irp)
 
NTSTATUS load_csum (_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb, UINT32 *csum, UINT64 start, UINT64 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 inode, BOOL subvol, PANSI_STRING utf8, PUNICODE_STRING name, UINT8 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 *inode, dir_child **pdc, BOOL case_sensitive)
 
UINT32 inherit_mode (fcb *parfcb, BOOL is_dir)
 
file_refcreate_fileref (device_extension *Vcb)
 
NTSTATUS fsctl_request (PDEVICE_OBJECT DeviceObject, PIRP *Pirp, UINT32 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 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_ UINT64 address, _In_reads_bytes_(length) void *data, _In_ UINT32 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 address, ULONG length, UINT32 *csum, PIRP Irp)
 
BOOL find_metadata_address_in_chunk (device_extension *Vcb, chunk *c, UINT64 *address)
 
void add_trim_entry_avoid_sb (device_extension *Vcb, device *dev, UINT64 address, UINT64 size)
 
NTSTATUS insert_tree_item_batch (LIST_ENTRY *batchlist, device_extension *Vcb, root *r, UINT64 objid, UINT8 objtype, UINT64 offset, _In_opt_ _When_(return >=0, __drv_aliasesMem) void *data, UINT16 datalen, enum batch_operation operation)
 
NTSTATUS flush_partial_stripe (device_extension *Vcb, chunk *c, partial_stripe *ps)
 
NTSTATUS update_dev_item (device_extension *Vcb, device *device, PIRP Irp)
 
 _Dispatch_type_ (IRP_MJ_READ) _Function_class_(DRIVER_DISPATCH) NTSTATUS drv_read(PDEVICE_OBJECT DeviceObject
 
NTSTATUS read_data (_In_ device_extension *Vcb, _In_ UINT64 addr, _In_ UINT32 length, _In_reads_bytes_opt_(length *sizeof(UINT32)/Vcb->superblock.sector_size) UINT32 *csum, _In_ BOOL is_tree, _Out_writes_bytes_(length) UINT8 *buf, _In_opt_ chunk *c, _Out_opt_ chunk **pc, _In_opt_ PIRP Irp, _In_ UINT64 generation, _In_ BOOL file_read, _In_ ULONG priority)
 
NTSTATUS read_file (fcb *fcb, UINT8 *data, UINT64 start, UINT64 length, ULONG *pbr, PIRP Irp)
 
NTSTATUS read_stream (fcb *fcb, UINT8 *data, UINT64 start, ULONG length, ULONG *pbr)
 
NTSTATUS do_read (PIRP Irp, BOOLEAN wait, ULONG *bytes_read)
 
NTSTATUS check_csum (device_extension *Vcb, UINT8 *data, UINT32 sectors, UINT32 *csum)
 
void raid6_recover2 (UINT8 *sectors, UINT16 num_stripes, ULONG sector_size, UINT16 missing1, UINT16 missing2, UINT8 *out)
 
 _Dispatch_type_ (IRP_MJ_PNP) _Function_class_(DRIVER_DISPATCH) NTSTATUS 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 offset, UINT64 size)
 
void space_list_add (chunk *c, UINT64 address, UINT64 length, LIST_ENTRY *rollback)
 
void space_list_add2 (LIST_ENTRY *list, LIST_ENTRY *list_size, UINT64 address, UINT64 length, chunk *c, LIST_ENTRY *rollback)
 
void space_list_subtract (chunk *c, BOOL deleting, UINT64 address, UINT64 length, LIST_ENTRY *rollback)
 
void space_list_subtract2 (LIST_ENTRY *list, LIST_ENTRY *list_size, UINT64 address, UINT64 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 address, UINT64 size, UINT64 root, UINT64 inode, UINT64 offset, UINT32 refcount, PIRP Irp)
 
NTSTATUS decrease_extent_refcount_data (device_extension *Vcb, UINT64 address, UINT64 size, UINT64 root, UINT64 inode, UINT64 offset, UINT32 refcount, BOOL superseded, PIRP Irp)
 
NTSTATUS decrease_extent_refcount_tree (device_extension *Vcb, UINT64 address, UINT64 size, UINT64 root, UINT8 level, PIRP Irp)
 
UINT64 get_extent_refcount (device_extension *Vcb, UINT64 address, UINT64 size, PIRP Irp)
 
BOOL is_extent_unique (device_extension *Vcb, UINT64 address, UINT64 size, PIRP Irp)
 
NTSTATUS increase_extent_refcount (device_extension *Vcb, UINT64 address, UINT64 size, UINT8 type, void *data, KEY *firstitem, UINT8 level, PIRP Irp)
 
UINT64 get_extent_flags (device_extension *Vcb, UINT64 address, PIRP Irp)
 
void update_extent_flags (device_extension *Vcb, UINT64 address, UINT64 flags, PIRP Irp)
 
NTSTATUS update_changed_extent_ref (device_extension *Vcb, chunk *c, UINT64 address, UINT64 size, UINT64 root, UINT64 objid, UINT64 offset, INT32 count, BOOL no_csum, BOOL superseded, PIRP Irp)
 
void add_changed_extent_ref (chunk *c, UINT64 address, UINT64 size, UINT64 root, UINT64 objid, UINT64 offset, UINT32 count, BOOL no_csum)
 
UINT64 find_extent_shared_tree_refcount (device_extension *Vcb, UINT64 address, UINT64 parent, PIRP Irp)
 
UINT32 find_extent_shared_data_refcount (device_extension *Vcb, UINT64 address, UINT64 parent, PIRP Irp)
 
NTSTATUS decrease_extent_refcount (device_extension *Vcb, UINT64 address, UINT64 size, UINT8 type, void *data, KEY *firstitem, UINT8 level, UINT64 parent, BOOL superseded, PIRP Irp)
 
UINT64 get_extent_data_ref_hash2 (UINT64 root, UINT64 objid, UINT64 offset)
 
void do_read_job (PIRP Irp)
 
void 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 *inbuf, UINT32 inlen, UINT8 *outbuf, UINT32 outlen)
 
NTSTATUS lzo_decompress (UINT8 *inbuf, UINT32 inlen, UINT8 *outbuf, UINT32 outlen, UINT32 inpageoff)
 
NTSTATUS write_compressed_bit (fcb *fcb, UINT64 start_data, UINT64 end_data, void *data, BOOL *compressed, PIRP Irp, LIST_ENTRY *rollback)
 
void galois_double (UINT8 *data, UINT32 len)
 
void galois_divpower (UINT8 *data, UINT8 div, UINT32 readlen)
 
UINT8 gpow2 (UINT8 e)
 
UINT8 gmul (UINT8 a, UINT8 b)
 
UINT8 gdiv (UINT8 a, UINT8 b)
 
 _Dispatch_type_ (IRP_MJ_DEVICE_CONTROL) _Function_class_(DRIVER_DISPATCH) NTSTATUS drv_device_control(IN PDEVICE_OBJECT DeviceObject
 
NTSTATUS add_calc_job (device_extension *Vcb, UINT8 *data, UINT32 sectors, UINT32 *csum, calc_job **pcj)
 
void free_calc_job (calc_job *cj)
 
NTSTATUS start_balance (device_extension *Vcb, void *data, ULONG length, KPROCESSOR_MODE processor_mode)
 
NTSTATUS query_balance (device_extension *Vcb, void *data, ULONG length)
 
NTSTATUS pause_balance (device_extension *Vcb, KPROCESSOR_MODE processor_mode)
 
NTSTATUS resume_balance (device_extension *Vcb, KPROCESSOR_MODE processor_mode)
 
NTSTATUS stop_balance (device_extension *Vcb, KPROCESSOR_MODE processor_mode)
 
NTSTATUS look_for_balance_item (_Requires_lock_held_(_Curr_->tree_lock) device_extension *Vcb)
 
NTSTATUS remove_device (device_extension *Vcb, void *data, ULONG length, KPROCESSOR_MODE processor_mode)
 
NTSTATUS vol_create (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_close (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_read (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_write (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_query_information (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_set_information (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_query_ea (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_set_ea (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_flush_buffers (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_query_volume_information (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_set_volume_information (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_cleanup (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_directory_control (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_file_system_control (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_lock_control (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_device_control (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_shutdown (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_query_security (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_set_security (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS vol_power (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
void add_volume_device (superblock *sb, PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath, UINT64 length, ULONG disk_num, ULONG part_num)
 
NTSTATUS mountmgr_add_drive_letter (PDEVICE_OBJECT mountmgr, PUNICODE_STRING devpath)
 
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)
 
static __inline void print_open_trees (device_extension *Vcb)
 
static __inline BOOL write_fcb_compressed (fcb *fcb)
 
static __inline void do_xor (UINT8 *buf1, UINT8 *buf2, UINT32 len)
 
static __inline UINT64 fcb_alloc_size (fcb *fcb)
 
BOOLEAN RtlIsNtDdiVersionAvailable (ULONG Version)
 
PEPROCESS PsGetThreadProcess (_In_ PETHREAD Thread)
 

Variables

_In_ UINT64 a
 
return n
 
_In_ UINT16 len
 
_In_ UINT16 _Out_ ULONGatts
 
BOOL have_sse2
 
UINT32 mount_compress
 
UINT32 mount_compress_force
 
UINT32 mount_compress_type
 
UINT32 mount_zlib_level
 
UINT32 mount_flush_interval
 
UINT32 mount_max_inline
 
UINT32 mount_skip_balance
 
UINT32 mount_no_barrier
 
UINT32 mount_no_trim
 
UINT32 mount_clear_cache
 
UINT32 mount_allow_degraded
 
UINT32 mount_readonly
 
UINT32 no_pnp
 
PVOID Context
 
CACHE_MANAGER_CALLBACKScache_callbacks
 
IN PIRP Irp
 
_In_ fcb _In_ chunkc
 
_In_ fcb _In_ chunk _In_ UINT64 start_data
 
_In_ fcb _In_ chunk _In_
UINT64 _In_ UINT64 
length
 
_In_ fcb _In_ chunk _In_
UINT64 _In_ UINT64 _In_ BOOL 
prealloc
 
_In_ fcb _In_ chunk _In_
UINT64 _In_ UINT64 _In_ BOOL
_In_opt_ void
data
 
_In_ fcb _In_ chunk _In_
UINT64 _In_ UINT64 _In_ BOOL
_In_opt_ void _In_opt_ PIRP
_In_ LIST_ENTRY
rollback
 
_In_ fcb _In_ chunk _In_
UINT64 _In_ UINT64 _In_ BOOL
_In_opt_ void _In_opt_ PIRP
_In_ LIST_ENTRY _In_ UINT8 
compression = compression
 
_In_ fcb _In_ chunk _In_
UINT64 _In_ UINT64 _In_ BOOL
_In_opt_ void _In_opt_ PIRP
_In_ LIST_ENTRY _In_ UINT8
_In_ UINT64 
decoded_size = decoded_size
 
_In_ fcb _In_ chunk _In_
UINT64 _In_ UINT64 _In_ BOOL
_In_opt_ void _In_opt_ PIRP
_In_ LIST_ENTRY _In_ UINT8
_In_ UINT64 _In_ BOOL 
file_write
 
_In_ fcb _In_ chunk _In_
UINT64 _In_ UINT64 _In_ BOOL
_In_opt_ void _In_opt_ PIRP
_In_ LIST_ENTRY _In_ UINT8
_In_ UINT64 _In_ BOOL _In_
UINT64 
irp_offset
 

Macro Definition Documentation

#define __drv_aliasesMem

Definition at line 161 of file btrfs_drv.h.

#define __S_IFBLK   0060000 /* Block device. */

Definition at line 1659 of file btrfs_drv.h.

Referenced by mknod(), open_fcb(), and send_inode().

#define __S_IFCHR   0020000 /* Character device. */

Definition at line 1658 of file btrfs_drv.h.

Referenced by mknod(), open_fcb(), and send_inode().

#define __S_IFDIR   0040000 /* Directory. */
#define __S_IFIFO   0010000 /* FIFO. */

Definition at line 1661 of file btrfs_drv.h.

Referenced by mknod(), open_fcb(), and send_inode().

#define __S_IFLNK   0120000 /* Symbolic link. */
#define __S_IFMT   0170000 /* These bits determine file type. */

Definition at line 1656 of file btrfs_drv.h.

#define __S_IFREG   0100000 /* Regular file. */

Definition at line 1660 of file btrfs_drv.h.

Referenced by allocate_cache_chunk(), delete_reparse_point(), mknod(), and send_inode().

#define __S_IFSOCK   0140000 /* Socket. */

Definition at line 1663 of file btrfs_drv.h.

Referenced by mknod(), open_fcb(), and send_inode().

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

Definition at line 1664 of file btrfs_drv.h.

#define _Acquires_exclusive_lock_ (   a)

Definition at line 174 of file btrfs_drv.h.

#define _Acquires_shared_lock_ (   a)

Definition at line 175 of file btrfs_drv.h.

#define _Create_lock_level_ (   a)

Definition at line 170 of file btrfs_drv.h.

#define _CRT_SECURE_NO_WARNINGS

Definition at line 27 of file btrfs_drv.h.

#define _Dispatch_type_ (   a)

Definition at line 169 of file btrfs_drv.h.

#define _Has_lock_level_ (   a)

Definition at line 172 of file btrfs_drv.h.

#define _Lock_level_order_ (   a,
  b 
)

Definition at line 171 of file btrfs_drv.h.

#define _NO_CRT_STDIO_INLINE

Definition at line 28 of file btrfs_drv.h.

#define _Out_writes_bytes_opt_ (   a)

Definition at line 165 of file btrfs_drv.h.

Referenced by DECLARE_INTERFACE_().

#define _Post_satisfies_ (   a)

Definition at line 167 of file btrfs_drv.h.

#define _Pre_satisfies_ (   a)

Definition at line 166 of file btrfs_drv.h.

#define _Releases_exclusive_lock_ (   a)

Definition at line 168 of file btrfs_drv.h.

#define _Releases_lock_ (   a)

Definition at line 164 of file btrfs_drv.h.

#define _Requires_exclusive_lock_held_ (   a)

Definition at line 163 of file btrfs_drv.h.

#define _Requires_lock_held_ (   a)

Definition at line 162 of file btrfs_drv.h.

#define _Requires_lock_not_held_ (   a)

Definition at line 173 of file btrfs_drv.h.

#define _WIN32_WINNT   0x0601

Definition at line 25 of file btrfs_drv.h.

#define ALLOC_TAG   0x7442484D

Definition at line 85 of file btrfs_drv.h.

Referenced by _Dispatch_type_(), _Function_class_(), _Success_(), add_balance_item(), add_calc_job(), add_changed_extent_ref(), add_changed_extent_ref_edr(), add_changed_extent_ref_sdr(), add_checksum_entry(), add_children_to_move_list(), add_data_reloc(), add_data_reloc_extent_item(), add_delete_inode_extref(), add_device(), add_dir_child(), add_ext_holes(), add_extent_to_fcb(), add_group_mapping(), add_insert_extent_rollback(), add_metadata_reloc(), add_metadata_reloc_extent_item(), add_parents(), add_partial_stripe(), add_pending_rmdir(), add_rollback(), add_rollback_space(), add_root_item_to_cache(), add_root_ref(), add_shared_block_extent_ref(), add_shared_data_extent_ref(), add_space_entry(), add_superblock_stripe(), add_thread_job(), add_to_bootstrap(), add_tree_block_extent_ref(), add_trim_entry(), add_user_mapping(), add_volume_device(), AddDevice(), alloc_chunk(), allocate_cache_chunk(), allow_degraded_mount(), balance_data_chunk(), bInitDefaultPalette(), bInitSURF(), bus_query_device_relations(), bus_query_hardware_ids(), check_csum(), clean_space_cache(), construct_extent_item(), create_calc_threads(), create_chunk(), create_directory_fcb(), create_fcb(), create_root(), create_snapshot(), create_stream(), create_subvol(), data_reloc_add_tree_edr(), decrease_extent_refcount(), delete_root_ref(), delete_xattr(), disk_arrival(), divide_ext(), do_create_snapshot(), do_tree_writes(), do_write_file_prealloc(), drop_chunk(), drop_root(), DrvEnablePDEV(), DrvEnableSurface(), DrvSetPalette(), DrvSetPointerShape(), duplicate_extents(), duplicate_fcb(), enqueue_pnp_callback(), excise_extents(), extend_file(), fcb_load_csums(), file_create(), file_create2(), file_desc_fcb(), file_desc_fileref(), find_device_from_uuid(), finish_removing_device(), flush_changed_dev_stats(), flush_changed_extent(), flush_disk_caches(), flush_extents(), flush_fcb(), flush_fileref(), flush_partial_stripe(), flush_refs(), flush_subvol(), found_path(), fs_ignored(), fsctl_set_xattr(), get_changed_extent_item(), get_device_pnp_name_guid(), get_registry_value(), get_reparse_block(), get_reparse_point(), get_top_level_sd(), GetAvailableModes(), getAvailableModes(), gid_to_sid(), handle_batch_collision(), if(), increase_extent_refcount(), init_cache(), init_device(), InitPointer(), InitSurface(), insert_sparse_extent(), insert_tree_extent(), insert_tree_extent_skinny(), insert_tree_item_batch(), IntInitDefaultPalette(), IntSetPalette(), invalidate_volumes(), is_btrfs_volume(), is_device_part_of_mounted_btrfs_raid(), lie_about_fs_type(), load_chunk_root(), load_default_acl(), load_dir_children(), load_free_space_cache(), load_stored_free_space_cache(), load_stored_free_space_tree(), load_sys_chunks(), load_tree(), log_error(), log_file_checksum_error(), log_file_checksum_error_shared(), log_tree_checksum_error(), log_tree_checksum_error_shared(), look_for_roots(), lzo_write_compressed_bit(), make_file_orphan(), mknod(), mount_vol(), mountmgr_add_drive_letter(), mountmgr_process_drive(), move_across_subvols(), notify_change_directory(), open_fcb(), open_fcb_stream(), open_file(), open_fileref_by_inode(), partial_stripe_read(), pdo_query_device_id(), pdo_query_hardware_ids(), prepare_raid0_write(), prepare_raid10_write(), prepare_raid5_write(), prepare_raid6_write(), query_directory(), rationalize_extents(), read_data(), read_data_dup(), read_data_raid10(), read_data_raid5(), read_data_raid6(), read_file(), read_group_mappings(), read_mappings(), read_registry(), read_superblock(), registry_load_volume_options(), registry_mark_volume_mounted(), registry_mark_volume_unmounted(), registry_mark_volume_unmounted_path(), remove_drive_letter(), remove_fcb_extent(), remove_superblocks(), remove_volume_child(), reset_subkeys(), scrub_chunk(), scrub_chunk_raid56_stripe_run(), scrub_extent(), scrub_extent_dup(), scrub_extent_raid0(), scrub_extent_raid10(), scrub_raid6_stripe(), send_add_dir(), send_disks_pnp_message(), send_extent_data(), send_inode(), send_inode_extref(), send_inode_ref(), send_notification_fcb(), send_notification_fileref(), send_subvol(), set_link_information(), set_rename_information(), set_reparse_point(), set_symlink(), set_xattr(), snapshot_tree_copy(), space_list_add2(), space_list_subtract2(), split_tree_at(), still_has_superblock(), stream_set_end_of_file_information(), sync_read_phys(), test_vol(), trim_unalloc_space(), truncate_file(), try_tree_amalgamate(), uid_to_sid(), update_changed_extent_ref(), update_chunk_cache(), update_chunk_cache_tree(), update_chunk_usage(), update_dev_item(), update_extent_level(), update_root_backref(), verify_device(), VGADDI_AllocSavedScreenBits(), VGADDI_InitializeOffScreenMem(), vol_get_disk_extents(), vol_read(), write_data(), write_file2(), write_metadata_items(), write_superblock(), write_trees(), zero_data(), and zlib_write_compressed_bit().

#define ALLOC_TAG_ZLIB   0x7A42484D

Definition at line 86 of file btrfs_drv.h.

Referenced by zlib_alloc().

#define BALANCE_OPTS_DATA   0
#define BALANCE_OPTS_METADATA   1
#define BALANCE_OPTS_SYSTEM   2
#define BTRFS_NODE_TYPE_CCB   0x2295

Definition at line 82 of file btrfs_drv.h.

Referenced by _Dispatch_type_(), file_create(), mount_vol(), and open_file().

#define BTRFS_NODE_TYPE_FCB   0x2296

Definition at line 83 of file btrfs_drv.h.

Referenced by create_fcb().

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

Definition at line 113 of file btrfs_drv.h.

Referenced by AddDevice(), and is_btrfs_volume().

#define CC_ENABLE_DISK_IO_ACCOUNTING   0x00000010

Definition at line 1744 of file btrfs_drv.h.

Referenced by FatInitializeCacheMap(), and init_file_cache().

#define COMPRESSED_EXTENT_SIZE   0x20000

Definition at line 107 of file btrfs_drv.h.

Referenced by write_compressed(), write_file2(), and zero_data().

#define EA_DOSATTRIB   "user.DOSATTRIB"

Definition at line 94 of file btrfs_drv.h.

#define EA_DOSATTRIB_HASH   0x914f9939

Definition at line 95 of file btrfs_drv.h.

Referenced by flush_fcb(), get_file_attributes(), and open_fcb().

#define EA_EA   "user.EA"

Definition at line 100 of file btrfs_drv.h.

#define EA_EA_HASH   0x8270dd43

Definition at line 101 of file btrfs_drv.h.

Referenced by flush_fcb(), get_ea_len(), and open_fcb().

#define EA_NTACL   "security.NTACL"

Definition at line 91 of file btrfs_drv.h.

#define EA_NTACL_HASH   0x45922146

Definition at line 92 of file btrfs_drv.h.

Referenced by fcb_get_sd(), flush_fcb(), and open_fcb().

#define EA_PROP_COMPRESSION   "btrfs.compression"

Definition at line 103 of file btrfs_drv.h.

Referenced by flush_fcb(), fsctl_set_xattr(), and open_fcb().

#define EA_PROP_COMPRESSION_HASH   0x20ccdf69

Definition at line 104 of file btrfs_drv.h.

Referenced by flush_fcb(), and open_fcb().

#define EA_REPARSE   "user.reparse"

Definition at line 97 of file btrfs_drv.h.

#define EA_REPARSE_HASH   0xfabad1fe

Definition at line 98 of file btrfs_drv.h.

Referenced by flush_fcb(), and open_fcb().

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

Definition at line 1170 of file btrfs_drv.h.

Referenced by print_open_trees().

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

Definition at line 121 of file btrfs_drv.h.

Referenced by FatCommonQueryEa(), interp_pop_except(), interp_push_except(), and thread_proc().

#define FILE_DEVICE_ALLOW_APPCONTAINER_TRAVERSAL   0x00020000

Definition at line 130 of file btrfs_drv.h.

Referenced by AddDevice(), and test_volume_info().

#define FILE_SUPPORTS_BLOCK_REFCOUNTING   0x08000000

Definition at line 126 of file btrfs_drv.h.

Referenced by _Dispatch_type_().

#define finally   if (1)

Definition at line 122 of file btrfs_drv.h.

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

Definition at line 1169 of file btrfs_drv.h.

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

Definition at line 140 of file btrfs_drv.h.

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

Definition at line 156 of file btrfs_drv.h.

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

Definition at line 157 of file btrfs_drv.h.

#define funcname   __func__

Definition at line 1117 of file btrfs_drv.h.

#define GID_NOBODY   65534

Definition at line 89 of file btrfs_drv.h.

Referenced by create_directory_fcb(), create_subvol(), file_create2(), and mknod().

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

Definition at line 111 of file btrfs_drv.h.

Referenced by get_reparse_point(), get_reparse_tag(), and set_reparse_point().

#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 984 of file btrfs_drv.h.

Referenced by _Function_class_(), add_balance_item(), add_delete_inode_extref(), add_device(), add_root_ref(), add_to_bootstrap(), allocate_cache_chunk(), commit_batch_list_root(), create_stream(), create_subvol(), decrease_extent_refcount(), delete_root_ref(), do_create_snapshot(), drop_chunk(), drop_root(), find_chunk_usage(), find_default_subvol(), find_disk_holes(), find_extent_data_refcount(), find_extent_shared_data_refcount(), find_extent_shared_tree_refcount(), find_item_in_tree(), find_subvol(), finish_removing_device(), flush_changed_dev_stats(), flush_changed_extent(), flush_fcb(), flush_subvol(), get_orphan_name(), handle_batch_collision(), increase_extent_refcount(), insert_tree_item(), insert_tree_item_batch(), is_extent_unique(), load_dir_children(), load_stored_free_space_cache(), load_stored_free_space_tree(), look_for_balance_item(), look_for_collision(), open_fcb_stream(), remove_balance_item(), send_read_symlink(), try_clone(), update_chunk_cache(), update_chunk_usage(), update_dev_item(), update_extent_level(), update_root_backref(), wait_for_flush(), and write_trees().

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

Definition at line 1568 of file btrfs_drv.h.

Referenced by get_inode_info(), and send_inode().

#define MAX_EXTENT_SIZE   0x8000000
#define NTDDI_VERSION   0x06020000

Definition at line 26 of file btrfs_drv.h.

#define READ_AHEAD_GRANULARITY   COMPRESSED_EXTENT_SIZE
#define S_IRGRP   (S_IRUSR >> 3)

Definition at line 1688 of file btrfs_drv.h.

#define S_IROTH   (S_IRGRP >> 3)

Definition at line 1700 of file btrfs_drv.h.

#define S_IRUSR   0000400

Definition at line 1671 of file btrfs_drv.h.

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

Definition at line 1667 of file btrfs_drv.h.

Referenced by fcb_alloc_size().

#define S_ISGID   0002000

Definition at line 1716 of file btrfs_drv.h.

#define S_ISUID   0004000

Definition at line 1712 of file btrfs_drv.h.

#define S_ISVTX   0001000

Definition at line 1720 of file btrfs_drv.h.

#define S_IWGRP   (S_IWUSR >> 3)

Definition at line 1692 of file btrfs_drv.h.

#define S_IWOTH   (S_IWGRP >> 3)

Definition at line 1704 of file btrfs_drv.h.

#define S_IWUSR   0000200

Definition at line 1675 of file btrfs_drv.h.

#define S_IXGRP   (S_IXUSR >> 3)

Definition at line 1696 of file btrfs_drv.h.

#define S_IXOTH   (S_IXGRP >> 3)

Definition at line 1708 of file btrfs_drv.h.

#define S_IXUSR   0000100

Definition at line 1679 of file btrfs_drv.h.

#define TRACE (   s,
  ... 
)

Definition at line 1167 of file btrfs_drv.h.

#define try   if (1)

Definition at line 120 of file btrfs_drv.h.

#define UID_NOBODY   65534

Definition at line 88 of file btrfs_drv.h.

Referenced by create_directory_fcb(), create_subvol(), fcb_get_new_sd(), mknod(), and sid_to_uid().

#define UNUSED (   x)    (void)(x)
#define VCB_TYPE_CONTROL   2

Definition at line 620 of file btrfs_drv.h.

Referenced by _Dispatch_type_(), and _Function_class_().

#define VCB_TYPE_FS   1

Definition at line 619 of file btrfs_drv.h.

Referenced by _Dispatch_type_(), and mount_vol().

#define VCB_TYPE_PDO   4

Definition at line 622 of file btrfs_drv.h.

Referenced by _Dispatch_type_(), and add_volume_device().

#define VCB_TYPE_VOLUME   3

Definition at line 621 of file btrfs_drv.h.

Referenced by _Dispatch_type_(), AddDevice(), and mount_vol().

#define WARN (   s,
  ... 
)

Definition at line 1168 of file btrfs_drv.h.

Typedef Documentation

typedef struct _ccb ccb

Definition at line 1289 of file btrfs_drv.h.

typedef struct _PEB PEB
typedef struct _PEB* PPEB
typedef VOID(NTAPI * PPS_POST_PROCESS_INIT_ROUTINE)(VOID)

Definition at line 1791 of file btrfs_drv.h.

typedef struct _root root

Definition at line 1740 of file btrfs_drv.h.

Definition at line 1737 of file btrfs_drv.h.

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

Definition at line 1747 of file btrfs_drv.h.

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

Definition at line 1749 of file btrfs_drv.h.

typedef BOOLEAN(* tPsIsDiskCountersEnabled)()

Definition at line 1732 of file btrfs_drv.h.

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

Definition at line 1734 of file btrfs_drv.h.

typedef struct _tree tree

Enumeration Type Documentation

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 429 of file btrfs_drv.h.

Enumerator
PropCompression_None 
PropCompression_Zlib 
PropCompression_LZO 

Definition at line 234 of file btrfs_drv.h.

Enumerator
ROLLBACK_INSERT_EXTENT 
ROLLBACK_DELETE_EXTENT 
ROLLBACK_ADD_SPACE 
ROLLBACK_SUBTRACT_SPACE 

Definition at line 1198 of file btrfs_drv.h.

Enumerator
WriteDataStatus_Pending 
WriteDataStatus_Success 
WriteDataStatus_Error 
WriteDataStatus_Cancelling 
WriteDataStatus_Cancelled 
WriteDataStatus_Ignore 

Definition at line 855 of file btrfs_drv.h.

Function Documentation

_Create_lock_level_ ( tree_lock  )
_Dispatch_type_ ( IRP_MJ_WRITE  )
_Dispatch_type_ ( IRP_MJ_DIRECTORY_CONTROL  )
_Dispatch_type_ ( IRP_MJ_QUERY_SECURITY  )
_Dispatch_type_ ( IRP_MJ_SET_SECURITY  )
_Dispatch_type_ ( IRP_MJ_SET_INFORMATION  )
_Dispatch_type_ ( IRP_MJ_QUERY_INFORMATION  )
_Dispatch_type_ ( IRP_MJ_QUERY_EA  )
_Dispatch_type_ ( IRP_MJ_SET_EA  )
_Dispatch_type_ ( IRP_MJ_CREATE  )
_Dispatch_type_ ( IRP_MJ_READ  )
_Dispatch_type_ ( IRP_MJ_PNP  )
_Dispatch_type_ ( IRP_MJ_DEVICE_CONTROL  )
_Function_class_ ( KSTART_ROUTINE  )

Definition at line 3027 of file balance.c.

3029  {
3030 #else
3031 void NTAPI balance_thread(void* context) {
3032 #endif
3033  device_extension* Vcb = (device_extension*)context;
3034  LIST_ENTRY chunks;
3035  LIST_ENTRY* le;
3036  UINT64 num_chunks[3], okay_metadata_chunks = 0, okay_data_chunks = 0, okay_system_chunks = 0;
3037  UINT64 old_data_flags = 0, old_metadata_flags = 0, old_system_flags = 0;
3038  NTSTATUS Status;
3039 
3040  Vcb->balance.balance_num++;
3041 
3042  Vcb->balance.stopping = FALSE;
3044 
3046  old_data_flags = Vcb->data_flags;
3048 
3050  }
3051 
3052  if (Vcb->balance.opts[BALANCE_OPTS_METADATA].flags & BTRFS_BALANCE_OPTS_ENABLED && Vcb->balance.opts[BALANCE_OPTS_METADATA].flags & BTRFS_BALANCE_OPTS_CONVERT) {
3053  old_metadata_flags = Vcb->metadata_flags;
3055  }
3056 
3057  if (Vcb->balance.opts[BALANCE_OPTS_SYSTEM].flags & BTRFS_BALANCE_OPTS_ENABLED && Vcb->balance.opts[BALANCE_OPTS_SYSTEM].flags & BTRFS_BALANCE_OPTS_CONVERT) {
3058  old_system_flags = Vcb->system_flags;
3060  }
3061 
3065  else if (Vcb->balance.opts[BALANCE_OPTS_METADATA].flags & BTRFS_BALANCE_OPTS_ENABLED)
3067  }
3068 
3069  num_chunks[0] = num_chunks[1] = num_chunks[2] = 0;
3070  Vcb->balance.total_chunks = Vcb->balance.chunks_left = 0;
3071 
3072  InitializeListHead(&chunks);
3073 
3074  // FIXME - what are we supposed to do with limit_start?
3075 
3076  if (!Vcb->readonly) {
3077  if (!Vcb->balance.removing && !Vcb->balance.shrinking) {
3078  Status = add_balance_item(Vcb);
3079  if (!NT_SUCCESS(Status)) {
3080  ERR("add_balance_item returned %08x\n", Status);
3081  Vcb->balance.status = Status;
3082  goto end;
3083  }
3084  } else {
3085  if (Vcb->need_write) {
3086  Status = do_write(Vcb, NULL);
3087 
3088  free_trees(Vcb);
3089 
3090  if (!NT_SUCCESS(Status)) {
3091  ERR("do_write returned %08x\n", Status);
3092  Vcb->balance.status = Status;
3093  goto end;
3094  }
3095  }
3096  }
3097  }
3098 
3100 
3101  if (Vcb->balance.stopping)
3102  goto end;
3103 
3105 
3106  le = Vcb->chunks.Flink;
3107  while (le != &Vcb->chunks) {
3109  UINT8 sort;
3110 
3112 
3113  if (c->chunk_item->type & BLOCK_FLAG_DATA)
3114  sort = BALANCE_OPTS_DATA;
3115  else if (c->chunk_item->type & BLOCK_FLAG_METADATA)
3116  sort = BALANCE_OPTS_METADATA;
3117  else if (c->chunk_item->type & BLOCK_FLAG_SYSTEM)
3118  sort = BALANCE_OPTS_SYSTEM;
3119  else {
3120  ERR("unexpected chunk type %llx\n", c->chunk_item->type);
3122  break;
3123  }
3124 
3125  if ((!(Vcb->balance.opts[sort].flags & BTRFS_BALANCE_OPTS_LIMIT) || num_chunks[sort] < Vcb->balance.opts[sort].limit_end) &&
3126  should_balance_chunk(Vcb, sort, c)) {
3127  InsertTailList(&chunks, &c->list_entry_balance);
3128 
3129  num_chunks[sort]++;
3130  Vcb->balance.total_chunks++;
3131  Vcb->balance.chunks_left++;
3132  } else if (sort == BALANCE_OPTS_METADATA)
3133  okay_metadata_chunks++;
3134  else if (sort == BALANCE_OPTS_DATA)
3135  okay_data_chunks++;
3136  else if (sort == BALANCE_OPTS_SYSTEM)
3137  okay_system_chunks++;
3138 
3139  if (!c->cache_loaded) {
3140  Status = load_cache_chunk(Vcb, c, NULL);
3141 
3142  if (!NT_SUCCESS(Status)) {
3143  ERR("load_cache_chunk returned %08x\n", Status);
3144  Vcb->balance.status = Status;
3147  goto end;
3148  }
3149  }
3150 
3152 
3153  le = le->Flink;
3154  }
3155 
3157 
3158  // If we're doing a full balance, try and allocate a new chunk now, before we mess things up
3159  if (okay_metadata_chunks == 0 || okay_data_chunks == 0 || okay_system_chunks == 0) {
3160  BOOL consolidated = FALSE;
3161  chunk* c;
3162 
3163  if (okay_metadata_chunks == 0) {
3165 
3166  Status = alloc_chunk(Vcb, Vcb->metadata_flags, &c, TRUE);
3167  if (NT_SUCCESS(Status))
3168  c->balance_num = Vcb->balance.balance_num;
3169  else if (Status != STATUS_DISK_FULL || consolidated) {
3170  ERR("alloc_chunk returned %08x\n", Status);
3172  Vcb->balance.status = Status;
3173  goto end;
3174  }
3175 
3177 
3178  if (Status == STATUS_DISK_FULL) {
3179  Status = try_consolidation(Vcb, Vcb->metadata_flags, &c);
3180  if (!NT_SUCCESS(Status)) {
3181  ERR("try_consolidation returned %08x\n", Status);
3182  Vcb->balance.status = Status;
3183  goto end;
3184  } else
3185  c->balance_num = Vcb->balance.balance_num;
3186 
3187  consolidated = TRUE;
3188 
3189  if (Vcb->balance.stopping)
3190  goto end;
3191  }
3192  }
3193 
3194  if (okay_data_chunks == 0) {
3196 
3197  Status = alloc_chunk(Vcb, Vcb->data_flags, &c, TRUE);
3198  if (NT_SUCCESS(Status))
3199  c->balance_num = Vcb->balance.balance_num;
3200  else if (Status != STATUS_DISK_FULL || consolidated) {
3201  ERR("alloc_chunk returned %08x\n", Status);
3203  Vcb->balance.status = Status;
3204  goto end;
3205  }
3206 
3208 
3209  if (Status == STATUS_DISK_FULL) {
3210  Status = try_consolidation(Vcb, Vcb->data_flags, &c);
3211  if (!NT_SUCCESS(Status)) {
3212  ERR("try_consolidation returned %08x\n", Status);
3213  Vcb->balance.status = Status;
3214  goto end;
3215  } else
3216  c->balance_num = Vcb->balance.balance_num;
3217 
3218  consolidated = TRUE;
3219 
3220  if (Vcb->balance.stopping)
3221  goto end;
3222  }
3223  }
3224 
3225  if (okay_system_chunks == 0) {
3227 
3228  Status = alloc_chunk(Vcb, Vcb->system_flags, &c, TRUE);
3229  if (NT_SUCCESS(Status))
3230  c->balance_num = Vcb->balance.balance_num;
3231  else if (Status != STATUS_DISK_FULL || consolidated) {
3232  ERR("alloc_chunk returned %08x\n", Status);
3234  Vcb->balance.status = Status;
3235  goto end;
3236  }
3237 
3239 
3240  if (Status == STATUS_DISK_FULL) {
3241  Status = try_consolidation(Vcb, Vcb->system_flags, &c);
3242  if (!NT_SUCCESS(Status)) {
3243  ERR("try_consolidation returned %08x\n", Status);
3244  Vcb->balance.status = Status;
3245  goto end;
3246  } else
3247  c->balance_num = Vcb->balance.balance_num;
3248 
3249  consolidated = TRUE;
3250 
3251  if (Vcb->balance.stopping)
3252  goto end;
3253  }
3254  }
3255  }
3256 
3258 
3259  le = chunks.Flink;
3260  while (le != &chunks) {
3261  chunk* c = CONTAINING_RECORD(le, chunk, list_entry_balance);
3262 
3263  c->reloc = TRUE;
3264 
3265  le = le->Flink;
3266  }
3267 
3269 
3270  // do data chunks before metadata
3271  le = chunks.Flink;
3272  while (le != &chunks) {
3273  chunk* c = CONTAINING_RECORD(le, chunk, list_entry_balance);
3274  LIST_ENTRY* le2 = le->Flink;
3275 
3276  if (c->chunk_item->type & BLOCK_FLAG_DATA) {
3277  BOOL changed;
3278 
3279  do {
3280  changed = FALSE;
3281 
3282  Status = balance_data_chunk(Vcb, c, &changed);
3283  if (!NT_SUCCESS(Status)) {
3284  ERR("balance_data_chunk returned %08x\n", Status);
3285  Vcb->balance.status = Status;
3286  goto end;
3287  }
3288 
3290 
3291  if (Vcb->readonly)
3292  Vcb->balance.stopping = TRUE;
3293 
3294  if (Vcb->balance.stopping)
3295  break;
3296  } while (changed);
3297 
3298  c->changed = TRUE;
3299  c->space_changed = TRUE;
3300  }
3301 
3302  if (Vcb->balance.stopping)
3303  goto end;
3304 
3305  if (c->chunk_item->type & BLOCK_FLAG_DATA &&
3306  (!(Vcb->balance.opts[BALANCE_OPTS_METADATA].flags & BTRFS_BALANCE_OPTS_ENABLED) || !(c->chunk_item->type & BLOCK_FLAG_METADATA))) {
3309 
3310  Vcb->balance.chunks_left--;
3311  }
3312 
3313  le = le2;
3314  }
3315 
3316  // do metadata chunks
3317  while (!IsListEmpty(&chunks)) {
3318  chunk* c;
3319  BOOL changed;
3320 
3321  le = RemoveHeadList(&chunks);
3322  c = CONTAINING_RECORD(le, chunk, list_entry_balance);
3323 
3325  do {
3326  Status = balance_metadata_chunk(Vcb, c, &changed);
3327  if (!NT_SUCCESS(Status)) {
3328  ERR("balance_metadata_chunk returned %08x\n", Status);
3329  Vcb->balance.status = Status;
3330  goto end;
3331  }
3332 
3334 
3335  if (Vcb->readonly)
3336  Vcb->balance.stopping = TRUE;
3337 
3338  if (Vcb->balance.stopping)
3339  break;
3340  } while (changed);
3341 
3342  c->changed = TRUE;
3343  c->space_changed = TRUE;
3344  }
3345 
3346  if (Vcb->balance.stopping)
3347  break;
3348 
3350 
3351  Vcb->balance.chunks_left--;
3352  }
3353 
3354 end:
3355  if (!Vcb->readonly) {
3356  if (Vcb->balance.stopping || !NT_SUCCESS(Vcb->balance.status)) {
3357  le = chunks.Flink;
3358  while (le != &chunks) {
3359  chunk* c = CONTAINING_RECORD(le, chunk, list_entry_balance);
3360  c->reloc = FALSE;
3361 
3362  le = le->Flink;
3364  }
3365 
3366  if (old_data_flags != 0)
3367  Vcb->data_flags = old_data_flags;
3368 
3369  if (old_metadata_flags != 0)
3370  Vcb->metadata_flags = old_metadata_flags;
3371 
3372  if (old_system_flags != 0)
3373  Vcb->system_flags = old_system_flags;
3374  }
3375 
3376  if (Vcb->balance.removing) {
3377  device* dev = NULL;
3378 
3379  ExAcquireResourceExclusiveLite(&Vcb->tree_lock, TRUE);
3380 
3381  le = Vcb->devices.Flink;
3382  while (le != &Vcb->devices) {
3383  device* dev2 = CONTAINING_RECORD(le, device, list_entry);
3384 
3385  if (dev2->devitem.dev_id == Vcb->balance.opts[0].devid) {
3386  dev = dev2;
3387  break;
3388  }
3389 
3390  le = le->Flink;
3391  }
3392 
3393  if (dev) {
3394  if (Vcb->balance.chunks_left == 0) {
3395  Status = finish_removing_device(Vcb, dev);
3396 
3397  if (!NT_SUCCESS(Status)) {
3398  ERR("finish_removing_device returned %08x\n", Status);
3399  dev->reloc = FALSE;
3400  }
3401  } else
3402  dev->reloc = FALSE;
3403  }
3404 
3405  ExReleaseResourceLite(&Vcb->tree_lock);
3406  } else if (Vcb->balance.shrinking) {
3407  device* dev = NULL;
3408 
3409  ExAcquireResourceExclusiveLite(&Vcb->tree_lock, TRUE);
3410 
3411  le = Vcb->devices.Flink;
3412  while (le != &Vcb->devices) {
3413  device* dev2 = CONTAINING_RECORD(le, device, list_entry);
3414 
3415  if (dev2->devitem.dev_id == Vcb->balance.opts[0].devid) {
3416  dev = dev2;
3417  break;
3418  }
3419 
3420  le = le->Flink;
3421  }
3422 
3423  if (!dev) {
3424  ERR("could not find device %llx\n", Vcb->balance.opts[0].devid);
3426  }
3427 
3428  if (Vcb->balance.stopping || !NT_SUCCESS(Vcb->balance.status)) {
3429  if (dev) {
3430  Status = regenerate_space_list(Vcb, dev);
3431  if (!NT_SUCCESS(Status))
3432  WARN("regenerate_space_list returned %08x\n", Status);
3433  }
3434  } else {
3435  UINT64 old_size;
3436 
3437  old_size = dev->devitem.num_bytes;
3438  dev->devitem.num_bytes = Vcb->balance.opts[0].drange_start;
3439 
3440  Status = update_dev_item(Vcb, dev, NULL);
3441  if (!NT_SUCCESS(Status)) {
3442  ERR("update_dev_item returned %08x\n", Status);
3443  dev->devitem.num_bytes = old_size;
3444  Vcb->balance.status = Status;
3445 
3446  Status = regenerate_space_list(Vcb, dev);
3447  if (!NT_SUCCESS(Status))
3448  WARN("regenerate_space_list returned %08x\n", Status);
3449  } else {
3450  Vcb->superblock.total_bytes -= old_size - dev->devitem.num_bytes;
3451 
3452  Status = do_write(Vcb, NULL);
3453  if (!NT_SUCCESS(Status))
3454  ERR("do_write returned %08x\n", Status);
3455 
3456  free_trees(Vcb);
3457  }
3458  }
3459 
3460  ExReleaseResourceLite(&Vcb->tree_lock);
3461 
3462  if (!Vcb->balance.stopping && NT_SUCCESS(Vcb->balance.status))
3464  } else {
3465  Status = remove_balance_item(Vcb);
3466  if (!NT_SUCCESS(Status)) {
3467  ERR("remove_balance_item returned %08x\n", Status);
3468  goto end;
3469  }
3470  }
3471 
3472  if (Vcb->trim && !Vcb->options.no_trim) {
3473  ExAcquireResourceExclusiveLite(&Vcb->tree_lock, TRUE);
3474 
3475  le = Vcb->devices.Flink;
3476  while (le != &Vcb->devices) {
3477  device* dev2 = CONTAINING_RECORD(le, device, list_entry);
3478 
3479  if (dev2->devobj && !dev2->readonly && dev2->trim)
3480  trim_unalloc_space(Vcb, dev2);
3481 
3482  le = le->Flink;
3483  }
3484 
3485  ExReleaseResourceLite(&Vcb->tree_lock);
3486  }
3487  }
3488 
3489  ZwClose(Vcb->balance.thread);
3490  Vcb->balance.thread = NULL;
3491 
3492  KeSetEvent(&Vcb->balance.finished, 0, FALSE);
3493 }
BOOL reloc
Definition: btrfs_drv.h:482
mount_options options
Definition: btrfs_drv.h:713
UINT64 total_bytes
Definition: btrfs.h:212
BOOL readonly
Definition: btrfs_drv.h:481
#define BTRFS_INCOMPAT_FLAGS_MIXED_GROUPS
Definition: btrfs.h:104
BOOL stopping
Definition: btrfs_drv.h:656
BOOL changed
Definition: btrfs_drv.h:534
#define TRUE
Definition: types.h:120
UINT64 chunks_left
Definition: btrfs_drv.h:653
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define BALANCE_OPTS_SYSTEM
Definition: btrfs_drv.h:648
BOOL removing
Definition: btrfs_drv.h:657
Definition: http.c:6587
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
btrfs_balance_opts opts[3]
Definition: btrfs_drv.h:654
_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:7272
PDEVICE_OBJECT devobj
Definition: btrfs_drv.h:477
superblock superblock
Definition: btrfs_drv.h:721
#define WARN(fmt,...)
Definition: debug.h:111
ERESOURCE chunk_lock
Definition: btrfs_drv.h:767
static NTSTATUS balance_data_chunk(device_extension *Vcb, chunk *c, BOOL *changed)
Definition: balance.c:1668
HANDLE thread
Definition: btrfs_drv.h:651
UINT64 metadata_flags
Definition: btrfs_drv.h:741
UINT64 dev_id
Definition: btrfs.h:156
GLuint GLuint end
Definition: gl.h:1545
#define InsertTailList(ListHead, Entry)
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
LIST_ENTRY devices
Definition: btrfs_drv.h:716
balance_info balance
Definition: btrfs_drv.h:772
KEVENT finished
Definition: btrfs_drv.h:663
#define BLOCK_FLAG_SINGLE
Definition: btrfsioctl.h:134
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define STATUS_INTERNAL_ERROR
Definition: ntstatus.h:451
static NTSTATUS try_consolidation(device_extension *Vcb, UINT64 flags, chunk **newchunk)
Definition: balance.c:2884
#define BTRFS_BALANCE_OPTS_CONVERT
Definition: btrfsioctl.h:131
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
Definition: devices.h:39
LIST_ENTRY list_entry_balance
Definition: btrfs_drv.h:543
PFILE_OBJECT root_file
Definition: btrfs_drv.h:777
#define BLOCK_FLAG_SYSTEM
Definition: shellext.h:59
BOOL shrinking
Definition: btrfs_drv.h:658
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
void free_trees(device_extension *Vcb)
Definition: treefuncs.c:771
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define FSRTL_VOLUME_CHANGE_SIZE
Definition: fsrtltypes.h:101
static NTSTATUS add_balance_item(device_extension *Vcb)
Definition: balance.c:2360
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
static NTSTATUS regenerate_space_list(device_extension *Vcb, device *dev)
Definition: balance.c:2977
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI FsRtlNotifyVolumeEvent(IN PFILE_OBJECT FileObject, IN ULONG EventCode)
Definition: pnp.c:38
NTSTATUS status
Definition: btrfs_drv.h:661
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define Vcb
Definition: cdprocs.h:1425
#define BTRFS_BALANCE_OPTS_LIMIT
Definition: btrfsioctl.h:128
const GLubyte * c
Definition: glext.h:8905
UINT64 type
Definition: btrfs.h:315
UINT64 system_flags
Definition: btrfs_drv.h:742
KEVENT event
Definition: btrfs_drv.h:662
UINT64 incompat_flags
Definition: btrfs.h:224
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
NTSTATUS update_dev_item(device_extension *Vcb, device *device, PIRP Irp)
Definition: flushthread.c:3865
#define BTRFS_BALANCE_OPTS_ENABLED
Definition: btrfsioctl.h:123
#define BLOCK_FLAG_METADATA
Definition: shellext.h:60
Definition: typedefs.h:117
static NTSTATUS balance_metadata_chunk(device_extension *Vcb, chunk *c, BOOL *changed)
Definition: balance.c:1100
NTSTATUS alloc_chunk(device_extension *Vcb, UINT64 flags, chunk **pc, BOOL full_size)
Definition: write.c:365
Status
Definition: gdiplustypes.h:24
LIST_ENTRY chunks
Definition: btrfs_drv.h:756
NTSTATUS load_cache_chunk(device_extension *Vcb, chunk *c, PIRP Irp)
Definition: free-space.c:947
#define ERR(fmt,...)
Definition: debug.h:109
ULONG balance_num
Definition: btrfs_drv.h:660
static NTSTATUS remove_balance_item(device_extension *Vcb)
Definition: balance.c:2433
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
BOOL reloc
Definition: btrfs_drv.h:531
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
BOOL cache_loaded
Definition: btrfs_drv.h:533
Definition: list.h:27
DEV_ITEM devitem
Definition: btrfs_drv.h:478
ERESOURCE lock
Definition: btrfs_drv.h:527
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
CHUNK_ITEM * chunk_item
Definition: btrfs_drv.h:512
#define BLOCK_FLAG_DATA
Definition: shellext.h:58
static NTSTATUS finish_removing_device(_Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, device *dev)
Definition: balance.c:2568
ULONG balance_num
Definition: btrfs_drv.h:540
#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:2784
#define c
Definition: ke_i.h:80
BOOL space_changed
Definition: btrfs_drv.h:535
BOOL trim
Definition: btrfs_drv.h:483
unsigned long long UINT64
UINT64 total_chunks
Definition: btrfs_drv.h:652
#define BALANCE_OPTS_METADATA
Definition: btrfs_drv.h:647
static BOOL should_balance_chunk(device_extension *Vcb, UINT8 sort, chunk *c)
Definition: balance.c:2207
unsigned char UINT8
UINT64 num_bytes
Definition: btrfs.h:157
#define BALANCE_OPTS_DATA
Definition: btrfs_drv.h:646
_Function_class_ ( DRIVER_NOTIFICATION_CALLBACK_ROUTINE  )
_Post_satisfies_ ( return >=  n)
_Releases_lock_ ( c->  lock)
_Requires_lock_held_ ( Vcb->  fcb_lock) -> fcb_lock) static __inline void release_fcb_lock(device_extension* Vcb)

Definition at line 939 of file btrfs_drv.h.

941  {
942  ExReleaseResourceLite(&Vcb->fcb_lock);
943 }
#define Vcb
Definition: cdprocs.h:1425
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
_Requires_lock_held_ ( c->  lock)
pure virtual
_Requires_lock_not_held_ ( Vcb->  fcb_lock) -> fcb_lock) static __inline void acquire_fcb_lock_shared(device_extension* Vcb)

Definition at line 899 of file btrfs_drv.h.

901  {
902 #ifdef DEBUG_STATS
903  LARGE_INTEGER time1, time2;
904 
905  if (ExAcquireResourceSharedLite(&Vcb->fcb_lock, FALSE))
906  return;
907 
909 #endif
910 
911  ExAcquireResourceSharedLite(&Vcb->fcb_lock, TRUE);
912 
913 #ifdef DEBUG_STATS
915  Vcb->stats.fcb_lock_time += time2.QuadPart - time1.QuadPart;
916 #endif
917 }
LARGE_INTEGER NTAPI KeQueryPerformanceCounter(IN PLARGE_INTEGER PerformanceFreq)
Definition: timer.c:138
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define Vcb
Definition: cdprocs.h:1425
BOOLEAN NTAPI ExAcquireResourceSharedLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:885
LONGLONG QuadPart
Definition: typedefs.h:112
_Success_ ( return  )
NTSTATUS add_calc_job ( device_extension Vcb,
UINT8 data,
UINT32  sectors,
UINT32 csum,
calc_job **  pcj 
)

Definition at line 22 of file calcthread.c.

Referenced by calc_csum(), and check_csum().

22  {
23  calc_job* cj;
24 
26  if (!cj) {
27  ERR("out of memory\n");
29  }
30 
31  cj->data = data;
32  cj->sectors = sectors;
33  cj->csum = csum;
34  cj->pos = 0;
35  cj->done = 0;
36  cj->refcount = 1;
38 
40 
42 
43  KeSetEvent(&Vcb->calcthreads.event, 0, FALSE);
45 
47 
48  *pcj = cj;
49 
50  return STATUS_SUCCESS;
51 }
#define TRUE
Definition: types.h:120
_In_ ULONG cj
Definition: winddi.h:3540
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
return STATUS_SUCCESS
Definition: btrfs.c:2690
UINT32 * csum
Definition: write.c:2816
KEVENT event
Definition: btrfs_drv.h:582
#define InsertTailList(ListHead, Entry)
LONG refcount
Definition: btrfs_drv.h:583
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define ALLOC_TAG
Definition: btrfs_drv.h:85
#define FALSE
Definition: types.h:117
UINT32 sectors
Definition: btrfs_drv.h:580
LIST_ENTRY job_list
Definition: btrfs_drv.h:596
ERESOURCE lock
Definition: btrfs_drv.h:597
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
LONG done
Definition: btrfs_drv.h:581
UINT32 * csum
Definition: btrfs_drv.h:579
#define ERR(fmt,...)
Definition: debug.h:109
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
drv_calc_threads calcthreads
Definition: btrfs_drv.h:771
__u8 sectors[2]
Definition: mkdosfs.c:366
LONG pos
Definition: btrfs_drv.h:581
LIST_ENTRY list_entry
Definition: btrfs_drv.h:584
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
UINT8 * data
Definition: btrfs_drv.h:578
void add_changed_extent_ref ( chunk c,
UINT64  address,
UINT64  size,
UINT64  root,
UINT64  objid,
UINT64  offset,
UINT32  count,
BOOL  no_csum 
)

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

Referenced by rationalize_extents().

2075  {
2076  changed_extent* ce;
2077  changed_extent_ref* cer;
2078  LIST_ENTRY* le;
2079 
2080  ce = get_changed_extent_item(c, address, size, no_csum);
2081 
2082  if (!ce) {
2083  ERR("get_changed_extent_item failed\n");
2084  return;
2085  }
2086 
2087  le = ce->refs.Flink;
2088  while (le != &ce->refs) {
2090 
2091  if (cer->type == TYPE_EXTENT_DATA_REF && cer->edr.root == root && cer->edr.objid == objid && cer->edr.offset == offset) {
2092  ce->count += count;
2093  cer->edr.count += count;
2094  return;
2095  }
2096 
2097  le = le->Flink;
2098  }
2099 
2101 
2102  if (!cer) {
2103  ERR("out of memory\n");
2104  return;
2105  }
2106 
2107  cer->type = TYPE_EXTENT_DATA_REF;
2108  cer->edr.root = root;
2109  cer->edr.objid = objid;
2110  cer->edr.offset = offset;
2111  cer->edr.count = count;
2112 
2113  InsertTailList(&ce->refs, &cer->list_entry);
2114 
2115  ce->count += count;
2116 }
LIST_ENTRY list_entry
Definition: btrfs_drv.h:567
struct _root root
GLintptr offset
Definition: glext.h:5920
#define InsertTailList(ListHead, Entry)
#define ALLOC_TAG
Definition: btrfs_drv.h:85
UINT64 count
Definition: btrfs_drv.h:550
EXTENT_DATA_REF edr
Definition: btrfs_drv.h:563
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
GLsizeiptr size
Definition: glext.h:5919
GLuint address
Definition: glext.h:9393
UINT32 count
Definition: btrfs.h:392
UINT64 root
Definition: btrfs.h:389
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Definition: typedefs.h:117
#define ERR(fmt,...)
Definition: debug.h:109
UINT64 offset
Definition: btrfs.h:391
LIST_ENTRY refs
Definition: btrfs_drv.h:554
Definition: list.h:27
UINT64 objid
Definition: btrfs.h:390
static changed_extent * get_changed_extent_item(chunk *c, UINT64 address, UINT64 size, BOOL no_csum)
Definition: extent-tree.c:1915
#define TYPE_EXTENT_DATA_REF
Definition: btrfs.h:32
void add_checksum_entry ( device_extension Vcb,
UINT64  address,
ULONG  length,
UINT32 csum,
PIRP  Irp 
)

Definition at line 2438 of file flushthread.c.

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

2438  {
2439  KEY searchkey;
2440  traverse_ptr tp, next_tp;
2441  NTSTATUS Status;
2442  UINT64 startaddr, endaddr;
2443  ULONG len;
2444  UINT32* checksums;
2445  RTL_BITMAP bmp;
2446  ULONG* bmparr;
2447  ULONG runlength, index;
2448 
2449  searchkey.obj_id = EXTENT_CSUM_ID;
2450  searchkey.obj_type = TYPE_EXTENT_CSUM;
2451  searchkey.offset = address;
2452 
2453  // FIXME - create checksum_root if it doesn't exist at all
2454 
2455  Status = find_item(Vcb, Vcb->checksum_root, &tp, &searchkey, FALSE, Irp);
2456  if (Status == STATUS_NOT_FOUND) { // tree is completely empty
2457  if (csum) { // not deleted
2458  ULONG length2 = length;
2459  UINT64 off = address;
2460  UINT32* data = csum;
2461 
2462  do {
2463  UINT16 il = (UINT16)min(length2, MAX_CSUM_SIZE / sizeof(UINT32));
2464 
2465  checksums = ExAllocatePoolWithTag(PagedPool, il * sizeof(UINT32), ALLOC_TAG);
2466  if (!checksums) {
2467  ERR("out of memory\n");
2468  return;
2469  }
2470 
2471  RtlCopyMemory(checksums, data, il * sizeof(UINT32));
2472 
2473  Status = insert_tree_item(Vcb, Vcb->checksum_root, EXTENT_CSUM_ID, TYPE_EXTENT_CSUM, off, checksums,
2474  il * sizeof(UINT32), NULL, Irp);
2475  if (!NT_SUCCESS(Status)) {
2476  ERR("insert_tree_item returned %08x\n", Status);
2477  ExFreePool(checksums);
2478  return;
2479  }
2480 
2481  length2 -= il;
2482 
2483  if (length2 > 0) {
2484  off += il * Vcb->superblock.sector_size;
2485  data += il;
2486  }
2487  } while (length2 > 0);
2488  }
2489  } else if (!NT_SUCCESS(Status)) {
2490  ERR("find_item returned %08x\n", Status);
2491  return;
2492  } else {
2493  UINT32 tplen;
2494 
2495  // FIXME - check entry is TYPE_EXTENT_CSUM?
2496 
2497  if (tp.item->key.offset < address && tp.item->key.offset + (tp.item->size * Vcb->superblock.sector_size / sizeof(UINT32)) >= address)
2498  startaddr = tp.item->key.offset;
2499  else
2500  startaddr = address;
2501 
2502  searchkey.obj_id = EXTENT_CSUM_ID;
2503  searchkey.obj_type = TYPE_EXTENT_CSUM;
2504  searchkey.offset = address + (length * Vcb->superblock.sector_size);
2505 
2506  Status = find_item(Vcb, Vcb->checksum_root, &tp, &searchkey, FALSE, Irp);
2507  if (!NT_SUCCESS(Status)) {
2508  ERR("find_item returned %08x\n", Status);
2509  return;
2510  }
2511 
2512  tplen = tp.item->size / sizeof(UINT32);
2513 
2514  if (tp.item->key.offset + (tplen * Vcb->superblock.sector_size) >= address + (length * Vcb->superblock.sector_size))
2515  endaddr = tp.item->key.offset + (tplen * Vcb->superblock.sector_size);
2516  else
2517  endaddr = address + (length * Vcb->superblock.sector_size);
2518 
2519  TRACE("cs starts at %llx (%x sectors)\n", address, length);
2520  TRACE("startaddr = %llx\n", startaddr);
2521  TRACE("endaddr = %llx\n", endaddr);
2522 
2523  len = (ULONG)((endaddr - startaddr) / Vcb->superblock.sector_size);
2524 
2525  checksums = ExAllocatePoolWithTag(PagedPool, sizeof(UINT32) * len, ALLOC_TAG);
2526  if (!checksums) {
2527  ERR("out of memory\n");
2528  return;
2529  }
2530 
2531  bmparr = ExAllocatePoolWithTag(PagedPool, sizeof(ULONG) * ((len/8)+1), ALLOC_TAG);
2532  if (!bmparr) {
2533  ERR("out of memory\n");
2534  ExFreePool(checksums);
2535  return;
2536  }
2537 
2538  RtlInitializeBitMap(&bmp, bmparr, len);
2539  RtlSetAllBits(&bmp);
2540 
2541  searchkey.obj_id = EXTENT_CSUM_ID;
2542  searchkey.obj_type = TYPE_EXTENT_CSUM;
2543  searchkey.offset = address;
2544 
2545  Status = find_item(Vcb, Vcb->checksum_root, &tp, &searchkey, FALSE, Irp);
2546  if (!NT_SUCCESS(Status)) {
2547  ERR("find_item returned %08x\n", Status);
2548  ExFreePool(checksums);
2549  ExFreePool(bmparr);
2550  return;
2551  }
2552 
2553  // set bit = free space, cleared bit = allocated sector
2554 
2555  while (tp.item->key.offset < endaddr) {
2556  if (tp.item->key.offset >= startaddr) {
2557  if (tp.item->size > 0) {
2558  ULONG itemlen = (ULONG)min((len - (tp.item->key.offset - startaddr) / Vcb->superblock.sector_size) * sizeof(UINT32), tp.item->size);
2559 
2560  RtlCopyMemory(&checksums[(tp.item->key.offset - startaddr) / Vcb->superblock.sector_size], tp.item->data, itemlen);
2561  RtlClearBits(&bmp, (ULONG)((tp.item->key.offset - startaddr) / Vcb->superblock.sector_size), itemlen / sizeof(UINT32));
2562  }
2563 
2564  Status = delete_tree_item(Vcb, &tp);
2565  if (!NT_SUCCESS(Status)) {
2566  ERR("delete_tree_item returned %08x\n", Status);
2567  ExFreePool(checksums);
2568  ExFreePool(bmparr);
2569  return;
2570  }
2571  }
2572 
2573  if (find_next_item(Vcb, &tp, &next_tp, FALSE, Irp)) {
2574  tp = next_tp;
2575  } else
2576  break;
2577  }
2578 
2579  if (!csum) { // deleted
2580  RtlSetBits(&bmp, (ULONG)((address - startaddr) / Vcb->superblock.sector_size), length);
2581  } else {
2582  RtlCopyMemory(&checksums[(address - startaddr) / Vcb->superblock.sector_size], csum, length * sizeof(UINT32));
2583  RtlClearBits(&bmp, (ULONG)((address - startaddr) / Vcb->superblock.sector_size), length);
2584  }
2585 
2586  runlength = RtlFindFirstRunClear(&bmp, &index);
2587 
2588  while (runlength != 0) {
2589  do {
2590  UINT16 rl;
2591  UINT64 off;
2592  UINT32* data;
2593 
2594  if (runlength * sizeof(UINT32) > MAX_CSUM_SIZE)
2595  rl = MAX_CSUM_SIZE / sizeof(UINT32);
2596  else
2597  rl = (UINT16)runlength;
2598 
2599  data = ExAllocatePoolWithTag(PagedPool, sizeof(UINT32) * rl, ALLOC_TAG);
2600  if (!data) {
2601  ERR("out of memory\n");
2602  ExFreePool(bmparr);
2603  ExFreePool(checksums);
2604  return;
2605  }
2606 
2607  RtlCopyMemory(data, &checksums[index], sizeof(UINT32) * rl);
2608 
2609  off = startaddr + UInt32x32To64(index, Vcb->superblock.sector_size);
2610 
2611  Status = insert_tree_item(Vcb, Vcb->checksum_root, EXTENT_CSUM_ID, TYPE_EXTENT_CSUM, off, data, sizeof(UINT32) * rl, NULL, Irp);
2612  if (!NT_SUCCESS(Status)) {
2613  ERR("insert_tree_item returned %08x\n", Status);
2614  ExFreePool(data);
2615  ExFreePool(bmparr);
2616  ExFreePool(checksums);
2617  return;
2618  }
2619 
2620  runlength -= rl;
2621  index += rl;
2622  } while (runlength > 0);
2623 
2624  runlength = RtlFindNextForwardRunClear(&bmp, index, &index);
2625  }
2626 
2627  ExFreePool(bmparr);
2628  ExFreePool(checksums);
2629  }
2630 }
NTSYSAPI void WINAPI RtlClearBits(PRTL_BITMAP, ULONG, ULONG)
#define MAX_CSUM_SIZE
Definition: flushthread.c:23
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
UINT64 offset
Definition: btrfs.h:124
_In_ PIRP Irp
Definition: csq.h:116
root * checksum_root
Definition: btrfs_drv.h:748
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:576
superblock superblock
Definition: btrfs_drv.h:721
UINT64 obj_id
Definition: btrfs.h:122
UINT32 * csum
Definition: write.c:2816
#define TYPE_EXTENT_CSUM
Definition: btrfs.h:25
UINT16 size
Definition: btrfs_drv.h:382
UINT8 obj_type
Definition: btrfs.h:123
#define ALLOC_TAG
Definition: btrfs_drv.h:85
#define FALSE
Definition: types.h:117
unsigned int UINT32
NTSYSAPI ULONG WINAPI RtlFindNextForwardRunClear(PCRTL_BITMAP, ULONG, PULONG)
smooth NULL
Definition: ftsmooth.c:416
UINT32 sector_size
Definition: btrfs.h:216
_In_ UINT64 _In_ UINT64 _In_ UINT64 _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2610
static LONG find_item(PropertyBag *This, LPCOLESTR name)
Definition: propertybag.c:110
#define STATUS_NOT_FOUND
Definition: shellext.h:55
#define TRACE(s)
Definition: solgame.cpp:4
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
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
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
tree_data * item
Definition: btrfs_drv.h:461
#define index(s, c)
Definition: various.h:29
#define EXTENT_CSUM_ID
Definition: btrfs.h:81
GLenum GLsizei len
Definition: glext.h:6722
static void startaddr(void)
NTSTATUS insert_tree_item(_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _In_ root *r, _In_ UINT64 obj_id, _In_ UINT8 obj_type, _In_ UINT64 offset, _In_reads_bytes_opt_(size) _When_(return >=0, __drv_aliasesMem) void *data, _In_ UINT16 size, _Out_opt_ traverse_ptr *ptp, _In_opt_ PIRP Irp)
Definition: treefuncs.c:832
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
Definition: btrfs.h:121
NTSYSAPI ULONG NTAPI RtlFindFirstRunClear(_In_ PRTL_BITMAP BitMapHeader, _Out_ PULONG StartingIndex)
unsigned short UINT16
#define min(a, b)
Definition: monoChain.cc:55
Definition: fs.h:216
NTSYSAPI void WINAPI RtlSetAllBits(PRTL_BITMAP)
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI void WINAPI RtlSetBits(PRTL_BITMAP, ULONG, ULONG)
unsigned long long UINT64
#define UInt32x32To64(a, b)
Definition: intsafe.h:258
UINT8 * data
Definition: btrfs_drv.h:383
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
NTSTATUS delete_tree_item(_In_ _Requires_exclusive_lock_held_(_Curr_->tree_lock) device_extension *Vcb, _Inout_ traverse_ptr *tp)
Definition: treefuncs.c:966
off
Definition: i386-dis.c:3909
NTSTATUS add_dir_child ( fcb fcb,
UINT64  inode,
BOOL  subvol,
PANSI_STRING  utf8,
PUNICODE_STRING  name,
UINT8  type,
dir_child **  pdc 
)

Definition at line 1566 of file create.c.

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

1566  {
1567  NTSTATUS Status;
1568  dir_child* dc;
1569 
1571  if (!dc) {
1572  ERR("out of memory\n");
1574  }
1575 
1577  if (!dc->utf8.Buffer) {
1578  ERR("out of memory\n");
1579  ExFreePool(dc);
1581  }
1582 
1584  if (!dc->name.Buffer) {
1585  ERR("out of memory\n");
1586  ExFreePool(dc->utf8.Buffer);
1587  ExFreePool(dc);
1589  }
1590 
1591  dc->key.obj_id = inode;
1593  dc->key.offset = subvol ? 0xffffffffffffffff : 0;
1594  dc->type = type;
1595  dc->fileref = NULL;
1596 
1597  dc->utf8.Length = dc->utf8.MaximumLength = utf8->Length;
1598  RtlCopyMemory(dc->utf8.Buffer, utf8->Buffer, utf8->Length);
1599 
1600  dc->name.Length = dc->name.MaximumLength = name->Length;
1601  RtlCopyMemory(dc->name.Buffer, name->Buffer, name->Length);
1602 
1603  Status = RtlUpcaseUnicodeString(&dc->name_uc, name, TRUE);
1604  if (!NT_SUCCESS(Status)) {
1605  ERR("RtlUpcaseUnicodeString returned %08x\n", Status);
1606  ExFreePool(dc->utf8.Buffer);
1607  ExFreePool(dc->name.Buffer);
1608  ExFreePool(dc);
1609  return Status;
1610  }
1611 
1612  dc->hash = calc_crc32c(0xffffffff, (UINT8*)dc->name.Buffer, dc->name.Length);
1613  dc->hash_uc = calc_crc32c(0xffffffff, (UINT8*)dc->name_uc.Buffer, dc->name_uc.Length);
1614 
1615  ExAcquireResourceExclusiveLite(&fcb->nonpaged->dir_children_lock, TRUE);
1616 
1617  if (IsListEmpty(&fcb->dir_children_index))
1618  dc->index = 2;
1619  else {
1620  dir_child* dc2 = CONTAINING_RECORD(fcb->dir_children_index.Blink, dir_child, list_entry_index);
1621 
1622  dc->index = max(2, dc2->index + 1);
1623  }
1624 
1626 
1628 
1629  ExReleaseResourceLite(&fcb->nonpaged->dir_children_lock);
1630 
1631  *pdc = dc;
1632 
1633  return STATUS_SUCCESS;
1634 }
#define TYPE_ROOT_ITEM
Definition: btrfs.h:26
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct _file_ref * fileref
Definition: btrfs_drv.h:228
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSTATUS RtlUpcaseUnicodeString(PUNICODE_STRING dst, PUNICODE_STRING src, BOOLEAN Alloc)
Definition: string_lib.cpp:46
UINT64 offset
Definition: btrfs.h:124
USHORT MaximumLength
Definition: env_spec_w32.h:370
Iosb Status
Definition: create.c:4311
UNICODE_STRING name_uc
Definition: btrfs_drv.h:226
UINT32 hash_uc
Definition: btrfs_drv.h:225
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
return STATUS_SUCCESS
Definition: btrfs.c:2690
UINT64 inode
Definition: btrfs_drv.h:255
UINT64 obj_id
Definition: btrfs.h:122
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
ANSI_STRING utf8
Definition: btrfs_drv.h:222
HDC dc
Definition: cylfrac.c:34
#define InsertTailList(ListHead, Entry)
UINT8 type
Definition: btrfs_drv.h:221
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
UINT8 obj_type
Definition: btrfs.h:123
BOOLEAN NTAPI ExAcquireResourceExclusiveLite(IN PERESOURCE Resource, IN BOOLEAN Wait)
Definition: resource.c:770
#define ALLOC_TAG
Definition: btrfs_drv.h:85
static UINT32 calc_crc32c(UINT32 seed, UINT8 *msg, ULONG msglen)
Definition: recv.cpp:134
smooth NULL
Definition: ftsmooth.c:416
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
USHORT MaximumLength
Definition: env_spec_w32.h:377
LIST_ENTRY dir_children_index
Definition: btrfs_drv.h:276
LONG NTSTATUS
Definition: precomp.h:26
UINT64 index
Definition: btrfs_drv.h:220
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
LIST_ENTRY list_entry_index
Definition: btrfs_drv.h:229
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1817
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
UINT32 hash
Definition: btrfs_drv.h:223
#define TYPE_INODE_ITEM
Definition: btrfs.h:18
#define ERR(fmt,...)
Definition: debug.h:109
struct _fcb_nonpaged * nonpaged
Definition: btrfs_drv.h:250
void insert_dir_child_into_hash_lists(fcb *fcb, dir_child *dc)
Definition: fileinfo.c:1211
struct _root * subvol
Definition: btrfs_drv.h:254
unsigned char UINT8
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
UNICODE_STRING name
Definition: btrfs_drv.h:224
void add_extent ( _In_ fcb fcb,
_In_ LIST_ENTRY prevextle,
_In_ __drv_aliasesMem extent newext 
)

Definition at line 2346 of file write.c.

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

2346  {
2347  LIST_ENTRY* le = prevextle->Flink;
2348 
2349  while (le != &fcb->extents) {
2351 
2352  if (ext->offset >= newext->offset) {
2353  InsertHeadList(ext->list_entry.Blink, &newext->list_entry);
2354  return;
2355  }
2356 
2357  le = le->Flink;
2358  }
2359 
2360  InsertTailList(&fcb->extents, &newext->list_entry);
2361 }
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
LIST_ENTRY list_entry
Definition: btrfs_drv.h:203
#define InsertTailList(ListHead, Entry)
UINT64 offset
Definition: btrfs_drv.h:196
char ext[3]
Definition: mkdosfs.c:358
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
LIST_ENTRY extents
Definition: btrfs_drv.h:266
Definition: typedefs.h:117
Definition: list.h:27
NTSTATUS add_extent_to_fcb ( _In_ fcb fcb,
_In_ UINT64  offset,
_In_reads_bytes_(edsize) EXTENT_DATA ed,
_In_ UINT16  edsize,
_In_ BOOL  unique,
_In_opt_ _When_(return >=0, __drv_aliasesMem) UINT32 csum,
_In_ LIST_ENTRY rollback 
)

Definition at line 2715 of file write.c.

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

2716  {
2717  extent* ext;
2718  LIST_ENTRY* le;
2719 
2721  if (!ext) {
2722  ERR("out of memory\n");
2724  }
2725 
2726  ext->offset = offset;
2727  ext->datalen = edsize;
2728  ext->unique = unique;
2729  ext->ignore = FALSE;
2730  ext->inserted = TRUE;
2731  ext->csum = csum;
2732 
2734 
2735  le = fcb->extents.Flink;
2736  while (le != &fcb->extents) {
2737  extent* oldext = CONTAINING_RECORD(le, extent, list_entry);
2738 
2739  if (oldext->offset >= offset) {
2740  InsertHeadList(le->Blink, &ext->list_entry);
2741  goto end;
2742  }
2743 
2744  le = le->Flink;
2745  }
2746 
2748 
2749 end:
2751 
2752  return STATUS_SUCCESS;
2753 }
return TRUE
Definition: write.c:2896
void add_insert_extent_rollback(LIST_ENTRY *rollback, fcb *fcb, extent *ext)
Definition: write.c:2696
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
return STATUS_SUCCESS
Definition: btrfs.c:2690
BOOL unique
Definition: btrfs_drv.h:198
GLintptr offset
Definition: glext.h:5920
LIST_ENTRY list_entry
Definition: btrfs_drv.h:203
UINT32 * csum
Definition: write.c:2816
GLuint GLuint end
Definition: gl.h:1545
#define InsertTailList(ListHead, Entry)
#define ALLOC_TAG
Definition: btrfs_drv.h:85
#define FALSE
Definition: types.h:117
UINT16 datalen
Definition: btrfs_drv.h:197
UINT64 offset
Definition: btrfs_drv.h:196
#define offsetof(TYPE, MEMBER)
char ext[3]
Definition: mkdosfs.c:358
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
UINT32 * csum
Definition: btrfs_drv.h:201
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
LIST_ENTRY extents
Definition: btrfs_drv.h:266
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Definition: typedefs.h:117
#define ERR(fmt,...)
Definition: debug.h:109
ed2 offset
Definition: write.c:2840
BOOL ignore
Definition: btrfs_drv.h:199
Definition: list.h:27
UINT16 edsize
Definition: write.c:2815
EXTENT_DATA extent_data
Definition: btrfs_drv.h:205
_ForwardIter unique(_ForwardIter __first, _ForwardIter __last)
Definition: _algo.h:298
_In_ fcb _In_ chunk _In_ UINT64 _In_ UINT64 _In_ BOOL _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY * rollback
Definition: write.c:2809
EXTENT_DATA * ed
Definition: write.c:2813
BOOL inserted
Definition: btrfs_drv.h:200
void add_group_mapping ( WCHAR sidstring,
ULONG  sidstringlength,
UINT32  gid 
)

Definition at line 145 of file security.c.

Referenced by read_group_mappings().

145  {
146  unsigned int i, np;
147  UINT8 numdashes;
148  UINT64 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);
170  sid = ExAllocatePoolWithTag(PagedPool, sidsize, ALLOC_TAG);
171  if (!sid) {
172  ERR("out of memory\n");
173  return;
174  }
175 
176  sid->revision = 0x01;
177  sid->elements = numdashes;
178 
179  np = 0;
180  while (sidstringlength > 0) {
181  val = 0;
182  i = 0;
183  while (sidstring[i] != '-' && i < sidstringlength) {
184  if (sidstring[i] >= '0' && sidstring[i] <= '9') {
185  val *= 10;
186  val += sidstring[i] - '0';
187  } else
188  break;
189 
190  i++;
191  }
192 
193  i++;
194  TRACE("val = %u, i = %u, ssl = %u\n", (UINT32)val, i, sidstringlength);
195 
196  if (np == 0) {
197  sid->auth[0] = (UINT8)((val & 0xff0000000000) >> 40);
198  sid->auth[1] = (UINT8)((val & 0xff00000000) >> 32);
199  sid->auth[2] = (UINT8)((val & 0xff000000) >> 24);
200  sid->auth[3] = (UINT8)((val & 0xff0000) >> 16);
201  sid->auth[4] = (UINT8)((val & 0xff00) >> 8);
202  sid->auth[5] = val & 0xff;
203  } else
204  sid->nums[np-1] = (UINT32)val;
205 
206  np++;
207 
208  if (sidstringlength > i) {
209  sidstringlength -= i;
210 
211  sidstring = &sidstring[i];
212  } else
213  break;
214  }
215 
217  if (!gm) {
218  ERR("out of memory\n");
219  ExFreePool(sid);
220  return;
221  }
222 
223  gm->sid = sid;
224  gm->gid = gid;
225 
227 }
UCHAR auth[6]
Definition: security.c:26
FT_UInt sid
Definition: cffcmap.c:139
#define InsertTailList(ListHead, Entry)
PSID sid
Definition: btrfs_drv.h:851
#define ALLOC_TAG
Definition: btrfs_drv.h:85
GLenum GLclampf GLint i
Definition: glfuncs.h:14
unsigned int UINT32
UCHAR elements
Definition: security.c:25
GLuint GLfloat * val
Definition: glext.h:7180
#define TRACE(s)
Definition: solgame.cpp:4
UINT32 gid
Definition: btrfs_drv.h:852
UCHAR revision
Definition: security.c:24
UINT32 nums[8]
Definition: security.c:27
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
LIST_ENTRY listentry
Definition: btrfs_drv.h:850
#define ERR(fmt,...)
Definition: debug.h:109
LIST_ENTRY gid_map_list
Definition: btrfs.c:65
unsigned int ULONG
Definition: retypes.h:1
unsigned long long UINT64
unsigned char UINT8
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
void add_insert_extent_rollback ( LIST_ENTRY rollback,
fcb fcb,
extent ext 
)

Definition at line 2696 of file write.c.

Referenced by add_extent_to_fcb(), and do_write_file_prealloc().

2696  {
2697  rollback_extent* re;
2698 
2700  if (!re) {
2701  ERR("out of memory\n");
2702  return;
2703  }
2704 
2705  re->fcb = fcb;
2706  re->ext = ext;
2707 
2708  add_rollback(rollback, ROLLBACK_INSERT_EXTENT, re);
2709 }
#define ALLOC_TAG
Definition: btrfs_drv.h:85
char ext[3]
Definition: mkdosfs.c:358
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define ERR(fmt,...)
Definition: debug.h:109
extent * ext
Definition: btrfs_drv.h:1195
_In_ fcb * fcb
Definition: write.c:2809
void add_rollback(_In_ LIST_ENTRY *rollback, _In_ enum rollback_type type, _In_ __drv_aliasesMem void *ptr)
Definition: treefuncs.c:811
void add_rollback ( _In_ LIST_ENTRY rollback,
_In_ enum rollback_type  type,
_In_ __drv_aliasesMem void ptr 
)

Definition at line 811 of file treefuncs.c.

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

811  {
812  rollback_item* ri;
813 
815  if (!ri) {
816  ERR("out of memory\n");
817  return;
818  }
819 
820  ri->type = type;
821  ri->ptr = ptr;
823 }
enum rollback_type type
Definition: btrfs_drv.h:1206
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define InsertTailList(ListHead, Entry)
#define ALLOC_TAG
Definition: btrfs_drv.h:85
static PVOID ptr
Definition: dispmode.c:27
LIST_ENTRY list_entry
Definition: btrfs_drv.h:1208
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
_In_ fcb _In_ chunk _In_ UINT64 _In_ UINT64 _In_ BOOL _In_opt_ void _In_opt_ PIRP _In_ LIST_ENTRY * rollback
Definition: btrfs_drv.h:1289
#define ERR(fmt,...)
Definition: debug.h:109
NTSTATUS add_space_entry ( LIST_ENTRY list,
LIST_ENTRY list_size,
UINT64  offset,
UINT64  size 
)

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

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

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

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

Referenced by _Dispatch_type_().

109  {
110  job_info* ji;
111 
113  if (!ji) {
114  ERR("out of memory\n");
115  return FALSE;
116  }
117 
118  ji->Vcb = Vcb;
119  ji->Irp = Irp;
120 
121  if (!Irp->MdlAddress) {
122  PMDL Mdl;
124  ULONG len;
126 
127  if (IrpSp->MajorFunction == IRP_MJ_READ) {
128  op = IoWriteAccess;
129  len = IrpSp->Parameters.Read.Length;
130  } else if (IrpSp->MajorFunction == IRP_MJ_WRITE) {
131  op = IoReadAccess;
132  len = IrpSp->Parameters.Write.Length;
133  } else {
134  ERR("unexpected major function %u\n", IrpSp->MajorFunction);
135  ExFreePool(ji);
136  return FALSE;
137  }
138 
139  Mdl = IoAllocateMdl(Irp->UserBuffer, len, FALSE,