Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
readwrite.c File Reference
#include "logfs.h"
#include <linux/sched.h>
#include <linux/slab.h>

Go to the source code of this file.

Data Structures

struct  write_control
 

Macros

#define ARCH_SHIFT   (BITS_PER_LONG - 32)
 
#define INDIRECT_BIT   (0x80000000UL << ARCH_SHIFT)
 
#define LEVEL_SHIFT   (28 + ARCH_SHIFT)
 
#define TRUNCATE_STEP   (8 * 1024 * 1024)
 

Functions

pgoff_t logfs_pack_index (u64 bix, level_t level)
 
void logfs_unpack_index (pgoff_t index, u64 *bix, level_t *level)
 
void logfs_set_blocks (struct inode *inode, u64 bytes)
 
void logfs_get_wblocks (struct super_block *sb, struct page *page, int lock)
 
void logfs_put_wblocks (struct super_block *sb, struct page *page, int lock)
 
int logfs_write_obj_aliases_pagecache (struct super_block *sb)
 
void __free_block (struct super_block *sb, struct logfs_block *block)
 
struct logfs_block__alloc_block (struct super_block *sb, u64 ino, u64 bix, level_t level)
 
void initialize_block_counters (struct page *page, struct logfs_block *block, __be64 *array, int page_is_empty)
 
int logfs_exist_block (struct inode *inode, u64 bix)
 
u64 logfs_seek_hole (struct inode *inode, u64 bix)
 
u64 logfs_seek_data (struct inode *inode, u64 bix)
 
int logfs_is_valid_block (struct super_block *sb, u64 ofs, u64 ino, u64 bix, gc_level_t gc_level)
 
int logfs_readpage_nolock (struct page *page)
 
int get_page_reserve (struct inode *inode, struct page *page)
 
void logfs_add_transaction (struct inode *inode, struct logfs_transaction *ta)
 
void logfs_del_transaction (struct inode *inode, struct logfs_transaction *ta)
 
int logfs_write_buf (struct inode *inode, struct page *page, long flags)
 
int logfs_delete (struct inode *inode, pgoff_t index, struct shadow_tree *shadow_tree)
 
int logfs_rewrite_block (struct inode *inode, u64 bix, u64 ofs, gc_level_t gc_level, long flags)
 
int logfs_truncate (struct inode *inode, u64 target)
 
int logfs_read_inode (struct inode *inode)
 
void logfs_get_segment_entry (struct super_block *sb, u32 segno, struct logfs_segment_entry *se)
 
void logfs_set_segment_used (struct super_block *sb, u64 ofs, int increment)
 
void logfs_set_segment_erased (struct super_block *sb, u32 segno, u32 ec, gc_level_t gc_level)
 
void logfs_set_segment_reserved (struct super_block *sb, u32 segno)
 
void logfs_set_segment_unreserved (struct super_block *sb, u32 segno, u32 ec)
 
int __logfs_write_inode (struct inode *inode, struct page *page, long flags)
 
void logfs_evict_inode (struct inode *inode)
 
void btree_write_block (struct logfs_block *block)
 
int logfs_inode_write (struct inode *inode, const void *buf, size_t count, loff_t bix, long flags, struct shadow_tree *shadow_tree)
 
int logfs_open_segfile (struct super_block *sb)
 
int logfs_init_rw (struct super_block *sb)
 
void logfs_cleanup_rw (struct super_block *sb)
 

Variables

struct logfs_block_ops indirect_block_ops
 

Macro Definition Documentation

#define ARCH_SHIFT   (BITS_PER_LONG - 32)

The inode address space is cut in two halves. Lower half belongs to data pages, upper half to indirect blocks. If the high bit (INDIRECT_BIT) is set, the actual block index (bix) and level can be derived from the page index.

The lowest three bits of the block index are set to 0 after packing and unpacking. Since the lowest n bits (9 for 4KiB blocksize) are ignored anyway this is harmless.

Definition at line 59 of file readwrite.c.

#define INDIRECT_BIT   (0x80000000UL << ARCH_SHIFT)

Definition at line 60 of file readwrite.c.

#define LEVEL_SHIFT   (28 + ARCH_SHIFT)

Definition at line 61 of file readwrite.c.

#define TRUNCATE_STEP   (8 * 1024 * 1024)

Definition at line 1867 of file readwrite.c.

Function Documentation

struct logfs_block* __alloc_block ( struct super_block sb,
u64  ino,
u64  bix,
level_t  level 
)
read

Definition at line 584 of file readwrite.c.

void __free_block ( struct super_block sb,
struct logfs_block block 
)

Definition at line 543 of file readwrite.c.

int __logfs_write_inode ( struct inode inode,
struct page page,
long  flags 
)

Definition at line 2126 of file readwrite.c.

void btree_write_block ( struct logfs_block block)

Definition at line 2197 of file readwrite.c.

int get_page_reserve ( struct inode inode,
struct page page 
)

Definition at line 1101 of file readwrite.c.

void initialize_block_counters ( struct page page,
struct logfs_block block,
__be64 array,
int  page_is_empty 
)

Definition at line 615 of file readwrite.c.

void logfs_add_transaction ( struct inode inode,
struct logfs_transaction ta 
)

Definition at line 1495 of file readwrite.c.

void logfs_cleanup_rw ( struct super_block sb)

Definition at line 2287 of file readwrite.c.

void logfs_del_transaction ( struct inode inode,
struct logfs_transaction ta 
)

Definition at line 1501 of file readwrite.c.

int logfs_delete ( struct inode inode,
pgoff_t  index,
struct shadow_tree shadow_tree 
)

Definition at line 1591 of file readwrite.c.

void logfs_evict_inode ( struct inode inode)

Definition at line 2162 of file readwrite.c.

int logfs_exist_block ( struct inode inode,
u64  bix 
)

Definition at line 810 of file readwrite.c.

void logfs_get_segment_entry ( struct super_block sb,
u32  segno,
struct logfs_segment_entry se 
)

Definition at line 2062 of file readwrite.c.

void logfs_get_wblocks ( struct super_block sb,
struct page page,
int  lock 
)

Definition at line 247 of file readwrite.c.

int logfs_init_rw ( struct super_block sb)

Definition at line 2272 of file readwrite.c.

int logfs_inode_write ( struct inode inode,
const void buf,
size_t  count,
loff_t  bix,
long  flags,
struct shadow_tree shadow_tree 
)

logfs_inode_write - write inode or dentry objects

: parent inode (ifile or directory) : object to write (inode or dentry)
: object size : object number (file position in blocks/objects) : write flags : 0 if write lock is already taken, 1 otherwise : shadow below this inode

FIXME: All caller of this put a 200-300 byte variable on the stack, only to call here and do a memcpy from that stack variable. A good example of wasted performance and stack space.

Definition at line 2233 of file readwrite.c.

int logfs_is_valid_block ( struct super_block sb,
u64  ofs,
u64  ino,
u64  bix,
gc_level_t  gc_level 
)

logfs_is_valid_block - check whether this block is still valid

- superblock - block physical offset - block inode number - block index - block level

Returns 0 if the block is invalid, 1 if it is valid and 2 if it will become invalid once the journal is written.

Definition at line 1031 of file readwrite.c.

int logfs_open_segfile ( struct super_block sb)

Definition at line 2260 of file readwrite.c.

pgoff_t logfs_pack_index ( u64  bix,
level_t  level 
)

Definition at line 67 of file readwrite.c.

void logfs_put_wblocks ( struct super_block sb,
struct page page,
int  lock 
)

Definition at line 262 of file readwrite.c.

int logfs_read_inode ( struct inode inode)

Definition at line 1945 of file readwrite.c.

int logfs_readpage_nolock ( struct page page)

Definition at line 1063 of file readwrite.c.

int logfs_rewrite_block ( struct inode inode,
u64  bix,
u64  ofs,
gc_level_t  gc_level,
long  flags 
)

Definition at line 1611 of file readwrite.c.

u64 logfs_seek_data ( struct inode inode,
u64  bix 
)

logfs_seek_data - find next data block after a given block index : inode to search in : block index to start searching

Returns next data block. If the file doesn't contain any further data blocks, the last block in the file is returned instead.

Definition at line 944 of file readwrite.c.

u64 logfs_seek_hole ( struct inode inode,
u64  bix 
)

logfs_seek_hole - find next hole starting at a given block index : inode to search in : block index to start searching

Returns next hole. If the file doesn't contain any further holes, the block address next to eof is returned instead.

Definition at line 887 of file readwrite.c.

void logfs_set_blocks ( struct inode inode,
u64  bytes 
)

Definition at line 197 of file readwrite.c.

void logfs_set_segment_erased ( struct super_block sb,
u32  segno,
u32  ec,
gc_level_t  gc_level 
)

Definition at line 2093 of file readwrite.c.

void logfs_set_segment_reserved ( struct super_block sb,
u32  segno 
)

Definition at line 2106 of file readwrite.c.

void logfs_set_segment_unreserved ( struct super_block sb,
u32  segno,
u32  ec 
)

Definition at line 2118 of file readwrite.c.

void logfs_set_segment_used ( struct super_block sb,
u64  ofs,
int  increment 
)

Definition at line 2077 of file readwrite.c.

int logfs_truncate ( struct inode inode,
u64  target 
)

Definition at line 1868 of file readwrite.c.

void logfs_unpack_index ( pgoff_t  index,
u64 bix,
level_t level 
)

Definition at line 81 of file readwrite.c.

int logfs_write_buf ( struct inode inode,
struct page page,
long  flags 
)

Definition at line 1565 of file readwrite.c.

int logfs_write_obj_aliases_pagecache ( struct super_block sb)

Definition at line 529 of file readwrite.c.

Variable Documentation

struct logfs_block_ops indirect_block_ops
Initial value:
= {
.write_block = indirect_write_block,
.free_block = indirect_free_block,
.write_alias = indirect_write_alias,
}

Definition at line 578 of file readwrite.c.