linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] f2fs: handle error cases in move_encrypted_block
@ 2015-07-14 19:18 Jaegeuk Kim
  2015-07-14 19:18 ` [PATCH 2/2] f2fs: use a page temporarily for encrypted gced page Jaegeuk Kim
  2015-07-15  1:39 ` [f2fs-dev] [PATCH 1/2] f2fs: handle error cases in move_encrypted_block Chao Yu
  0 siblings, 2 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2015-07-14 19:18 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

This patch fixes some missing error handlers.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/gc.c | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 11046db..db11861 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -556,27 +556,34 @@ static void move_encrypted_block(struct inode *inode, block_t bidx)
 	if (!fio.encrypted_page)
 		goto put_out;
 
-	f2fs_submit_page_bio(&fio);
-
-	/* allocate block address */
-	f2fs_wait_on_page_writeback(dn.node_page, NODE);
-
-	allocate_data_block(fio.sbi, NULL, fio.blk_addr,
-					&fio.blk_addr, &sum, CURSEG_COLD_DATA);
-	dn.data_blkaddr = fio.blk_addr;
+	err = f2fs_submit_page_bio(&fio);
+	if (err)
+		goto put_page_out;
 
 	/* write page */
 	lock_page(fio.encrypted_page);
+
+	if (unlikely(!PageUptodate(fio.encrypted_page)))
+		goto put_page_out;
+	if (unlikely(fio.encrypted_page->mapping != META_MAPPING(fio.sbi)))
+		goto put_page_out;
+
 	set_page_writeback(fio.encrypted_page);
 	fio.rw = WRITE_SYNC;
 	f2fs_submit_page_mbio(&fio);
 
+	/* allocate block address */
+	f2fs_wait_on_page_writeback(dn.node_page, NODE);
+	allocate_data_block(fio.sbi, NULL, fio.blk_addr,
+					&fio.blk_addr, &sum, CURSEG_COLD_DATA);
+	dn.data_blkaddr = fio.blk_addr;
+
 	set_data_blkaddr(&dn);
 	f2fs_update_extent_cache(&dn);
 	set_inode_flag(F2FS_I(inode), FI_APPEND_WRITE);
 	if (page->index == 0)
 		set_inode_flag(F2FS_I(inode), FI_FIRST_BLOCK_WRITTEN);
-
+put_page_out:
 	f2fs_put_page(fio.encrypted_page, 1);
 put_out:
 	f2fs_put_dnode(&dn);
-- 
2.1.1


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

* [PATCH 2/2] f2fs: use a page temporarily for encrypted gced page
  2015-07-14 19:18 [PATCH 1/2] f2fs: handle error cases in move_encrypted_block Jaegeuk Kim
@ 2015-07-14 19:18 ` Jaegeuk Kim
  2015-07-15  1:43   ` [f2fs-dev] " Chao Yu
  2015-07-15  1:39 ` [f2fs-dev] [PATCH 1/2] f2fs: handle error cases in move_encrypted_block Chao Yu
  1 sibling, 1 reply; 5+ messages in thread
From: Jaegeuk Kim @ 2015-07-14 19:18 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, linux-f2fs-devel; +Cc: Jaegeuk Kim

That encrypted page is used temporarily, so we don't need to mark it accessed.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/gc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index db11861..ca562df 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -552,7 +552,10 @@ static void move_encrypted_block(struct inode *inode, block_t bidx)
 	fio.page = page;
 	fio.blk_addr = dn.data_blkaddr;
 
-	fio.encrypted_page = grab_cache_page(META_MAPPING(fio.sbi), fio.blk_addr);
+	fio.encrypted_page = pagecache_get_page(META_MAPPING(fio.sbi),
+					fio.blk_addr,
+					FGP_LOCK|FGP_CREAT,
+					GFP_NOFS);
 	if (!fio.encrypted_page)
 		goto put_out;
 
-- 
2.1.1


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

* RE: [f2fs-dev] [PATCH 1/2] f2fs: handle error cases in move_encrypted_block
  2015-07-14 19:18 [PATCH 1/2] f2fs: handle error cases in move_encrypted_block Jaegeuk Kim
  2015-07-14 19:18 ` [PATCH 2/2] f2fs: use a page temporarily for encrypted gced page Jaegeuk Kim
@ 2015-07-15  1:39 ` Chao Yu
  2015-07-15 22:42   ` Jaegeuk Kim
  1 sibling, 1 reply; 5+ messages in thread
From: Chao Yu @ 2015-07-15  1:39 UTC (permalink / raw)
  To: 'Jaegeuk Kim'; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel

Hi Jaegeuk,

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Wednesday, July 15, 2015 3:18 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim
> Subject: [f2fs-dev] [PATCH 1/2] f2fs: handle error cases in move_encrypted_block
> 
> This patch fixes some missing error handlers.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/gc.c | 25 ++++++++++++++++---------
>  1 file changed, 16 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index 11046db..db11861 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -556,27 +556,34 @@ static void move_encrypted_block(struct inode *inode, block_t bidx)
>  	if (!fio.encrypted_page)
>  		goto put_out;
> 
> -	f2fs_submit_page_bio(&fio);
> -
> -	/* allocate block address */
> -	f2fs_wait_on_page_writeback(dn.node_page, NODE);
> -
> -	allocate_data_block(fio.sbi, NULL, fio.blk_addr,
> -					&fio.blk_addr, &sum, CURSEG_COLD_DATA);
> -	dn.data_blkaddr = fio.blk_addr;
> +	err = f2fs_submit_page_bio(&fio);
> +	if (err)
> +		goto put_page_out;

f2fs_submit_page_bio will put the page when failed.

So goto put_out is enough?

> 
>  	/* write page */
>  	lock_page(fio.encrypted_page);
> +
> +	if (unlikely(!PageUptodate(fio.encrypted_page)))
> +		goto put_page_out;
> +	if (unlikely(fio.encrypted_page->mapping != META_MAPPING(fio.sbi)))
> +		goto put_page_out;
> +
>  	set_page_writeback(fio.encrypted_page);
>  	fio.rw = WRITE_SYNC;
>  	f2fs_submit_page_mbio(&fio);
> 
> +	/* allocate block address */
> +	f2fs_wait_on_page_writeback(dn.node_page, NODE);
> +	allocate_data_block(fio.sbi, NULL, fio.blk_addr,
> +					&fio.blk_addr, &sum, CURSEG_COLD_DATA);

move above f2fs_submit_page_mbio(&fio) to here?

Thanks,

> +	dn.data_blkaddr = fio.blk_addr;
> +
>  	set_data_blkaddr(&dn);
>  	f2fs_update_extent_cache(&dn);
>  	set_inode_flag(F2FS_I(inode), FI_APPEND_WRITE);
>  	if (page->index == 0)
>  		set_inode_flag(F2FS_I(inode), FI_FIRST_BLOCK_WRITTEN);
> -
> +put_page_out:
>  	f2fs_put_page(fio.encrypted_page, 1);
>  put_out:
>  	f2fs_put_dnode(&dn);
> --
> 2.1.1
> 
> 
> ------------------------------------------------------------------------------
> Don't Limit Your Business. Reach for the Cloud.
> GigeNET's Cloud Solutions provide you with the tools and support that
> you need to offload your IT needs and focus on growing your business.
> Configured For All Businesses. Start Your Cloud Today.
> https://www.gigenetcloud.com/
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel


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

* RE: [f2fs-dev] [PATCH 2/2] f2fs: use a page temporarily for encrypted gced page
  2015-07-14 19:18 ` [PATCH 2/2] f2fs: use a page temporarily for encrypted gced page Jaegeuk Kim
@ 2015-07-15  1:43   ` Chao Yu
  0 siblings, 0 replies; 5+ messages in thread
From: Chao Yu @ 2015-07-15  1:43 UTC (permalink / raw)
  To: 'Jaegeuk Kim'; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel

> -----Original Message-----
> From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> Sent: Wednesday, July 15, 2015 3:18 AM
> To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> linux-f2fs-devel@lists.sourceforge.net
> Cc: Jaegeuk Kim
> Subject: [f2fs-dev] [PATCH 2/2] f2fs: use a page temporarily for encrypted gced page
> 
> That encrypted page is used temporarily, so we don't need to mark it accessed.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <chao2.yu@samsung.com>


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

* Re: [f2fs-dev] [PATCH 1/2] f2fs: handle error cases in move_encrypted_block
  2015-07-15  1:39 ` [f2fs-dev] [PATCH 1/2] f2fs: handle error cases in move_encrypted_block Chao Yu
@ 2015-07-15 22:42   ` Jaegeuk Kim
  0 siblings, 0 replies; 5+ messages in thread
From: Jaegeuk Kim @ 2015-07-15 22:42 UTC (permalink / raw)
  To: Chao Yu; +Cc: linux-kernel, linux-fsdevel, linux-f2fs-devel

On Wed, Jul 15, 2015 at 09:39:47AM +0800, Chao Yu wrote:
> Hi Jaegeuk,
> 
> > -----Original Message-----
> > From: Jaegeuk Kim [mailto:jaegeuk@kernel.org]
> > Sent: Wednesday, July 15, 2015 3:18 AM
> > To: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org;
> > linux-f2fs-devel@lists.sourceforge.net
> > Cc: Jaegeuk Kim
> > Subject: [f2fs-dev] [PATCH 1/2] f2fs: handle error cases in move_encrypted_block
> > 
> > This patch fixes some missing error handlers.
> > 
> > Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> > ---
> >  fs/f2fs/gc.c | 25 ++++++++++++++++---------
> >  1 file changed, 16 insertions(+), 9 deletions(-)
> > 
> > diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> > index 11046db..db11861 100644
> > --- a/fs/f2fs/gc.c
> > +++ b/fs/f2fs/gc.c
> > @@ -556,27 +556,34 @@ static void move_encrypted_block(struct inode *inode, block_t bidx)
> >  	if (!fio.encrypted_page)
> >  		goto put_out;
> > 
> > -	f2fs_submit_page_bio(&fio);
> > -
> > -	/* allocate block address */
> > -	f2fs_wait_on_page_writeback(dn.node_page, NODE);
> > -
> > -	allocate_data_block(fio.sbi, NULL, fio.blk_addr,
> > -					&fio.blk_addr, &sum, CURSEG_COLD_DATA);
> > -	dn.data_blkaddr = fio.blk_addr;
> > +	err = f2fs_submit_page_bio(&fio);
> > +	if (err)
> > +		goto put_page_out;
> 
> f2fs_submit_page_bio will put the page when failed.
> 
> So goto put_out is enough?

Right.
BTW, I realized that this is somewhat wrong, since this function needs to
take care of its page for error cases too.
I wrote a patch dealing with errors of f2fs_submit_page_bio, and submitted
it right ago.

> 
> > 
> >  	/* write page */
> >  	lock_page(fio.encrypted_page);
> > +
> > +	if (unlikely(!PageUptodate(fio.encrypted_page)))
> > +		goto put_page_out;
> > +	if (unlikely(fio.encrypted_page->mapping != META_MAPPING(fio.sbi)))
> > +		goto put_page_out;
> > +
> >  	set_page_writeback(fio.encrypted_page);
> >  	fio.rw = WRITE_SYNC;
> >  	f2fs_submit_page_mbio(&fio);
> > 
> > +	/* allocate block address */
> > +	f2fs_wait_on_page_writeback(dn.node_page, NODE);
> > +	allocate_data_block(fio.sbi, NULL, fio.blk_addr,
> > +					&fio.blk_addr, &sum, CURSEG_COLD_DATA);
> 
> move above f2fs_submit_page_mbio(&fio) to here?

Fixed.

Thanks,

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

end of thread, other threads:[~2015-07-15 22:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-14 19:18 [PATCH 1/2] f2fs: handle error cases in move_encrypted_block Jaegeuk Kim
2015-07-14 19:18 ` [PATCH 2/2] f2fs: use a page temporarily for encrypted gced page Jaegeuk Kim
2015-07-15  1:43   ` [f2fs-dev] " Chao Yu
2015-07-15  1:39 ` [f2fs-dev] [PATCH 1/2] f2fs: handle error cases in move_encrypted_block Chao Yu
2015-07-15 22:42   ` Jaegeuk Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).