/*
- * Copyright (c) 2000-2012 Apple Inc. All rights reserved.
+ * Copyright (c) 2000-2014 Apple Inc. All rights reserved.
*
* @APPLE_OSREFERENCE_LICENSE_HEADER_START@
*
#include <sys/buf.h>
#include <sys/lock.h>
+#if CONFIG_PROTECT
+#include <sys/cprotect.h>
+#endif
+
#define NOLIST ((struct buf *)0x87654321)
/*
*/
struct bufattr {
#if CONFIG_PROTECT
- struct cprotect *ba_cpentry; /* address of cp_entry */
- uint64_t ba_cp_file_off; /* rounded file offset. See buf_setcpoff() for more comments */
+ struct cpx *ba_cpx;
+ uint64_t ba_cp_file_off;
#endif
uint64_t ba_flags; /* flags. Some are only in-use on embedded devices */
};
LIST_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */
int b_timestamp; /* timestamp for queuing operation */
+ struct timeval b_timestamp_tv; /* microuptime for disk conditioner */
int b_whichq; /* the free list the buffer belongs to */
volatile uint32_t b_flags; /* B_* flags. */
volatile uint32_t b_lflags; /* BL_BUSY | BL_WANTED flags... protected by buf_mtx */
#define BL_WAITSHADOW 0x00000080
#define BL_IOBUF_ALLOC 0x00000100
#define BL_WANTED_REF 0x00000200
+#define BL_IOBUF_VDEV 0x00000400 /* iobuf was for a diskimage */
/*
* Parameters for buffer cache garbage collection
#define B_WASDIRTY 0x02000000 /* page was found dirty in the VM cache */
#define B_HDRALLOC 0x04000000 /* zone allocated buffer header */
#define B_ZALLOC 0x08000000 /* b_datap is zalloc()ed */
-/*
- * private flags used by the journal layer
- */
-#define B_NORELSE 0x10000000 /* don't brelse() in bwrite() */
/*
* private flags used by by the cluster layer
*/
-#define B_TWANTED 0x20000000 /* but_t that is part of a cluster level transaction is wanted */
#define B_COMMIT_UPL 0x40000000 /* commit/abort the UPL on I/O success/failure */
#define B_TDONE 0x80000000 /* buf_t that is part of a cluster level transaction has completed */
#define BA_DELAYIDLESLEEP 0x00000004 /* Process is marked to delay idle sleep on disk IO */
#define BA_NOCACHE 0x00000008
#define BA_META 0x00000010
-#define BA_IO_TIER_MASK 0x00000f00
-#define BA_IO_TIER_SHIFT 8
#define BA_GREEDY_MODE 0x00000020 /* High speed writes that consume more storage */
#define BA_QUICK_COMPLETE 0x00000040 /* Request quick completion at expense of storage efficiency */
+#define BA_PASSIVE 0x00000080
+
+/*
+ * Note: IO_TIERs consume 0x0100, 0x0200, 0x0400, 0x0800
+ * These are now in-use by the I/O tiering system.
+ */
+#define BA_IO_TIER_MASK 0x00000f00
+#define BA_IO_TIER_SHIFT 8
+
+#define BA_ISOCHRONOUS 0x00001000 /* device specific isochronous throughput to media */
+
+#define BA_STRATEGY_TRACKED_IO 0x00002000 /* tracked by spec_strategy */
+#define BA_IO_TIER_UPGRADE 0x00004000 /* effective I/O tier is higher than BA_IO_TIER */
+
#define GET_BUFATTR_IO_TIER(bap) ((bap->ba_flags & BA_IO_TIER_MASK) >> BA_IO_TIER_SHIFT)
-#define SET_BUFATTR_IO_TIER(bap, tier) (bap->ba_flags |= ((tier << BA_IO_TIER_SHIFT) & BA_IO_TIER_MASK))
+#define SET_BUFATTR_IO_TIER(bap, tier) \
+do { \
+ (bap)->ba_flags &= (~BA_IO_TIER_MASK); \
+ (bap)->ba_flags |= (((tier) << BA_IO_TIER_SHIFT) & BA_IO_TIER_MASK); \
+} while(0)
extern int niobuf_headers; /* The number of IO buffer headers for cluster IO */
extern int nbuf_headers; /* The number of buffer headers */
__BEGIN_DECLS
-buf_t buf_create_shadow_priv(buf_t bp, boolean_t force_copy, uintptr_t external_storage, void (*iodone)(buf_t, void *), void *arg);
-
buf_t alloc_io_buf(vnode_t, int);
void free_io_buf(buf_t);
int allocbuf(struct buf *, int);
void bufinit(void);
-/*
- * Flags for buf_acquire
- */
-#define BAC_NOWAIT 0x01 /* Don't wait if buffer is busy */
-#define BAC_REMOVE 0x02 /* Remove from free list once buffer is acquired */
-#define BAC_SKIP_NONLOCKED 0x04 /* Don't return LOCKED buffers */
-#define BAC_SKIP_LOCKED 0x08 /* Only return LOCKED buffers */
-
void buf_list_lock(void);
void buf_list_unlock(void);
void cluster_init(void);
-void buf_drop(buf_t);
-errno_t buf_acquire(buf_t, int, int, int);
int count_busy_buffers(void);
-int count_lock_queue(void);
int buf_flushdirtyblks_skipinfo (vnode_t, int, int, const char *);
void buf_wait_for_shadow_io (vnode_t, daddr64_t);
#endif
#ifdef CONFIG_PROTECT
-void buf_setcpaddr(buf_t, struct cprotect *);
void buf_setcpoff (buf_t, uint64_t);
#endif
long bufs_iobufmax; /* Max. number of IO buffers used */
long bufs_iobufinuse; /* number of IO buffers in use */
long bufs_iobufsleeps; /* IO buffer starvation */
+ long bufs_iobufinuse_vdev; /* number of IO buffers in use by
+ diskimages */
};
#endif /* KERNEL */