dm io: fix panic on large request

2007-07-21 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=80b16c192e469541263d6bfd9177662ceb632ecc
Commit: 80b16c192e469541263d6bfd9177662ceb632ecc
Parent: d3fec424b23c47686efcf3f2004c3f1c1cee4d9c
Author: Milan Broz [EMAIL PROTECTED]
AuthorDate: Sat Jul 21 04:37:27 2007 -0700
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Sat Jul 21 17:49:14 2007 -0700

dm io: fix panic on large request

Flush workqueue before releasing bioset and mopools in dm-crypt.  There can
be finished but not yet released request.

Call chain causing oops:
  run workqueue
dec_pending
  bio_endio(...);
remove device request - remove mempool
  mempool_free(io, cc-io_pool);

This usually happens when cryptsetup create temporary
luks mapping in the beggining of crypt device activation.

When dm-core calls destructor crypt_dtr, no new request
are possible.

Signed-off-by: Milan Broz [EMAIL PROTECTED]
Cc: Chuck Ebbert [EMAIL PROTECTED]
Cc: Patrick McHardy [EMAIL PROTECTED]
Acked-by: Alasdair G Kergon [EMAIL PROTECTED]
Cc: Christophe Saout [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Signed-off-by: Andrew Morton [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 drivers/md/dm-crypt.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index ba952a0..bdc52d6 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -920,6 +920,8 @@ static void crypt_dtr(struct dm_target *ti)
 {
struct crypt_config *cc = (struct crypt_config *) ti-private;
 
+   flush_workqueue(_kcryptd_workqueue);
+
bioset_free(cc-bs);
mempool_destroy(cc-page_pool);
mempool_destroy(cc-io_pool);
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


dm io: fix panic on large request

2007-07-12 Thread Linux Kernel Mailing List
Gitweb: 
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=596f138eede0c113aa655937c8be85fc15ccd61c
Commit: 596f138eede0c113aa655937c8be85fc15ccd61c
Parent: c95bc206da4bc9838bad826883f8f461a972e441
Author: Jun'ichi Nomura [EMAIL PROTECTED]
AuthorDate: Thu Jul 12 17:27:45 2007 +0100
Committer:  Linus Torvalds [EMAIL PROTECTED]
CommitDate: Thu Jul 12 15:01:08 2007 -0700

dm io: fix panic on large request

bio_alloc_bioset() will return NULL if 'num_vecs' is too large.
Use bio_get_nr_vecs() to get estimation of maximum number.

Cc: [EMAIL PROTECTED]
Signed-off-by: Jun'ichi Nomura [EMAIL PROTECTED]
Signed-off-by: Alasdair G Kergon [EMAIL PROTECTED]
Signed-off-by: Linus Torvalds [EMAIL PROTECTED]
---
 drivers/md/dm-io.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index 352c6fb..f3a7724 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -293,7 +293,10 @@ static void do_region(int rw, unsigned int region, struct 
io_region *where,
 * bvec for bio_get/set_region() and decrement bi_max_vecs
 * to hide it from bio_add_page().
 */
-   num_bvecs = (remaining / (PAGE_SIZE  SECTOR_SHIFT)) + 2;
+   num_bvecs = dm_sector_div_up(remaining,
+(PAGE_SIZE  SECTOR_SHIFT));
+   num_bvecs = 1 + min_t(int, bio_get_nr_vecs(where-bdev),
+ num_bvecs);
bio = bio_alloc_bioset(GFP_NOIO, num_bvecs, io-client-bios);
bio-bi_sector = where-sector + (where-count - remaining);
bio-bi_bdev = where-bdev;
-
To unsubscribe from this list: send the line unsubscribe git-commits-head in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html