]> git.pld-linux.org Git - packages/xfsprogs.git/blob - xfsprogs-small_fixes.patch
- rel 2; fix deadlock
[packages/xfsprogs.git] / xfsprogs-small_fixes.patch
1 From: Dave Chinner <dchinner@redhat.com>\r
2 \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
7 it.\r
8 \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
11 \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
15 ---\r
16  libxfs/trans.c | 17 +++++++++++++----\r
17  1 file changed, 13 insertions(+), 4 deletions(-)\r
18 \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
24  \r
25  /*\r
26   * Transaction commital code follows (i.e. write to disk in libxfs)\r
27 + *\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
30   */\r
31 -\r
32  static void\r
33  inode_item_done(\r
34         xfs_inode_log_item_t    *iip)\r
35 @@ -856,17 +858,24 @@ inode_item_done(\r
36                 return;\r
37         }\r
38  \r
39 +       /*\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
43 +        */\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
49 +\r
50         if (error) {\r
51                 fprintf(stderr, _("%s: warning - iflush_int failed (%d)\n"),\r
52                         progname, error);\r
53 +               libxfs_putbuf(bp);\r
54                 return;\r
55         }\r
56  \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
61  #ifdef XACT_DEBUG\r
62         fprintf(stderr, "flushing dirty inode %llu, buffer %p\n",\r
63 -- \r
64 2.20.1\r
65 \r
This page took 0.0344989999999999 seconds and 3 git commands to generate.