All of lore.kernel.org
 help / color / mirror / Atom feed
* [dev-test][PATCH 1/2] f2fs: add a missing truncate_inode_pages_final
@ 2017-03-10  9:50 Yunlei He
  2017-03-10  9:50 ` [PATCH 2/2] f2fs: avoid move encrypted block in BG_GC if it has been in memory Yunlei He
  2017-03-17  1:49 ` [dev-test][PATCH 1/2] f2fs: add a missing truncate_inode_pages_final Jaegeuk Kim
  0 siblings, 2 replies; 6+ messages in thread
From: Yunlei He @ 2017-03-10  9:50 UTC (permalink / raw)
  To: jaegeuk, yuchao0, linux-f2fs-devel

This patch add a missing truncate_inode_pages_final

Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
 fs/f2fs/super.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index cfb40d3..7ad2606 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -642,6 +642,8 @@ static int f2fs_drop_inode(struct inode *inode)
 			if (f2fs_is_atomic_file(inode))
 				drop_inmem_pages(inode);
 
+			truncate_inode_pages_final(&inode->i_data);
+
 			/* should remain fi->extent_tree for writepage */
 			f2fs_destroy_extent_node(inode);
 
-- 
2.10.1


------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] f2fs: avoid move encrypted block in BG_GC if it has been in memory
  2017-03-10  9:50 [dev-test][PATCH 1/2] f2fs: add a missing truncate_inode_pages_final Yunlei He
@ 2017-03-10  9:50 ` Yunlei He
  2017-03-13 18:30   ` Jaegeuk Kim
  2017-03-17  1:49 ` [dev-test][PATCH 1/2] f2fs: add a missing truncate_inode_pages_final Jaegeuk Kim
  1 sibling, 1 reply; 6+ messages in thread
From: Yunlei He @ 2017-03-10  9:50 UTC (permalink / raw)
  To: jaegeuk, yuchao0, linux-f2fs-devel

If an encrypted block has been read to memory, we just dirty it
and return directly.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
 fs/f2fs/gc.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 418fd98..ca94518 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -564,7 +564,7 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
 }
 
 static void move_encrypted_block(struct inode *inode, block_t bidx,
-							unsigned int segno, int off)
+					int gc_type, unsigned int segno, int off)
 {
 	struct f2fs_io_info fio = {
 		.sbi = F2FS_I_SB(inode),
@@ -607,6 +607,12 @@ static void move_encrypted_block(struct inode *inode, block_t bidx,
 	 */
 	f2fs_wait_on_page_writeback(page, DATA, true);
 
+	if (gc_type == BG_GC && PageUptodate(page) &&
+				fscrypt_has_encryption_key(inode)) {
+		set_page_dirty(page);
+		goto put_out;
+	}
+
 	get_node_info(fio.sbi, dn.nid, &ni);
 	set_summary(&sum, dn.nid, dn.ofs_in_node, ni.version);
 
@@ -827,7 +833,8 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
 			start_bidx = start_bidx_of_node(nofs, inode)
 								+ ofs_in_node;
 			if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode))
-				move_encrypted_block(inode, start_bidx, segno, off);
+				move_encrypted_block(inode, start_bidx,
+								gc_type, segno, off);
 			else
 				move_data_page(inode, start_bidx, gc_type, segno, off);
 
-- 
2.10.1


------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] f2fs: avoid move encrypted block in BG_GC if it has been in memory
  2017-03-10  9:50 ` [PATCH 2/2] f2fs: avoid move encrypted block in BG_GC if it has been in memory Yunlei He
@ 2017-03-13 18:30   ` Jaegeuk Kim
  2017-03-14  1:37     ` heyunlei
  0 siblings, 1 reply; 6+ messages in thread
From: Jaegeuk Kim @ 2017-03-13 18:30 UTC (permalink / raw)
  To: Yunlei He; +Cc: linux-f2fs-devel

On 03/10, Yunlei He wrote:
> If an encrypted block has been read to memory, we just dirty it
> and return directly.
> 
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
>  fs/f2fs/gc.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index 418fd98..ca94518 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -564,7 +564,7 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
>  }
>  
>  static void move_encrypted_block(struct inode *inode, block_t bidx,
> -							unsigned int segno, int off)
> +					int gc_type, unsigned int segno, int off)
>  {
>  	struct f2fs_io_info fio = {
>  		.sbi = F2FS_I_SB(inode),
> @@ -607,6 +607,12 @@ static void move_encrypted_block(struct inode *inode, block_t bidx,
>  	 */
>  	f2fs_wait_on_page_writeback(page, DATA, true);
>  
> +	if (gc_type == BG_GC && PageUptodate(page) &&
> +				fscrypt_has_encryption_key(inode)) {

Why do we need the encryption key?

Thanks,

> +		set_page_dirty(page);
> +		goto put_out;
> +	}
> +
>  	get_node_info(fio.sbi, dn.nid, &ni);
>  	set_summary(&sum, dn.nid, dn.ofs_in_node, ni.version);
>  
> @@ -827,7 +833,8 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
>  			start_bidx = start_bidx_of_node(nofs, inode)
>  								+ ofs_in_node;
>  			if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode))
> -				move_encrypted_block(inode, start_bidx, segno, off);
> +				move_encrypted_block(inode, start_bidx,
> +								gc_type, segno, off);
>  			else
>  				move_data_page(inode, start_bidx, gc_type, segno, off);
>  
> -- 
> 2.10.1
> 
> 
> ------------------------------------------------------------------------------
> Announcing the Oxford Dictionaries API! The API offers world-renowned
> dictionary content that is easy and intuitive to access. Sign up for an
> account today to start using our lexical data to power your apps and
> projects. Get started today and enter our developer competition.
> http://sdm.link/oxford
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] f2fs: avoid move encrypted block in BG_GC if it has been in memory
  2017-03-13 18:30   ` Jaegeuk Kim
@ 2017-03-14  1:37     ` heyunlei
  2017-03-14  3:42       ` Chao Yu
  0 siblings, 1 reply; 6+ messages in thread
From: heyunlei @ 2017-03-14  1:37 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-f2fs-devel


Hi Jaegeuk,
On 2017/3/14 2:30, Jaegeuk Kim wrote:
> On 03/10, Yunlei He wrote:
>> If an encrypted block has been read to memory, we just dirty it
>> and return directly.
>>
>> Signed-off-by: Yunlei He <heyunlei@huawei.com>
>> ---
>>  fs/f2fs/gc.c | 11 +++++++++--
>>  1 file changed, 9 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
>> index 418fd98..ca94518 100644
>> --- a/fs/f2fs/gc.c
>> +++ b/fs/f2fs/gc.c
>> @@ -564,7 +564,7 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
>>  }
>>
>>  static void move_encrypted_block(struct inode *inode, block_t bidx,
>> -							unsigned int segno, int off)
>> +					int gc_type, unsigned int segno, int off)
>>  {
>>  	struct f2fs_io_info fio = {
>>  		.sbi = F2FS_I_SB(inode),
>> @@ -607,6 +607,12 @@ static void move_encrypted_block(struct inode *inode, block_t bidx,
>>  	 */
>>  	f2fs_wait_on_page_writeback(page, DATA, true);
>>
>> +	if (gc_type == BG_GC && PageUptodate(page) &&
>> +				fscrypt_has_encryption_key(inode)) {
>
> Why do we need the encryption key?

Here I am afraid some cases dirty encrypted pages have no authority to write back.

Thanks.
>
> Thanks,
>
>> +		set_page_dirty(page);
>> +		goto put_out;
>> +	}
>> +
>>  	get_node_info(fio.sbi, dn.nid, &ni);
>>  	set_summary(&sum, dn.nid, dn.ofs_in_node, ni.version);
>>
>> @@ -827,7 +833,8 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
>>  			start_bidx = start_bidx_of_node(nofs, inode)
>>  								+ ofs_in_node;
>>  			if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode))
>> -				move_encrypted_block(inode, start_bidx, segno, off);
>> +				move_encrypted_block(inode, start_bidx,
>> +								gc_type, segno, off);
>>  			else
>>  				move_data_page(inode, start_bidx, gc_type, segno, off);
>>
>> --
>> 2.10.1
>>
>>
>> ------------------------------------------------------------------------------
>> Announcing the Oxford Dictionaries API! The API offers world-renowned
>> dictionary content that is easy and intuitive to access. Sign up for an
>> account today to start using our lexical data to power your apps and
>> projects. Get started today and enter our developer competition.
>> http://sdm.link/oxford
>> _______________________________________________
>> Linux-f2fs-devel mailing list
>> Linux-f2fs-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>
> .
>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] f2fs: avoid move encrypted block in BG_GC if it has been in memory
  2017-03-14  1:37     ` heyunlei
@ 2017-03-14  3:42       ` Chao Yu
  0 siblings, 0 replies; 6+ messages in thread
From: Chao Yu @ 2017-03-14  3:42 UTC (permalink / raw)
  To: heyunlei, Jaegeuk Kim; +Cc: linux-f2fs-devel

On 2017/3/14 9:37, heyunlei wrote:
> 
> Hi Jaegeuk,
> On 2017/3/14 2:30, Jaegeuk Kim wrote:
>> On 03/10, Yunlei He wrote:
>>> If an encrypted block has been read to memory, we just dirty it
>>> and return directly.
>>>
>>> Signed-off-by: Yunlei He <heyunlei@huawei.com>
>>> ---
>>>  fs/f2fs/gc.c | 11 +++++++++--
>>>  1 file changed, 9 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
>>> index 418fd98..ca94518 100644
>>> --- a/fs/f2fs/gc.c
>>> +++ b/fs/f2fs/gc.c
>>> @@ -564,7 +564,7 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
>>>  }
>>>
>>>  static void move_encrypted_block(struct inode *inode, block_t bidx,
>>> -							unsigned int segno, int off)
>>> +					int gc_type, unsigned int segno, int off)
>>>  {
>>>  	struct f2fs_io_info fio = {
>>>  		.sbi = F2FS_I_SB(inode),
>>> @@ -607,6 +607,12 @@ static void move_encrypted_block(struct inode *inode, block_t bidx,
>>>  	 */
>>>  	f2fs_wait_on_page_writeback(page, DATA, true);
>>>
>>> +	if (gc_type == BG_GC && PageUptodate(page) &&
>>> +				fscrypt_has_encryption_key(inode)) {
>>
>> Why do we need the encryption key?
> 
> Here I am afraid some cases dirty encrypted pages have no authority to write back.

Not sure this is the right way, I suspect that user may change master key to
incorrect one in keyring, then, this approach will make original data in page
cache being encrypted with the wrong key and writebacked to storage even if user
only have read permission?

Thanks,

> 
> Thanks.
>>
>> Thanks,
>>
>>> +		set_page_dirty(page);
>>> +		goto put_out;
>>> +	}
>>> +
>>>  	get_node_info(fio.sbi, dn.nid, &ni);
>>>  	set_summary(&sum, dn.nid, dn.ofs_in_node, ni.version);
>>>
>>> @@ -827,7 +833,8 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
>>>  			start_bidx = start_bidx_of_node(nofs, inode)
>>>  								+ ofs_in_node;
>>>  			if (f2fs_encrypted_inode(inode) && S_ISREG(inode->i_mode))
>>> -				move_encrypted_block(inode, start_bidx, segno, off);
>>> +				move_encrypted_block(inode, start_bidx,
>>> +								gc_type, segno, off);
>>>  			else
>>>  				move_data_page(inode, start_bidx, gc_type, segno, off);
>>>
>>> --
>>> 2.10.1
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Announcing the Oxford Dictionaries API! The API offers world-renowned
>>> dictionary content that is easy and intuitive to access. Sign up for an
>>> account today to start using our lexical data to power your apps and
>>> projects. Get started today and enter our developer competition.
>>> http://sdm.link/oxford
>>> _______________________________________________
>>> Linux-f2fs-devel mailing list
>>> Linux-f2fs-devel@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
>>
>> .
>>
> 
> 
> .
> 


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dev-test][PATCH 1/2] f2fs: add a missing truncate_inode_pages_final
  2017-03-10  9:50 [dev-test][PATCH 1/2] f2fs: add a missing truncate_inode_pages_final Yunlei He
  2017-03-10  9:50 ` [PATCH 2/2] f2fs: avoid move encrypted block in BG_GC if it has been in memory Yunlei He
@ 2017-03-17  1:49 ` Jaegeuk Kim
  1 sibling, 0 replies; 6+ messages in thread
From: Jaegeuk Kim @ 2017-03-17  1:49 UTC (permalink / raw)
  To: Yunlei He; +Cc: linux-f2fs-devel

Hi Yunlei,

I just hit this, so will pop the patch out.

[  870.158785] sysrq: SysRq : Show Blocked State
[  870.158991]   task                        PC stack   pid father
[  870.159024] kworker/u8:2    D    0   127      2 0x00000000
[  870.159033] Workqueue: writeback wb_workfn (flush-8:32)
[  870.159036] Call Trace:
[  870.159042]  __schedule+0x28e/0x8d0
[  870.159045]  schedule+0x36/0x80
[  870.159049]  io_schedule+0x16/0x40
[  870.159052]  wait_on_page_bit+0xf7/0x130
[  870.159054]  ? page_cache_tree_insert+0x120/0x120
[  870.159057]  truncate_inode_pages_range+0x4b0/0x930
[  870.159063]  truncate_inode_pages_final+0x4d/0x60
[  870.159073]  f2fs_drop_inode+0x1a0/0x290 [f2fs]
[  870.159075]  iput+0xf0/0x230
[  870.159083]  f2fs_sync_inode_meta+0x3f/0x100 [f2fs]
[  870.159090]  block_operations+0xfc/0x200 [f2fs]
[  870.159097]  ? f2fs_inode_dirtied+0x62/0xd0 [f2fs]
[  870.159106]  ? __insert_extent_tree+0xc0/0xf0 [f2fs]
[  870.159113]  write_checkpoint+0x9d/0xe50 [f2fs]
[  870.159121]  f2fs_gc+0x398/0x480 [f2fs]
[  870.159129]  ? write_data_page+0x68/0x90 [f2fs]
[  870.159137]  f2fs_balance_fs+0x132/0x150 [f2fs]
[  870.159145]  __write_data_page+0x111/0x5c0 [f2fs]
[  870.159153]  f2fs_write_cache_pages+0x23a/0x4a0 [f2fs]
[  870.159160]  f2fs_write_data_pages+0x9b/0x1d0 [f2fs]
[  870.159162]  ? set_page_dirty+0x5b/0xb0
[  870.159204]  ? update_inode+0x273/0x2e0 [f2fs]
[  870.159206]  do_writepages+0x1e/0x30
[  870.159208]  __writeback_single_inode+0x45/0x320
[  870.159211]  writeback_sb_inodes+0x266/0x5f0
[  870.159213]  __writeback_inodes_wb+0x92/0xc0
[  870.159215]  wb_writeback+0x268/0x300
[  870.159217]  ? get_nr_dirty_inodes+0x4c/0x70
[  870.159219]  wb_workfn+0x2df/0x410
[  870.159221]  process_one_work+0x1fc/0x4b0
[  870.159223]  worker_thread+0x4b/0x500
[  870.159224]  kthread+0x101/0x140
[  870.159226]  ? process_one_work+0x4b0/0x4b0
[  870.159227]  ? kthread_create_on_node+0x60/0x60
[  870.159229]  ret_from_fork+0x2c/0x40
[  870.159269] fsstress        D    0  3329   3328 0x000000

Thanks,

On 03/10, Yunlei He wrote:
> This patch add a missing truncate_inode_pages_final
> 
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
>  fs/f2fs/super.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index cfb40d3..7ad2606 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -642,6 +642,8 @@ static int f2fs_drop_inode(struct inode *inode)
>  			if (f2fs_is_atomic_file(inode))
>  				drop_inmem_pages(inode);
>  
> +			truncate_inode_pages_final(&inode->i_data);
> +
>  			/* should remain fi->extent_tree for writepage */
>  			f2fs_destroy_extent_node(inode);
>  
> -- 
> 2.10.1
> 
> 
> ------------------------------------------------------------------------------
> Announcing the Oxford Dictionaries API! The API offers world-renowned
> dictionary content that is easy and intuitive to access. Sign up for an
> account today to start using our lexical data to power your apps and
> projects. Get started today and enter our developer competition.
> http://sdm.link/oxford
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-03-17  1:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-10  9:50 [dev-test][PATCH 1/2] f2fs: add a missing truncate_inode_pages_final Yunlei He
2017-03-10  9:50 ` [PATCH 2/2] f2fs: avoid move encrypted block in BG_GC if it has been in memory Yunlei He
2017-03-13 18:30   ` Jaegeuk Kim
2017-03-14  1:37     ` heyunlei
2017-03-14  3:42       ` Chao Yu
2017-03-17  1:49 ` [dev-test][PATCH 1/2] f2fs: add a missing truncate_inode_pages_final Jaegeuk Kim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.