All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Kent Overstreet <kent.overstreet@gmail.com>
Cc: Mike Snitzer <snitzer@redhat.com>, Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, dm-devel@redhat.com,
	Eric Biggers <ebiggers@google.com>,
	Dmitry Monakhov <dmonakhov@openvz.org>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Subject: Re: [PATCH 5.20 1/4] block: add bio_rewind() API
Date: Thu, 30 Jun 2022 08:47:13 +0800	[thread overview]
Message-ID: <YrzykX0jTWpq5DYQ@T590> (raw)
In-Reply-To: <20220629181154.eejrlfhj5n4la446@moria.home.lan>

On Wed, Jun 29, 2022 at 02:11:54PM -0400, Kent Overstreet wrote:
> On Wed, Jun 29, 2022 at 02:07:08AM -0400, Mike Snitzer wrote:
> > Please try to dial down the hyperbole and judgment. Ming wrote this
> > code. And you haven't been able to point out anything _actually_ wrong
> > with it (yet).
> > 
> > This patch's header does need editing for clarity, but we can help
> > improve it and the documentation above bio_rewind() in the code.
> > 
> > > So, and I'm sorry I have to be the killjoy here, but hard NACK on this patchset.
> > > Hard, hard NACK.
> > 
> > <insert tom-delonge-wtf.gif>
> > 
> > You see this bio_rewind() as history repeating itself, but it isn't
> > like what you ranted about in the past:
> > https://marc.info/?l=linux-block&m=153549921116441&w=2
> > 
> > I can certainly see why you think it similar at first glance. But this
> > patchset shows how bio_rewind() must be used, and how DM benefits from
> > using it safely (with no impact to struct bio or DM's per-bio-data).
> > 
> > bio_rewind() usage will be as niche as DM's use-case for it. If other
> > code respects the documented constraint, that the original bio's end
> > sector be preserved, then they can use it too.
> > 
> > The key is for a driver to maintain enough state to allow this fixed
> > end be effectively immutable. (DM happens to get this state "for free"
> > simply because it was already established for its IO accounting of
> > split bios).
> > 
> > The Linux codebase requires precision. This isn't new.
> 
> Mike, that's not justification for making things _more_ dangerous.
> 
> > 
> > > I'll be happy to assist in coming up with alternate, less dangerous solutions
> > > though (and I think introducing a real bio_iter is overdue, so that's probably
> > > the first thing we should look at).
> > 
> > It isn't dangerous. It is an interface whose constraint needs to be
> > respected. Just like is documented for a myriad other kernel
> > interfaces.
> > 
> > Factoring out a bio_iter will bloat struct bio for functionality most
> > consumers don't need. And gating DM's ability to achieve this
> > patchset's functionality with some overdue refactoring is really _not_
> > acceptable.
> 
> Mike, you're the one who's getting seriously hyperbolic here. You're getting
> frustrated because you've got this one thing you really want to get done, and
> you feel like you're running into a brick wall when I tell you "no".
> 
> And yes, coding in the kernel is a complicated, dangerous environment with many
> rules that need to be respected.
> 
> That does not mean it's ok to be adding to that complexity, and making it even
> more dangerous, without a _really fucking good reason_. This doesn't fly. Maybe
> it would if it was some device mapper private thing, but you're acting like it's
> only going to be used by device mapper when you're trying to add it to the
> public interface for core block layer bio code. _That_ needs real justification.
> 
> Also, bio_iter is something we should definitely be considering because of the
> way integrity and now crypt has been tacked on to struct bio.
> 
> When I originally wrote the modern bvec_iter code, the ability to use an
> iterator besides the one in struct bio was an important piece of functionality,
> one that's still in use (including in device mapper; see
> __bio_for_each_segment()). The fact that we're growing additional data
> structures that in theory want to be iterated in lockstep with the main bio
> payload but _aren't_ iterated over with bi_iter is, at best, a code smell and a
> lurking footgun.
> 
> However, I can see that the two of you are not likely take on figuring out how
> to clean that up, and truthfully I don't have the time right now either, much as
> it pains me.
> 
> Here's an alternative approach:
> 
> The fundamental problem with bio_rewind() (and I know that you two are super
> serious that this is completely safe for your use case and no one else is going
> to use it for anything else) is that we're using it to get back to some initial
> state, but it's not invariant w.r.t. what's been done to the bio since then, and
> the nature of the block layer is that that's a problem.
> 
> So here's what you do:
> 
> You bring back bi_done: bi_done counts bytes advanced, total, since the start
> of the bio. Then we introduce a type:
> 
> struct bio_pos {
> 	unsigned	bi_done;
> 	unsigned	bi_size;
> };
> 
> And two new functions:
> 
> struct bio_pos bio_get_pos(struct bio *)
> {
> 	...
> }
> 
> void bio_set_pos(struct bio *, struct bio_pos)
> {
> 	...
> }
> 
> That gets you the same functionality as bio_rewind(), but it'll be much more
> broadly useful.

What is the difference between bio_set_pos and bio_rewind()? Both have
to restore bio->bi_iter(the sector part and the bvec part).

Also how to update ->bi_done which 'counts bytes advanced'? You meant doing it in
very bio_advance()? then no, why do we have to pay the cost for very unusual
bio_rewind()?

Or if I misunderstood your point, please cook a patch and I am happy to
take a close look, and posting one very raw idea with random data
structure looks not helpful much for this discussion technically.


Thanks,
Ming


WARNING: multiple messages have this Message-ID (diff)
From: Ming Lei <ming.lei@redhat.com>
To: Kent Overstreet <kent.overstreet@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	Mike Snitzer <snitzer@redhat.com>,
	Eric Biggers <ebiggers@google.com>,
	linux-block@vger.kernel.org, dm-devel@redhat.com,
	Dmitry Monakhov <dmonakhov@openvz.org>
Subject: Re: [dm-devel] [PATCH 5.20 1/4] block: add bio_rewind() API
Date: Thu, 30 Jun 2022 08:47:13 +0800	[thread overview]
Message-ID: <YrzykX0jTWpq5DYQ@T590> (raw)
In-Reply-To: <20220629181154.eejrlfhj5n4la446@moria.home.lan>

On Wed, Jun 29, 2022 at 02:11:54PM -0400, Kent Overstreet wrote:
> On Wed, Jun 29, 2022 at 02:07:08AM -0400, Mike Snitzer wrote:
> > Please try to dial down the hyperbole and judgment. Ming wrote this
> > code. And you haven't been able to point out anything _actually_ wrong
> > with it (yet).
> > 
> > This patch's header does need editing for clarity, but we can help
> > improve it and the documentation above bio_rewind() in the code.
> > 
> > > So, and I'm sorry I have to be the killjoy here, but hard NACK on this patchset.
> > > Hard, hard NACK.
> > 
> > <insert tom-delonge-wtf.gif>
> > 
> > You see this bio_rewind() as history repeating itself, but it isn't
> > like what you ranted about in the past:
> > https://marc.info/?l=linux-block&m=153549921116441&w=2
> > 
> > I can certainly see why you think it similar at first glance. But this
> > patchset shows how bio_rewind() must be used, and how DM benefits from
> > using it safely (with no impact to struct bio or DM's per-bio-data).
> > 
> > bio_rewind() usage will be as niche as DM's use-case for it. If other
> > code respects the documented constraint, that the original bio's end
> > sector be preserved, then they can use it too.
> > 
> > The key is for a driver to maintain enough state to allow this fixed
> > end be effectively immutable. (DM happens to get this state "for free"
> > simply because it was already established for its IO accounting of
> > split bios).
> > 
> > The Linux codebase requires precision. This isn't new.
> 
> Mike, that's not justification for making things _more_ dangerous.
> 
> > 
> > > I'll be happy to assist in coming up with alternate, less dangerous solutions
> > > though (and I think introducing a real bio_iter is overdue, so that's probably
> > > the first thing we should look at).
> > 
> > It isn't dangerous. It is an interface whose constraint needs to be
> > respected. Just like is documented for a myriad other kernel
> > interfaces.
> > 
> > Factoring out a bio_iter will bloat struct bio for functionality most
> > consumers don't need. And gating DM's ability to achieve this
> > patchset's functionality with some overdue refactoring is really _not_
> > acceptable.
> 
> Mike, you're the one who's getting seriously hyperbolic here. You're getting
> frustrated because you've got this one thing you really want to get done, and
> you feel like you're running into a brick wall when I tell you "no".
> 
> And yes, coding in the kernel is a complicated, dangerous environment with many
> rules that need to be respected.
> 
> That does not mean it's ok to be adding to that complexity, and making it even
> more dangerous, without a _really fucking good reason_. This doesn't fly. Maybe
> it would if it was some device mapper private thing, but you're acting like it's
> only going to be used by device mapper when you're trying to add it to the
> public interface for core block layer bio code. _That_ needs real justification.
> 
> Also, bio_iter is something we should definitely be considering because of the
> way integrity and now crypt has been tacked on to struct bio.
> 
> When I originally wrote the modern bvec_iter code, the ability to use an
> iterator besides the one in struct bio was an important piece of functionality,
> one that's still in use (including in device mapper; see
> __bio_for_each_segment()). The fact that we're growing additional data
> structures that in theory want to be iterated in lockstep with the main bio
> payload but _aren't_ iterated over with bi_iter is, at best, a code smell and a
> lurking footgun.
> 
> However, I can see that the two of you are not likely take on figuring out how
> to clean that up, and truthfully I don't have the time right now either, much as
> it pains me.
> 
> Here's an alternative approach:
> 
> The fundamental problem with bio_rewind() (and I know that you two are super
> serious that this is completely safe for your use case and no one else is going
> to use it for anything else) is that we're using it to get back to some initial
> state, but it's not invariant w.r.t. what's been done to the bio since then, and
> the nature of the block layer is that that's a problem.
> 
> So here's what you do:
> 
> You bring back bi_done: bi_done counts bytes advanced, total, since the start
> of the bio. Then we introduce a type:
> 
> struct bio_pos {
> 	unsigned	bi_done;
> 	unsigned	bi_size;
> };
> 
> And two new functions:
> 
> struct bio_pos bio_get_pos(struct bio *)
> {
> 	...
> }
> 
> void bio_set_pos(struct bio *, struct bio_pos)
> {
> 	...
> }
> 
> That gets you the same functionality as bio_rewind(), but it'll be much more
> broadly useful.

What is the difference between bio_set_pos and bio_rewind()? Both have
to restore bio->bi_iter(the sector part and the bvec part).

Also how to update ->bi_done which 'counts bytes advanced'? You meant doing it in
very bio_advance()? then no, why do we have to pay the cost for very unusual
bio_rewind()?

Or if I misunderstood your point, please cook a patch and I am happy to
take a close look, and posting one very raw idea with random data
structure looks not helpful much for this discussion technically.


Thanks,
Ming
--
dm-devel mailing list
dm-devel@redhat.com
https://listman.redhat.com/mailman/listinfo/dm-devel


  reply	other threads:[~2022-06-30  0:47 UTC|newest]

Thread overview: 76+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-24 14:12 [PATCH 5.20 0/4] block/dm: add bio_rewind for improving dm requeue Ming Lei
2022-06-24 14:12 ` [dm-devel] " Ming Lei
2022-06-24 14:12 ` [PATCH 5.20 1/4] block: add bio_rewind() API Ming Lei
2022-06-24 14:12   ` [dm-devel] " Ming Lei
2022-06-26 20:14   ` Kent Overstreet
2022-06-26 20:14     ` [dm-devel] " Kent Overstreet
2022-06-27  7:36     ` Ming Lei
2022-06-27  7:36       ` [dm-devel] " Ming Lei
2022-06-28  4:20       ` Kent Overstreet
2022-06-28  4:20         ` [dm-devel] " Kent Overstreet
2022-06-28  7:42         ` Ming Lei
2022-06-28  7:42           ` [dm-devel] " Ming Lei
2022-06-28 16:16           ` Kent Overstreet
2022-06-28 16:16             ` [dm-devel] " Kent Overstreet
2022-06-28 18:13         ` Jens Axboe
2022-06-28 18:13           ` [dm-devel] " Jens Axboe
2022-06-28 18:32           ` Kent Overstreet
2022-06-28 18:32             ` [dm-devel] " Kent Overstreet
2022-06-29 17:16             ` Jens Axboe
2022-06-29 17:16               ` [dm-devel] " Jens Axboe
2022-06-29 18:40               ` Kent Overstreet
2022-06-29 18:40                 ` [dm-devel] " Kent Overstreet
2022-06-29 18:51                 ` Bart Van Assche
2022-06-29 18:51                   ` [dm-devel] " Bart Van Assche
2022-06-29 19:05                   ` Kent Overstreet
2022-06-29 19:05                     ` [dm-devel] " Kent Overstreet
2022-06-29 19:37                     ` Bart Van Assche
2022-06-29 19:37                       ` [dm-devel] " Bart Van Assche
2022-06-29 19:50                       ` Kent Overstreet
2022-06-29 19:50                         ` [dm-devel] " Kent Overstreet
2022-06-29 19:59                       ` Kent Overstreet
2022-06-29 19:59                         ` [dm-devel] " Kent Overstreet
2022-06-29 19:00                 ` Jens Axboe
2022-06-29 19:00                   ` [dm-devel] " Jens Axboe
2022-06-29 19:26                   ` Kent Overstreet
2022-06-29 19:26                     ` [dm-devel] " Kent Overstreet
2022-06-29 20:51                     ` Jens Axboe
2022-06-29 20:51                       ` [dm-devel] " Jens Axboe
2022-06-29  0:49           ` Ming Lei
2022-06-29  0:49             ` [dm-devel] " Ming Lei
2022-06-28  4:26       ` Kent Overstreet
2022-06-28  4:26         ` [dm-devel] " Kent Overstreet
2022-06-28  7:49         ` Ming Lei
2022-06-28  7:49           ` [dm-devel] " Ming Lei
2022-06-28 16:36           ` Kent Overstreet
2022-06-28 16:36             ` [dm-devel] " Kent Overstreet
2022-06-28 17:41             ` Mike Snitzer
2022-06-28 17:41               ` [dm-devel] " Mike Snitzer
2022-06-28 17:52               ` Kent Overstreet
2022-06-28 17:52                 ` [dm-devel] " Kent Overstreet
2022-06-29  6:07                 ` Mike Snitzer
2022-06-29  6:07                   ` [dm-devel] " Mike Snitzer
2022-06-29 18:11                   ` Kent Overstreet
2022-06-29 18:11                     ` [dm-devel] " Kent Overstreet
2022-06-30  0:47                     ` Ming Lei [this message]
2022-06-30  0:47                       ` Ming Lei
2022-06-30  0:58                       ` Kent Overstreet
2022-06-30  0:58                         ` [dm-devel] " Kent Overstreet
2022-06-30  1:14                       ` Kent Overstreet
2022-06-30  1:14                         ` [dm-devel] " Kent Overstreet
2022-07-01  3:58                         ` Ming Lei
2022-07-01  3:58                           ` Ming Lei
2022-07-01 21:09                           ` Kent Overstreet
2022-07-01 21:09                             ` [dm-devel] " Kent Overstreet
2022-06-29  1:02             ` Ming Lei
2022-06-29  1:02               ` [dm-devel] " Ming Lei
2022-06-26 21:37   ` Eric Biggers
2022-06-26 21:37     ` Eric Biggers
2022-06-27  7:37     ` Ming Lei
2022-06-27  7:37       ` Ming Lei
2022-06-24 14:12 ` [PATCH 5.20 2/4] dm: add new helper for handling dm_io requeue Ming Lei
2022-06-24 14:12   ` [dm-devel] " Ming Lei
2022-06-24 14:12 ` [PATCH 5.20 3/4] dm: improve handling for DM_REQUEUE and AGAIN Ming Lei
2022-06-24 14:12   ` [dm-devel] " Ming Lei
2022-06-24 14:12 ` [PATCH 5.20 4/4] dm: add two stage requeue Ming Lei
2022-06-24 14:12   ` [dm-devel] " Ming Lei

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=YrzykX0jTWpq5DYQ@T590 \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=dmonakhov@openvz.org \
    --cc=ebiggers@google.com \
    --cc=kent.overstreet@gmail.com \
    --cc=linux-block@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=snitzer@redhat.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 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.