Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
0003  *
0004  * This file is released under the GPL.
0005  */
0006 
0007 #ifndef DM_BIO_RECORD_H
0008 #define DM_BIO_RECORD_H
0009 
0010 #include <linux/bio.h>
0011 #include <linux/blk-integrity.h>
0012 
0013 /*
0014  * There are lots of mutable fields in the bio struct that get
0015  * changed by the lower levels of the block layer.  Some targets,
0016  * such as multipath, may wish to resubmit a bio on error.  The
0017  * functions in this file help the target record and restore the
0018  * original bio state.
0019  */
0020 
0021 struct dm_bio_details {
0022     struct block_device *bi_bdev;
0023     int __bi_remaining;
0024     unsigned long bi_flags;
0025     struct bvec_iter bi_iter;
0026     bio_end_io_t *bi_end_io;
0027 #if defined(CONFIG_BLK_DEV_INTEGRITY)
0028     struct bio_integrity_payload *bi_integrity;
0029 #endif
0030 };
0031 
0032 static inline void dm_bio_record(struct dm_bio_details *bd, struct bio *bio)
0033 {
0034     bd->bi_bdev = bio->bi_bdev;
0035     bd->bi_flags = bio->bi_flags;
0036     bd->bi_iter = bio->bi_iter;
0037     bd->__bi_remaining = atomic_read(&bio->__bi_remaining);
0038     bd->bi_end_io = bio->bi_end_io;
0039 #if defined(CONFIG_BLK_DEV_INTEGRITY)
0040     bd->bi_integrity = bio_integrity(bio);
0041 #endif
0042 }
0043 
0044 static inline void dm_bio_restore(struct dm_bio_details *bd, struct bio *bio)
0045 {
0046     bio->bi_bdev = bd->bi_bdev;
0047     bio->bi_flags = bd->bi_flags;
0048     bio->bi_iter = bd->bi_iter;
0049     atomic_set(&bio->__bi_remaining, bd->__bi_remaining);
0050     bio->bi_end_io = bd->bi_end_io;
0051 #if defined(CONFIG_BLK_DEV_INTEGRITY)
0052     bio->bi_integrity = bd->bi_integrity;
0053 #endif
0054 }
0055 
0056 #endif