block: Introduce a new API bdrv_co_no_copy_on_readv()
In some cases, we need to disable copy-on-read, and just read the data. Signed-off-by: Wen Congyang <wency@cn.fujitsu.com> Message-id: 1441682913-14320-2-git-send-email-wency@cn.fujitsu.com Signed-off-by: Jeff Cody <jcody@redhat.com>
This commit is contained in:
		
							parent
							
								
									4da65c8092
								
							
						
					
					
						commit
						9568b511c9
					
				
							
								
								
									
										12
									
								
								block/io.c
								
								
								
								
							
							
						
						
									
										12
									
								
								block/io.c
								
								
								
								
							| 
						 | 
				
			
			@ -932,7 +932,8 @@ static int coroutine_fn bdrv_co_do_preadv(BlockDriverState *bs,
 | 
			
		|||
        return ret;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (bs->copy_on_read) {
 | 
			
		||||
    /* Don't do copy-on-read if we read data before write operation */
 | 
			
		||||
    if (bs->copy_on_read && !(flags & BDRV_REQ_NO_COPY_ON_READ)) {
 | 
			
		||||
        flags |= BDRV_REQ_COPY_ON_READ;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1001,6 +1002,15 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num,
 | 
			
		|||
    return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov, 0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int coroutine_fn bdrv_co_no_copy_on_readv(BlockDriverState *bs,
 | 
			
		||||
    int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
 | 
			
		||||
{
 | 
			
		||||
    trace_bdrv_co_no_copy_on_readv(bs, sector_num, nb_sectors);
 | 
			
		||||
 | 
			
		||||
    return bdrv_co_do_readv(bs, sector_num, nb_sectors, qiov,
 | 
			
		||||
                            BDRV_REQ_NO_COPY_ON_READ);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs,
 | 
			
		||||
    int64_t sector_num, int nb_sectors, QEMUIOVector *qiov)
 | 
			
		||||
{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -60,6 +60,7 @@ typedef enum {
 | 
			
		|||
     * opened with BDRV_O_UNMAP.
 | 
			
		||||
     */
 | 
			
		||||
    BDRV_REQ_MAY_UNMAP          = 0x4,
 | 
			
		||||
    BDRV_REQ_NO_COPY_ON_READ    = 0x8,
 | 
			
		||||
} BdrvRequestFlags;
 | 
			
		||||
 | 
			
		||||
typedef struct BlockSizes {
 | 
			
		||||
| 
						 | 
				
			
			@ -252,6 +253,8 @@ int coroutine_fn bdrv_co_readv(BlockDriverState *bs, int64_t sector_num,
 | 
			
		|||
    int nb_sectors, QEMUIOVector *qiov);
 | 
			
		||||
int coroutine_fn bdrv_co_copy_on_readv(BlockDriverState *bs,
 | 
			
		||||
    int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
 | 
			
		||||
int coroutine_fn bdrv_co_no_copy_on_readv(BlockDriverState *bs,
 | 
			
		||||
    int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
 | 
			
		||||
int coroutine_fn bdrv_co_writev(BlockDriverState *bs, int64_t sector_num,
 | 
			
		||||
    int nb_sectors, QEMUIOVector *qiov);
 | 
			
		||||
/*
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,6 +69,7 @@ bdrv_aio_write_zeroes(void *bs, int64_t sector_num, int nb_sectors, int flags, v
 | 
			
		|||
bdrv_lock_medium(void *bs, bool locked) "bs %p locked %d"
 | 
			
		||||
bdrv_co_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d"
 | 
			
		||||
bdrv_co_copy_on_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d"
 | 
			
		||||
bdrv_co_no_copy_on_readv(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d"
 | 
			
		||||
bdrv_co_writev(void *bs, int64_t sector_num, int nb_sector) "bs %p sector_num %"PRId64" nb_sectors %d"
 | 
			
		||||
bdrv_co_write_zeroes(void *bs, int64_t sector_num, int nb_sector, int flags) "bs %p sector_num %"PRId64" nb_sectors %d flags %#x"
 | 
			
		||||
bdrv_co_io_em(void *bs, int64_t sector_num, int nb_sectors, int is_write, void *acb) "bs %p sector_num %"PRId64" nb_sectors %d is_write %d acb %p"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue