Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
segment.c File Reference
#include <linux/pagemap.h>
#include <linux/buffer_head.h>
#include <linux/writeback.h>
#include <linux/bio.h>
#include <linux/completion.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
#include <linux/freezer.h>
#include <linux/kthread.h>
#include <linux/crc32.h>
#include <linux/pagevec.h>
#include <linux/slab.h>
#include "nilfs.h"
#include "btnode.h"
#include "page.h"
#include "segment.h"
#include "sufile.h"
#include "cpfile.h"
#include "ifile.h"
#include "segbuf.h"

Go to the source code of this file.

Data Structures

struct  nilfs_sc_operations
 
struct  nilfs_segctor_wait_request
 

Macros

#define SC_N_INODEVEC   16 /* Size of locally allocated inode vector */
 
#define SC_MAX_SEGDELTA
 
#define NILFS_CF_NODE   0x0001 /* Collecting node blocks */
 
#define NILFS_CF_IFILE_STARTED   0x0002 /* IFILE stage has started */
 
#define NILFS_CF_SUFREED   0x0004 /* segment usages has been freed */
 
#define NILFS_CF_HISTORY_MASK   (NILFS_CF_IFILE_STARTED | NILFS_CF_SUFREED)
 
#define nilfs_cnt32_gt(a, b)
 
#define nilfs_cnt32_ge(a, b)
 
#define nilfs_cnt32_lt(a, b)   nilfs_cnt32_gt(b, a)
 
#define nilfs_cnt32_le(a, b)   nilfs_cnt32_ge(b, a)
 
#define FLUSH_FILE_BIT   (0x1) /* data file only */
 
#define FLUSH_DAT_BIT   (1 << NILFS_DAT_INO) /* DAT only */
 

Enumerations

enum  { SC_LSEG_SR = 1, SC_LSEG_DSYNC, SC_FLUSH_FILE, SC_FLUSH_DAT }
 
enum  {
  NILFS_ST_INIT = 0, NILFS_ST_GC, NILFS_ST_FILE, NILFS_ST_IFILE,
  NILFS_ST_CPFILE, NILFS_ST_SUFILE, NILFS_ST_DAT, NILFS_ST_SR,
  NILFS_ST_DSYNC, NILFS_ST_DONE
}
 

Functions

int nilfs_transaction_begin (struct super_block *sb, struct nilfs_transaction_info *ti, int vacancy_check)
 
int nilfs_transaction_commit (struct super_block *sb)
 
void nilfs_transaction_abort (struct super_block *sb)
 
void nilfs_relax_pressure_in_lock (struct super_block *sb)
 
void nilfs_flush_segment (struct super_block *sb, ino_t ino)
 
int nilfs_construct_segment (struct super_block *sb)
 
int nilfs_construct_dsync_segment (struct super_block *sb, struct inode *inode, loff_t start, loff_t end)
 
int nilfs_clean_segments (struct super_block *sb, struct nilfs_argv *argv, void **kbufs)
 
int nilfs_attach_log_writer (struct super_block *sb, struct nilfs_root *root)
 
void nilfs_detach_log_writer (struct super_block *sb)
 

Macro Definition Documentation

#define FLUSH_DAT_BIT   (1 << NILFS_DAT_INO) /* DAT only */

Definition at line 2215 of file segment.c.

#define FLUSH_FILE_BIT   (0x1) /* data file only */

Definition at line 2214 of file segment.c.

#define NILFS_CF_HISTORY_MASK   (NILFS_CF_IFILE_STARTED | NILFS_CF_SUFREED)

Definition at line 82 of file segment.c.

#define NILFS_CF_IFILE_STARTED   0x0002 /* IFILE stage has started */

Definition at line 80 of file segment.c.

#define NILFS_CF_NODE   0x0001 /* Collecting node blocks */

Definition at line 79 of file segment.c.

#define NILFS_CF_SUFREED   0x0004 /* segment usages has been freed */

Definition at line 81 of file segment.c.

#define nilfs_cnt32_ge (   a,
  b 
)
Value:
((__s32)(a) - (__s32)(b) >= 0))

Definition at line 111 of file segment.c.

#define nilfs_cnt32_gt (   a,
  b 
)
Value:
((__s32)(b) - (__s32)(a) < 0))

Definition at line 108 of file segment.c.

#define nilfs_cnt32_le (   a,
  b 
)    nilfs_cnt32_ge(b, a)

Definition at line 115 of file segment.c.

#define nilfs_cnt32_lt (   a,
  b 
)    nilfs_cnt32_gt(b, a)

Definition at line 114 of file segment.c.

#define SC_MAX_SEGDELTA
Value:
64 /* Upper limit of the number of segments
appended in collection retry loop */

Definition at line 51 of file segment.c.

#define SC_N_INODEVEC   16 /* Size of locally allocated inode vector */

Definition at line 49 of file segment.c.

Enumeration Type Documentation

anonymous enum
Enumerator:
SC_LSEG_SR 
SC_LSEG_DSYNC 
SC_FLUSH_FILE 
SC_FLUSH_DAT 

Definition at line 54 of file segment.c.

anonymous enum
Enumerator:
NILFS_ST_INIT 
NILFS_ST_GC 
NILFS_ST_FILE 
NILFS_ST_IFILE 
NILFS_ST_CPFILE 
NILFS_ST_SUFILE 
NILFS_ST_DAT 
NILFS_ST_SR 
NILFS_ST_DSYNC 
NILFS_ST_DONE 

Definition at line 65 of file segment.c.

Function Documentation

int nilfs_attach_log_writer ( struct super_block sb,
struct nilfs_root root 
)

nilfs_attach_log_writer - attach log writer : super block instance : root object of the current filesystem tree

This allocates a log writer object, initializes it, and starts the log writer.

Return Value: On success, 0 is returned. On error, one of the following negative error code is returned.

%-ENOMEM - Insufficient memory available.

Definition at line 2656 of file segment.c.

int nilfs_clean_segments ( struct super_block sb,
struct nilfs_argv argv,
void **  kbufs 
)

Definition at line 2320 of file segment.c.

int nilfs_construct_dsync_segment ( struct super_block sb,
struct inode inode,
loff_t  start,
loff_t  end 
)

nilfs_construct_dsync_segment - construct a data-only logical segment : super block : inode whose data blocks should be written out : start byte offset : end byte offset (inclusive)

Return Value: On success, 0 is retured. On errors, one of the following negative error code is returned.

%-EROFS - Read only filesystem.

%-EIO - I/O error

%-ENOSPC - No space left on device (only in a panic state).

%-ERESTARTSYS - Interrupted.

%-ENOMEM - Insufficient memory available.

Definition at line 2172 of file segment.c.

int nilfs_construct_segment ( struct super_block sb)

nilfs_construct_segment - construct a logical segment : super block

Return Value: On success, 0 is retured. On errors, one of the following negative error code is returned.

%-EROFS - Read only filesystem.

%-EIO - I/O error

%-ENOSPC - No space left on device (only in a panic state).

%-ERESTARTSYS - Interrupted.

%-ENOMEM - Insufficient memory available.

Definition at line 2135 of file segment.c.

void nilfs_detach_log_writer ( struct super_block sb)

nilfs_detach_log_writer - destroy log writer : super block instance

This kills log writer daemon, frees the log writer object, and destroys list of dirty files.

Definition at line 2689 of file segment.c.

void nilfs_flush_segment ( struct super_block sb,
ino_t  ino 
)

nilfs_flush_segment - trigger a segment construction for resource control : super block : inode number of the file to be flushed out.

Definition at line 2045 of file segment.c.

void nilfs_relax_pressure_in_lock ( struct super_block sb)

Definition at line 271 of file segment.c.

void nilfs_transaction_abort ( struct super_block sb)

Definition at line 253 of file segment.c.

int nilfs_transaction_begin ( struct super_block sb,
struct nilfs_transaction_info ti,
int  vacancy_check 
)

nilfs_transaction_begin - start indivisible file operations. : super block : nilfs_transaction_info : flags for vacancy rate checks

nilfs_transaction_begin() acquires a reader/writer semaphore, called the segment semaphore, to make a segment construction and write tasks exclusive. The function is used with nilfs_transaction_commit() in pairs. The region enclosed by these two functions can be nested. To avoid a deadlock, the semaphore is only acquired or released in the outermost call.

This function allocates a nilfs_transaction_info struct to keep context information on it. It is initialized and hooked onto the current task in the outermost call. If a pre-allocated struct is given to , it is used instead; otherwise a new struct is assigned from a slab.

When flag is set, this function will check the amount of free space, and will wait for the GC to reclaim disk space if low capacity.

Return Value: On success, 0 is returned. On error, one of the following negative error code is returned.

%-ENOMEM - Insufficient memory available.

%-ENOSPC - No space left on device

Definition at line 179 of file segment.c.

int nilfs_transaction_commit ( struct super_block sb)

nilfs_transaction_commit - commit indivisible file operations. : super block

nilfs_transaction_commit() releases the read semaphore which is acquired by nilfs_transaction_begin(). This is only performed in outermost call of this function. If a commit flag is set, nilfs_transaction_commit() sets a timer to start the segment constructor. If a sync flag is set, it starts construction directly.

Definition at line 222 of file segment.c.