Re: [dm-devel] [PATCH 3/5] iomap: simplify iomap_init() with PAGE_SECTORS

2023-04-21 Thread Jens Axboe
On 4/21/23 4:30?PM, Luis Chamberlain wrote: > On Fri, Apr 21, 2023 at 04:24:57PM -0600, Jens Axboe wrote: >> On 4/21/23 4:02?PM, Luis Chamberlain wrote: >>> On Fri, Apr 21, 2023 at 09:14:00PM +0100, Matthew Wilcox wrote: On Fri, Apr 21, 2023 at 12:58:05PM -0700, Luis Chamberlain wrote: >

Re: [dm-devel] [PATCH 3/5] iomap: simplify iomap_init() with PAGE_SECTORS

2023-04-21 Thread Dave Chinner
On Fri, Apr 21, 2023 at 03:02:30PM -0700, Luis Chamberlain wrote: > On Fri, Apr 21, 2023 at 09:14:00PM +0100, Matthew Wilcox wrote: > > On Fri, Apr 21, 2023 at 12:58:05PM -0700, Luis Chamberlain wrote: > > > Just use the PAGE_SECTORS generic define. This produces no functional > > > changes. While

Re: [dm-devel] [PATCH 3/5] iomap: simplify iomap_init() with PAGE_SECTORS

2023-04-21 Thread Luis Chamberlain
On Fri, Apr 21, 2023 at 04:24:57PM -0600, Jens Axboe wrote: > On 4/21/23 4:02 PM, Luis Chamberlain wrote: > > On Fri, Apr 21, 2023 at 09:14:00PM +0100, Matthew Wilcox wrote: > >> On Fri, Apr 21, 2023 at 12:58:05PM -0700, Luis Chamberlain wrote: > >>> Just use the PAGE_SECTORS generic define. This

Re: [dm-devel] [PATCH 3/5] iomap: simplify iomap_init() with PAGE_SECTORS

2023-04-21 Thread Jens Axboe
On 4/21/23 4:02 PM, Luis Chamberlain wrote: > On Fri, Apr 21, 2023 at 09:14:00PM +0100, Matthew Wilcox wrote: >> On Fri, Apr 21, 2023 at 12:58:05PM -0700, Luis Chamberlain wrote: >>> Just use the PAGE_SECTORS generic define. This produces no functional >>> changes. While at it use left shift to

Re: [dm-devel] [PATCH 3/5] iomap: simplify iomap_init() with PAGE_SECTORS

2023-04-21 Thread Luis Chamberlain
On Fri, Apr 21, 2023 at 09:14:00PM +0100, Matthew Wilcox wrote: > On Fri, Apr 21, 2023 at 12:58:05PM -0700, Luis Chamberlain wrote: > > Just use the PAGE_SECTORS generic define. This produces no functional > > changes. While at it use left shift to simplify this even further. > > How is FOO << 2

[dm-devel] [PATCH 3/5] iomap: simplify iomap_init() with PAGE_SECTORS

2023-04-21 Thread Luis Chamberlain
Just use the PAGE_SECTORS generic define. This produces no functional changes. While at it use left shift to simplify this even further. Signed-off-by: Luis Chamberlain --- fs/iomap/buffered-io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/iomap/buffered-io.c

[dm-devel] [PATCH 5/5] zram: use generic PAGE_SECTORS and PAGE_SECTORS_SHIFT

2023-04-21 Thread Luis Chamberlain
Instead of re-defining the already existing constants use the provided ones: So replace: o SECTORS_PER_PAGE_SHIFT with PAGE_SECTORS_SHIFT o SECTORS_PER_PAGE with PAGE_SECTORS This produces no functional changes. Signed-off-by: Luis Chamberlain --- drivers/block/zram/zram_drv.c | 12

[dm-devel] [PATCH 4/5] dm bufio: simplify by using PAGE_SECTORS_SHIFT

2023-04-21 Thread Luis Chamberlain
The PAGE_SHIFT - SECTOR_SHIFT constant be replaced with PAGE_SECTORS_SHIFT defined in linux/blt_types.h, which is included by linux/blkdev.h. This produces no functional changes. Signed-off-by: Luis Chamberlain --- drivers/md/dm-bufio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)

[dm-devel] [PATCH 1/5] dm integrity: simplify by using PAGE_SECTORS_SHIFT

2023-04-21 Thread Luis Chamberlain
The PAGE_SHIFT - SECTOR_SHIFT constant be replaced with PAGE_SECTORS_SHIFT defined in linux/blt_types.h, which is included by linux/blkdev.h. This produces no functional changes. Signed-off-by: Luis Chamberlain --- drivers/md/dm-integrity.c | 10 +- 1 file changed, 5 insertions(+), 5

[dm-devel] [PATCH 0/5] block: simplify with PAGE_SECTORS_SHIFT

2023-04-21 Thread Luis Chamberlain
A bit of block drivers have their own incantations with PAGE_SHIFT - SECTOR_SHIFT. Just simplfy and use PAGE_SECTORS_SHIFT all over. Based on linux-next next-20230421. Luis Chamberlain (5): dm integrity: simplify by using PAGE_SECTORS_SHIFT drbd: use PAGE_SECTORS_SHIFT and PAGE_SECTORS

[dm-devel] [PATCH 2/5] drbd: use PAGE_SECTORS_SHIFT and PAGE_SECTORS

2023-04-21 Thread Luis Chamberlain
Replace common constants with generic versions. This produces no functional changes. Signed-off-by: Luis Chamberlain --- drivers/block/drbd/drbd_bitmap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/block/drbd/drbd_bitmap.c b/drivers/block/drbd/drbd_bitmap.c

Re: [dm-devel] [PATCH 1/5] dm integrity: simplify by using PAGE_SECTORS_SHIFT

2023-04-21 Thread Matthew Wilcox
On Fri, Apr 21, 2023 at 12:58:03PM -0700, Luis Chamberlain wrote: > - *pl_index = sector >> (PAGE_SHIFT - SECTOR_SHIFT); > + *pl_index = sector >> (PAGE_SECTORS_SHIFT); You could/should remove the () around PAGE_SECTORS_SHIFT (throughout) -- dm-devel mailing list dm-devel@redhat.com

Re: [dm-devel] [PATCH 3/5] iomap: simplify iomap_init() with PAGE_SECTORS

2023-04-21 Thread Matthew Wilcox
On Fri, Apr 21, 2023 at 12:58:05PM -0700, Luis Chamberlain wrote: > Just use the PAGE_SECTORS generic define. This produces no functional > changes. While at it use left shift to simplify this even further. How is FOO << 2 simpler than FOO * 4? > - return bioset_init(_ioend_bioset, 4 *

[dm-devel] [PATCH v4 11/22] gfs2: use __bio_add_page for adding single page to bio

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The GFS2 superblock reading code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. Use __bio_add_page() as adding a single page to a newly created bio is guaranteed to succeed. This brings us a

[dm-devel] [PATCH v4 02/22] drbd: use __bio_add_page to add page to bio

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The drbd code only adds a single page to a newly created bio. So use __bio_add_page() to add the page which is guaranteed to succeed in this case. This brings us closer to marking bio_add_page() as __must_check. Signed-off-by: Johannes Thumshirn Reviewed-by: Damien Le

[dm-devel] [PATCH v4 19/22] block: mark bio_add_page as __must_check

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn Now that all users of bio_add_page check for the return value, mark bio_add_page as __must_check. Signed-off-by: Johannes Thumshirn Reviewed-by: Damien Le Moal --- include/linux/bio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

[dm-devel] [PATCH v4 13/22] zram: use __bio_add_page for adding single page to bio

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The zram writeback code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. Use __bio_add_page() as adding a single page to a newly created bio is guaranteed to succeed. This brings us a step closer

Re: [dm-devel] [PATCH v3 11/19] gfs: use __bio_add_page for adding single page to bio

2023-04-21 Thread Johannes Thumshirn
On 19/04/2023 17:19, Andreas Gruenbacher wrote: On Wed, Apr 19, 2023 at 4:10 PM Johannes Thumshirn wrote: From: Johannes Thumshirn The GFS superblock reading code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. It's

[dm-devel] [PATCH v4 21/22] fs: iomap: use __bio_add_folio where possible

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn When the iomap buffered-io code can't add a folio to a bio, it allocates a new bio and adds the folio to that one. This is done using bio_add_folio(), but doesn't check for errors. As adding a folio to a newly created bio can't fail, use the newly introduced

[dm-devel] [PATCH v4 18/22] dm-crypt: check if adding pages to clone bio fails

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn Check if adding pages to clone bio fails and if it does retry with reclaim. This mirrors the behaviour of page allocation in crypt_alloc_buffer(). This way we can mark bio_add_pages as __must_check. Signed-off-by: Johannes Thumshirn Reviewed-by: Damien Le Moal ---

[dm-devel] [PATCH v4 22/22] block: mark bio_add_folio as __must_check

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn Now that all callers of bio_add_folio() check the return value, mark it as __must_check. Signed-off-by: Johannes Thumshirn --- include/linux/bio.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/bio.h b/include/linux/bio.h index

[dm-devel] [PATCH v4 10/22] jfs: logmgr: use __bio_add_page to add single page to bio

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The JFS IO code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. Use __bio_add_page() as adding a single page to a newly created bio is guaranteed to succeed. This brings us a step closer to

[dm-devel] [PATCH v4 08/22] btrfs: repair: use __bio_add_page for adding single page

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The btrfs repair bio submission code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. Use __bio_add_page() as adding a single page to a newly created bio is guaranteed to succeed. This brings us a

[dm-devel] [PATCH v4 05/22] md: use __bio_add_page to add single page

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The md-raid superblock writing code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. Use __bio_add_page() as adding a single page to a newly created bio is guaranteed to succeed. This brings us a

[dm-devel] [PATCH v4 07/22] md: raid5: use __bio_add_page to add single page to new bio

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The raid5-ppl submission code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. For adding consecutive pages, the return is actually checked and a new bio is allocated if adding the page fails. Use

[dm-devel] [PATCH v4 14/22] floppy: use __bio_add_page for adding single page to bio

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The floppy code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. Use __bio_add_page() as adding a single page to a newly created bio is guaranteed to succeed. This brings us a step closer to

[dm-devel] [PATCH v4 03/22] dm: dm-zoned: use __bio_add_page for adding single metadata page

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn dm-zoned uses bio_add_page() for adding a single page to a freshly created metadata bio. Use __bio_add_page() instead as adding a single page to a new bio is always guaranteed to succeed. This brings us a step closer to marking bio_add_page() __must_check

[dm-devel] [PATCH v4 06/22] md: raid5-log: use __bio_add_page to add single page

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The raid5 log metadata submission code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. Use __bio_add_page() as adding a single page to a newly created bio is guaranteed to succeed. This brings us

[dm-devel] [PATCH v4 00/22] bio: check return values of bio_add_page

2023-04-21 Thread Johannes Thumshirn
We have two functions for adding a page to a bio, __bio_add_page() which is used to add a single page to a freshly created bio and bio_add_page() which is used to add a page to an existing bio. While __bio_add_page() is expected to succeed, bio_add_page() can fail. This series converts the

[dm-devel] [PATCH v4 17/22] md: raid1: check if adding pages to resync bio fails

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn Check if adding pages to resync bio fails and if bail out. As the comment above suggests this cannot happen, WARN if it actually happens. This way we can mark bio_add_pages as __must_check. Signed-off-by: Johannes Thumshirn Reviewed-by: Damien Le Moal Acked-by: Song

[dm-devel] [PATCH v4 16/22] md: raid1: use __bio_add_page for adding single page to bio

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The sync request code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. Use __bio_add_page() as adding a single page to a newly created bio is guaranteed to succeed. This brings us a step closer to

[dm-devel] [PATCH v4 04/22] fs: buffer: use __bio_add_page to add single page to bio

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The buffer_head submission code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. Use __bio_add_page() as adding a single page to a newly created bio is guaranteed to succeed. This brings us a step

[dm-devel] [PATCH v4 15/22] md: check for failure when adding pages in alloc_behind_master_bio

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn alloc_behind_master_bio() can possibly add multiple pages to a bio, but it is not checking for the return value of bio_add_page() if adding really succeeded. Check if the page adding succeeded and if not bail out. Signed-off-by: Johannes Thumshirn Reviewed-by: Damien

[dm-devel] [PATCH v4 01/22] swap: use __bio_add_page to add page to bio

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The swap code only adds a single page to a newly created bio. So use __bio_add_page() to add the page which is guaranteed to succeed in this case. This brings us closer to marking bio_add_page() as __must_check. Signed-off-by: Johannes Thumshirn Reviewed-by: Damien Le

[dm-devel] [PATCH v4 12/22] zonefs: use __bio_add_page for adding single page to bio

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The zonefs superblock reading code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. Use __bio_add_page() as adding a single page to a newly created bio is guaranteed to succeed. This brings us a

[dm-devel] [PATCH v4 20/22] block: add __bio_add_folio

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn Just like for bio_add_pages() add a no-fail variant for bio_add_folio(). Signed-off-by: Johannes Thumshirn --- block/bio.c | 8 include/linux/bio.h | 1 + 2 files changed, 9 insertions(+) diff --git a/block/bio.c b/block/bio.c index

[dm-devel] [PATCH v4 09/22] btrfs: raid56: use __bio_add_page to add single page

2023-04-21 Thread Johannes Thumshirn
From: Johannes Thumshirn The btrfs raid58 sector submission code uses bio_add_page() to add a page to a newly created bio. bio_add_page() can fail, but the return value is never checked. Use __bio_add_page() as adding a single page to a newly created bio is guaranteed to succeed. This brings