]> err.no Git - linux-2.6/blobdiff - drivers/scsi/sg.c
Merge rsync://rsync.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-2.6] / drivers / scsi / sg.c
index af3fea59a456bb780e62629414fdf98d66637580..98b9312ba8da233344751ea5a9820f0a3becc102 100644 (file)
@@ -748,6 +748,7 @@ sg_common_write(Sg_fd * sfp, Sg_request * srp,
                /*
                 * most likely out of mem, but could also be a bad map
                 */
+               sg_finish_rem_req(srp);
                return -ENOMEM;
        } else
                return 0;
@@ -1044,7 +1045,7 @@ sg_ioctl(struct inode *inode, struct file *filp,
                        if (!sg_allow_access(opcode, sdp->device->type))
                                return -EPERM;
                }
-               return scsi_ioctl_send_command(sdp->device, p);
+               return sg_scsi_ioctl(filp, sdp->device->request_queue, NULL, p);
        case SG_SET_DEBUG:
                result = get_user(val, ip);
                if (result)
@@ -1139,32 +1140,6 @@ sg_fasync(int fd, struct file *filp, int mode)
        return (retval < 0) ? retval : 0;
 }
 
-/* When startFinish==1 increments page counts for pages other than the 
-   first of scatter gather elements obtained from alloc_pages().
-   When startFinish==0 decrements ... */
-static void
-sg_rb_correct4mmap(Sg_scatter_hold * rsv_schp, int startFinish)
-{
-       struct scatterlist *sg = rsv_schp->buffer;
-       struct page *page;
-       int k, m;
-
-       SCSI_LOG_TIMEOUT(3, printk("sg_rb_correct4mmap: startFinish=%d, scatg=%d\n", 
-                                  startFinish, rsv_schp->k_use_sg));
-       /* N.B. correction _not_ applied to base page of each allocation */
-       for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sg) {
-               for (m = PAGE_SIZE; m < sg->length; m += PAGE_SIZE) {
-                       page = sg->page;
-                       if (startFinish)
-                               get_page(page);
-                       else {
-                               if (page_count(page) > 0)
-                                       __put_page(page);
-                       }
-               }
-       }
-}
-
 static struct page *
 sg_vma_nopage(struct vm_area_struct *vma, unsigned long addr, int *type)
 {
@@ -1236,10 +1211,7 @@ sg_mmap(struct file *filp, struct vm_area_struct *vma)
                sa += len;
        }
 
-       if (0 == sfp->mmap_called) {
-               sg_rb_correct4mmap(rsv_schp, 1);        /* do only once per fd lifetime */
-               sfp->mmap_called = 1;
-       }
+       sfp->mmap_called = 1;
        vma->vm_flags |= VM_RESERVED;
        vma->vm_private_data = sfp;
        vma->vm_ops = &sg_mmap_vm_ops;
@@ -1827,8 +1799,10 @@ sg_build_direct(Sg_request * srp, Sg_fd * sfp, int dxfer_len)
        res = st_map_user_pages(schp->buffer, mx_sc_elems,
                                (unsigned long)hp->dxferp, dxfer_len, 
                                (SG_DXFER_TO_DEV == hp->dxfer_direction) ? 1 : 0);
-       if (res <= 0)
+       if (res <= 0) {
+               sg_remove_scat(schp);
                return 1;
+       }
        schp->k_use_sg = res;
        schp->dio_in_use = 1;
        hp->info |= SG_INFO_DIRECT_IO;
@@ -2155,7 +2129,7 @@ sg_link_reserve(Sg_fd * sfp, Sg_request * srp, int size)
 
        srp->res_used = 1;
        SCSI_LOG_TIMEOUT(4, printk("sg_link_reserve: size=%d\n", size));
-       rem = size = (size + 1) & (~1); /* round to even for aha1542 */
+       rem = size;
 
        for (k = 0; k < rsv_schp->k_use_sg; ++k, ++sg) {
                num = sg->length;
@@ -2388,8 +2362,6 @@ __sg_remove_sfp(Sg_device * sdp, Sg_fd * sfp)
                SCSI_LOG_TIMEOUT(6, 
                        printk("__sg_remove_sfp:    bufflen=%d, k_use_sg=%d\n",
                        (int) sfp->reserve.bufflen, (int) sfp->reserve.k_use_sg));
-               if (sfp->mmap_called)
-                       sg_rb_correct4mmap(&sfp->reserve, 0);   /* undo correction */
                sg_remove_scat(&sfp->reserve);
        }
        sfp->parentdp = NULL;
@@ -2471,9 +2443,9 @@ sg_page_malloc(int rqSz, int lowDma, int *retSzp)
                return resp;
 
        if (lowDma)
-               page_mask = GFP_ATOMIC | GFP_DMA | __GFP_NOWARN;
+               page_mask = GFP_ATOMIC | GFP_DMA | __GFP_COMP | __GFP_NOWARN;
        else
-               page_mask = GFP_ATOMIC | __GFP_NOWARN;
+               page_mask = GFP_ATOMIC | __GFP_COMP | __GFP_NOWARN;
 
        for (order = 0, a_size = PAGE_SIZE; a_size < rqSz;
             order++, a_size <<= 1) ;
@@ -2663,8 +2635,7 @@ static int
 sg_proc_init(void)
 {
        int k, mask;
-       int num_leaves =
-           sizeof (sg_proc_leaf_arr) / sizeof (sg_proc_leaf_arr[0]);
+       int num_leaves = ARRAY_SIZE(sg_proc_leaf_arr);
        struct proc_dir_entry *pdep;
        struct sg_proc_leaf * leaf;
 
@@ -2689,8 +2660,7 @@ static void
 sg_proc_cleanup(void)
 {
        int k;
-       int num_leaves =
-           sizeof (sg_proc_leaf_arr) / sizeof (sg_proc_leaf_arr[0]);
+       int num_leaves = ARRAY_SIZE(sg_proc_leaf_arr);
 
        if (!sg_proc_sgp)
                return;