all: port to newer kernels (up to 3.15)

This commit is contained in:
Thomas Schoebel-Theuer 2014-06-04 09:10:50 +02:00 committed by Thomas Schoebel-Theuer
parent d04562a39d
commit 1439d30ffb
6 changed files with 156 additions and 10 deletions

View File

@ -586,8 +586,11 @@ static int aio_event_thread(void *data)
struct aio_threadinfo *tinfo = data;
struct aio_output *output = tinfo->output;
struct aio_threadinfo *other = &output->tinfo[2];
struct io_event *events;
int err = -ENOMEM;
events = brick_mem_alloc(sizeof(struct io_event) * MARS_MAX_AIO_READ);
MARS_DBG("event thread has started.\n");
//set_user_nice(current, -20);
@ -606,7 +609,6 @@ static int aio_event_thread(void *data)
struct timespec timeout = {
.tv_sec = 1,
};
struct io_event events[MARS_MAX_AIO_READ];
oldfs = get_fs();
set_fs(get_ds());
@ -670,6 +672,7 @@ static int aio_event_thread(void *data)
tinfo->terminated = true;
wake_up_interruptible_all(&tinfo->terminate_event);
brick_mem_free(events);
return err;
}

View File

@ -20,7 +20,12 @@
#include "lib_mapfree.h"
#include "mars_bio.h"
// remove_this
#ifdef __bvec_iter_bvec
#define HAS_BVEC_ITER
#endif
// end_remove_this
static struct timing_stats timings[2] = {};
struct threshold bio_submit_threshold = {
@ -185,9 +190,19 @@ int make_bio(struct bio_brick *brick, void *data, int len, loff_t pos, struct bi
}
bio->bi_vcnt = i;
// remove_this
#ifdef HAS_BVEC_ITER
// end_remove_this
bio->bi_iter.bi_idx = 0;
bio->bi_iter.bi_size = result_len;
bio->bi_iter.bi_sector = sector;
// remove_this
#else
bio->bi_idx = 0;
bio->bi_size = result_len;
bio->bi_sector = sector;
#endif
// end_remove_this
bio->bi_bdev = bdev;
bio->bi_private = private;
bio->bi_end_io = bio_callback;

View File

@ -39,6 +39,15 @@
#include "mars.h"
#include "lib_limiter.h"
// remove_this
#ifdef bio_end_sector
#define HAS_VOID_RELEASE
#endif
#ifdef __bvec_iter_bvec
#define HAS_BVEC_ITER
#endif
// end_remove_this
///////////////////////// global tuning ////////////////////////
int if_throttle_start_size = 0; // in kb
@ -80,7 +89,15 @@ void _if_start_io_acct(struct if_input *input, struct bio_wrapper *biow)
(void)cpu;
part_round_stats(cpu, &input->disk->part0);
part_stat_inc(cpu, &input->disk->part0, ios[rw]);
// remove_this
#ifdef HAS_BVEC_ITER
// end_remove_this
part_stat_add(cpu, &input->disk->part0, sectors[rw], bio->bi_iter.bi_size >> 9);
// remove_this
#else
part_stat_add(cpu, &input->disk->part0, sectors[rw], bio->bi_size >> 9);
#endif
// end_remove_this
part_inc_in_flight(&input->disk->part0, rw);
part_stat_unlock();
biow->start_time = jiffies;
@ -150,10 +167,27 @@ void if_endio(struct generic_callback *cb)
error = CALLBACK_ERROR(mref_a->object);
if (unlikely(error < 0)) {
MARS_ERR("NYI: error=%d RETRY LOGIC %u\n", error, bio->bi_size);
// remove_this
#ifdef HAS_BVEC_ITER
// end_remove_this
int bi_size = bio->bi_iter.bi_size;
// remove_this
#else
int bi_size = bio->bi_size;
#endif
// end_remove_this
MARS_ERR("NYI: error=%d RETRY LOGIC %u\n", error, bi_size);
} else { // bio conventions are slightly different...
error = 0;
// remove_this
#ifdef HAS_BVEC_ITER
// end_remove_this
bio->bi_iter.bi_size = 0;
// remove_this
#else
bio->bi_size = 0;
#endif
// end_remove_this
}
MARS_IO("calling end_io() rw = %d error = %d\n", rw, error);
bio_endio(bio, error);
@ -320,11 +354,22 @@ if_make_request(struct request_queue *q, struct bio *bio)
struct bio_wrapper *biow;
struct mref_object *mref = NULL;
struct if_mref_aspect *mref_a;
// remove_this
#ifdef HAS_BVEC_ITER
// end_remove_this
struct bio_vec bvec;
struct bvec_iter i;
loff_t pos = ((loff_t)bio->bi_iter.bi_sector) << 9; // TODO: make dynamic
int total_len = bio->bi_iter.bi_size;
// remove_this
#else
struct bio_vec *bvec;
int i;
bool assigned = false;
loff_t pos = ((loff_t)bio->bi_sector) << 9; // TODO: make dynamic
int total_len = bio->bi_size;
#endif
// end_remove_this
bool assigned = false;
int error = -ENOSYS;
bind_to_channel(brick->say_channel, current);
@ -424,9 +469,19 @@ if_make_request(struct request_queue *q, struct bio *bio)
down(&input->kick_sem);
bio_for_each_segment(bvec, bio, i) {
// remove_this
#ifdef HAS_BVEC_ITER
// end_remove_this
struct page *page = bvec.bv_page;
int bv_len = bvec.bv_len;
int offset = bvec.bv_offset;
// remove_this
#else
struct page *page = bvec->bv_page;
int bv_len = bvec->bv_len;
int offset = bvec->bv_offset;
#endif
// end_remove_this
void *data;
#ifdef ARCH_HAS_KMAP
@ -577,9 +632,19 @@ if_make_request(struct request_queue *q, struct bio *bio)
* working in synchronous writethrough mode.
*/
mref->ref_skip_sync = true;
// remove_this
#ifdef HAS_BVEC_ITER
// end_remove_this
if (!do_skip_sync && i.bi_idx + 1 >= bio->bi_iter.bi_idx) {
mref->ref_skip_sync = false;
}
// remove_this
#else
if (!do_skip_sync && i + 1 >= bio->bi_vcnt) {
mref->ref_skip_sync = false;
}
#endif
// end_remove_this
atomic_inc(&input->plugged_count);
@ -964,7 +1029,17 @@ static int if_open(struct block_device *bdev, fmode_t mode)
return 0;
}
static int if_release(struct gendisk *gd, fmode_t mode)
static
// remove_this
#ifdef HAS_VOID_RELEASE
// end_remove_this
void
// remove_this
#else
int
#endif
// end_remove_this
if_release(struct gendisk *gd, fmode_t mode)
{
struct if_input *input = gd->private_data;
struct if_brick *brick = input->brick;
@ -981,7 +1056,11 @@ static int if_release(struct gendisk *gd, fmode_t mode)
MARS_DBG("status button=%d led_on=%d led_off=%d\n", brick->power.button, brick->power.led_on, brick->power.led_off);
mars_trigger();
}
// remove_this
#ifndef HAS_VOID_RELEASE
return 0;
#endif
// end_remove_this
}
static const struct block_device_operations if_blkdev_ops = {

View File

@ -1833,9 +1833,9 @@ int run_bone(struct mars_peerinfo *peer, struct mars_dent *remote_dent)
run_trigger = true;
}
if (remote_dent->new_stat.uid != local_stat.uid && update_ctime) {
MARS_DBG("lchown '%s' %d -> %d\n", remote_dent->d_path, local_stat.uid, remote_dent->new_stat.uid);
mars_lchown(remote_dent->d_path, remote_dent->new_stat.uid);
if (__kuid_val(remote_dent->new_stat.uid) != __kuid_val(local_stat.uid) && update_ctime) {
MARS_DBG("lchown '%s' %d -> %d\n", remote_dent->d_path, __kuid_val(local_stat.uid), __kuid_val(remote_dent->new_stat.uid));
mars_lchown(remote_dent->d_path, __kuid_val(remote_dent->new_stat.uid));
run_trigger = true;
}
}
@ -1850,12 +1850,12 @@ int run_bone(struct mars_peerinfo *peer, struct mars_dent *remote_dent)
MARS_DBG("create directory '%s' status = %d\n", remote_dent->d_path, status);
if (status >= 0) {
mars_chmod(remote_dent->d_path, remote_dent->new_stat.mode);
mars_lchown(remote_dent->d_path, remote_dent->new_stat.uid);
mars_lchown(remote_dent->d_path, __kuid_val(remote_dent->new_stat.uid));
}
}
} else if (S_ISLNK(remote_dent->new_stat.mode) && remote_dent->new_link) {
if (!stat_ok || update_mtime) {
status = mars_symlink(remote_dent->new_link, remote_dent->d_path, &remote_dent->new_stat.mtime, remote_dent->new_stat.uid);
status = mars_symlink(remote_dent->new_link, remote_dent->d_path, &remote_dent->new_stat.mtime, __kuid_val(remote_dent->new_stat.uid));
MARS_DBG("create symlink '%s' -> '%s' status = %d\n", remote_dent->d_path, remote_dent->new_link, status);
run_trigger = true;
}

View File

@ -7,6 +7,15 @@
#include "../mars.h"
// remove_this
#ifdef KUIDT_INIT
#define HAS_KUID
#else
#define __kuid_val(x) (x)
#define __kgid_val(x) (x)
#endif
// end_remove_this
#define MARS_ARGV_MAX 4
extern loff_t global_total_space;

View File

@ -26,6 +26,13 @@
#define SKIP_BIO false
// remove_this
#include <linux/wait.h>
#ifndef __WAIT_ATOMIC_T_KEY_INITIALIZER
#define HAS_VFS_READDIR
#endif
// end_remove_this
/////////////////////////////////////////////////////////////////////
// meta descriptions
@ -636,11 +643,31 @@ int dent_compare(struct mars_dent *a, struct mars_dent *b)
return strcmp(a->d_path, b->d_path);
}
// remove_this
#ifndef HAS_VFS_READDIR
// end_remove_this
struct mars_dir_context {
struct dir_context ctx;
struct mars_cookie *cookie;
};
// remove_this
#endif
// end_remove_this
static
int mars_filler(void *__buf, const char *name, int namlen, loff_t offset,
u64 ino, unsigned int d_type)
{
// remove_this
#ifdef HAS_VFS_READDIR
struct mars_cookie *cookie = __buf;
#else
// end_remove_this
struct mars_dir_context *buf = __buf;
struct mars_cookie *cookie = buf->cookie;
// remove_this
#endif
// end_remove_this
struct mars_global *global = cookie->global;
struct list_head *anchor = &global->dent_anchor;
struct list_head *start = anchor;
@ -761,9 +788,22 @@ static int _mars_readdir(struct mars_cookie *cookie)
}
for (;;) {
// remove_this
#ifdef HAS_VFS_READDIR
cookie->hit = false;
status = vfs_readdir(f, mars_filler, cookie);
MARS_IO("vfs_readdir() status = %d\n", status);
#else
// end_remove_this
struct mars_dir_context buf = {
.ctx.actor = mars_filler,
.cookie = cookie,
};
cookie->hit = false;
status = iterate_dir(f, &buf.ctx);
// remove_this
#endif
// end_remove_this
if (!cookie->hit)
break;
if (unlikely(status < 0)) {