#include <sys/queue.h>
Go to the source code of this file.
◆ BufCacheEntry
◆ BufCache_Alloc()
BufCache_Alloc –
Allocate a buffer cache entry to allow writing new data to disk.
- Parameters
-
[in] | disk | Disk object |
[in] | diskOffset | Block offset within the disk |
[out] | entry | If successful, this contains the buffer cache entry. |
- Return values
-
- Returns
- Otherwise returns an error code.
Definition at line 178 of file bufcache.c.
179{
180 int status;
181
183
185 if (*entry ==
NULL) {
187 }
188
189 cacheAlloc++;
190
192
193 return status;
194}
static int BufCacheLookup(Disk *disk, uint64_t diskOffset, BufCacheEntry **entry)
static int BufCacheAlloc(Disk *disk, uint64_t diskOffset, BufCacheEntry **entry)
void Spinlock_Unlock(Spinlock *lock) __UNLOCK_EX(*lock)
void Spinlock_Lock(Spinlock *lock) __LOCK_EX(*lock)
◆ BufCache_Init()
◆ BufCache_Read()
BufCache_Read –
Read block from disk into the buffer cache.
- Parameters
-
[in] | disk | Disk object |
[in] | diskOffset | Block offset within the disk |
[out] | entry | If successful, this contains the buffer cache entry. |
- Return values
-
- Returns
- Otherwise returns an error code.
Definition at line 229 of file bufcache.c.
230{
231 int status;
234
237 if (*entry !=
NULL) {
238 cacheHit++;
240 return status;
241 }
242 cacheMiss++;
243
245 if (status != 0) {
247 return status;
248 }
249
250 buf = (*entry)->buffer;
253
254
255
256
257
260
261 return status;
262}
int Disk_Read(Disk *disk, void *buf, SGArray *sga, DiskCB cb, void *arg)
void SGArray_Init(SGArray *sga)
int SGArray_Append(SGArray *sga, uint64_t off, uint64_t len)
◆ BufCache_Release()
BufCache_Release –
Release a buffer cache entry. If no other references are held the buffer cache entry is placed on the LRU list.
- Parameters
-
[in] | entry | Buffer cache entry. |
Definition at line 205 of file bufcache.c.
206{
208
212 }
213
215}
#define TAILQ_INSERT_TAIL(head, elm, field)
◆ BufCache_Write()
BufCache_Write –
Write a buffer cache entry to disk.
- Return values
-
- Returns
- Otherwise an error code is returned.
Definition at line 273 of file bufcache.c.
274{
277
280
282}
int Disk_Write(Disk *disk, void *buf, SGArray *sga, DiskCB cb, void *arg)