* [PATCH AUTOSEL 6.1 14/35] btrfs: factor out scratching of one regular super block
[not found] <20230124134131.637036-1-sashal@kernel.org>
@ 2023-01-24 13:41 ` Sasha Levin
2023-01-24 13:41 ` [PATCH AUTOSEL 6.1 15/35] btrfs: stop using write_one_page in btrfs_scratch_superblock Sasha Levin
1 sibling, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2023-01-24 13:41 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Christoph Hellwig, Johannes Thumshirn, David Sterba, Sasha Levin,
clm, josef, linux-btrfs
From: Christoph Hellwig <hch@lst.de>
[ Upstream commit 0e0078f72be81bbb2a02b229fd2cec8ad63e4fb1 ]
btrfs_scratch_superblocks open codes scratching super block of a
non-zoned super block. Split the code to read, zero and write the
superblock for regular devices into a separate helper.
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/volumes.c | 51 +++++++++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 25 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index dba087ad40ea..8fd14dc7f667 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2017,42 +2017,43 @@ static u64 btrfs_num_devices(struct btrfs_fs_info *fs_info)
return num_devices;
}
+static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info,
+ struct block_device *bdev, int copy_num)
+{
+ struct btrfs_super_block *disk_super;
+ struct page *page;
+ int ret;
+
+ disk_super = btrfs_read_dev_one_super(bdev, copy_num, false);
+ if (IS_ERR(disk_super))
+ return;
+
+ memset(&disk_super->magic, 0, sizeof(disk_super->magic));
+ page = virt_to_page(disk_super);
+ set_page_dirty(page);
+ lock_page(page);
+ /* write_on_page() unlocks the page */
+ ret = write_one_page(page);
+ if (ret)
+ btrfs_warn(fs_info, "error clearing superblock number %d (%d)",
+ copy_num, ret);
+ btrfs_release_disk_super(disk_super);
+}
+
void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
struct block_device *bdev,
const char *device_path)
{
- struct btrfs_super_block *disk_super;
int copy_num;
if (!bdev)
return;
for (copy_num = 0; copy_num < BTRFS_SUPER_MIRROR_MAX; copy_num++) {
- struct page *page;
- int ret;
-
- disk_super = btrfs_read_dev_one_super(bdev, copy_num, false);
- if (IS_ERR(disk_super))
- continue;
-
- if (bdev_is_zoned(bdev)) {
+ if (bdev_is_zoned(bdev))
btrfs_reset_sb_log_zones(bdev, copy_num);
- continue;
- }
-
- memset(&disk_super->magic, 0, sizeof(disk_super->magic));
-
- page = virt_to_page(disk_super);
- set_page_dirty(page);
- lock_page(page);
- /* write_on_page() unlocks the page */
- ret = write_one_page(page);
- if (ret)
- btrfs_warn(fs_info,
- "error clearing superblock number %d (%d)",
- copy_num, ret);
- btrfs_release_disk_super(disk_super);
-
+ else
+ btrfs_scratch_superblock(fs_info, bdev, copy_num);
}
/* Notify udev that device has changed */
--
2.39.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 6.1 15/35] btrfs: stop using write_one_page in btrfs_scratch_superblock
[not found] <20230124134131.637036-1-sashal@kernel.org>
2023-01-24 13:41 ` [PATCH AUTOSEL 6.1 14/35] btrfs: factor out scratching of one regular super block Sasha Levin
@ 2023-01-24 13:41 ` Sasha Levin
2023-01-24 16:57 ` David Sterba
1 sibling, 1 reply; 4+ messages in thread
From: Sasha Levin @ 2023-01-24 13:41 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Christoph Hellwig, David Sterba, Sasha Levin, clm, josef,
linux-btrfs
From: Christoph Hellwig <hch@lst.de>
[ Upstream commit 26ecf243e407be54807ad67210f7e83b9fad71ea ]
write_one_page is an awkward interface that expects the page locked and
->writepage to be implemented. Replace that by zeroing the signature
bytes and synchronize the block device page using the proper bdev
helpers.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: David Sterba <dsterba@suse.com>
[ update changelog ]
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/btrfs/volumes.c | 17 ++++++++---------
1 file changed, 8 insertions(+), 9 deletions(-)
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 8fd14dc7f667..36bb664a25a2 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2021,23 +2021,22 @@ static void btrfs_scratch_superblock(struct btrfs_fs_info *fs_info,
struct block_device *bdev, int copy_num)
{
struct btrfs_super_block *disk_super;
- struct page *page;
+ const size_t len = sizeof(disk_super->magic);
+ const u64 bytenr = btrfs_sb_offset(copy_num);
int ret;
- disk_super = btrfs_read_dev_one_super(bdev, copy_num, false);
+ disk_super = btrfs_read_disk_super(bdev, bytenr, bytenr);
if (IS_ERR(disk_super))
return;
- memset(&disk_super->magic, 0, sizeof(disk_super->magic));
- page = virt_to_page(disk_super);
- set_page_dirty(page);
- lock_page(page);
- /* write_on_page() unlocks the page */
- ret = write_one_page(page);
+ memset(&disk_super->magic, 0, len);
+ folio_mark_dirty(virt_to_folio(disk_super));
+ btrfs_release_disk_super(disk_super);
+
+ ret = sync_blockdev_range(bdev, bytenr, bytenr + len - 1);
if (ret)
btrfs_warn(fs_info, "error clearing superblock number %d (%d)",
copy_num, ret);
- btrfs_release_disk_super(disk_super);
}
void btrfs_scratch_superblocks(struct btrfs_fs_info *fs_info,
--
2.39.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH AUTOSEL 6.1 15/35] btrfs: stop using write_one_page in btrfs_scratch_superblock
2023-01-24 13:41 ` [PATCH AUTOSEL 6.1 15/35] btrfs: stop using write_one_page in btrfs_scratch_superblock Sasha Levin
@ 2023-01-24 16:57 ` David Sterba
2023-02-01 15:21 ` Sasha Levin
0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2023-01-24 16:57 UTC (permalink / raw)
To: Sasha Levin
Cc: linux-kernel, stable, Christoph Hellwig, David Sterba, clm, josef,
linux-btrfs
On Tue, Jan 24, 2023 at 08:41:11AM -0500, Sasha Levin wrote:
> From: Christoph Hellwig <hch@lst.de>
>
> [ Upstream commit 26ecf243e407be54807ad67210f7e83b9fad71ea ]
>
> write_one_page is an awkward interface that expects the page locked and
> ->writepage to be implemented. Replace that by zeroing the signature
> bytes and synchronize the block device page using the proper bdev
> helpers.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: David Sterba <dsterba@suse.com>
> [ update changelog ]
> Signed-off-by: David Sterba <dsterba@suse.com>
> Signed-off-by: Sasha Levin <sashal@kernel.org>
Please drop this patch and "btrfs: factor out scratching of one regular
super block" from all stable queues. It's not a fix, only preparatory
work to allow removing write_one_page from MM code.
Commit ids: 0e0078f72be81bbb and 26ecf243e407be54
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH AUTOSEL 6.1 15/35] btrfs: stop using write_one_page in btrfs_scratch_superblock
2023-01-24 16:57 ` David Sterba
@ 2023-02-01 15:21 ` Sasha Levin
0 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2023-02-01 15:21 UTC (permalink / raw)
To: David Sterba
Cc: linux-kernel, stable, Christoph Hellwig, David Sterba, clm, josef,
linux-btrfs
On Tue, Jan 24, 2023 at 05:57:16PM +0100, David Sterba wrote:
>On Tue, Jan 24, 2023 at 08:41:11AM -0500, Sasha Levin wrote:
>> From: Christoph Hellwig <hch@lst.de>
>>
>> [ Upstream commit 26ecf243e407be54807ad67210f7e83b9fad71ea ]
>>
>> write_one_page is an awkward interface that expects the page locked and
>> ->writepage to be implemented. Replace that by zeroing the signature
>> bytes and synchronize the block device page using the proper bdev
>> helpers.
>>
>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>> Reviewed-by: David Sterba <dsterba@suse.com>
>> [ update changelog ]
>> Signed-off-by: David Sterba <dsterba@suse.com>
>> Signed-off-by: Sasha Levin <sashal@kernel.org>
>
>Please drop this patch and "btrfs: factor out scratching of one regular
>super block" from all stable queues. It's not a fix, only preparatory
>work to allow removing write_one_page from MM code.
>
>Commit ids: 0e0078f72be81bbb and 26ecf243e407be54
Ack, dropped.
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-02-01 15:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20230124134131.637036-1-sashal@kernel.org>
2023-01-24 13:41 ` [PATCH AUTOSEL 6.1 14/35] btrfs: factor out scratching of one regular super block Sasha Levin
2023-01-24 13:41 ` [PATCH AUTOSEL 6.1 15/35] btrfs: stop using write_one_page in btrfs_scratch_superblock Sasha Levin
2023-01-24 16:57 ` David Sterba
2023-02-01 15:21 ` Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox