* [PATCH 04/10] btrfs: Add error check for add_to_page_cache_lru
@ 2010-05-20 7:18 Miao Xie
2010-05-20 8:43 ` Mike Fedyk
0 siblings, 1 reply; 3+ messages in thread
From: Miao Xie @ 2010-05-20 7:18 UTC (permalink / raw)
To: Chris Mason; +Cc: Linux Btrfs
From: Liu Bo <liubo2009@cn.fujitsu.com>
If add_to_page_cache_lru() returns -EEXIST, it indicates the page
that belongs to this page_index has been added and this readahead
action can go on to next page.
If add_to_page_cache_lru() returns -ENOMEM, it should break for
no memory left.
Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
---
fs/btrfs/compression.c | 19 ++++++++++++++++---
1 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c
index 1d54c53..1bd4d92 100644
--- a/fs/btrfs/compression.c
+++ b/fs/btrfs/compression.c
@@ -480,10 +480,23 @@ static noinline int add_ra_bio_pages(struct inode *inode,
if (!page)
break;
- if (add_to_page_cache_lru(page, mapping, page_index,
- GFP_NOFS)) {
+ ret = add_to_page_cache_lru(page, mapping, page_index,
+ GFP_NOFS);
+ if (ret) {
page_cache_release(page);
- goto next;
+
+ /*
+ * -EEXIST indicates the page has been added, so
+ * it can move on to next page.
+ */
+ if (ret == -EEXIST) {
+ misses++;
+ if (misses > 4)
+ break;
+ goto next;
+ }
+
+ break;
}
end = last_offset + PAGE_CACHE_SIZE - 1;
--
1.6.5.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 04/10] btrfs: Add error check for add_to_page_cache_lru
2010-05-20 7:18 [PATCH 04/10] btrfs: Add error check for add_to_page_cache_lru Miao Xie
@ 2010-05-20 8:43 ` Mike Fedyk
2010-05-24 2:34 ` liubo
0 siblings, 1 reply; 3+ messages in thread
From: Mike Fedyk @ 2010-05-20 8:43 UTC (permalink / raw)
To: miaox; +Cc: Chris Mason, Linux Btrfs
T24gVGh1LCBNYXkgMj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sKPiAtLQo+IDEuNi41LjIKPgo+
IC0tCj4gVG8gdW5zdWJzY3JpYmUgZnJvbSB0aGlzIGxpc3Q6IHNlbmQgdGhlIGxpbmUgInVuc3Vi
c2NyaWJlIGxpbnV4LWJ0cmZzIiBpbgo+IHRoZSBib2R5IG9mIGEgbWVzc2FnZSB0byBtYWpvcmRv
bW9Admdlci5rZXJuZWwub3JnCj4gTW9yZSBtYWpvcmRvbW8gaW5mbyBhdCDCoGh0dHA6Ly92Z2Vy
Lmtlcm5lbC5vcmcvbWFqb3Jkb21vLWluZm8uaHRtbAo+Cg==
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 04/10] btrfs: Add error check for add_to_page_cache_lru
2010-05-20 8:43 ` Mike Fedyk
@ 2010-05-24 2:34 ` liubo
0 siblings, 0 replies; 3+ messages in thread
From: liubo @ 2010-05-24 2:34 UTC (permalink / raw)
To: Mike Fedyk; +Cc: miaox, Chris Mason, Linux Btrfs
On 05/20/2010 04:43 PM, Mike Fedyk wrote:
> Shouldn't this use a pre-processor label instead of hard coding
> compression sensitivity or readahead tuning? this way it'll be set in
> one place.
>
>
All right.
Since Adding a macro may make the whole code harder to read, I add a
"goto" to avoid this kind of hard coding style instead.
Thanks.
--
Liubo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-05-24 2:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-20 7:18 [PATCH 04/10] btrfs: Add error check for add_to_page_cache_lru Miao Xie
2010-05-20 8:43 ` Mike Fedyk
2010-05-24 2:34 ` liubo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).