diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-19 13:12:17 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-05-19 13:12:17 -0400 |
commit | 14e931a264498fbd4baef07ee0644e347252393b (patch) | |
tree | c202cd976f478fed3d7d786521ab3e32abdc0f9e | |
parent | a2ae9787568ac50978c03ce67bfb79ad2e100cca (diff) | |
parent | 05c69d298c96703741cac9a5cbbf6c53bd55a6e2 (diff) |
Merge branch 'for-linus' of git://git.kernel.dk/linux-block
Pull block layer fixes from Jens Axboe:
"A few small, but important fixes. Most of them are marked for stable
as well
- Fix failure to release a semaphore on error path in mtip32xx.
- Fix crashable condition in bio_get_nr_vecs().
- Don't mark end-of-disk buffers as mapped, limit it to i_size.
- Fix for build problem with CONFIG_BLOCK=n on arm at least.
- Fix for a buffer overlow on UUID partition printing.
- Trivial removal of unused variables in dac960."
* 'for-linus' of git://git.kernel.dk/linux-block:
block: fix buffer overflow when printing partition UUIDs
Fix blkdev.h build errors when BLOCK=n
bio allocation failure due to bio_get_nr_vecs()
block: don't mark buffers beyond end of disk as mapped
mtip32xx: release the semaphore on an error path
dac960: Remove unused variables from DAC960_CreateProcEntries()
-rw-r--r-- | block/genhd.c | 10 | ||||
-rw-r--r-- | drivers/block/DAC960.c | 23 | ||||
-rw-r--r-- | drivers/block/mtip32xx/mtip32xx.c | 4 | ||||
-rw-r--r-- | fs/bio.c | 7 | ||||
-rw-r--r-- | fs/block_dev.c | 6 | ||||
-rw-r--r-- | fs/buffer.c | 4 | ||||
-rw-r--r-- | include/linux/blkdev.h | 3 | ||||
-rw-r--r-- | include/linux/fs.h | 1 | ||||
-rw-r--r-- | include/linux/genhd.h | 6 |
9 files changed, 34 insertions, 30 deletions
diff --git a/block/genhd.c b/block/genhd.c index df9816ede75b..9cf5583c90ff 100644 --- a/block/genhd.c +++ b/block/genhd.c | |||
@@ -743,7 +743,7 @@ void __init printk_all_partitions(void) | |||
743 | struct hd_struct *part; | 743 | struct hd_struct *part; |
744 | char name_buf[BDEVNAME_SIZE]; | 744 | char name_buf[BDEVNAME_SIZE]; |
745 | char devt_buf[BDEVT_SIZE]; | 745 | char devt_buf[BDEVT_SIZE]; |
746 | u8 uuid[PARTITION_META_INFO_UUIDLTH * 2 + 1]; | 746 | char uuid_buf[PARTITION_META_INFO_UUIDLTH * 2 + 5]; |
747 | 747 | ||
748 | /* | 748 | /* |
749 | * Don't show empty devices or things that have been | 749 | * Don't show empty devices or things that have been |
@@ -762,14 +762,16 @@ void __init printk_all_partitions(void) | |||
762 | while ((part = disk_part_iter_next(&piter))) { | 762 | while ((part = disk_part_iter_next(&piter))) { |
763 | bool is_part0 = part == &disk->part0; | 763 | bool is_part0 = part == &disk->part0; |
764 | 764 | ||
765 | uuid[0] = 0; | 765 | uuid_buf[0] = '\0'; |
766 | if (part->info) | 766 | if (part->info) |
767 | part_unpack_uuid(part->info->uuid, uuid); | 767 | snprintf(uuid_buf, sizeof(uuid_buf), "%pU", |
768 | part->info->uuid); | ||
768 | 769 | ||
769 | printk("%s%s %10llu %s %s", is_part0 ? "" : " ", | 770 | printk("%s%s %10llu %s %s", is_part0 ? "" : " ", |
770 | bdevt_str(part_devt(part), devt_buf), | 771 | bdevt_str(part_devt(part), devt_buf), |
771 | (unsigned long long)part->nr_sects >> 1, | 772 | (unsigned long long)part->nr_sects >> 1, |
772 | disk_name(disk, part->partno, name_buf), uuid); | 773 | disk_name(disk, part->partno, name_buf), |
774 | uuid_buf); | ||
773 | if (is_part0) { | 775 | if (is_part0) { |
774 | if (disk->driverfs_dev != NULL && | 776 | if (disk->driverfs_dev != NULL && |
775 | disk->driverfs_dev->driver != NULL) | 777 | disk->driverfs_dev->driver != NULL) |
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 8db9089127c5..9a13e889837e 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c | |||
@@ -6580,24 +6580,21 @@ static const struct file_operations dac960_user_command_proc_fops = { | |||
6580 | 6580 | ||
6581 | static void DAC960_CreateProcEntries(DAC960_Controller_T *Controller) | 6581 | static void DAC960_CreateProcEntries(DAC960_Controller_T *Controller) |
6582 | { | 6582 | { |
6583 | struct proc_dir_entry *StatusProcEntry; | ||
6584 | struct proc_dir_entry *ControllerProcEntry; | 6583 | struct proc_dir_entry *ControllerProcEntry; |
6585 | struct proc_dir_entry *UserCommandProcEntry; | ||
6586 | 6584 | ||
6587 | if (DAC960_ProcDirectoryEntry == NULL) { | 6585 | if (DAC960_ProcDirectoryEntry == NULL) { |
6588 | DAC960_ProcDirectoryEntry = proc_mkdir("rd", NULL); | 6586 | DAC960_ProcDirectoryEntry = proc_mkdir("rd", NULL); |
6589 | StatusProcEntry = proc_create("status", 0, | 6587 | proc_create("status", 0, DAC960_ProcDirectoryEntry, |
6590 | DAC960_ProcDirectoryEntry, | 6588 | &dac960_proc_fops); |
6591 | &dac960_proc_fops); | ||
6592 | } | 6589 | } |
6593 | 6590 | ||
6594 | sprintf(Controller->ControllerName, "c%d", Controller->ControllerNumber); | 6591 | sprintf(Controller->ControllerName, "c%d", Controller->ControllerNumber); |
6595 | ControllerProcEntry = proc_mkdir(Controller->ControllerName, | 6592 | ControllerProcEntry = proc_mkdir(Controller->ControllerName, |
6596 | DAC960_ProcDirectoryEntry); | 6593 | DAC960_ProcDirectoryEntry); |
6597 | proc_create_data("initial_status", 0, ControllerProcEntry, &dac960_initial_status_proc_fops, Controller); | 6594 | proc_create_data("initial_status", 0, ControllerProcEntry, &dac960_initial_status_proc_fops, Controller); |
6598 | proc_create_data("current_status", 0, ControllerProcEntry, &dac960_current_status_proc_fops, Controller); | 6595 | proc_create_data("current_status", 0, ControllerProcEntry, &dac960_current_status_proc_fops, Controller); |
6599 | UserCommandProcEntry = proc_create_data("user_command", S_IWUSR | S_IRUSR, ControllerProcEntry, &dac960_user_command_proc_fops, Controller); | 6596 | proc_create_data("user_command", S_IWUSR | S_IRUSR, ControllerProcEntry, &dac960_user_command_proc_fops, Controller); |
6600 | Controller->ControllerProcEntry = ControllerProcEntry; | 6597 | Controller->ControllerProcEntry = ControllerProcEntry; |
6601 | } | 6598 | } |
6602 | 6599 | ||
6603 | 6600 | ||
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c index 00f9fc992090..304000c3d433 100644 --- a/drivers/block/mtip32xx/mtip32xx.c +++ b/drivers/block/mtip32xx/mtip32xx.c | |||
@@ -2510,8 +2510,10 @@ static struct scatterlist *mtip_hw_get_scatterlist(struct driver_data *dd, | |||
2510 | up(&dd->port->cmd_slot); | 2510 | up(&dd->port->cmd_slot); |
2511 | return NULL; | 2511 | return NULL; |
2512 | } | 2512 | } |
2513 | if (unlikely(*tag < 0)) | 2513 | if (unlikely(*tag < 0)) { |
2514 | up(&dd->port->cmd_slot); | ||
2514 | return NULL; | 2515 | return NULL; |
2516 | } | ||
2515 | 2517 | ||
2516 | return dd->port->commands[*tag].sg; | 2518 | return dd->port->commands[*tag].sg; |
2517 | } | 2519 | } |
@@ -505,9 +505,14 @@ EXPORT_SYMBOL(bio_clone); | |||
505 | int bio_get_nr_vecs(struct block_device *bdev) | 505 | int bio_get_nr_vecs(struct block_device *bdev) |
506 | { | 506 | { |
507 | struct request_queue *q = bdev_get_queue(bdev); | 507 | struct request_queue *q = bdev_get_queue(bdev); |
508 | return min_t(unsigned, | 508 | int nr_pages; |
509 | |||
510 | nr_pages = min_t(unsigned, | ||
509 | queue_max_segments(q), | 511 | queue_max_segments(q), |
510 | queue_max_sectors(q) / (PAGE_SIZE >> 9) + 1); | 512 | queue_max_sectors(q) / (PAGE_SIZE >> 9) + 1); |
513 | |||
514 | return min_t(unsigned, nr_pages, BIO_MAX_PAGES); | ||
515 | |||
511 | } | 516 | } |
512 | EXPORT_SYMBOL(bio_get_nr_vecs); | 517 | EXPORT_SYMBOL(bio_get_nr_vecs); |
513 | 518 | ||
diff --git a/fs/block_dev.c b/fs/block_dev.c index e08f6a20a5bb..ba11c30f302d 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
@@ -70,7 +70,7 @@ static void bdev_inode_switch_bdi(struct inode *inode, | |||
70 | spin_unlock(&dst->wb.list_lock); | 70 | spin_unlock(&dst->wb.list_lock); |
71 | } | 71 | } |
72 | 72 | ||
73 | static sector_t max_block(struct block_device *bdev) | 73 | sector_t blkdev_max_block(struct block_device *bdev) |
74 | { | 74 | { |
75 | sector_t retval = ~((sector_t)0); | 75 | sector_t retval = ~((sector_t)0); |
76 | loff_t sz = i_size_read(bdev->bd_inode); | 76 | loff_t sz = i_size_read(bdev->bd_inode); |
@@ -163,7 +163,7 @@ static int | |||
163 | blkdev_get_block(struct inode *inode, sector_t iblock, | 163 | blkdev_get_block(struct inode *inode, sector_t iblock, |
164 | struct buffer_head *bh, int create) | 164 | struct buffer_head *bh, int create) |
165 | { | 165 | { |
166 | if (iblock >= max_block(I_BDEV(inode))) { | 166 | if (iblock >= blkdev_max_block(I_BDEV(inode))) { |
167 | if (create) | 167 | if (create) |
168 | return -EIO; | 168 | return -EIO; |
169 | 169 | ||
@@ -185,7 +185,7 @@ static int | |||
185 | blkdev_get_blocks(struct inode *inode, sector_t iblock, | 185 | blkdev_get_blocks(struct inode *inode, sector_t iblock, |
186 | struct buffer_head *bh, int create) | 186 | struct buffer_head *bh, int create) |
187 | { | 187 | { |
188 | sector_t end_block = max_block(I_BDEV(inode)); | 188 | sector_t end_block = blkdev_max_block(I_BDEV(inode)); |
189 | unsigned long max_blocks = bh->b_size >> inode->i_blkbits; | 189 | unsigned long max_blocks = bh->b_size >> inode->i_blkbits; |
190 | 190 | ||
191 | if ((iblock + max_blocks) > end_block) { | 191 | if ((iblock + max_blocks) > end_block) { |
diff --git a/fs/buffer.c b/fs/buffer.c index 351e18ea2e53..ad5938ca357c 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
@@ -921,6 +921,7 @@ init_page_buffers(struct page *page, struct block_device *bdev, | |||
921 | struct buffer_head *head = page_buffers(page); | 921 | struct buffer_head *head = page_buffers(page); |
922 | struct buffer_head *bh = head; | 922 | struct buffer_head *bh = head; |
923 | int uptodate = PageUptodate(page); | 923 | int uptodate = PageUptodate(page); |
924 | sector_t end_block = blkdev_max_block(I_BDEV(bdev->bd_inode)); | ||
924 | 925 | ||
925 | do { | 926 | do { |
926 | if (!buffer_mapped(bh)) { | 927 | if (!buffer_mapped(bh)) { |
@@ -929,7 +930,8 @@ init_page_buffers(struct page *page, struct block_device *bdev, | |||
929 | bh->b_blocknr = block; | 930 | bh->b_blocknr = block; |
930 | if (uptodate) | 931 | if (uptodate) |
931 | set_buffer_uptodate(bh); | 932 | set_buffer_uptodate(bh); |
932 | set_buffer_mapped(bh); | 933 | if (block < end_block) |
934 | set_buffer_mapped(bh); | ||
933 | } | 935 | } |
934 | block++; | 936 | block++; |
935 | bh = bh->b_this_page; | 937 | bh = bh->b_this_page; |
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 2aa24664a5b5..4d4ac24a263e 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -1,9 +1,10 @@ | |||
1 | #ifndef _LINUX_BLKDEV_H | 1 | #ifndef _LINUX_BLKDEV_H |
2 | #define _LINUX_BLKDEV_H | 2 | #define _LINUX_BLKDEV_H |
3 | 3 | ||
4 | #include <linux/sched.h> | ||
5 | |||
4 | #ifdef CONFIG_BLOCK | 6 | #ifdef CONFIG_BLOCK |
5 | 7 | ||
6 | #include <linux/sched.h> | ||
7 | #include <linux/major.h> | 8 | #include <linux/major.h> |
8 | #include <linux/genhd.h> | 9 | #include <linux/genhd.h> |
9 | #include <linux/list.h> | 10 | #include <linux/list.h> |
diff --git a/include/linux/fs.h b/include/linux/fs.h index 8de675523e46..25c40b9f848a 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -2051,6 +2051,7 @@ extern void unregister_blkdev(unsigned int, const char *); | |||
2051 | extern struct block_device *bdget(dev_t); | 2051 | extern struct block_device *bdget(dev_t); |
2052 | extern struct block_device *bdgrab(struct block_device *bdev); | 2052 | extern struct block_device *bdgrab(struct block_device *bdev); |
2053 | extern void bd_set_size(struct block_device *, loff_t size); | 2053 | extern void bd_set_size(struct block_device *, loff_t size); |
2054 | extern sector_t blkdev_max_block(struct block_device *bdev); | ||
2054 | extern void bd_forget(struct inode *inode); | 2055 | extern void bd_forget(struct inode *inode); |
2055 | extern void bdput(struct block_device *); | 2056 | extern void bdput(struct block_device *); |
2056 | extern void invalidate_bdev(struct block_device *); | 2057 | extern void invalidate_bdev(struct block_device *); |
diff --git a/include/linux/genhd.h b/include/linux/genhd.h index e61d3192448e..017a7fb5a1fc 100644 --- a/include/linux/genhd.h +++ b/include/linux/genhd.h | |||
@@ -222,12 +222,6 @@ static inline void part_pack_uuid(const u8 *uuid_str, u8 *to) | |||
222 | } | 222 | } |
223 | } | 223 | } |
224 | 224 | ||
225 | static inline char *part_unpack_uuid(const u8 *uuid, char *out) | ||
226 | { | ||
227 | sprintf(out, "%pU", uuid); | ||
228 | return out; | ||
229 | } | ||
230 | |||
231 | static inline int disk_max_parts(struct gendisk *disk) | 225 | static inline int disk_max_parts(struct gendisk *disk) |
232 | { | 226 | { |
233 | if (disk->flags & GENHD_FL_EXT_DEVT) | 227 | if (disk->flags & GENHD_FL_EXT_DEVT) |