Whamcloud - gitweb
LU-12355 ldiskfs: Remove old map blocks support 96/35496/3
authorShaun Tancheff <stancheff@cray.com>
Sun, 14 Jul 2019 11:17:56 +0000 (06:17 -0500)
committerOleg Drokin <green@whamcloud.com>
Fri, 2 Aug 2019 06:02:25 +0000 (06:02 +0000)
Oldest supported kernel has ext4_map_blocks and ext_pblock
Remove them instead of fixing them for newer (4.14+) kernels

Test-Parameters: trivial
Cray-bug-id: LUS-6962
Signed-off-by: Shaun Tancheff <stancheff@cray.com>
Change-Id: I415dcfa4b0a5bde5f7240b802ea81199715bdb88
Reviewed-on: https://review.whamcloud.com/35496
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Petros Koutoupis <pkoutoupis@cray.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
config/lustre-build-ldiskfs.m4
lustre/osd-ldiskfs/osd_io.c

index 49d40c1..e1c64a2 100644 (file)
@@ -114,23 +114,6 @@ ext4_free_blocks_with_buffer_head, [
 ]) # LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
 
 #
-# LB_EXT_PBLOCK
-#
-# 2.6.35 renamed ext_pblock to ext4_ext_pblock(ex)
-#
-AC_DEFUN([LB_EXT_PBLOCK], [
-LB_CHECK_COMPILE([if Linux kernel has 'ext_pblock'],
-ext_pblock, [
-       #include <linux/fs.h>
-       #include "$EXT4_SRC_DIR/ext4_extents.h"
-],[
-       ext_pblock(NULL);
-],[
-       AC_DEFINE(HAVE_EXT_PBLOCK, 1, [Linux kernel has ext_pblock])
-])
-]) # LB_EXT_PBLOCK
-
-#
 # LB_EXT4_JOURNAL_START_3ARGS
 #
 # 3.9 added a type argument to ext4_journal_start and friends
@@ -148,25 +131,6 @@ ext4_journal_start, [
 ]) # LB_EXT4_JOURNAL_START_3ARGS
 
 #
-# LB_LDISKFS_MAP_BLOCKS
-#
-# Since 2.6.35 brought ext4_map_blocks() for IO.
-# We just check this function whether existed.
-# it must be exported by ldiskfs patches.
-#
-AC_DEFUN([LB_LDISKFS_MAP_BLOCKS], [
-LB_CHECK_COMPILE([if kernel has ext4_map_blocks],
-ext4_map_blocks, [
-       #include <linux/fs.h>
-       #include "$EXT4_SRC_DIR/ext4.h"
-],[
-       ext4_map_blocks(NULL, NULL, NULL, 0);
-],[
-       AC_DEFINE(HAVE_LDISKFS_MAP_BLOCKS, 1, [kernel has ext4_map_blocks])
-])
-])
-
-#
 # LB_EXT4_BREAD_4ARGS
 #
 # 3.18 ext4_bread has 4 arguments
@@ -340,9 +304,7 @@ AS_IF([test x$enable_ldiskfs != xno],[
        LDISKFS_LINUX_SERIES
        LDISKFS_AC_PATCH_PROGRAM
        LB_EXT_FREE_BLOCKS_WITH_BUFFER_HEAD
-       LB_EXT_PBLOCK
        LB_EXT4_JOURNAL_START_3ARGS
-       LB_LDISKFS_MAP_BLOCKS
        LB_EXT4_BREAD_4ARGS
        LB_EXT4_HAVE_INFO_DQUOT
        LB_EXT4_HAVE_I_CRYPT_INFO
index c695e79..ea8dde5 100644 (file)
@@ -833,348 +833,6 @@ cleanup:
        return rc;
 }
 
-#ifndef HAVE_LDISKFS_MAP_BLOCKS
-
-#ifdef HAVE_EXT_PBLOCK /* Name changed to ext4_ext_pblock for kernel 2.6.35 */
-#define ldiskfs_ext_pblock(ex) ext_pblock((ex))
-#endif
-
-struct bpointers {
-       sector_t *blocks;
-       unsigned long start;
-       int num;
-       int init_num;
-       int create;
-};
-
-static long ldiskfs_ext_find_goal(struct inode *inode,
-                                 struct ldiskfs_ext_path *path,
-                                 unsigned long block, int *aflags)
-{
-       struct ldiskfs_inode_info *ei = LDISKFS_I(inode);
-       unsigned long bg_start;
-       unsigned long colour;
-       int depth;
-
-       if (path) {
-               struct ldiskfs_extent *ex;
-               depth = path->p_depth;
-
-               /* try to predict block placement */
-               if ((ex = path[depth].p_ext))
-                       return ldiskfs_ext_pblock(ex) +
-                               (block - le32_to_cpu(ex->ee_block));
-
-               /* it looks index is empty
-                * try to find starting from index itself */
-               if (path[depth].p_bh)
-                       return path[depth].p_bh->b_blocknr;
-       }
-
-       /* OK. use inode's group */
-       bg_start = (ei->i_block_group * LDISKFS_BLOCKS_PER_GROUP(inode->i_sb)) +
-               le32_to_cpu(LDISKFS_SB(inode->i_sb)->s_es->s_first_data_block);
-       colour = (current->pid % 16) *
-               (LDISKFS_BLOCKS_PER_GROUP(inode->i_sb) / 16);
-       return bg_start + colour + block;
-}
-
-static unsigned long new_blocks(handle_t *handle, struct inode *inode,
-                               struct ldiskfs_ext_path *path,
-                               unsigned long block, unsigned long *count,
-                               int *err)
-{
-       struct ldiskfs_allocation_request ar;
-       unsigned long pblock;
-       int aflags;
-
-       /* find neighbour allocated blocks */
-       ar.lleft = block;
-       *err = ldiskfs_ext_search_left(inode, path, &ar.lleft, &ar.pleft);
-       if (*err)
-               return 0;
-       ar.lright = block;
-       *err = ldiskfs_ext_search_right(inode, path, &ar.lright, &ar.pright);
-       if (*err)
-               return 0;
-
-       /* allocate new block */
-       ar.goal = ldiskfs_ext_find_goal(inode, path, block, &aflags);
-       ar.inode = inode;
-       ar.logical = block;
-       ar.len = *count;
-       ar.flags = LDISKFS_MB_HINT_DATA;
-       pblock = ldiskfs_mb_new_blocks(handle, &ar, err);
-       *count = ar.len;
-       return pblock;
-}
-
-static int ldiskfs_ext_new_extent_cb(struct inode *inode,
-                                    struct ldiskfs_ext_path *path,
-                                    struct ldiskfs_ext_cache *cex,
-#ifdef HAVE_EXT_PREPARE_CB_EXTENT
-                                    struct ldiskfs_extent *ex,
-#endif
-                                    void *cbdata)
-{
-       struct bpointers *bp = cbdata;
-       struct ldiskfs_extent nex;
-       unsigned long pblock = 0;
-       unsigned long tgen;
-       int err, i;
-       unsigned long count;
-       handle_t *handle;
-
-#ifdef LDISKFS_EXT_CACHE_EXTENT /* until kernel 2.6.37 */
-       if (cex->ec_type == LDISKFS_EXT_CACHE_EXTENT) {
-#else
-       if ((cex->ec_len != 0) && (cex->ec_start != 0)) {
-#endif
-               err = EXT_CONTINUE;
-               goto map;
-       }
-
-       if (bp->create == 0) {
-               i = 0;
-               if (cex->ec_block < bp->start)
-                       i = bp->start - cex->ec_block;
-               if (i >= cex->ec_len)
-                       CERROR("nothing to do?! i = %d, e_num = %u\n",
-                                       i, cex->ec_len);
-               for (; i < cex->ec_len && bp->num; i++) {
-                       *(bp->blocks) = 0;
-                       bp->blocks++;
-                       bp->num--;
-                       bp->start++;
-               }
-
-               return EXT_CONTINUE;
-       }
-
-       tgen = LDISKFS_I(inode)->i_ext_generation;
-       count = ldiskfs_ext_calc_credits_for_insert(inode, path);
-
-       handle = osd_journal_start(inode, LDISKFS_HT_MISC,
-                                  count + LDISKFS_ALLOC_NEEDED + 1);
-       if (IS_ERR(handle)) {
-               return PTR_ERR(handle);
-       }
-
-       if (tgen != LDISKFS_I(inode)->i_ext_generation) {
-               /* the tree has changed. so path can be invalid at moment */
-               ldiskfs_journal_stop(handle);
-               return EXT_REPEAT;
-       }
-
-       /* In 2.6.32 kernel, ldiskfs_ext_walk_space()'s callback func is not
-        * protected by i_data_sem as whole. so we patch it to store
-        * generation to path and now verify the tree hasn't changed */
-       down_write((&LDISKFS_I(inode)->i_data_sem));
-
-       /* validate extent, make sure the extent tree does not changed */
-       if (LDISKFS_I(inode)->i_ext_generation != path[0].p_generation) {
-               /* cex is invalid, try again */
-               up_write(&LDISKFS_I(inode)->i_data_sem);
-               ldiskfs_journal_stop(handle);
-               return EXT_REPEAT;
-       }
-
-       count = cex->ec_len;
-       pblock = new_blocks(handle, inode, path, cex->ec_block, &count, &err);
-       if (!pblock)
-               goto out;
-       BUG_ON(count > cex->ec_len);
-
-       /* insert new extent */
-       nex.ee_block = cpu_to_le32(cex->ec_block);
-       ldiskfs_ext_store_pblock(&nex, pblock);
-       nex.ee_len = cpu_to_le16(count);
-       err = ldiskfs_ext_insert_extent(handle, inode, path, &nex, 0);
-       if (err) {
-               /* free data blocks we just allocated */
-               /* not a good idea to call discard here directly,
-                * but otherwise we'd need to call it every free() */
-               ldiskfs_discard_preallocations(inode);
-#ifdef HAVE_EXT_FREE_BLOCK_WITH_BUFFER_HEAD /* Introduced in 2.6.32-rc7 */
-               ldiskfs_free_blocks(handle, inode, NULL,
-                                   ldiskfs_ext_pblock(&nex),
-                                   le16_to_cpu(nex.ee_len), 0);
-#else
-               ldiskfs_free_blocks(handle, inode, ldiskfs_ext_pblock(&nex),
-                                   le16_to_cpu(nex.ee_len), 0);
-#endif
-               goto out;
-       }
-
-       /*
-        * Putting len of the actual extent we just inserted,
-        * we are asking ldiskfs_ext_walk_space() to continue
-        * scaning after that block
-        */
-       cex->ec_len = le16_to_cpu(nex.ee_len);
-       cex->ec_start = ldiskfs_ext_pblock(&nex);
-       BUG_ON(le16_to_cpu(nex.ee_len) == 0);
-       BUG_ON(le32_to_cpu(nex.ee_block) != cex->ec_block);
-
-out:
-       up_write((&LDISKFS_I(inode)->i_data_sem));
-       ldiskfs_journal_stop(handle);
-map:
-       if (err >= 0) {
-               /* map blocks */
-               if (bp->num == 0) {
-                       CERROR("hmm. why do we find this extent?\n");
-                       CERROR("initial space: %lu:%u\n",
-                               bp->start, bp->init_num);
-#ifdef LDISKFS_EXT_CACHE_EXTENT /* until kernel 2.6.37 */
-                       CERROR("current extent: %u/%u/%llu %d\n",
-                               cex->ec_block, cex->ec_len,
-                               (unsigned long long)cex->ec_start,
-                               cex->ec_type);
-#else
-                       CERROR("current extent: %u/%u/%llu\n",
-                               cex->ec_block, cex->ec_len,
-                               (unsigned long long)cex->ec_start);
-#endif
-               }
-               i = 0;
-               if (cex->ec_block < bp->start)
-                       i = bp->start - cex->ec_block;
-               if (i >= cex->ec_len)
-                       CERROR("nothing to do?! i = %d, e_num = %u\n",
-                                       i, cex->ec_len);
-               for (; i < cex->ec_len && bp->num; i++) {
-                       *(bp->blocks) = cex->ec_start + i;
-                       /* unmap any underlying metadata from
-                        * the block device mapping.  b=6998.
-                        */
-                       if (pblock != 0)
-                               clean_bdev_aliases(inode->i_sb->s_bdev,
-                                                  *(bp->blocks), 1);
-                       bp->blocks++;
-                       bp->num--;
-                       bp->start++;
-               }
-       }
-       return err;
-}
-
-static int osd_ldiskfs_map_nblocks(struct inode *inode, unsigned long index,
-                                  int clen, sector_t *blocks, int create)
-{
-       int blocks_per_page = PAGE_SIZE >> inode->i_blkbits;
-       struct bpointers bp;
-       int err;
-
-       if (index + clen >= inode->i_sb->s_maxbytes >> PAGE_SHIFT)
-               return -EFBIG;
-
-       bp.blocks = blocks;
-       bp.start = index * blocks_per_page;
-       bp.init_num = bp.num = clen * blocks_per_page;
-       bp.create = create;
-
-       CDEBUG(D_OTHER, "blocks %lu-%lu requested for inode %u\n",
-              bp.start, bp.start + bp.num - 1, (unsigned)inode->i_ino);
-
-       err = ldiskfs_ext_walk_space(inode, bp.start, bp.num,
-                                    ldiskfs_ext_new_extent_cb, &bp);
-       ldiskfs_ext_invalidate_cache(inode);
-
-       return err;
-}
-
-static int osd_ldiskfs_map_bm_inode_pages(struct inode *inode,
-                                         struct page **page, int pages,
-                                         sector_t *blocks, int create)
-{
-       int blocks_per_page = PAGE_SIZE >> inode->i_blkbits;
-       pgoff_t bitmap_max_page_index;
-       sector_t *b;
-       int rc = 0, i;
-
-       bitmap_max_page_index = LDISKFS_SB(inode->i_sb)->s_bitmap_maxbytes >>
-                               PAGE_SHIFT;
-       for (i = 0, b = blocks; i < pages; i++, page++) {
-               if ((*page)->index + 1 >= bitmap_max_page_index) {
-                       rc = -EFBIG;
-                       break;
-               }
-               rc = ldiskfs_map_inode_page(inode, *page, b, create);
-               if (rc) {
-                       CERROR("ino %lu, blk %llu create %d: rc %d\n",
-                              inode->i_ino,
-                              (unsigned long long)*b, create, rc);
-                       break;
-               }
-               b += blocks_per_page;
-       }
-       return rc;
-}
-
-static int osd_ldiskfs_map_ext_inode_pages(struct inode *inode,
-                                          struct page **page,
-                                          int pages, sector_t *blocks,
-                                          int create)
-{
-       int rc = 0, i = 0, clen = 0;
-       struct page *fp = NULL;
-
-       CDEBUG(D_OTHER, "inode %lu: map %d pages from %lu\n",
-               inode->i_ino, pages, (*page)->index);
-
-       /* pages are sorted already. so, we just have to find
-        * contig. space and process them properly */
-       while (i < pages) {
-               if (fp == NULL) {
-                       /* start new extent */
-                       fp = *page++;
-                       clen = 1;
-                       i++;
-                       continue;
-               } else if (fp->index + clen == (*page)->index) {
-                       /* continue the extent */
-                       page++;
-                       clen++;
-                       i++;
-                       continue;
-               }
-
-               /* process found extent */
-               rc = osd_ldiskfs_map_nblocks(inode, fp->index, clen,
-                                            blocks, create);
-               if (rc)
-                       GOTO(cleanup, rc);
-
-               /* look for next extent */
-               fp = NULL;
-               blocks += clen * (PAGE_SIZE >> inode->i_blkbits);
-       }
-
-       if (fp)
-               rc = osd_ldiskfs_map_nblocks(inode, fp->index, clen,
-                                            blocks, create);
-
-cleanup:
-       return rc;
-}
-
-static int osd_ldiskfs_map_inode_pages(struct inode *inode, struct page **page,
-                                      int pages, sector_t *blocks,
-                                      int create)
-{
-       int rc;
-
-       if (LDISKFS_I(inode)->i_flags & LDISKFS_EXTENTS_FL) {
-               rc = osd_ldiskfs_map_ext_inode_pages(inode, page, pages,
-                                                    blocks, create);
-               return rc;
-       }
-       rc = osd_ldiskfs_map_bm_inode_pages(inode, page, pages, blocks, create);
-
-       return rc;
-}
-#else
 static int osd_ldiskfs_map_inode_pages(struct inode *inode, struct page **page,
                                       int pages, sector_t *blocks,
                                       int create)
@@ -1260,7 +918,6 @@ cont_map:
 cleanup:
        return rc;
 }
-#endif /* HAVE_LDISKFS_MAP_BLOCKS */
 
 static int osd_write_prep(const struct lu_env *env, struct dt_object *dt,
                           struct niobuf_local *lnb, int npages)