Commit 15bd1cfb authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.kernel.dk/linux-block

* 'for-linus' of git://git.kernel.dk/linux-block:
  block: add missed trace_block_plug
  paride: fix potential information leak in pg_read()
  bio: change some signed vars to unsigned
  block: avoid unnecessary plug list flush
  cciss: auto engage SCSI mid layer at driver load time
  loop: cleanup set_status interface
  include/linux/bio.h: use a static inline function for bio_integrity_clone()
  loop: prevent information leak after failed read
  block: Always check length of all iov entries in blk_rq_map_user_iov()
  The Windows driver .inf disables ASPM on all cciss devices. Do the same.
  backing-dev: ensure wakeup_timer is deleted
  block: Revert "[SCSI] genhd: add a new attribute "alias" in gendisk"
parents 9545eb61 019ceb7d
...@@ -206,16 +206,3 @@ Description: ...@@ -206,16 +206,3 @@ Description:
when a discarded area is read the discard_zeroes_data when a discarded area is read the discard_zeroes_data
parameter will be set to one. Otherwise it will be 0 and parameter will be set to one. Otherwise it will be 0 and
the result of reading a discarded area is undefined. the result of reading a discarded area is undefined.
What: /sys/block/<disk>/alias
Date: Aug 2011
Contact: Nao Nishijima <nao.nishijima.xt@hitachi.com>
Description:
A raw device name of a disk does not always point a same disk
each boot-up time. Therefore, users have to use persistent
device names, which udev creates when the kernel finds a disk,
instead of raw device name. However, kernel doesn't show those
persistent names on its messages (e.g. dmesg).
This file can store an alias of the disk and it would be
appeared in kernel messages if it is set. A disk can have an
alias which length is up to 255bytes. Users can use alphabets,
numbers, "-" and "_" in alias name. This file is writeonce.
...@@ -98,14 +98,12 @@ You must enable "SCSI tape drive support for Smart Array 5xxx" and ...@@ -98,14 +98,12 @@ You must enable "SCSI tape drive support for Smart Array 5xxx" and
"SCSI support" in your kernel configuration to be able to use SCSI "SCSI support" in your kernel configuration to be able to use SCSI
tape drives with your Smart Array 5xxx controller. tape drives with your Smart Array 5xxx controller.
Additionally, note that the driver will not engage the SCSI core at init Additionally, note that the driver will engage the SCSI core at init
time. The driver must be directed to dynamically engage the SCSI core via time if any tape drives or medium changers are detected. The driver may
the /proc filesystem entry which the "block" side of the driver creates as also be directed to dynamically engage the SCSI core via the /proc filesystem
/proc/driver/cciss/cciss* at runtime. This is because at driver init time, entry which the "block" side of the driver creates as
the SCSI core may not yet be initialized (because the driver is a block /proc/driver/cciss/cciss* at runtime. This is best done via a script.
driver) and attempting to register it with the SCSI core in such a case
would cause a hang. This is best done via an initialization script
(typically in /etc/init.d, but could vary depending on distribution).
For example: For example:
for x in /proc/driver/cciss/cciss[0-9]* for x in /proc/driver/cciss/cciss[0-9]*
......
...@@ -1379,15 +1379,19 @@ void blk_queue_bio(struct request_queue *q, struct bio *bio) ...@@ -1379,15 +1379,19 @@ void blk_queue_bio(struct request_queue *q, struct bio *bio)
*/ */
if (list_empty(&plug->list)) if (list_empty(&plug->list))
trace_block_plug(q); trace_block_plug(q);
else if (!plug->should_sort) { else {
struct request *__rq; if (!plug->should_sort) {
struct request *__rq;
__rq = list_entry_rq(plug->list.prev); __rq = list_entry_rq(plug->list.prev);
if (__rq->q != q) if (__rq->q != q)
plug->should_sort = 1; plug->should_sort = 1;
}
if (request_count >= BLK_MAX_REQUEST_COUNT) {
blk_flush_plug_list(plug, false);
trace_block_plug(q);
}
} }
if (request_count >= BLK_MAX_REQUEST_COUNT)
blk_flush_plug_list(plug, false);
list_add_tail(&req->queuelist, &plug->list); list_add_tail(&req->queuelist, &plug->list);
drive_stat_acct(req, 1); drive_stat_acct(req, 1);
} else { } else {
......
...@@ -204,10 +204,11 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq, ...@@ -204,10 +204,11 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
if (!iov[i].iov_len) if (!iov[i].iov_len)
return -EINVAL; return -EINVAL;
if (uaddr & queue_dma_alignment(q)) { /*
* Keep going so we check length of all segments
*/
if (uaddr & queue_dma_alignment(q))
unaligned = 1; unaligned = 1;
break;
}
} }
if (unaligned || (q->dma_pad_mask & len) || map_data) if (unaligned || (q->dma_pad_mask & len) || map_data)
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <linux/mutex.h> #include <linux/mutex.h>
#include <linux/idr.h> #include <linux/idr.h>
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/ctype.h>
#include "blk.h" #include "blk.h"
...@@ -916,74 +915,6 @@ static int __init genhd_device_init(void) ...@@ -916,74 +915,6 @@ static int __init genhd_device_init(void)
subsys_initcall(genhd_device_init); subsys_initcall(genhd_device_init);
static ssize_t alias_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gendisk *disk = dev_to_disk(dev);
ssize_t ret = 0;
if (disk->alias)
ret = snprintf(buf, ALIAS_LEN, "%s\n", disk->alias);
return ret;
}
static ssize_t alias_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct gendisk *disk = dev_to_disk(dev);
char *alias;
char *envp[] = { NULL, NULL };
unsigned char c;
int i;
ssize_t ret = count;
if (!count)
return -EINVAL;
if (count >= ALIAS_LEN) {
printk(KERN_ERR "alias: alias is too long\n");
return -EINVAL;
}
/* Validation check */
for (i = 0; i < count; i++) {
c = buf[i];
if (i == count - 1 && c == '\n')
break;
if (!isalnum(c) && c != '_' && c != '-') {
printk(KERN_ERR "alias: invalid alias\n");
return -EINVAL;
}
}
if (disk->alias) {
printk(KERN_INFO "alias: %s is already assigned (%s)\n",
disk->disk_name, disk->alias);
return -EINVAL;
}
alias = kasprintf(GFP_KERNEL, "%s", buf);
if (!alias)
return -ENOMEM;
if (alias[count - 1] == '\n')
alias[count - 1] = '\0';
envp[0] = kasprintf(GFP_KERNEL, "ALIAS=%s", alias);
if (!envp[0]) {
kfree(alias);
return -ENOMEM;
}
disk->alias = alias;
printk(KERN_INFO "alias: assigned %s to %s\n", alias, disk->disk_name);
kobject_uevent_env(&dev->kobj, KOBJ_ADD, envp);
kfree(envp[0]);
return ret;
}
static ssize_t disk_range_show(struct device *dev, static ssize_t disk_range_show(struct device *dev,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
{ {
...@@ -1043,7 +974,6 @@ static ssize_t disk_discard_alignment_show(struct device *dev, ...@@ -1043,7 +974,6 @@ static ssize_t disk_discard_alignment_show(struct device *dev,
return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue)); return sprintf(buf, "%d\n", queue_discard_alignment(disk->queue));
} }
static DEVICE_ATTR(alias, S_IRUGO|S_IWUSR, alias_show, alias_store);
static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL); static DEVICE_ATTR(range, S_IRUGO, disk_range_show, NULL);
static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL); static DEVICE_ATTR(ext_range, S_IRUGO, disk_ext_range_show, NULL);
static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL); static DEVICE_ATTR(removable, S_IRUGO, disk_removable_show, NULL);
...@@ -1066,7 +996,6 @@ static struct device_attribute dev_attr_fail_timeout = ...@@ -1066,7 +996,6 @@ static struct device_attribute dev_attr_fail_timeout =
#endif #endif
static struct attribute *disk_attrs[] = { static struct attribute *disk_attrs[] = {
&dev_attr_alias.attr,
&dev_attr_range.attr, &dev_attr_range.attr,
&dev_attr_ext_range.attr, &dev_attr_ext_range.attr,
&dev_attr_removable.attr, &dev_attr_removable.attr,
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/pci-aspm.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/delay.h> #include <linux/delay.h>
...@@ -4319,6 +4320,10 @@ static int __devinit cciss_pci_init(ctlr_info_t *h) ...@@ -4319,6 +4320,10 @@ static int __devinit cciss_pci_init(ctlr_info_t *h)
dev_warn(&h->pdev->dev, "controller appears to be disabled\n"); dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
return -ENODEV; return -ENODEV;
} }
pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
err = pci_enable_device(h->pdev); err = pci_enable_device(h->pdev);
if (err) { if (err) {
dev_warn(&h->pdev->dev, "Unable to Enable PCI device\n"); dev_warn(&h->pdev->dev, "Unable to Enable PCI device\n");
...@@ -5158,6 +5163,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev, ...@@ -5158,6 +5163,7 @@ static int __devinit cciss_init_one(struct pci_dev *pdev,
h->cciss_max_sectors = 8192; h->cciss_max_sectors = 8192;
rebuild_lun_table(h, 1, 0); rebuild_lun_table(h, 1, 0);
cciss_engage_scsi(h);
h->busy_initializing = 0; h->busy_initializing = 0;
return 1; return 1;
......
...@@ -1720,5 +1720,6 @@ static int cciss_eh_abort_handler(struct scsi_cmnd *scsicmd) ...@@ -1720,5 +1720,6 @@ static int cciss_eh_abort_handler(struct scsi_cmnd *scsicmd)
/* If no tape support, then these become defined out of existence */ /* If no tape support, then these become defined out of existence */
#define cciss_scsi_setup(cntl_num) #define cciss_scsi_setup(cntl_num)
#define cciss_engage_scsi(h)
#endif /* CONFIG_CISS_SCSI_TAPE */ #endif /* CONFIG_CISS_SCSI_TAPE */
...@@ -161,17 +161,19 @@ static struct loop_func_table *xfer_funcs[MAX_LO_CRYPT] = { ...@@ -161,17 +161,19 @@ static struct loop_func_table *xfer_funcs[MAX_LO_CRYPT] = {
&xor_funcs &xor_funcs
}; };
static loff_t get_loop_size(struct loop_device *lo, struct file *file) static loff_t get_size(loff_t offset, loff_t sizelimit, struct file *file)
{ {
loff_t size, offset, loopsize; loff_t size, loopsize;
/* Compute loopsize in bytes */ /* Compute loopsize in bytes */
size = i_size_read(file->f_mapping->host); size = i_size_read(file->f_mapping->host);
offset = lo->lo_offset;
loopsize = size - offset; loopsize = size - offset;
if (lo->lo_sizelimit > 0 && lo->lo_sizelimit < loopsize) /* offset is beyond i_size, wierd but possible */
loopsize = lo->lo_sizelimit; if (loopsize < 0)
return 0;
if (sizelimit > 0 && sizelimit < loopsize)
loopsize = sizelimit;
/* /*
* Unfortunately, if we want to do I/O on the device, * Unfortunately, if we want to do I/O on the device,
* the number of 512-byte sectors has to fit into a sector_t. * the number of 512-byte sectors has to fit into a sector_t.
...@@ -179,17 +181,25 @@ static loff_t get_loop_size(struct loop_device *lo, struct file *file) ...@@ -179,17 +181,25 @@ static loff_t get_loop_size(struct loop_device *lo, struct file *file)
return loopsize >> 9; return loopsize >> 9;
} }
static loff_t get_loop_size(struct loop_device *lo, struct file *file)
{
return get_size(lo->lo_offset, lo->lo_sizelimit, file);
}
static int static int
figure_loop_size(struct loop_device *lo) figure_loop_size(struct loop_device *lo, loff_t offset, loff_t sizelimit)
{ {
loff_t size = get_loop_size(lo, lo->lo_backing_file); loff_t size = get_size(offset, sizelimit, lo->lo_backing_file);
sector_t x = (sector_t)size; sector_t x = (sector_t)size;
if (unlikely((loff_t)x != size)) if (unlikely((loff_t)x != size))
return -EFBIG; return -EFBIG;
if (lo->lo_offset != offset)
lo->lo_offset = offset;
if (lo->lo_sizelimit != sizelimit)
lo->lo_sizelimit = sizelimit;
set_capacity(lo->lo_disk, x); set_capacity(lo->lo_disk, x);
return 0; return 0;
} }
static inline int static inline int
...@@ -372,7 +382,8 @@ do_lo_receive(struct loop_device *lo, ...@@ -372,7 +382,8 @@ do_lo_receive(struct loop_device *lo,
if (retval < 0) if (retval < 0)
return retval; return retval;
if (retval != bvec->bv_len)
return -EIO;
return 0; return 0;
} }
...@@ -1058,9 +1069,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info) ...@@ -1058,9 +1069,7 @@ loop_set_status(struct loop_device *lo, const struct loop_info64 *info)
if (lo->lo_offset != info->lo_offset || if (lo->lo_offset != info->lo_offset ||
lo->lo_sizelimit != info->lo_sizelimit) { lo->lo_sizelimit != info->lo_sizelimit) {
lo->lo_offset = info->lo_offset; if (figure_loop_size(lo, info->lo_offset, info->lo_sizelimit))
lo->lo_sizelimit = info->lo_sizelimit;
if (figure_loop_size(lo))
return -EFBIG; return -EFBIG;
} }
loop_config_discard(lo); loop_config_discard(lo);
...@@ -1246,7 +1255,7 @@ static int loop_set_capacity(struct loop_device *lo, struct block_device *bdev) ...@@ -1246,7 +1255,7 @@ static int loop_set_capacity(struct loop_device *lo, struct block_device *bdev)
err = -ENXIO; err = -ENXIO;
if (unlikely(lo->lo_state != Lo_bound)) if (unlikely(lo->lo_state != Lo_bound))
goto out; goto out;
err = figure_loop_size(lo); err = figure_loop_size(lo, lo->lo_offset, lo->lo_sizelimit);
if (unlikely(err)) if (unlikely(err))
goto out; goto out;
sec = get_capacity(lo->lo_disk); sec = get_capacity(lo->lo_disk);
...@@ -1284,13 +1293,19 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode, ...@@ -1284,13 +1293,19 @@ static int lo_ioctl(struct block_device *bdev, fmode_t mode,
goto out_unlocked; goto out_unlocked;
break; break;
case LOOP_SET_STATUS: case LOOP_SET_STATUS:
err = loop_set_status_old(lo, (struct loop_info __user *) arg); err = -EPERM;
if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))
err = loop_set_status_old(lo,
(struct loop_info __user *)arg);
break; break;
case LOOP_GET_STATUS: case LOOP_GET_STATUS:
err = loop_get_status_old(lo, (struct loop_info __user *) arg); err = loop_get_status_old(lo, (struct loop_info __user *) arg);
break; break;
case LOOP_SET_STATUS64: case LOOP_SET_STATUS64:
err = loop_set_status64(lo, (struct loop_info64 __user *) arg); err = -EPERM;
if ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))
err = loop_set_status64(lo,
(struct loop_info64 __user *) arg);
break; break;
case LOOP_GET_STATUS64: case LOOP_GET_STATUS64:
err = loop_get_status64(lo, (struct loop_info64 __user *) arg); err = loop_get_status64(lo, (struct loop_info64 __user *) arg);
......
...@@ -630,6 +630,7 @@ static ssize_t pg_read(struct file *filp, char __user *buf, size_t count, loff_t ...@@ -630,6 +630,7 @@ static ssize_t pg_read(struct file *filp, char __user *buf, size_t count, loff_t
if (dev->status & 0x10) if (dev->status & 0x10)
return -ETIME; return -ETIME;
memset(&hdr, 0, sizeof(hdr));
hdr.magic = PG_MAGIC; hdr.magic = PG_MAGIC;
hdr.dlen = dev->dlen; hdr.dlen = dev->dlen;
copy = 0; copy = 0;
......
...@@ -337,7 +337,7 @@ static void bio_fs_destructor(struct bio *bio) ...@@ -337,7 +337,7 @@ static void bio_fs_destructor(struct bio *bio)
* RETURNS: * RETURNS:
* Pointer to new bio on success, NULL on failure. * Pointer to new bio on success, NULL on failure.
*/ */
struct bio *bio_alloc(gfp_t gfp_mask, int nr_iovecs) struct bio *bio_alloc(gfp_t gfp_mask, unsigned int nr_iovecs)
{ {
struct bio *bio = bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set); struct bio *bio = bio_alloc_bioset(gfp_mask, nr_iovecs, fs_bio_set);
...@@ -365,7 +365,7 @@ static void bio_kmalloc_destructor(struct bio *bio) ...@@ -365,7 +365,7 @@ static void bio_kmalloc_destructor(struct bio *bio)
* %__GFP_WAIT, the allocation is guaranteed to succeed. * %__GFP_WAIT, the allocation is guaranteed to succeed.
* *
**/ **/
struct bio *bio_kmalloc(gfp_t gfp_mask, int nr_iovecs) struct bio *bio_kmalloc(gfp_t gfp_mask, unsigned int nr_iovecs)
{ {
struct bio *bio; struct bio *bio;
...@@ -696,7 +696,8 @@ static void bio_free_map_data(struct bio_map_data *bmd) ...@@ -696,7 +696,8 @@ static void bio_free_map_data(struct bio_map_data *bmd)
kfree(bmd); kfree(bmd);
} }
static struct bio_map_data *bio_alloc_map_data(int nr_segs, int iov_count, static struct bio_map_data *bio_alloc_map_data(int nr_segs,
unsigned int iov_count,
gfp_t gfp_mask) gfp_t gfp_mask)
{ {
struct bio_map_data *bmd; struct bio_map_data *bmd;
......
...@@ -211,8 +211,8 @@ extern void bio_pair_release(struct bio_pair *dbio); ...@@ -211,8 +211,8 @@ extern void bio_pair_release(struct bio_pair *dbio);
extern struct bio_set *bioset_create(unsigned int, unsigned int); extern struct bio_set *bioset_create(unsigned int, unsigned int);
extern void bioset_free(struct bio_set *); extern void bioset_free(struct bio_set *);
extern struct bio *bio_alloc(gfp_t, int); extern struct bio *bio_alloc(gfp_t, unsigned int);
extern struct bio *bio_kmalloc(gfp_t, int); extern struct bio *bio_kmalloc(gfp_t, unsigned int);
extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *); extern struct bio *bio_alloc_bioset(gfp_t, int, struct bio_set *);
extern void bio_put(struct bio *); extern void bio_put(struct bio *);
extern void bio_free(struct bio *, struct bio_set *); extern void bio_free(struct bio *, struct bio_set *);
...@@ -519,7 +519,11 @@ extern void bio_integrity_init(void); ...@@ -519,7 +519,11 @@ extern void bio_integrity_init(void);
#define bioset_integrity_create(a, b) (0) #define bioset_integrity_create(a, b) (0)
#define bio_integrity_prep(a) (0) #define bio_integrity_prep(a) (0)
#define bio_integrity_enabled(a) (0) #define bio_integrity_enabled(a) (0)
#define bio_integrity_clone(a, b, c, d) (0) static inline int bio_integrity_clone(struct bio *bio, struct bio *bio_src,
gfp_t gfp_mask, struct bio_set *bs)
{
return 0;
}
#define bioset_integrity_free(a) do { } while (0) #define bioset_integrity_free(a) do { } while (0)
#define bio_integrity_free(a, b) do { } while (0) #define bio_integrity_free(a, b) do { } while (0)
#define bio_integrity_endio(a, b) do { } while (0) #define bio_integrity_endio(a, b) do { } while (0)
......
...@@ -21,8 +21,6 @@ ...@@ -21,8 +21,6 @@
#define dev_to_part(device) container_of((device), struct hd_struct, __dev) #define dev_to_part(device) container_of((device), struct hd_struct, __dev)
#define disk_to_dev(disk) (&(disk)->part0.__dev) #define disk_to_dev(disk) (&(disk)->part0.__dev)
#define part_to_dev(part) (&((part)->__dev)) #define part_to_dev(part) (&((part)->__dev))
#define alias_name(disk) ((disk)->alias ? (disk)->alias : \
(disk)->disk_name)
extern struct device_type part_type; extern struct device_type part_type;
extern struct kobject *block_depr; extern struct kobject *block_depr;
...@@ -60,7 +58,6 @@ enum { ...@@ -60,7 +58,6 @@ enum {
#define DISK_MAX_PARTS 256 #define DISK_MAX_PARTS 256
#define DISK_NAME_LEN 32 #define DISK_NAME_LEN 32
#define ALIAS_LEN 256
#include <linux/major.h> #include <linux/major.h>
#include <linux/device.h> #include <linux/device.h>
...@@ -166,7 +163,6 @@ struct gendisk { ...@@ -166,7 +163,6 @@ struct gendisk {
* disks that can't be partitioned. */ * disks that can't be partitioned. */
char disk_name[DISK_NAME_LEN]; /* name of major driver */ char disk_name[DISK_NAME_LEN]; /* name of major driver */
char *alias; /* alias name of disk */
char *(*devnode)(struct gendisk *gd, mode_t *mode); char *(*devnode)(struct gendisk *gd, mode_t *mode);
unsigned int events; /* supported events */ unsigned int events; /* supported events */
......
...@@ -724,6 +724,14 @@ void bdi_destroy(struct backing_dev_info *bdi) ...@@ -724,6 +724,14 @@ void bdi_destroy(struct backing_dev_info *bdi)
bdi_unregister(bdi); bdi_unregister(bdi);
/*
* If bdi_unregister() had already been called earlier, the
* wakeup_timer could still be armed because bdi_prune_sb()
* can race with the bdi_wakeup_thread_delayed() calls from
* __mark_inode_dirty().
*/
del_timer_sync(&bdi->wb.wakeup_timer);
for (i = 0; i < NR_BDI_STAT_ITEMS; i++) for (i = 0; i < NR_BDI_STAT_ITEMS; i++)
percpu_counter_destroy(&bdi->bdi_stat[i]); percpu_counter_destroy(&bdi->bdi_stat[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment