lkml.org 
[lkml]   [2020]   [Jan]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH TEST] f2fs: compress: fix deadlock in prepare_compress_overwrite()
Date
   100.00%    13.65%  fsstress  [f2fs]              [k] prepare_compress_overwrite
|
|--86.35%--prepare_compress_overwrite
| |
| |--46.78%--f2fs_read_multi_pages
| | |
| | |--19.81%--f2fs_decompress_end_io
| | | |
| | | --5.77%--unlock_page
| | |
| | |--19.53%--f2fs_get_dnode_of_data

In prepare_compress_overwrite(), we need to check cluster state before
read cluster data, otherwise, read normal cluster as a compressed one
will always cause failure and retry.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/f2fs/compress.c | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 9e8fba78db4d..f993b4ce1970 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -570,8 +570,7 @@ static void set_cluster_dirty(struct compress_ctx *cc)
}

static int prepare_compress_overwrite(struct compress_ctx *cc,
- struct page **pagep, pgoff_t index, void **fsdata,
- bool prealloc)
+ struct page **pagep, pgoff_t index, void **fsdata)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(cc->inode);
struct address_space *mapping = cc->inode->i_mapping;
@@ -582,11 +581,20 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
unsigned int start_idx = start_idx_of_cluster(cc);
int i, idx;
int ret;
+ bool prealloc;
+
+retry:
+ ret = is_compressed_cluster(cc);
+ if (ret <= 0)
+ return ret;
+
+ /* compressed case */
+ prealloc = (ret == CLUSTER_HAS_SPACE);

ret = f2fs_init_compress_ctx(cc);
if (ret)
return ret;
-retry:
+
/* keep page reference to avoid page reclaim */
for (i = 0; i < cc->cluster_size; i++) {
page = f2fs_pagecache_get_page(mapping, start_idx + i,
@@ -632,6 +640,7 @@ static int prepare_compress_overwrite(struct compress_ctx *cc,
(idx <= i) ? 1 : 0);
cc->rpages[idx] = NULL;
}
+ kvfree(cc->rpages);
cc->nr_rpages = 0;
goto retry;
}
@@ -687,14 +696,8 @@ int f2fs_prepare_compress_overwrite(struct inode *inode,
.rpages = NULL,
.nr_rpages = 0,
};
- int ret = is_compressed_cluster(&cc);
-
- if (ret <= 0)
- return ret;

- /* compressed case */
- return prepare_compress_overwrite(&cc, pagep, index,
- fsdata, ret == CLUSTER_HAS_SPACE);
+ return prepare_compress_overwrite(&cc, pagep, index, fsdata);
}

bool f2fs_compress_write_end(struct inode *inode, void *fsdata,
--
2.18.0.rc1
\
 
 \ /
  Last update: 2020-01-03 10:51    [W:0.191 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site