Release 4.12 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>
#include <linux/dax.h>
#endif
#include <linux/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;
#ifdef CONFIG_BLK_DEV_RAM_DAX
	
struct dax_device	*dax_dev;
#endif
	
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 | 
| Nicholas Piggin | 41 | 64.06% | 1 | 20.00% | 
| Linus Torvalds | 12 | 18.75% | 1 | 20.00% | 
| Andrew Morton | 11 | 17.19% | 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 | 
| Nicholas Piggin | 110 | 63.58% | 2 | 25.00% | 
| Andrew Morton | 37 | 21.39% | 2 | 25.00% | 
| Linus Torvalds | 17 | 9.83% | 1 | 12.50% | 
| Brian Behlendorf | 6 | 3.47% | 1 | 12.50% | 
| Matthew Wilcox | 2 | 1.16% | 1 | 12.50% | 
| Petr Tesarik | 1 | 0.58% | 1 | 12.50% | 
| Total | 173 | 100.00% | 8 | 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 | 
| Nicholas Piggin | 130 | 93.53% | 1 | 50.00% | 
| 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 | 
| Nicholas Piggin | 73 | 77.66% | 1 | 20.00% | 
| Andrew Morton | 15 | 15.96% | 2 | 40.00% | 
| Linus Torvalds | 4 | 4.26% | 1 | 20.00% | 
| Matthew Wilcox | 2 | 2.13% | 1 | 20.00% | 
| Total | 94 | 100.00% | 5 | 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 | 
| Nicholas Piggin | 84 | 52.17% | 1 | 10.00% | 
| Linus Torvalds | 52 | 32.30% | 3 | 30.00% | 
| Andrew Morton | 11 | 6.83% | 2 | 20.00% | 
| Al Viro | 7 | 4.35% | 1 | 10.00% | 
| Christian Bornträger | 5 | 3.11% | 1 | 10.00% | 
| Russell King | 1 | 0.62% | 1 | 10.00% | 
| Christoph Hellwig | 1 | 0.62% | 1 | 10.00% | 
| Total | 161 | 100.00% | 10 | 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 | 
| Nicholas Piggin | 131 | 72.78% | 1 | 14.29% | 
| Linus Torvalds | 27 | 15.00% | 3 | 42.86% | 
| Al Viro | 13 | 7.22% | 1 | 14.29% | 
| Linus Torvalds (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, bool is_write,
			sector_t sector)
{
	void *mem;
	int err = 0;
	if (is_write) {
		err = copy_to_brd_setup(brd, sector, len);
		if (err)
			goto out;
	}
	mem = kmap_atomic(page);
	if (!is_write) {
		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 | 
| Nicholas Piggin | 94 | 74.60% | 2 | 20.00% | 
| Linus Torvalds (pre-git) | 18 | 14.29% | 2 | 20.00% | 
| Linus Torvalds | 5 | 3.97% | 2 | 20.00% | 
| Al Viro | 4 | 3.17% | 2 | 20.00% | 
| Jens Axboe | 4 | 3.17% | 1 | 10.00% | 
| Michael Christie | 1 | 0.79% | 1 | 10.00% | 
| Total | 126 | 100.00% | 10 | 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;
	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;
	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,
					op_is_write(bio_op(bio)), sector);
		if (err)
			goto io_error;
		sector += len >> SECTOR_SHIFT;
	}
	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 | 
| Nicholas Piggin | 111 | 73.51% | 1 | 12.50% | 
| Christoph Hellwig | 14 | 9.27% | 1 | 12.50% | 
| Kent Overstreet | 12 | 7.95% | 3 | 37.50% | 
| Jens Axboe | 10 | 6.62% | 2 | 25.00% | 
| Michael Christie | 4 | 2.65% | 1 | 12.50% | 
| Total | 151 | 100.00% | 8 | 100.00% | 
static int brd_rw_page(struct block_device *bdev, sector_t sector,
		       struct page *page, bool is_write)
{
	struct brd_device *brd = bdev->bd_disk->private_data;
	int err = brd_do_bvec(brd, page, PAGE_SIZE, 0, is_write, sector);
	page_endio(page, is_write, err);
	return err;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Matthew Wilcox | 58 | 92.06% | 1 | 33.33% | 
| Jens Axboe | 4 | 6.35% | 1 | 33.33% | 
| Kirill A. Shutemov | 1 | 1.59% | 1 | 33.33% | 
| Total | 63 | 100.00% | 3 | 100.00% | 
#ifdef CONFIG_BLK_DEV_RAM_DAX
static long __brd_direct_access(struct brd_device *brd, pgoff_t pgoff,
		long nr_pages, void **kaddr, pfn_t *pfn)
{
	struct page *page;
	if (!brd)
		return -ENODEV;
	page = brd_insert_page(brd, PFN_PHYS(pgoff) / 512);
	if (!page)
		return -ENOSPC;
	*kaddr = page_address(page);
	*pfn = page_to_pfn_t(page);
	return 1;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Nicholas Piggin | 49 | 59.76% | 1 | 16.67% | 
| Dan J Williams | 17 | 20.73% | 2 | 33.33% | 
| Jared Hulbert | 14 | 17.07% | 1 | 16.67% | 
| Matthew Wilcox | 2 | 2.44% | 2 | 33.33% | 
| Total | 82 | 100.00% | 6 | 100.00% | 
static long brd_dax_direct_access(struct dax_device *dax_dev,
		pgoff_t pgoff, long nr_pages, void **kaddr, pfn_t *pfn)
{
	struct brd_device *brd = dax_get_private(dax_dev);
	return __brd_direct_access(brd, pgoff, nr_pages, kaddr, pfn);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Dan J Williams | 50 | 100.00% | 1 | 100.00% | 
| Total | 50 | 100.00% | 1 | 100.00% | 
static const struct dax_operations brd_dax_ops = {
	.direct_access = brd_dax_direct_access,
};
#endif
static const struct block_device_operations brd_fops = {
	.owner =		THIS_MODULE,
	.rw_page =		brd_rw_page,
};
/*
 * 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");
unsigned long rd_size = CONFIG_BLK_DEV_RAM_SIZE;
module_param(rd_size, ulong, 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 | 
| Nicholas Piggin | 22 | 88.00% | 1 | 50.00% | 
| 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);
	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);
#ifdef CONFIG_BLK_DEV_RAM_DAX
	queue_flag_set_unlocked(QUEUE_FLAG_DAX, brd->brd_queue);
	brd->dax_dev = alloc_dax(brd, disk->disk_name, &brd_dax_ops);
	if (!brd->dax_dev)
		goto out_free_inode;
#endif
	return brd;
#ifdef CONFIG_BLK_DEV_RAM_DAX
out_free_inode:
	kill_dax(brd->dax_dev);
	put_dax(brd->dax_dev);
#endif
out_free_queue:
	blk_cleanup_queue(brd->brd_queue);
out_free_dev:
	kfree(brd);
out:
	return NULL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Nicholas Piggin | 148 | 51.57% | 1 | 4.55% | 
| Dan J Williams | 53 | 18.47% | 1 | 4.55% | 
| Andrew Morton | 18 | 6.27% | 2 | 9.09% | 
| Al Viro | 15 | 5.23% | 5 | 22.73% | 
| Boaz Harrosh | 15 | 5.23% | 2 | 9.09% | 
| Linus Torvalds | 9 | 3.14% | 3 | 13.64% | 
| Linus Torvalds (pre-git) | 8 | 2.79% | 4 | 18.18% | 
| Eric W. Biedermann | 8 | 2.79% | 1 | 4.55% | 
| Gerald Schaefer | 8 | 2.79% | 1 | 4.55% | 
| Marcin Krol | 4 | 1.39% | 1 | 4.55% | 
| Martin K. Petersen | 1 | 0.35% | 1 | 4.55% | 
| Total | 287 | 100.00% | 22 | 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 | 
| Nicholas Piggin | 32 | 91.43% | 1 | 50.00% | 
| Linus Torvalds (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 | 
| Nicholas Piggin | 50 | 57.47% | 1 | 9.09% | 
| Boaz Harrosh | 14 | 16.09% | 1 | 9.09% | 
| Al Viro | 8 | 9.20% | 3 | 27.27% | 
| Linus Torvalds | 6 | 6.90% | 2 | 18.18% | 
| Linus Torvalds (pre-git) | 6 | 6.90% | 3 | 27.27% | 
| Jeff Garzik | 3 | 3.45% | 1 | 9.09% | 
| Total | 87 | 100.00% | 11 | 100.00% | 
static void brd_del_one(struct brd_device *brd)
{
	list_del(&brd->brd_list);
#ifdef CONFIG_BLK_DEV_RAM_DAX
	kill_dax(brd->dax_dev);
	put_dax(brd->dax_dev);
#endif
	del_gendisk(brd->brd_disk);
	brd_free(brd);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Nicholas Piggin | 21 | 42.00% | 1 | 25.00% | 
| Dan J Williams | 19 | 38.00% | 1 | 25.00% | 
| Peter Zijlstra | 6 | 12.00% | 1 | 25.00% | 
| Linus Torvalds (pre-git) | 4 | 8.00% | 1 | 25.00% | 
| Total | 50 | 100.00% | 4 | 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 | 
| Nicholas Piggin | 45 | 53.57% | 1 | 11.11% | 
| Boaz Harrosh | 12 | 14.29% | 1 | 11.11% | 
| Peter Zijlstra | 11 | 13.10% | 1 | 11.11% | 
| Linus Torvalds (pre-git) | 11 | 13.10% | 3 | 33.33% | 
| Namhyung Kim | 3 | 3.57% | 1 | 11.11% | 
| Mikulas Patocka | 1 | 1.19% | 1 | 11.11% | 
| Linus Torvalds | 1 | 1.19% | 1 | 11.11% | 
| Total | 84 | 100.00% | 9 | 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 | 
| Nicholas Piggin | 103 | 58.52% | 1 | 5.26% | 
| Boaz Harrosh | 26 | 14.77% | 1 | 5.26% | 
| Linus Torvalds (pre-git) | 16 | 9.09% | 5 | 26.32% | 
| Al Viro | 11 | 6.25% | 5 | 26.32% | 
| Linus Torvalds | 7 | 3.98% | 1 | 5.26% | 
| Peter Zijlstra | 7 | 3.98% | 1 | 5.26% | 
| Andrew Morton | 4 | 2.27% | 3 | 15.79% | 
| Akinobu Mita | 1 | 0.57% | 1 | 5.26% | 
| Christoph Hellwig | 1 | 0.57% | 1 | 5.26% | 
| Total | 176 | 100.00% | 19 | 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 | 
| Nicholas Piggin | 27 | 46.55% | 1 | 16.67% | 
| Linus Torvalds | 12 | 20.69% | 1 | 16.67% | 
| Linus Torvalds (pre-git) | 11 | 18.97% | 3 | 50.00% | 
| Boaz Harrosh | 8 | 13.79% | 1 | 16.67% | 
| Total | 58 | 100.00% | 6 | 100.00% | 
module_init(brd_init);
module_exit(brd_exit);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Nicholas Piggin | 1405 | 59.61% | 4 | 3.96% | 
| Dan J Williams | 173 | 7.34% | 2 | 1.98% | 
| Linus Torvalds | 165 | 7.00% | 9 | 8.91% | 
| Andrew Morton | 118 | 5.01% | 15 | 14.85% | 
| Linus Torvalds (pre-git) | 95 | 4.03% | 17 | 16.83% | 
| Boaz Harrosh | 87 | 3.69% | 2 | 1.98% | 
| Matthew Wilcox | 69 | 2.93% | 4 | 3.96% | 
| Al Viro | 61 | 2.59% | 11 | 10.89% | 
| Christoph Hellwig | 25 | 1.06% | 5 | 4.95% | 
| Peter Zijlstra | 24 | 1.02% | 1 | 0.99% | 
| Jens Axboe | 18 | 0.76% | 2 | 1.98% | 
| Jared Hulbert | 14 | 0.59% | 1 | 0.99% | 
| Dmitriy Monakhov | 14 | 0.59% | 1 | 0.99% | 
| Kent Overstreet | 12 | 0.51% | 3 | 2.97% | 
| Arnd Bergmann | 9 | 0.38% | 2 | 1.98% | 
| Gerald Schaefer | 8 | 0.34% | 1 | 0.99% | 
| Eric W. Biedermann | 8 | 0.34% | 1 | 0.99% | 
| Stephen Hemminger | 6 | 0.25% | 1 | 0.99% | 
| Brian Behlendorf | 6 | 0.25% | 1 | 0.99% | 
| Christian Bornträger | 5 | 0.21% | 1 | 0.99% | 
| Michael Christie | 5 | 0.21% | 1 | 0.99% | 
| Namhyung Kim | 5 | 0.21% | 2 | 1.98% | 
| Marcin Krol | 4 | 0.17% | 1 | 0.99% | 
| Tejun Heo | 3 | 0.13% | 1 | 0.99% | 
| Jeff Garzik | 3 | 0.13% | 1 | 0.99% | 
| Robert P. J. Day | 3 | 0.13% | 2 | 1.98% | 
| Jan Kara | 3 | 0.13% | 1 | 0.99% | 
| Laurent Vivier | 2 | 0.08% | 1 | 0.99% | 
| Mikulas Patocka | 1 | 0.04% | 1 | 0.99% | 
| Kirill A. Shutemov | 1 | 0.04% | 1 | 0.99% | 
| Akinobu Mita | 1 | 0.04% | 1 | 0.99% | 
| Petr Tesarik | 1 | 0.04% | 1 | 0.99% | 
| Alexey Dobriyan | 1 | 0.04% | 1 | 0.99% | 
| Russell King | 1 | 0.04% | 1 | 0.99% | 
| Martin K. Petersen | 1 | 0.04% | 1 | 0.99% | 
| Total | 2357 | 100.00% | 101 | 100.00% | 
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.