From: Tejun Heo <tj@kernel.org>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
Imre Deak <imre.deak@intel.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
linux-crypto@vger.kernel.org,
"James E.J. Bottomley" <JBottomley@parallels.com>,
Douglas Gilbert <dgilbert@interlog.com>,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/3] lib/scatterlist: introduce sg_pcopy_from_buffer() and sg_pcopy_to_buffer()
Date: Thu, 6 Jun 2013 14:00:41 -0700 [thread overview]
Message-ID: <20130606210041.GD5045@htj.dyndns.org> (raw)
In-Reply-To: <1370523178-5437-2-git-send-email-akinobu.mita@gmail.com>
Hello,
On Thu, Jun 06, 2013 at 09:52:56PM +0900, Akinobu Mita wrote:
> +static bool sg_miter_get_next_page(struct sg_mapping_iter *miter)
> +{
> + if (!miter->__remaining) {
> + struct scatterlist *sg;
> + unsigned long pgoffset;
> +
> + if (!__sg_page_iter_next(&miter->piter))
> + return false;
> +
> + sg = miter->piter.sg;
> + pgoffset = miter->piter.sg_pgoffset;
> +
> + miter->__offset = pgoffset ? 0 : sg->offset;
> + miter->__remaining = sg->offset + sg->length -
> + (pgoffset << PAGE_SHIFT) - miter->__offset;
> + miter->__remaining = min_t(unsigned long, miter->__remaining,
> + PAGE_SIZE - miter->__offset);
> + }
> +
> + return true;
> +}
It'd be better if separating out this function is a separate patch.
Mixing factoring out something and adding new stuff makes the patch a
bit harder to read.
> +static bool sg_miter_seek(struct sg_mapping_iter *miter, off_t offset)
> +{
> + WARN_ON(miter->addr);
> +
> + while (offset) {
> + off_t consumed;
> +
> + if (!sg_miter_get_next_page(miter))
> + return false;
> +
> + consumed = min_t(off_t, offset, miter->__remaining);
> + miter->__offset += consumed;
> + miter->__remaining -= consumed;
> + offset -= consumed;
> + }
> +
> + return true;
> +}
While I think the above should work at the beginning, what if @miter
is in the middle of iteration and __remaining isn't zero?
Looks good to me otherwise.
Thanks.
--
tejun
WARNING: multiple messages have this Message-ID (diff)
From: Tejun Heo <tj@kernel.org>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org,
Imre Deak <imre.deak@intel.com>,
Herbert Xu <herbert@gondor.hengli.com.au>,
"David S. Miller" <davem@davemloft.net>,
linux-crypto@vger.kernel.org,
"James E.J. Bottomley" <JBottomley@parallels.com>,
Douglas Gilbert <dgilbert@interlog.com>,
linux-scsi@vger.kernel.org
Subject: Re: [PATCH 1/3] lib/scatterlist: introduce sg_pcopy_from_buffer() and sg_pcopy_to_buffer()
Date: Thu, 6 Jun 2013 14:00:41 -0700 [thread overview]
Message-ID: <20130606210041.GD5045@htj.dyndns.org> (raw)
In-Reply-To: <1370523178-5437-2-git-send-email-akinobu.mita@gmail.com>
Hello,
On Thu, Jun 06, 2013 at 09:52:56PM +0900, Akinobu Mita wrote:
> +static bool sg_miter_get_next_page(struct sg_mapping_iter *miter)
> +{
> + if (!miter->__remaining) {
> + struct scatterlist *sg;
> + unsigned long pgoffset;
> +
> + if (!__sg_page_iter_next(&miter->piter))
> + return false;
> +
> + sg = miter->piter.sg;
> + pgoffset = miter->piter.sg_pgoffset;
> +
> + miter->__offset = pgoffset ? 0 : sg->offset;
> + miter->__remaining = sg->offset + sg->length -
> + (pgoffset << PAGE_SHIFT) - miter->__offset;
> + miter->__remaining = min_t(unsigned long, miter->__remaining,
> + PAGE_SIZE - miter->__offset);
> + }
> +
> + return true;
> +}
It'd be better if separating out this function is a separate patch.
Mixing factoring out something and adding new stuff makes the patch a
bit harder to read.
> +static bool sg_miter_seek(struct sg_mapping_iter *miter, off_t offset)
> +{
> + WARN_ON(miter->addr);
> +
> + while (offset) {
> + off_t consumed;
> +
> + if (!sg_miter_get_next_page(miter))
> + return false;
> +
> + consumed = min_t(off_t, offset, miter->__remaining);
> + miter->__offset += consumed;
> + miter->__remaining -= consumed;
> + offset -= consumed;
> + }
> +
> + return true;
> +}
While I think the above should work at the beginning, what if @miter
is in the middle of iteration and __remaining isn't zero?
Looks good to me otherwise.
Thanks.
--
tejun
next prev parent reply other threads:[~2013-06-06 21:00 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-06 12:52 [PATCH 0/3] introduce sg_pcopy_from_buffer() and sg_pcopy_to_buffer() Akinobu Mita
2013-06-06 12:52 ` Akinobu Mita
2013-06-06 12:52 ` [PATCH 1/3] lib/scatterlist: " Akinobu Mita
2013-06-06 12:52 ` Akinobu Mita
2013-06-06 13:12 ` Imre Deak
2013-06-06 13:12 ` Imre Deak
2013-06-08 14:04 ` Akinobu Mita
2013-06-08 14:04 ` Akinobu Mita
2013-06-06 21:00 ` Tejun Heo [this message]
2013-06-06 21:00 ` Tejun Heo
2013-06-08 14:28 ` Akinobu Mita
2013-06-08 14:28 ` Akinobu Mita
2013-06-06 12:52 ` [PATCH 2/3] crypto: talitos: use sg_pcopy_to_buffer() Akinobu Mita
2013-06-06 12:52 ` Akinobu Mita
2013-06-06 12:52 ` [PATCH 3/3] scsi_debug: fix do_device_access() with wrap around range Akinobu Mita
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=20130606210041.GD5045@htj.dyndns.org \
--to=tj@kernel.org \
--cc=JBottomley@parallels.com \
--cc=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=dgilbert@interlog.com \
--cc=herbert@gondor.apana.org.au \
--cc=imre.deak@intel.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.