Re: [PATCH v14 091/138] block: Add bio_for_each_folio_all()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jul 15, 2021 at 02:12:54PM -0700, Darrick J. Wong wrote:
> On Thu, Jul 15, 2021 at 04:36:17AM +0100, Matthew Wilcox (Oracle) wrote:
> > +struct folio_iter {
> > +	struct folio *folio;
> > +	size_t offset;
> > +	size_t length;
> 
> Hm... so after every bio_{first,next}_folio call, we can access the
> folio, the offset, and the length (both in units of bytes) within the
> folio?

Correct.

> > +	size_t _seg_count;
> > +	int _i;
> 
> And these are private variables that the iteration code should not
> scribble over?

Indeed!

> > +/*
> > + * Iterate over each folio in a bio.
> > + */
> > +#define bio_for_each_folio_all(fi, bio)				\
> > +	for (bio_first_folio(&fi, bio, 0); fi.folio; bio_next_folio(&fi, bio))
> 
> ...so I guess a sample iteration loop would be something like:
> 
> 	struct bio *bio = <get one from somewhere>;
> 	struct folio_iter fi;
> 
> 	bio_for_each_folio_all(fi, bio) {
> 		if (folio_test_dirty(fi.folio))
> 			printk("folio idx 0x%lx is dirty, i hates dirty data!",
> 					folio_index(fi.folio));
> 			panic();
> 	}
> 
> I'll go look through the rest of the patches, but this so far looks
> pretty straightforward to me.

Something very much like that!

+static void iomap_read_end_io(struct bio *bio)
 {
+       struct folio_iter fi;
+       bio_for_each_folio_all(fi, bio)
+               iomap_finish_folio_read(fi.folio, fi.offset, fi.length, error);




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux