public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sg: disable interrupts inside sg_copy_buffer
@ 2008-09-11 14:52 FUJITA Tomonori
  2008-09-11 16:33 ` Jens Axboe
  0 siblings, 1 reply; 8+ messages in thread
From: FUJITA Tomonori @ 2008-09-11 14:52 UTC (permalink / raw)
  To: linux-scsi; +Cc: James.Bottomley, jens.axboe

The callers of sg_copy_buffer must disable interrupts before calling
it (since it uses kmap_atomic). Some callers use it on
interrupt-disabled code but some need to take the trouble to disable
interrupts just for this. No wonder they forget about it and we hit a
bug like:

http://bugzilla.kernel.org/show_bug.cgi?id=11529

James said that it might be better to disable interrupts inside the
function rather than risk the callers getting it wrong.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
---
 lib/scatterlist.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/lib/scatterlist.c b/lib/scatterlist.c
index 876ba6d..dd52cd5 100644
--- a/lib/scatterlist.c
+++ b/lib/scatterlist.c
@@ -422,6 +422,9 @@ static size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents,
 {
 	unsigned int offset = 0;
 	struct sg_mapping_iter miter;
+	unsigned long flags;
+
+	local_irq_save(flags);
 
 	sg_miter_start(&miter, sgl, nents, SG_MITER_ATOMIC);
 
@@ -442,6 +445,8 @@ static size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents,
 
 	sg_miter_stop(&miter);
 
+	local_irq_restore(flags);
+
 	return offset;
 }
 
-- 
1.5.4.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-09-12 14:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-11 14:52 [PATCH] sg: disable interrupts inside sg_copy_buffer FUJITA Tomonori
2008-09-11 16:33 ` Jens Axboe
2008-09-12  2:04   ` FUJITA Tomonori
2008-09-12  6:05     ` Jens Axboe
2008-09-12  6:26       ` FUJITA Tomonori
2008-09-12 13:48         ` James Bottomley
2008-09-12 14:12           ` FUJITA Tomonori
2008-09-12 14:11             ` James Bottomley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox