Release 4.7 drivers/block/brd.c
/*
* Ram backed block device driver.
*
* Copyright (C) 2007 Nick Piggin
* Copyright (C) 2007 Novell Inc.
*
* Parts derived from drivers/block/rd.c, and drivers/block/loop.c, copyright
* of their respective owners.
*/
#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/major.h>
#include <linux/blkdev.h>
#include <linux/bio.h>
#include <linux/highmem.h>
#include <linux/mutex.h>
#include <linux/radix-tree.h>
#include <linux/fs.h>
#include <linux/slab.h>
#ifdef CONFIG_BLK_DEV_RAM_DAX
#include <linux/pfn_t.h>
#endif
#include <asm/uaccess.h>
#define SECTOR_SHIFT 9
#define PAGE_SECTORS_SHIFT (PAGE_SHIFT - SECTOR_SHIFT)
#define PAGE_SECTORS (1 << PAGE_SECTORS_SHIFT)
/*
* Each block ramdisk device has a radix_tree brd_pages of pages that stores
* the pages containing the block device's contents. A brd page's ->index is
* its offset in PAGE_SIZE units. This is similar to, but in no way connected
* with, the kernel's pagecache or buffer cache (which sit above our block
* device).
*/
struct brd_device {
int brd_number;
struct request_queue *brd_queue;
struct gendisk *brd_disk;
struct list_head brd_list;
/*
* Backing store of pages and lock to protect it. This is the contents
* of the block device.
*/
spinlock_t brd_lock;
struct radix_tree_root brd_pages;
};
/*
* Look up and return a brd's page for a given sector.
*/
static DEFINE_MUTEX(brd_mutex);
static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector)
{
pgoff_t idx;
struct page *page;
/*
* The page lifetime is protected by the fact that we have opened the
* device node -- brd pages will never be deleted under us, so we
* don't need any further locking or refcounting.
*
* This is strictly true for the radix-tree nodes as well (ie. we
* don't actually need the rcu_read_lock()), however that is not a
* documented feature of the radix-tree API so it is better to be
* safe here (we don't have total exclusion from radix tree updates
* here, only deletes).
*/
rcu_read_lock();
idx = sector >> PAGE_SECTORS_SHIFT; /* sector to page index */
page = radix_tree_lookup(&brd->brd_pages, idx);
rcu_read_unlock();
BUG_ON(page && page->index != idx);
return page;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 41 | 64.06% | 1 | 20.00% |
linus torvalds | linus torvalds | 13 | 20.31% | 1 | 20.00% |
andrew morton | andrew morton | 10 | 15.62% | 3 | 60.00% |
| Total | 64 | 100.00% | 5 | 100.00% |
/*
* Look up and return a brd's page for a given sector.
* If one does not exist, allocate an empty page, and insert that. Then
* return it.
*/
static struct page *brd_insert_page(struct brd_device *brd, sector_t sector)
{
pgoff_t idx;
struct page *page;
gfp_t gfp_flags;
page = brd_lookup_page(brd, sector);
if (page)
return page;
/*
* Must use NOIO because we don't want to recurse back into the
* block or filesystem layers from page reclaim.
*
* Cannot support DAX and highmem, because our ->direct_access
* routine for DAX must return memory that is always addressable.
* If DAX was reworked to use pfns and kmap throughout, this
* restriction might be able to be lifted.
*/
gfp_flags = GFP_NOIO | __GFP_ZERO;
#ifndef CONFIG_BLK_DEV_RAM_DAX
gfp_flags |= __GFP_HIGHMEM;
#endif
page = alloc_page(gfp_flags);
if (!page)
return NULL;
if (radix_tree_preload(GFP_NOIO)) {
__free_page(page);
return NULL;
}
spin_lock(&brd->brd_lock);
idx = sector >> PAGE_SECTORS_SHIFT;
page->index = idx;
if (radix_tree_insert(&brd->brd_pages, idx, page)) {
__free_page(page);
page = radix_tree_lookup(&brd->brd_pages, idx);
BUG_ON(!page);
BUG_ON(page->index != idx);
}
spin_unlock(&brd->brd_lock);
radix_tree_preload_end();
return page;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 109 | 63.01% | 2 | 25.00% |
andrew morton | andrew morton | 38 | 21.97% | 2 | 25.00% |
linus torvalds | linus torvalds | 17 | 9.83% | 1 | 12.50% |
brian behlendorf | brian behlendorf | 6 | 3.47% | 1 | 12.50% |
matthew wilcox | matthew wilcox | 2 | 1.16% | 1 | 12.50% |
petr tesarik | petr tesarik | 1 | 0.58% | 1 | 12.50% |
| Total | 173 | 100.00% | 8 | 100.00% |
static void brd_free_page(struct brd_device *brd, sector_t sector)
{
struct page *page;
pgoff_t idx;
spin_lock(&brd->brd_lock);
idx = sector >> PAGE_SECTORS_SHIFT;
page = radix_tree_delete(&brd->brd_pages, idx);
spin_unlock(&brd->brd_lock);
if (page)
__free_page(page);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 65 | 100.00% | 1 | 100.00% |
| Total | 65 | 100.00% | 1 | 100.00% |
static void brd_zero_page(struct brd_device *brd, sector_t sector)
{
struct page *page;
page = brd_lookup_page(brd, sector);
if (page)
clear_highpage(page);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 37 | 100.00% | 1 | 100.00% |
| Total | 37 | 100.00% | 1 | 100.00% |
/*
* Free all backing store pages and radix tree. This must only be called when
* there are no other users of the device.
*/
#define FREE_BATCH 16
static void brd_free_pages(struct brd_device *brd)
{
unsigned long pos = 0;
struct page *pages[FREE_BATCH];
int nr_pages;
do {
int i;
nr_pages = radix_tree_gang_lookup(&brd->brd_pages,
(void **)pages, pos, FREE_BATCH);
for (i = 0; i < nr_pages; i++) {
void *ret;
BUG_ON(pages[i]->index < pos);
pos = pages[i]->index;
ret = radix_tree_delete(&brd->brd_pages, pos);
BUG_ON(!ret || ret != pages[i]);
__free_page(pages[i]);
}
pos++;
/*
* This assumes radix_tree_gang_lookup always returns as
* many pages as possible. If the radix-tree code changes,
* so will this have to.
*/
} while (nr_pages == FREE_BATCH);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 130 | 93.53% | 1 | 50.00% |
andrew morton | andrew morton | 9 | 6.47% | 1 | 50.00% |
| Total | 139 | 100.00% | 2 | 100.00% |
/*
* copy_to_brd_setup must be called before copy_to_brd. It may sleep.
*/
static int copy_to_brd_setup(struct brd_device *brd, sector_t sector, size_t n)
{
unsigned int offset = (sector & (PAGE_SECTORS-1)) << SECTOR_SHIFT;
size_t copy;
copy = min_t(size_t, n, PAGE_SIZE - offset);
if (!brd_insert_page(brd, sector))
return -ENOSPC;
if (copy < n) {
sector += copy >> SECTOR_SHIFT;
if (!brd_insert_page(brd, sector))
return -ENOSPC;
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 73 | 77.66% | 1 | 20.00% |
andrew morton | andrew morton | 15 | 15.96% | 2 | 40.00% |
linus torvalds | linus torvalds | 4 | 4.26% | 1 | 20.00% |
matthew wilcox | matthew wilcox | 2 | 2.13% | 1 | 20.00% |
| Total | 94 | 100.00% | 5 | 100.00% |
static void discard_from_brd(struct brd_device *brd,
sector_t sector, size_t n)
{
while (n >= PAGE_SIZE) {
/*
* Don't want to actually discard pages here because
* re-allocating the pages can result in writeback
* deadlocks under heavy load.
*/
if (0)
brd_free_page(brd, sector);
else
brd_zero_page(brd, sector);
sector += PAGE_SIZE >> SECTOR_SHIFT;
n -= PAGE_SIZE;
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 55 | 100.00% | 1 | 100.00% |
| Total | 55 | 100.00% | 1 | 100.00% |
/*
* Copy n bytes from src to the brd starting at sector. Does not sleep.
*/
static void copy_to_brd(struct brd_device *brd, const void *src,
sector_t sector, size_t n)
{
struct page *page;
void *dst;
unsigned int offset = (sector & (PAGE_SECTORS-1)) << SECTOR_SHIFT;
size_t copy;
copy = min_t(size_t, n, PAGE_SIZE - offset);
page = brd_lookup_page(brd, sector);
BUG_ON(!page);
dst = kmap_atomic(page);
memcpy(dst + offset, src, copy);
kunmap_atomic(dst);
if (copy < n) {
src += copy;
sector += copy >> SECTOR_SHIFT;
copy = n - copy;
page = brd_lookup_page(brd, sector);
BUG_ON(!page);
dst = kmap_atomic(page);
memcpy(dst, src, copy);
kunmap_atomic(dst);
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 87 | 54.04% | 1 | 11.11% |
linus torvalds | linus torvalds | 50 | 31.06% | 3 | 33.33% |
andrew morton | andrew morton | 11 | 6.83% | 2 | 22.22% |
christian borntraeger | christian borntraeger | 7 | 4.35% | 1 | 11.11% |
al viro | al viro | 5 | 3.11% | 1 | 11.11% |
russell king | russell king | 1 | 0.62% | 1 | 11.11% |
| Total | 161 | 100.00% | 9 | 100.00% |
/*
* Copy n bytes to dst from the brd starting at sector. Does not sleep.
*/
static void copy_from_brd(void *dst, struct brd_device *brd,
sector_t sector, size_t n)
{
struct page *page;
void *src;
unsigned int offset = (sector & (PAGE_SECTORS-1)) << SECTOR_SHIFT;
size_t copy;
copy = min_t(size_t, n, PAGE_SIZE - offset);
page = brd_lookup_page(brd, sector);
if (page) {
src = kmap_atomic(page);
memcpy(dst, src + offset, copy);
kunmap_atomic(src);
} else
memset(dst, 0, copy);
if (copy < n) {
dst += copy;
sector += copy >> SECTOR_SHIFT;
copy = n - copy;
page = brd_lookup_page(brd, sector);
if (page) {
src = kmap_atomic(page);
memcpy(dst, src, copy);
kunmap_atomic(src);
} else
memset(dst, 0, copy);
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 131 | 72.78% | 1 | 14.29% |
linus torvalds | linus torvalds | 27 | 15.00% | 3 | 42.86% |
al viro | al viro | 13 | 7.22% | 1 | 14.29% |
pre-git | pre-git | 9 | 5.00% | 2 | 28.57% |
| Total | 180 | 100.00% | 7 | 100.00% |
/*
* Process a single bvec of a bio.
*/
static int brd_do_bvec(struct brd_device *brd, struct page *page,
unsigned int len, unsigned int off, int rw,
sector_t sector)
{
void *mem;
int err = 0;
if (rw != READ) {
err = copy_to_brd_setup(brd, sector, len);
if (err)
goto out;
}
mem = kmap_atomic(page);
if (rw == READ) {
copy_from_brd(mem + off, brd, sector, len);
flush_dcache_page(page);
} else {
flush_dcache_page(page);
copy_to_brd(brd, mem + off, sector, len);
}
kunmap_atomic(mem);
out:
return err;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 99 | 76.74% | 2 | 25.00% |
pre-git | pre-git | 18 | 13.95% | 2 | 25.00% |
linus torvalds | linus torvalds | 7 | 5.43% | 2 | 25.00% |
al viro | al viro | 5 | 3.88% | 2 | 25.00% |
| Total | 129 | 100.00% | 8 | 100.00% |
static blk_qc_t brd_make_request(struct request_queue *q, struct bio *bio)
{
struct block_device *bdev = bio->bi_bdev;
struct brd_device *brd = bdev->bd_disk->private_data;
int rw;
struct bio_vec bvec;
sector_t sector;
struct bvec_iter iter;
sector = bio->bi_iter.bi_sector;
if (bio_end_sector(bio) > get_capacity(bdev->bd_disk))
goto io_error;
if (unlikely(bio->bi_rw & REQ_DISCARD)) {
if (sector & ((PAGE_SIZE >> SECTOR_SHIFT) - 1) ||
bio->bi_iter.bi_size & ~PAGE_MASK)
goto io_error;
discard_from_brd(brd, sector, bio->bi_iter.bi_size);
goto out;
}
rw = bio_rw(bio);
if (rw == READA)
rw = READ;
bio_for_each_segment(bvec, bio, iter) {
unsigned int len = bvec.bv_len;
int err;
err = brd_do_bvec(brd, bvec.bv_page, len,
bvec.bv_offset, rw, sector);
if (err)
goto io_error;
sector += len >> SECTOR_SHIFT;
}
out:
bio_endio(bio);
return BLK_QC_T_NONE;
io_error:
bio_io_error(bio);
return BLK_QC_T_NONE;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 157 | 70.72% | 2 | 20.00% |
jan kara | jan kara | 25 | 11.26% | 1 | 10.00% |
christoph hellwig | christoph hellwig | 18 | 8.11% | 2 | 20.00% |
kent overstreet | kent overstreet | 14 | 6.31% | 3 | 30.00% |
jens axboe | jens axboe | 7 | 3.15% | 1 | 10.00% |
bart van assche | bart van assche | 1 | 0.45% | 1 | 10.00% |
| Total | 222 | 100.00% | 10 | 100.00% |
static int brd_rw_page(struct block_device *bdev, sector_t sector,
struct page *page, int rw)
{
struct brd_device *brd = bdev->bd_disk->private_data;
int err = brd_do_bvec(brd, page, PAGE_SIZE, 0, rw, sector);
page_endio(page, rw & WRITE, err);
return err;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
matthew wilcox | matthew wilcox | 64 | 98.46% | 1 | 50.00% |
kirill a. shutemov | kirill a. shutemov | 1 | 1.54% | 1 | 50.00% |
| Total | 65 | 100.00% | 2 | 100.00% |
#ifdef CONFIG_BLK_DEV_RAM_DAX
static long brd_direct_access(struct block_device *bdev, sector_t sector,
void __pmem **kaddr, pfn_t *pfn, long size)
{
struct brd_device *brd = bdev->bd_disk->private_data;
struct page *page;
if (!brd)
return -ENODEV;
page = brd_insert_page(brd, sector);
if (!page)
return -ENOSPC;
*kaddr = (void __pmem *)page_address(page);
*pfn = page_to_pfn_t(page);
return PAGE_SIZE;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 66 | 70.21% | 1 | 14.29% |
jared hulbert | jared hulbert | 14 | 14.89% | 1 | 14.29% |
ross zwisler | ross zwisler | 6 | 6.38% | 1 | 14.29% |
dan williams | dan williams | 5 | 5.32% | 2 | 28.57% |
matthew wilcox | matthew wilcox | 3 | 3.19% | 2 | 28.57% |
| Total | 94 | 100.00% | 7 | 100.00% |
#else
#define brd_direct_access NULL
#endif
static int brd_ioctl(struct block_device *bdev, fmode_t mode,
unsigned int cmd, unsigned long arg)
{
int error;
struct brd_device *brd = bdev->bd_disk->private_data;
if (cmd != BLKFLSBUF)
return -ENOTTY;
/*
* ram device BLKFLSBUF has special semantics, we want to actually
* release and destroy the ramdisk data.
*/
mutex_lock(&brd_mutex);
mutex_lock(&bdev->bd_mutex);
error = -EBUSY;
if (bdev->bd_openers <= 1) {
/*
* Kill the cache first, so it isn't written back to the
* device.
*
* Another thread might instantiate more buffercache here,
* but there is not much we can do to close that race.
*/
kill_bdev(bdev);
brd_free_pages(brd);
error = 0;
}
mutex_unlock(&bdev->bd_mutex);
mutex_unlock(&brd_mutex);
return error;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 71 | 65.74% | 1 | 9.09% |
arnd bergmann | arnd bergmann | 12 | 11.11% | 2 | 18.18% |
linus torvalds | linus torvalds | 9 | 8.33% | 2 | 18.18% |
al viro | al viro | 7 | 6.48% | 3 | 27.27% |
pre-git | pre-git | 7 | 6.48% | 2 | 18.18% |
arjan van de ven | arjan van de ven | 2 | 1.85% | 1 | 9.09% |
| Total | 108 | 100.00% | 11 | 100.00% |
static const struct block_device_operations brd_fops = {
.owner = THIS_MODULE,
.rw_page = brd_rw_page,
.ioctl = brd_ioctl,
.direct_access = brd_direct_access,
};
/*
* And now the modules code and kernel interface.
*/
static int rd_nr = CONFIG_BLK_DEV_RAM_COUNT;
module_param(rd_nr, int, S_IRUGO);
MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices");
int rd_size = CONFIG_BLK_DEV_RAM_SIZE;
module_param(rd_size, int, S_IRUGO);
MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes.");
static int max_part = 1;
module_param(max_part, int, S_IRUGO);
MODULE_PARM_DESC(max_part, "Num Minors to reserve between devices");
MODULE_LICENSE("GPL");
MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
MODULE_ALIAS("rd");
#ifndef MODULE
/* Legacy boot options - nonmodular */
static int __init ramdisk_size(char *str)
{
rd_size = simple_strtol(str, NULL, 0);
return 1;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 22 | 88.00% | 1 | 50.00% |
linus torvalds | linus torvalds | 3 | 12.00% | 1 | 50.00% |
| Total | 25 | 100.00% | 2 | 100.00% |
__setup("ramdisk_size=", ramdisk_size);
#endif
/*
* The device scheme is derived from loop.c. Keep them in synch where possible
* (should share code eventually).
*/
static LIST_HEAD(brd_devices);
static DEFINE_MUTEX(brd_devices_mutex);
static struct brd_device *brd_alloc(int i)
{
struct brd_device *brd;
struct gendisk *disk;
brd = kzalloc(sizeof(*brd), GFP_KERNEL);
if (!brd)
goto out;
brd->brd_number = i;
spin_lock_init(&brd->brd_lock);
INIT_RADIX_TREE(&brd->brd_pages, GFP_ATOMIC);
brd->brd_queue = blk_alloc_queue(GFP_KERNEL);
if (!brd->brd_queue)
goto out_free_dev;
blk_queue_make_request(brd->brd_queue, brd_make_request);
blk_queue_max_hw_sectors(brd->brd_queue, 1024);
blk_queue_bounce_limit(brd->brd_queue, BLK_BOUNCE_ANY);
/* This is so fdisk will align partitions on 4k, because of
* direct_access API needing 4k alignment, returning a PFN
* (This is only a problem on very small devices <= 4M,
* otherwise fdisk will align on 1M. Regardless this call
* is harmless)
*/
blk_queue_physical_block_size(brd->brd_queue, PAGE_SIZE);
brd->brd_queue->limits.discard_granularity = PAGE_SIZE;
blk_queue_max_discard_sectors(brd->brd_queue, UINT_MAX);
brd->brd_queue->limits.discard_zeroes_data = 1;
queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, brd->brd_queue);
disk = brd->brd_disk = alloc_disk(max_part);
if (!disk)
goto out_free_queue;
disk->major = RAMDISK_MAJOR;
disk->first_minor = i * max_part;
disk->fops = &brd_fops;
disk->private_data = brd;
disk->queue = brd->brd_queue;
disk->flags = GENHD_FL_EXT_DEVT;
sprintf(disk->disk_name, "ram%d", i);
set_capacity(disk, rd_size * 2);
return brd;
out_free_queue:
blk_cleanup_queue(brd->brd_queue);
out_free_dev:
kfree(brd);
out:
return NULL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 185 | 70.08% | 2 | 9.52% |
andrew morton | andrew morton | 18 | 6.82% | 2 | 9.52% |
al viro | al viro | 15 | 5.68% | 5 | 23.81% |
boaz harrosh | boaz harrosh | 15 | 5.68% | 2 | 9.52% |
linus torvalds | linus torvalds | 9 | 3.41% | 3 | 14.29% |
eric w. biederman | eric w. biederman | 8 | 3.03% | 1 | 4.76% |
pre-git | pre-git | 5 | 1.89% | 3 | 14.29% |
marcin krol | marcin krol | 4 | 1.52% | 1 | 4.76% |
jens axboe | jens axboe | 4 | 1.52% | 1 | 4.76% |
martin k. petersen | martin k. petersen | 1 | 0.38% | 1 | 4.76% |
| Total | 264 | 100.00% | 21 | 100.00% |
static void brd_free(struct brd_device *brd)
{
put_disk(brd->brd_disk);
blk_cleanup_queue(brd->brd_queue);
brd_free_pages(brd);
kfree(brd);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 32 | 91.43% | 1 | 50.00% |
pre-git | pre-git | 3 | 8.57% | 1 | 50.00% |
| Total | 35 | 100.00% | 2 | 100.00% |
static struct brd_device *brd_init_one(int i, bool *new)
{
struct brd_device *brd;
*new = false;
list_for_each_entry(brd, &brd_devices, brd_list) {
if (brd->brd_number == i)
goto out;
}
brd = brd_alloc(i);
if (brd) {
add_disk(brd->brd_disk);
list_add_tail(&brd->brd_list, &brd_devices);
}
*new = true;
out:
return brd;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 51 | 58.62% | 1 | 10.00% |
boaz harrosh | boaz harrosh | 14 | 16.09% | 1 | 10.00% |
linus torvalds | linus torvalds | 11 | 12.64% | 3 | 30.00% |
pre-git | pre-git | 10 | 11.49% | 4 | 40.00% |
al viro | al viro | 1 | 1.15% | 1 | 10.00% |
| Total | 87 | 100.00% | 10 | 100.00% |
static void brd_del_one(struct brd_device *brd)
{
list_del(&brd->brd_list);
del_gendisk(brd->brd_disk);
brd_free(brd);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 21 | 67.74% | 1 | 20.00% |
al viro | al viro | 7 | 22.58% | 3 | 60.00% |
jeff garzik | jeff garzik | 3 | 9.68% | 1 | 20.00% |
| Total | 31 | 100.00% | 5 | 100.00% |
static struct kobject *brd_probe(dev_t dev, int *part, void *data)
{
struct brd_device *brd;
struct kobject *kobj;
bool new;
mutex_lock(&brd_devices_mutex);
brd = brd_init_one(MINOR(dev) / max_part, &new);
kobj = brd ? get_disk(brd->brd_disk) : NULL;
mutex_unlock(&brd_devices_mutex);
if (new)
*part = 0;
return kobj;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 58 | 69.05% | 1 | 16.67% |
boaz harrosh | boaz harrosh | 12 | 14.29% | 1 | 16.67% |
peter zijlstra | peter zijlstra | 6 | 7.14% | 1 | 16.67% |
pre-git | pre-git | 4 | 4.76% | 1 | 16.67% |
namhyung kim | namhyung kim | 3 | 3.57% | 1 | 16.67% |
mikulas patocka | mikulas patocka | 1 | 1.19% | 1 | 16.67% |
| Total | 84 | 100.00% | 6 | 100.00% |
static int __init brd_init(void)
{
struct brd_device *brd, *next;
int i;
/*
* brd module now has a feature to instantiate underlying device
* structure on-demand, provided that there is an access dev node.
*
* (1) if rd_nr is specified, create that many upfront. else
* it defaults to CONFIG_BLK_DEV_RAM_COUNT
* (2) User can further extend brd devices by create dev node themselves
* and have kernel automatically instantiate actual device
* on-demand. Example:
* mknod /path/devnod_name b 1 X # 1 is the rd major
* fdisk -l /path/devnod_name
* If (X / max_part) was not already created it will be created
* dynamically.
*/
if (register_blkdev(RAMDISK_MAJOR, "ramdisk"))
return -EIO;
if (unlikely(!max_part))
max_part = 1;
for (i = 0; i < rd_nr; i++) {
brd = brd_alloc(i);
if (!brd)
goto out_free;
list_add_tail(&brd->brd_list, &brd_devices);
}
/* point of no return */
list_for_each_entry(brd, &brd_devices, brd_list)
add_disk(brd->brd_disk);
blk_register_region(MKDEV(RAMDISK_MAJOR, 0), 1UL << MINORBITS,
THIS_MODULE, brd_probe, NULL, NULL);
pr_info("brd: module loaded\n");
return 0;
out_free:
list_for_each_entry_safe(brd, next, &brd_devices, brd_list) {
list_del(&brd->brd_list);
brd_free(brd);
}
unregister_blkdev(RAMDISK_MAJOR, "ramdisk");
pr_info("brd: module NOT loaded !!!\n");
return -ENOMEM;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 76 | 43.18% | 1 | 5.56% |
pre-git | pre-git | 43 | 24.43% | 6 | 33.33% |
boaz harrosh | boaz harrosh | 26 | 14.77% | 1 | 5.56% |
al viro | al viro | 8 | 4.55% | 3 | 16.67% |
linus torvalds | linus torvalds | 8 | 4.55% | 1 | 5.56% |
peter zijlstra | peter zijlstra | 7 | 3.98% | 1 | 5.56% |
andrew morton | andrew morton | 5 | 2.84% | 2 | 11.11% |
christoph hellwig | christoph hellwig | 1 | 0.57% | 1 | 5.56% |
akinobu mita | akinobu mita | 1 | 0.57% | 1 | 5.56% |
eric w. biederman | eric w. biederman | 1 | 0.57% | 1 | 5.56% |
| Total | 176 | 100.00% | 18 | 100.00% |
static void __exit brd_exit(void)
{
struct brd_device *brd, *next;
list_for_each_entry_safe(brd, next, &brd_devices, brd_list)
brd_del_one(brd);
blk_unregister_region(MKDEV(RAMDISK_MAJOR, 0), 1UL << MINORBITS);
unregister_blkdev(RAMDISK_MAJOR, "ramdisk");
pr_info("brd: module unloaded\n");
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 27 | 46.55% | 1 | 14.29% |
linus torvalds | linus torvalds | 12 | 20.69% | 1 | 14.29% |
pre-git | pre-git | 10 | 17.24% | 3 | 42.86% |
boaz harrosh | boaz harrosh | 8 | 13.79% | 1 | 14.29% |
stephen hemminger | stephen hemminger | 1 | 1.72% | 1 | 14.29% |
| Total | 58 | 100.00% | 7 | 100.00% |
module_init(brd_init);
module_exit(brd_exit);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nick piggin | nick piggin | 1734 | 66.51% | 5 | 4.95% |
linus torvalds | linus torvalds | 175 | 6.71% | 8 | 7.92% |
andrew morton | andrew morton | 124 | 4.76% | 14 | 13.86% |
pre-git | pre-git | 120 | 4.60% | 17 | 16.83% |
boaz harrosh | boaz harrosh | 88 | 3.38% | 2 | 1.98% |
matthew wilcox | matthew wilcox | 84 | 3.22% | 4 | 3.96% |
al viro | al viro | 64 | 2.45% | 11 | 10.89% |
christoph hellwig | christoph hellwig | 27 | 1.04% | 5 | 4.95% |
jan kara | jan kara | 25 | 0.96% | 1 | 0.99% |
arnd bergmann | arnd bergmann | 22 | 0.84% | 2 | 1.98% |
dmitriy monakhov | dmitriy monakhov | 14 | 0.54% | 1 | 0.99% |
jared hulbert | jared hulbert | 14 | 0.54% | 1 | 0.99% |
kent overstreet | kent overstreet | 14 | 0.54% | 3 | 2.97% |
peter zijlstra | peter zijlstra | 13 | 0.50% | 1 | 0.99% |
dan williams | dan williams | 13 | 0.50% | 2 | 1.98% |
jens axboe | jens axboe | 11 | 0.42% | 2 | 1.98% |
eric w. biederman | eric w. biederman | 9 | 0.35% | 1 | 0.99% |
christian borntraeger | christian borntraeger | 7 | 0.27% | 1 | 0.99% |
stephen hemminger | stephen hemminger | 7 | 0.27% | 1 | 0.99% |
brian behlendorf | brian behlendorf | 6 | 0.23% | 1 | 0.99% |
ross zwisler | ross zwisler | 6 | 0.23% | 1 | 0.99% |
namhyung kim | namhyung kim | 5 | 0.19% | 2 | 1.98% |
marcin krol | marcin krol | 4 | 0.15% | 1 | 0.99% |
jeff garzik | jeff garzik | 3 | 0.12% | 1 | 0.99% |
tejun heo | tejun heo | 3 | 0.12% | 1 | 0.99% |
robert p. j. day | robert p. j. day | 3 | 0.12% | 2 | 1.98% |
laurent vivier | laurent vivier | 2 | 0.08% | 1 | 0.99% |
arjan van de ven | arjan van de ven | 2 | 0.08% | 1 | 0.99% |
petr tesarik | petr tesarik | 1 | 0.04% | 1 | 0.99% |
bart van assche | bart van assche | 1 | 0.04% | 1 | 0.99% |
martin k. petersen | martin k. petersen | 1 | 0.04% | 1 | 0.99% |
alexey dobriyan | alexey dobriyan | 1 | 0.04% | 1 | 0.99% |
kirill a. shutemov | kirill a. shutemov | 1 | 0.04% | 1 | 0.99% |
russell king | russell king | 1 | 0.04% | 1 | 0.99% |
mikulas patocka | mikulas patocka | 1 | 0.04% | 1 | 0.99% |
akinobu mita | akinobu mita | 1 | 0.04% | 1 | 0.99% |
| Total | 2607 | 100.00% | 101 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.