1 From: Dave Chinner <dchinner@redhat.com>
\r
3 If inode_item_done() fails to flush an inode after we've grabbed a
\r
4 reference to the underlying buffer during a transaction commit, we
\r
5 fail to put the buffer and hence leak it. We then deadlock on the
\r
6 next lookup ofthe inode buffer as it is still locked and no-one owns
\r
9 To fix it, put the buffer on error so that it gets unlocked and
\r
10 can be recovered appropriately in a later phase of repair.
\r
12 Reported-by: Arkadiusz Miskiewicz <arekm@maven.pl>
\r
13 Fixes: d15188a1ec14 ("xfs: rework the inline directory verifiers")
\r
14 Signed-off-by: Dave Chinner <dchinner@redhat.com>
\r
16 libxfs/trans.c | 17 +++++++++++++----
\r
17 1 file changed, 13 insertions(+), 4 deletions(-)
\r
19 diff --git a/libxfs/trans.c b/libxfs/trans.c
\r
20 index 46ff8b4ae798..10a35dd47b01 100644
\r
21 --- a/libxfs/trans.c
\r
22 +++ b/libxfs/trans.c
\r
23 @@ -824,8 +824,10 @@ _("Transaction block reservation exceeded! %u > %u\n"),
\r
26 * Transaction commital code follows (i.e. write to disk in libxfs)
\r
28 + * XXX (dgc): should failure to flush the inode (e.g. due to uncorrected
\r
29 + * corruption) result in transaction commit failure w/ EFSCORRUPTED?
\r
34 xfs_inode_log_item_t *iip)
\r
35 @@ -856,17 +858,24 @@ inode_item_done(
\r
40 + * Flush the inode and disassociate it from the transaction regardless
\r
41 + * of whether the flush succeed or not. If we fail the flush, make sure
\r
42 + * we still release the buffer reference we currently hold.
\r
44 bp->b_log_item = iip;
\r
45 error = libxfs_iflush_int(ip, bp);
\r
46 + ip->i_transp = NULL; /* disassociate from transaction */
\r
47 + bp->b_log_item = NULL; /* remove log item */
\r
48 + bp->b_transp = NULL; /* remove xact ptr */
\r
51 fprintf(stderr, _("%s: warning - iflush_int failed (%d)\n"),
\r
53 + libxfs_putbuf(bp);
\r
57 - ip->i_transp = NULL; /* disassociate from transaction */
\r
58 - bp->b_log_item = NULL; /* remove log item */
\r
59 - bp->b_transp = NULL; /* remove xact ptr */
\r
60 libxfs_writebuf(bp, 0);
\r
62 fprintf(stderr, "flushing dirty inode %llu, buffer %p\n",
\r