linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch 10/18] sg: nopage
       [not found] <20071205071547.701344000@nick.local0.net>
@ 2007-12-05  7:15 ` npiggin
  2008-02-08  3:45   ` Douglas Gilbert
  0 siblings, 1 reply; 2+ messages in thread
From: npiggin @ 2007-12-05  7:15 UTC (permalink / raw)
  To: akpm; +Cc: dgilbert, linux-scsi, linux-kernel

[-- Attachment #1: sg-nopage.patch --]
[-- Type: text/plain, Size: 2001 bytes --]

Convert SG from nopage to fault.

Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: dgilbert@interlog.com
Cc: linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
 drivers/scsi/sg.c |   23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)

Index: linux-2.6/drivers/scsi/sg.c
===================================================================
--- linux-2.6.orig/drivers/scsi/sg.c
+++ linux-2.6/drivers/scsi/sg.c
@@ -1144,23 +1144,22 @@ sg_fasync(int fd, struct file *filp, int
 	return (retval < 0) ? retval : 0;
 }
 
-static struct page *
-sg_vma_nopage(struct vm_area_struct *vma, unsigned long addr, int *type)
+static int
+sg_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
 	Sg_fd *sfp;
-	struct page *page = NOPAGE_SIGBUS;
 	unsigned long offset, len, sa;
 	Sg_scatter_hold *rsv_schp;
 	struct scatterlist *sg;
 	int k;
 
 	if ((NULL == vma) || (!(sfp = (Sg_fd *) vma->vm_private_data)))
-		return page;
+		return VM_FAULT_SIGBUS;
 	rsv_schp = &sfp->reserve;
-	offset = addr - vma->vm_start;
+	offset = vmf->pgoff << PAGE_SHIFT;
 	if (offset >= rsv_schp->bufflen)
-		return page;
-	SCSI_LOG_TIMEOUT(3, printk("sg_vma_nopage: offset=%lu, scatg=%d\n",
+		return VM_FAULT_SIGBUS;
+	SCSI_LOG_TIMEOUT(3, printk("sg_vma_fault: offset=%lu, scatg=%d\n",
 				   offset, rsv_schp->k_use_sg));
 	sg = rsv_schp->buffer;
 	sa = vma->vm_start;
@@ -1169,21 +1168,21 @@ sg_vma_nopage(struct vm_area_struct *vma
 		len = vma->vm_end - sa;
 		len = (len < sg->length) ? len : sg->length;
 		if (offset < len) {
+			struct page *page;
 			page = virt_to_page(page_address(sg_page(sg)) + offset);
 			get_page(page);	/* increment page count */
-			break;
+			vmf->page = page;
+			return 0; /* success */
 		}
 		sa += len;
 		offset -= len;
 	}
 
-	if (type)
-		*type = VM_FAULT_MINOR;
-	return page;
+	return VM_FAULT_SIGBUS;
 }
 
 static struct vm_operations_struct sg_mmap_vm_ops = {
-	.nopage = sg_vma_nopage,
+	.fault = sg_vma_fault,
 };
 
 static int

-- 


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

* Re: [patch 10/18] sg: nopage
  2007-12-05  7:15 ` [patch 10/18] sg: nopage npiggin
@ 2008-02-08  3:45   ` Douglas Gilbert
  0 siblings, 0 replies; 2+ messages in thread
From: Douglas Gilbert @ 2008-02-08  3:45 UTC (permalink / raw)
  To: npiggin; +Cc: akpm, linux-scsi, linux-kernel, James Bottomley

For the patch shown below:

Signed-off-by: Douglas Gilbert <dougg@torque.net>



npiggin@suse.de wrote:
Convert SG from nopage to fault.

Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: dgilbert@interlog.com
Cc: linux-scsi@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
---
  drivers/scsi/sg.c |   23 +++++++++++------------
  1 file changed, 11 insertions(+), 12 deletions(-)

Index: linux-2.6/drivers/scsi/sg.c
===================================================================
--- linux-2.6.orig/drivers/scsi/sg.c
+++ linux-2.6/drivers/scsi/sg.c
@@ -1144,23 +1144,22 @@ sg_fasync(int fd, struct file *filp, int
  	return (retval < 0) ? retval : 0;
  }

-static struct page *
-sg_vma_nopage(struct vm_area_struct *vma, unsigned long addr, int *type)
+static int
+sg_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
  {
  	Sg_fd *sfp;
-	struct page *page = NOPAGE_SIGBUS;
  	unsigned long offset, len, sa;
  	Sg_scatter_hold *rsv_schp;
  	struct scatterlist *sg;
  	int k;

  	if ((NULL == vma) || (!(sfp = (Sg_fd *) vma->vm_private_data)))
-		return page;
+		return VM_FAULT_SIGBUS;
  	rsv_schp = &sfp->reserve;
-	offset = addr - vma->vm_start;
+	offset = vmf->pgoff << PAGE_SHIFT;
  	if (offset >= rsv_schp->bufflen)
-		return page;
-	SCSI_LOG_TIMEOUT(3, printk("sg_vma_nopage: offset=%lu, scatg=%d\n",
+		return VM_FAULT_SIGBUS;
+	SCSI_LOG_TIMEOUT(3, printk("sg_vma_fault: offset=%lu, scatg=%d\n",
  				   offset, rsv_schp->k_use_sg));
  	sg = rsv_schp->buffer;
  	sa = vma->vm_start;
@@ -1169,21 +1168,21 @@ sg_vma_nopage(struct vm_area_struct *vma
  		len = vma->vm_end - sa;
  		len = (len < sg->length) ? len : sg->length;
  		if (offset < len) {
+			struct page *page;
  			page = virt_to_page(page_address(sg_page(sg)) + offset);
  			get_page(page);	/* increment page count */
-			break;
+			vmf->page = page;
+			return 0; /* success */
  		}
  		sa += len;
  		offset -= len;
  	}

-	if (type)
-		*type = VM_FAULT_MINOR;
-	return page;
+	return VM_FAULT_SIGBUS;
  }

  static struct vm_operations_struct sg_mmap_vm_ops = {
-	.nopage = sg_vma_nopage,
+	.fault = sg_vma_fault,
  };

  static int



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

end of thread, other threads:[~2008-02-08  3:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20071205071547.701344000@nick.local0.net>
2007-12-05  7:15 ` [patch 10/18] sg: nopage npiggin
2008-02-08  3:45   ` Douglas Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).