From: Yu Kuai <yukuai1@huaweicloud.com>
To: Yu Kuai <yukuai1@huaweicloud.com>,
jack@suse.cz, hch@lst.de, brauner@kernel.org,
viro@zeniv.linux.org.uk, axboe@kernel.dk, gustavoars@kernel.org
Cc: linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org,
yi.zhang@huawei.com, yangerkun@huawei.com,
"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: [PATCH vfs.all 00/26] fs & block: remove bdev->bd_inode
Date: Sun, 7 Apr 2024 10:20:39 +0800 [thread overview]
Message-ID: <227a872d-51e9-babc-0489-7fcc7112c0e6@huaweicloud.com> (raw)
In-Reply-To: <20240406090930.2252838-1-yukuai1@huaweicloud.com>
Hi, Christian!
Hi, Jan!
+CC Gustavo
While testing this set, I found that the branch vfs.all seems broken,
xfstests report success while lots of BUG is reported in dmesg:
[22709.079704]
=============================================================================^M
[22709.082404] BUG kmalloc-16 (Not tainted): Right Redzone overwritten^M
[22709.084148]
-----------------------------------------------------------------------------^M
[22709.084148] ^M
[22709.086784] 0xffff88817d52e7a0-0xffff88817d52e7a7 @offset=1952. First
byte 0x0 instead of 0xcc^M
[22709.089169] Allocated in do_handle_open+0x97/0x440 age=10 cpu=13
pid=814795^M
[22709.091158] __kmalloc+0x41d/0x5e0^M
[22709.092153] do_handle_open+0x97/0x440^M
[22709.093240] __x64_sys_open_by_handle_at+0x23/0x30^M
[22709.094482] do_syscall_64+0xb1/0x210^M
[22709.095316] entry_SYSCALL_64_after_hwframe+0x6c/0x74^M
[22709.096414] Freed in kvfree+0x4c/0x60 age=43560 cpu=15 pid=813506^M
[22709.097719] kfree+0x31c/0x530^M
[22709.098396] kvfree+0x4c/0x60^M
[22709.099048] ext4_mb_release+0x29c/0x570^M
[22709.099901] ext4_put_super+0x17f/0x590^M
[22709.100735] generic_shutdown_super+0xba/0x240^M
[22709.101698] kill_block_super+0x22/0x70^M
[22709.102525] ext4_kill_sb+0x2a/0x70^M
[22709.103297] deactivate_locked_super+0x4f/0xe0^M
[22709.104261] deactivate_super+0x81/0x90^M
[22709.104876] cleanup_mnt+0xe0/0x1b0^M
[22709.105419] __cleanup_mnt+0x1a/0x30^M
[22709.105964] task_work_run+0x88/0x100^M
[22709.106531] syscall_exit_to_user_mode+0x3cc/0x3e0^M
[22709.107263] do_syscall_64+0xc5/0x210^M
[22709.107820] entry_SYSCALL_64_after_hwframe+0x6c/0x74^M
While digging this problem, I found that commit 1b43c4629756 ("fs:
Annotate struct file_handle with __counted_by() and use struct_size()")
might made a mistake, and I verified following patch can fix the
problem.
Thanks,
Kuai
diff --git a/fs/fhandle.c b/fs/fhandle.c
index 53ed54711cd2..bcfecac2dc54 100644
--- a/fs/fhandle.c
+++ b/fs/fhandle.c
@@ -201,8 +201,7 @@ static int handle_to_path(int mountdirfd, struct
file_handle __user *ufh,
/* copy the full handle */
*handle = f_handle;
if (copy_from_user(&handle->f_handle,
- &ufh->f_handle,
- struct_size(ufh, f_handle,
f_handle.handle_bytes))) {
+ &ufh->f_handle, f_handle.handle_bytes)) {
retval = -EFAULT;
goto out_handle;
}
在 2024/04/06 17:09, Yu Kuai 写道:
> From: Yu Kuai <yukuai3@huawei.com>
>
> Hi, Jens!
> Hi, Jan!
> Hi, Christoph!
> Hi, Christian!
> Hi, AL!
>
> Sorry for the delay(I was overwhelmed with other work stuff). Main changes
> from last version is patch 22(modified based on [1]), the idea is that
> stash a 'bdev_file' in 'bd_inode->i_private' while opening bdev the first
> time, and release it when last opener close the bdev.
>
> The patch to use bdev and bdev_file as union for iomap/buffer_head is
> dropped and changes for iomap/buffer is splitted to patch 23-26.
>
> I tested this set in my VM with blktests for virtio-scsi and xfstests
> for ext4/xfs for one round now, no regerssions are found yet.
>
> Please let me know what you think!
>
> [1] https://lore.kernel.org/all/c62dac0e-666f-9cc9-cffe-f3d985029d6a@huaweicloud.com/
>
> Changes from RFC v4:
> - respin on the top of vfs.all branch from vfs tree;
> - add review tag, patches that are not reviewed: patch 19-26;
> - add patch 21, fix a module reference problem;
> - instead of using a union of bdev(for raw block device) and
> bdev_file(for filesystems), add patch 22 to stash a bdev_file to
> bd_inode->i_private, so that iomap and buffer_head for raw block device
> can convert to use bdev_file as well;
> - split the huge path for iomap/buffer into 4 patches, 21-24;
>
> Changes from RFC v3:
> - respin on the top of linux-next, based on Christian's patchset to
> open bdev as file. Most of patches from v3 is dropped and change to use
> file_inode(bdev_file) to get bd_inode or bdev_file->f_mapping to get
> bd_inode->i_mapping.
>
> Changes from RFC v2:
> - remove bdev_associated_mapping() and patch 12 from v1;
> - add kerneldoc comments for new bdev apis;
> - rename __bdev_get_folio() to bdev_get_folio;
> - fix a problem in erofs that erofs_init_metabuf() is not always
> called.
> - add reviewed-by tag for patch 15-17;
>
> Changes from RFC v1:
> - remove some bdev apis that is not necessary;
> - pass in offset for bdev_read_folio() and __bdev_get_folio();
> - remove bdev_gfp_constraint() and add a new helper in fs/buffer.c to
> prevent access bd_indoe() directly from mapping_gfp_constraint() in
> ext4.(patch 15, 16);
> - remove block_device_ejected() from ext4.
>
> Yu Kuai (26):
> block: move two helpers into bdev.c
> block: remove sync_blockdev_nowait()
> block: remove sync_blockdev_range()
> block: prevent direct access of bd_inode
> block: add a helper bdev_read_folio()
> bcachefs: remove dead function bdev_sectors()
> cramfs: prevent direct access of bd_inode
> erofs: prevent direct access of bd_inode
> nilfs2: prevent direct access of bd_inode
> gfs2: prevent direct access of bd_inode
> btrfs: prevent direct access of bd_inode
> ext4: remove block_device_ejected()
> ext4: prevent direct access of bd_inode
> jbd2: prevent direct access of bd_inode
> s390/dasd: use bdev api in dasd_format()
> bcache: prevent direct access of bd_inode
> block2mtd: prevent direct access of bd_inode
> scsi: use bdev helper in scsi_bios_ptable()
> dm-vdo: convert to use bdev_file
> block: factor out a helper init_bdev_file()
> block: fix module reference leakage from bdev_open_by_dev error path
> block: stash a bdev_file to read/write raw blcok_device
> iomap: add helpers helpers to get and set bdev
> iomap: convert to use bdev_file
> buffer: add helpers to get and set bdev
> buffer: convert to use bdev_file
>
> block/bdev.c | 262 ++++++++++++++++------
> block/blk-zoned.c | 4 +-
> block/blk.h | 2 +
> block/fops.c | 6 +-
> block/genhd.c | 9 +-
> block/ioctl.c | 8 +-
> block/partitions/core.c | 8 +-
> drivers/md/bcache/super.c | 7 +-
> drivers/md/dm-vdo/dedupe.c | 7 +-
> drivers/md/dm-vdo/dm-vdo-target.c | 9 +-
> drivers/md/dm-vdo/indexer/config.c | 2 +-
> drivers/md/dm-vdo/indexer/config.h | 4 +-
> drivers/md/dm-vdo/indexer/index-layout.c | 6 +-
> drivers/md/dm-vdo/indexer/index-layout.h | 2 +-
> drivers/md/dm-vdo/indexer/index-session.c | 18 +-
> drivers/md/dm-vdo/indexer/index.c | 4 +-
> drivers/md/dm-vdo/indexer/index.h | 2 +-
> drivers/md/dm-vdo/indexer/indexer.h | 6 +-
> drivers/md/dm-vdo/indexer/io-factory.c | 17 +-
> drivers/md/dm-vdo/indexer/io-factory.h | 4 +-
> drivers/md/dm-vdo/indexer/volume.c | 4 +-
> drivers/md/dm-vdo/indexer/volume.h | 2 +-
> drivers/md/dm-vdo/vdo.c | 2 +-
> drivers/md/md-bitmap.c | 2 +-
> drivers/mtd/devices/block2mtd.c | 6 +-
> drivers/s390/block/dasd_ioctl.c | 5 +-
> drivers/scsi/scsicam.c | 3 +-
> fs/affs/file.c | 2 +-
> fs/bcachefs/util.h | 5 -
> fs/btrfs/disk-io.c | 17 +-
> fs/btrfs/disk-io.h | 4 +-
> fs/btrfs/inode.c | 2 +-
> fs/btrfs/super.c | 2 +-
> fs/btrfs/volumes.c | 25 ++-
> fs/btrfs/zoned.c | 20 +-
> fs/btrfs/zoned.h | 4 +-
> fs/buffer.c | 104 ++++-----
> fs/cramfs/inode.c | 2 +-
> fs/direct-io.c | 4 +-
> fs/erofs/data.c | 22 +-
> fs/erofs/internal.h | 1 +
> fs/erofs/zmap.c | 2 +-
> fs/exfat/fatent.c | 2 +-
> fs/ext2/inode.c | 4 +-
> fs/ext2/xattr.c | 2 +-
> fs/ext4/dir.c | 2 +-
> fs/ext4/ext4_jbd2.c | 2 +-
> fs/ext4/inode.c | 2 +-
> fs/ext4/mmp.c | 2 +-
> fs/ext4/page-io.c | 5 +-
> fs/ext4/super.c | 30 +--
> fs/ext4/xattr.c | 2 +-
> fs/f2fs/data.c | 10 +-
> fs/f2fs/f2fs.h | 1 +
> fs/fat/inode.c | 2 +-
> fs/fuse/dax.c | 2 +-
> fs/gfs2/aops.c | 2 +-
> fs/gfs2/bmap.c | 2 +-
> fs/gfs2/glock.c | 2 +-
> fs/gfs2/meta_io.c | 2 +-
> fs/gfs2/ops_fstype.c | 2 +-
> fs/hpfs/file.c | 2 +-
> fs/iomap/buffered-io.c | 8 +-
> fs/iomap/direct-io.c | 11 +-
> fs/iomap/swapfile.c | 2 +-
> fs/iomap/trace.h | 6 +-
> fs/jbd2/commit.c | 2 +-
> fs/jbd2/journal.c | 34 +--
> fs/jbd2/recovery.c | 9 +-
> fs/jbd2/revoke.c | 14 +-
> fs/jbd2/transaction.c | 8 +-
> fs/mpage.c | 18 +-
> fs/nilfs2/btnode.c | 4 +-
> fs/nilfs2/gcinode.c | 2 +-
> fs/nilfs2/mdt.c | 2 +-
> fs/nilfs2/page.c | 4 +-
> fs/nilfs2/recovery.c | 27 ++-
> fs/nilfs2/segment.c | 2 +-
> fs/ntfs3/fsntfs.c | 10 +-
> fs/ntfs3/inode.c | 4 +-
> fs/ntfs3/super.c | 6 +-
> fs/ocfs2/journal.c | 2 +-
> fs/reiserfs/fix_node.c | 2 +-
> fs/reiserfs/journal.c | 10 +-
> fs/reiserfs/prints.c | 4 +-
> fs/reiserfs/reiserfs.h | 6 +-
> fs/reiserfs/stree.c | 2 +-
> fs/reiserfs/tail_conversion.c | 2 +-
> fs/sync.c | 9 +-
> fs/xfs/xfs_iomap.c | 4 +-
> fs/zonefs/file.c | 4 +-
> include/linux/blk_types.h | 2 +-
> include/linux/blkdev.h | 19 +-
> include/linux/buffer_head.h | 81 ++++---
> include/linux/iomap.h | 13 +-
> include/linux/jbd2.h | 18 +-
> include/trace/events/block.h | 2 +-
> 97 files changed, 620 insertions(+), 440 deletions(-)
>
next prev parent reply other threads:[~2024-04-07 2:20 UTC|newest]
Thread overview: 117+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-06 9:09 [PATCH vfs.all 00/26] fs & block: remove bdev->bd_inode Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 01/26] block: move two helpers into bdev.c Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 02/26] block: remove sync_blockdev_nowait() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 03/26] block: remove sync_blockdev_range() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 04/26] block: prevent direct access of bd_inode Yu Kuai
2024-04-07 2:22 ` Al Viro
2024-04-07 2:37 ` Yu Kuai
2024-04-11 11:12 ` Christian Brauner
2024-04-06 9:09 ` [PATCH vfs.all 05/26] block: add a helper bdev_read_folio() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 06/26] bcachefs: remove dead function bdev_sectors() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 07/26] cramfs: prevent direct access of bd_inode Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 08/26] erofs: " Yu Kuai
2024-04-07 4:05 ` Al Viro
2024-04-07 4:08 ` Al Viro
2024-04-11 16:13 ` Gao Xiang
2024-04-12 1:14 ` Yu Kuai
2024-04-25 19:56 ` Al Viro
2024-04-25 19:57 ` [PATCH 1/6] erofs: switch erofs_bread() to passing offset instead of block number Al Viro
2024-04-29 3:01 ` Gao Xiang
2024-04-25 19:58 ` [PATCH 2/6] erofs_buf: store address_space instead of inode Al Viro
2024-04-29 3:01 ` Gao Xiang
2024-04-25 19:58 ` erofs: mechanically convert erofs_read_metabuf() to offsets Al Viro
2024-04-25 19:59 ` [PATCH 4/6] erofs: don't align offset for erofs_read_metabuf() (simple cases) Al Viro
2024-04-25 19:59 ` [PATCH 5/6] erofs: don't round offset down for erofs_read_metabuf() Al Viro
2024-04-25 20:00 ` [PATCH 6/6] z_erofs_pcluster_begin(): don't bother with rounding position down Al Viro
2024-04-26 5:32 ` Gao Xiang
2024-05-03 4:15 ` Al Viro
2024-05-03 13:01 ` Gao Xiang
2024-05-17 2:24 ` Gao Xiang
2024-04-25 20:08 ` [PATCH vfs.all 08/26] erofs: prevent direct access of bd_inode Al Viro
2024-04-25 21:56 ` Gao Xiang
2024-04-25 22:28 ` Al Viro
2024-04-25 23:11 ` Gao Xiang
2024-04-25 23:22 ` Gao Xiang
2024-04-06 9:09 ` [PATCH vfs.all 09/26] nilfs2: " Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 10/26] gfs2: " Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 11/26] btrfs: " Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 12/26] ext4: remove block_device_ejected() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 13/26] ext4: prevent direct access of bd_inode Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 14/26] jbd2: " Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 15/26] s390/dasd: use bdev api in dasd_format() Yu Kuai
2024-04-16 1:35 ` Al Viro
2024-04-16 8:47 ` Alexander Gordeev
2024-04-17 12:47 ` Stefan Haberland
2024-04-28 18:58 ` Al Viro
2024-04-28 23:23 ` Al Viro
2024-04-29 14:41 ` Stefan Haberland
2024-04-30 0:30 ` Al Viro
2024-04-30 11:35 ` Stefan Haberland
2024-04-06 9:09 ` [PATCH vfs.all 16/26] bcache: prevent direct access of bd_inode Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 17/26] block2mtd: " Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 18/26] scsi: use bdev helper in scsi_bios_ptable() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 19/26] dm-vdo: convert to use bdev_file Yu Kuai
2024-04-10 10:56 ` Jan Kara
2024-04-10 17:26 ` Matthew Sakai
2024-04-10 17:40 ` Al Viro
2024-04-10 18:59 ` Matthew Sakai
2024-04-11 11:12 ` Christian Brauner
2024-04-06 9:09 ` [PATCH vfs.all 20/26] block: factor out a helper init_bdev_file() Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 21/26] block: fix module reference leakage from bdev_open_by_dev error path Yu Kuai
2024-04-11 9:16 ` (subset) " Christian Brauner
2024-04-06 9:09 ` [PATCH vfs.all 22/26] block: stash a bdev_file to read/write raw blcok_device Yu Kuai
2024-04-06 19:42 ` Al Viro
2024-04-06 20:29 ` Al Viro
2024-04-07 1:18 ` Yu Kuai
2024-04-07 1:51 ` Al Viro
2024-04-07 2:34 ` Yu Kuai
2024-04-07 3:06 ` Al Viro
2024-04-07 3:21 ` Yu Kuai
2024-04-07 4:57 ` Al Viro
2024-04-07 5:11 ` Al Viro
2024-04-07 5:21 ` Al Viro
2024-04-11 15:22 ` Matthew Wilcox
2024-04-09 4:26 ` Al Viro
2024-04-09 4:53 ` Al Viro
2024-04-09 6:22 ` Yu Kuai
2024-04-10 10:59 ` Jan Kara
2024-04-10 22:34 ` Al Viro
2024-04-11 11:56 ` Christian Brauner
2024-04-11 14:04 ` Al Viro
2024-04-11 14:49 ` Al Viro
2024-04-11 14:53 ` [PATCH 01/11] block_device: add a pointer to struct address_space (page cache of bdev) Al Viro
2024-04-11 14:53 ` [PATCH 02/11] use ->bd_mapping instead of ->bd_inode->i_mapping Al Viro
2024-04-11 14:53 ` [PATCH 03/11] grow_dev_folio(): we only want ->bd_inode->i_mapping there Al Viro
2024-04-11 14:59 ` Matthew Wilcox
2024-04-11 14:53 ` [PATCH 04/11] gfs2: more obvious initializations of mapping->host Al Viro
2024-04-11 14:53 ` [PATCH 05/11] blkdev_write_iter(): saner way to get inode and bdev Al Viro
2024-04-11 14:53 ` [PATCH 06/11] blk_ioctl_{discard,zeroout}(): we only want ->bd_inode->i_mapping here Al Viro
2024-04-11 14:53 ` [PATCH 07/11] ext4: remove block_device_ejected() Al Viro
2024-04-11 14:53 ` [PATCH 08/11] block: move two helpers into bdev.c Al Viro
2024-04-11 14:53 ` [PATCH 09/11] dm-vdo: use bdev_nr_bytes(bdev) instead of i_size_read(bdev->bd_inode) Al Viro
2024-04-11 18:04 ` Matthew Sakai
2024-04-11 14:53 ` [PATCH 10/11] bcachefs: remove dead function bdev_sectors() Al Viro
2024-04-11 14:53 ` [PATCH 11/11] block2mtd: prevent direct access of bd_inode Al Viro
2024-04-17 11:05 ` [PATCH 01/11] block_device: add a pointer to struct address_space (page cache of bdev) Christian Brauner
2024-04-12 1:38 ` [PATCH vfs.all 22/26] block: stash a bdev_file to read/write raw blcok_device Yu Kuai
2024-04-12 2:59 ` Al Viro
2024-04-12 4:41 ` Al Viro
2024-04-12 7:13 ` Al Viro
2024-04-12 9:21 ` Christian Brauner
2024-04-12 11:29 ` Al Viro
2024-04-13 15:25 ` Christian Brauner
2024-04-15 20:45 ` Al Viro
2024-04-16 6:32 ` Al Viro
2024-04-17 4:35 ` [PATCH][RFC] set_blocksize() in pktcdvd (was Re: [PATCH vfs.all 22/26] block: stash a bdev_file to read/write raw blcok_device) Al Viro
2024-04-17 13:43 ` [PATCH vfs.all 22/26] block: stash a bdev_file to read/write raw blcok_device Jan Kara
2024-04-17 15:23 ` Al Viro
2024-04-17 20:45 ` [RFC] set_blocksize() in kernel/power/swap.c (was Re: [PATCH vfs.all 22/26] block: stash a bdev_file to read/write raw blcok_device) Al Viro
2024-04-09 9:00 ` [PATCH vfs.all 22/26] block: stash a bdev_file to read/write raw blcok_device Christian Brauner
2024-04-09 10:23 ` Christian Brauner
2024-04-09 11:53 ` Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 23/26] iomap: add helpers helpers to get and set bdev Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 24/26] iomap: convert to use bdev_file Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 25/26] buffer: add helpers to get and set bdev Yu Kuai
2024-04-06 9:09 ` [PATCH vfs.all 26/26] buffer: convert to use bdev_file Yu Kuai
2024-04-07 2:20 ` Yu Kuai [this message]
2024-04-08 14:05 ` [PATCH vfs.all 00/26] fs & block: remove bdev->bd_inode Jan Kara
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=227a872d-51e9-babc-0489-7fcc7112c0e6@huaweicloud.com \
--to=yukuai1@huaweicloud.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=gustavoars@kernel.org \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-block@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=yangerkun@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).