On Mon, Mar 07, 2022 at 10:41:31AM +0800, Ming Lei wrote: > On Sun, Mar 06, 2022 at 07:25:11PM -0700, Jens Axboe wrote: > > On 3/6/22 7:20 PM, Ming Lei wrote: > > > On Sun, Mar 06, 2022 at 06:48:15PM -0700, Jens Axboe wrote: > > >> On 3/6/22 2:29 AM, Christoph Hellwig wrote: > > >>>> +/* > > >>>> + * Reuse ->bi_end_io as hlist head for storing all dm_io instances > > >>>> + * associated with this bio, and this bio's bi_end_io has to be > > >>>> + * stored in one of 'dm_io' instance first. > > >>>> + */ > > >>>> +static inline struct hlist_head *dm_get_bio_hlist_head(struct bio *bio) > > >>>> +{ > > >>>> + WARN_ON_ONCE(!(bio->bi_opf & REQ_DM_POLL_LIST)); > > >>>> + > > >>>> + return (struct hlist_head *)&bio->bi_end_io; > > >>>> +} > > >>> > > >>> So this reuse is what I really hated. I still think we should be able > > >>> to find space in the bio by creatively shifting fields around to just > > >>> add the hlist there directly, which would remove the need for this > > >>> override and more importantly the quite cumbersome saving and restoring > > >>> of the end_io handler. > > >> > > >> If it's possible, then that would be preferable. But I don't think > > >> that's going to be easy to do... > > > > > > I agree, now basically there isn't gap inside bio, so either adding one > > > new field or reusing one existed field... > > > > There'd no amount of re-arranging that'll free up 8 bytes, that's just > > not happening. I'm not a huge fan of growing struct bio for that, and > > the oddity here is mostly (to me) that ->bi_end_io is the one overlayed. > > That would usually belong to the owner of the bio. > > > > Maybe some commenting would help? > > OK, ->bi_end_io is safe because it is only called until the bio is > ended, so we can retrieve the list head and recover ->bi_end_io before > polling. ->bi_private can be reused too, is that better? Yeah, both belong to owner(higher level storage), then block layer can't touch them inside submit_bio_noacct(), that is also why this trick is safe. Thanks, Ming -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel