* [PATCH v2] f2fs:return directly if block has been removed from the victim
@ 2016-11-02 10:41 Yunlei He
2016-11-02 11:54 ` Chao Yu
2016-11-02 18:05 ` Jaegeuk Kim
0 siblings, 2 replies; 3+ messages in thread
From: Yunlei He @ 2016-11-02 10:41 UTC (permalink / raw)
To: linux-f2fs-devel, jaegeuk, yuchao0; +Cc: heyunlei
If one block has been to written to a new place, just return
in move data process. This patch check it again with holding
page lock.
Signed-off-by: Yunlei He <heyunlei@huawei.com>
---
fs/f2fs/gc.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 9c18917..131e0fe 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -544,7 +544,8 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
return true;
}
-static void move_encrypted_block(struct inode *inode, block_t bidx)
+static void move_encrypted_block(struct inode *inode, block_t bidx,
+ unsigned int segno, int off)
{
struct f2fs_io_info fio = {
.sbi = F2FS_I_SB(inode),
@@ -579,6 +580,9 @@ static void move_encrypted_block(struct inode *inode, block_t bidx)
* don't cache encrypted data into meta inode until previous dirty
* data were writebacked to avoid racing between GC and flush.
*/
+ if (!check_valid_map(F2FS_I_SB(inode), segno, off))
+ goto out;
+
f2fs_wait_on_page_writeback(page, DATA, true);
get_node_info(fio.sbi, dn.nid, &ni);
@@ -645,7 +649,8 @@ static void move_encrypted_block(struct inode *inode, block_t bidx)
f2fs_put_page(page, 1);
}
-static void move_data_page(struct inode *inode, block_t bidx, int gc_type)
+static void move_data_page(struct inode *inode, block_t bidx, int gc_type,
+ unsigned int segno, int off)
{
struct page *page;
@@ -670,6 +675,9 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type)
bool is_dirty = PageDirty(page);
int err;
+ if (!check_valid_map(F2FS_I_SB(inode), segno, off))
+ goto out;
+
retry:
set_page_dirty(page);
f2fs_wait_on_page_writeback(page, DATA, true);
@@ -796,9 +804,9 @@ 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);
+ move_encrypted_block(inode, start_bidx, segno, off);
else
- move_data_page(inode, start_bidx, gc_type);
+ move_data_page(inode, start_bidx, gc_type, segno, off);
if (locked) {
up_write(&fi->dio_rwsem[WRITE]);
--
2.10.1
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2] f2fs:return directly if block has been removed from the victim
2016-11-02 10:41 [PATCH v2] f2fs:return directly if block has been removed from the victim Yunlei He
@ 2016-11-02 11:54 ` Chao Yu
2016-11-02 18:05 ` Jaegeuk Kim
1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2016-11-02 11:54 UTC (permalink / raw)
To: Yunlei He, linux-f2fs-devel, jaegeuk; +Cc: heyunlei
On 2016/11/2 18:41, Yunlei He wrote:
> If one block has been to written to a new place, just return
> in move data process. This patch check it again with holding
> page lock.
>
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
> fs/f2fs/gc.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index 9c18917..131e0fe 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -544,7 +544,8 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
> return true;
> }
>
> -static void move_encrypted_block(struct inode *inode, block_t bidx)
> +static void move_encrypted_block(struct inode *inode, block_t bidx,
> + unsigned int segno, int off)
> {
> struct f2fs_io_info fio = {
> .sbi = F2FS_I_SB(inode),
> @@ -579,6 +580,9 @@ static void move_encrypted_block(struct inode *inode, block_t bidx)
> * don't cache encrypted data into meta inode until previous dirty
> * data were writebacked to avoid racing between GC and flush.
> */
> + if (!check_valid_map(F2FS_I_SB(inode), segno, off))
> + goto out;
> +
> f2fs_wait_on_page_writeback(page, DATA, true);
>
> get_node_info(fio.sbi, dn.nid, &ni);
> @@ -645,7 +649,8 @@ static void move_encrypted_block(struct inode *inode, block_t bidx)
> f2fs_put_page(page, 1);
> }
>
> -static void move_data_page(struct inode *inode, block_t bidx, int gc_type)
> +static void move_data_page(struct inode *inode, block_t bidx, int gc_type,
> + unsigned int segno, int off)
> {
> struct page *page;
>
> @@ -670,6 +675,9 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type)
> bool is_dirty = PageDirty(page);
> int err;
>
> + if (!check_valid_map(F2FS_I_SB(inode), segno, off))
Better to do detection after get_lock_data_page?
Thanks,
> + goto out;
> +
> retry:
> set_page_dirty(page);
> f2fs_wait_on_page_writeback(page, DATA, true);
> @@ -796,9 +804,9 @@ 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);
> + move_encrypted_block(inode, start_bidx, segno, off);
> else
> - move_data_page(inode, start_bidx, gc_type);
> + move_data_page(inode, start_bidx, gc_type, segno, off);
>
> if (locked) {
> up_write(&fi->dio_rwsem[WRITE]);
>
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] f2fs:return directly if block has been removed from the victim
2016-11-02 10:41 [PATCH v2] f2fs:return directly if block has been removed from the victim Yunlei He
2016-11-02 11:54 ` Chao Yu
@ 2016-11-02 18:05 ` Jaegeuk Kim
1 sibling, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2016-11-02 18:05 UTC (permalink / raw)
To: Yunlei He; +Cc: heyunlei, linux-f2fs-devel
On Wed, Nov 02, 2016 at 06:41:50PM +0800, Yunlei He wrote:
> If one block has been to written to a new place, just return
> in move data process. This patch check it again with holding
> page lock.
>
> Signed-off-by: Yunlei He <heyunlei@huawei.com>
> ---
> fs/f2fs/gc.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
> index 9c18917..131e0fe 100644
> --- a/fs/f2fs/gc.c
> +++ b/fs/f2fs/gc.c
> @@ -544,7 +544,8 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
> return true;
> }
>
> -static void move_encrypted_block(struct inode *inode, block_t bidx)
> +static void move_encrypted_block(struct inode *inode, block_t bidx,
> + unsigned int segno, int off)
> {
> struct f2fs_io_info fio = {
> .sbi = F2FS_I_SB(inode),
> @@ -579,6 +580,9 @@ static void move_encrypted_block(struct inode *inode, block_t bidx)
> * don't cache encrypted data into meta inode until previous dirty
> * data were writebacked to avoid racing between GC and flush.
> */
> + if (!check_valid_map(F2FS_I_SB(inode), segno, off))
> + goto out;
goto put_out;
> +
> f2fs_wait_on_page_writeback(page, DATA, true);
>
> get_node_info(fio.sbi, dn.nid, &ni);
> @@ -645,7 +649,8 @@ static void move_encrypted_block(struct inode *inode, block_t bidx)
> f2fs_put_page(page, 1);
> }
>
> -static void move_data_page(struct inode *inode, block_t bidx, int gc_type)
> +static void move_data_page(struct inode *inode, block_t bidx, int gc_type,
> + unsigned int segno, int off)
> {
> struct page *page;
>
> @@ -670,6 +675,9 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type)
> bool is_dirty = PageDirty(page);
> int err;
>
> + if (!check_valid_map(F2FS_I_SB(inode), segno, off))
> + goto out;
Agreed with Chao.
Thanks,
> +
> retry:
> set_page_dirty(page);
> f2fs_wait_on_page_writeback(page, DATA, true);
> @@ -796,9 +804,9 @@ 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);
> + move_encrypted_block(inode, start_bidx, segno, off);
> else
> - move_data_page(inode, start_bidx, gc_type);
> + move_data_page(inode, start_bidx, gc_type, segno, off);
>
> if (locked) {
> up_write(&fi->dio_rwsem[WRITE]);
> --
> 2.10.1
>
>
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-02 18:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-02 10:41 [PATCH v2] f2fs:return directly if block has been removed from the victim Yunlei He
2016-11-02 11:54 ` Chao Yu
2016-11-02 18:05 ` 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).