aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/bitmap.c12
-rw-r--r--drivers/md/dm-crypt.c14
-rw-r--r--drivers/md/dm-ioctl.c9
-rw-r--r--drivers/md/dm-raid1.c22
-rw-r--r--drivers/md/dm-round-robin.c2
-rw-r--r--drivers/md/dm.c4
-rw-r--r--drivers/md/md.c25
-rw-r--r--drivers/md/multipath.c4
-rw-r--r--drivers/md/raid1.c4
-rw-r--r--drivers/md/raid10.c6
-rw-r--r--drivers/md/raid5.c2
11 files changed, 65 insertions, 39 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 8e67634e79a0..d6f614738bbd 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -536,7 +536,7 @@ static int bitmap_read_sb(struct bitmap *bitmap)
536 printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) " 536 printk(KERN_INFO "%s: bitmap file is out of date (%llu < %llu) "
537 "-- forcing full recovery\n", bmname(bitmap), events, 537 "-- forcing full recovery\n", bmname(bitmap), events,
538 (unsigned long long) bitmap->mddev->events); 538 (unsigned long long) bitmap->mddev->events);
539 sb->state |= BITMAP_STALE; 539 sb->state |= cpu_to_le32(BITMAP_STALE);
540 } 540 }
541success: 541success:
542 /* assign fields using values from superblock */ 542 /* assign fields using values from superblock */
@@ -544,11 +544,11 @@ success:
544 bitmap->daemon_sleep = daemon_sleep; 544 bitmap->daemon_sleep = daemon_sleep;
545 bitmap->daemon_lastrun = jiffies; 545 bitmap->daemon_lastrun = jiffies;
546 bitmap->max_write_behind = write_behind; 546 bitmap->max_write_behind = write_behind;
547 bitmap->flags |= sb->state; 547 bitmap->flags |= le32_to_cpu(sb->state);
548 if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN) 548 if (le32_to_cpu(sb->version) == BITMAP_MAJOR_HOSTENDIAN)
549 bitmap->flags |= BITMAP_HOSTENDIAN; 549 bitmap->flags |= BITMAP_HOSTENDIAN;
550 bitmap->events_cleared = le64_to_cpu(sb->events_cleared); 550 bitmap->events_cleared = le64_to_cpu(sb->events_cleared);
551 if (sb->state & BITMAP_STALE) 551 if (sb->state & cpu_to_le32(BITMAP_STALE))
552 bitmap->events_cleared = bitmap->mddev->events; 552 bitmap->events_cleared = bitmap->mddev->events;
553 err = 0; 553 err = 0;
554out: 554out:
@@ -578,9 +578,9 @@ static void bitmap_mask_state(struct bitmap *bitmap, enum bitmap_state bits,
578 spin_unlock_irqrestore(&bitmap->lock, flags); 578 spin_unlock_irqrestore(&bitmap->lock, flags);
579 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0); 579 sb = (bitmap_super_t *)kmap_atomic(bitmap->sb_page, KM_USER0);
580 switch (op) { 580 switch (op) {
581 case MASK_SET: sb->state |= bits; 581 case MASK_SET: sb->state |= cpu_to_le32(bits);
582 break; 582 break;
583 case MASK_UNSET: sb->state &= ~bits; 583 case MASK_UNSET: sb->state &= cpu_to_le32(~bits);
584 break; 584 break;
585 default: BUG(); 585 default: BUG();
586 } 586 }
@@ -1413,7 +1413,7 @@ int bitmap_create(mddev_t *mddev)
1413 int err; 1413 int err;
1414 sector_t start; 1414 sector_t start;
1415 1415
1416 BUG_ON(sizeof(bitmap_super_t) != 256); 1416 BUILD_BUG_ON(sizeof(bitmap_super_t) != 256);
1417 1417
1418 if (!file && !mddev->bitmap_offset) /* bitmap disabled, nothing to do */ 1418 if (!file && !mddev->bitmap_offset) /* bitmap disabled, nothing to do */
1419 return 0; 1419 return 0;
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 655d816760e5..08a40f4e4f60 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -16,6 +16,7 @@
16#include <linux/slab.h> 16#include <linux/slab.h>
17#include <linux/crypto.h> 17#include <linux/crypto.h>
18#include <linux/workqueue.h> 18#include <linux/workqueue.h>
19#include <linux/backing-dev.h>
19#include <asm/atomic.h> 20#include <asm/atomic.h>
20#include <linux/scatterlist.h> 21#include <linux/scatterlist.h>
21#include <asm/page.h> 22#include <asm/page.h>
@@ -602,7 +603,7 @@ static void process_write(struct crypt_io *io)
602 603
603 /* out of memory -> run queues */ 604 /* out of memory -> run queues */
604 if (remaining) 605 if (remaining)
605 blk_congestion_wait(bio_data_dir(clone), HZ/100); 606 congestion_wait(bio_data_dir(clone), HZ/100);
606 } 607 }
607} 608}
608 609
@@ -914,8 +915,6 @@ static int crypt_status(struct dm_target *ti, status_type_t type,
914 char *result, unsigned int maxlen) 915 char *result, unsigned int maxlen)
915{ 916{
916 struct crypt_config *cc = (struct crypt_config *) ti->private; 917 struct crypt_config *cc = (struct crypt_config *) ti->private;
917 const char *cipher;
918 const char *chainmode = NULL;
919 unsigned int sz = 0; 918 unsigned int sz = 0;
920 919
921 switch (type) { 920 switch (type) {
@@ -924,14 +923,11 @@ static int crypt_status(struct dm_target *ti, status_type_t type,
924 break; 923 break;
925 924
926 case STATUSTYPE_TABLE: 925 case STATUSTYPE_TABLE:
927 cipher = crypto_blkcipher_name(cc->tfm);
928
929 chainmode = cc->chainmode;
930
931 if (cc->iv_mode) 926 if (cc->iv_mode)
932 DMEMIT("%s-%s-%s ", cipher, chainmode, cc->iv_mode); 927 DMEMIT("%s-%s-%s ", cc->cipher, cc->chainmode,
928 cc->iv_mode);
933 else 929 else
934 DMEMIT("%s-%s ", cipher, chainmode); 930 DMEMIT("%s-%s ", cc->cipher, cc->chainmode);
935 931
936 if (cc->key_size > 0) { 932 if (cc->key_size > 0) {
937 if ((maxlen - sz) < ((cc->key_size << 1) + 1)) 933 if ((maxlen - sz) < ((cc->key_size << 1) + 1))
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index d13bb15a8a02..4510ad8f971c 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -606,9 +606,14 @@ static struct hash_cell *__find_device_hash_cell(struct dm_ioctl *param)
606 return __get_name_cell(param->name); 606 return __get_name_cell(param->name);
607 607
608 md = dm_get_md(huge_decode_dev(param->dev)); 608 md = dm_get_md(huge_decode_dev(param->dev));
609 if (md) 609 if (!md)
610 mdptr = dm_get_mdptr(md); 610 goto out;
611 611
612 mdptr = dm_get_mdptr(md);
613 if (!mdptr)
614 dm_put(md);
615
616out:
612 return mdptr; 617 return mdptr;
613} 618}
614 619
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
index 659224cb7c53..48a653b3f518 100644
--- a/drivers/md/dm-raid1.c
+++ b/drivers/md/dm-raid1.c
@@ -24,6 +24,7 @@
24 24
25static struct workqueue_struct *_kmirrord_wq; 25static struct workqueue_struct *_kmirrord_wq;
26static struct work_struct _kmirrord_work; 26static struct work_struct _kmirrord_work;
27static DECLARE_WAIT_QUEUE_HEAD(_kmirrord_recovery_stopped);
27 28
28static inline void wake(void) 29static inline void wake(void)
29{ 30{
@@ -83,6 +84,7 @@ struct region_hash {
83 struct list_head *buckets; 84 struct list_head *buckets;
84 85
85 spinlock_t region_lock; 86 spinlock_t region_lock;
87 atomic_t recovery_in_flight;
86 struct semaphore recovery_count; 88 struct semaphore recovery_count;
87 struct list_head clean_regions; 89 struct list_head clean_regions;
88 struct list_head quiesced_regions; 90 struct list_head quiesced_regions;
@@ -191,6 +193,7 @@ static int rh_init(struct region_hash *rh, struct mirror_set *ms,
191 193
192 spin_lock_init(&rh->region_lock); 194 spin_lock_init(&rh->region_lock);
193 sema_init(&rh->recovery_count, 0); 195 sema_init(&rh->recovery_count, 0);
196 atomic_set(&rh->recovery_in_flight, 0);
194 INIT_LIST_HEAD(&rh->clean_regions); 197 INIT_LIST_HEAD(&rh->clean_regions);
195 INIT_LIST_HEAD(&rh->quiesced_regions); 198 INIT_LIST_HEAD(&rh->quiesced_regions);
196 INIT_LIST_HEAD(&rh->recovered_regions); 199 INIT_LIST_HEAD(&rh->recovered_regions);
@@ -382,6 +385,8 @@ static void rh_update_states(struct region_hash *rh)
382 rh->log->type->clear_region(rh->log, reg->key); 385 rh->log->type->clear_region(rh->log, reg->key);
383 rh->log->type->complete_resync_work(rh->log, reg->key, 1); 386 rh->log->type->complete_resync_work(rh->log, reg->key, 1);
384 dispatch_bios(rh->ms, &reg->delayed_bios); 387 dispatch_bios(rh->ms, &reg->delayed_bios);
388 if (atomic_dec_and_test(&rh->recovery_in_flight))
389 wake_up_all(&_kmirrord_recovery_stopped);
385 up(&rh->recovery_count); 390 up(&rh->recovery_count);
386 mempool_free(reg, rh->region_pool); 391 mempool_free(reg, rh->region_pool);
387 } 392 }
@@ -502,11 +507,21 @@ static int __rh_recovery_prepare(struct region_hash *rh)
502 507
503static void rh_recovery_prepare(struct region_hash *rh) 508static void rh_recovery_prepare(struct region_hash *rh)
504{ 509{
505 while (!down_trylock(&rh->recovery_count)) 510 /* Extra reference to avoid race with rh_stop_recovery */
511 atomic_inc(&rh->recovery_in_flight);
512
513 while (!down_trylock(&rh->recovery_count)) {
514 atomic_inc(&rh->recovery_in_flight);
506 if (__rh_recovery_prepare(rh) <= 0) { 515 if (__rh_recovery_prepare(rh) <= 0) {
516 atomic_dec(&rh->recovery_in_flight);
507 up(&rh->recovery_count); 517 up(&rh->recovery_count);
508 break; 518 break;
509 } 519 }
520 }
521
522 /* Drop the extra reference */
523 if (atomic_dec_and_test(&rh->recovery_in_flight))
524 wake_up_all(&_kmirrord_recovery_stopped);
510} 525}
511 526
512/* 527/*
@@ -1177,6 +1192,11 @@ static void mirror_postsuspend(struct dm_target *ti)
1177 struct dirty_log *log = ms->rh.log; 1192 struct dirty_log *log = ms->rh.log;
1178 1193
1179 rh_stop_recovery(&ms->rh); 1194 rh_stop_recovery(&ms->rh);
1195
1196 /* Wait for all I/O we generated to complete */
1197 wait_event(_kmirrord_recovery_stopped,
1198 !atomic_read(&ms->rh.recovery_in_flight));
1199
1180 if (log->type->suspend && log->type->suspend(log)) 1200 if (log->type->suspend && log->type->suspend(log))
1181 /* FIXME: need better error handling */ 1201 /* FIXME: need better error handling */
1182 DMWARN("log suspend failed"); 1202 DMWARN("log suspend failed");
diff --git a/drivers/md/dm-round-robin.c b/drivers/md/dm-round-robin.c
index c5a16c550122..6f9fcd4db9b5 100644
--- a/drivers/md/dm-round-robin.c
+++ b/drivers/md/dm-round-robin.c
@@ -136,7 +136,7 @@ static int rr_add_path(struct path_selector *ps, struct path *path,
136 136
137 path->pscontext = pi; 137 path->pscontext = pi;
138 138
139 list_add(&pi->list, &s->valid_paths); 139 list_add_tail(&pi->list, &s->valid_paths);
140 140
141 return 0; 141 return 0;
142} 142}
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index b5764a86c8b5..fc4f743f3b53 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -1285,7 +1285,7 @@ int dm_suspend(struct mapped_device *md, int do_lockfs)
1285 down(&md->suspend_lock); 1285 down(&md->suspend_lock);
1286 1286
1287 if (dm_suspended(md)) 1287 if (dm_suspended(md))
1288 goto out; 1288 goto out_unlock;
1289 1289
1290 map = dm_get_table(md); 1290 map = dm_get_table(md);
1291 1291
@@ -1361,6 +1361,8 @@ out:
1361 } 1361 }
1362 1362
1363 dm_table_put(map); 1363 dm_table_put(map);
1364
1365out_unlock:
1364 up(&md->suspend_lock); 1366 up(&md->suspend_lock);
1365 return r; 1367 return r;
1366} 1368}
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 57fa64f93e5f..8cbf9c9df1c3 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -974,12 +974,13 @@ static void super_90_sync(mddev_t *mddev, mdk_rdev_t *rdev)
974 * version 1 superblock 974 * version 1 superblock
975 */ 975 */
976 976
977static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb) 977static __le32 calc_sb_1_csum(struct mdp_superblock_1 * sb)
978{ 978{
979 unsigned int disk_csum, csum; 979 __le32 disk_csum;
980 u32 csum;
980 unsigned long long newcsum; 981 unsigned long long newcsum;
981 int size = 256 + le32_to_cpu(sb->max_dev)*2; 982 int size = 256 + le32_to_cpu(sb->max_dev)*2;
982 unsigned int *isuper = (unsigned int*)sb; 983 __le32 *isuper = (__le32*)sb;
983 int i; 984 int i;
984 985
985 disk_csum = sb->sb_csum; 986 disk_csum = sb->sb_csum;
@@ -989,7 +990,7 @@ static unsigned int calc_sb_1_csum(struct mdp_superblock_1 * sb)
989 newcsum += le32_to_cpu(*isuper++); 990 newcsum += le32_to_cpu(*isuper++);
990 991
991 if (size == 2) 992 if (size == 2)
992 newcsum += le16_to_cpu(*(unsigned short*) isuper); 993 newcsum += le16_to_cpu(*(__le16*) isuper);
993 994
994 csum = (newcsum & 0xffffffff) + (newcsum >> 32); 995 csum = (newcsum & 0xffffffff) + (newcsum >> 32);
995 sb->sb_csum = disk_csum; 996 sb->sb_csum = disk_csum;
@@ -1106,7 +1107,7 @@ static int super_1_load(mdk_rdev_t *rdev, mdk_rdev_t *refdev, int minor_version)
1106 if (le32_to_cpu(sb->chunksize)) 1107 if (le32_to_cpu(sb->chunksize))
1107 rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1); 1108 rdev->size &= ~((sector_t)le32_to_cpu(sb->chunksize)/2 - 1);
1108 1109
1109 if (le32_to_cpu(sb->size) > rdev->size*2) 1110 if (le64_to_cpu(sb->size) > rdev->size*2)
1110 return -EINVAL; 1111 return -EINVAL;
1111 return ret; 1112 return ret;
1112} 1113}
@@ -1228,7 +1229,7 @@ static void super_1_sync(mddev_t *mddev, mdk_rdev_t *rdev)
1228 else 1229 else
1229 sb->resync_offset = cpu_to_le64(0); 1230 sb->resync_offset = cpu_to_le64(0);
1230 1231
1231 sb->cnt_corrected_read = atomic_read(&rdev->corrected_errors); 1232 sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
1232 1233
1233 sb->raid_disks = cpu_to_le32(mddev->raid_disks); 1234 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
1234 sb->size = cpu_to_le64(mddev->size<<1); 1235 sb->size = cpu_to_le64(mddev->size<<1);
@@ -2002,6 +2003,7 @@ static mdk_rdev_t *md_import_device(dev_t newdev, int super_format, int super_mi
2002 kobject_init(&rdev->kobj); 2003 kobject_init(&rdev->kobj);
2003 2004
2004 rdev->desc_nr = -1; 2005 rdev->desc_nr = -1;
2006 rdev->saved_raid_disk = -1;
2005 rdev->flags = 0; 2007 rdev->flags = 0;
2006 rdev->data_offset = 0; 2008 rdev->data_offset = 0;
2007 rdev->sb_events = 0; 2009 rdev->sb_events = 0;
@@ -3198,6 +3200,7 @@ static int do_md_run(mddev_t * mddev)
3198 3200
3199 mddev->changed = 1; 3201 mddev->changed = 1;
3200 md_new_event(mddev); 3202 md_new_event(mddev);
3203 kobject_uevent(&mddev->gendisk->kobj, KOBJ_CHANGE);
3201 return 0; 3204 return 0;
3202} 3205}
3203 3206
@@ -4043,11 +4046,8 @@ static int update_size(mddev_t *mddev, unsigned long size)
4043 return -EBUSY; 4046 return -EBUSY;
4044 ITERATE_RDEV(mddev,rdev,tmp) { 4047 ITERATE_RDEV(mddev,rdev,tmp) {
4045 sector_t avail; 4048 sector_t avail;
4046 if (rdev->sb_offset > rdev->data_offset) 4049 avail = rdev->size * 2;
4047 avail = (rdev->sb_offset*2) - rdev->data_offset; 4050
4048 else
4049 avail = get_capacity(rdev->bdev->bd_disk)
4050 - rdev->data_offset;
4051 if (fit && (size == 0 || size > avail/2)) 4051 if (fit && (size == 0 || size > avail/2))
4052 size = avail/2; 4052 size = avail/2;
4053 if (avail < ((sector_t)size << 1)) 4053 if (avail < ((sector_t)size << 1))
@@ -4486,6 +4486,7 @@ static int md_thread(void * arg)
4486 * many dirty RAID5 blocks. 4486 * many dirty RAID5 blocks.
4487 */ 4487 */
4488 4488
4489 current->flags |= PF_NOFREEZE;
4489 allow_signal(SIGKILL); 4490 allow_signal(SIGKILL);
4490 while (!kthread_should_stop()) { 4491 while (!kthread_should_stop()) {
4491 4492
@@ -4502,7 +4503,6 @@ static int md_thread(void * arg)
4502 test_bit(THREAD_WAKEUP, &thread->flags) 4503 test_bit(THREAD_WAKEUP, &thread->flags)
4503 || kthread_should_stop(), 4504 || kthread_should_stop(),
4504 thread->timeout); 4505 thread->timeout);
4505 try_to_freeze();
4506 4506
4507 clear_bit(THREAD_WAKEUP, &thread->flags); 4507 clear_bit(THREAD_WAKEUP, &thread->flags);
4508 4508
@@ -4912,6 +4912,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
4912} 4912}
4913 4913
4914static struct file_operations md_seq_fops = { 4914static struct file_operations md_seq_fops = {
4915 .owner = THIS_MODULE,
4915 .open = md_seq_open, 4916 .open = md_seq_open,
4916 .read = seq_read, 4917 .read = seq_read,
4917 .llseek = seq_lseek, 4918 .llseek = seq_lseek,
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c
index 171ff41b52b0..14da37fee37b 100644
--- a/drivers/md/multipath.c
+++ b/drivers/md/multipath.c
@@ -277,6 +277,7 @@ static void multipath_error (mddev_t *mddev, mdk_rdev_t *rdev)
277 set_bit(Faulty, &rdev->flags); 277 set_bit(Faulty, &rdev->flags);
278 set_bit(MD_CHANGE_DEVS, &mddev->flags); 278 set_bit(MD_CHANGE_DEVS, &mddev->flags);
279 conf->working_disks--; 279 conf->working_disks--;
280 mddev->degraded++;
280 printk(KERN_ALERT "multipath: IO failure on %s," 281 printk(KERN_ALERT "multipath: IO failure on %s,"
281 " disabling IO path. \n Operation continuing" 282 " disabling IO path. \n Operation continuing"
282 " on %d IO paths.\n", 283 " on %d IO paths.\n",
@@ -336,6 +337,7 @@ static int multipath_add_disk(mddev_t *mddev, mdk_rdev_t *rdev)
336 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9); 337 blk_queue_max_sectors(mddev->queue, PAGE_SIZE>>9);
337 338
338 conf->working_disks++; 339 conf->working_disks++;
340 mddev->degraded--;
339 rdev->raid_disk = path; 341 rdev->raid_disk = path;
340 set_bit(In_sync, &rdev->flags); 342 set_bit(In_sync, &rdev->flags);
341 rcu_assign_pointer(p->rdev, rdev); 343 rcu_assign_pointer(p->rdev, rdev);
@@ -501,7 +503,7 @@ static int multipath_run (mddev_t *mddev)
501 mdname(mddev)); 503 mdname(mddev));
502 goto out_free_conf; 504 goto out_free_conf;
503 } 505 }
504 mddev->degraded = conf->raid_disks = conf->working_disks; 506 mddev->degraded = conf->raid_disks - conf->working_disks;
505 507
506 conf->pool = mempool_create_kzalloc_pool(NR_RESERVED_BUFS, 508 conf->pool = mempool_create_kzalloc_pool(NR_RESERVED_BUFS,
507 sizeof(struct multipath_bh)); 509 sizeof(struct multipath_bh));
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index dc9d2def0270..656fae912fe3 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1474,8 +1474,8 @@ static void fix_read_error(conf_t *conf, int read_disk,
1474 "raid1:%s: read error corrected " 1474 "raid1:%s: read error corrected "
1475 "(%d sectors at %llu on %s)\n", 1475 "(%d sectors at %llu on %s)\n",
1476 mdname(mddev), s, 1476 mdname(mddev), s,
1477 (unsigned long long)sect + 1477 (unsigned long long)(sect +
1478 rdev->data_offset, 1478 rdev->data_offset),
1479 bdevname(rdev->bdev, b)); 1479 bdevname(rdev->bdev, b));
1480 } 1480 }
1481 } 1481 }
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
index 1250f0eab4af..7492d6033ac6 100644
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@ -1470,8 +1470,8 @@ static void fix_read_error(conf_t *conf, mddev_t *mddev, r10bio_t *r10_bio)
1470 "raid10:%s: read error corrected" 1470 "raid10:%s: read error corrected"
1471 " (%d sectors at %llu on %s)\n", 1471 " (%d sectors at %llu on %s)\n",
1472 mdname(mddev), s, 1472 mdname(mddev), s,
1473 (unsigned long long)sect+ 1473 (unsigned long long)(sect+
1474 rdev->data_offset, 1474 rdev->data_offset),
1475 bdevname(rdev->bdev, b)); 1475 bdevname(rdev->bdev, b));
1476 1476
1477 rdev_dec_pending(rdev, mddev); 1477 rdev_dec_pending(rdev, mddev);
@@ -2079,7 +2079,7 @@ static int run(mddev_t *mddev)
2079 disk = conf->mirrors + i; 2079 disk = conf->mirrors + i;
2080 2080
2081 if (!disk->rdev || 2081 if (!disk->rdev ||
2082 !test_bit(In_sync, &rdev->flags)) { 2082 !test_bit(In_sync, &disk->rdev->flags)) {
2083 disk->head_position = 0; 2083 disk->head_position = 0;
2084 mddev->degraded++; 2084 mddev->degraded++;
2085 } 2085 }
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index e14f45780720..69c3e201fa3b 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -3659,7 +3659,7 @@ static void end_reshape(raid5_conf_t *conf)
3659 bdev = bdget_disk(conf->mddev->gendisk, 0); 3659 bdev = bdget_disk(conf->mddev->gendisk, 0);
3660 if (bdev) { 3660 if (bdev) {
3661 mutex_lock(&bdev->bd_inode->i_mutex); 3661 mutex_lock(&bdev->bd_inode->i_mutex);
3662 i_size_write(bdev->bd_inode, conf->mddev->array_size << 10); 3662 i_size_write(bdev->bd_inode, (loff_t)conf->mddev->array_size << 10);
3663 mutex_unlock(&bdev->bd_inode->i_mutex); 3663 mutex_unlock(&bdev->bd_inode->i_mutex);
3664 bdput(bdev); 3664 bdput(bdev);
3665 } 3665 }