Re: [PATCH v2] fscrypt: Change fscrypt_encrypt_pagecache_blocks() to take a folio

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 04, 2025 at 05:02:23PM +0000, Matthew Wilcox (Oracle) wrote:
> ext4 and ceph already have a folio to pass; f2fs needs to be properly
> converted but this will do for now.  This removes a reference
> to page->index and page->mapping as well as removing a call to
> compound_head().
> 
> Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
> ---
> This is against next-20250304 and will have conflicts with the ceph tree
> if applied to mainline.  It might be easiest for Christian to carry it?

That's fine with me.

Acked-by: Eric Biggers <ebiggers@xxxxxxxxxx>

> +struct page *fscrypt_encrypt_pagecache_blocks(struct folio *folio,
> +		size_t len, size_t offs, gfp_t gfp_flags)
>  {
> -	const struct inode *inode = page->mapping->host;
> +	const struct inode *inode = folio->mapping->host;
>  	const struct fscrypt_inode_info *ci = inode->i_crypt_info;
>  	const unsigned int du_bits = ci->ci_data_unit_bits;
>  	const unsigned int du_size = 1U << du_bits;
>  	struct page *ciphertext_page;
> -	u64 index = ((u64)page->index << (PAGE_SHIFT - du_bits)) +
> +	u64 index = ((u64)folio->index << (PAGE_SHIFT - du_bits)) +
>  		    (offs >> du_bits);
>  	unsigned int i;

'i' should be changed to size_t to match len and offs.

>  	int err;
>  
> -	if (WARN_ON_ONCE(!PageLocked(page)))
> +	VM_BUG_ON_FOLIO(folio_test_large(folio), folio);
> +	if (WARN_ON_ONCE(!folio_test_locked(folio)))
>  		return ERR_PTR(-EINVAL);

I'm not sure you considered using VM_WARN_ON_ONCE_FOLIO() here?  TBH I'm fine
with BUG_ON, but sometimes people complain about it.  That's why fs/crypto/
sticks to WARN_ON_ONCE these days.

- Eric




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux