ext4: Use clean_bdev_aliases() instead of iteration
authorJan Kara <jack@suse.cz>
Fri, 4 Nov 2016 17:08:13 +0000 (18:08 +0100)
committerJens Axboe <axboe@fb.com>
Fri, 4 Nov 2016 20:34:47 +0000 (14:34 -0600)
Use clean_bdev_aliases() instead of iterating through blocks one by one.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
fs/ext4/extents.c
fs/ext4/inode.c

index c930a0110fb4f6ecc19819d1728879277b9e8843..dd5b74dfa01804c3b69cdaf121b4a2e4a61972de 100644 (file)
@@ -3777,14 +3777,6 @@ out:
        return err;
 }
 
-static void unmap_underlying_metadata_blocks(struct block_device *bdev,
-                       sector_t block, int count)
-{
-       int i;
-       for (i = 0; i < count; i++)
-                unmap_underlying_metadata(bdev, block + i);
-}
-
 /*
  * Handle EOFBLOCKS_FL flag, clearing it if necessary
  */
@@ -4121,9 +4113,8 @@ out:
         * new.
         */
        if (allocated > map->m_len) {
-               unmap_underlying_metadata_blocks(inode->i_sb->s_bdev,
-                                       newblock + map->m_len,
-                                       allocated - map->m_len);
+               clean_bdev_aliases(inode->i_sb->s_bdev, newblock + map->m_len,
+                                  allocated - map->m_len);
                allocated = map->m_len;
        }
        map->m_len = allocated;
index 9c064727ed62978e95f27f2fe73c5e946ce672b0..7c7cc4ae4b8e6df59c18f434bf01058108beb293 100644 (file)
@@ -654,12 +654,8 @@ found:
                if (flags & EXT4_GET_BLOCKS_ZERO &&
                    map->m_flags & EXT4_MAP_MAPPED &&
                    map->m_flags & EXT4_MAP_NEW) {
-                       ext4_lblk_t i;
-
-                       for (i = 0; i < map->m_len; i++) {
-                               unmap_underlying_metadata(inode->i_sb->s_bdev,
-                                                         map->m_pblk + i);
-                       }
+                       clean_bdev_aliases(inode->i_sb->s_bdev, map->m_pblk,
+                                          map->m_len);
                        ret = ext4_issue_zeroout(inode, map->m_lblk,
                                                 map->m_pblk, map->m_len);
                        if (ret) {
@@ -2360,11 +2356,8 @@ static int mpage_map_one_extent(handle_t *handle, struct mpage_da_data *mpd)
 
        BUG_ON(map->m_len == 0);
        if (map->m_flags & EXT4_MAP_NEW) {
-               struct block_device *bdev = inode->i_sb->s_bdev;
-               int i;
-
-               for (i = 0; i < map->m_len; i++)
-                       unmap_underlying_metadata(bdev, map->m_pblk + i);
+               clean_bdev_aliases(inode->i_sb->s_bdev, map->m_pblk,
+                                  map->m_len);
        }
        return 0;
 }