linux-next: manual merge of the md tree with the block tree

2018-05-30 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/md.c

between commit:

  afeee514ce7f ("md: convert to bioset_init()/mempool_init()")

from the block tree and commit:

  5a409b4f56d5 ("MD: fix lock contention for flush bios")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/md.c
index fc692b7128bb,6b4e2f29fe4e..
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@@ -5498,16 -5518,34 +5519,32 @@@ int md_run(struct mddev *mddev
sysfs_notify_dirent_safe(rdev->sysfs_state);
}
  
 -  if (mddev->bio_set == NULL) {
 -  mddev->bio_set = bioset_create(BIO_POOL_SIZE, 0, 
BIOSET_NEED_BVECS);
 -  if (!mddev->bio_set)
 -  return -ENOMEM;
 +  if (!bioset_initialized(>bio_set)) {
 +  err = bioset_init(>bio_set, BIO_POOL_SIZE, 0, 
BIOSET_NEED_BVECS);
 +  if (err)
 +  return err;
}
 -  if (mddev->sync_set == NULL) {
 -  mddev->sync_set = bioset_create(BIO_POOL_SIZE, 0, 
BIOSET_NEED_BVECS);
 -  if (!mddev->sync_set) {
 -  err = -ENOMEM;
 +  if (!bioset_initialized(>sync_set)) {
 +  err = bioset_init(>sync_set, BIO_POOL_SIZE, 0, 
BIOSET_NEED_BVECS);
 +  if (err)
goto abort;
 -  }
}
+   if (mddev->flush_pool == NULL) {
+   mddev->flush_pool = mempool_create(NR_FLUSH_INFOS, 
flush_info_alloc,
+   flush_info_free, mddev);
+   if (!mddev->flush_pool) {
+   err = -ENOMEM;
+   goto abort;
+   }
+   }
+   if (mddev->flush_bio_pool == NULL) {
+   mddev->flush_bio_pool = mempool_create(NR_FLUSH_BIOS, 
flush_bio_alloc,
+   flush_bio_free, mddev);
+   if (!mddev->flush_bio_pool) {
+   err = -ENOMEM;
+   goto abort;
+   }
+   }
  
spin_lock(_lock);
pers = find_pers(mddev->level, mddev->clevel);
@@@ -5667,8 -5705,22 +5704,16 @@@
return 0;
  
  abort:
+   if (mddev->flush_bio_pool) {
+   mempool_destroy(mddev->flush_bio_pool);
+   mddev->flush_bio_pool = NULL;
+   }
+   if (mddev->flush_pool){
+   mempool_destroy(mddev->flush_pool);
+   mddev->flush_pool = NULL;
+   }
 -  if (mddev->bio_set) {
 -  bioset_free(mddev->bio_set);
 -  mddev->bio_set = NULL;
 -  }
 -  if (mddev->sync_set) {
 -  bioset_free(mddev->sync_set);
 -  mddev->sync_set = NULL;
 -  }
 +  bioset_exit(>bio_set);
 +  bioset_exit(>sync_set);
  
return err;
  }
@@@ -5881,8 -5933,22 +5926,16 @@@ void md_stop(struct mddev *mddev
 * This is called from dm-raid
 */
__md_stop(mddev);
+   if (mddev->flush_bio_pool) {
+   mempool_destroy(mddev->flush_bio_pool);
+   mddev->flush_bio_pool = NULL;
+   }
+   if (mddev->flush_pool) {
+   mempool_destroy(mddev->flush_pool);
+   mddev->flush_pool = NULL;
+   }
 -  if (mddev->bio_set) {
 -  bioset_free(mddev->bio_set);
 -  mddev->bio_set = NULL;
 -  }
 -  if (mddev->sync_set) {
 -  bioset_free(mddev->sync_set);
 -  mddev->sync_set = NULL;
 -  }
 +  bioset_exit(>bio_set);
 +  bioset_exit(>sync_set);
  }
  
  EXPORT_SYMBOL_GPL(md_stop);


pgpzrliHFLmRq.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the md tree with the block tree

2018-05-30 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/md.c

between commit:

  afeee514ce7f ("md: convert to bioset_init()/mempool_init()")

from the block tree and commit:

  5a409b4f56d5 ("MD: fix lock contention for flush bios")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/md.c
index fc692b7128bb,6b4e2f29fe4e..
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@@ -5498,16 -5518,34 +5519,32 @@@ int md_run(struct mddev *mddev
sysfs_notify_dirent_safe(rdev->sysfs_state);
}
  
 -  if (mddev->bio_set == NULL) {
 -  mddev->bio_set = bioset_create(BIO_POOL_SIZE, 0, 
BIOSET_NEED_BVECS);
 -  if (!mddev->bio_set)
 -  return -ENOMEM;
 +  if (!bioset_initialized(>bio_set)) {
 +  err = bioset_init(>bio_set, BIO_POOL_SIZE, 0, 
BIOSET_NEED_BVECS);
 +  if (err)
 +  return err;
}
 -  if (mddev->sync_set == NULL) {
 -  mddev->sync_set = bioset_create(BIO_POOL_SIZE, 0, 
BIOSET_NEED_BVECS);
 -  if (!mddev->sync_set) {
 -  err = -ENOMEM;
 +  if (!bioset_initialized(>sync_set)) {
 +  err = bioset_init(>sync_set, BIO_POOL_SIZE, 0, 
BIOSET_NEED_BVECS);
 +  if (err)
goto abort;
 -  }
}
+   if (mddev->flush_pool == NULL) {
+   mddev->flush_pool = mempool_create(NR_FLUSH_INFOS, 
flush_info_alloc,
+   flush_info_free, mddev);
+   if (!mddev->flush_pool) {
+   err = -ENOMEM;
+   goto abort;
+   }
+   }
+   if (mddev->flush_bio_pool == NULL) {
+   mddev->flush_bio_pool = mempool_create(NR_FLUSH_BIOS, 
flush_bio_alloc,
+   flush_bio_free, mddev);
+   if (!mddev->flush_bio_pool) {
+   err = -ENOMEM;
+   goto abort;
+   }
+   }
  
spin_lock(_lock);
pers = find_pers(mddev->level, mddev->clevel);
@@@ -5667,8 -5705,22 +5704,16 @@@
return 0;
  
  abort:
+   if (mddev->flush_bio_pool) {
+   mempool_destroy(mddev->flush_bio_pool);
+   mddev->flush_bio_pool = NULL;
+   }
+   if (mddev->flush_pool){
+   mempool_destroy(mddev->flush_pool);
+   mddev->flush_pool = NULL;
+   }
 -  if (mddev->bio_set) {
 -  bioset_free(mddev->bio_set);
 -  mddev->bio_set = NULL;
 -  }
 -  if (mddev->sync_set) {
 -  bioset_free(mddev->sync_set);
 -  mddev->sync_set = NULL;
 -  }
 +  bioset_exit(>bio_set);
 +  bioset_exit(>sync_set);
  
return err;
  }
@@@ -5881,8 -5933,22 +5926,16 @@@ void md_stop(struct mddev *mddev
 * This is called from dm-raid
 */
__md_stop(mddev);
+   if (mddev->flush_bio_pool) {
+   mempool_destroy(mddev->flush_bio_pool);
+   mddev->flush_bio_pool = NULL;
+   }
+   if (mddev->flush_pool) {
+   mempool_destroy(mddev->flush_pool);
+   mddev->flush_pool = NULL;
+   }
 -  if (mddev->bio_set) {
 -  bioset_free(mddev->bio_set);
 -  mddev->bio_set = NULL;
 -  }
 -  if (mddev->sync_set) {
 -  bioset_free(mddev->sync_set);
 -  mddev->sync_set = NULL;
 -  }
 +  bioset_exit(>bio_set);
 +  bioset_exit(>sync_set);
  }
  
  EXPORT_SYMBOL_GPL(md_stop);


pgpzrliHFLmRq.pgp
Description: OpenPGP digital signature


linux-next: manual merge of the md tree with the block tree

2017-08-28 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid5-ppl.c

between commit:

  74d46992e0d9 ("block: replace bi_bdev with a gendisk pointer and partitions 
index")

from the block tree and commit:

  ddc088238cd6 ("md: Runtime support for multiple ppls")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell
diff --cc drivers/md/raid5-ppl.c
index 1e237c40d6fa,a98ef172f8e8..
--- a/drivers/md/raid5-ppl.c
+++ b/drivers/md/raid5-ppl.c
@@@ -451,12 -456,25 +456,25 @@@ static void ppl_submit_iounit(struct pp
pplhdr->entries_count = cpu_to_le32(io->entries_count);
pplhdr->checksum = cpu_to_le32(~crc32c_le(~0, pplhdr, PPL_HEADER_SIZE));
  
+   /* Rewind the buffer if current PPL is larger then remaining space */
+   if (log->use_multippl &&
+   log->rdev->ppl.sector + log->rdev->ppl.size - log->next_io_sector <
+   (PPL_HEADER_SIZE + io->pp_size) >> 9)
+   log->next_io_sector = log->rdev->ppl.sector;
+ 
+ 
bio->bi_end_io = ppl_log_endio;
bio->bi_opf = REQ_OP_WRITE | REQ_FUA;
 -  bio->bi_bdev = log->rdev->bdev;
 +  bio_set_dev(bio, log->rdev->bdev);
-   bio->bi_iter.bi_sector = log->rdev->ppl.sector;
+   bio->bi_iter.bi_sector = log->next_io_sector;
bio_add_page(bio, io->header_page, PAGE_SIZE, 0);
  
+   pr_debug("%s: log->current_io_sector: %llu\n", __func__,
+   (unsigned long long)log->next_io_sector);
+ 
+   if (log->use_multippl)
+   log->next_io_sector += (PPL_HEADER_SIZE + io->pp_size) >> 9;
+ 
list_for_each_entry(sh, >stripe_list, log_list) {
/* entries for full stripe writes have no partial parity */
if (test_bit(STRIPE_FULL_WRITE, >state))


linux-next: manual merge of the md tree with the block tree

2017-08-28 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid5-ppl.c

between commit:

  74d46992e0d9 ("block: replace bi_bdev with a gendisk pointer and partitions 
index")

from the block tree and commit:

  ddc088238cd6 ("md: Runtime support for multiple ppls")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell
diff --cc drivers/md/raid5-ppl.c
index 1e237c40d6fa,a98ef172f8e8..
--- a/drivers/md/raid5-ppl.c
+++ b/drivers/md/raid5-ppl.c
@@@ -451,12 -456,25 +456,25 @@@ static void ppl_submit_iounit(struct pp
pplhdr->entries_count = cpu_to_le32(io->entries_count);
pplhdr->checksum = cpu_to_le32(~crc32c_le(~0, pplhdr, PPL_HEADER_SIZE));
  
+   /* Rewind the buffer if current PPL is larger then remaining space */
+   if (log->use_multippl &&
+   log->rdev->ppl.sector + log->rdev->ppl.size - log->next_io_sector <
+   (PPL_HEADER_SIZE + io->pp_size) >> 9)
+   log->next_io_sector = log->rdev->ppl.sector;
+ 
+ 
bio->bi_end_io = ppl_log_endio;
bio->bi_opf = REQ_OP_WRITE | REQ_FUA;
 -  bio->bi_bdev = log->rdev->bdev;
 +  bio_set_dev(bio, log->rdev->bdev);
-   bio->bi_iter.bi_sector = log->rdev->ppl.sector;
+   bio->bi_iter.bi_sector = log->next_io_sector;
bio_add_page(bio, io->header_page, PAGE_SIZE, 0);
  
+   pr_debug("%s: log->current_io_sector: %llu\n", __func__,
+   (unsigned long long)log->next_io_sector);
+ 
+   if (log->use_multippl)
+   log->next_io_sector += (PPL_HEADER_SIZE + io->pp_size) >> 9;
+ 
list_for_each_entry(sh, >stripe_list, log_list) {
/* entries for full stripe writes have no partial parity */
if (test_bit(STRIPE_FULL_WRITE, >state))


linux-next: manual merge of the md tree with the block tree

2017-06-12 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid5.c

between commit:

  4e4cbee93d56 ("block: switch bios to blk_status_t")

from the block tree and commit:

  66a8066d55fd ("md: simplify code with bio_io_error")

from the md tree.

I fixed it up (the latter removed code updated by the former) and can
carry the fix as necessary. This is now fixed as far as linux-next is
concerned, but any non trivial conflicts should be mentioned to your
upstream maintainer when your tree is submitted for merging.  You may
also want to consider cooperating with the maintainer of the conflicting
tree to minimise any particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell


linux-next: manual merge of the md tree with the block tree

2017-06-12 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid5.c

between commit:

  4e4cbee93d56 ("block: switch bios to blk_status_t")

from the block tree and commit:

  66a8066d55fd ("md: simplify code with bio_io_error")

from the md tree.

I fixed it up (the latter removed code updated by the former) and can
carry the fix as necessary. This is now fixed as far as linux-next is
concerned, but any non trivial conflicts should be mentioned to your
upstream maintainer when your tree is submitted for merging.  You may
also want to consider cooperating with the maintainer of the conflicting
tree to minimise any particularly complex conflicts.

-- 
Cheers,
Stephen Rothwell


linux-next: manual merge of the md tree with the block tree

2017-04-11 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the md tree got conflicts in:

  drivers/md/linear.c
  drivers/md/raid0.c

between commit:

  3deff1a70d59 ("md: support REQ_OP_WRITE_ZEROES")

from the block tree and commits:

  868f604b1de2 ("md/linear: improve bio splitting.")
  f00d7c85be9e ("md/raid0: fix up bio splitting.")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/linear.c
index 377a8a3672e3,f16316fbf658..
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@@ -257,46 -257,40 +257,41 @@@ static void linear_make_request(struct 
return;
}
  
-   do {
-   sector_t bio_sector = bio->bi_iter.bi_sector;
-   tmp_dev = which_dev(mddev, bio_sector);
-   start_sector = tmp_dev->end_sector - tmp_dev->rdev->sectors;
-   end_sector = tmp_dev->end_sector;
-   data_offset = tmp_dev->rdev->data_offset;
-   bio->bi_bdev = tmp_dev->rdev->bdev;
- 
-   if (unlikely(bio_sector >= end_sector ||
-bio_sector < start_sector))
-   goto out_of_bounds;
- 
-   if (unlikely(bio_end_sector(bio) > end_sector)) {
-   /* This bio crosses a device boundary, so we have to
-* split it.
-*/
-   split = bio_split(bio, end_sector - bio_sector,
- GFP_NOIO, fs_bio_set);
-   bio_chain(split, bio);
-   } else {
-   split = bio;
-   }
+   tmp_dev = which_dev(mddev, bio_sector);
+   start_sector = tmp_dev->end_sector - tmp_dev->rdev->sectors;
+   end_sector = tmp_dev->end_sector;
+   data_offset = tmp_dev->rdev->data_offset;
+ 
+   if (unlikely(bio_sector >= end_sector ||
+bio_sector < start_sector))
+   goto out_of_bounds;
+ 
+   if (unlikely(bio_end_sector(bio) > end_sector)) {
+   /* This bio crosses a device boundary, so we have to split it */
+   struct bio *split = bio_split(bio, end_sector - bio_sector,
+ GFP_NOIO, mddev->bio_set);
+   bio_chain(split, bio);
+   generic_make_request(bio);
+   bio = split;
+   }
  
-   split->bi_iter.bi_sector = split->bi_iter.bi_sector -
-   start_sector + data_offset;
- 
-   if (unlikely((bio_op(split) == REQ_OP_DISCARD) &&
-!blk_queue_discard(bdev_get_queue(split->bi_bdev {
-   /* Just ignore it */
-   bio_endio(split);
-   } else {
-   if (mddev->gendisk)
-   
trace_block_bio_remap(bdev_get_queue(split->bi_bdev),
- split, 
disk_devt(mddev->gendisk),
- bio_sector);
-   mddev_check_writesame(mddev, split);
-   mddev_check_write_zeroes(mddev, split);
-   generic_make_request(split);
-   }
-   } while (split != bio);
+   bio->bi_bdev = tmp_dev->rdev->bdev;
+   bio->bi_iter.bi_sector = bio->bi_iter.bi_sector -
+   start_sector + data_offset;
+ 
+   if (unlikely((bio_op(bio) == REQ_OP_DISCARD) &&
+!blk_queue_discard(bdev_get_queue(bio->bi_bdev {
+   /* Just ignore it */
+   bio_endio(bio);
+   } else {
+   if (mddev->gendisk)
+   trace_block_bio_remap(bdev_get_queue(bio->bi_bdev),
+ bio, disk_devt(mddev->gendisk),
+ bio_sector);
+   mddev_check_writesame(mddev, bio);
++  mddev_check_write_zeroes(mddev, bio);
+   generic_make_request(bio);
+   }
return;
  
  out_of_bounds:
diff --cc drivers/md/raid0.c
index ce7a6a56cf73,e777e48f55f6..
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@@ -469,46 -472,43 +473,44 @@@ static void raid0_make_request(struct m
return;
}
  
-   do {
-   sector_t bio_sector = bio->bi_iter.bi_sector;
-   sector_t sector = bio_sector;
-   unsigned chunk_sects = mddev->chunk_sectors;
+   bio_sector = bio->bi_iter.bi_sector;
+   sector = bio_sector;
+   chunk_sects = mddev->chunk_sectors;
  
-  

linux-next: manual merge of the md tree with the block tree

2017-04-11 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the md tree got conflicts in:

  drivers/md/linear.c
  drivers/md/raid0.c

between commit:

  3deff1a70d59 ("md: support REQ_OP_WRITE_ZEROES")

from the block tree and commits:

  868f604b1de2 ("md/linear: improve bio splitting.")
  f00d7c85be9e ("md/raid0: fix up bio splitting.")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/linear.c
index 377a8a3672e3,f16316fbf658..
--- a/drivers/md/linear.c
+++ b/drivers/md/linear.c
@@@ -257,46 -257,40 +257,41 @@@ static void linear_make_request(struct 
return;
}
  
-   do {
-   sector_t bio_sector = bio->bi_iter.bi_sector;
-   tmp_dev = which_dev(mddev, bio_sector);
-   start_sector = tmp_dev->end_sector - tmp_dev->rdev->sectors;
-   end_sector = tmp_dev->end_sector;
-   data_offset = tmp_dev->rdev->data_offset;
-   bio->bi_bdev = tmp_dev->rdev->bdev;
- 
-   if (unlikely(bio_sector >= end_sector ||
-bio_sector < start_sector))
-   goto out_of_bounds;
- 
-   if (unlikely(bio_end_sector(bio) > end_sector)) {
-   /* This bio crosses a device boundary, so we have to
-* split it.
-*/
-   split = bio_split(bio, end_sector - bio_sector,
- GFP_NOIO, fs_bio_set);
-   bio_chain(split, bio);
-   } else {
-   split = bio;
-   }
+   tmp_dev = which_dev(mddev, bio_sector);
+   start_sector = tmp_dev->end_sector - tmp_dev->rdev->sectors;
+   end_sector = tmp_dev->end_sector;
+   data_offset = tmp_dev->rdev->data_offset;
+ 
+   if (unlikely(bio_sector >= end_sector ||
+bio_sector < start_sector))
+   goto out_of_bounds;
+ 
+   if (unlikely(bio_end_sector(bio) > end_sector)) {
+   /* This bio crosses a device boundary, so we have to split it */
+   struct bio *split = bio_split(bio, end_sector - bio_sector,
+ GFP_NOIO, mddev->bio_set);
+   bio_chain(split, bio);
+   generic_make_request(bio);
+   bio = split;
+   }
  
-   split->bi_iter.bi_sector = split->bi_iter.bi_sector -
-   start_sector + data_offset;
- 
-   if (unlikely((bio_op(split) == REQ_OP_DISCARD) &&
-!blk_queue_discard(bdev_get_queue(split->bi_bdev {
-   /* Just ignore it */
-   bio_endio(split);
-   } else {
-   if (mddev->gendisk)
-   
trace_block_bio_remap(bdev_get_queue(split->bi_bdev),
- split, 
disk_devt(mddev->gendisk),
- bio_sector);
-   mddev_check_writesame(mddev, split);
-   mddev_check_write_zeroes(mddev, split);
-   generic_make_request(split);
-   }
-   } while (split != bio);
+   bio->bi_bdev = tmp_dev->rdev->bdev;
+   bio->bi_iter.bi_sector = bio->bi_iter.bi_sector -
+   start_sector + data_offset;
+ 
+   if (unlikely((bio_op(bio) == REQ_OP_DISCARD) &&
+!blk_queue_discard(bdev_get_queue(bio->bi_bdev {
+   /* Just ignore it */
+   bio_endio(bio);
+   } else {
+   if (mddev->gendisk)
+   trace_block_bio_remap(bdev_get_queue(bio->bi_bdev),
+ bio, disk_devt(mddev->gendisk),
+ bio_sector);
+   mddev_check_writesame(mddev, bio);
++  mddev_check_write_zeroes(mddev, bio);
+   generic_make_request(bio);
+   }
return;
  
  out_of_bounds:
diff --cc drivers/md/raid0.c
index ce7a6a56cf73,e777e48f55f6..
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@@ -469,46 -472,43 +473,44 @@@ static void raid0_make_request(struct m
return;
}
  
-   do {
-   sector_t bio_sector = bio->bi_iter.bi_sector;
-   sector_t sector = bio_sector;
-   unsigned chunk_sects = mddev->chunk_sectors;
+   bio_sector = bio->bi_iter.bi_sector;
+   sector = bio_sector;
+   chunk_sects = mddev->chunk_sectors;
  
-  

linux-next: manual merge of the md tree with the block tree

2017-04-09 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid5.c

between commit:

  48920ff2a5a9 ("block: remove the discard_zeroes_data flag")

from the block tree and commit:

  97d53438081e ("Revert "md/raid5: limit request size according to 
implementation limits"")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/raid5.c
index 2efdb0d67460,6036d5e41ddd..
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@@ -7253,17 -7361,13 +7358,9 @@@ static int raid5_run(struct mddev *mdde
stripe = (stripe | (stripe-1)) + 1;
mddev->queue->limits.discard_alignment = stripe;
mddev->queue->limits.discard_granularity = stripe;
 -  /*
 -   * unaligned part of discard request will be ignored, so can't
 -   * guarantee discard_zeroes_data
 -   */
 -  mddev->queue->limits.discard_zeroes_data = 0;
  
-   /*
-* We use 16-bit counter of active stripes in bi_phys_segments
-* (minus one for over-loaded initialization)
-*/
-   blk_queue_max_hw_sectors(mddev->queue, 0xfffe * STRIPE_SECTORS);
-   blk_queue_max_discard_sectors(mddev->queue,
- 0xfffe * STRIPE_SECTORS);
- 
blk_queue_max_write_same_sectors(mddev->queue, 0);
 +  blk_queue_max_write_zeroes_sectors(mddev->queue, 0);
  
rdev_for_each(rdev, mddev) {
disk_stack_limits(mddev->gendisk, rdev->bdev,


linux-next: manual merge of the md tree with the block tree

2017-04-09 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid5.c

between commit:

  48920ff2a5a9 ("block: remove the discard_zeroes_data flag")

from the block tree and commit:

  97d53438081e ("Revert "md/raid5: limit request size according to 
implementation limits"")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/raid5.c
index 2efdb0d67460,6036d5e41ddd..
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@@ -7253,17 -7361,13 +7358,9 @@@ static int raid5_run(struct mddev *mdde
stripe = (stripe | (stripe-1)) + 1;
mddev->queue->limits.discard_alignment = stripe;
mddev->queue->limits.discard_granularity = stripe;
 -  /*
 -   * unaligned part of discard request will be ignored, so can't
 -   * guarantee discard_zeroes_data
 -   */
 -  mddev->queue->limits.discard_zeroes_data = 0;
  
-   /*
-* We use 16-bit counter of active stripes in bi_phys_segments
-* (minus one for over-loaded initialization)
-*/
-   blk_queue_max_hw_sectors(mddev->queue, 0xfffe * STRIPE_SECTORS);
-   blk_queue_max_discard_sectors(mddev->queue,
- 0xfffe * STRIPE_SECTORS);
- 
blk_queue_max_write_same_sectors(mddev->queue, 0);
 +  blk_queue_max_write_zeroes_sectors(mddev->queue, 0);
  
rdev_for_each(rdev, mddev) {
disk_stack_limits(mddev->gendisk, rdev->bdev,


linux-next: manual merge of the md tree with the block tree

2017-04-09 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/md.h

between commit:

  3deff1a70d59 ("md: support REQ_OP_WRITE_ZEROES")

from the block tree and commits:

  d8e29fbc3bed ("md: move two macros into md.h")
  513e2faa0138 ("md: prepare for managing resync I/O pages in clean way")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/md.h
index 1e76d64ce180,0418b29945e7..
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@@ -710,10 -719,58 +719,65 @@@ static inline void mddev_check_writesam
mddev->queue->limits.max_write_same_sectors = 0;
  }
  
 +static inline void mddev_check_write_zeroes(struct mddev *mddev, struct bio 
*bio)
 +{
 +  if (bio_op(bio) == REQ_OP_WRITE_ZEROES &&
 +  !bdev_get_queue(bio->bi_bdev)->limits.max_write_zeroes_sectors)
 +  mddev->queue->limits.max_write_zeroes_sectors = 0;
 +}
++
+ /* Maximum size of each resync request */
+ #define RESYNC_BLOCK_SIZE (64*1024)
+ #define RESYNC_PAGES ((RESYNC_BLOCK_SIZE + PAGE_SIZE-1) / PAGE_SIZE)
+ 
+ /* for managing resync I/O pages */
+ struct resync_pages {
+   unsignedidx;/* for get/put page from the pool */
+   void*raid_bio;
+   struct page *pages[RESYNC_PAGES];
+ };
+ 
+ static inline int resync_alloc_pages(struct resync_pages *rp,
+gfp_t gfp_flags)
+ {
+   int i;
+ 
+   for (i = 0; i < RESYNC_PAGES; i++) {
+   rp->pages[i] = alloc_page(gfp_flags);
+   if (!rp->pages[i])
+   goto out_free;
+   }
+ 
+   return 0;
+ 
+ out_free:
+   while (--i >= 0)
+   put_page(rp->pages[i]);
+   return -ENOMEM;
+ }
+ 
+ static inline void resync_free_pages(struct resync_pages *rp)
+ {
+   int i;
+ 
+   for (i = 0; i < RESYNC_PAGES; i++)
+   put_page(rp->pages[i]);
+ }
+ 
+ static inline void resync_get_all_pages(struct resync_pages *rp)
+ {
+   int i;
+ 
+   for (i = 0; i < RESYNC_PAGES; i++)
+   get_page(rp->pages[i]);
+ }
+ 
+ static inline struct page *resync_fetch_page(struct resync_pages *rp,
+unsigned idx)
+ {
+   if (WARN_ON_ONCE(idx >= RESYNC_PAGES))
+   return NULL;
+   return rp->pages[idx];
+ }
+ 
  #endif /* _MD_MD_H */


linux-next: manual merge of the md tree with the block tree

2017-04-09 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/md.h

between commit:

  3deff1a70d59 ("md: support REQ_OP_WRITE_ZEROES")

from the block tree and commits:

  d8e29fbc3bed ("md: move two macros into md.h")
  513e2faa0138 ("md: prepare for managing resync I/O pages in clean way")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/md.h
index 1e76d64ce180,0418b29945e7..
--- a/drivers/md/md.h
+++ b/drivers/md/md.h
@@@ -710,10 -719,58 +719,65 @@@ static inline void mddev_check_writesam
mddev->queue->limits.max_write_same_sectors = 0;
  }
  
 +static inline void mddev_check_write_zeroes(struct mddev *mddev, struct bio 
*bio)
 +{
 +  if (bio_op(bio) == REQ_OP_WRITE_ZEROES &&
 +  !bdev_get_queue(bio->bi_bdev)->limits.max_write_zeroes_sectors)
 +  mddev->queue->limits.max_write_zeroes_sectors = 0;
 +}
++
+ /* Maximum size of each resync request */
+ #define RESYNC_BLOCK_SIZE (64*1024)
+ #define RESYNC_PAGES ((RESYNC_BLOCK_SIZE + PAGE_SIZE-1) / PAGE_SIZE)
+ 
+ /* for managing resync I/O pages */
+ struct resync_pages {
+   unsignedidx;/* for get/put page from the pool */
+   void*raid_bio;
+   struct page *pages[RESYNC_PAGES];
+ };
+ 
+ static inline int resync_alloc_pages(struct resync_pages *rp,
+gfp_t gfp_flags)
+ {
+   int i;
+ 
+   for (i = 0; i < RESYNC_PAGES; i++) {
+   rp->pages[i] = alloc_page(gfp_flags);
+   if (!rp->pages[i])
+   goto out_free;
+   }
+ 
+   return 0;
+ 
+ out_free:
+   while (--i >= 0)
+   put_page(rp->pages[i]);
+   return -ENOMEM;
+ }
+ 
+ static inline void resync_free_pages(struct resync_pages *rp)
+ {
+   int i;
+ 
+   for (i = 0; i < RESYNC_PAGES; i++)
+   put_page(rp->pages[i]);
+ }
+ 
+ static inline void resync_get_all_pages(struct resync_pages *rp)
+ {
+   int i;
+ 
+   for (i = 0; i < RESYNC_PAGES; i++)
+   get_page(rp->pages[i]);
+ }
+ 
+ static inline struct page *resync_fetch_page(struct resync_pages *rp,
+unsigned idx)
+ {
+   if (WARN_ON_ONCE(idx >= RESYNC_PAGES))
+   return NULL;
+   return rp->pages[idx];
+ }
+ 
  #endif /* _MD_MD_H */


linux-next: manual merge of the md tree with the block tree

2016-11-22 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/md.c

between commit:

  70fd76140a6c ("block,fs: use REQ_* flags directly")

from the block tree and commit:

  46533ff7fefb ("md: Use REQ_FAILFAST_* on metadata writes where appropriate")

from the md tree.

I fixed it up (I think - see below) and can carry the fix as necessary.
This is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/md.c
index f975cd08923d,c7894fbbd8e5..
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@@ -743,7 -765,12 +765,12 @@@ void md_super_write(struct mddev *mddev
bio_add_page(bio, page, size, 0);
bio->bi_private = rdev;
bio->bi_end_io = super_written;
-   bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_FUA;
+ 
+   if (test_bit(MD_FAILFAST_SUPPORTED, >flags) &&
+   test_bit(FailFast, >flags) &&
+   !test_bit(LastDev, >flags))
+   ff = MD_FAILFAST;
 -  bio_set_op_attrs(bio, REQ_OP_WRITE, WRITE_FLUSH_FUA | ff);
++  bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_FUA | ff;
  
atomic_inc(>pending_writes);
submit_bio(bio);


linux-next: manual merge of the md tree with the block tree

2016-11-22 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/md.c

between commit:

  70fd76140a6c ("block,fs: use REQ_* flags directly")

from the block tree and commit:

  46533ff7fefb ("md: Use REQ_FAILFAST_* on metadata writes where appropriate")

from the md tree.

I fixed it up (I think - see below) and can carry the fix as necessary.
This is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/md.c
index f975cd08923d,c7894fbbd8e5..
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@@ -743,7 -765,12 +765,12 @@@ void md_super_write(struct mddev *mddev
bio_add_page(bio, page, size, 0);
bio->bi_private = rdev;
bio->bi_end_io = super_written;
-   bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_FUA;
+ 
+   if (test_bit(MD_FAILFAST_SUPPORTED, >flags) &&
+   test_bit(FailFast, >flags) &&
+   !test_bit(LastDev, >flags))
+   ff = MD_FAILFAST;
 -  bio_set_op_attrs(bio, REQ_OP_WRITE, WRITE_FLUSH_FUA | ff);
++  bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH | REQ_FUA | ff;
  
atomic_inc(>pending_writes);
submit_bio(bio);


linux-next: manual merge of the md tree with the block tree

2016-11-21 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid5-cache.c

between commit:

  70fd76140a6c ("block,fs: use REQ_* flags directly")

from the block tree and commits:

  b4c625c67362 ("md/r5cache: r5cache recovery: part 1")
  3bddb7f8f264 ("md/r5cache: handle FLUSH and FUA")

from the md tree.

I fixed it up (I think - see below) and can carry the fix as necessary.
This is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/raid5-cache.c
index 2bca090cd64e,8cb79fc0eed9..
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@@ -231,6 -544,64 +544,64 @@@ static void r5l_log_endio(struct bio *b
  
if (log->need_cache_flush)
md_wakeup_thread(log->rdev->mddev->thread);
+ 
+   if (io->has_null_flush) {
+   struct bio *bi;
+ 
+   WARN_ON(bio_list_empty(>flush_barriers));
+   while ((bi = bio_list_pop(>flush_barriers)) != NULL) {
+   bio_endio(bi);
+   atomic_dec(>pending_stripe);
+   }
+   if (atomic_read(>pending_stripe) == 0)
+   __r5l_stripe_write_finished(io);
+   }
+ }
+ 
+ static void r5l_do_submit_io(struct r5l_log *log, struct r5l_io_unit *io)
+ {
+   unsigned long flags;
+ 
+   spin_lock_irqsave(>io_list_lock, flags);
+   __r5l_set_io_unit_state(io, IO_UNIT_IO_START);
+   spin_unlock_irqrestore(>io_list_lock, flags);
+ 
+   if (io->has_flush)
 -  bio_set_op_attrs(io->current_bio, REQ_OP_WRITE, WRITE_FLUSH);
++  io->current_bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
+   if (io->has_fua)
 -  bio_set_op_attrs(io->current_bio, REQ_OP_WRITE, WRITE_FUA);
++  io->current_bio->bi_opf = REQ_OP_WRITE | REQ_FUA;
+   submit_bio(io->current_bio);
+ 
+   if (!io->split_bio)
+   return;
+ 
+   if (io->has_flush)
 -  bio_set_op_attrs(io->split_bio, REQ_OP_WRITE, WRITE_FLUSH);
++  io->split_bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
+   if (io->has_fua)
 -  bio_set_op_attrs(io->split_bio, REQ_OP_WRITE, WRITE_FUA);
++  io->split_bio->bi_opf = REQ_OP_WRITE | REQ_FUA;
+   submit_bio(io->split_bio);
+ }
+ 
+ /* deferred io_unit will be dispatched here */
+ static void r5l_submit_io_async(struct work_struct *work)
+ {
+   struct r5l_log *log = container_of(work, struct r5l_log,
+  deferred_io_work);
+   struct r5l_io_unit *io = NULL;
+   unsigned long flags;
+ 
+   spin_lock_irqsave(>io_list_lock, flags);
+   if (!list_empty(>running_ios)) {
+   io = list_first_entry(>running_ios, struct r5l_io_unit,
+ log_sibling);
+   if (!io->io_deferred)
+   io = NULL;
+   else
+   io->io_deferred = 0;
+   }
+   spin_unlock_irqrestore(>io_list_lock, flags);
+   if (io)
+   r5l_do_submit_io(log, io);
  }
  
  static void r5l_submit_current_io(struct r5l_log *log)
@@@ -892,82 -1517,138 +1517,138 @@@ static int r5l_recovery_read_meta_block
return 0;
  }
  
- static int r5l_recovery_flush_one_stripe(struct r5l_log *log,
-struct r5l_recovery_ctx *ctx,
-sector_t stripe_sect,
-int *offset, sector_t *log_offset)
+ static void
+ r5l_recovery_create_empty_meta_block(struct r5l_log *log,
+struct page *page,
+sector_t pos, u64 seq)
  {
-   struct r5conf *conf = log->rdev->mddev->private;
-   struct stripe_head *sh;
-   struct r5l_payload_data_parity *payload;
-   int disk_index;
+   struct r5l_meta_block *mb;
+   u32 crc;
  
-   sh = raid5_get_active_stripe(conf, stripe_sect, 0, 0, 0);
-   while (1) {
-   payload = page_address(ctx->meta_page) + *offset;
+   mb = page_address(page);
+   clear_page(mb);
+   mb->magic = cpu_to_le32(R5LOG_MAGIC);
+   mb->version = R5LOG_VERSION;
+   mb->meta_size = cpu_to_le32(sizeof(struct r5l_meta_block));
+   mb->seq = cpu_to_le64(seq);
+   mb->position = cpu_to_le64(pos);
+   crc = crc32c_le(log->uuid_checksum, mb, PAGE_SIZE);
+   mb->checksum = cpu_to_le32(crc);
+ }
  
-   if (le16_to_cpu(payload->header.type) == R5LOG_PAYLOAD_DATA) {
-   raid5_compute_sector(conf,
-le64_to_cpu(payload->location), 0,
- 

linux-next: manual merge of the md tree with the block tree

2016-11-21 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid5-cache.c

between commit:

  70fd76140a6c ("block,fs: use REQ_* flags directly")

from the block tree and commits:

  b4c625c67362 ("md/r5cache: r5cache recovery: part 1")
  3bddb7f8f264 ("md/r5cache: handle FLUSH and FUA")

from the md tree.

I fixed it up (I think - see below) and can carry the fix as necessary.
This is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/raid5-cache.c
index 2bca090cd64e,8cb79fc0eed9..
--- a/drivers/md/raid5-cache.c
+++ b/drivers/md/raid5-cache.c
@@@ -231,6 -544,64 +544,64 @@@ static void r5l_log_endio(struct bio *b
  
if (log->need_cache_flush)
md_wakeup_thread(log->rdev->mddev->thread);
+ 
+   if (io->has_null_flush) {
+   struct bio *bi;
+ 
+   WARN_ON(bio_list_empty(>flush_barriers));
+   while ((bi = bio_list_pop(>flush_barriers)) != NULL) {
+   bio_endio(bi);
+   atomic_dec(>pending_stripe);
+   }
+   if (atomic_read(>pending_stripe) == 0)
+   __r5l_stripe_write_finished(io);
+   }
+ }
+ 
+ static void r5l_do_submit_io(struct r5l_log *log, struct r5l_io_unit *io)
+ {
+   unsigned long flags;
+ 
+   spin_lock_irqsave(>io_list_lock, flags);
+   __r5l_set_io_unit_state(io, IO_UNIT_IO_START);
+   spin_unlock_irqrestore(>io_list_lock, flags);
+ 
+   if (io->has_flush)
 -  bio_set_op_attrs(io->current_bio, REQ_OP_WRITE, WRITE_FLUSH);
++  io->current_bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
+   if (io->has_fua)
 -  bio_set_op_attrs(io->current_bio, REQ_OP_WRITE, WRITE_FUA);
++  io->current_bio->bi_opf = REQ_OP_WRITE | REQ_FUA;
+   submit_bio(io->current_bio);
+ 
+   if (!io->split_bio)
+   return;
+ 
+   if (io->has_flush)
 -  bio_set_op_attrs(io->split_bio, REQ_OP_WRITE, WRITE_FLUSH);
++  io->split_bio->bi_opf = REQ_OP_WRITE | REQ_PREFLUSH;
+   if (io->has_fua)
 -  bio_set_op_attrs(io->split_bio, REQ_OP_WRITE, WRITE_FUA);
++  io->split_bio->bi_opf = REQ_OP_WRITE | REQ_FUA;
+   submit_bio(io->split_bio);
+ }
+ 
+ /* deferred io_unit will be dispatched here */
+ static void r5l_submit_io_async(struct work_struct *work)
+ {
+   struct r5l_log *log = container_of(work, struct r5l_log,
+  deferred_io_work);
+   struct r5l_io_unit *io = NULL;
+   unsigned long flags;
+ 
+   spin_lock_irqsave(>io_list_lock, flags);
+   if (!list_empty(>running_ios)) {
+   io = list_first_entry(>running_ios, struct r5l_io_unit,
+ log_sibling);
+   if (!io->io_deferred)
+   io = NULL;
+   else
+   io->io_deferred = 0;
+   }
+   spin_unlock_irqrestore(>io_list_lock, flags);
+   if (io)
+   r5l_do_submit_io(log, io);
  }
  
  static void r5l_submit_current_io(struct r5l_log *log)
@@@ -892,82 -1517,138 +1517,138 @@@ static int r5l_recovery_read_meta_block
return 0;
  }
  
- static int r5l_recovery_flush_one_stripe(struct r5l_log *log,
-struct r5l_recovery_ctx *ctx,
-sector_t stripe_sect,
-int *offset, sector_t *log_offset)
+ static void
+ r5l_recovery_create_empty_meta_block(struct r5l_log *log,
+struct page *page,
+sector_t pos, u64 seq)
  {
-   struct r5conf *conf = log->rdev->mddev->private;
-   struct stripe_head *sh;
-   struct r5l_payload_data_parity *payload;
-   int disk_index;
+   struct r5l_meta_block *mb;
+   u32 crc;
  
-   sh = raid5_get_active_stripe(conf, stripe_sect, 0, 0, 0);
-   while (1) {
-   payload = page_address(ctx->meta_page) + *offset;
+   mb = page_address(page);
+   clear_page(mb);
+   mb->magic = cpu_to_le32(R5LOG_MAGIC);
+   mb->version = R5LOG_VERSION;
+   mb->meta_size = cpu_to_le32(sizeof(struct r5l_meta_block));
+   mb->seq = cpu_to_le64(seq);
+   mb->position = cpu_to_le64(pos);
+   crc = crc32c_le(log->uuid_checksum, mb, PAGE_SIZE);
+   mb->checksum = cpu_to_le32(crc);
+ }
  
-   if (le16_to_cpu(payload->header.type) == R5LOG_PAYLOAD_DATA) {
-   raid5_compute_sector(conf,
-le64_to_cpu(payload->location), 0,
- 

linux-next: manual merge of the md tree with the block tree

2016-06-13 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid1.c

between commit:

  796a5cf083c2 ("md: use bio op accessors")

from the block tree and commit:

  707a6a420ccf ("md/raid1: add rcu protection to rdev in fix_read_error")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/raid1.c
index 41d9c31da3b3,5027ef4752ac..
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@@ -2086,15 -2069,20 +2067,21 @@@ static void fix_read_error(struct r1con
 (!test_bit(Faulty, >flags) &&
  rdev->recovery_offset >= sect + s)) &&
is_badblock(rdev, sect, s,
-   _bad, _sectors) == 0 &&
-   sync_page_io(rdev, sect, s<<9,
-conf->tmppage, REQ_OP_READ, 0, false))
-   success = 1;
-   else {
-   d++;
-   if (d == conf->raid_disks * 2)
-   d = 0;
-   }
+   _bad, _sectors) == 0) {
+   atomic_inc(>nr_pending);
+   rcu_read_unlock();
+   if (sync_page_io(rdev, sect, s<<9,
 -   conf->tmppage, READ, false))
++   conf->tmppage, REQ_OP_READ, 0,
++   false))
+   success = 1;
+   rdev_dec_pending(rdev, mddev);
+   if (success)
+   break;
+   } else
+   rcu_read_unlock();
+   d++;
+   if (d == conf->raid_disks * 2)
+   d = 0;
} while (!success && d != read_disk);
  
if (!success) {


linux-next: manual merge of the md tree with the block tree

2016-06-13 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid1.c

between commit:

  796a5cf083c2 ("md: use bio op accessors")

from the block tree and commit:

  707a6a420ccf ("md/raid1: add rcu protection to rdev in fix_read_error")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/raid1.c
index 41d9c31da3b3,5027ef4752ac..
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@@ -2086,15 -2069,20 +2067,21 @@@ static void fix_read_error(struct r1con
 (!test_bit(Faulty, >flags) &&
  rdev->recovery_offset >= sect + s)) &&
is_badblock(rdev, sect, s,
-   _bad, _sectors) == 0 &&
-   sync_page_io(rdev, sect, s<<9,
-conf->tmppage, REQ_OP_READ, 0, false))
-   success = 1;
-   else {
-   d++;
-   if (d == conf->raid_disks * 2)
-   d = 0;
-   }
+   _bad, _sectors) == 0) {
+   atomic_inc(>nr_pending);
+   rcu_read_unlock();
+   if (sync_page_io(rdev, sect, s<<9,
 -   conf->tmppage, READ, false))
++   conf->tmppage, REQ_OP_READ, 0,
++   false))
+   success = 1;
+   rdev_dec_pending(rdev, mddev);
+   if (success)
+   break;
+   } else
+   rcu_read_unlock();
+   d++;
+   if (d == conf->raid_disks * 2)
+   d = 0;
} while (!success && d != read_disk);
  
if (!success) {


linux-next: manual merge of the md tree with the block tree

2016-06-13 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid10.c

between commit:

  796a5cf083c2 ("md: use bio op accessors")

from the block tree and commits:

  f90145f317ef ("md/raid10: add rcu protection to rdev access in 
raid10_sync_request."
  d094d6860b66 ("md/raid10: add rcu protection to rdev access during reshape.")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/raid10.c
index 26ae74fd0d01,8ee5d96e6a2d..
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@@ -3063,10 -3092,10 +3091,10 @@@ static sector_t raid10_sync_request(str
biolist = bio;
bio->bi_private = r10_bio;
bio->bi_end_io = end_sync_write;
 -  bio->bi_rw = WRITE;
 +  bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
bio->bi_iter.bi_sector = to_addr
-   + rdev->data_offset;
-   bio->bi_bdev = rdev->bdev;
+   + mrdev->data_offset;
+   bio->bi_bdev = mrdev->bdev;
atomic_inc(_bio->remaining);
} else
r10_bio->devs[1].bio->bi_end_io = NULL;
@@@ -3092,10 -3120,10 +3119,10 @@@
biolist = bio;
bio->bi_private = r10_bio;
bio->bi_end_io = end_sync_write;
 -  bio->bi_rw = WRITE;
 +  bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
bio->bi_iter.bi_sector = to_addr +
-   rdev->data_offset;
-   bio->bi_bdev = rdev->bdev;
+   mreplace->data_offset;
+   bio->bi_bdev = mreplace->bdev;
atomic_inc(_bio->remaining);
break;
}
@@@ -3212,16 -3251,18 +3250,18 @@@
biolist = bio;
bio->bi_private = r10_bio;
bio->bi_end_io = end_sync_read;
 -  bio->bi_rw = READ;
 +  bio_set_op_attrs(bio, REQ_OP_READ, 0);
-   bio->bi_iter.bi_sector = sector +
-   conf->mirrors[d].rdev->data_offset;
-   bio->bi_bdev = conf->mirrors[d].rdev->bdev;
+   bio->bi_iter.bi_sector = sector + rdev->data_offset;
+   bio->bi_bdev = rdev->bdev;
count++;
  
-   if (conf->mirrors[d].replacement == NULL ||
-   test_bit(Faulty,
->mirrors[d].replacement->flags))
+   rdev = rcu_dereference(conf->mirrors[d].replacement);
+   if (rdev == NULL || test_bit(Faulty, >flags)) {
+   rcu_read_unlock();
continue;
+   }
+   atomic_inc(>nr_pending);
+   rcu_read_unlock();
  
/* Need to set up for writing to the replacement */
bio = r10_bio->devs[i].repl_bio;
@@@ -3234,10 -3274,9 +3273,9 @@@
biolist = bio;
bio->bi_private = r10_bio;
bio->bi_end_io = end_sync_write;
 -  bio->bi_rw = WRITE;
 +  bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
-   bio->bi_iter.bi_sector = sector +
-   conf->mirrors[d].replacement->data_offset;
-   bio->bi_bdev = conf->mirrors[d].replacement->bdev;
+   bio->bi_iter.bi_sector = sector + rdev->data_offset;
+   bio->bi_bdev = rdev->bdev;
count++;
}
  
@@@ -4521,7 -4569,9 +4568,9 @@@ static int handle_reshape_read_error(st
   addr,
   s << 9,
   bvec[idx].bv_page,
 - READ, false);
 + REQ_OP_READ, 0, 

linux-next: manual merge of the md tree with the block tree

2016-06-13 Thread Stephen Rothwell
Hi Shaohua,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid10.c

between commit:

  796a5cf083c2 ("md: use bio op accessors")

from the block tree and commits:

  f90145f317ef ("md/raid10: add rcu protection to rdev access in 
raid10_sync_request."
  d094d6860b66 ("md/raid10: add rcu protection to rdev access during reshape.")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/raid10.c
index 26ae74fd0d01,8ee5d96e6a2d..
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@@ -3063,10 -3092,10 +3091,10 @@@ static sector_t raid10_sync_request(str
biolist = bio;
bio->bi_private = r10_bio;
bio->bi_end_io = end_sync_write;
 -  bio->bi_rw = WRITE;
 +  bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
bio->bi_iter.bi_sector = to_addr
-   + rdev->data_offset;
-   bio->bi_bdev = rdev->bdev;
+   + mrdev->data_offset;
+   bio->bi_bdev = mrdev->bdev;
atomic_inc(_bio->remaining);
} else
r10_bio->devs[1].bio->bi_end_io = NULL;
@@@ -3092,10 -3120,10 +3119,10 @@@
biolist = bio;
bio->bi_private = r10_bio;
bio->bi_end_io = end_sync_write;
 -  bio->bi_rw = WRITE;
 +  bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
bio->bi_iter.bi_sector = to_addr +
-   rdev->data_offset;
-   bio->bi_bdev = rdev->bdev;
+   mreplace->data_offset;
+   bio->bi_bdev = mreplace->bdev;
atomic_inc(_bio->remaining);
break;
}
@@@ -3212,16 -3251,18 +3250,18 @@@
biolist = bio;
bio->bi_private = r10_bio;
bio->bi_end_io = end_sync_read;
 -  bio->bi_rw = READ;
 +  bio_set_op_attrs(bio, REQ_OP_READ, 0);
-   bio->bi_iter.bi_sector = sector +
-   conf->mirrors[d].rdev->data_offset;
-   bio->bi_bdev = conf->mirrors[d].rdev->bdev;
+   bio->bi_iter.bi_sector = sector + rdev->data_offset;
+   bio->bi_bdev = rdev->bdev;
count++;
  
-   if (conf->mirrors[d].replacement == NULL ||
-   test_bit(Faulty,
->mirrors[d].replacement->flags))
+   rdev = rcu_dereference(conf->mirrors[d].replacement);
+   if (rdev == NULL || test_bit(Faulty, >flags)) {
+   rcu_read_unlock();
continue;
+   }
+   atomic_inc(>nr_pending);
+   rcu_read_unlock();
  
/* Need to set up for writing to the replacement */
bio = r10_bio->devs[i].repl_bio;
@@@ -3234,10 -3274,9 +3273,9 @@@
biolist = bio;
bio->bi_private = r10_bio;
bio->bi_end_io = end_sync_write;
 -  bio->bi_rw = WRITE;
 +  bio_set_op_attrs(bio, REQ_OP_WRITE, 0);
-   bio->bi_iter.bi_sector = sector +
-   conf->mirrors[d].replacement->data_offset;
-   bio->bi_bdev = conf->mirrors[d].replacement->bdev;
+   bio->bi_iter.bi_sector = sector + rdev->data_offset;
+   bio->bi_bdev = rdev->bdev;
count++;
}
  
@@@ -4521,7 -4569,9 +4568,9 @@@ static int handle_reshape_read_error(st
   addr,
   s << 9,
   bvec[idx].bv_page,
 - READ, false);
 + REQ_OP_READ, 0, 

linux-next: manual merge of the md tree with the block tree

2015-08-16 Thread Stephen Rothwell
Hi Neil,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid5.c

between commit:

  4246a0b63bd8 ("block: add a bi_error field to struct bio")
  8ae126660fdd ("block: kill merge_bvec_fn() completely")

from the block tree and commit:

  1722781be955 ("md/raid5: switch to use conf->chunk_sectors in place of 
mddev->chunk_sectors where possible")
  4273c3f9d668 ("md/raid5: use bio_list for the list of bios to return.")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/md/raid5.c
index b29e89cb815b,4195064460d0..
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@@ -233,8 -230,7 +230,7 @@@ static void return_io(struct bio_list *
bi->bi_iter.bi_size = 0;
trace_block_bio_complete(bdev_get_queue(bi->bi_bdev),
 bi, 0);
 -  bio_endio(bi, 0);
 +  bio_endio(bi);
-   bi = return_bi;
}
  }
  
@@@ -3110,12 -3107,10 +3105,11 @@@ handle_failed_stripe(struct r5conf *con
while (bi && bi->bi_iter.bi_sector <
sh->dev[i].sector + STRIPE_SECTORS) {
struct bio *nextbi = r5_next_bio(bi, sh->dev[i].sector);
 -  clear_bit(BIO_UPTODATE, >bi_flags);
 +
 +  bi->bi_error = -EIO;
if (!raid5_dec_bi_active_stripes(bi)) {
md_write_end(conf->mddev);
-   bi->bi_next = *return_bi;
-   *return_bi = bi;
+   bio_list_add(return_bi, bi);
}
bi = nextbi;
}
@@@ -3135,12 -3130,10 +3129,11 @@@
while (bi && bi->bi_iter.bi_sector <
   sh->dev[i].sector + STRIPE_SECTORS) {
struct bio *bi2 = r5_next_bio(bi, sh->dev[i].sector);
 -  clear_bit(BIO_UPTODATE, >bi_flags);
 +
 +  bi->bi_error = -EIO;
if (!raid5_dec_bi_active_stripes(bi)) {
md_write_end(conf->mddev);
-   bi->bi_next = *return_bi;
-   *return_bi = bi;
+   bio_list_add(return_bi, bi);
}
bi = bi2;
}
@@@ -3161,12 -3154,9 +3154,10 @@@
   sh->dev[i].sector + STRIPE_SECTORS) {
struct bio *nextbi =
r5_next_bio(bi, sh->dev[i].sector);
 -  clear_bit(BIO_UPTODATE, >bi_flags);
 +
 +  bi->bi_error = -EIO;
-   if (!raid5_dec_bi_active_stripes(bi)) {
-   bi->bi_next = *return_bi;
-   *return_bi = bi;
-   }
+   if (!raid5_dec_bi_active_stripes(bi))
+   bio_list_add(return_bi, bi);
bi = nextbi;
}
}
@@@ -4670,14 -4667,43 +4668,14 @@@ static int raid5_congested(struct mdde
return 0;
  }
  
 -/* We want read requests to align with chunks where possible,
 - * but write requests don't need to.
 - */
 -static int raid5_mergeable_bvec(struct mddev *mddev,
 -  struct bvec_merge_data *bvm,
 -  struct bio_vec *biovec)
 -{
 -  struct r5conf *conf = mddev->private;
 -  sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
 -  int max;
 -  unsigned int chunk_sectors;
 -  unsigned int bio_sectors = bvm->bi_size >> 9;
 -
 -  /*
 -   * always allow writes to be mergeable, read as well if array
 -   * is degraded as we'll go through stripe cache anyway.
 -   */
 -  if ((bvm->bi_rw & 1) == WRITE || mddev->degraded)
 -  return biovec->bv_len;
 -
 -  chunk_sectors = min(conf->chunk_sectors, conf->prev_chunk_sectors);
 -  max =  (chunk_sectors - ((sector & (chunk_sectors - 1)) + bio_sectors)) 
<< 9;
 -  if (max < 0) max = 0;
 -  if (max <= biovec->bv_len && bio_sectors == 0)
 -  return biovec->bv_len;
 -  else
 -  return max;
 -}
 -
  static int in_chunk_boundary(struct mddev *mddev, struct bio *bio)
  {
+   struct r5conf *conf = mddev->private;
sector_t sector = bio->bi_iter.bi_sector + get_start_sect(bio->bi_bdev);
-   unsigned int chunk_sectors = mddev->chunk_sectors;
+   unsigned int chunk_sectors;
unsigned int bio_sectors = bio_sectors(bio);
  
-   if (mddev->new_chunk_sectors < mddev->chunk_sectors)
-   

linux-next: manual merge of the md tree with the block tree

2015-08-16 Thread Stephen Rothwell
Hi Neil,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid10.c

between commit:

  4246a0b63bd8 ("block: add a bi_error field to struct bio")

from the block tree and commit:

  90421c7cfde6 ("md/raid10: ensure device failure recorded before write request 
returns.")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/md/raid10.c
index b0fce2ebf7ad,a14c304aa751..
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@@ -2633,7 -2750,9 +2635,8 @@@ static void handle_write_completed(stru
r10_bio->devs[m].addr,
r10_bio->sectors, 0);
rdev_dec_pending(rdev, conf->mddev);
 -  } else if (bio != NULL &&
 - !test_bit(BIO_UPTODATE, >bi_flags)) {
 +  } else if (bio != NULL && bio->bi_error) {
+   fail = true;
if (!narrow_write_error(r10_bio, m)) {
md_error(conf->mddev, rdev);
set_bit(R10BIO_Degraded,
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: manual merge of the md tree with the block tree

2015-08-16 Thread Stephen Rothwell
Hi Neil,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid0.c

between commit:

  8ae126660fdd ("block: kill merge_bvec_fn() completely")

from the block tree and commit:

  927d881980b7 ("md/raid0: update queue parameter in a safer location.")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/md/raid0.c
index 59cda501a224,4a13c3cb940b..
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@@ -188,10 -203,9 +203,6 @@@ static int create_strip_zones(struct md
}
dev[j] = rdev1;
  
-   if (mddev->queue)
-   disk_stack_limits(mddev->gendisk, rdev1->bdev,
- rdev1->data_offset << 9);
 -  if (rdev1->bdev->bd_disk->queue->merge_bvec_fn)
 -  conf->has_merge_bvec = 1;
--
if (!smallest || (rdev1->sectors < smallest->sectors))
smallest = rdev1;
cnt++;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: manual merge of the md tree with the block tree

2015-08-16 Thread Stephen Rothwell
Hi Neil,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid10.c

between commit:

  4246a0b63bd8 (block: add a bi_error field to struct bio)

from the block tree and commit:

  90421c7cfde6 (md/raid10: ensure device failure recorded before write request 
returns.)

from the md tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/md/raid10.c
index b0fce2ebf7ad,a14c304aa751..
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@@ -2633,7 -2750,9 +2635,8 @@@ static void handle_write_completed(stru
r10_bio-devs[m].addr,
r10_bio-sectors, 0);
rdev_dec_pending(rdev, conf-mddev);
 -  } else if (bio != NULL 
 - !test_bit(BIO_UPTODATE, bio-bi_flags)) {
 +  } else if (bio != NULL  bio-bi_error) {
+   fail = true;
if (!narrow_write_error(r10_bio, m)) {
md_error(conf-mddev, rdev);
set_bit(R10BIO_Degraded,
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: manual merge of the md tree with the block tree

2015-08-16 Thread Stephen Rothwell
Hi Neil,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid0.c

between commit:

  8ae126660fdd (block: kill merge_bvec_fn() completely)

from the block tree and commit:

  927d881980b7 (md/raid0: update queue parameter in a safer location.)

from the md tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/md/raid0.c
index 59cda501a224,4a13c3cb940b..
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@@ -188,10 -203,9 +203,6 @@@ static int create_strip_zones(struct md
}
dev[j] = rdev1;
  
-   if (mddev-queue)
-   disk_stack_limits(mddev-gendisk, rdev1-bdev,
- rdev1-data_offset  9);
 -  if (rdev1-bdev-bd_disk-queue-merge_bvec_fn)
 -  conf-has_merge_bvec = 1;
--
if (!smallest || (rdev1-sectors  smallest-sectors))
smallest = rdev1;
cnt++;
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


linux-next: manual merge of the md tree with the block tree

2015-08-16 Thread Stephen Rothwell
Hi Neil,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/raid5.c

between commit:

  4246a0b63bd8 (block: add a bi_error field to struct bio)
  8ae126660fdd (block: kill merge_bvec_fn() completely)

from the block tree and commit:

  1722781be955 (md/raid5: switch to use conf-chunk_sectors in place of 
mddev-chunk_sectors where possible)
  4273c3f9d668 (md/raid5: use bio_list for the list of bios to return.)

from the md tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/md/raid5.c
index b29e89cb815b,4195064460d0..
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@@ -233,8 -230,7 +230,7 @@@ static void return_io(struct bio_list *
bi-bi_iter.bi_size = 0;
trace_block_bio_complete(bdev_get_queue(bi-bi_bdev),
 bi, 0);
 -  bio_endio(bi, 0);
 +  bio_endio(bi);
-   bi = return_bi;
}
  }
  
@@@ -3110,12 -3107,10 +3105,11 @@@ handle_failed_stripe(struct r5conf *con
while (bi  bi-bi_iter.bi_sector 
sh-dev[i].sector + STRIPE_SECTORS) {
struct bio *nextbi = r5_next_bio(bi, sh-dev[i].sector);
 -  clear_bit(BIO_UPTODATE, bi-bi_flags);
 +
 +  bi-bi_error = -EIO;
if (!raid5_dec_bi_active_stripes(bi)) {
md_write_end(conf-mddev);
-   bi-bi_next = *return_bi;
-   *return_bi = bi;
+   bio_list_add(return_bi, bi);
}
bi = nextbi;
}
@@@ -3135,12 -3130,10 +3129,11 @@@
while (bi  bi-bi_iter.bi_sector 
   sh-dev[i].sector + STRIPE_SECTORS) {
struct bio *bi2 = r5_next_bio(bi, sh-dev[i].sector);
 -  clear_bit(BIO_UPTODATE, bi-bi_flags);
 +
 +  bi-bi_error = -EIO;
if (!raid5_dec_bi_active_stripes(bi)) {
md_write_end(conf-mddev);
-   bi-bi_next = *return_bi;
-   *return_bi = bi;
+   bio_list_add(return_bi, bi);
}
bi = bi2;
}
@@@ -3161,12 -3154,9 +3154,10 @@@
   sh-dev[i].sector + STRIPE_SECTORS) {
struct bio *nextbi =
r5_next_bio(bi, sh-dev[i].sector);
 -  clear_bit(BIO_UPTODATE, bi-bi_flags);
 +
 +  bi-bi_error = -EIO;
-   if (!raid5_dec_bi_active_stripes(bi)) {
-   bi-bi_next = *return_bi;
-   *return_bi = bi;
-   }
+   if (!raid5_dec_bi_active_stripes(bi))
+   bio_list_add(return_bi, bi);
bi = nextbi;
}
}
@@@ -4670,14 -4667,43 +4668,14 @@@ static int raid5_congested(struct mdde
return 0;
  }
  
 -/* We want read requests to align with chunks where possible,
 - * but write requests don't need to.
 - */
 -static int raid5_mergeable_bvec(struct mddev *mddev,
 -  struct bvec_merge_data *bvm,
 -  struct bio_vec *biovec)
 -{
 -  struct r5conf *conf = mddev-private;
 -  sector_t sector = bvm-bi_sector + get_start_sect(bvm-bi_bdev);
 -  int max;
 -  unsigned int chunk_sectors;
 -  unsigned int bio_sectors = bvm-bi_size  9;
 -
 -  /*
 -   * always allow writes to be mergeable, read as well if array
 -   * is degraded as we'll go through stripe cache anyway.
 -   */
 -  if ((bvm-bi_rw  1) == WRITE || mddev-degraded)
 -  return biovec-bv_len;
 -
 -  chunk_sectors = min(conf-chunk_sectors, conf-prev_chunk_sectors);
 -  max =  (chunk_sectors - ((sector  (chunk_sectors - 1)) + bio_sectors)) 
 9;
 -  if (max  0) max = 0;
 -  if (max = biovec-bv_len  bio_sectors == 0)
 -  return biovec-bv_len;
 -  else
 -  return max;
 -}
 -
  static int in_chunk_boundary(struct mddev *mddev, struct bio *bio)
  {
+   struct r5conf *conf = mddev-private;
sector_t sector = bio-bi_iter.bi_sector + get_start_sect(bio-bi_bdev);
-   unsigned int chunk_sectors = mddev-chunk_sectors;
+   unsigned int chunk_sectors;
unsigned int bio_sectors = bio_sectors(bio);
  
-   if (mddev-new_chunk_sectors  mddev-chunk_sectors)
-   chunk_sectors = mddev-new_chunk_sectors;
+   

Re: linux-next: manual merge of the md tree with the block tree

2014-01-14 Thread NeilBrown
On Wed, 15 Jan 2014 15:07:43 +1100 Stephen Rothwell 
wrote:

> Hi Neil,
> 
> Today's linux-next merge of the md tree got a conflict in
> drivers/md/raid10.c between commit 4f024f3797c4 ("block: Abstract out
> bvec iterator") from the block tree and commit b50c259e25d9 ("md/raid10:
> fix two bugs in handling of known-bad-blocks") from the md tree.
> 
> I fixed it up (see below) and can carry the fix as necessary (no action
> is required).
> 

Thanks Stephen.
Those md fixes are now on their way to Linus (I'm hoping for 3.13 inclusion,
I might be lucky).  Good they they are easy to resolve!

Thanks,
NeilBrown


signature.asc
Description: PGP signature


linux-next: manual merge of the md tree with the block tree

2014-01-14 Thread Stephen Rothwell
Hi Neil,

Today's linux-next merge of the md tree got a conflict in
drivers/md/raid10.c between commit 4f024f3797c4 ("block: Abstract out
bvec iterator") from the block tree and commit b50c259e25d9 ("md/raid10:
fix two bugs in handling of known-bad-blocks") from the md tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/md/raid10.c
index 6d43d88657aa,8d39d63281b9..
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@@ -1256,8 -1319,8 +1256,8 @@@ read_again
/* Could not read all from this device, so we will
 * need another r10_bio.
 */
-   sectors_handled = (r10_bio->sectors + max_sectors
+   sectors_handled = (r10_bio->sector + max_sectors
 - - bio->bi_sector);
 + - bio->bi_iter.bi_sector);
r10_bio->sectors = max_sectors;
spin_lock_irq(>device_lock);
if (bio->bi_phys_segments == 0)


pgp0mUzDMyGJx.pgp
Description: PGP signature


linux-next: manual merge of the md tree with the block tree

2014-01-14 Thread Stephen Rothwell
Hi Neil,

Today's linux-next merge of the md tree got a conflict in
drivers/md/raid10.c between commit 4f024f3797c4 (block: Abstract out
bvec iterator) from the block tree and commit b50c259e25d9 (md/raid10:
fix two bugs in handling of known-bad-blocks) from the md tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/md/raid10.c
index 6d43d88657aa,8d39d63281b9..
--- a/drivers/md/raid10.c
+++ b/drivers/md/raid10.c
@@@ -1256,8 -1319,8 +1256,8 @@@ read_again
/* Could not read all from this device, so we will
 * need another r10_bio.
 */
-   sectors_handled = (r10_bio-sectors + max_sectors
+   sectors_handled = (r10_bio-sector + max_sectors
 - - bio-bi_sector);
 + - bio-bi_iter.bi_sector);
r10_bio-sectors = max_sectors;
spin_lock_irq(conf-device_lock);
if (bio-bi_phys_segments == 0)


pgp0mUzDMyGJx.pgp
Description: PGP signature


Re: linux-next: manual merge of the md tree with the block tree

2014-01-14 Thread NeilBrown
On Wed, 15 Jan 2014 15:07:43 +1100 Stephen Rothwell s...@canb.auug.org.au
wrote:

 Hi Neil,
 
 Today's linux-next merge of the md tree got a conflict in
 drivers/md/raid10.c between commit 4f024f3797c4 (block: Abstract out
 bvec iterator) from the block tree and commit b50c259e25d9 (md/raid10:
 fix two bugs in handling of known-bad-blocks) from the md tree.
 
 I fixed it up (see below) and can carry the fix as necessary (no action
 is required).
 

Thanks Stephen.
Those md fixes are now on their way to Linus (I'm hoping for 3.13 inclusion,
I might be lucky).  Good they they are easy to resolve!

Thanks,
NeilBrown


signature.asc
Description: PGP signature


linux-next: manual merge of the md tree with the block tree

2012-09-20 Thread Stephen Rothwell
Hi Neil,

Today's linux-next merge of the md tree got a conflict in
drivers/md/raid0.c between commit 4363ac7c13a9 ("block: Implement support
for WRITE SAME") from the block tree and commit c9264cda8f11 ("md: raid 0
supports TRIM") from the md tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/md/raid0.c
index a9e4fa9,1a8e5e3..000
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@@ -422,7 -431,7 +431,8 @@@ static int raid0_run(struct mddev *mdde
if (md_check_no_bitmap(mddev))
return -EINVAL;
blk_queue_max_hw_sectors(mddev->queue, mddev->chunk_sectors);
 +  blk_queue_max_write_same_sectors(mddev->queue, mddev->chunk_sectors);
+   blk_queue_max_discard_sectors(mddev->queue, mddev->chunk_sectors);
  
/* if private is not null, we are here after takeover */
if (mddev->private == NULL) {


pgpWAvXrKom72.pgp
Description: PGP signature


linux-next: manual merge of the md tree with the block tree

2012-09-20 Thread Stephen Rothwell
Hi Neil,

Today's linux-next merge of the md tree got a conflict in
drivers/md/raid0.c between commit 4363ac7c13a9 (block: Implement support
for WRITE SAME) from the block tree and commit c9264cda8f11 (md: raid 0
supports TRIM) from the md tree.

I fixed it up (see below) and can carry the fix as necessary (no action
is required).

-- 
Cheers,
Stephen Rothwells...@canb.auug.org.au

diff --cc drivers/md/raid0.c
index a9e4fa9,1a8e5e3..000
--- a/drivers/md/raid0.c
+++ b/drivers/md/raid0.c
@@@ -422,7 -431,7 +431,8 @@@ static int raid0_run(struct mddev *mdde
if (md_check_no_bitmap(mddev))
return -EINVAL;
blk_queue_max_hw_sectors(mddev-queue, mddev-chunk_sectors);
 +  blk_queue_max_write_same_sectors(mddev-queue, mddev-chunk_sectors);
+   blk_queue_max_discard_sectors(mddev-queue, mddev-chunk_sectors);
  
/* if private is not null, we are here after takeover */
if (mddev-private == NULL) {


pgpWAvXrKom72.pgp
Description: PGP signature