cregit-Linux how code gets into the kernel

Release 4.10 drivers/s390/block/dasd_genhd.c

/*
 * Author(s)......: Holger Smolinski <Holger.Smolinski@de.ibm.com>
 *                  Horst Hummel <Horst.Hummel@de.ibm.com>
 *                  Carsten Otte <Cotte@de.ibm.com>
 *                  Martin Schwidefsky <schwidefsky@de.ibm.com>
 * Bugreports.to..: <Linux390@de.ibm.com>
 * Copyright IBM Corp. 1999, 2001
 *
 * gendisk related functions for the dasd driver.
 *
 */


#define KMSG_COMPONENT "dasd"

#include <linux/interrupt.h>
#include <linux/fs.h>
#include <linux/blkpg.h>

#include <linux/uaccess.h>

/* This is ugly... */

#define PRINTK_HEADER "dasd_gendisk:"

#include "dasd_int.h"

/*
 * Allocate and register gendisk structure for device.
 */

int dasd_gendisk_alloc(struct dasd_block *block) { struct gendisk *gdp; struct dasd_device *base; int len; /* Make sure the minor for this device exists. */ base = block->base; if (base->devindex >= DASD_PER_MAJOR) return -EBUSY; gdp = alloc_disk(1 << DASD_PARTN_BITS); if (!gdp) return -ENOMEM; /* Initialize gendisk structure. */ gdp->major = DASD_MAJOR; gdp->first_minor = base->devindex << DASD_PARTN_BITS; gdp->fops = &dasd_device_operations; /* * Set device name. * dasda - dasdz : 26 devices * dasdaa - dasdzz : 676 devices, added up = 702 * dasdaaa - dasdzzz : 17576 devices, added up = 18278 * dasdaaaa - dasdzzzz : 456976 devices, added up = 475252 */ len = sprintf(gdp->disk_name, "dasd"); if (base->devindex > 25) { if (base->devindex > 701) { if (base->devindex > 18277) len += sprintf(gdp->disk_name + len, "%c", 'a'+(((base->devindex-18278) /17576)%26)); len += sprintf(gdp->disk_name + len, "%c", 'a'+(((base->devindex-702)/676)%26)); } len += sprintf(gdp->disk_name + len, "%c", 'a'+(((base->devindex-26)/26)%26)); } len += sprintf(gdp->disk_name + len, "%c", 'a'+(base->devindex%26)); if (base->features & DASD_FEATURE_READONLY || test_bit(DASD_FLAG_DEVICE_RO, &base->flags)) set_disk_ro(gdp, 1); dasd_add_link_to_gendisk(gdp, base); gdp->queue = block->request_queue; block->gdp = gdp; set_capacity(block->gdp, 0); device_add_disk(&base->cdev->dev, block->gdp); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton14145.19%17.69%
martin schwidefskymartin schwidefsky10934.94%538.46%
stefan weinhuberstefan weinhuber4313.78%323.08%
dan williamsdan williams82.56%17.69%
al viroal viro72.24%215.38%
horst hummelhorst hummel41.28%17.69%
Total312100.00%13100.00%

/* * Unregister and free gendisk structure for device. */
void dasd_gendisk_free(struct dasd_block *block) { if (block->gdp) { del_gendisk(block->gdp); block->gdp->private_data = NULL; put_disk(block->gdp); block->gdp = NULL; } }

Contributors

PersonTokensPropCommitsCommitProp
martin schwidefskymartin schwidefsky2656.52%450.00%
stefan weinhuberstefan weinhuber817.39%112.50%
horst hummelhorst hummel715.22%112.50%
stefan haberlandstefan haberland48.70%112.50%
heiko carstensheiko carstens12.17%112.50%
Total46100.00%8100.00%

/* * Trigger a partition detection. */
int dasd_scan_partitions(struct dasd_block *block) { struct block_device *bdev; int rc; bdev = bdget_disk(block->gdp, 0); if (!bdev) { DBF_DEV_EVENT(DBF_ERR, block->base, "%s", "scan partitions error, bdget returned NULL"); return -ENODEV; } rc = blkdev_get(bdev, FMODE_READ, NULL); if (rc < 0) { DBF_DEV_EVENT(DBF_ERR, block->base, "scan partitions error, blkdev_get returned %d", rc); return -ENODEV; } rc = blkdev_reread_part(bdev); if (rc) DBF_DEV_EVENT(DBF_ERR, block->base, "scan partitions error, rc %d", rc); /* * Since the matching blkdev_put call to the blkdev_get in * this function is not called before dasd_destroy_partitions * the offline open_count limit needs to be increased from * 0 to 1. This is done by setting device->bdev (see * dasd_generic_set_offline). As long as the partition * detection is running no offline should be allowed. That * is why the assignment to device->bdev is done AFTER * the BLKRRPART ioctl. */ block->bdev = bdev; return 0; }

Contributors

PersonTokensPropCommitsCommitProp
stefan haberlandstefan haberland6149.59%18.33%
martin schwidefskymartin schwidefsky3024.39%325.00%
andrew mortonandrew morton1310.57%18.33%
al viroal viro97.32%325.00%
stefan weinhuberstefan weinhuber54.07%18.33%
tejun heotejun heo21.63%18.33%
jarod wilsonjarod wilson21.63%18.33%
ming leiming lei10.81%18.33%
Total123100.00%12100.00%

/* * Remove all inodes in the system for a device, delete the * partitions and make device unusable by setting its size to zero. */
void dasd_destroy_partitions(struct dasd_block *block) { /* The two structs have 168/176 byte on 31/64 bit. */ struct blkpg_partition bpart; struct blkpg_ioctl_arg barg; struct block_device *bdev; /* * Get the bdev pointer from the device structure and clear * device->bdev to lower the offline open_count limit again. */ bdev = block->bdev; block->bdev = NULL; /* * See fs/partition/check.c:delete_partition * Can't call delete_partitions directly. Use ioctl. * The ioctl also does locking and invalidation. */ memset(&bpart, 0, sizeof(struct blkpg_partition)); memset(&barg, 0, sizeof(struct blkpg_ioctl_arg)); barg.data = (void __force __user *) &bpart; barg.op = BLKPG_DEL_PARTITION; for (bpart.pno = block->gdp->minors - 1; bpart.pno > 0; bpart.pno--) ioctl_by_bdev(bdev, BLKPG, (unsigned long) &barg); invalidate_partition(block->gdp, 0); /* Matching blkdev_put to the blkdev_get in dasd_scan_partitions. */ blkdev_put(bdev, FMODE_READ); set_capacity(block->gdp, 0); }

Contributors

PersonTokensPropCommitsCommitProp
andrew mortonandrew morton7852.00%19.09%
martin schwidefskymartin schwidefsky4832.00%436.36%
stefan weinhuberstefan weinhuber85.33%19.09%
heiko carstensheiko carstens74.67%218.18%
al viroal viro53.33%218.18%
joe kortyjoe korty42.67%19.09%
Total150100.00%11100.00%


int dasd_gendisk_init(void) { int rc; /* Register to static dasd major 94 */ rc = register_blkdev(DASD_MAJOR, "dasd"); if (rc != 0) { pr_warn("Registering the device driver with major number %d failed\n", DASD_MAJOR); return rc; } return 0; }

Contributors

PersonTokensPropCommitsCommitProp
martin schwidefskymartin schwidefsky3892.68%360.00%
joe perchesjoe perches24.88%120.00%
stefan weinhuberstefan weinhuber12.44%120.00%
Total41100.00%5100.00%


void dasd_gendisk_exit(void) { unregister_blkdev(DASD_MAJOR, "dasd"); }

Contributors

PersonTokensPropCommitsCommitProp
martin schwidefskymartin schwidefsky1392.86%266.67%
stefan weinhuberstefan weinhuber17.14%133.33%
Total14100.00%3100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
martin schwidefskymartin schwidefsky28740.14%720.59%
andrew mortonandrew morton23232.45%25.88%
stefan haberlandstefan haberland699.65%38.82%
stefan weinhuberstefan weinhuber669.23%38.82%
al viroal viro212.94%720.59%
horst hummelhorst hummel111.54%25.88%
heiko carstensheiko carstens91.26%38.82%
dan williamsdan williams81.12%12.94%
joe kortyjoe korty40.56%12.94%
tejun heotejun heo20.28%12.94%
joe perchesjoe perches20.28%12.94%
jarod wilsonjarod wilson20.28%12.94%
ming leiming lei10.14%12.94%
linus torvaldslinus torvalds10.14%12.94%
Total715100.00%34100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.