}
int osd_bio_integrity_handle(struct osd_device *osd, struct bio *bio,
- struct osd_iobuf *iobuf,
- int start_page_idx, bool fault_inject,
- bool integrity_enabled)
+ struct osd_iobuf *iobuf)
{
- struct super_block *sb = osd_sb(osd);
integrity_gen_fn *generate_fn = NULL;
integrity_vrfy_fn *verify_fn = NULL;
int rc;
ENTRY;
- if (!integrity_enabled)
+ if (!iobuf->dr_integrity)
RETURN(0);
rc = osd_get_integrity_profile(osd, &generate_fn, &verify_fn);
/* Verify and inject fault only when writing */
if (iobuf->dr_rw == 1) {
if (unlikely(CFS_FAIL_CHECK(OBD_FAIL_OST_INTEGRITY_CMP))) {
+ struct super_block *sb = osd_sb(osd);
+ struct osd_bio_private *b_priv = bio->bi_private;
+ int st_page_index = b_priv->obp_start_page_idx;
+
rc = osd_bio_integrity_compare(bio, sb->s_bdev, iobuf,
- start_page_idx);
+ st_page_index);
if (rc)
RETURN(rc);
}
- if (unlikely(fault_inject))
+ if (unlikely(CFS_FAIL_CHECK(OBD_FAIL_OST_INTEGRITY_FAULT)))
bio_integrity_fault_inject(bio);
}
RETURN(0);
int dr_npages;
int dr_error;
int dr_frags;
- unsigned int dr_elapsed_valid:1; /* we really did count time */
- unsigned int dr_rw:1;
+ unsigned int dr_init_at:16, /* the line iobuf was initialized */
+ dr_elapsed_valid:1, /* we really did count time */
+ dr_rw:1,
+ dr_integrity:1;
struct lu_buf dr_pg_buf;
struct page **dr_pages;
struct niobuf_local **dr_lnbs;
ktime_t dr_start_time;
ktime_t dr_elapsed; /* how long io took */
struct osd_device *dr_dev;
- unsigned int dr_init_at; /* the line iobuf was initialized */
/* Already written blocks of the start page */
unsigned int dr_start_pg_wblks;
+ struct inode *dr_inode;
};
#define osd_dirty_inode(inode, flag) (inode)->i_sb->s_op->dirty_inode((inode), flag)
#if IS_ENABLED(CONFIG_BLK_DEV_INTEGRITY) && defined(HAVE_BIO_INTEGRITY_PREP_FN)
int osd_bio_integrity_handle(struct osd_device *osd, struct bio *bio,
- struct osd_iobuf *iobuf,
- int start_page_idx, bool fault_inject,
- bool integrity_enabled);
+ struct osd_iobuf *iobuf);
#else /* !CONFIG_BLK_DEV_INTEGRITY */
-#define osd_bio_integrity_handle(osd, bio, iobuf, start_page_idx, \
- fault_inject, integrity_enabled) 0
+#define osd_bio_integrity_handle(osd, bio, iobuf) (0)
#endif
#ifdef HAVE_BIO_INTEGRITY_PREP_FN
#endif
static int osd_bio_init(struct bio *bio, struct osd_iobuf *iobuf,
- bool integrity_enabled, int start_page_idx)
+ int start_page_idx)
{
struct osd_bio_private *bio_private = NULL;
ENTRY;
}
static int __osd_init_iobuf(struct osd_device *d, struct osd_iobuf *iobuf,
- int rw, int line, int pages)
+ struct inode *inode,
+ int rw, const short line, int pages)
{
int blocks, i;
/* must be counted before, so assert */
iobuf->dr_rw = rw;
iobuf->dr_init_at = line;
+ iobuf->dr_inode = inode;
/* Init dr_start_pg_wblks to 0 for osd_read/write_prep().
* For osd_write_commit() need to keep the value assigned in
return 0;
}
-#define osd_init_iobuf(dev, iobuf, rw, pages) \
- __osd_init_iobuf(dev, iobuf, rw, __LINE__, pages)
+
+#define osd_init_iobuf(dev, iobuf, inode, rw, pages) \
+({ \
+ int __r; \
+ BUILD_BUG_ON(__LINE__ >= (1 << 16)); \
+ __r = __osd_init_iobuf(dev, iobuf, inode, rw, __LINE__, pages); \
+ __r; \
+})
static void osd_iobuf_add_page(struct osd_iobuf *iobuf,
struct niobuf_local *lnb)
iobuf->dr_error = 0;
}
-
#ifdef HAVE_BIO_ENDIO_USES_ONE_ARG
static void dio_complete_routine(struct bio *bio)
{
}
}
-static int osd_submit_bio(struct osd_device *osd, struct block_device *bdev,
+static int osd_submit_bio(struct osd_device *osd,
struct osd_iobuf *iobuf,
- struct bio *bio, int bio_start_page_idx)
+ struct bio *bio)
{
struct request_queue *q;
unsigned int bi_size;
osd_bio_nr_segs(bio),
queue_max_segments(q));
- rc = osd_bio_integrity_handle(osd, bio,
- iobuf, bio_start_page_idx,
- CFS_FAIL_CHECK(OBD_FAIL_OST_INTEGRITY_FAULT),
- bdev_integrity_enabled(bdev, iobuf->dr_rw));
+ rc = osd_bio_integrity_handle(osd, bio, iobuf);
if (rc)
goto out;
page_offset) != 0)
continue; /* added this frag OK */
- rc = osd_submit_bio(osd, bdev, iobuf, bio,
- bio_start_page_idx);
+ rc = osd_submit_bio(osd, iobuf, bio);
if (rc)
goto out;
goto out;
}
bio_set_sector(bio, sector);
- rc = osd_bio_init(bio, iobuf, integrity_enabled,
- bio_start_page_idx);
+ rc = osd_bio_init(bio, iobuf, bio_start_page_idx);
if (rc)
goto out;
LASSERT(rc != 0);
}
}
- rc = osd_submit_bio(osd, bdev, iobuf, bio, bio_start_page_idx);
+ rc = osd_submit_bio(osd, iobuf, bio);
if (rc)
goto out;
out:
LASSERT(inode);
- rc = osd_init_iobuf(osd, iobuf, 0, npages);
+ rc = osd_init_iobuf(osd, iobuf, inode, 0, npages);
if (unlikely(rc != 0))
RETURN(rc);
LASSERT(inode);
- rc = osd_init_iobuf(osd, iobuf, 1, npages);
+ rc = osd_init_iobuf(osd, iobuf, inode, 1, npages);
if (unlikely(rc != 0))
RETURN(rc);
LASSERT(inode);
- rc = osd_init_iobuf(osd, iobuf, 0, npages);
+ rc = osd_init_iobuf(osd, iobuf, inode, 0, npages);
if (unlikely(rc != 0))
RETURN(rc);