xfs: Fix leak of discard bio
Subsystems (2)
PATCH 1/1 xfs: Fix leak of discard bio
The bio describing discard operation is allocated by __blkdev_issue_discard() which returns us a reference to it. That reference is never released and thus we leak this bio. Drop the bio reference once it completes in xlog_discard_endio().
--- fs/xfs/xfs_log_cil.c | 1 + 1 file changed, 1 insertion(+)
Note, this is untested. It's just something I've noticed when looking at the code.
fs/xfs/xfs_log_cil.c +1 -0
@@ -539,6 +539,7 @@ xlog_discard_endio(INIT_WORK (&ctx->discard_endio_work, xlog_discard_endio_work);queue_work (xfs_discard_wq, &ctx->discard_endio_work); +bio_put (bio); } static void
Signature · 1 line
2.12.3
Quoted 20 lines · Jan Kara
The bio describing discard operation is allocated by
__blkdev_issue_discard()which returns us a reference to it. That reference is never released and thus we leak this bio. Drop the bio reference once it completes inxlog_discard_endio().Fixes 4560e78f40cb55bd2ea8f1ef4001c5baa88531c7Signed-off-by Jan Kara <[email protected]>--- fs/xfs/xfs_log_cil.c | 1 + 1 file changed, 1 insertion(+)Note, this is untested. It's just something I've noticed when looking at the code.
fs/xfs/xfs_log_cil.c +0
-0
fs/xfs/xfs_log_cil.c xlog_discard_endio( · line 543
Quoted 5 lines
fs/xfs/xfs_log_cil.c +1
-0@@ -539,6 +539,7 @@ xlog_discard_endio(INIT_WORK (&ctx->discard_endio_work, xlog_discard_endio_work);queue_work (xfs_discard_wq, &ctx->discard_endio_work); +bio_put (bio); }
At a quick glance, it does seem that we are leaking the bio here. It appears to me that ext4_process_freed_data() also has the same problem and leaks the discard_bio....
Cheers,
Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 22 lines · Dave Chinner
Quoted 21 lines · Jan Kara
The bio describing discard operation is allocated by
__blkdev_issue_discard()which returns us a reference to it. That reference is never released and thus we leak this bio. Drop the bio reference once it completes inxlog_discard_endio().Fixes 4560e78f40cb55bd2ea8f1ef4001c5baa88531c7Signed-off-by Jan Kara <[email protected]>--- fs/xfs/xfs_log_cil.c | 1 + 1 file changed, 1 insertion(+)Note, this is untested. It's just something I've noticed when looking at the code.
fs/xfs/xfs_log_cil.c +0
-0@@ -539,6 +539,7 @@ xlog_discard_endio(
Quoted 8 lines
fs/xfs/xfs_log_cil.c xlog_discard_endio( · line 543
Quoted 4 lines
fs/xfs/xfs_log_cil.c +1
-0INIT_WORK (&ctx->discard_endio_work, xlog_discard_endio_work);queue_work (xfs_discard_wq, &ctx->discard_endio_work); +bio_put (bio); }At a quick glance, it does seem that we are leaking the bio here. It appears to me that
ext4_process_freed_data()also has the same problem and leaks thediscard_bio....
Yes, and a fix of that prompted me to look into how XFS does things ;)
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 20 lines · Jan Kara
The bio describing discard operation is allocated by
__blkdev_issue_discard()which returns us a reference to it. That reference is never released and thus we leak this bio. Drop the bio reference once it completes inxlog_discard_endio().Fixes 4560e78f40cb55bd2ea8f1ef4001c5baa88531c7Signed-off-by Jan Kara <[email protected]>--- fs/xfs/xfs_log_cil.c | 1 + 1 file changed, 1 insertion(+)Note, this is untested. It's just something I've noticed when looking at the code.
fs/xfs/xfs_log_cil.c +0
-0
fs/xfs/xfs_log_cil.c xlog_discard_endio( · line 542
Quoted 4 lines
fs/xfs/xfs_log_cil.c +1
-0@@ -539,6 +539,7 @@ xlog_discard_endio(INIT_WORK (&ctx->discard_endio_work, xlog_discard_endio_work);queue_work (xfs_discard_wq, &ctx->discard_endio_work); +bio_put (bio);
It would seem that we /do/ leak the bio here. :(
--D
Quoted 10 lines
fs/xfs/xfs_log_cil.c +0
-0} static voidSignature · 6 lines
2.12.3 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Looks fine,