Whamcloud - gitweb
LU-16847 ldiskfs: reduce a memory usage by ost IO threads 92/51392/6
authorAlexey Lyashkov <alexey.lyashkov@hpe.com>
Wed, 21 Jun 2023 09:10:27 +0000 (12:10 +0300)
committerOleg Drokin <green@whamcloud.com>
Wed, 13 Sep 2023 04:01:00 +0000 (04:01 +0000)
page array is useless once lnb array added it might addressed
via lnb->lnb_page, let's remove it and reduce memory consumption.

Signed-off-by: Alexey Lyashkov <alexey.lyashkov@hpe.com>
Change-Id: Ieb0c186e27f56c770fd2ebfbddce9ccf19791611
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51392
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/osd-ldiskfs/osd_handler.c
lustre/osd-ldiskfs/osd_integrity.c
lustre/osd-ldiskfs/osd_internal.h
lustre/osd-ldiskfs/osd_io.c

index bc865f3..cd2e93f 100644 (file)
@@ -8076,7 +8076,6 @@ static void osd_key_fini(const struct lu_context *ctx,
        if (info->oti_hlock != NULL)
                ldiskfs_htree_lock_free(info->oti_hlock);
        OBD_FREE(info->oti_it_ea_buf, OSD_IT_EA_BUFSIZE);
-       lu_buf_free(&info->oti_iobuf.dr_pg_buf);
        lu_buf_free(&info->oti_iobuf.dr_bl_buf);
        lu_buf_free(&info->oti_iobuf.dr_lnb_buf);
        lu_buf_free(&info->oti_big_buf);
index 9e48d65..9f0c6ee 100644 (file)
@@ -76,11 +76,11 @@ static struct niobuf_local *find_lnb(struct blk_integrity_iter *iter)
 
        /*
         * blocks are contiguous in bio but pages added to bio
-        * could have a gap comparing to iobuf->dr_pages.
+        * could have a gap comparing to pages.
         * e.g. a page mapped to a hole in the middle.
         */
        for (i = index; i < iobuf->dr_npages; i++) {
-               if (iobuf->dr_pages[i] == bv->bv_page)
+               if (iobuf->dr_lnbs[i]->lnb_page == bv->bv_page)
                        return iobuf->dr_lnbs[i];
        }
 
@@ -326,7 +326,7 @@ static int osd_bio_integrity_compare(struct bio *bio, struct block_device *bdev,
        total = 0;
        bio_for_each_segment_all(bv, bio, iter_all) {
                for (i = index; i < iobuf->dr_npages; i++) {
-                       if (iobuf->dr_pages[i] == bv->bv_page) {
+                       if (iobuf->dr_lnbs[i]->lnb_page == bv->bv_page) {
                                lnb = iobuf->dr_lnbs[i];
                                break;
                        }
index dc80457..7f50f3d 100644 (file)
@@ -602,8 +602,6 @@ struct osd_iobuf {
                           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;
        struct lu_buf      dr_bl_buf;
        struct lu_buf      dr_lnb_buf;
index d38affa..bcfd1fe 100644 (file)
@@ -147,8 +147,6 @@ static int __osd_init_iobuf(struct osd_device *d, struct osd_iobuf *iobuf,
 
        blocks = pages * (PAGE_SIZE >> osd_sb(d)->s_blocksize_bits);
        if (iobuf->dr_bl_buf.lb_len >= blocks * sizeof(iobuf->dr_blocks[0])) {
-               LASSERT(iobuf->dr_pg_buf.lb_len >=
-                       pages * sizeof(iobuf->dr_pages[0]));
                return 0;
        }
 
@@ -158,7 +156,7 @@ static int __osd_init_iobuf(struct osd_device *d, struct osd_iobuf *iobuf,
                i <<= 1;
 
        CDEBUG(D_OTHER, "realloc %u for %u (%u) pages\n",
-              (unsigned int)(pages * sizeof(iobuf->dr_pages[0])), i, pages);
+              (unsigned int)(pages * sizeof(iobuf->dr_lnbs[0])), i, pages);
        pages = i;
        blocks = pages * (PAGE_SIZE >> osd_sb(d)->s_blocksize_bits);
        iobuf->dr_max_pages = 0;
@@ -170,11 +168,6 @@ static int __osd_init_iobuf(struct osd_device *d, struct osd_iobuf *iobuf,
        if (unlikely(iobuf->dr_blocks == NULL))
                return -ENOMEM;
 
-       lu_buf_realloc(&iobuf->dr_pg_buf, pages * sizeof(iobuf->dr_pages[0]));
-       iobuf->dr_pages = iobuf->dr_pg_buf.lb_buf;
-       if (unlikely(iobuf->dr_pages == NULL))
-               return -ENOMEM;
-
        lu_buf_realloc(&iobuf->dr_lnb_buf,
                       pages * sizeof(iobuf->dr_lnbs[0]));
        iobuf->dr_lnbs = iobuf->dr_lnb_buf.lb_buf;
@@ -198,7 +191,6 @@ static void osd_iobuf_add_page(struct osd_iobuf *iobuf,
                               struct niobuf_local *lnb)
 {
        LASSERT(iobuf->dr_npages < iobuf->dr_max_pages);
-       iobuf->dr_pages[iobuf->dr_npages] = lnb->lnb_page;
        iobuf->dr_lnbs[iobuf->dr_npages] = lnb;
        iobuf->dr_npages++;
 }
@@ -391,7 +383,7 @@ static int osd_do_bio(struct osd_device *osd, struct inode *inode,
                      sector_t count)
 {
        int blocks_per_page = PAGE_SIZE >> inode->i_blkbits;
-       struct page **pages = iobuf->dr_pages;
+       struct niobuf_local **lnbs = iobuf->dr_lnbs;
        int npages = iobuf->dr_npages;
        sector_t *blocks = iobuf->dr_blocks;
        struct super_block *sb = inode->i_sb;
@@ -437,7 +429,7 @@ static int osd_do_bio(struct osd_device *osd, struct inode *inode,
                 * "blocks_left_page" is reduced), and the last page may
                 * skip some blocks at the end (limited by "count").
                 */
-               page = pages[page_idx];
+               page = lnbs[page_idx]->lnb_page;
                LASSERT(page_idx < iobuf->dr_npages);
 
                i = block_idx % blocks_per_page;
@@ -935,7 +927,7 @@ static int osd_ldiskfs_map_inode_pages(struct inode *inode,
        handle_t *handle = NULL;
        sector_t start_blocks = 0, count = 0;
        loff_t disk_size = 0;
-       struct page **page = iobuf->dr_pages;
+       struct niobuf_local **lnbs = iobuf->dr_lnbs;
        int pages = iobuf->dr_npages;
        sector_t *blocks = iobuf->dr_blocks;
        struct niobuf_local *lnb1, *lnb2;
@@ -944,7 +936,7 @@ static int osd_ldiskfs_map_inode_pages(struct inode *inode,
        max_page_index = inode->i_sb->s_maxbytes >> PAGE_SHIFT;
 
        CDEBUG(D_OTHER, "inode %lu: map %d pages from %lu\n",
-               inode->i_ino, pages, (*page)->index);
+               inode->i_ino, pages, (*lnbs)->lnb_page->index);
 
        if (create) {
                create = LDISKFS_GET_BLOCKS_CREATE;
@@ -969,14 +961,15 @@ static int osd_ldiskfs_map_inode_pages(struct inode *inode,
                ktime_t time;
 
                if (fp == NULL) { /* start new extent */
-                       fp = *page++;
+                       fp = (*lnbs)->lnb_page;
+                       lnbs++;
                        clen = 1;
                        iobuf->dr_lextents++;
                        if (++i != pages)
                                continue;
-               } else if (fp->index + clen == (*page)->index) {
+               } else if (fp->index + clen == (*lnbs)->lnb_page->index) {
                        /* continue the extent */
-                       page++;
+                       lnbs++;
                        clen++;
                        if (++i != pages)
                                continue;
@@ -1607,9 +1600,10 @@ static int osd_read_prep(const struct lu_env *env, struct dt_object *dt,
 
                /* early release to let others read data during the bulk */
                for (i = 0; i < iobuf->dr_npages; i++) {
-                       LASSERT(PageLocked(iobuf->dr_pages[i]));
-                       if (!PagePrivate2(iobuf->dr_pages[i]))
-                               unlock_page(iobuf->dr_pages[i]);
+                       struct page *page = iobuf->dr_lnbs[i]->lnb_page;
+                       LASSERT(PageLocked(page));
+                       if (!PagePrivate2(page))
+                               unlock_page(page);
                }
        }