Example #1
0
static int test_bio_clone(void)
{
	tbiop_dup = bio_clone(tbiop, GFP_NOIO);
	if (tbiop_dup == NULL) {
		prk_err("bio_clone failed");
		return -1;
	}

	test_bio_put(tbiop_dup);

	return 0;
}
Example #2
0
static int test_bio_clone(void)
{
	tbiop_dup = bio_clone(tbiop,GFP_NOIO);
	if( tbiop_dup == NULL ) {
		printk("tbio: bio_clone failed\n");
		return -1;
	}

	test_bio_put(tbiop_dup);

	return 0;
}
Example #3
0
File: dm.c Project: wxlong/Test
/*
 * Creates a bio that consists of range of complete bvecs.
 */
static struct bio *clone_bio(struct bio *bio, sector_t sector,
			     unsigned short idx, unsigned short bv_count,
			     unsigned int len)
{
	struct bio *clone;

	clone = bio_clone(bio, GFP_NOIO);
	clone->bi_sector = sector;
	clone->bi_idx = idx;
	clone->bi_vcnt = idx + bv_count;
	clone->bi_size = to_bytes(len);
	clone->bi_flags &= ~(1 << BIO_SEG_VALID);

	return clone;
}
Example #4
0
/**
 * Create a bio_entry by clone.
 *
 * @bioe bio entry (bioe->bio must be NULL)
 * @bio original bio.
 * @bdev block device to forward bio.
 */
bool init_bio_entry_by_clone(
	struct bio_entry *bioe, struct bio *bio,
	struct block_device *bdev, gfp_t gfp_mask)
{
	struct bio *clone;

	clone = bio_clone(bio, gfp_mask);
	if (!clone)
		return false;

	clone->bi_bdev = bdev;

	init_bio_entry(bioe, clone);
	return true;
}
Example #5
0
static int passthrough_make_request(struct request_queue *q, struct bio *bio)
{
	static int c = 0;
	if(bio->bi_rw & REQ_WRITE){
		struct bio *clone = bio_clone(bio,GFP_IOFS);
		bio->bi_bdev = passthrough->target_dev;
		clone->bi_bdev = passthrough->target_ssd;
	} else {
		if (c){
			bio->bi_bdev = passthrough->target_dev;
			c = 0;
		} else {
			bio->bi_bdev = passthrough->target_ssd;
			c = 1;
		}
	}
	return 1;
}
Example #6
0
static int ltpdev_ioctl ( struct inode *pinode, struct file *pfile, unsigned int cmd, unsigned long arg )
{

    struct bio *my_bio = NULL;
    struct bio *my_bio_copy = NULL;
	request_queue_t *q = NULL;
    struct block_device *bdev = NULL;
    unsigned long uaddr;

    unsigned int bytes_done = 100;

    int          error = 0;
    int          rc = 0;

    /*****************************************************************************/




    printk(KERN_ALERT "ltpdev_ioctl fs tests\n");

    switch (cmd) {
    
    case LTPAIODEV_CMD:
        printk(KERN_ALERT "Running AIO FS tests \n");
        printk(KERN_ALERT "AIO FS tests complete\n");
        break;

    case LTPBIODEV_CMD:

        printk(KERN_ALERT "Running BIO FS tests \n");

        my_bio = bio_alloc(GFP_KERNEL, 0);
        if (!my_bio) {
            printk(KERN_ALERT "Error getting kernel slab memory !!\n");
        }
        else {
            printk(KERN_ALERT "kernel slab memory alloc OK\n");
        }

        bio_endio(my_bio, bytes_done, error);

        printk(KERN_ALERT "Return from bio_endio = %d \n", error);

        my_bio_copy = bio_clone(my_bio,GFP_ATOMIC);

        if (!my_bio_copy) {
            printk(KERN_ALERT "Error getting kernel bio clone !!\n");
        }
        else {
            printk(KERN_ALERT "kernel bio clone OK\n");
        }

        my_bio_copy = bio_clone(my_bio,GFP_NOIO);

        if (!my_bio_copy) {
            printk(KERN_ALERT "Error getting kernel bio clone !!\n");
        }
        else {
            printk(KERN_ALERT "kernel bio clone OK\n");
        }

//        q = bdev_get_queue(my_bio->bi_bdev);

//        rc = bio_phys_segments(q, my_bio);

//        rc = bio_hw_segments(q, my_bio);

        bdev = lookup_bdev(LTP_FS_DEVICE_NAME);

        printk(KERN_ALERT "return from bdev size %d\n", bdev->bd_block_size);

        printk(KERN_ALERT "Return from phys_segments = %d \n", rc);

//        Don't use this API, causes system to hang and corrupts FS
//        bio_put(my_bio);

        (char *)uaddr = kmalloc(TEST_MEM_SIZE, GFP_KERNEL);

        my_bio_copy = bio_map_user(bdev, uaddr, TEST_MEM_SIZE, FALSE);

        printk(KERN_ALERT "Return from bio_map_user %p\n", my_bio_copy);

        do_buffer_c_tests();

        printk(KERN_ALERT "BIO FS tests complete\n");

    break;
    }


    return 0;
}
Example #7
0
static int function(void)
{
	int arg, res;
	eel_symbol_t *func = eel_current.lval->value.sym;

	eel_push_scope();

	/* Grab arguments */
	res = eel_parse_args(",", ';');

	/* Enter function */
	eel_push_context();
	if(eel_current.script == func->token)
		eel_current.bio = bio_clone(eel_current.bio);
	else
		eel_current.bio = bio_open(eel_scripttab[func->token].data,
				eel_scripttab[func->token].len);
	if(!eel_current.bio)
	{
		eel_error("INTERNAL ERROR: Failed to set up script"
				" reading at start of function!");
		eel_pop_context();
		eel_pop_scope();
		return -1;
	}
	res = bio_seek(eel_current.bio, func->data.value.a, SEEK_SET);

	/*
	 * Find out where to stuff the arguments.
	 */
	for(arg = 0; (arg < eel_arg_count) && (res >= 0); )
		switch(eel_lex(0))
		{
		  case ',':
			/* Already verified, so we just skip them. */
			break;
		  case TK_NEWSYM:
		  {
			eel_symbol_t *sym;
			sym = eel_set_data(eel_current.lval->value.s,
					eel_args + arg);
			if(sym)
			{
				sym->type = EST_VARIABLE;
				++arg;
			}
			else
			{
				eel_error("INTERNAL ERROR: Failed to "
						"create argument variable!");
				res = -1;
			}
			break;
		  }
		  case TK_SYMREF:
			eel_error("Function argument clashes with "
					"previously defined symbol!");
			res = -1;
			break;
		  default:
			eel_error("Syntax error in argument list!");
			res = -1;
			break;
		}
	
	/* Find start of body ("the code") */
	if(res >= 0)
	{
		if(eel_lex(0) != ')')
		{
			eel_error("Expected ')'!");
			res = -1;
		}
		else if(eel_lex(0) != '{')
		{
			eel_error("Expected '{'!");
			res = -1;
		}
	}

	if(res >= 0)
	{
		/*
		 * Execute function
		 *
		 * Note that this is a simple, inefficient
		 * RECURSIVE implementation!
		 *
		 * Alternatively, we could set up a "trigger"
		 * to run "the rest of this function" when
		 * the function ends - and then just return.
		 */
		res = eel_call(eel_current.script, bio_tell(eel_current.bio));
	}

	/* Leave function */
	bio_close(eel_current.bio);
	eel_pop_context();
	eel_pop_scope();

	if(res >= 0)
		return 1;
	else
		return res;
}