From patchwork Thu Apr 23 23:04:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lin X-Patchwork-Id: 6265651 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 38ED19F1C4 for ; Thu, 23 Apr 2015 23:05:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 65077203DB for ; Thu, 23 Apr 2015 23:05:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 64CE120138 for ; Thu, 23 Apr 2015 23:05:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031142AbbDWXFf (ORCPT ); Thu, 23 Apr 2015 19:05:35 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:45144 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031199AbbDWXFU (ORCPT ); Thu, 23 Apr 2015 19:05:20 -0400 Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NNA009UZ84U0MB0@mailout4.samsung.com>; Fri, 24 Apr 2015 08:05:18 +0900 (KST) X-AuditID: cbfee61b-f79536d000000f1f-d3-55397aae82ad Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 06.85.03871.EAA79355; Fri, 24 Apr 2015 08:05:18 +0900 (KST) Received: from localhost.localdomain ([105.128.19.153]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NNA00IAW83XRM70@mmp2.samsung.com>; Fri, 24 Apr 2015 08:05:18 +0900 (KST) From: Ming Lin To: linux-kernel@vger.kernel.org Cc: Christoph Hellwig , Kent Overstreet , Jens Axboe , Dongsu Park , linux-pm@vger.kernel.org, Ming Lin Subject: [PATCH v3 4/4] PM: submit bio in a sane way in cases without bio_chain Date: Thu, 23 Apr 2015 16:04:35 -0700 Message-id: <1429830275-6792-5-git-send-email-mlin@kernel.org> X-Mailer: git-send-email 1.9.1 In-reply-to: <1429830275-6792-1-git-send-email-mlin@kernel.org> References: <1429830275-6792-1-git-send-email-mlin@kernel.org> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprGLMWRmVeSWpSXmKPExsVy+t9jQd11VZahBgsn6VisvtvPZnF59Sp2 i9MTFjFZHGmqsri8aw6bxefeI4wW57edZHVg99g56y67x+YVWh6Xz5Z6bFrVyebx589nZo/P m+QC2KK4bFJSczLLUov07RK4Ml49a2EvWCtY8e/XL7YGxvl8XYycHBICJhLPZ09nhLDFJC7c W8/WxcjFISQwnVFi9f85rBDOT0aJXWsns4JUsQkoSBxct4EJxBYBsjf3PgOLMwvcYZRo/yUD YgsL+Es8P3yLBcRmEVCVuP+9FayeV8BO4sfC5SwQ2+QkTh6DmMkpYC/x9eRjNhBbCKhm5e0p TBMYeRcwMqxiFE0tSC4oTkrPNdIrTswtLs1L10vOz93ECA6tZ9I7GFc1WBxiFOBgVOLh/VBk ESrEmlhWXJl7iFGCg1lJhJe93DJUiDclsbIqtSg/vqg0J7X4EKM0B4uSOO8cXblQIYH0xJLU 7NTUgtQimCwTB6dUA6M/y6aiKe2NZ0UP8zl8EOW5ExHxuy9yTWtl4A3G+NUnhaeuPCS899+c TuaABA6Hl+fi+qe8uZB7STEm6Oj0Gouncfn6xdwhy9SNkzikvpgxFNWYLM3I2fDu9H0to6zD /Iz3p8TllCcxLe8q5TG1/z3n5Mq42P+lfV/vaLSqNmkqPTngtmeppxJLcUaioRZzUXEiAKjz 4FUpAgAA Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kent Overstreet Make bio submission in kernel/power/block_io.c to properly submit bios also when bio_chain is not available. In that case, it's not necessary to handle refcount with bio_get(), but it's saner to simply call a predefined helper submit_bio_wait(). So call bio_get() only when bio_chain is given. Cc: Christoph Hellwig Cc: linux-pm@vger.kernel.org Acked-by: Rafael J. Wysocki Signed-off-by: Kent Overstreet [dpark: add more description in commit message] Signed-off-by: Dongsu Park Signed-off-by: Ming Lin --- kernel/power/block_io.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/kernel/power/block_io.c b/kernel/power/block_io.c index 9a58bc2..7206408 100644 --- a/kernel/power/block_io.c +++ b/kernel/power/block_io.c @@ -34,7 +34,6 @@ static int submit(int rw, struct block_device *bdev, sector_t sector, bio = bio_alloc(__GFP_WAIT | __GFP_HIGH, 1); bio->bi_iter.bi_sector = sector; bio->bi_bdev = bdev; - bio->bi_end_io = end_swap_bio_read; if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) { printk(KERN_ERR "PM: Adding page to bio failed at %llu\n", @@ -44,15 +43,29 @@ static int submit(int rw, struct block_device *bdev, sector_t sector, } lock_page(page); - bio_get(bio); if (bio_chain == NULL) { - submit_bio(bio_rw, bio); - wait_on_page_locked(page); + int err = submit_bio_wait(bio_rw, bio); + + if (err) { + SetPageError(page); + ClearPageUptodate(page); + pr_alert("Read-error on swap-device (%u:%u:%llu)\n", + imajor(bio->bi_bdev->bd_inode), + iminor(bio->bi_bdev->bd_inode), + (unsigned long long)bio->bi_iter.bi_sector); + } else { + SetPageUptodate(page); + } + if (rw == READ) - bio_set_pages_dirty(bio); + set_page_dirty_lock(page); + unlock_page(page); bio_put(bio); } else { + bio->bi_end_io = end_swap_bio_read; + bio_get(bio); + if (rw == READ) get_page(page); /* These pages are freed later */ bio->bi_private = *bio_chain;