]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: Jeff Mahoney <jeffm@suse.com> |
2 | Subject: [PATCH] reiserfs: Use list_del_init in use_preallocated_list_if_available | |
3 | References: bnc#378095 | |
4 | ||
5 | __discard_prealloc() calls list_del on ei->i_prealloc_list regardless of | |
6 | the state of ei->i_prealloc_count. The rest of the action in that function | |
7 | is safe regardless of if the list is empty or not. | |
8 | ||
9 | If the list hasn't been used, then i_prealloc_list will be just initialized. | |
10 | If it has, and use_preallocated_list_if_available() has been called, and | |
11 | the prealloc list has been depleted, then the list entry will be poisoned. | |
12 | ||
13 | This patch uses list_del_init so the list_head is initialized and we don't | |
14 | oops on the poisoned value. | |
15 | ||
16 | Signed-off-by: Jeff Mahoney <jeffm@suse.com> | |
17 | ||
18 | --- | |
19 | fs/reiserfs/bitmap.c | 11 ++++++----- | |
20 | 1 file changed, 6 insertions(+), 5 deletions(-) | |
21 | ||
22 | --- a/fs/reiserfs/bitmap.c | |
23 | +++ b/fs/reiserfs/bitmap.c | |
24 | @@ -1145,17 +1145,18 @@ static int use_preallocated_list_if_avai | |
25 | int amount_needed) | |
26 | { | |
27 | struct inode *inode = hint->inode; | |
28 | + struct reiserfs_inode_info *ei = REISERFS_I(inode); | |
29 | ||
30 | - if (REISERFS_I(inode)->i_prealloc_count > 0) { | |
31 | + if (ei->i_prealloc_count > 0) { | |
32 | while (amount_needed) { | |
33 | ||
34 | - *new_blocknrs++ = REISERFS_I(inode)->i_prealloc_block++; | |
35 | - REISERFS_I(inode)->i_prealloc_count--; | |
36 | + *new_blocknrs++ = ei->i_prealloc_block++; | |
37 | + ei->i_prealloc_count--; | |
38 | ||
39 | amount_needed--; | |
40 | ||
41 | - if (REISERFS_I(inode)->i_prealloc_count <= 0) { | |
42 | - list_del(&REISERFS_I(inode)->i_prealloc_list); | |
43 | + if (ei->i_prealloc_count <= 0) { | |
44 | + list_del_init(&ei->i_prealloc_list); | |
45 | break; | |
46 | } | |
47 | } |