All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
	Christian Brauner <brauner@kernel.org>,
	Jens Axboe <axboe@kernel.dk>, David Sterba <dsterba@suse.com>,
	Theodore Ts'o <tytso@mit.edu>, Jaegeuk Kim <jaegeuk@kernel.org>,
	Chao Yu <chao@kernel.org>, Trond Myklebust <trondmy@kernel.org>,
	Anna Schumaker <anna@kernel.org>,
	Namjae Jeon <linkinjeon@kernel.org>,
	Hyunchul Lee <hyc.lee@gmail.com>,
	Steve French <sfrench@samba.org>,
	Paulo Alcantara <pc@manguebit.org>,
	Carlos Maiolino <cem@kernel.org>,
	Damien Le Moal <dlemoal@kernel.org>,
	Naohiro Aota <naohiro.aota@wdc.com>,
	linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-doc@vger.kernel.org, linux-mm@kvack.org,
	linux-block@vger.kernel.org, linux-btrfs@vger.kernel.org,
	linux-ext4@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org
Subject: Re: [PATCH 08/12] swap,iomap: simplify iomap_swapfile_iter
Date: Wed, 13 May 2026 07:59:19 -0700	[thread overview]
Message-ID: <20260513145919.GP9555@frogsfrogsfrogs> (raw)
In-Reply-To: <20260513065608.GA2250@lst.de>

On Wed, May 13, 2026 at 08:56:08AM +0200, Christoph Hellwig wrote:
> On Tue, May 12, 2026 at 10:02:04AM -0700, Darrick J. Wong wrote:
> > OH.  Now I remember why -- it's to handle contiguous mixed mappings
> > better.
> > 
> > Let's say that you have a 1k fsblock filesystem and 4k base pages.  You
> > fallocate an 8G swap file and then mkswap it.  The first mapping is a 1k
> > written mapping at offset 0 for the swap header, followed by an 8388607k
> > unwritten mapping at offset 3k.
> > 
> > The PAGE_SIZE rounding code in iomap_swapfile_add_extent will round the
> > end of that first mapping down to zero and ignore it.  The second
> > mapping will be treated as if it were a 8388604k mapping starting at
> > offset 4096.  Now the page counts are wrong and the swapon fails.
> 
> Do we care about this use case?  I guess you did as you implemented
> his, but still?

We do, because mkswap -F uses fallocate nowadays:

$ mkswap -s 4194304 -F a
Setting up swapspace version 1, size = 4 MiB (4190208 bytes)
no label, UUID=bc9746bf-e200-4944-927c-80d83872f1cb
$ filefrag -v a
Filesystem type is: 58465342
File size of a is 4194304 (1024 blocks of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..       0:  411383552.. 411383552:      1:            
   1:        1..    1023:  411383553.. 411384575:   1023:             last,unwritten,eof
a: 1 extent found

> > A more generic solution to this would be to change add_swap_extent to
> > take sector_t addr and length values and use them to construct a bitmap
> > representing contiguous physical space on the bdev, accounting of course
> > for PAGE_SIZE alignment.  Except for the swap header page, every other
> > contiguously set page-aligned region in the bitmap gets added to the
> > swap extent map.
> 
> You don't even need a bitmap, just do basically the same checks as
> the iomap code when moving to a new swap extent after moving to use
> the sector_t.  And it really should anyway, as the current abuse of
> sector_t to store a disk offset in PAGE_SIZE units is pretty gross.

Oh, I meant this to handle the particularly gross case where the fsblock
size is smaller than a base page, but there are a very large number of
file mappings that point to a physically contiguous extent but are not
in logical order:

{.offset=0, .length=1k, .addr=7},
{.offset=1, .length=1k, .addr=6},
{.offset=2, .length=1k, .addr=5},
{.offset=3, .length=1k, .addr=4},
{.offset=4, .length=1k, .addr=3},
{.offset=5, .length=1k, .addr=2},
{.offset=6, .length=1k, .addr=1},
{.offset=7, .length=1k, .addr=0},

That's two pages of swapfile, but with the current layout accumulation
code we "cannot" find either.

--D


WARNING: multiple messages have this Message-ID (diff)
From: "Darrick J. Wong via Linux-f2fs-devel" <linux-f2fs-devel@lists.sourceforge.net>
To: Christoph Hellwig <hch@lst.de>
Cc: Paulo Alcantara <pc@manguebit.org>,
	linux-doc@vger.kernel.org, Carlos Maiolino <cem@kernel.org>,
	Hyunchul Lee <hyc.lee@gmail.com>,
	linux-mm@kvack.org, Naohiro Aota <naohiro.aota@wdc.com>,
	linux-xfs@vger.kernel.org, linux-ext4@vger.kernel.org,
	Namjae Jeon <linkinjeon@kernel.org>, Chris Li <chrisl@kernel.org>,
	linux-nfs@vger.kernel.org, linux-block@vger.kernel.org,
	Damien Le Moal <dlemoal@kernel.org>,
	David Sterba <dsterba@suse.com>, Jaegeuk Kim <jaegeuk@kernel.org>,
	Jens Axboe <axboe@kernel.dk>,
	Christian Brauner <brauner@kernel.org>,
	Kairui Song <kasong@tencent.com>, Theodore Ts'o <tytso@mit.edu>,
	linux-cifs@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	Steve French <sfrench@samba.org>,
	linux-btrfs@vger.kernel.org, Anna Schumaker <anna@kernel.org>,
	linux-fsdevel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Trond Myklebust <trondmy@kernel.org>
Subject: Re: [f2fs-dev] [PATCH 08/12] swap, iomap: simplify iomap_swapfile_iter
Date: Wed, 13 May 2026 07:59:19 -0700	[thread overview]
Message-ID: <20260513145919.GP9555@frogsfrogsfrogs> (raw)
In-Reply-To: <20260513065608.GA2250@lst.de>

On Wed, May 13, 2026 at 08:56:08AM +0200, Christoph Hellwig wrote:
> On Tue, May 12, 2026 at 10:02:04AM -0700, Darrick J. Wong wrote:
> > OH.  Now I remember why -- it's to handle contiguous mixed mappings
> > better.
> > 
> > Let's say that you have a 1k fsblock filesystem and 4k base pages.  You
> > fallocate an 8G swap file and then mkswap it.  The first mapping is a 1k
> > written mapping at offset 0 for the swap header, followed by an 8388607k
> > unwritten mapping at offset 3k.
> > 
> > The PAGE_SIZE rounding code in iomap_swapfile_add_extent will round the
> > end of that first mapping down to zero and ignore it.  The second
> > mapping will be treated as if it were a 8388604k mapping starting at
> > offset 4096.  Now the page counts are wrong and the swapon fails.
> 
> Do we care about this use case?  I guess you did as you implemented
> his, but still?

We do, because mkswap -F uses fallocate nowadays:

$ mkswap -s 4194304 -F a
Setting up swapspace version 1, size = 4 MiB (4190208 bytes)
no label, UUID=bc9746bf-e200-4944-927c-80d83872f1cb
$ filefrag -v a
Filesystem type is: 58465342
File size of a is 4194304 (1024 blocks of 4096 bytes)
 ext:     logical_offset:        physical_offset: length:   expected: flags:
   0:        0..       0:  411383552.. 411383552:      1:            
   1:        1..    1023:  411383553.. 411384575:   1023:             last,unwritten,eof
a: 1 extent found

> > A more generic solution to this would be to change add_swap_extent to
> > take sector_t addr and length values and use them to construct a bitmap
> > representing contiguous physical space on the bdev, accounting of course
> > for PAGE_SIZE alignment.  Except for the swap header page, every other
> > contiguously set page-aligned region in the bitmap gets added to the
> > swap extent map.
> 
> You don't even need a bitmap, just do basically the same checks as
> the iomap code when moving to a new swap extent after moving to use
> the sector_t.  And it really should anyway, as the current abuse of
> sector_t to store a disk offset in PAGE_SIZE units is pretty gross.

Oh, I meant this to handle the particularly gross case where the fsblock
size is smaller than a base page, but there are a very large number of
file mappings that point to a physically contiguous extent but are not
in logical order:

{.offset=0, .length=1k, .addr=7},
{.offset=1, .length=1k, .addr=6},
{.offset=2, .length=1k, .addr=5},
{.offset=3, .length=1k, .addr=4},
{.offset=4, .length=1k, .addr=3},
{.offset=5, .length=1k, .addr=2},
{.offset=6, .length=1k, .addr=1},
{.offset=7, .length=1k, .addr=0},

That's two pages of swapfile, but with the current layout accumulation
code we "cannot" find either.

--D


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2026-05-13 14:59 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12  5:35 improve the swap_activate interface Christoph Hellwig
2026-05-12  5:35 ` [f2fs-dev] " Christoph Hellwig
2026-05-12  5:35 ` [PATCH 01/12] swap: remove the maxpages variable in sys_swapon Christoph Hellwig
2026-05-12  5:35   ` [f2fs-dev] " Christoph Hellwig
2026-05-12  7:08   ` Damien Le Moal
2026-05-12  7:08     ` [f2fs-dev] " Damien Le Moal via Linux-f2fs-devel
2026-05-12  7:20     ` Christoph Hellwig
2026-05-12  7:20       ` [f2fs-dev] " Christoph Hellwig
2026-05-12 14:19   ` Hannes Reinecke
2026-05-12 14:19     ` [f2fs-dev] " Hannes Reinecke
2026-05-12 16:14   ` Darrick J. Wong
2026-05-12 16:14     ` [f2fs-dev] " Darrick J. Wong via Linux-f2fs-devel
2026-05-15 22:37   ` Chris Li
2026-05-15 22:37     ` [f2fs-dev] " Chris Li via Linux-f2fs-devel
2026-05-12  5:35 ` [PATCH 02/12] swap: move boilerplate code into the core swap code Christoph Hellwig
2026-05-12  5:35   ` [f2fs-dev] " Christoph Hellwig
2026-05-12  7:11   ` Damien Le Moal
2026-05-12  7:11     ` [f2fs-dev] " Damien Le Moal via Linux-f2fs-devel
2026-05-12 16:33   ` Darrick J. Wong
2026-05-12 16:33     ` [f2fs-dev] " Darrick J. Wong via Linux-f2fs-devel
2026-05-15 22:29   ` Chris Li
2026-05-15 22:29     ` [f2fs-dev] " Chris Li via Linux-f2fs-devel
2026-05-12  5:35 ` [PATCH 03/12] swap,fs: move swapfile operations to struct file_operations Christoph Hellwig
2026-05-12  5:35   ` [f2fs-dev] [PATCH 03/12] swap, fs: " Christoph Hellwig
2026-05-12  7:16   ` [PATCH 03/12] swap,fs: " Damien Le Moal
2026-05-12  7:16     ` [f2fs-dev] [PATCH 03/12] swap, fs: " Damien Le Moal via Linux-f2fs-devel
2026-05-12 16:41   ` [PATCH 03/12] swap,fs: " Darrick J. Wong
2026-05-12 16:41     ` [f2fs-dev] [PATCH 03/12] swap, fs: " Darrick J. Wong via Linux-f2fs-devel
2026-05-15 22:24   ` [PATCH 03/12] swap,fs: " Chris Li
2026-05-15 22:24     ` [f2fs-dev] [PATCH 03/12] swap, fs: " Chris Li via Linux-f2fs-devel
2026-05-12  5:35 ` [PATCH 04/12] swap: restrict to regular files or block devices Christoph Hellwig
2026-05-12  5:35   ` [f2fs-dev] " Christoph Hellwig
2026-05-12  7:17   ` Damien Le Moal
2026-05-12  7:17     ` [f2fs-dev] " Damien Le Moal via Linux-f2fs-devel
2026-05-12 16:42   ` Darrick J. Wong
2026-05-12 16:42     ` [f2fs-dev] " Darrick J. Wong via Linux-f2fs-devel
2026-05-15 22:19   ` Chris Li
2026-05-15 22:19     ` [f2fs-dev] " Chris Li via Linux-f2fs-devel
2026-05-12  5:35 ` [PATCH 05/12] swap: cleanup setup_swap_extents Christoph Hellwig
2026-05-12  5:35   ` [f2fs-dev] " Christoph Hellwig
2026-05-12  7:18   ` Damien Le Moal
2026-05-12  7:18     ` [f2fs-dev] " Damien Le Moal via Linux-f2fs-devel
2026-05-12 16:43   ` Darrick J. Wong
2026-05-12 16:43     ` [f2fs-dev] " Darrick J. Wong via Linux-f2fs-devel
2026-05-13  5:56     ` Christoph Hellwig
2026-05-13  5:56       ` [f2fs-dev] " Christoph Hellwig
2026-05-15 22:18   ` Chris Li
2026-05-15 22:18     ` [f2fs-dev] " Chris Li via Linux-f2fs-devel
2026-05-12  5:35 ` [PATCH 06/12] swap,block: move the block device swapon code into block/fops.c Christoph Hellwig
2026-05-12  5:35   ` [f2fs-dev] [PATCH 06/12] swap, block: " Christoph Hellwig
2026-05-12  7:20   ` [PATCH 06/12] swap,block: " Damien Le Moal
2026-05-12  7:20     ` [f2fs-dev] [PATCH 06/12] swap, block: " Damien Le Moal via Linux-f2fs-devel
2026-05-12 16:44   ` [PATCH 06/12] swap,block: " Darrick J. Wong
2026-05-12 16:44     ` [f2fs-dev] [PATCH 06/12] swap, block: " Darrick J. Wong via Linux-f2fs-devel
2026-05-15 22:14   ` [PATCH 06/12] swap,block: " Chris Li
2026-05-15 22:14     ` [f2fs-dev] [PATCH 06/12] swap, block: " Chris Li via Linux-f2fs-devel
2026-05-12  5:35 ` [PATCH 07/12] swap,block: limit swap file size to device size Christoph Hellwig
2026-05-12  5:35   ` [f2fs-dev] [PATCH 07/12] swap, block: " Christoph Hellwig
2026-05-12  7:21   ` [PATCH 07/12] swap,block: " Damien Le Moal
2026-05-12  7:21     ` [f2fs-dev] [PATCH 07/12] swap, block: " Damien Le Moal via Linux-f2fs-devel
2026-05-12  7:23     ` [PATCH 07/12] swap,block: " Christoph Hellwig
2026-05-12  7:23       ` [f2fs-dev] [PATCH 07/12] swap, block: " Christoph Hellwig
2026-05-12 16:45   ` [PATCH 07/12] swap,block: " Darrick J. Wong
2026-05-12 16:45     ` [f2fs-dev] [PATCH 07/12] swap, block: " Darrick J. Wong via Linux-f2fs-devel
2026-05-12  5:35 ` [PATCH 08/12] swap,iomap: simplify iomap_swapfile_iter Christoph Hellwig
2026-05-12  5:35   ` [f2fs-dev] " Christoph Hellwig
2026-05-12  7:31   ` Damien Le Moal
2026-05-12  7:31     ` [f2fs-dev] [PATCH 08/12] swap, iomap: " Damien Le Moal via Linux-f2fs-devel
2026-05-12 17:02   ` [PATCH 08/12] swap,iomap: " Darrick J. Wong
2026-05-12 17:02     ` [f2fs-dev] [PATCH 08/12] swap, iomap: " Darrick J. Wong via Linux-f2fs-devel
2026-05-13  6:56     ` [PATCH 08/12] swap,iomap: " Christoph Hellwig
2026-05-13  6:56       ` [f2fs-dev] [PATCH 08/12] swap, iomap: " Christoph Hellwig
2026-05-13 14:59       ` Darrick J. Wong [this message]
2026-05-13 14:59         ` Darrick J. Wong via Linux-f2fs-devel
2026-05-12  5:35 ` [PATCH 09/12] swap: push down setting sis->bdev into ->swap_activate Christoph Hellwig
2026-05-12  5:35   ` [f2fs-dev] " Christoph Hellwig
2026-05-12  7:34   ` Damien Le Moal
2026-05-12  7:34     ` [f2fs-dev] " Damien Le Moal via Linux-f2fs-devel
2026-05-12 17:08   ` Darrick J. Wong
2026-05-12 17:08     ` [f2fs-dev] " Darrick J. Wong via Linux-f2fs-devel
2026-05-13  5:58     ` Christoph Hellwig
2026-05-13  5:58       ` [f2fs-dev] " Christoph Hellwig
2026-05-13  7:44       ` Damien Le Moal
2026-05-13  7:44         ` [f2fs-dev] " Damien Le Moal via Linux-f2fs-devel
2026-05-13  7:46         ` Christoph Hellwig
2026-05-13  7:46           ` [f2fs-dev] " Christoph Hellwig
2026-05-13  7:58           ` Damien Le Moal
2026-05-13  7:58             ` [f2fs-dev] " Damien Le Moal via Linux-f2fs-devel
2026-05-14 14:37             ` Darrick J. Wong
2026-05-14 14:37               ` [f2fs-dev] " Darrick J. Wong via Linux-f2fs-devel
2026-05-15 22:12   ` Chris Li
2026-05-15 22:12     ` [f2fs-dev] " Chris Li via Linux-f2fs-devel
2026-05-12  5:35 ` [PATCH 10/12] swap: add a swap_activate_fs_ops helper Christoph Hellwig
2026-05-12  5:35   ` [f2fs-dev] " Christoph Hellwig
2026-05-12  7:36   ` Damien Le Moal
2026-05-12  7:36     ` [f2fs-dev] " Damien Le Moal via Linux-f2fs-devel
2026-05-12 17:09   ` Darrick J. Wong
2026-05-12 17:09     ` [f2fs-dev] " Darrick J. Wong via Linux-f2fs-devel
2026-05-15 22:00   ` Chris Li
2026-05-15 22:00     ` [f2fs-dev] " Chris Li via Linux-f2fs-devel
2026-05-12  5:35 ` [PATCH 11/12] swap: move struct swap_extent to swapfile.c Christoph Hellwig
2026-05-12  5:35   ` [f2fs-dev] " Christoph Hellwig
2026-05-12  7:36   ` Damien Le Moal
2026-05-12  7:36     ` [f2fs-dev] " Damien Le Moal via Linux-f2fs-devel
2026-05-12 17:09   ` Darrick J. Wong
2026-05-12 17:09     ` [f2fs-dev] " Darrick J. Wong via Linux-f2fs-devel
2026-05-15 21:58   ` Chris Li
2026-05-15 21:58     ` [f2fs-dev] " Chris Li via Linux-f2fs-devel
2026-05-12  5:35 ` [PATCH 12/12] swap: move swap_info_struct to mm/swap.h Christoph Hellwig
2026-05-12  5:35   ` [f2fs-dev] " Christoph Hellwig
2026-05-12  7:41   ` Damien Le Moal
2026-05-12  7:41     ` [f2fs-dev] " Damien Le Moal via Linux-f2fs-devel
2026-05-12 17:10   ` Darrick J. Wong
2026-05-12 17:10     ` [f2fs-dev] " Darrick J. Wong via Linux-f2fs-devel
2026-05-15 21:58   ` Chris Li
2026-05-15 21:58     ` [f2fs-dev] " Chris Li via Linux-f2fs-devel
2026-05-13 20:34 ` improve the swap_activate interface Steve French
2026-05-13 20:34   ` [f2fs-dev] " Steve French
2026-05-15 11:33   ` Christoph Hellwig
2026-05-15 11:33     ` [f2fs-dev] " Christoph Hellwig
2026-05-15 21:40 ` Chris Li
2026-05-15 21:40   ` [f2fs-dev] " Chris Li via Linux-f2fs-devel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260513145919.GP9555@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=anna@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=cem@kernel.org \
    --cc=chao@kernel.org \
    --cc=chrisl@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=dsterba@suse.com \
    --cc=hch@lst.de \
    --cc=hyc.lee@gmail.com \
    --cc=jaegeuk@kernel.org \
    --cc=kasong@tencent.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=naohiro.aota@wdc.com \
    --cc=pc@manguebit.org \
    --cc=sfrench@samba.org \
    --cc=trondmy@kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.