Skip to content

Commit

Permalink
Remove Btrfs compat code for older kernels
Browse files Browse the repository at this point in the history
Btrfs had compatibility code for kernels back to 2.6.18.  These have
been removed, and will be maintained in a separate backport
git tree from now on.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Chris Mason committed Sep 25, 2008
1 parent 9b49c9b commit 2b1f55b
Show file tree
Hide file tree
Showing 12 changed files with 10 additions and 368 deletions.
6 changes: 0 additions & 6 deletions fs/btrfs/async-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,7 @@
#include <linux/kthread.h>
#include <linux/list.h>
#include <linux/spinlock.h>

#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
# include <linux/freezer.h>
#else
# include <linux/sched.h>
#endif

#include "async-thread.h"

/*
Expand Down
40 changes: 2 additions & 38 deletions fs/btrfs/compat.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#ifndef _COMPAT_H_
#define _COMPAT_H_

#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,26)
#define trylock_page(page) (!TestSetPageLocked(page))
#endif
#define btrfs_drop_nlink(inode) drop_nlink(inode)
#define btrfs_inc_nlink(inode) inc_nlink(inode)

#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27)
static inline struct dentry *d_obtain_alias(struct inode *inode)
Expand All @@ -22,39 +21,4 @@ static inline struct dentry *d_obtain_alias(struct inode *inode)
}
#endif

#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
static inline void btrfs_drop_nlink(struct inode *inode)
{
inode->i_nlink--;
}

static inline void btrfs_inc_nlink(struct inode *inode)
{
inode->i_nlink++;
}
#else
# define btrfs_drop_nlink(inode) drop_nlink(inode)
# define btrfs_inc_nlink(inode) inc_nlink(inode)
#endif

/*
* Even if AppArmor isn't enabled, it still has different prototypes.
* Add more distro/version pairs here to declare which has AppArmor applied.
*/
#if defined(CONFIG_SUSE_KERNEL)
# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
# define REMOVE_SUID_PATH 1
# endif
#endif

/*
* catch any other distros that have patched in apparmor. This isn't
* 100% reliable because it won't catch people that hand compile their
* own distro kernels without apparmor compiled in. But, it is better
* than nothing.
*/
#ifdef CONFIG_SECURITY_APPARMOR
# define REMOVE_SUID_PATH 1
#endif

#endif /* _COMPAT_H_ */
6 changes: 0 additions & 6 deletions fs/btrfs/crc32c.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,7 @@ static inline u32 __btrfs_crc32c(u32 crc, unsigned char const *address,
* We must workaround older implementations of crc32c_le()
* found on older kernel versions.
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
#define btrfs_crc32c(seed, data, length) \
__cpu_to_le32( __btrfs_crc32c( __le32_to_cpu(seed), \
(unsigned char const *)data, length) )
#else
#define btrfs_crc32c(seed, data, length) \
__btrfs_crc32c(seed, (unsigned char const *)data, length)
#endif
#endif

7 changes: 2 additions & 5 deletions fs/btrfs/ctree.h
Original file line number Diff line number Diff line change
Expand Up @@ -1472,12 +1472,9 @@ static inline u32 btrfs_level_size(struct btrfs_root *root, int level) {
((unsigned long)(btrfs_leaf_data(leaf) + \
btrfs_item_offset_nr(leaf, slot)))

static inline struct dentry *fdentry(struct file *file) {
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
return file->f_dentry;
#else
static inline struct dentry *fdentry(struct file *file)
{
return file->f_path.dentry;
#endif
}

/* extent-tree.c */
Expand Down
28 changes: 0 additions & 28 deletions fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@
#include <linux/buffer_head.h> // for block_sync_page
#include <linux/workqueue.h>
#include <linux/kthread.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,20)
# include <linux/freezer.h>
#else
# include <linux/sched.h>
#endif
#include "crc32c.h"
#include "ctree.h"
#include "disk-io.h"
Expand Down Expand Up @@ -373,21 +369,11 @@ int btree_readpage_end_io_hook(struct page *page, u64 start, u64 end,
return ret;
}

#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
static void end_workqueue_bio(struct bio *bio, int err)
#else
static int end_workqueue_bio(struct bio *bio,
unsigned int bytes_done, int err)
#endif
{
struct end_io_wq *end_io_wq = bio->bi_private;
struct btrfs_fs_info *fs_info;

#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
if (bio->bi_size)
return 1;
#endif

fs_info = end_io_wq->info;
end_io_wq->error = err;
end_io_wq->work.func = end_workqueue_fn;
Expand All @@ -397,10 +383,6 @@ static int end_workqueue_bio(struct bio *bio,
&end_io_wq->work);
else
btrfs_queue_worker(&fs_info->endio_workers, &end_io_wq->work);

#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
return 0;
#endif
}

int btrfs_bio_wq_end_io(struct btrfs_fs_info *info, struct bio *bio,
Expand Down Expand Up @@ -1161,9 +1143,7 @@ void btrfs_unplug_io_fn(struct backing_dev_info *bdi, struct page *page)

static int setup_bdi(struct btrfs_fs_info *info, struct backing_dev_info *bdi)
{
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
bdi_init(bdi);
#endif
bdi->ra_pages = default_backing_dev_info.ra_pages;
bdi->state = 0;
bdi->capabilities = default_backing_dev_info.capabilities;
Expand Down Expand Up @@ -1242,11 +1222,7 @@ static void end_workqueue_fn(struct btrfs_work *work)
bio->bi_private = end_io_wq->private;
bio->bi_end_io = end_io_wq->end_io;
kfree(end_io_wq);
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
bio_endio(bio, bio->bi_size, error);
#else
bio_endio(bio, error);
#endif
}

static int cleaner_kthread(void *arg)
Expand Down Expand Up @@ -1673,9 +1649,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,

kfree(extent_root);
kfree(tree_root);
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
bdi_destroy(&fs_info->bdi);
#endif
kfree(fs_info);
return ERR_PTR(err);
}
Expand Down Expand Up @@ -1936,9 +1910,7 @@ int close_ctree(struct btrfs_root *root)
btrfs_close_devices(fs_info->fs_devices);
btrfs_mapping_tree_free(&fs_info->mapping_tree);

#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
bdi_destroy(&fs_info->bdi);
#endif

kfree(fs_info->extent_root);
kfree(fs_info->tree_root);
Expand Down
6 changes: 0 additions & 6 deletions fs/btrfs/export.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
#include "export.h"
#include "compat.h"

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,28)
#define FILEID_BTRFS_WITHOUT_PARENT 0x4d
#define FILEID_BTRFS_WITH_PARENT 0x4e
#define FILEID_BTRFS_WITH_PARENT_ROOT 0x4f
#endif

#define BTRFS_FID_SIZE_NON_CONNECTABLE (offsetof(struct btrfs_fid, parent_objectid)/4)
#define BTRFS_FID_SIZE_CONNECTABLE (offsetof(struct btrfs_fid, parent_root_objectid)/4)
#define BTRFS_FID_SIZE_CONNECTABLE_ROOT (sizeof(struct btrfs_fid)/4)
Expand Down
66 changes: 3 additions & 63 deletions fs/btrfs/extent_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -1397,12 +1397,7 @@ static int check_page_writeback(struct extent_io_tree *tree,
* Scheduling is not allowed, so the extent state tree is expected
* to have one and only one object corresponding to this IO.
*/
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
static void end_bio_extent_writepage(struct bio *bio, int err)
#else
static int end_bio_extent_writepage(struct bio *bio,
unsigned int bytes_done, int err)
#endif
{
int uptodate = err == 0;
struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
Expand All @@ -1412,10 +1407,6 @@ static int end_bio_extent_writepage(struct bio *bio,
int whole_page;
int ret;

#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
if (bio->bi_size)
return 1;
#endif
do {
struct page *page = bvec->bv_page;
tree = &BTRFS_I(page->mapping->host)->io_tree;
Expand Down Expand Up @@ -1461,10 +1452,8 @@ static int end_bio_extent_writepage(struct bio *bio,
else
check_page_writeback(tree, page);
} while (bvec >= bio->bi_io_vec);

bio_put(bio);
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
return 0;
#endif
}

/*
Expand All @@ -1478,12 +1467,7 @@ static int end_bio_extent_writepage(struct bio *bio,
* Scheduling is not allowed, so the extent state tree is expected
* to have one and only one object corresponding to this IO.
*/
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
static void end_bio_extent_readpage(struct bio *bio, int err)
#else
static int end_bio_extent_readpage(struct bio *bio,
unsigned int bytes_done, int err)
#endif
{
int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
Expand All @@ -1493,11 +1477,6 @@ static int end_bio_extent_readpage(struct bio *bio,
int whole_page;
int ret;

#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
if (bio->bi_size)
return 1;
#endif

do {
struct page *page = bvec->bv_page;
tree = &BTRFS_I(page->mapping->host)->io_tree;
Expand Down Expand Up @@ -1556,34 +1535,21 @@ static int end_bio_extent_readpage(struct bio *bio,
} while (bvec >= bio->bi_io_vec);

bio_put(bio);
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
return 0;
#endif
}

/*
* IO done from prepare_write is pretty simple, we just unlock
* the structs in the extent tree when done, and set the uptodate bits
* as appropriate.
*/
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23)
static void end_bio_extent_preparewrite(struct bio *bio, int err)
#else
static int end_bio_extent_preparewrite(struct bio *bio,
unsigned int bytes_done, int err)
#endif
{
const int uptodate = test_bit(BIO_UPTODATE, &bio->bi_flags);
struct bio_vec *bvec = bio->bi_io_vec + bio->bi_vcnt - 1;
struct extent_io_tree *tree;
u64 start;
u64 end;

#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
if (bio->bi_size)
return 1;
#endif

do {
struct page *page = bvec->bv_page;
tree = &BTRFS_I(page->mapping->host)->io_tree;
Expand All @@ -1607,9 +1573,6 @@ static int end_bio_extent_preparewrite(struct bio *bio,
} while (bvec >= bio->bi_io_vec);

bio_put(bio);
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
return 0;
#endif
}

static struct bio *
Expand Down Expand Up @@ -2079,12 +2042,6 @@ static int __extent_writepage(struct page *page, struct writeback_control *wbc,
return 0;
}

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22)
/* Taken directly from 2.6.23 with a mod for a lockpage hook */
typedef int (*writepage_t)(struct page *page, struct writeback_control *wbc,
void *data);
#endif

/**
* write_cache_pages - walk the list of dirty pages of the given address space and write all of them.
* @mapping: address space structure to write
Expand Down Expand Up @@ -2201,10 +2158,9 @@ int extent_write_cache_pages(struct extent_io_tree *tree,
}
if (wbc->range_cyclic || (range_whole && wbc->nr_to_write > 0))
mapping->writeback_index = index;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,26)

if (wbc->range_cont)
wbc->range_start = index << PAGE_CACHE_SHIFT;
#endif
return ret;
}
EXPORT_SYMBOL(extent_write_cache_pages);
Expand Down Expand Up @@ -2560,18 +2516,10 @@ static inline struct page *extent_buffer_page(struct extent_buffer *eb,
* 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);
#endif
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);
#endif

return p;
}

Expand Down Expand Up @@ -2773,21 +2721,13 @@ int clear_extent_buffer_dirty(struct extent_io_tree *tree,
}
}
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);
#endif
if (!PageDirty(page)) {
radix_tree_tag_clear(&page->mapping->page_tree,
page_index(page),
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);
#endif
unlock_page(page);
}
return 0;
Expand Down
Loading

0 comments on commit 2b1f55b

Please sign in to comment.