sg: disable interrupts inside sg_copy_buffer
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Thu, 11 Sep 2008 16:35:39 +0000 (18:35 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 11 Sep 2008 16:35:39 +0000 (18:35 +0200)
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>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
lib/scatterlist.c

index 876ba6d..8d2688f 100644 (file)
@@ -422,9 +422,12 @@ static size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents,
 {
        unsigned int offset = 0;
        struct sg_mapping_iter miter;
+       unsigned long flags;
 
        sg_miter_start(&miter, sgl, nents, SG_MITER_ATOMIC);
 
+       local_irq_save(flags);
+
        while (sg_miter_next(&miter) && offset < buflen) {
                unsigned int len;
 
@@ -442,6 +445,7 @@ static size_t sg_copy_buffer(struct scatterlist *sgl, unsigned int nents,
 
        sg_miter_stop(&miter);
 
+       local_irq_restore(flags);
        return offset;
 }