[Devel] [PATCH rh7] ploop: drop obsolete code related to old kernels
Konstantin Khorenko
khorenko at virtuozzo.com
Thu Feb 9 04:29:15 PST 2017
https://jira.sw.ru/browse/PSBM-51358
To be merged into initial ploop patch:
25e20b3 ("ploop: add ploop to the tree")
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
drivers/block/ploop/dev.c | 43 -----------------------
drivers/block/ploop/io_direct.c | 8 -----
drivers/block/ploop/io_direct_map.c | 3 --
drivers/block/ploop/map.c | 3 --
drivers/block/ploop/sysfs.c | 46 ------------------------
include/linux/ploop/compat.h | 41 ++--------------------
include/linux/ploop/internal.h | 70 -------------------------------------
include/linux/ploop/ploop.h | 1 -
8 files changed, 3 insertions(+), 212 deletions(-)
delete mode 100644 include/linux/ploop/internal.h
diff --git a/drivers/block/ploop/dev.c b/drivers/block/ploop/dev.c
index eaf48c2..09f5a41 100644
--- a/drivers/block/ploop/dev.c
+++ b/drivers/block/ploop/dev.c
@@ -199,23 +199,11 @@ ploop_alloc_request(struct ploop_device * plo)
static void ploop_grab_iocontext(struct bio *bio)
{
struct io_context **ioc_pp = (struct io_context **)(&bio->bi_bdev);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
- /* This is WRONG. Seems, in 2.6.18 we can do nothing.
- * But leave this piece of art for now.
- */
- if (current->io_context) {
- *ioc_pp = current->io_context;
- if (!atomic_inc_not_zero((*ioc_pp)->refcount))
- *ioc_pp = NULL;
- set_bit(BIO_BDEV_REUSED, &bio->bi_flags);
- }
-#else
if (current->io_context) {
ioc_task_link(current->io_context);
*ioc_pp = current->io_context;
set_bit(BIO_BDEV_REUSED, &bio->bi_flags);
}
-#endif
}
/* always called with plo->lock held */
@@ -1158,21 +1146,6 @@ static int ploop_congested(void *data, int bits)
if (top_delta->io.ops->congested)
ret |= top_delta->io.ops->congested(&top_delta->io, bits);
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24) && LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
- if (plo->tune.congestion_detection &&
- plo->entry_qlen + plo->active_reqs - plo->fastpath_reqs
- > (3*plo->tune.max_requests)/4) {
- if ((bits & (1<<BDI_write_congested)) && !(ret & (1<<BDI_write_congested))) {
- ret |= (1<<BDI_write_congested);
- set_bit(PLOOP_S_WRITE_CONG, &plo->state);
- }
- if ((bits & (1<<BDI_read_congested)) && !(ret & (1<<BDI_read_congested))) {
- ret |= (1<<BDI_read_congested);
- set_bit(PLOOP_S_READ_CONG, &plo->state);
- }
- }
-#endif
-
return ret;
}
@@ -1455,7 +1428,6 @@ static void ploop_complete_request(struct ploop_request * preq)
}
plo->bio_total -= nr_completed;
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24)
if (plo->tune.congestion_detection &&
plo->entry_qlen + plo->active_reqs - plo->fastpath_reqs
<= plo->tune.max_requests/2) {
@@ -1464,7 +1436,6 @@ static void ploop_complete_request(struct ploop_request * preq)
if (test_and_clear_bit(PLOOP_S_READ_CONG, &plo->state))
clear_bdi_congested(&plo->queue->backing_dev_info, READ);
}
-#endif
spin_unlock_irq(&plo->lock);
@@ -3870,17 +3841,6 @@ static int ploop_truncate(struct ploop_device * plo, unsigned long arg)
return err;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
-static int ploop_issue_flush_fn(request_queue_t *q, struct gendisk *disk,
- sector_t *error_sector)
-{
- /* Should queue barrier request on ploop and wait for completion.
- * The interface is broken and obsolete.
- */
- return -EOPNOTSUPP;
-}
-#endif
-
#define FUSE_SUPER_MAGIC 0x65735546
#define IS_PSTORAGE(sb) (sb->s_magic == FUSE_SUPER_MAGIC && \
!strcmp(sb->s_subtype, "pstorage"))
@@ -3996,9 +3956,6 @@ static int ploop_start(struct ploop_device * plo, struct block_device *bdev)
blk_queue_merge_bvec(plo->queue, ploop_merge_bvec);
blk_queue_flush(plo->queue, REQ_FLUSH);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
- blk_queue_issue_flush_fn(plo->queue, ploop_issue_flush_fn);
-#endif
if (top_delta->io.ops->queue_settings)
top_delta->io.ops->queue_settings(&top_delta->io, plo->queue);
diff --git a/drivers/block/ploop/io_direct.c b/drivers/block/ploop/io_direct.c
index 6663964..fb594c8 100644
--- a/drivers/block/ploop/io_direct.c
+++ b/drivers/block/ploop/io_direct.c
@@ -365,7 +365,6 @@ cached_submit(struct ploop_io *io, iblock_t iblk, struct ploop_request * preq,
file_start_write(io->files.file);
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24)
if (use_prealloc && end_pos > used_pos && may_fallocate) {
if (unlikely(io->prealloced_size < clu_siz)) {
loff_t prealloc = end_pos;
@@ -393,7 +392,6 @@ try_again:
io->prealloced_size -= clu_siz;
}
-#endif
if (may_fallocate) {
sector_t sec = (sector_t)iblk << preq->plo->cluster_log;
@@ -1317,7 +1315,6 @@ static int dio_alloc_sync(struct ploop_io * io, loff_t pos, loff_t len)
struct page *pad = NULL;
int pad_len = pos & (PAGE_CACHE_SIZE - 1);
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,24)
if (pos + len > i_size_read(io->files.inode) &&
io->files.file->f_op->fallocate) {
err = io->files.file->f_op->fallocate(io->files.file, 0,
@@ -1325,7 +1322,6 @@ static int dio_alloc_sync(struct ploop_io * io, loff_t pos, loff_t len)
if (err)
return err;
}
-#endif
if (pad_len) {
BUILD_BUG_ON(PAGE_SIZE != PAGE_CACHE_SIZE);
@@ -1807,10 +1803,6 @@ static int dio_congested(struct ploop_io * io, int bits)
static void dio_queue_settings(struct ploop_io * io, struct request_queue * q)
{
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
- q->max_sectors = 0;
- q->max_hw_sectors = 0;
-#endif
blk_queue_stack_limits(q, bdev_get_queue(io->files.bdev));
}
diff --git a/drivers/block/ploop/io_direct_map.c b/drivers/block/ploop/io_direct_map.c
index e260ee6..db1da7d 100644
--- a/drivers/block/ploop/io_direct_map.c
+++ b/drivers/block/ploop/io_direct_map.c
@@ -232,9 +232,6 @@ int __init ploop_extent_map_init(void)
extent_map_cache = kmem_cache_create("ploop_itree",
sizeof(struct extent_map), 0,
SLAB_MEM_SPREAD, NULL
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
- , NULL
-#endif
);
if (!extent_map_cache)
return -ENOMEM;
diff --git a/drivers/block/ploop/map.c b/drivers/block/ploop/map.c
index f21b9ab..e579133 100644
--- a/drivers/block/ploop/map.c
+++ b/drivers/block/ploop/map.c
@@ -1326,9 +1326,6 @@ int __init ploop_map_init(void)
ploop_map_cache = kmem_cache_create("ploop_map",
sizeof(struct map_node), 0,
SLAB_MEM_SPREAD, NULL
-#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
- , NULL
-#endif
);
if (!ploop_map_cache)
return -ENOMEM;
diff --git a/drivers/block/ploop/sysfs.c b/drivers/block/ploop/sysfs.c
index 55f5d58..0395ccf 100644
--- a/drivers/block/ploop/sysfs.c
+++ b/drivers/block/ploop/sysfs.c
@@ -88,13 +88,7 @@ static ssize_t delta_image_show(struct ploop_delta *delta, char *page)
mutex_lock(&delta->plo->sysfs_mutex);
if (delta->io.files.file) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
- res = d_path(delta->io.files.file->f_dentry,
- delta->io.files.file->f_vfsmnt,
- page, PAGE_SIZE-1);
-#else
res = d_path(&delta->io.files.file->f_path, page, PAGE_SIZE-1);
-#endif
len = PTR_ERR(res);
if (!IS_ERR(res)) {
len = strlen(res);
@@ -223,11 +217,7 @@ static const struct attribute_group stats_group = {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
#define to_disk(obj) dev_to_disk(container_of(obj,struct device,kobj))
-#else
-#define to_disk(obj) container_of(obj,struct gendisk,kobj)
-#endif
static ssize_t pstat_show(struct kobject *kobj, struct attribute *attr,
char *page)
@@ -631,7 +621,6 @@ static struct kobj_type pstat_ktype = {
.sysfs_ops = &pstat_sysfs_ops,
};
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
struct kobject *kobject_add_attr(struct gendisk *gd, const char *name,
struct kobj_type * type)
{
@@ -652,31 +641,6 @@ struct kobject *kobject_add_attr(struct gendisk *gd, const char *name,
}
return k;
}
-#else
-struct kobject *kobject_add_attr(struct gendisk *gd, const char *name,
- struct kobj_type * type)
-{
- struct kobject *k;
- int err;
- struct kobject * parent = &gd->kobj;
-
- k = kzalloc(sizeof(*k), GFP_KERNEL);
- if (!k)
- return NULL;
-
- snprintf(k->name, KOBJ_NAME_LEN, "%s", name);
- k->ktype = type;
- kobject_init(k);
-
- k->parent = parent;
- err = kobject_add(k);
- if (err) {
- kobject_put(k);
- return NULL;
- }
- return k;
-}
-#endif
void ploop_sysfs_init(struct ploop_device * plo)
{
@@ -696,14 +660,8 @@ void ploop_sysfs_init(struct ploop_device * plo)
printk("ploop: were not able to create ptune dir\n");
}
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
if (kobject_add(&plo->kobj, kobject_get(&disk_to_dev(plo->disk)->kobj), "%s", "pdelta"))
printk("ploop: were not able to create pdelta dir\n");
-#else
- plo->kobj.parent = kobject_get(&plo->disk->kobj);
- if (kobject_add(&plo->kobj))
- printk("ploop: were not able to create pdelta dir\n");
-#endif
}
void ploop_sysfs_uninit(struct ploop_device * plo)
@@ -728,9 +686,5 @@ void ploop_sysfs_uninit(struct ploop_device * plo)
}
kobject_del(&plo->kobj);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
kobject_put(&disk_to_dev(plo->disk)->kobj);
-#else
- kobject_put(&plo->disk->kobj);
-#endif
}
diff --git a/include/linux/ploop/compat.h b/include/linux/ploop/compat.h
index 7e38663..5b74e9c 100644
--- a/include/linux/ploop/compat.h
+++ b/include/linux/ploop/compat.h
@@ -1,6 +1,9 @@
/*
* include/linux/ploop/compat.h
*
+ * This file contained macros to provide compatibility layer for 2.6.18,
+ * where bio layer was different.
+ *
* Copyright (c) 2010-2015 Parallels IP Holdings GmbH
*
*/
@@ -10,42 +13,6 @@
#include <linux/version.h>
-/* Macros to provide compatibility layer for 2.6.18, where bio layer
- * was different
- */
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)
-#define DEFINE_BIO_CB(func) \
-static int func(struct bio *bio, unsigned int bytes_done, int err) { \
- if (bio->bi_size) return 1;
-
-#define END_BIO_CB(func) return 0; }
-
-
-#define BIO_ENDIO(_bio, _err) bio_endio((_bio), (_bio)->bi_size, (_err))
-
-int pagecache_write_begin(struct file *file, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned flags,
- struct page **pagep, void **fsdata);
-int pagecache_write_end(struct file *file, struct address_space *mapping,
- loff_t pos, unsigned len, unsigned copied,
- struct page *page, void *fsdata);
-
-
-#define F_DENTRY(file) (file)->f_dentry
-#define F_MNT(file) (file)->f_vfsmnt
-
-#define KOBJECT_INIT(_kobj, _ktype) do { \
- (_kobj)->ktype = (_ktype); kobject_init(_kobj); } while (0)
-
-#define KOBJECT_ADD(_kobj, _parent, fmt, arg...) ({ \
- struct kobject * _tmp = (_kobj); \
- _tmp->parent = _parent; \
- snprintf(_tmp->name, KOBJ_NAME_LEN, fmt, arg); \
- kobject_add(_tmp); })
-
-#else
-
#define DEFINE_BIO_CB(func) \
static void func(struct bio *bio, int err) {
@@ -64,5 +31,3 @@ static void func(struct bio *bio, int err) {
#define KOBJECT_ADD(kobj, parent, fmt, arg...) kobject_add(kobj, parent, fmt, arg)
#endif
-
-#endif
diff --git a/include/linux/ploop/internal.h b/include/linux/ploop/internal.h
deleted file mode 100644
index 574a31c..0000000
--- a/include/linux/ploop/internal.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * include/linux/ploop/internal.h
- *
- * Copyright (c) 2010-2015 Parallels IP Holdings GmbH
- *
- */
-
-#ifndef _BIO_HELP_H_
-#define _BIO_HELP_H_ 1
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,31)
-
-struct bio_list
-{
- struct bio *head;
- struct bio *tail;
-};
-
-static inline int bio_list_empty(const struct bio_list *bl)
-{
- return bl->head == NULL;
-}
-
-static inline void bio_list_init(struct bio_list *bl)
-{
- bl->head = bl->tail = NULL;
-}
-
-#define bio_list_for_each(bio, bl) \
- for (bio = (bl)->head; bio; bio = bio->bi_next)
-
-static inline void bio_list_add(struct bio_list *bl, struct bio *bio)
-{
- bio->bi_next = NULL;
-
- if (bl->tail)
- bl->tail->bi_next = bio;
- else
- bl->head = bio;
-
- bl->tail = bio;
-}
-
-static inline struct bio *bio_list_pop(struct bio_list *bl)
-{
- struct bio *bio = bl->head;
-
- if (bio) {
- bl->head = bl->head->bi_next;
- if (!bl->head)
- bl->tail = NULL;
-
- bio->bi_next = NULL;
- }
-
- return bio;
-}
-
-static inline struct bio *bio_list_get(struct bio_list *bl)
-{
- struct bio *bio = bl->head;
-
- bl->head = bl->tail = NULL;
-
- return bio;
-}
-
-#endif
-
-#endif
diff --git a/include/linux/ploop/ploop.h b/include/linux/ploop/ploop.h
index 280bbab..c7261c4 100644
--- a/include/linux/ploop/ploop.h
+++ b/include/linux/ploop/ploop.h
@@ -17,7 +17,6 @@
#include "ploop_if.h"
#include "compat.h"
-#include "internal.h"
#define PLOOP_NAME_SIZE 64
#define PLOOP_MAX_FORMATS 32
--
1.8.3.1
More information about the Devel
mailing list