Commit d3b4d0fd authored by David Sterba's avatar David Sterba
Browse files

btrfs: convert EXTENT_* bits to enums

parent fd8d2951
Loading
Loading
Loading
Loading
+38 −33
Original line number Original line Diff line number Diff line
@@ -3,43 +3,48 @@
#ifndef BTRFS_EXTENT_IO_TREE_H
#ifndef BTRFS_EXTENT_IO_TREE_H
#define BTRFS_EXTENT_IO_TREE_H
#define BTRFS_EXTENT_IO_TREE_H


#include "misc.h"

struct extent_changeset;
struct extent_changeset;
struct io_failure_record;
struct io_failure_record;


/* Bits for the extent state */
/* Bits for the extent state */
#define EXTENT_DIRTY		(1U << 0)
enum {
#define EXTENT_UPTODATE		(1U << 1)
	ENUM_BIT(EXTENT_DIRTY),
#define EXTENT_LOCKED		(1U << 2)
	ENUM_BIT(EXTENT_UPTODATE),
#define EXTENT_NEW		(1U << 3)
	ENUM_BIT(EXTENT_LOCKED),
#define EXTENT_DELALLOC		(1U << 4)
	ENUM_BIT(EXTENT_NEW),
#define EXTENT_DEFRAG		(1U << 5)
	ENUM_BIT(EXTENT_DELALLOC),
#define EXTENT_BOUNDARY		(1U << 6)
	ENUM_BIT(EXTENT_DEFRAG),
#define EXTENT_NODATASUM	(1U << 7)
	ENUM_BIT(EXTENT_BOUNDARY),
#define EXTENT_CLEAR_META_RESV	(1U << 8)
	ENUM_BIT(EXTENT_NODATASUM),
#define EXTENT_NEED_WAIT	(1U << 9)
	ENUM_BIT(EXTENT_CLEAR_META_RESV),
#define EXTENT_NORESERVE	(1U << 11)
	ENUM_BIT(EXTENT_NEED_WAIT),
#define EXTENT_QGROUP_RESERVED	(1U << 12)
	ENUM_BIT(EXTENT_NORESERVE),
#define EXTENT_CLEAR_DATA_RESV	(1U << 13)
	ENUM_BIT(EXTENT_QGROUP_RESERVED),
	ENUM_BIT(EXTENT_CLEAR_DATA_RESV),
	/*
	/*
 * Must be cleared only during ordered extent completion or on error paths if we
	 * Must be cleared only during ordered extent completion or on error
 * did not manage to submit bios and create the ordered extents for the range.
	 * paths if we did not manage to submit bios and create the ordered
 * Should not be cleared during page release and page invalidation (if there is
	 * extents for the range.  Should not be cleared during page release
 * an ordered extent in flight), that is left for the ordered extent completion.
	 * and page invalidation (if there is an ordered extent in flight),
	 * that is left for the ordered extent completion.
	 */
	 */
#define EXTENT_DELALLOC_NEW	(1U << 14)
	ENUM_BIT(EXTENT_DELALLOC_NEW),
	/*
	/*
 * When an ordered extent successfully completes for a region marked as a new
	 * When an ordered extent successfully completes for a region marked as
 * delalloc range, use this flag when clearing a new delalloc range to indicate
	 * a new delalloc range, use this flag when clearing a new delalloc
 * that the VFS' inode number of bytes should be incremented and the inode's new
	 * range to indicate that the VFS' inode number of bytes should be
 * delalloc bytes decremented, in an atomic way to prevent races with stat(2).
	 * incremented and the inode's new delalloc bytes decremented, in an
	 * atomic way to prevent races with stat(2).
	 */
	 */
#define EXTENT_ADD_INODE_BYTES  (1U << 15)
	ENUM_BIT(EXTENT_ADD_INODE_BYTES),

	/*
	/*
 * Set during truncate when we're clearing an entire range and we just want the
	 * Set during truncate when we're clearing an entire range and we just
 * extent states to go away.
	 * want the extent states to go away.
	 */
	 */
#define EXTENT_CLEAR_ALL_BITS	(1U << 16)
	ENUM_BIT(EXTENT_CLEAR_ALL_BITS),
};


#define EXTENT_DO_ACCOUNTING    (EXTENT_CLEAR_META_RESV | \
#define EXTENT_DO_ACCOUNTING    (EXTENT_CLEAR_META_RESV | \
				 EXTENT_CLEAR_DATA_RESV)
				 EXTENT_CLEAR_DATA_RESV)