Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Functions | Variables
block_dev.c File Reference
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/fcntl.h>
#include <linux/slab.h>
#include <linux/kmod.h>
#include <linux/major.h>
#include <linux/device_cgroup.h>
#include <linux/highmem.h>
#include <linux/blkdev.h>
#include <linux/module.h>
#include <linux/blkpg.h>
#include <linux/magic.h>
#include <linux/buffer_head.h>
#include <linux/swap.h>
#include <linux/pagevec.h>
#include <linux/writeback.h>
#include <linux/mpage.h>
#include <linux/mount.h>
#include <linux/uio.h>
#include <linux/namei.h>
#include <linux/log2.h>
#include <linux/cleancache.h>
#include <asm/uaccess.h>
#include "internal.h"

Go to the source code of this file.

Data Structures

struct  bdev_inode
 

Functions

struct block_deviceI_BDEV (struct inode *inode)
 
 EXPORT_SYMBOL (I_BDEV)
 
void kill_bdev (struct block_device *bdev)
 
 EXPORT_SYMBOL (kill_bdev)
 
void invalidate_bdev (struct block_device *bdev)
 
 EXPORT_SYMBOL (invalidate_bdev)
 
int set_blocksize (struct block_device *bdev, int size)
 
 EXPORT_SYMBOL (set_blocksize)
 
int sb_set_blocksize (struct super_block *sb, int size)
 
 EXPORT_SYMBOL (sb_set_blocksize)
 
int sb_min_blocksize (struct super_block *sb, int size)
 
 EXPORT_SYMBOL (sb_min_blocksize)
 
int __sync_blockdev (struct block_device *bdev, int wait)
 
int sync_blockdev (struct block_device *bdev)
 
 EXPORT_SYMBOL (sync_blockdev)
 
int fsync_bdev (struct block_device *bdev)
 
 EXPORT_SYMBOL (fsync_bdev)
 
struct super_blockfreeze_bdev (struct block_device *bdev)
 
 EXPORT_SYMBOL (freeze_bdev)
 
int thaw_bdev (struct block_device *bdev, struct super_block *sb)
 
 EXPORT_SYMBOL (thaw_bdev)
 
int blkdev_fsync (struct file *filp, loff_t start, loff_t end, int datasync)
 
 EXPORT_SYMBOL (blkdev_fsync)
 
void __init bdev_cache_init (void)
 
struct block_devicebdget (dev_t dev)
 
 EXPORT_SYMBOL (bdget)
 
struct block_devicebdgrab (struct block_device *bdev)
 
long nr_blockdev_pages (void)
 
void bdput (struct block_device *bdev)
 
 EXPORT_SYMBOL (bdput)
 
void bd_forget (struct inode *inode)
 
void check_disk_size_change (struct gendisk *disk, struct block_device *bdev)
 
 EXPORT_SYMBOL (check_disk_size_change)
 
int revalidate_disk (struct gendisk *disk)
 
 EXPORT_SYMBOL (revalidate_disk)
 
int check_disk_change (struct block_device *bdev)
 
 EXPORT_SYMBOL (check_disk_change)
 
void bd_set_size (struct block_device *bdev, loff_t size)
 
 EXPORT_SYMBOL (bd_set_size)
 
int blkdev_get (struct block_device *bdev, fmode_t mode, void *holder)
 
 EXPORT_SYMBOL (blkdev_get)
 
struct block_deviceblkdev_get_by_path (const char *path, fmode_t mode, void *holder)
 
 EXPORT_SYMBOL (blkdev_get_by_path)
 
struct block_deviceblkdev_get_by_dev (dev_t dev, fmode_t mode, void *holder)
 
 EXPORT_SYMBOL (blkdev_get_by_dev)
 
int blkdev_put (struct block_device *bdev, fmode_t mode)
 
 EXPORT_SYMBOL (blkdev_put)
 
ssize_t blkdev_aio_write (struct kiocb *iocb, const struct iovec *iov, unsigned long nr_segs, loff_t pos)
 
 EXPORT_SYMBOL_GPL (blkdev_aio_write)
 
int ioctl_by_bdev (struct block_device *bdev, unsigned cmd, unsigned long arg)
 
 EXPORT_SYMBOL (ioctl_by_bdev)
 
struct block_devicelookup_bdev (const char *pathname)
 
 EXPORT_SYMBOL (lookup_bdev)
 
int __invalidate_device (struct block_device *bdev, bool kill_dirty)
 
 EXPORT_SYMBOL (__invalidate_device)
 
void iterate_bdevs (void(*func)(struct block_device *, void *), void *arg)
 

Variables

struct file_operations def_blk_fops
 

Function Documentation

int __invalidate_device ( struct block_device bdev,
bool  kill_dirty 
)

Definition at line 1659 of file block_dev.c.

int __sync_blockdev ( struct block_device bdev,
int  wait 
)

Definition at line 170 of file block_dev.c.

void bd_forget ( struct inode inode)

Definition at line 614 of file block_dev.c.

void bd_set_size ( struct block_device bdev,
loff_t  size 
)

Definition at line 1031 of file block_dev.c.

void __init bdev_cache_init ( void  )

Definition at line 468 of file block_dev.c.

struct block_device* bdget ( dev_t  dev)
read

Definition at line 509 of file block_dev.c.

struct block_device* bdgrab ( struct block_device bdev)
read

bdgrab – Grab a reference to an already referenced block device : Block device to grab a reference to.

Definition at line 549 of file block_dev.c.

void bdput ( struct block_device bdev)

Definition at line 567 of file block_dev.c.

ssize_t blkdev_aio_write ( struct kiocb iocb,
const struct iovec iov,
unsigned long  nr_segs,
loff_t  pos 
)

Definition at line 1524 of file block_dev.c.

int blkdev_fsync ( struct file filp,
loff_t  start,
loff_t  end,
int  datasync 
)

Definition at line 356 of file block_dev.c.

int blkdev_get ( struct block_device bdev,
fmode_t  mode,
void holder 
)

blkdev_get - open a block device : block_device to open : FMODE_* mask : exclusive holder identifier

Open with . If includes FMODE_EXCL, is open with exclusive access. Specifying FMODE_EXCL with NULL is invalid. Exclusive opens may nest for the same .

On success, the reference count of is unchanged. On failure, is put.

CONTEXT: Might sleep.

RETURNS: 0 on success, -errno on failure.

Definition at line 1228 of file block_dev.c.

struct block_device* blkdev_get_by_dev ( dev_t  dev,
fmode_t  mode,
void holder 
)
read

blkdev_get_by_dev - open a block device by device number : device number of block device to open : FMODE_* mask : exclusive holder identifier

Open the blockdevice described by device number . and are identical to blkdev_get().

Use it ONLY if you really do not have anything better - i.e. when you are behind a truly sucky interface and all you are given is a device number. Never to be used for internal purposes. If you ever need it - reconsider your API.

On success, the returned block_device has reference count of one.

CONTEXT: Might sleep.

RETURNS: Pointer to block_device on success, ERR_PTR(-errno) on failure.

Definition at line 1356 of file block_dev.c.

struct block_device* blkdev_get_by_path ( const char path,
fmode_t  mode,
void holder 
)
read

blkdev_get_by_path - open a block device by name : path to the block device to open : FMODE_* mask : exclusive holder identifier

Open the blockdevice described by the device file at . and are identical to blkdev_get().

On success, the returned block_device has reference count of one.

CONTEXT: Might sleep.

RETURNS: Pointer to block_device on success, ERR_PTR(-errno) on failure.

Definition at line 1311 of file block_dev.c.

int blkdev_put ( struct block_device bdev,
fmode_t  mode 
)

Definition at line 1445 of file block_dev.c.

int check_disk_change ( struct block_device bdev)

Definition at line 1012 of file block_dev.c.

void check_disk_size_change ( struct gendisk *  disk,
struct block_device bdev 
)

check_disk_size_change - checks for disk size change and adjusts bdev size. : struct gendisk to check : struct bdev to adjust.

This routine checks to see if the bdev size does not match the disk size and adjusts it if it differs.

Definition at line 956 of file block_dev.c.

EXPORT_SYMBOL ( I_BDEV  )
EXPORT_SYMBOL ( kill_bdev  )
EXPORT_SYMBOL ( invalidate_bdev  )
EXPORT_SYMBOL ( set_blocksize  )
EXPORT_SYMBOL ( sb_set_blocksize  )
EXPORT_SYMBOL ( sb_min_blocksize  )
EXPORT_SYMBOL ( sync_blockdev  )
EXPORT_SYMBOL ( fsync_bdev  )
EXPORT_SYMBOL ( freeze_bdev  )
EXPORT_SYMBOL ( thaw_bdev  )
EXPORT_SYMBOL ( blkdev_fsync  )
EXPORT_SYMBOL ( bdget  )
EXPORT_SYMBOL ( bdput  )
EXPORT_SYMBOL ( check_disk_size_change  )
EXPORT_SYMBOL ( revalidate_disk  )
EXPORT_SYMBOL ( check_disk_change  )
EXPORT_SYMBOL ( bd_set_size  )
EXPORT_SYMBOL ( blkdev_get  )
EXPORT_SYMBOL ( blkdev_get_by_path  )
EXPORT_SYMBOL ( blkdev_get_by_dev  )
EXPORT_SYMBOL ( blkdev_put  )
EXPORT_SYMBOL ( ioctl_by_bdev  )
EXPORT_SYMBOL ( lookup_bdev  )
EXPORT_SYMBOL ( __invalidate_device  )
EXPORT_SYMBOL_GPL ( blkdev_aio_write  )
struct super_block* freeze_bdev ( struct block_device bdev)
read

freeze_bdev – lock a filesystem and force it into a consistent state : blockdevice to lock

If a superblock is found on this device, we take the s_umount semaphore on it to make sure nobody unmounts until the snapshot creation is done. The reference counter (bd_fsfreeze_count) guarantees that only the last unfreeze process can unfreeze the frozen filesystem actually when multiple freeze requests arrive simultaneously. It counts up in freeze_bdev() and count down in thaw_bdev(). When it becomes 0, thaw_bdev() will unfreeze actually.

Definition at line 218 of file block_dev.c.

int fsync_bdev ( struct block_device bdev)

Definition at line 194 of file block_dev.c.

struct block_device* I_BDEV ( struct inode inode)
read

Definition at line 45 of file block_dev.c.

void invalidate_bdev ( struct block_device bdev)

Definition at line 87 of file block_dev.c.

int ioctl_by_bdev ( struct block_device bdev,
unsigned  cmd,
unsigned long  arg 
)

Definition at line 1605 of file block_dev.c.

void iterate_bdevs ( void(*)(struct block_device *, void *)  func,
void arg 
)

Definition at line 1680 of file block_dev.c.

void kill_bdev ( struct block_device bdev)

Definition at line 74 of file block_dev.c.

struct block_device* lookup_bdev ( const char pathname)
read

lookup_bdev - lookup a struct block_device by name : special file representing the block device

Get a reference to the blockdevice at in the current namespace if possible and return it. Return ERR_PTR(error) otherwise.

Definition at line 1625 of file block_dev.c.

long nr_blockdev_pages ( void  )

Definition at line 555 of file block_dev.c.

int revalidate_disk ( struct gendisk *  disk)

revalidate_disk - wrapper for lower-level driver's revalidate_disk call-back : struct gendisk to be revalidated

This routine is a wrapper for lower-level driver's revalidate_disk call-backs. It is used to do common pre and post operations needed for all revalidate_disk operations.

Definition at line 983 of file block_dev.c.

int sb_min_blocksize ( struct super_block sb,
int  size 
)

Definition at line 139 of file block_dev.c.

int sb_set_blocksize ( struct super_block sb,
int  size 
)

Definition at line 126 of file block_dev.c.

int set_blocksize ( struct block_device bdev,
int  size 
)

Definition at line 104 of file block_dev.c.

int sync_blockdev ( struct block_device bdev)

Definition at line 183 of file block_dev.c.

int thaw_bdev ( struct block_device bdev,
struct super_block sb 
)

thaw_bdev – unlock filesystem : blockdevice to unlock : associated superblock

Unlocks the filesystem and marks it writeable again after freeze_bdev().

Definition at line 261 of file block_dev.c.

Variable Documentation

struct file_operations def_blk_fops
Initial value:
= {
.open = blkdev_open,
.release = blkdev_close,
.llseek = block_llseek,
.read = do_sync_read,
.write = do_sync_write,
.aio_read = blkdev_aio_read,
.aio_write = blkdev_aio_write,
.fsync = blkdev_fsync,
.unlocked_ioctl = block_ioctl,
.splice_read = generic_file_splice_read,
.splice_write = generic_file_splice_write,
}

Definition at line 1587 of file block_dev.c.