From: Chao Yu <[email protected]>

[ Upstream commit df77fbd8c5b222c680444801ffd20e8bbc90a56e ]

Using f2fs_trylock_op() in f2fs_write_compressed_pages() to avoid potential
deadlock like we did in f2fs_write_single_data_page().

Signed-off-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
---
 fs/f2fs/compress.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index d8a64be90a501..c847523ab4a2e 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -772,7 +772,6 @@ static int f2fs_write_compressed_pages(struct compress_ctx 
*cc,
                .encrypted_page = NULL,
                .compressed_page = NULL,
                .submitted = false,
-               .need_lock = LOCK_RETRY,
                .io_type = io_type,
                .io_wbc = wbc,
                .encrypted = f2fs_encrypted_file(cc->inode),
@@ -785,9 +784,10 @@ static int f2fs_write_compressed_pages(struct compress_ctx 
*cc,
        loff_t psize;
        int i, err;
 
-       set_new_dnode(&dn, cc->inode, NULL, NULL, 0);
+       if (!f2fs_trylock_op(sbi))
+               return -EAGAIN;
 
-       f2fs_lock_op(sbi);
+       set_new_dnode(&dn, cc->inode, NULL, NULL, 0);
 
        err = f2fs_get_dnode_of_data(&dn, start_idx, LOOKUP_NODE);
        if (err)
-- 
2.20.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to