Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755760AbbESJkA (ORCPT ); Tue, 19 May 2015 05:40:00 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:12003 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755726AbbESJjz (ORCPT ); Tue, 19 May 2015 05:39:55 -0400 X-AuditID: cbfee61b-f79536d000000f1f-c1-555b04e9e989 From: Chao Yu To: Jaegeuk Kim , Changman Lee Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] f2fs: avoid duplicated code by reusing f2fs_read_end_io Date: Tue, 19 May 2015 17:38:56 +0800 Message-id: <005d01d09217$c0df57f0$429e07d0$@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: AdCSDMGsHN6kuHW4RfKREkBsu0fQCw== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrMLMWRmVeSWpSXmKPExsVy+t9jQd2XLNGhBm/v6Fhc29fIZPFk/Sxm i0uL3C0u75rD5sDisWlVJ5vH7gWfmTz6tqxi9Pi8SS6AJYrLJiU1J7MstUjfLoErY8OCvUwF fwUqFhx9wtzAuIG3i5GTQ0LARGLLhMlsELaYxIV764FsLg4hgemMEgs37GSFcF4xSizu3A9W xSagIrG84z8TiC0i4CUxaf8JFhCbWcBDorHjOyuILSzgI7HsxEmwehYBVYneBS/B6nkFLCWe zVjPAmELSvyYfA+qV0ti/c7jTBC2vMTmNW+ZIS5SkNhx9jUjxC49iW3rVjFD1IhLbDxyi2UC o8AsJKNmIRk1C8moWUhaFjCyrGIUTS1ILihOSs810itOzC0uzUvXS87P3cQIDupn0jsYVzVY HGIU4GBU4uGNqI8KFWJNLCuuzD3EKMHBrCTCK/kZKMSbklhZlVqUH19UmpNafIhRmoNFSZz3 ZL5PqJBAemJJanZqakFqEUyWiYNTqoExxTolb2NgVMNGC+ab69K2OfG8uB/PeNNRMO7hhsI3 xn9LN/+Xba2+sSngcnGQ7LfKHsG5sf5BPso725s/PLWRlc67kt7g/1hkVYv05oDD643SLtqc /VJ3+v2FiT1eDYelJvYY33eNXP8758XhlI7oI5Kln29UFassFzhRJlY3c1H48g1TrJ8osRRn JBpqMRcVJwIAoU3/22YCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2332 Lines: 91 This patch tries to clean up code as 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 --- fs/f2fs/data.c | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 8d04e24..5173d0f 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -34,40 +34,16 @@ 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); } else { - f2fs_end_io_crypto_work(bio->bi_private, bio); - return; + return f2fs_end_io_crypto_work(bio->bi_private, bio); } } - 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 +53,6 @@ static void mpage_end_io(struct bio *bio, int err) } unlock_page(page); } - bio_put(bio); } @@ -122,7 +97,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 +1559,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.3 -- 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/