From: Chao Yu <chao@kernel.org>
To: Hyeong-Jun Kim <hj514.kim@samsung.com>,
Fengnan Chang <changfengnan@vivo.com>,
Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Sungjong Seo <sj1557.seo@samsung.com>,
Youngjin Gil <youngjin.gil@samsung.com>,
linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] f2fs: compress: fix potential deadlock of compress file
Date: Fri, 10 Dec 2021 22:59:35 +0800 [thread overview]
Message-ID: <139522fa-ad23-ccce-52cb-e7fa9caf2394@kernel.org> (raw)
In-Reply-To: <20211210043012.180588-1-hj514.kim@samsung.com>
On 2021/12/10 12:30, Hyeong-Jun Kim wrote:
> There is a potential deadlock between writeback process and a process
> performing write_begin() or write_cache_pages() while trying to write
> same compress file, but not compressable, as below:
>
> [Process A] - doing checkpoint
> [Process B] [Process C]
> f2fs_write_cache_pages()
> - lock_page() [all pages in cluster, 0-31]
> - f2fs_write_multi_pages()
> - f2fs_write_raw_pages()
> - f2fs_write_single_data_page()
> - f2fs_do_write_data_page()
> - return -EAGAIN [f2fs_trylock_op() failed]
> - unlock_page(page) [e.g., page 0]
> - generic_perform_write()
> - f2fs_write_begin()
> - f2fs_prepare_compress_overwrite()
> - prepare_compress_overwrite()
> - lock_page() [e.g., page 0]
> - lock_page() [e.g., page 1]
> - lock_page(page) [e.g., page 0]
>
> Since there is no compress process, it is no longer necessary to hold
> locks on every pages in cluster within f2fs_write_raw_pages().
>
> This patch changes f2fs_write_raw_pages() to release all locks first
> and then perform write same as the non-compress file in
> f2fs_write_cache_pages().
>
> Fixes: 4c8ff7095bef ("f2fs: support data compression")
> Signed-off-by: Hyeong-Jun Kim <hj514.kim@samsung.com>
> Signed-off-by: Sungjong Seo <sj1557.seo@samsung.com>
> Signed-off-by: Youngjin Gil <youngjin.gil@samsung.com>
Looks good to me, thanks for Fengnan and Hyeong-Jun's report and Hyeong-Jun's
fixing. :)
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
prev parent reply other threads:[~2021-12-10 14:59 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20211210043017epcas1p38cc53389a50e33752e97618498b18f33@epcas1p3.samsung.com>
2021-12-10 4:30 ` Hyeong-Jun Kim
2021-12-10 6:32 ` [f2fs-dev] " fengnan chang
2021-12-10 14:59 ` Chao Yu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=139522fa-ad23-ccce-52cb-e7fa9caf2394@kernel.org \
--to=chao@kernel.org \
--cc=changfengnan@vivo.com \
--cc=hj514.kim@samsung.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=sj1557.seo@samsung.com \
--cc=youngjin.gil@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®