]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.22.14/ocfs2-fix-write-performance-regression.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 2.6.22.14 / ocfs2-fix-write-performance-regression.patch
1 From mark.fasheh@oracle.com Mon Nov 19 09:43:53 2007
2 From: Mark Fasheh <mark.fasheh@oracle.com>
3 Date: Wed, 14 Nov 2007 13:33:27 -0800
4 Subject: ocfs2: fix write() performance regression
5 To: gregkh@suse.de
6 Cc: stable@kernel.org
7 Message-ID: <20071114213327.GN28607@ca-server1.us.oracle.com>
8 Content-Disposition: inline
9
10
11 From: Mark Fasheh <mark.fasheh@oracle.com>
12
13 ocfs2: fix write() performance regression
14
15 patch 4e9563fd55ff4479f2b118d0757d121dd0cfc39c in mainline.
16
17 On file systems which don't support sparse files, Ocfs2_map_page_blocks()
18 was reading blocks on appending writes. This caused write performance to
19 suffer dramatically. Fix this by detecting an appending write on a nonsparse
20 fs and skipping the read.
21
22 Signed-off-by: Mark Fasheh <mark.fasheh@oracle.com>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
24
25 ---
26 fs/ocfs2/aops.c | 24 +++++++++++++++++++++++-
27 1 file changed, 23 insertions(+), 1 deletion(-)
28
29 --- a/fs/ocfs2/aops.c
30 +++ b/fs/ocfs2/aops.c
31 @@ -661,6 +661,27 @@ static void ocfs2_clear_page_regions(str
32 }
33
34 /*
35 + * Nonsparse file systems fully allocate before we get to the write
36 + * code. This prevents ocfs2_write() from tagging the write as an
37 + * allocating one, which means ocfs2_map_page_blocks() might try to
38 + * read-in the blocks at the tail of our file. Avoid reading them by
39 + * testing i_size against each block offset.
40 + */
41 +static int ocfs2_should_read_blk(struct inode *inode, struct page *page,
42 + unsigned int block_start)
43 +{
44 + u64 offset = page_offset(page) + block_start;
45 +
46 + if (ocfs2_sparse_alloc(OCFS2_SB(inode->i_sb)))
47 + return 1;
48 +
49 + if (i_size_read(inode) > offset)
50 + return 1;
51 +
52 + return 0;
53 +}
54 +
55 +/*
56 * Some of this taken from block_prepare_write(). We already have our
57 * mapping by now though, and the entire write will be allocating or
58 * it won't, so not much need to use BH_New.
59 @@ -711,7 +732,8 @@ int ocfs2_map_page_blocks(struct page *p
60 if (!buffer_uptodate(bh))
61 set_buffer_uptodate(bh);
62 } else if (!buffer_uptodate(bh) && !buffer_delay(bh) &&
63 - (block_start < from || block_end > to)) {
64 + ocfs2_should_read_blk(inode, page, block_start) &&
65 + (block_start < from || block_end > to)) {
66 ll_rw_block(READ, 1, &bh);
67 *wait_bh++=bh;
68 }