[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f49534bf-f119-2fa5-81a3-5e169d6c5f61@huawei.com>
Date: Fri, 19 Jun 2020 10:43:15 +0800
From: Chao Yu <yuchao0@...wei.com>
To: Jaegeuk Kim <jaegeuk@...nel.org>,
Eric Biggers <ebiggers@...nel.org>
CC: Satya Tangirala <satyat@...gle.com>,
<linux-fscrypt@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>,
<linux-f2fs-devel@...ts.sourceforge.net>,
<linux-ext4@...r.kernel.org>
Subject: Re: [PATCH 3/4] f2fs: add inline encryption support
On 2020/6/19 3:28, Jaegeuk Kim wrote:
> On 06/18, Eric Biggers wrote:
>> Hi Chao,
>>
>> On Thu, Jun 18, 2020 at 06:06:02PM +0800, Chao Yu wrote:
>>>> @@ -936,8 +972,11 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)
>>>>
>>>> inc_page_count(sbi, WB_DATA_TYPE(bio_page));
>>>>
>>>> - if (io->bio && !io_is_mergeable(sbi, io->bio, io, fio,
>>>> - io->last_block_in_bio, fio->new_blkaddr))
>>>> + if (io->bio &&
>>>> + (!io_is_mergeable(sbi, io->bio, io, fio, io->last_block_in_bio,
>>>> + fio->new_blkaddr) ||
>>>> + !f2fs_crypt_mergeable_bio(io->bio, fio->page->mapping->host,
>>>> + fio->page->index, fio)))
>>>
>>> bio_page->index, fio)))
>>>
>>>> __submit_merged_bio(io);
>>>> alloc_new:
>>>> if (io->bio == NULL) {
>>>> @@ -949,6 +988,8 @@ void f2fs_submit_page_write(struct f2fs_io_info *fio)
>>>> goto skip;
>>>> }
>>>> io->bio = __bio_alloc(fio, BIO_MAX_PAGES);
>>>> + f2fs_set_bio_crypt_ctx(io->bio, fio->page->mapping->host,
>>>> + fio->page->index, fio, GFP_NOIO);
>>>
>>> bio_page->index, fio, GFP_NOIO);
>>>
>>
>> We're using ->mapping->host and ->index. Ordinarily that would mean the page
>> needs to be a pagecache page. But bio_page can also be a compressed page or a
>> bounce page containing fs-layer encrypted contents.
>>
>> Is your suggestion to keep using fio->page->mapping->host (since encrypted pages
>> don't have a mapping), but start using bio_page->index (since f2fs apparently
>> *does* set ->index for compressed pages, and if the file uses fs-layer
>> encryption then f2fs_set_bio_crypt_ctx() won't use the index anyway)?
>>
>> Does this mean the code is currently broken for compression + inline encryption
>> because it's using the wrong ->index? I think the answer is no, since
>> f2fs_write_compressed_pages() will still pass the first 'nr_cpages' pagecache
>> pages along with the compressed pages. In that case, your suggestion would be a
>> cleanup rather than a fix?
>>
>> It would be helpful if there was an f2fs mount option to auto-enable compression
>> on all files (similar to how test_dummy_encryption auto-enables encryption on
>> all files) so that it could be tested more easily.
>
> Eric, you can use "-o compress_extension=*".
Cool, we should update documentation when merge that patch...
>
>>
>> - Eric
> .
>
Powered by blists - more mailing lists