linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: FUJITA Tomonori <tomof@acm.org>
To: stern@rowland.harvard.edu
Cc: tomof@acm.org, fujita.tomonori@lab.ntt.co.jp,
	bharrosh@panasas.com, linux-ide@vger.kernel.org,
	linux-scsi@vger.kernel.org,
	James.Bottomley@HansenPartnership.com, jens.axboe@oracle.com,
	dougg@torque.net, Geert.Uytterhoeven@sonycom.com,
	tony.luck@intel.com, Mark_Salyzyn@adaptec.com,
	ed.lin@promise.com, linuxraid@amcc.com,
	linux-usb@vger.kernel.orgfujita.tomonori@lab.ntt.co.jp
Subject: Re: [PATCH 00/10] sg buffer copy helper functions
Date: Fri, 14 Mar 2008 18:35:37 +0900	[thread overview]
Message-ID: <20080314183434J.tomof@acm.org> (raw)
In-Reply-To: <Pine.LNX.4.44L0.0803131420090.5744-100000@iolanthe.rowland.org>

On Thu, 13 Mar 2008 14:32:59 -0400 (EDT)
Alan Stern <stern@rowland.harvard.edu> wrote:

> On Thu, 13 Mar 2008, FUJITA Tomonori wrote:
> 
> > > > +	for_each_sg(*sgl, sg, nents, i) {
> > > 
> > > Will there be a problem in subsequent calls if *sgl has been
> > > incremented but nents hasn't been changed?  Maybe nents needs to be a 
> > > pointer also.
> > 
> > usb_stor_access_xfer_buf doesn't check scsi_sg_count (the number of sg
> > entries). It assumes that callers take care about the issue.
> > 
> > If you want nents to be a pointer, I'm fine with it.
> 
> If nents doesn't change then for_each_sg() won't work right.  There 
> could be an alternative macro:

Oops, I thought that for_each_sg is defined like:

#define for_each_sg(sglist, sg, nr, __i)	\
	for (__i = 0, sg = (sglist); __i < (nr) && sg; __i++, sg = sg_next(sg))


> /*
>  * Loop over each sg element, stopping at the end of the chain
>  */
> #define for_each_sg_all(sglist, sg, __i)	\
> 	for (__i = 0, sg = (sglist); sg; __i++, sg = sg_next(sg))
> 
> If you added this macro to include/linux/scatterlist.h and used it
> instead of for_each_sg() then you can get rid of nents entirely.  
> However I'm not sure whether this would be safe.  Do people sometimes 
> use a subset of the entries in a scatterlist?

IIRC, some drivers do that (though they might use sg_next).


I don't think that we add a new macro just for this function. We could
change for_each_sg in the above way or we could just do in
usb_stor_access_xfer_buf

for (i = 0, sg = *sgl; i < nents && sg; i++, sg = sg_next(sg))


> If it isn't safe then nents would have to be passed as a pointer too.  
> At this stage I think it would be better to encapsulate sgl, offset, 
> and nents in a single structure than to pass multiple pointers.

  reply	other threads:[~2008-03-14  9:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1205037877-12843-1-git-send-email-fujita.tomonori@lab.ntt.co.jp>
     [not found] ` <47D5415C.3010904@panasas.com>
2008-03-10 22:39   ` [PATCH 00/10] sg buffer copy helper functions FUJITA Tomonori
2008-03-11 10:05     ` Boaz Harrosh
2008-03-11 20:09     ` Alan Stern
2008-03-12  0:14       ` FUJITA Tomonori
2008-03-12  0:28         ` FUJITA Tomonori
2008-03-12  2:24           ` FUJITA Tomonori
2008-03-12 16:04           ` Alan Stern
2008-03-13  0:03             ` FUJITA Tomonori
2008-03-13  0:18               ` FUJITA Tomonori
2008-03-13 18:34                 ` Alan Stern
2008-03-12 16:01         ` Alan Stern
2008-03-12 16:26           ` Boaz Harrosh
2008-03-13  0:03           ` FUJITA Tomonori
2008-03-13 18:32             ` Alan Stern
2008-03-14  9:35               ` FUJITA Tomonori [this message]
     [not found]                 ` <20080314183434J.tomof-HInyCGIudOg@public.gmane.org>
2008-03-14 14:46                   ` Alan Stern
2008-03-16 11:55                     ` FUJITA Tomonori
2008-03-16 17:18                       ` Alan Stern
2008-03-17  3:23                         ` FUJITA Tomonori
2008-03-17 14:06                           ` Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080314183434J.tomof@acm.org \
    --to=tomof@acm.org \
    --cc=Geert.Uytterhoeven@sonycom.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=Mark_Salyzyn@adaptec.com \
    --cc=bharrosh@panasas.com \
    --cc=dougg@torque.net \
    --cc=ed.lin@promise.com \
    --cc=fujita.tomonori@lab.ntt.co.jp \
    --cc=jens.axboe@oracle.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.orgfujita.tomonori \
    --cc=linuxraid@amcc.com \
    --cc=stern@rowland.harvard.edu \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).