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

Go to the source code of this file.

Data Structures

struct  scan_data
 

Functions

int ubifs_find_dirty_leb (struct ubifs_info *c, struct ubifs_lprops *ret_lp, int min_space, int pick_free)
 
int ubifs_find_free_space (struct ubifs_info *c, int min_space, int *offs, int squeeze)
 
int ubifs_find_free_leb_for_idx (struct ubifs_info *c)
 
int ubifs_save_dirty_idx_lnums (struct ubifs_info *c)
 
int ubifs_find_dirty_idx_leb (struct ubifs_info *c)
 

Function Documentation

int ubifs_find_dirty_idx_leb ( struct ubifs_info c)

ubifs_find_dirty_idx_leb - try to find dirtiest index LEB as at last commit. : the UBIFS file-system description object

This function attempts to find an untaken index LEB with the most free and dirty space that can be used without overwriting index nodes that were in the last index committed.

Definition at line 963 of file find.c.

int ubifs_find_dirty_leb ( struct ubifs_info c,
struct ubifs_lprops ret_lp,
int  min_space,
int  pick_free 
)

ubifs_find_dirty_leb - find a dirty LEB for the Garbage Collector. : the UBIFS file-system description object : LEB properties are returned here on exit : minimum amount free plus dirty space the returned LEB has to have : controls whether it is OK to pick empty or index LEBs

This function tries to find a dirty logical eraseblock which has at least free and dirty space. It prefers to take an LEB from the dirty or dirty index heap, and it falls-back to LPT scanning if the heaps are empty or do not have an LEB which satisfies the criteria.

Note, LEBs which have less than dead watermark of free + dirty space are never picked by this function.

The additional argument controls if this function has to return a free or freeable LEB if one is present. For example, GC must to set it to %1, when called from the journal space reservation function, because the appearance of free space may coincide with the loss of enough dirty space for GC to succeed anyway.

In contrast, if the Garbage Collector is called from budgeting, it should just make free space, not return LEBs which are already free or freeable.

In addition is set to %2 by the recovery process in order to recover gc_lnum in which case an index LEB must not be returned.

This function returns zero and the LEB properties of found dirty LEB in case of success, %-ENOSPC if no dirty LEB was found and a negative error code in case of other failures. The returned LEB is marked as "taken".

Definition at line 233 of file find.c.

int ubifs_find_free_leb_for_idx ( struct ubifs_info c)

ubifs_find_free_leb_for_idx - find a free LEB for the index. : the UBIFS file-system description object

This function looks for a free LEB and returns that LEB number. The returned LEB is marked as "taken", "index".

Only empty LEBs are allocated. This is for two reasons. First, the commit calculates the number of LEBs to allocate based on the assumption that they will be empty. Secondly, free space at the end of an index LEB is not guaranteed to be empty because it may have been used by the in-the-gaps method prior to an unclean unmount.

If no LEB is found %-ENOSPC is returned. For other failures another negative error code is returned.

Definition at line 673 of file find.c.

int ubifs_find_free_space ( struct ubifs_info c,
int  min_space,
int offs,
int  squeeze 
)

ubifs_find_free_space - find a data LEB with free space. : the UBIFS file-system description object : minimum amount of required free space : contains offset of where free space starts on exit : whether to try to find space in a non-empty LEB first

This function looks for an LEB with at least bytes of free space. It tries to find an empty LEB if possible. If no empty LEBs are available, this function searches for a non-empty data LEB. The returned LEB is marked as "taken".

This function returns found LEB number in case of success, %-ENOSPC if it failed to find a LEB with bytes of free space and other a negative error codes in case of failure.

Definition at line 493 of file find.c.

int ubifs_save_dirty_idx_lnums ( struct ubifs_info c)

ubifs_save_dirty_idx_lnums - save an array of the most dirty index LEB nos. : the UBIFS file-system description object

This function is called each commit to create an array of LEB numbers of dirty index LEBs sorted in order of dirty and free space. This is used by the in-the-gaps method of TNC commit.

Definition at line 767 of file find.c.