From 00c74b245fb70188ae2829609b5c709b8629a191 Mon Sep 17 00:00:00 2001 From: Alexey Lyashkov Date: Tue, 20 Jun 2023 15:23:56 +0300 Subject: [PATCH] LU-16847 ldiskfs: refactor code. unused parameters should removed to reduce a stack usage. iobuf is common struct in io path now. Test-Parameters: trivial HPe-bug-id: LUS-11645 Signed-off-by: Alexey Lyashkov Change-Id: Ie4d68ff7548f049de8706ac5b0e3f62eb15a211a Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51390 Reviewed-by: Andrew Perepechko Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- lustre/osd-ldiskfs/osd_integrity.c | 15 +++++++------- lustre/osd-ldiskfs/osd_internal.h | 15 +++++++------- lustre/osd-ldiskfs/osd_io.c | 40 ++++++++++++++++++++------------------ 3 files changed, 36 insertions(+), 34 deletions(-) diff --git a/lustre/osd-ldiskfs/osd_integrity.c b/lustre/osd-ldiskfs/osd_integrity.c index 8bc61bb..9e48d65 100644 --- a/lustre/osd-ldiskfs/osd_integrity.c +++ b/lustre/osd-ldiskfs/osd_integrity.c @@ -353,18 +353,15 @@ static int osd_bio_integrity_compare(struct bio *bio, struct block_device *bdev, } 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); @@ -383,13 +380,17 @@ int osd_bio_integrity_handle(struct osd_device *osd, struct bio *bio, /* 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); diff --git a/lustre/osd-ldiskfs/osd_internal.h b/lustre/osd-ldiskfs/osd_internal.h index 3b3a124..349dc28 100644 --- a/lustre/osd-ldiskfs/osd_internal.h +++ b/lustre/osd-ldiskfs/osd_internal.h @@ -596,8 +596,10 @@ struct osd_iobuf { 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; @@ -607,9 +609,9 @@ struct osd_iobuf { 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) @@ -1638,12 +1640,9 @@ extern struct kmem_cache *biop_cachep; #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 diff --git a/lustre/osd-ldiskfs/osd_io.c b/lustre/osd-ldiskfs/osd_io.c index 43c60b1..e238be4 100644 --- a/lustre/osd-ldiskfs/osd_io.c +++ b/lustre/osd-ldiskfs/osd_io.c @@ -72,7 +72,7 @@ static void dio_complete_routine(struct bio *bio, int error); #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; @@ -111,7 +111,8 @@ static inline bool osd_use_page_cache(struct osd_device *d) } 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; @@ -131,6 +132,7 @@ static int __osd_init_iobuf(struct osd_device *d, struct osd_iobuf *iobuf, /* 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 @@ -180,8 +182,14 @@ static int __osd_init_iobuf(struct osd_device *d, struct osd_iobuf *iobuf, 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) @@ -211,7 +219,6 @@ void osd_fini_iobuf(struct osd_device *d, struct osd_iobuf *iobuf) iobuf->dr_error = 0; } - #ifdef HAVE_BIO_ENDIO_USES_ONE_ARG static void dio_complete_routine(struct bio *bio) { @@ -308,9 +315,9 @@ static void record_start_io(struct osd_iobuf *iobuf, int size) } } -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; @@ -330,10 +337,7 @@ static int osd_submit_bio(struct osd_device *osd, struct block_device *bdev, 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; @@ -469,8 +473,7 @@ static int osd_do_bio(struct osd_device *osd, struct inode *inode, 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; @@ -491,8 +494,7 @@ static int osd_do_bio(struct osd_device *osd, struct inode *inode, 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; @@ -501,7 +503,7 @@ static int osd_do_bio(struct osd_device *osd, struct inode *inode, 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: @@ -1139,7 +1141,7 @@ static int osd_write_prep(const struct lu_env *env, struct dt_object *dt, 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); @@ -1440,7 +1442,7 @@ static int osd_write_commit(const struct lu_env *env, struct dt_object *dt, 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); @@ -1534,7 +1536,7 @@ static int osd_read_prep(const struct lu_env *env, struct dt_object *dt, 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); -- 1.8.3.1