Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4995583pxj; Tue, 25 May 2021 23:40:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxmx7uFULIhVPcJl1+NG0jX7rw5Dwn9EHcoisPfUxF3eNyNZ2W8CkOy8iA4PgAiBPua7UhJ X-Received: by 2002:a17:907:98e6:: with SMTP id ke6mr31919594ejc.107.1622011210333; Tue, 25 May 2021 23:40:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622011210; cv=none; d=google.com; s=arc-20160816; b=dxCpBiBZnM/5gi42ahJYhXAlPMmHbwHUVSZqs38FBj7IccIeEdjvcTqmtjLcusgucM KMGx3Ic61lrMN8vkA929UGSAAuGgEmM9BA9h+RC2NjljJSe2L0NyzI5m6eDUhPVH+EWi 9laG26txKFFv+pXLP64atlUUR/kg+X3ihcVIKYyJVjJZBlocMqZLUEQcbxcZQJexWYGP lgwpl/CrNyb2819Pb0yklJz9d/r9deRhtYrFFx9tp6VYQ3q/f5jOOaWbUxhzDoNFM7HG rGtzcjMNxAti+tZlh7seZdvt15h6qKsFTcg2VGMZS9k3yUssFD3sm4w7DQo7tgntXBn6 VYdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=M6qvMRrZSaXWR0jWXHS5FogTAi2w+VL/Eeu3VqtxnsM=; b=j5i4xVqB5DcNTHC95zPVzExfSj+jOp+NQ5FbJbRZe5+F0r6KAZUhuuPqB3aSZbgnS+ VhOAE0ioZdj7MYZQer5/aW4D+6QtYmwjkVqIje3Z2RfCaViNQmKsE12tfTJcNC1BOqFe bpRrMEGSxNghFYgM0WWwBNVZJ2jdlrMtuKKTPzlvQXP7TYuoKPERqbKfuQ5Ft6aaCnNL rzHL+4ujFsdoPdIIQO3KX9uUwOfJq5kb0ZyZKrHSFBi54MaYtn6iYor9IPnXnIcqk1Vy pPZXsj6umcN/wt731Y7xzoxkiSKAK3LrF1gMhm4N+FTodrfX7FEF7YBdzZy03pDesBDO zqAw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v20si14031903edc.437.2021.05.25.23.39.46; Tue, 25 May 2021 23:40:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232528AbhEZGbE (ORCPT + 99 others); Wed, 26 May 2021 02:31:04 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6636 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229494AbhEZGbD (ORCPT ); Wed, 26 May 2021 02:31:03 -0400 Received: from dggems701-chm.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Fqgvg38y7z1BQvW; Wed, 26 May 2021 14:26:39 +0800 (CST) Received: from dggemx753-chm.china.huawei.com (10.0.44.37) by dggems701-chm.china.huawei.com (10.3.19.178) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Wed, 26 May 2021 14:29:31 +0800 Received: from szvp000207684.huawei.com (10.120.216.130) by dggemx753-chm.china.huawei.com (10.0.44.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Wed, 26 May 2021 14:29:30 +0800 From: Chao Yu To: CC: , , , Chao Yu Subject: [PATCH 1/2] f2fs: swap: remove dead codes Date: Wed, 26 May 2021 14:29:26 +0800 Message-ID: <20210526062927.52629-1-yuchao0@huawei.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.120.216.130] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggemx753-chm.china.huawei.com (10.0.44.37) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After commit af4b6b8edf6a ("f2fs: introduce check_swap_activate_fast()"), we will never run into original logic of check_swap_activate() before f2fs supports non 4k-sized page, so let's delete those dead codes. Signed-off-by: Chao Yu --- fs/f2fs/data.c | 171 +------------------------------------------------ 1 file changed, 3 insertions(+), 168 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 3058c7e28b11..9c23fde93b76 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -3830,67 +3830,7 @@ int f2fs_migrate_page(struct address_space *mapping, #endif #ifdef CONFIG_SWAP -static int f2fs_is_file_aligned(struct inode *inode) -{ - struct f2fs_sb_info *sbi = F2FS_I_SB(inode); - block_t main_blkaddr = SM_I(sbi)->main_blkaddr; - block_t cur_lblock; - block_t last_lblock; - block_t pblock; - unsigned long nr_pblocks; - unsigned int blocks_per_sec = BLKS_PER_SEC(sbi); - unsigned int not_aligned = 0; - int ret = 0; - - cur_lblock = 0; - last_lblock = bytes_to_blks(inode, i_size_read(inode)); - - while (cur_lblock < last_lblock) { - struct f2fs_map_blocks map; - - memset(&map, 0, sizeof(map)); - map.m_lblk = cur_lblock; - map.m_len = last_lblock - cur_lblock; - map.m_next_pgofs = NULL; - map.m_next_extent = NULL; - map.m_seg_type = NO_CHECK_TYPE; - map.m_may_create = false; - - ret = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_FIEMAP); - if (ret) - goto out; - - /* hole */ - if (!(map.m_flags & F2FS_MAP_FLAGS)) { - f2fs_err(sbi, "Swapfile has holes\n"); - ret = -ENOENT; - goto out; - } - - pblock = map.m_pblk; - nr_pblocks = map.m_len; - - if ((pblock - main_blkaddr) & (blocks_per_sec - 1) || - nr_pblocks & (blocks_per_sec - 1)) { - if (f2fs_is_pinned_file(inode)) { - f2fs_err(sbi, "Swapfile does not align to section"); - ret = -EINVAL; - goto out; - } - not_aligned++; - } - - cur_lblock += nr_pblocks; - } - if (not_aligned) - f2fs_warn(sbi, "Swapfile (%u) is not align to section: \n" - "\t1) creat(), 2) ioctl(F2FS_IOC_SET_PIN_FILE), 3) fallocate()", - not_aligned); -out: - return ret; -} - -static int check_swap_activate_fast(struct swap_info_struct *sis, +static int check_swap_activate(struct swap_info_struct *sis, struct file *swap_file, sector_t *span) { struct address_space *mapping = swap_file->f_mapping; @@ -3907,6 +3847,8 @@ static int check_swap_activate_fast(struct swap_info_struct *sis, unsigned int not_aligned = 0; int ret = 0; + f2fs_bug_on(sbi, PAGE_SIZE != F2FS_BLKSIZE); + /* * Map all the blocks into the extent list. This code doesn't try * to be very smart. @@ -3986,113 +3928,6 @@ static int check_swap_activate_fast(struct swap_info_struct *sis, return ret; } -/* Copied from generic_swapfile_activate() to check any holes */ -static int check_swap_activate(struct swap_info_struct *sis, - struct file *swap_file, sector_t *span) -{ - struct address_space *mapping = swap_file->f_mapping; - struct inode *inode = mapping->host; - struct f2fs_sb_info *sbi = F2FS_I_SB(inode); - unsigned blocks_per_page; - unsigned long page_no; - sector_t probe_block; - sector_t last_block; - sector_t lowest_block = -1; - sector_t highest_block = 0; - int nr_extents = 0; - int ret = 0; - - if (PAGE_SIZE == F2FS_BLKSIZE) - return check_swap_activate_fast(sis, swap_file, span); - - ret = f2fs_is_file_aligned(inode); - if (ret) - goto out; - - blocks_per_page = bytes_to_blks(inode, PAGE_SIZE); - - /* - * Map all the blocks into the extent list. This code doesn't try - * to be very smart. - */ - probe_block = 0; - page_no = 0; - last_block = bytes_to_blks(inode, i_size_read(inode)); - while ((probe_block + blocks_per_page) <= last_block && - page_no < sis->max) { - unsigned block_in_page; - sector_t first_block; - sector_t block = 0; - - cond_resched(); - - block = probe_block; - ret = bmap(inode, &block); - if (ret) - goto out; - if (!block) - goto bad_bmap; - first_block = block; - - /* - * It must be PAGE_SIZE aligned on-disk - */ - if (first_block & (blocks_per_page - 1)) { - probe_block++; - goto reprobe; - } - - for (block_in_page = 1; block_in_page < blocks_per_page; - block_in_page++) { - - block = probe_block + block_in_page; - ret = bmap(inode, &block); - if (ret) - goto out; - if (!block) - goto bad_bmap; - - if (block != first_block + block_in_page) { - /* Discontiguity */ - probe_block++; - goto reprobe; - } - } - - first_block >>= (PAGE_SHIFT - inode->i_blkbits); - if (page_no) { /* exclude the header page */ - if (first_block < lowest_block) - lowest_block = first_block; - if (first_block > highest_block) - highest_block = first_block; - } - - /* - * We found a PAGE_SIZE-length, PAGE_SIZE-aligned run of blocks - */ - ret = add_swap_extent(sis, page_no, 1, first_block); - if (ret < 0) - goto out; - nr_extents += ret; - page_no++; - probe_block += blocks_per_page; -reprobe: - continue; - } - ret = nr_extents; - *span = 1 + highest_block - lowest_block; - if (page_no == 0) - page_no = 1; /* force Empty message */ - sis->max = page_no; - sis->pages = page_no - 1; - sis->highest_bit = page_no - 1; -out: - return ret; -bad_bmap: - f2fs_err(sbi, "Swapfile has holes\n"); - return -EINVAL; -} - static int f2fs_swap_activate(struct swap_info_struct *sis, struct file *file, sector_t *span) { -- 2.29.2