summaryrefslogtreecommitdiff
path: root/block/genhd.c
diff options
context:
space:
mode:
authorAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-03-25 03:53:42 -0300
committerAndré Fabian Silva Delgado <emulatorman@parabola.nu>2016-03-25 03:53:42 -0300
commit03dd4cb26d967f9588437b0fc9cc0e8353322bb7 (patch)
treefa581f6dc1c0596391690d1f67eceef3af8246dc /block/genhd.c
parentd4e493caf788ef44982e131ff9c786546904d934 (diff)
Linux-libre 4.5-gnu
Diffstat (limited to 'block/genhd.c')
-rw-r--r--block/genhd.c113
1 files changed, 30 insertions, 83 deletions
diff --git a/block/genhd.c b/block/genhd.c
index c06731166..9f42526b4 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -18,10 +18,9 @@
#include <linux/kobj_map.h>
#include <linux/mutex.h>
#include <linux/idr.h>
-#include <linux/ctype.h>
-#include <linux/fs_uuid.h>
#include <linux/log2.h>
#include <linux/pm_runtime.h>
+#include <linux/badblocks.h>
#include "blk.h"
@@ -666,7 +665,6 @@ void del_gendisk(struct gendisk *disk)
kobject_put(disk->part0.holder_dir);
kobject_put(disk->slave_dir);
- disk->driverfs_dev = NULL;
if (!sysfs_deprecated)
sysfs_remove_link(block_depr, dev_name(disk_to_dev(disk)));
pm_runtime_set_memalloc_noio(disk_to_dev(disk), false);
@@ -674,6 +672,31 @@ void del_gendisk(struct gendisk *disk)
}
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);
+}
+
+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);
+}
+
/**
* get_gendisk - get partitioning information for a given device
* @devt: device to get partitioning information for
@@ -992,6 +1015,8 @@ static DEVICE_ATTR(discard_alignment, S_IRUGO, disk_discard_alignment_show,
static DEVICE_ATTR(capability, S_IRUGO, disk_capability_show, NULL);
static DEVICE_ATTR(stat, S_IRUGO, part_stat_show, NULL);
static DEVICE_ATTR(inflight, S_IRUGO, part_inflight_show, NULL);
+static DEVICE_ATTR(badblocks, S_IRUGO | S_IWUSR, disk_badblocks_show,
+ disk_badblocks_store);
#ifdef CONFIG_FAIL_MAKE_REQUEST
static struct device_attribute dev_attr_fail =
__ATTR(make-it-fail, S_IRUGO|S_IWUSR, part_fail_show, part_fail_store);
@@ -1013,6 +1038,7 @@ static struct attribute *disk_attrs[] = {
&dev_attr_capability.attr,
&dev_attr_stat.attr,
&dev_attr_inflight.attr,
+ &dev_attr_badblocks.attr,
#ifdef CONFIG_FAIL_MAKE_REQUEST
&dev_attr_fail.attr,
#endif
@@ -1391,85 +1417,6 @@ int invalidate_partition(struct gendisk *disk, int partno)
EXPORT_SYMBOL(invalidate_partition);
-dev_t blk_lookup_fs_info(struct fs_info *seek)
-{
- dev_t devt = MKDEV(0, 0);
- struct class_dev_iter iter;
- struct device *dev;
- int best_score = 0;
-
- class_dev_iter_init(&iter, &block_class, NULL, &disk_type);
- while (best_score < 3 && (dev = class_dev_iter_next(&iter))) {
- struct gendisk *disk = dev_to_disk(dev);
- struct disk_part_iter piter;
- struct hd_struct *part;
-
- disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
-
- while (best_score < 3 && (part = disk_part_iter_next(&piter))) {
- int score = part_matches_fs_info(part, seek);
- if (score > best_score) {
- devt = part_devt(part);
- best_score = score;
- }
- }
- disk_part_iter_exit(&piter);
- }
- class_dev_iter_exit(&iter);
- return devt;
-}
-
-/* Caller uses NULL, key to start. For each match found, we return a bdev on
- * which we have done blkdev_get, and we do the blkdev_put on block devices
- * that are passed to us. When no more matches are found, we return NULL.
- */
-struct block_device *next_bdev_of_type(struct block_device *last,
- const char *key)
-{
- dev_t devt = MKDEV(0, 0);
- struct class_dev_iter iter;
- struct device *dev;
- struct block_device *next = NULL, *bdev;
- int got_last = 0;
-
- if (!key)
- goto out;
-
- class_dev_iter_init(&iter, &block_class, NULL, &disk_type);
- while (!devt && (dev = class_dev_iter_next(&iter))) {
- struct gendisk *disk = dev_to_disk(dev);
- struct disk_part_iter piter;
- struct hd_struct *part;
-
- disk_part_iter_init(&piter, disk, DISK_PITER_INCL_PART0);
-
- while ((part = disk_part_iter_next(&piter))) {
- bdev = bdget(part_devt(part));
- if (last && !got_last) {
- if (last == bdev)
- got_last = 1;
- continue;
- }
-
- if (blkdev_get(bdev, FMODE_READ, 0))
- continue;
-
- if (bdev_matches_key(bdev, key)) {
- next = bdev;
- break;
- }
-
- blkdev_put(bdev, FMODE_READ);
- }
- disk_part_iter_exit(&piter);
- }
- class_dev_iter_exit(&iter);
-out:
- if (last)
- blkdev_put(last, FMODE_READ);
- return next;
-}
-
/*
* Disk events - monitor disk events like media change and eject request.
*/
@@ -1502,7 +1449,7 @@ static DEFINE_MUTEX(disk_events_mutex);
static LIST_HEAD(disk_events);
/* disable in-kernel polling by default */
-static unsigned long disk_events_dfl_poll_msecs = 0;
+static unsigned long disk_events_dfl_poll_msecs;
static unsigned long disk_events_poll_jiffies(struct gendisk *disk)
{