Re: [PATCH] block: don't use for-inside-for in bio_for_each_segment_all

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

 



On Mon, Apr 08, 2019 at 08:07:55AM +0200, Hannes Reinecke wrote:
> Oh yes, please do.
> The macros are fast becoming unparseable :-)

I think something that would help is removing the mandatory 'i' parameter
to this iterator.  Most of the users don't use it, and the ones that do
can implement it themselves.  eg:


                int j;
                struct bio_vec *bv;
                void *base = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1));
                struct bvec_iter_all iter_all;

                bio_for_each_segment_all(bv, b->bio, j, iter_all)
                        memcpy(page_address(bv->bv_page),
                               base + j * PAGE_SIZE, PAGE_SIZE);

could become

                struct bio_vec *bv;
                void *addr = (void *) ((unsigned long) i & ~(PAGE_SIZE - 1));
                struct bvec_iter_all iter_all;

                bio_for_each_segment_all(bv, b->bio, iter_all) {
                        memcpy(page_address(bv->bv_page), addr, PAGE_SIZE);
			addr += PAGE_SIZE;
		}

eg2:

                bio_for_each_segment_all(bi, sbio, j, iter_all)
                        page_len[j] = bi->bv_len;

could become:
                bio_for_each_segment_all(bi, sbio, iter_all)
                        page_len[j++] = bi->bv_len;




[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