Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752298AbbEYKEY (ORCPT ); Mon, 25 May 2015 06:04:24 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:58598 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752273AbbEYKEW (ORCPT ); Mon, 25 May 2015 06:04:22 -0400 X-AuditID: cbfee61a-f79516d000006302-6a-5562f3a57c24 From: Chao Yu To: Jaegeuk Kim , Changman Lee Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/2] f2fs: avoid duplicated code by reusing f2fs_read_end_io Date: Mon, 25 May 2015 18:03:38 +0800 Message-id: <00d301d096d2$2b7a2c70$826e8550$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdCWxNn3l0wp1KW2QsK8LpQ/kQpG4w== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsVy+t9jQd2ln5NCDV53Slhc29fIZPFk/Sxm i0uL3C0u75rD5sDisWlVJ5vH7gWfmTz6tqxi9Pi8SS6AJYrLJiU1J7MstUjfLoEr4+DtJsaC s4IVs46cZG9g/MjbxcjJISFgIvF1xwYmCFtM4sK99WwgtpDAdEaJJ/MLuxi5gOxXjBJLji5k BEmwCahILO/4D9YgIuAlMWn/CRYQm1nAQ6Kx4zsriC0s4C9xbeZuIJuDg0VAVWLWwwqQMK+A pcTcmZeZIGxBiR+T70G1akms33mcCcKWl9i85i0zxD0KEjvOvmaEWKUncaDnLStEjbjExiO3 WCYwCsxCMmoWklGzkIyahaRlASPLKkbR1ILkguKk9FxDveLE3OLSvHS95PzcTYzggH4mtYNx ZYPFIUYBDkYlHt6IjKRQIdbEsuLK3EOMEhzMSiK8IR+BQrwpiZVVqUX58UWlOanFhxilOViU xHlP5vuECgmkJ5akZqemFqQWwWSZODilGhinPlN8IZpmIXz2jEOT/6FrPhtdO+sc37Fmt8lz Z00Psbtcn2KRYX8mjzvDfFG92v6J5jNLHhpwGdllSH16kr/xxrfb7ZFqKxzUvixf+FH5doGR moHHBvs2vlnKIc1cXL/W8KZa9FeHGsf8Ez72uXD1f1U/C9WLctcfhQYzFT/SW9q1U0dGQIml OCPRUIu5qDgRAKptX01kAgAA Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2411 Lines: 92 This patch tries to clean up code because part code of f2fs_read_end_io and mpage_end_io are the same, so it's better to merge and reuse them. Signed-off-by: Chao Yu --- v2: * do not merge 'f2fs_end_io_crypto_work' and 'return' to indicate f2fs_end_io_crypto_work is defined to be a void returned function. fs/f2fs/data.c | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 8d04e24..9bedfa8 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -34,29 +34,6 @@ static void f2fs_read_end_io(struct bio *bio, int err) struct bio_vec *bvec; int i; - bio_for_each_segment_all(bvec, bio, i) { - struct page *page = bvec->bv_page; - - if (!err) { - SetPageUptodate(page); - } else { - ClearPageUptodate(page); - SetPageError(page); - } - unlock_page(page); - } - bio_put(bio); -} - -/* - * I/O completion handler for multipage BIOs. - * copied from fs/mpage.c - */ -static void mpage_end_io(struct bio *bio, int err) -{ - struct bio_vec *bv; - int i; - if (f2fs_bio_encrypted(bio)) { if (err) { f2fs_release_crypto_ctx(bio->bi_private); @@ -66,8 +43,8 @@ static void mpage_end_io(struct bio *bio, int err) } } - bio_for_each_segment_all(bv, bio, i) { - struct page *page = bv->bv_page; + bio_for_each_segment_all(bvec, bio, i) { + struct page *page = bvec->bv_page; if (!err) { SetPageUptodate(page); @@ -77,7 +54,6 @@ static void mpage_end_io(struct bio *bio, int err) } unlock_page(page); } - bio_put(bio); } @@ -122,7 +98,7 @@ static struct bio *__bio_alloc(struct f2fs_sb_info *sbi, block_t blk_addr, bio->bi_bdev = sbi->sb->s_bdev; bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(blk_addr); bio->bi_end_io = is_read ? f2fs_read_end_io : f2fs_write_end_io; - bio->bi_private = sbi; + bio->bi_private = is_read ? NULL : sbi; return bio; } @@ -1584,7 +1560,7 @@ submit_and_realloc: } bio->bi_bdev = bdev; bio->bi_iter.bi_sector = SECTOR_FROM_BLOCK(block_nr); - bio->bi_end_io = mpage_end_io; + bio->bi_end_io = f2fs_read_end_io; bio->bi_private = ctx; } -- 2.3.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/