Miao Xie
2010-May-20 07:18 UTC
[PATCH 04/10] btrfs: Add error check for add_to_page_cache_lru
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
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs"
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Mike Fedyk
2010-May-20 08:43 UTC
Re: [PATCH 04/10] btrfs: Add error check for add_to_page_cache_lru
On Thu, May 20, 2010 at 12:18 AM, Miao Xie <miaox@cn.fujitsu.com> wrote:> 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;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.> + goto next; > + } > + > + break; > } > > end = last_offset + PAGE_CACHE_SIZE - 1; > -- > 1.6.5.2 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html >
liubo
2010-May-24 02:34 UTC
Re: [PATCH 04/10] btrfs: Add error check for add_to_page_cache_lru
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 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html