All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pankaj Raghav (Samsung)" <pankaj.raghav@linux.dev>
To: Breno Leitao <leitao@debian.org>
Cc: Christian Brauner <brauner@kernel.org>,
	Jens Axboe <axboe@kernel.dk>,  Hannes Reinecke <hare@suse.de>,
	Pankaj Raghav <p.raghav@samsung.com>,
	 Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	 Christoph Hellwig <hch@infradead.org>,
	linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	 linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH v2] iomap: don't update i_size of block devices on buffered write
Date: Mon, 23 Nov 2026 14:25:35 +0100	[thread overview]
Message-ID: <awQ-uwPzYYEVJxjz@quentin> (raw)
In-Reply-To: <20261120-iomap-bdev-isize-v2-1-f25cc668fbc1@debian.org>

On Fri, Nov 20, 2026 at 12:24:39PM -0800, Breno Leitao wrote:
> We are seeing this warning on an arm64 linux-next host while the ublk
> selftests run (stress_01 deletes the ublk disks under fio buffered
> writes):
> 
>   WARNING: mm/truncate.c:902 at pagecache_isize_extended+0x37c/0x490, CPU#40: iou-wrk-3496756/3497370
>   Call trace:
>    pagecache_isize_extended+0x37c/0x490 (P)
>    iomap_file_buffered_write+0x38c/0x5d0
>    blkdev_buffered_write+0xcc/0x138
>    blkdev_write_iter+0x32c/0x4e0
>    io_write+0x77c/0xff8
> 
> The theory is that the disk shrank under the write. del_gendisk() sets
> the capacity to 0, which writes the bdev inode's i_size under
> bd_size_lock only. A writer whose mapping predates that reads
> old_size == 0 in iomap_write_iter(), sets i_size to pos + written and
> calls pagecache_isize_extended(inode, 0, pos). blkdev_buffered_write()
> holds i_rwsem shared, so a writer at a lower offset can store a smaller
> i_size in between, and WARN_ON(to > inode->i_size) fires. Even without
> the warning, the write path regrows the size of a dead disk. The block
> layer owns that size (bdev_set_nr_sectors()), and blkdev_write_end()
> never touched it before the switch to iomap.
> 
> A reproducer on linux-next supports the theory: 128 threads doing 64K
> buffered writes to a loop device, while another thread flips its
> capacity between 1M and 1G with LOOP_SET_STATUS64, hit the warning 6
> to 18 times per 30 second run (4 runs). With this patch it never fires,
> and data written through the page cache still reads back intact.
> 
> Skip the size update and pagecache_isize_extended() for block devices.
> 
> Fixes: 487c607df790 ("block: use iomap for writes to block devices")
> Signed-off-by: Breno Leitao <leitao@debian.org>

Looks good,
Reviewed-by: Pankaj Raghav (Samsung) <pankaj.raghav@linux.dev>

--
Pankaj

  parent reply	other threads:[~2026-11-23 13:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20 20:24 [PATCH v2] iomap: don't update i_size of block devices on buffered write Breno Leitao
2026-11-21  0:15 ` Christoph Hellwig
2026-11-23 13:25 ` Pankaj Raghav (Samsung) [this message]
2026-12-01 13:04 ` Christian Brauner

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=awQ-uwPzYYEVJxjz@quentin \
    --to=pankaj.raghav@linux.dev \
    --cc=axboe@kernel.dk \
    --cc=brauner@kernel.org \
    --cc=hare@suse.de \
    --cc=hch@infradead.org \
    --cc=johannes.thumshirn@wdc.com \
    --cc=kernel-team@meta.com \
    --cc=leitao@debian.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=p.raghav@samsung.com \
    /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.