Message ID | 20181121032327.8434-3-ming.lei@redhat.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | block: support multi-page bvec | expand |
On Wed, Nov 21, 2018 at 11:23:10AM +0800, Ming Lei wrote: > This patch introduces helpers of 'segment_iter_*' for multipage > bvec support. > > The introduced helpers treate one bvec as real multi-page segment, > which may include more than one pages. Unless I'm missing something these bvec vs segment names are exactly inverted vs how we use it elsewhere. In the iterators we use segment for single-page bvec, and bvec for multi page ones, and here it is inverse. Please switch it around.
On Wed, Nov 21, 2018 at 02:19:28PM +0100, Christoph Hellwig wrote: > On Wed, Nov 21, 2018 at 11:23:10AM +0800, Ming Lei wrote: > > This patch introduces helpers of 'segment_iter_*' for multipage > > bvec support. > > > > The introduced helpers treate one bvec as real multi-page segment, > > which may include more than one pages. > > Unless I'm missing something these bvec vs segment names are exactly > inverted vs how we use it elsewhere. > > In the iterators we use segment for single-page bvec, and bvec for multi > page ones, and here it is inverse. Please switch it around. bvec_iter_* is used for single-page bvec in current linus tree, and there are lots of users now: [linux]$ git grep -n "bvec_iter_*" ./ | wc 191 995 13242 If we have to switch it first, it can be a big change, just wondering if Jens is happy with that? Thanks, Ming
On Wed, Nov 21, 2018 at 11:06:11PM +0800, Ming Lei wrote: > bvec_iter_* is used for single-page bvec in current linus tree, and there are > lots of users now: > > [linux]$ git grep -n "bvec_iter_*" ./ | wc > 191 995 13242 > > If we have to switch it first, it can be a big change, just wondering if Jens > is happy with that? Your above grep statement seems to catch every use of struct bvec_iter, due to the *. Most uses of bvec_iter_ are either in the block headers, or are ceph wrappers that match the above and can easily be redefined.
On Wed, Nov 21, 2018 at 05:08:11PM +0100, Christoph Hellwig wrote: > On Wed, Nov 21, 2018 at 11:06:11PM +0800, Ming Lei wrote: > > bvec_iter_* is used for single-page bvec in current linus tree, and there are > > lots of users now: > > > > [linux]$ git grep -n "bvec_iter_*" ./ | wc > > 191 995 13242 > > > > If we have to switch it first, it can be a big change, just wondering if Jens > > is happy with that? > > Your above grep statement seems to catch every use of struct bvec_iter, > due to the *. > > Most uses of bvec_iter_ are either in the block headers, or are > ceph wrappers that match the above and can easily be redefined. OK, looks you are right, seems not so widely used: $ git grep -n -w -E "bvec_iter_len|bvec_iter_bvec|bvec_iter_advance|bvec_iter_page|bvec_iter_offset" ./ | wc 36 194 2907 I will switch to that given the effected driver are only dm, nvdimm and ceph. Thanks, Ming
diff --git a/include/linux/bvec.h b/include/linux/bvec.h index 02c73c6aa805..ed90bbf4c9c9 100644 --- a/include/linux/bvec.h +++ b/include/linux/bvec.h @@ -23,6 +23,7 @@ #include <linux/kernel.h> #include <linux/bug.h> #include <linux/errno.h> +#include <linux/mm.h> /* * was unsigned short, but we might as well be ready for > 64kB I/O pages @@ -50,16 +51,35 @@ struct bvec_iter { */ #define __bvec_iter_bvec(bvec, iter) (&(bvec)[(iter).bi_idx]) -#define bvec_iter_page(bvec, iter) \ +#define segment_iter_page(bvec, iter) \ (__bvec_iter_bvec((bvec), (iter))->bv_page) -#define bvec_iter_len(bvec, iter) \ +#define segment_iter_len(bvec, iter) \ min((iter).bi_size, \ __bvec_iter_bvec((bvec), (iter))->bv_len - (iter).bi_bvec_done) -#define bvec_iter_offset(bvec, iter) \ +#define segment_iter_offset(bvec, iter) \ (__bvec_iter_bvec((bvec), (iter))->bv_offset + (iter).bi_bvec_done) +#define segment_iter_page_idx(bvec, iter) \ + (segment_iter_offset((bvec), (iter)) / PAGE_SIZE) + +/* + * <page, offset,length> of single-page segment. + * + * This helpers are for building single-page bvec in flight. + */ +#define bvec_iter_offset(bvec, iter) \ + (segment_iter_offset((bvec), (iter)) % PAGE_SIZE) + +#define bvec_iter_len(bvec, iter) \ + min_t(unsigned, segment_iter_len((bvec), (iter)), \ + PAGE_SIZE - bvec_iter_offset((bvec), (iter))) + +#define bvec_iter_page(bvec, iter) \ + nth_page(segment_iter_page((bvec), (iter)), \ + segment_iter_page_idx((bvec), (iter))) + #define bvec_iter_bvec(bvec, iter) \ ((struct bio_vec) { \ .bv_page = bvec_iter_page((bvec), (iter)), \