Commit 0ee0fda0 authored by Sven Wegener's avatar Sven Wegener Committed by Chris Mason

Btrfs: Add compatibility for kernels >= 2.6.27-rc1

Add a couple of #if's to follow API changes.
Signed-off-by: default avatarSven Wegener <sven.wegener@stealer.net>
Signed-off-by: default avatarChris Mason <chris.mason@oracle.com>
parent bcc63abb
...@@ -2649,9 +2649,24 @@ static inline struct page *extent_buffer_page(struct extent_buffer *eb, ...@@ -2649,9 +2649,24 @@ static inline struct page *extent_buffer_page(struct extent_buffer *eb,
mapping = eb->first_page->mapping; mapping = eb->first_page->mapping;
if (!mapping) if (!mapping)
return NULL; return NULL;
/*
* extent_buffer_page is only called after pinning the page
* by increasing the reference count. So we know the page must
* be in the radix tree.
*/
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
rcu_read_lock();
#else
read_lock_irq(&mapping->tree_lock); read_lock_irq(&mapping->tree_lock);
#endif
p = radix_tree_lookup(&mapping->page_tree, i); p = radix_tree_lookup(&mapping->page_tree, i);
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
rcu_read_unlock();
#else
read_unlock_irq(&mapping->tree_lock); read_unlock_irq(&mapping->tree_lock);
#endif
return p; return p;
} }
...@@ -2843,13 +2858,21 @@ int clear_extent_buffer_dirty(struct extent_io_tree *tree, ...@@ -2843,13 +2858,21 @@ int clear_extent_buffer_dirty(struct extent_io_tree *tree,
} }
} }
clear_page_dirty_for_io(page); clear_page_dirty_for_io(page);
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
spin_lock_irq(&page->mapping->tree_lock);
#else
read_lock_irq(&page->mapping->tree_lock); read_lock_irq(&page->mapping->tree_lock);
#endif
if (!PageDirty(page)) { if (!PageDirty(page)) {
radix_tree_tag_clear(&page->mapping->page_tree, radix_tree_tag_clear(&page->mapping->page_tree,
page_index(page), page_index(page),
PAGECACHE_TAG_DIRTY); PAGECACHE_TAG_DIRTY);
} }
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
spin_unlock_irq(&page->mapping->tree_lock);
#else
read_unlock_irq(&page->mapping->tree_lock); read_unlock_irq(&page->mapping->tree_lock);
#endif
unlock_page(page); unlock_page(page);
} }
return 0; return 0;
......
...@@ -886,7 +886,11 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf, ...@@ -886,7 +886,11 @@ static ssize_t btrfs_file_write(struct file *file, const char __user *buf,
#ifdef REMOVE_SUID_PATH #ifdef REMOVE_SUID_PATH
err = remove_suid(&file->f_path); err = remove_suid(&file->f_path);
#else #else
# if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
err = file_remove_suid(file);
# else
err = remove_suid(fdentry(file)); err = remove_suid(fdentry(file));
# endif
#endif #endif
if (err) if (err)
goto out_nolock; goto out_nolock;
......
...@@ -3293,7 +3293,9 @@ void btrfs_destroy_inode(struct inode *inode) ...@@ -3293,7 +3293,9 @@ void btrfs_destroy_inode(struct inode *inode)
kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode)); kmem_cache_free(btrfs_inode_cachep, BTRFS_I(inode));
} }
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23) #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
static void init_once(void *foo)
#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
static void init_once(struct kmem_cache * cachep, void *foo) static void init_once(struct kmem_cache * cachep, void *foo)
#else #else
static void init_once(void * foo, struct kmem_cache * cachep, static void init_once(void * foo, struct kmem_cache * cachep,
...@@ -3321,7 +3323,9 @@ void btrfs_destroy_cachep(void) ...@@ -3321,7 +3323,9 @@ void btrfs_destroy_cachep(void)
struct kmem_cache *btrfs_cache_create(const char *name, size_t size, struct kmem_cache *btrfs_cache_create(const char *name, size_t size,
unsigned long extra_flags, unsigned long extra_flags,
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23) #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
void (*ctor)(void *)
#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
void (*ctor)(struct kmem_cache *, void *) void (*ctor)(struct kmem_cache *, void *)
#else #else
void (*ctor)(void *, struct kmem_cache *, void (*ctor)(void *, struct kmem_cache *,
...@@ -3561,8 +3565,12 @@ static int btrfs_set_page_dirty(struct page *page) ...@@ -3561,8 +3565,12 @@ static int btrfs_set_page_dirty(struct page *page)
return __set_page_dirty_nobuffers(page); return __set_page_dirty_nobuffers(page);
} }
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)
static int btrfs_permission(struct inode *inode, int mask)
#else
static int btrfs_permission(struct inode *inode, int mask, static int btrfs_permission(struct inode *inode, int mask,
struct nameidata *nd) struct nameidata *nd)
#endif
{ {
if (btrfs_test_flag(inode, READONLY) && (mask & MAY_WRITE)) if (btrfs_test_flag(inode, READONLY) && (mask & MAY_WRITE))
return -EACCES; return -EACCES;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment