aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/.gitignore4
-rw-r--r--drivers/md/bitmap.c12
-rw-r--r--drivers/md/dm-ioctl.c1
-rw-r--r--drivers/md/dm.c10
-rw-r--r--drivers/md/md.c44
-rw-r--r--drivers/md/md.h2
-rw-r--r--drivers/md/raid1.c4
7 files changed, 37 insertions, 40 deletions
diff --git a/drivers/md/.gitignore b/drivers/md/.gitignore
deleted file mode 100644
index a7afec6b19c6..000000000000
--- a/drivers/md/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
1mktables
2raid6altivec*.c
3raid6int*.c
4raid6tables.c
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 1ba1e122e948..e4fb58db5454 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1000,10 +1000,11 @@ static int bitmap_init_from_disk(struct bitmap *bitmap, sector_t start)
1000 page = bitmap->sb_page; 1000 page = bitmap->sb_page;
1001 offset = sizeof(bitmap_super_t); 1001 offset = sizeof(bitmap_super_t);
1002 if (!file) 1002 if (!file)
1003 read_sb_page(bitmap->mddev, 1003 page = read_sb_page(
1004 bitmap->mddev->bitmap_info.offset, 1004 bitmap->mddev,
1005 page, 1005 bitmap->mddev->bitmap_info.offset,
1006 index, count); 1006 page,
1007 index, count);
1007 } else if (file) { 1008 } else if (file) {
1008 page = read_page(file, index, bitmap, count); 1009 page = read_page(file, index, bitmap, count);
1009 offset = 0; 1010 offset = 0;
@@ -1542,8 +1543,7 @@ void bitmap_cond_end_sync(struct bitmap *bitmap, sector_t sector)
1542 atomic_read(&bitmap->mddev->recovery_active) == 0); 1543 atomic_read(&bitmap->mddev->recovery_active) == 0);
1543 1544
1544 bitmap->mddev->curr_resync_completed = bitmap->mddev->curr_resync; 1545 bitmap->mddev->curr_resync_completed = bitmap->mddev->curr_resync;
1545 if (bitmap->mddev->persistent) 1546 set_bit(MD_CHANGE_CLEAN, &bitmap->mddev->flags);
1546 set_bit(MD_CHANGE_CLEAN, &bitmap->mddev->flags);
1547 sector &= ~((1ULL << CHUNK_BLOCK_SHIFT(bitmap)) - 1); 1547 sector &= ~((1ULL << CHUNK_BLOCK_SHIFT(bitmap)) - 1);
1548 s = 0; 1548 s = 0;
1549 while (s < sector && s < bitmap->mddev->resync_max_sectors) { 1549 while (s < sector && s < bitmap->mddev->resync_max_sectors) {
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index 3e39193e5036..4b54618b4159 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1596,6 +1596,7 @@ static const struct file_operations _ctl_fops = {
1596 .unlocked_ioctl = dm_ctl_ioctl, 1596 .unlocked_ioctl = dm_ctl_ioctl,
1597 .compat_ioctl = dm_compat_ctl_ioctl, 1597 .compat_ioctl = dm_compat_ctl_ioctl,
1598 .owner = THIS_MODULE, 1598 .owner = THIS_MODULE,
1599 .llseek = noop_llseek,
1599}; 1600};
1600 1601
1601static struct miscdevice _dm_misc = { 1602static struct miscdevice _dm_misc = {
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index ac384b2a6a33..7967eca5a2d5 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -15,7 +15,6 @@
15#include <linux/blkpg.h> 15#include <linux/blkpg.h>
16#include <linux/bio.h> 16#include <linux/bio.h>
17#include <linux/buffer_head.h> 17#include <linux/buffer_head.h>
18#include <linux/smp_lock.h>
19#include <linux/mempool.h> 18#include <linux/mempool.h>
20#include <linux/slab.h> 19#include <linux/slab.h>
21#include <linux/idr.h> 20#include <linux/idr.h>
@@ -33,6 +32,7 @@
33#define DM_COOKIE_ENV_VAR_NAME "DM_COOKIE" 32#define DM_COOKIE_ENV_VAR_NAME "DM_COOKIE"
34#define DM_COOKIE_LENGTH 24 33#define DM_COOKIE_LENGTH 24
35 34
35static DEFINE_MUTEX(dm_mutex);
36static const char *_name = DM_NAME; 36static const char *_name = DM_NAME;
37 37
38static unsigned int major = 0; 38static unsigned int major = 0;
@@ -344,7 +344,7 @@ static int dm_blk_open(struct block_device *bdev, fmode_t mode)
344{ 344{
345 struct mapped_device *md; 345 struct mapped_device *md;
346 346
347 lock_kernel(); 347 mutex_lock(&dm_mutex);
348 spin_lock(&_minor_lock); 348 spin_lock(&_minor_lock);
349 349
350 md = bdev->bd_disk->private_data; 350 md = bdev->bd_disk->private_data;
@@ -362,7 +362,7 @@ static int dm_blk_open(struct block_device *bdev, fmode_t mode)
362 362
363out: 363out:
364 spin_unlock(&_minor_lock); 364 spin_unlock(&_minor_lock);
365 unlock_kernel(); 365 mutex_unlock(&dm_mutex);
366 366
367 return md ? 0 : -ENXIO; 367 return md ? 0 : -ENXIO;
368} 368}
@@ -371,10 +371,10 @@ static int dm_blk_close(struct gendisk *disk, fmode_t mode)
371{ 371{
372 struct mapped_device *md = disk->private_data; 372 struct mapped_device *md = disk->private_data;
373 373
374 lock_kernel(); 374 mutex_lock(&dm_mutex);
375 atomic_dec(&md->open_count); 375 atomic_dec(&md->open_count);
376 dm_put(md); 376 dm_put(md);
377 unlock_kernel(); 377 mutex_unlock(&dm_mutex);
378 378
379 return 0; 379 return 0;
380} 380}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index c148b6302154..dbf822df942a 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -36,7 +36,7 @@
36#include <linux/blkdev.h> 36#include <linux/blkdev.h>
37#include <linux/sysctl.h> 37#include <linux/sysctl.h>
38#include <linux/seq_file.h> 38#include <linux/seq_file.h>
39#include <linux/smp_lock.h> 39#include <linux/mutex.h>
40#include <linux/buffer_head.h> /* for invalidate_bdev */ 40#include <linux/buffer_head.h> /* for invalidate_bdev */
41#include <linux/poll.h> 41#include <linux/poll.h>
42#include <linux/ctype.h> 42#include <linux/ctype.h>
@@ -57,6 +57,7 @@
57#define DEBUG 0 57#define DEBUG 0
58#define dprintk(x...) ((void)(DEBUG && printk(x))) 58#define dprintk(x...) ((void)(DEBUG && printk(x)))
59 59
60static DEFINE_MUTEX(md_mutex);
60 61
61#ifndef MODULE 62#ifndef MODULE
62static void autostart_arrays(int part); 63static void autostart_arrays(int part);
@@ -1643,7 +1644,9 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1643 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1; 1644 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
1644 if (rdev->sb_size & bmask) 1645 if (rdev->sb_size & bmask)
1645 rdev->sb_size = (rdev->sb_size | bmask) + 1; 1646 rdev->sb_size = (rdev->sb_size | bmask) + 1;
1646 } 1647 } else
1648 max_dev = le32_to_cpu(sb->max_dev);
1649
1647 for (i=0; i<max_dev;i++) 1650 for (i=0; i<max_dev;i++)
1648 sb->dev_roles[i] = cpu_to_le16(0xfffe); 1651 sb->dev_roles[i] = cpu_to_le16(0xfffe);
1649 1652
@@ -2167,9 +2170,9 @@ repeat:
2167 rdev->recovery_offset = mddev->curr_resync_completed; 2170 rdev->recovery_offset = mddev->curr_resync_completed;
2168 2171
2169 } 2172 }
2170 if (mddev->external || !mddev->persistent) { 2173 if (!mddev->persistent) {
2171 clear_bit(MD_CHANGE_DEVS, &mddev->flags);
2172 clear_bit(MD_CHANGE_CLEAN, &mddev->flags); 2174 clear_bit(MD_CHANGE_CLEAN, &mddev->flags);
2175 clear_bit(MD_CHANGE_DEVS, &mddev->flags);
2173 wake_up(&mddev->sb_wait); 2176 wake_up(&mddev->sb_wait);
2174 return; 2177 return;
2175 } 2178 }
@@ -2178,7 +2181,6 @@ repeat:
2178 2181
2179 mddev->utime = get_seconds(); 2182 mddev->utime = get_seconds();
2180 2183
2181 set_bit(MD_CHANGE_PENDING, &mddev->flags);
2182 if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags)) 2184 if (test_and_clear_bit(MD_CHANGE_DEVS, &mddev->flags))
2183 force_change = 1; 2185 force_change = 1;
2184 if (test_and_clear_bit(MD_CHANGE_CLEAN, &mddev->flags)) 2186 if (test_and_clear_bit(MD_CHANGE_CLEAN, &mddev->flags))
@@ -3371,7 +3373,7 @@ array_state_show(mddev_t *mddev, char *page)
3371 case 0: 3373 case 0:
3372 if (mddev->in_sync) 3374 if (mddev->in_sync)
3373 st = clean; 3375 st = clean;
3374 else if (test_bit(MD_CHANGE_CLEAN, &mddev->flags)) 3376 else if (test_bit(MD_CHANGE_PENDING, &mddev->flags))
3375 st = write_pending; 3377 st = write_pending;
3376 else if (mddev->safemode) 3378 else if (mddev->safemode)
3377 st = active_idle; 3379 st = active_idle;
@@ -3452,9 +3454,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
3452 mddev->in_sync = 1; 3454 mddev->in_sync = 1;
3453 if (mddev->safemode == 1) 3455 if (mddev->safemode == 1)
3454 mddev->safemode = 0; 3456 mddev->safemode = 0;
3455 if (mddev->persistent) 3457 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
3456 set_bit(MD_CHANGE_CLEAN,
3457 &mddev->flags);
3458 } 3458 }
3459 err = 0; 3459 err = 0;
3460 } else 3460 } else
@@ -3466,8 +3466,7 @@ array_state_store(mddev_t *mddev, const char *buf, size_t len)
3466 case active: 3466 case active:
3467 if (mddev->pers) { 3467 if (mddev->pers) {
3468 restart_array(mddev); 3468 restart_array(mddev);
3469 if (mddev->external) 3469 clear_bit(MD_CHANGE_PENDING, &mddev->flags);
3470 clear_bit(MD_CHANGE_CLEAN, &mddev->flags);
3471 wake_up(&mddev->sb_wait); 3470 wake_up(&mddev->sb_wait);
3472 err = 0; 3471 err = 0;
3473 } else { 3472 } else {
@@ -5953,7 +5952,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)
5953 mddev_t *mddev = mddev_find(bdev->bd_dev); 5952 mddev_t *mddev = mddev_find(bdev->bd_dev);
5954 int err; 5953 int err;
5955 5954
5956 lock_kernel(); 5955 mutex_lock(&md_mutex);
5957 if (mddev->gendisk != bdev->bd_disk) { 5956 if (mddev->gendisk != bdev->bd_disk) {
5958 /* we are racing with mddev_put which is discarding this 5957 /* we are racing with mddev_put which is discarding this
5959 * bd_disk. 5958 * bd_disk.
@@ -5962,7 +5961,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)
5962 /* Wait until bdev->bd_disk is definitely gone */ 5961 /* Wait until bdev->bd_disk is definitely gone */
5963 flush_scheduled_work(); 5962 flush_scheduled_work();
5964 /* Then retry the open from the top */ 5963 /* Then retry the open from the top */
5965 unlock_kernel(); 5964 mutex_unlock(&md_mutex);
5966 return -ERESTARTSYS; 5965 return -ERESTARTSYS;
5967 } 5966 }
5968 BUG_ON(mddev != bdev->bd_disk->private_data); 5967 BUG_ON(mddev != bdev->bd_disk->private_data);
@@ -5976,7 +5975,7 @@ static int md_open(struct block_device *bdev, fmode_t mode)
5976 5975
5977 check_disk_size_change(mddev->gendisk, bdev); 5976 check_disk_size_change(mddev->gendisk, bdev);
5978 out: 5977 out:
5979 unlock_kernel(); 5978 mutex_unlock(&md_mutex);
5980 return err; 5979 return err;
5981} 5980}
5982 5981
@@ -5985,10 +5984,10 @@ static int md_release(struct gendisk *disk, fmode_t mode)
5985 mddev_t *mddev = disk->private_data; 5984 mddev_t *mddev = disk->private_data;
5986 5985
5987 BUG_ON(!mddev); 5986 BUG_ON(!mddev);
5988 lock_kernel(); 5987 mutex_lock(&md_mutex);
5989 atomic_dec(&mddev->openers); 5988 atomic_dec(&mddev->openers);
5990 mddev_put(mddev); 5989 mddev_put(mddev);
5991 unlock_kernel(); 5990 mutex_unlock(&md_mutex);
5992 5991
5993 return 0; 5992 return 0;
5994} 5993}
@@ -6572,6 +6571,7 @@ void md_write_start(mddev_t *mddev, struct bio *bi)
6572 if (mddev->in_sync) { 6571 if (mddev->in_sync) {
6573 mddev->in_sync = 0; 6572 mddev->in_sync = 0;
6574 set_bit(MD_CHANGE_CLEAN, &mddev->flags); 6573 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
6574 set_bit(MD_CHANGE_PENDING, &mddev->flags);
6575 md_wakeup_thread(mddev->thread); 6575 md_wakeup_thread(mddev->thread);
6576 did_change = 1; 6576 did_change = 1;
6577 } 6577 }
@@ -6580,7 +6580,6 @@ void md_write_start(mddev_t *mddev, struct bio *bi)
6580 if (did_change) 6580 if (did_change)
6581 sysfs_notify_dirent_safe(mddev->sysfs_state); 6581 sysfs_notify_dirent_safe(mddev->sysfs_state);
6582 wait_event(mddev->sb_wait, 6582 wait_event(mddev->sb_wait,
6583 !test_bit(MD_CHANGE_CLEAN, &mddev->flags) &&
6584 !test_bit(MD_CHANGE_PENDING, &mddev->flags)); 6583 !test_bit(MD_CHANGE_PENDING, &mddev->flags));
6585} 6584}
6586 6585
@@ -6616,6 +6615,7 @@ int md_allow_write(mddev_t *mddev)
6616 if (mddev->in_sync) { 6615 if (mddev->in_sync) {
6617 mddev->in_sync = 0; 6616 mddev->in_sync = 0;
6618 set_bit(MD_CHANGE_CLEAN, &mddev->flags); 6617 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
6618 set_bit(MD_CHANGE_PENDING, &mddev->flags);
6619 if (mddev->safemode_delay && 6619 if (mddev->safemode_delay &&
6620 mddev->safemode == 0) 6620 mddev->safemode == 0)
6621 mddev->safemode = 1; 6621 mddev->safemode = 1;
@@ -6625,7 +6625,7 @@ int md_allow_write(mddev_t *mddev)
6625 } else 6625 } else
6626 spin_unlock_irq(&mddev->write_lock); 6626 spin_unlock_irq(&mddev->write_lock);
6627 6627
6628 if (test_bit(MD_CHANGE_CLEAN, &mddev->flags)) 6628 if (test_bit(MD_CHANGE_PENDING, &mddev->flags))
6629 return -EAGAIN; 6629 return -EAGAIN;
6630 else 6630 else
6631 return 0; 6631 return 0;
@@ -6823,8 +6823,7 @@ void md_do_sync(mddev_t *mddev)
6823 atomic_read(&mddev->recovery_active) == 0); 6823 atomic_read(&mddev->recovery_active) == 0);
6824 mddev->curr_resync_completed = 6824 mddev->curr_resync_completed =
6825 mddev->curr_resync; 6825 mddev->curr_resync;
6826 if (mddev->persistent) 6826 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
6827 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
6828 sysfs_notify(&mddev->kobj, NULL, "sync_completed"); 6827 sysfs_notify(&mddev->kobj, NULL, "sync_completed");
6829 } 6828 }
6830 6829
@@ -7073,7 +7072,7 @@ void md_check_recovery(mddev_t *mddev)
7073 if (mddev->ro && !test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) 7072 if (mddev->ro && !test_bit(MD_RECOVERY_NEEDED, &mddev->recovery))
7074 return; 7073 return;
7075 if ( ! ( 7074 if ( ! (
7076 (mddev->flags && !mddev->external) || 7075 (mddev->flags & ~ (1<<MD_CHANGE_PENDING)) ||
7077 test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) || 7076 test_bit(MD_RECOVERY_NEEDED, &mddev->recovery) ||
7078 test_bit(MD_RECOVERY_DONE, &mddev->recovery) || 7077 test_bit(MD_RECOVERY_DONE, &mddev->recovery) ||
7079 (mddev->external == 0 && mddev->safemode == 1) || 7078 (mddev->external == 0 && mddev->safemode == 1) ||
@@ -7103,8 +7102,7 @@ void md_check_recovery(mddev_t *mddev)
7103 mddev->recovery_cp == MaxSector) { 7102 mddev->recovery_cp == MaxSector) {
7104 mddev->in_sync = 1; 7103 mddev->in_sync = 1;
7105 did_change = 1; 7104 did_change = 1;
7106 if (mddev->persistent) 7105 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
7107 set_bit(MD_CHANGE_CLEAN, &mddev->flags);
7108 } 7106 }
7109 if (mddev->safemode == 1) 7107 if (mddev->safemode == 1)
7110 mddev->safemode = 0; 7108 mddev->safemode = 0;
diff --git a/drivers/md/md.h b/drivers/md/md.h
index a953fe2808ae..3931299788dc 100644
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@ -140,7 +140,7 @@ struct mddev_s
140 unsigned long flags; 140 unsigned long flags;
141#define MD_CHANGE_DEVS 0 /* Some device status has changed */ 141#define MD_CHANGE_DEVS 0 /* Some device status has changed */
142#define MD_CHANGE_CLEAN 1 /* transition to or from 'clean' */ 142#define MD_CHANGE_CLEAN 1 /* transition to or from 'clean' */
143#define MD_CHANGE_PENDING 2 /* superblock update in progress */ 143#define MD_CHANGE_PENDING 2 /* switch from 'clean' to 'active' in progress */
144 144
145 int suspended; 145 int suspended;
146 atomic_t active_io; 146 atomic_t active_io;
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index ad83a4dcadc3..0b830bbe1d8b 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1839,7 +1839,9 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1839 1839
1840 /* take from bio_init */ 1840 /* take from bio_init */
1841 bio->bi_next = NULL; 1841 bio->bi_next = NULL;
1842 bio->bi_flags &= ~(BIO_POOL_MASK-1);
1842 bio->bi_flags |= 1 << BIO_UPTODATE; 1843 bio->bi_flags |= 1 << BIO_UPTODATE;
1844 bio->bi_comp_cpu = -1;
1843 bio->bi_rw = READ; 1845 bio->bi_rw = READ;
1844 bio->bi_vcnt = 0; 1846 bio->bi_vcnt = 0;
1845 bio->bi_idx = 0; 1847 bio->bi_idx = 0;
@@ -1912,7 +1914,7 @@ static sector_t sync_request(mddev_t *mddev, sector_t sector_nr, int *skipped, i
1912 !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery)) 1914 !test_bit(MD_RECOVERY_REQUESTED, &mddev->recovery))
1913 break; 1915 break;
1914 BUG_ON(sync_blocks < (PAGE_SIZE>>9)); 1916 BUG_ON(sync_blocks < (PAGE_SIZE>>9));
1915 if (len > (sync_blocks<<9)) 1917 if ((len >> 9) > sync_blocks)
1916 len = sync_blocks<<9; 1918 len = sync_blocks<<9;
1917 } 1919 }
1918 1920