cregit-Linux how code gets into the kernel

Release 4.14 block/genhd.c

Directory: block
/*
 *  gendisk handling
 */

#include <linux/module.h>
#include <linux/fs.h>
#include <linux/genhd.h>
#include <linux/kdev_t.h>
#include <linux/kernel.h>
#include <linux/blkdev.h>
#include <linux/backing-dev.h>
#include <linux/init.h>
#include <linux/spinlock.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include <linux/kmod.h>
#include <linux/kobj_map.h>
#include <linux/mutex.h>
#include <linux/idr.h>
#include <linux/log2.h>
#include <linux/pm_runtime.h>
#include <linux/badblocks.h>

#include "blk.h"

static DEFINE_MUTEX(block_class_lock);

struct kobject *block_depr;

/* for extended dynamic devt allocation, currently only one major is used */

#define NR_EXT_DEVT		(1 << MINORBITS)

/* For extended devt allocation.  ext_devt_lock prevents look up
 * results from going away underneath its user.
 */
static DEFINE_SPINLOCK(ext_devt_lock);
static DEFINE_IDR(ext_devt_idr);


static const struct device_type disk_type;

static void disk_check_events(struct disk_events *ev,
			      unsigned int *clearing_ptr);
static void disk_alloc_events(struct gendisk *disk);
static void disk_add_events(struct gendisk *disk);
static void disk_del_events(struct gendisk *disk);
static void disk_release_events(struct gendisk *disk);


void part_inc_in_flight(struct request_queue *q, struct hd_struct *part, int rw) { if (q->mq_ops) return; atomic_inc(&part->in_flight[rw]); if (part->partno) atomic_inc(&part_to_disk(part)->part0.in_flight[rw]); }

Contributors

PersonTokensPropCommitsCommitProp
Jens Axboe5086.21%150.00%
Tejun Heo813.79%150.00%
Total58100.00%2100.00%


void part_dec_in_flight(struct request_queue *q, struct hd_struct *part, int rw) { if (q->mq_ops) return; atomic_dec(&part->in_flight[rw]); if (part->partno) atomic_dec(&part_to_disk(part)->part0.in_flight[rw]); }

Contributors

PersonTokensPropCommitsCommitProp
Jens Axboe5493.10%150.00%
Tejun Heo46.90%150.00%
Total58100.00%2100.00%


void part_in_flight(struct request_queue *q, struct hd_struct *part, unsigned int inflight[2]) { if (q->mq_ops) { blk_mq_in_flight(q, part, inflight); return; } inflight[0] = atomic_read(&part->in_flight[0]) + atomic_read(&part->in_flight[1]); if (part->partno) { part = &part_to_disk(part)->part0; inflight[1] = atomic_read(&part->in_flight[0]) + atomic_read(&part->in_flight[1]); } }

Contributors

PersonTokensPropCommitsCommitProp
Jens Axboe10291.07%125.00%
Tejun Heo108.93%375.00%
Total112100.00%4100.00%


struct hd_struct *__disk_get_part(struct gendisk *disk, int partno) { struct disk_part_tbl *ptbl = rcu_dereference(disk->part_tbl); if (unlikely(partno < 0 || partno >= ptbl->len)) return NULL; return rcu_dereference(ptbl->part[partno]); }

Contributors

PersonTokensPropCommitsCommitProp
Tejun Heo4275.00%266.67%
Christoph Hellwig1425.00%133.33%
Total56100.00%3100.00%

/** * disk_get_part - get partition * @disk: disk to look partition from * @partno: partition number * * Look for partition @partno from @disk. If found, increment * reference count and return it. * * CONTEXT: * Don't care. * * RETURNS: * Pointer to the found partition on success, NULL if not found. */
struct hd_struct *disk_get_part(struct gendisk *disk, int partno) { struct hd_struct *part; rcu_read_lock(); part = __disk_get_part(disk, partno); if (part) get_device(part_to_dev(part)); rcu_read_unlock(); return part; }

Contributors

PersonTokensPropCommitsCommitProp
Christoph Hellwig3060.00%133.33%
Tejun Heo2040.00%266.67%
Total50100.00%3100.00%

EXPORT_SYMBOL_GPL(disk_get_part); /** * disk_part_iter_init - initialize partition iterator * @piter: iterator to initialize * @disk: disk to iterate over * @flags: DISK_PITER_* flags * * Initialize @piter so that it iterates over partitions of @disk. * * CONTEXT: * Don't care. */
void disk_part_iter_init(struct disk_part_iter *piter, struct gendisk *disk, unsigned int flags) { struct disk_part_tbl *ptbl; rcu_read_lock(); ptbl = rcu_dereference(disk->part_tbl); piter->disk = disk; piter->part = NULL; if (flags & DISK_PITER_REVERSE) piter->idx = ptbl->len - 1; else if (flags & (DISK_PITER_INCL_PART0 | DISK_PITER_INCL_EMPTY_PART0)) piter->idx = 0; else piter->idx = 1; piter->flags = flags; rcu_read_unlock(); }

Contributors

PersonTokensPropCommitsCommitProp
Tejun Heo97100.00%4100.00%
Total97100.00%4100.00%

EXPORT_SYMBOL_GPL(disk_part_iter_init); /** * disk_part_iter_next - proceed iterator to the next partition and return it * @piter: iterator of interest * * Proceed @piter to the next partition and return it. * * CONTEXT: * Don't care. */
struct hd_struct *disk_part_iter_next(struct disk_part_iter *piter) { struct disk_part_tbl *ptbl; int inc, end; /* put the last partition */ disk_put_part(piter->part); piter->part = NULL; /* get part_tbl */ rcu_read_lock(); ptbl = rcu_dereference(piter->disk->part_tbl); /* determine iteration parameters */ if (piter->flags & DISK_PITER_REVERSE) { inc = -1; if (piter->flags & (DISK_PITER_INCL_PART0 | DISK_PITER_INCL_EMPTY_PART0)) end = -1; else end = 0; } else { inc = 1; end = ptbl->len; } /* iterate to the next partition */ for (; piter->idx != end; piter->idx += inc) { struct hd_struct *part; part = rcu_dereference(ptbl->part[piter->idx]); if (!part) continue; if (!part_nr_sects_read(part) && !(piter->flags & DISK_PITER_INCL_EMPTY) && !(piter->flags & DISK_PITER_INCL_EMPTY_PART0 && piter->idx == 0)) continue; get_device(part_to_dev(part)); piter->part = part; piter->idx += inc; break; } rcu_read_unlock(); return piter->part; }

Contributors

PersonTokensPropCommitsCommitProp
Tejun Heo20498.55%583.33%
Vivek Goyal31.45%116.67%
Total207100.00%6100.00%

EXPORT_SYMBOL_GPL(disk_part_iter_next); /** * disk_part_iter_exit - finish up partition iteration * @piter: iter of interest * * Called when iteration is over. Cleans up @piter. * * CONTEXT: * Don't care. */
void disk_part_iter_exit(struct disk_part_iter *piter) { disk_put_part(piter->part); piter->part = NULL; }

Contributors

PersonTokensPropCommitsCommitProp
Tejun Heo23100.00%1100.00%
Total23100.00%1100.00%

EXPORT_SYMBOL_GPL(disk_part_iter_exit);
static inline int sector_in_part(struct hd_struct *part, sector_t sector) { return part->start_sect <= sector && sector < part->start_sect + part_nr_sects_read(part); }

Contributors

PersonTokensPropCommitsCommitProp
Jens Axboe3090.91%150.00%
Vivek Goyal39.09%150.00%
Total33100.00%2100.00%

/** * disk_map_sector_rcu - map sector to partition * @disk: gendisk of interest * @sector: sector to map * * Find out which partition @sector maps to on @disk. This is * primarily used for stats accounting. * * CONTEXT: * RCU read locked. The returned partition pointer is valid only * while preemption is disabled. * * RETURNS: * Found partition on success, part0 is returned if no partition matches */
struct hd_struct *disk_map_sector_rcu(struct gendisk *disk, sector_t sector) { struct disk_part_tbl *ptbl; struct hd_struct *part; int i; ptbl = rcu_dereference(disk->part_tbl); part = rcu_dereference(ptbl->last_lookup); if (part && sector_in_part(part, sector)) return part; for (i = 1; i < ptbl->len; i++) { part = rcu_dereference(ptbl->part[i]); if (part && sector_in_part(part, sector)) { rcu_assign_pointer(ptbl->last_lookup, part); return part; } } return &disk->part0; }

Contributors

PersonTokensPropCommitsCommitProp
Tejun Heo7663.33%480.00%
Jens Axboe4436.67%120.00%
Total120100.00%5100.00%

EXPORT_SYMBOL_GPL(disk_map_sector_rcu); /* * Can be deleted altogether. Later. * */ #define BLKDEV_MAJOR_HASH_SIZE 255 static struct blk_major_name { struct blk_major_name *next; int major; char name[16]; } *major_names[BLKDEV_MAJOR_HASH_SIZE]; /* index in the above - for now: assume no multimajor ranges */
static inline int major_to_index(unsigned major) { return major % BLKDEV_MAJOR_HASH_SIZE; }

Contributors

PersonTokensPropCommitsCommitProp
Andrew Morton1386.67%133.33%
Yang Zhang16.67%133.33%
Joe Korty16.67%133.33%
Total15100.00%3100.00%

#ifdef CONFIG_PROC_FS
void blkdev_show(struct seq_file *seqf, off_t offset) { struct blk_major_name *dp; mutex_lock(&block_class_lock); for (dp = major_names[major_to_index(offset)]; dp; dp = dp->next) if (dp->major == offset) seq_printf(seqf, "%3d %s\n", dp->major, dp->name); mutex_unlock(&block_class_lock); }

Contributors

PersonTokensPropCommitsCommitProp
Joe Korty2939.73%112.50%
Neil Horman1926.03%112.50%
Logan Gunthorpe1115.07%112.50%
Andrew Morton68.22%112.50%
Al Viro34.11%112.50%
Kay Sievers22.74%112.50%
Tejun Heo22.74%112.50%
Jes Sorensen11.37%112.50%
Total73100.00%8100.00%

#endif /* CONFIG_PROC_FS */ /** * register_blkdev - register a new block device * * @major: the requested major device number [1..255]. If @major = 0, try to * allocate any unused major number. * @name: the name of the new block device as a zero terminated string * * The @name must be unique within the system. * * The return value depends on the @major input parameter: * * - if a major device number was requested in range [1..255] then the * function returns zero on success, or a negative error code * - if any unused major number was requested with @major = 0 parameter * then the return value is the allocated major number in range * [1..255] or a negative error code otherwise */
int register_blkdev(unsigned int major, const char *name) { struct blk_major_name **n, *p; int index, ret = 0; mutex_lock(&block_class_lock); /* temporary */ if (major == 0) { for (index = ARRAY_SIZE(major_names)-1; index > 0; index--) { if (major_names[index] == NULL) break; } if (index == 0) { printk("register_blkdev: failed to get major for %s\n", name); ret = -EBUSY; goto out; } major = index; ret = major; } if (major >= BLKDEV_MAJOR_MAX) { pr_err("register_blkdev: major requested (%d) is greater than the maximum (%d) for %s\n", major, BLKDEV_MAJOR_MAX, name); ret = -EINVAL; goto out; } p = kmalloc(sizeof(struct blk_major_name), GFP_KERNEL); if (p == NULL) { ret = -ENOMEM; goto out; } p->major = major; strlcpy(p->name, name, sizeof(p->name)); p->next = NULL; index = major_to_index(major); for (n = &major_names[index]; *n; n = &(*n)->next) { if ((*n)->major == major) break; } if (!*n) *n = p; else ret = -EBUSY; if (ret < 0) { printk("register_blkdev: cannot get major %d for %s\n", major, name); kfree(p); } out: mutex_unlock(&block_class_lock); return ret; }

Contributors

PersonTokensPropCommitsCommitProp
Andrew Morton25188.38%337.50%
Logan Gunthorpe279.51%112.50%
Jes Sorensen20.70%112.50%
Kay Sievers20.70%112.50%
Benjamin Collins10.35%112.50%
Mika Kukkonen10.35%112.50%
Total284100.00%8100.00%

EXPORT_SYMBOL(register_blkdev);
void unregister_blkdev(unsigned int major, const char *name) { struct blk_major_name **n; struct blk_major_name *p = NULL; int index = major_to_index(major); mutex_lock(&block_class_lock); for (n = &major_names[index]; *n; n = &(*n)->next) if ((*n)->major == major) break; if (!*n || strcmp((*n)->name, name)) { WARN_ON(1); } else { p = *n; *n = p->next; } mutex_unlock(&block_class_lock); kfree(p); }

Contributors

PersonTokensPropCommitsCommitProp
Andrew Morton11086.61%228.57%
Akinobu Mita86.30%228.57%
Christoph Hellwig53.94%114.29%
Kay Sievers21.57%114.29%
Jes Sorensen21.57%114.29%
Total127100.00%7100.00%

EXPORT_SYMBOL(unregister_blkdev); static struct kobj_map *bdev_map; /** * blk_mangle_minor - scatter minor numbers apart * @minor: minor number to mangle * * Scatter consecutively allocated @minor number apart if MANGLE_DEVT * is enabled. Mangling twice gives the original value. * * RETURNS: * Mangled value. * * CONTEXT: * Don't care. */
static int blk_mangle_minor(int minor) { #ifdef CONFIG_DEBUG_BLOCK_EXT_DEVT int i; for (i = 0; i < MINORBITS / 2; i++) { int low = minor & (1 << i); int high = minor & (1 << (MINORBITS - 1 - i)); int distance = MINORBITS - 1 - 2 * i; minor ^= low | high; /* clear both bits */ low <<= distance; /* swap the positions */ high >>= distance; minor |= low | high; /* and set */ } #endif return minor; }

Contributors

PersonTokensPropCommitsCommitProp
Tejun Heo99100.00%1100.00%
Total99100.00%1100.00%

/** * blk_alloc_devt - allocate a dev_t for a partition * @part: partition to allocate dev_t for * @devt: out parameter for resulting dev_t * * Allocate a dev_t for block device. * * RETURNS: * 0 on success, allocated dev_t is returned in *@devt. -errno on * failure. * * CONTEXT: * Might sleep. */
int blk_alloc_devt(struct hd_struct *part, dev_t *devt) { struct gendisk *disk = part_to_disk(part); int idx; /* in consecutive minor range? */ if (part->partno < disk->minors) { *devt = MKDEV(disk->major, disk->first_minor + part->partno); return 0; } /* allocate ext devt */ idr_preload(GFP_KERNEL); spin_lock_bh(&ext_devt_lock); idx = idr_alloc(&ext_devt_idr, part, 0, NR_EXT_DEVT, GFP_NOWAIT); spin_unlock_bh(&ext_devt_lock); idr_preload_end(); if (idx < 0) return idx == -ENOSPC ? -EBUSY : idx; *devt = MKDEV(BLOCK_EXT_MAJOR, blk_mangle_minor(idx)); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Tejun Heo11083.97%457.14%
Keith Busch118.40%114.29%
Tomas Henzl86.11%114.29%
Dan J Williams21.53%114.29%
Total131100.00%7100.00%

/** * blk_free_devt - free a dev_t * @devt: dev_t to free * * Free @devt which was allocated using blk_alloc_devt(). * * CONTEXT: * Might sleep. */
void blk_free_devt(dev_t devt) { if (devt == MKDEV(0, 0)) return; if (MAJOR(devt) == BLOCK_EXT_MAJOR) { spin_lock_bh(&ext_devt_lock); idr_remove(&ext_devt_idr, blk_mangle_minor(MINOR(devt))); spin_unlock_bh(&ext_devt_lock); } }

Contributors

PersonTokensPropCommitsCommitProp
Tejun Heo5392.98%250.00%
Dan J Williams23.51%125.00%
Keith Busch23.51%125.00%
Total57100.00%4100.00%


static char *bdevt_str(dev_t devt, char *buf) { if (MAJOR(devt) <= 0xff && MINOR(devt) <= 0xff) { char tbuf[BDEVT_SIZE]; snprintf(tbuf, BDEVT_SIZE, "%02x%02x", MAJOR(devt), MINOR(devt)); snprintf(buf, BDEVT_SIZE, "%-9s", tbuf); } else snprintf(buf, BDEVT_SIZE, "%03x:%05x", MAJOR(devt), MINOR(devt)); return buf; }

Contributors

PersonTokensPropCommitsCommitProp
Tejun Heo91100.00%1100.00%
Total91100.00%1100.00%

/* * Register device numbers dev..(dev+range-1) * range must be nonzero * The hash chain is sorted on range, so that subranges can override. */ void blk_register_region(dev_t devt, unsigned long range, struct module *module, struct kobject *(*probe)(dev_t, int *, void *), int (*lock)(dev_t, void *), void *data) { kobj_map(bdev_map, devt, range, module, probe, lock, data); } EXPORT_SYMBOL(blk_register_region);
void blk_unregister_region(dev_t devt, unsigned long range) { kobj_unmap(bdev_map, devt, range); }

Contributors

PersonTokensPropCommitsCommitProp
Al Viro1990.48%266.67%
Kay Sievers29.52%133.33%
Total21100.00%3100.00%

EXPORT_SYMBOL(blk_unregister_region);
static struct kobject *exact_match(dev_t devt, int *partno, void *data) { struct gendisk *p = data; return &disk_to_dev(p)->kobj; }

Contributors

PersonTokensPropCommitsCommitProp
Al Viro3085.71%350.00%
Tejun Heo411.43%233.33%
Kay Sievers12.86%116.67%
Total35100.00%6100.00%


static int exact_lock(dev_t devt, void *data) { struct gendisk *p = data; if (!get_disk(p)) return -1; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
Al Viro3497.14%266.67%
Kay Sievers12.86%133.33%
Total35100.00%3100.00%


static void register_disk(struct device *parent, struct gendisk *disk) { struct device *ddev = disk_to_dev(disk); struct block_device *bdev; struct disk_part_iter piter; struct hd_struct *part; int err; ddev->parent = parent; dev_set_name(ddev, "%s", disk->disk_name); /* delay uevents, until we scanned partition table */ dev_set_uevent_suppress(ddev, 1); if (device_add(ddev)) return; if (!sysfs_deprecated) { err = sysfs_create_link(block_depr, &ddev->kobj, kobject_name(&ddev->kobj)); if (err) { device_del(ddev); return; } } /* * avoid probable deadlock caused by allocating memory with * GFP_KERNEL in runtime_resume callback of its all ancestor * devices */ pm_runtime_set_memalloc_noio(ddev, true); disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj); disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); /* No minors to use for partitions */ if (!disk_part_scan_enabled(disk)) goto exit; /* No such device (e.g., media were just removed) */ if (!get_capacity(disk)) goto exit; bdev = bdget_disk(disk, 0); if (!bdev) goto exit; bdev->bd_invalidated = 1; err = blkdev_get(bdev, FMODE_READ, NULL); if (err < 0) goto exit; blkdev_put(bdev, FMODE_READ); exit: /* announce disk after possible partitions are created */ dev_set_uevent_suppress(ddev, 0); kobject_uevent(&ddev->kobj, KOBJ_ADD); /* announce possible partitions */ disk_part_iter_init(&piter, disk, 0); while ((part = disk_part_iter_next(&piter))) kobject_uevent(&part_to_dev(part)->kobj, KOBJ_ADD); disk_part_iter_exit(&piter); }

Contributors

PersonTokensPropCommitsCommitProp
Tejun Heo22176.47%526.32%
Al Viro206.92%526.32%
Peter Zijlstra93.11%15.26%
Linus Torvalds93.11%210.53%
Ming Lei82.77%15.26%
Dan J Williams62.08%15.26%
Jan Kara62.08%15.26%
Greg Kroah-Hartman51.73%15.26%
Jens Axboe31.04%15.26%
Kees Cook20.69%15.26%
Total289100.00%19100.00%

/** * device_add_disk - add partitioning information to kernel list * @parent: parent device for the disk * @disk: per-device partitioning information * * This function registers the partitioning information in @disk * with the kernel. * * FIXME: error handling */
void device_add_disk(struct device *parent, struct gendisk *disk) { struct backing_dev_info *bdi; dev_t devt; int retval; /* minors == 0 indicates to use ext devt from part0 and should * be accompanied with EXT_DEVT flag. Make sure all * parameters make sense. */ WARN_ON(disk->minors && !(disk->major || disk->first_minor)); WARN_ON(!disk->minors && !(disk->flags & GENHD_FL_EXT_DEVT)); disk->flags |= GENHD_FL_UP; retval = blk_alloc_devt(&disk->part0, &devt); if (retval) { WARN_ON(1); return; } disk_to_dev(disk)->devt = devt; /* ->major and ->first_minor aren't supposed to be * dereferenced from here on, but set them just in case. */ disk->major = MAJOR(devt); disk->first_minor = MINOR(devt); disk_alloc_events(disk); /* Register BDI before referencing it from bdev */ bdi = disk->queue->backing_dev_info; bdi_register_owner(bdi, disk_to_dev(disk)); blk_register_region(disk_devt(disk), disk->minors, NULL, exact_match, exact_lock, disk); register_disk(parent, disk); blk_register_queue(disk); /* * Take an extra ref on queue which will be put on disk_release() * so that it sticks around as long as @disk is there. */ WARN_ON_ONCE(!blk_get_queue(disk->queue)); retval = sysfs_create_link(&disk_to_dev(disk)->kobj, &bdi->dev->kobj, "bdi"); WARN_ON(retval); disk_add_events(disk); blk_integrity_add(disk); }

Contributors

PersonTokensPropCommitsCommitProp
Tejun Heo9843.36%628.57%
Al Viro3615.93%419.05%
Peter Zijlstra3515.49%14.76%
Linus Torvalds114.87%29.52%
Dan J Williams104.42%29.52%
Greg Kroah-Hartman104.42%14.76%
Jens Axboe83.54%14.76%
Jan Kara73.10%14.76%
Stanislaw Gruszka52.21%14.76%
Martin K. Petersen52.21%14.76%
Andrew Morton10.44%14.76%
Total226100.00%21100.00%

EXPORT_SYMBOL(device_add_disk);
void del_gendisk(struct gendisk *disk) { struct disk_part_iter piter; struct hd_struct *part; blk_integrity_del(disk); disk_del_events(disk); /* invalidate stuff */ disk_part_iter_init(&piter, disk, DISK_PITER_INCL_EMPTY | DISK_PITER_REVERSE); while ((part = disk_part_iter_next(&piter))) { invalidate_partition(disk, part->partno); bdev_unhash_inode(part_devt(part)); delete_partition(disk, part->partno); } disk_part_iter_exit(&piter); invalidate_partition(disk, 0); bdev_unhash_inode(disk_devt(disk)); set_capacity(disk, 0); disk->flags &= ~GENHD_FL_UP; sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi"); if (disk->queue) { /* * Unregister bdi before releasing device numbers (as they can * get reused and we'd get clashes in sysfs). */ bdi_unregister(disk->queue->backing_dev_info); blk_unregister_queue(disk); } else { WARN_ON(1); } blk_unregister_region(disk_devt(disk), disk->minors); part_stat_set_all(&disk->part0, 0); disk->part0.stamp = 0; kobject_put(disk->part0.holder_dir); kobject_put(disk->slave_dir); if (!sysfs_deprecated) sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk))); pm_runtime_set_memalloc_noio(disk_to_dev(disk), false); device_del(disk_to_dev(disk)); }

Contributors

PersonTokensPropCommitsCommitProp
Tejun Heo14559.67%526.32%
Jan Kara4719.34%526.32%
Linus Torvalds124.94%210.53%
Ming Lei104.12%15.26%
Peter Zijlstra104.12%15.26%
Al Viro93.70%210.53%
Martin K. Petersen52.06%15.26%
Jens Axboe41.65%15.26%
Andrew Morton10.41%15.26%
Total243100.00%19100.00%

EXPORT_SYMBOL(del_gendisk); /* sysfs access to bad-blocks list. */
static ssize_t disk_badblocks_show(struct device *dev, struct device_attribute *attr, char *page) { struct gendisk *disk = dev_to_disk(dev); if (!disk->bb) return sprintf(page, "\n"); return badblocks_show(disk->bb, page, 0); }

Contributors

PersonTokensPropCommitsCommitProp
Vishal Verma57100.00%1100.00%
Total57100.00%1100.00%


static ssize_t disk_badblocks_store(struct device *dev, struct device_attribute *attr, const char *page, size_t len) { struct gendisk *disk = dev_to_disk(dev); if (!disk->bb) return -ENXIO; return badblocks_store(disk->bb, page, len, 0); }

Contributors

PersonTokensPropCommitsCommitProp
Vishal Verma59100.00%1100.00%
Total59100.00%1100.00%

/** * get_gendisk - get partitioning information for a given device * @devt: device to get partitioning information for * @partno: returned partition index * * This function gets the structure containing partitioning * information for the given device @devt. */
struct gendisk *get_gendisk(dev_t devt, int *partno) { struct gendisk *disk = NULL; if (MAJOR(devt) !=