mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
ceph: fix writeback_count leak in write_folio_nounlock()
commitcbf59617cdupstream. write_folio_nounlock() increments fsc->writeback_count to track in-flight writeback operations. On several error paths where the function returns early (folio lookup failure, snapshot context allocation failure, and writepages submission failure), the function returns without calling atomic_long_dec_return() to decrement the counter. Each leaked increment keeps the counter above zero, which can prevent the filesystem from cleanly unmounting or suspending writes. Add atomic_long_dec_return() calls on all error paths that currently return without decrementing the counter. Cc: stable@vger.kernel.org Fixes:d55207717d("ceph: add encryption support to writepage and writepages") Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> Reviewed-by: Viacheslav Dubeyko <Slava.Dubeyko@ibm.com> Signed-off-by: Ilya Dryomov <idryomov@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
a7c2dfa610
commit
7d03e08b76
@@ -785,6 +785,9 @@ static int write_folio_nounlock(struct folio *folio,
|
||||
ceph_wbc.truncate_size, true);
|
||||
if (IS_ERR(req)) {
|
||||
folio_redirty_for_writepage(wbc, folio);
|
||||
if (atomic_long_dec_return(&fsc->writeback_count) <
|
||||
CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
|
||||
fsc->write_congested = false;
|
||||
return PTR_ERR(req);
|
||||
}
|
||||
|
||||
@@ -804,6 +807,9 @@ static int write_folio_nounlock(struct folio *folio,
|
||||
folio_redirty_for_writepage(wbc, folio);
|
||||
folio_end_writeback(folio);
|
||||
ceph_osdc_put_request(req);
|
||||
if (atomic_long_dec_return(&fsc->writeback_count) <
|
||||
CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
|
||||
fsc->write_congested = false;
|
||||
return PTR_ERR(bounce_page);
|
||||
}
|
||||
}
|
||||
@@ -838,6 +844,9 @@ static int write_folio_nounlock(struct folio *folio,
|
||||
ceph_vinop(inode), folio);
|
||||
folio_redirty_for_writepage(wbc, folio);
|
||||
folio_end_writeback(folio);
|
||||
if (atomic_long_dec_return(&fsc->writeback_count) <
|
||||
CONGESTION_OFF_THRESH(fsc->mount_options->congestion_kb))
|
||||
fsc->write_congested = false;
|
||||
return err;
|
||||
}
|
||||
if (err == -EBLOCKLISTED)
|
||||
|
||||
Reference in New Issue
Block a user