lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZmMMDy9eeCU2igqj@casper.infradead.org>
Date: Fri, 7 Jun 2024 14:33:03 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Chao Yu <chao@...nel.org>
Cc: jaegeuk@...nel.org, linux-f2fs-devel@...ts.sourceforge.net,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] f2fs: get rid of buffer_head use

On Fri, Jun 07, 2024 at 06:18:29PM +0800, Chao Yu wrote:
> @@ -1990,6 +1989,12 @@ static inline struct f2fs_super_block *F2FS_RAW_SUPER(struct f2fs_sb_info *sbi)
>  	return (struct f2fs_super_block *)(sbi->raw_super);
>  }
>  
> +static inline struct f2fs_super_block *F2FS_SUPER_BLOCK(struct folio *folio)
> +{
> +	return (struct f2fs_super_block *)(page_address(folio_page(folio, 0)) +
> +							F2FS_SUPER_OFFSET);
> +}

This assumes that the superblock is in the first page of the folio.
That's not necessarily guaranteed; let's say you have a 64KiB folio
that covers the start of the bdev.

I don't quite know how to write this because f2fs defines its block size
in terms of PAGE_SIZE, which just seems like nonsense to me.  If you
format a filesystem on a 16KiB PAGE_SIZE machine and then try to mount
it on a machine with a 4KiB PAGE_SIZE, it's going to go horribly wrong.

You'd need to pass in something that indicates whether you're trying to
access the first or second superblock; there's no way to tell from the
folio which one it is.

> +static int __f2fs_commit_super(struct f2fs_sb_info *sbi, struct folio *folio,
> +								bool update)
>  {
> -	lock_buffer(bh);
> -	if (super)
> -		memcpy(bh->b_data + F2FS_SUPER_OFFSET, super, sizeof(*super));
> -	set_buffer_dirty(bh);
> -	unlock_buffer(bh);
> -
> +	struct bio *bio;
>  	/* it's rare case, we can do fua all the time */
> -	return __sync_dirty_buffer(bh, REQ_SYNC | REQ_PREFLUSH | REQ_FUA);
> +	blk_opf_t opf = REQ_OP_WRITE | REQ_SYNC | REQ_PREFLUSH | REQ_FUA;
> +	int ret;
> +
> +	folio_lock(folio);
> +	folio_wait_writeback(folio);
> +	if (update)
> +		memcpy(F2FS_SUPER_BLOCK(folio), F2FS_RAW_SUPER(sbi),
> +					sizeof(struct f2fs_super_block));
> +	folio_mark_dirty(folio);
> +	folio_clear_dirty_for_io(folio);
> +	folio_start_writeback(folio);
> +	folio_unlock(folio);
> +
> +	bio = bio_alloc(sbi->sb->s_bdev, 1, opf, GFP_NOFS);
> +
> +	/* it doesn't need to set crypto context for superblock update */
> +	bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(folio_index(folio));
> +
> +	if (!bio_add_folio(bio, folio, PAGE_SIZE, 0))
> +		f2fs_bug_on(sbi, 1);

Better make that folio_size(folio) to support bs>PS.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ