From patchwork Fri Aug 11 11:04:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13350681 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7C37C0015E for ; Fri, 11 Aug 2023 11:05:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236027AbjHKLFi (ORCPT ); Fri, 11 Aug 2023 07:05:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235700AbjHKLFL (ORCPT ); Fri, 11 Aug 2023 07:05:11 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CF7E10C9; Fri, 11 Aug 2023 04:05:10 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2D62621880; Fri, 11 Aug 2023 11:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1691751906; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mxcAzzD+Uyye6qjjVVcqoAgSgsS8B+BvpQl4uroL/p4=; b=UfLc/kvaQVRluoWTmPGAQrSqxXK8dQnKKaN1pkarO69aTnznWAZsqMwuoauiVv31nLrMtX wF8rV+yetP+zQuaGhOpDx6rYvlHkRzJZldFd4RKw/Y/RoB92UDRCYE1WewkQzsYZjkI3xr uXmSid0sxidMQKO9Q/Nz18nSYtlIg6Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1691751906; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mxcAzzD+Uyye6qjjVVcqoAgSgsS8B+BvpQl4uroL/p4=; b=XU2xPpP6S2ppAm6IQSk6w5oc41GYALuZTxpzlRlafMYomHz5nlFXFJCQ0tz29zy0BysmNA N0xSyS8/7SJEjTCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 22452138E3; Fri, 11 Aug 2023 11:05:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id JPpRCOIV1mRcRQAAMHmgww (envelope-from ); Fri, 11 Aug 2023 11:05:06 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 1FA5CA078F; Fri, 11 Aug 2023 13:05:05 +0200 (CEST) From: Jan Kara To: Cc: , Christoph Hellwig , Jan Kara , linux-pm@vger.kernel.org Subject: [PATCH 16/29] PM: hibernate: Convert to bdev_open_by_dev() Date: Fri, 11 Aug 2023 13:04:47 +0200 Message-Id: <20230811110504.27514-16-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230810171429.31759-1-jack@suse.cz> References: <20230810171429.31759-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3086; i=jack@suse.cz; h=from:subject; bh=gHRpjpEOsJl1nkmTzeoLxPEEw/WCLHXfkHcdzoKJwjw=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBk1hXQ4OczpzJX8G4+68Yl6+VrCj6JyNam5hshjuFc a9M++HCJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZNYV0AAKCRCcnaoHP2RA2YjZB/ 0fUUUmmAgt3XVjXh8Cy0RuahYZ18A/bH531q2MqfRMz7ANRKFT2d1eNapi0/DnQLi54DhT8O6as0ly JV0r2+GizKfh2gUBQ6oMJg5Di2H1Y8Vf5KZmMKp/ic1XQTgmZoJpWqWgX/TbzfB6uhO+VIzFYbwq// 2AEPM6hZ/7efSqdUgWCvE58bZ0o7PO9+gC4PQfWtItqIjGBiHRSbfzTES+inXRoXur4djMwigd4iEd 1mQyR6geMQ8X1OhHbg4RmaoHO/uo2LM4ZXfqHJmMHS1cYj4s0vTxlUZxLGgeLfPHWa3kjaWbj+6YBz sgmliYID/ZuLdnSkTNmw0kZnzcy6XI X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Convert hibernation code to use bdev_open_by_dev(). CC: linux-pm@vger.kernel.org Signed-off-by: Jan Kara Acked-by: Rafael J. Wysocki --- kernel/power/swap.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/kernel/power/swap.c b/kernel/power/swap.c index f6ebcd00c410..b475bee282ff 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c @@ -222,7 +222,7 @@ int swsusp_swap_in_use(void) */ static unsigned short root_swap = 0xffff; -static struct block_device *hib_resume_bdev; +static struct bdev_handle *hib_resume_bdev_handle; struct hib_bio_batch { atomic_t count; @@ -276,7 +276,8 @@ static int hib_submit_io(blk_opf_t opf, pgoff_t page_off, void *addr, struct bio *bio; int error = 0; - bio = bio_alloc(hib_resume_bdev, 1, opf, GFP_NOIO | __GFP_HIGH); + bio = bio_alloc(hib_resume_bdev_handle->bdev, 1, opf, + GFP_NOIO | __GFP_HIGH); bio->bi_iter.bi_sector = page_off * (PAGE_SIZE >> 9); if (bio_add_page(bio, page, PAGE_SIZE, 0) < PAGE_SIZE) { @@ -356,14 +357,14 @@ static int swsusp_swap_check(void) return res; root_swap = res; - hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, + hib_resume_bdev_handle = bdev_open_by_dev(swsusp_resume_device, BLK_OPEN_WRITE, NULL, NULL); - if (IS_ERR(hib_resume_bdev)) - return PTR_ERR(hib_resume_bdev); + if (IS_ERR(hib_resume_bdev_handle)) + return PTR_ERR(hib_resume_bdev_handle); - res = set_blocksize(hib_resume_bdev, PAGE_SIZE); + res = set_blocksize(hib_resume_bdev_handle->bdev, PAGE_SIZE); if (res < 0) - blkdev_put(hib_resume_bdev, NULL); + bdev_release(hib_resume_bdev_handle); return res; } @@ -1521,10 +1522,10 @@ int swsusp_check(bool snapshot_test) void *holder = snapshot_test ? &swsusp_holder : NULL; int error; - hib_resume_bdev = blkdev_get_by_dev(swsusp_resume_device, BLK_OPEN_READ, - holder, NULL); - if (!IS_ERR(hib_resume_bdev)) { - set_blocksize(hib_resume_bdev, PAGE_SIZE); + hib_resume_bdev_handle = bdev_open_by_dev(swsusp_resume_device, + BLK_OPEN_READ, holder, NULL); + if (!IS_ERR(hib_resume_bdev_handle)) { + set_blocksize(hib_resume_bdev_handle->bdev, PAGE_SIZE); clear_page(swsusp_header); error = hib_submit_io(REQ_OP_READ, swsusp_resume_block, swsusp_header, NULL); @@ -1549,11 +1550,11 @@ int swsusp_check(bool snapshot_test) put: if (error) - blkdev_put(hib_resume_bdev, holder); + bdev_release(hib_resume_bdev_handle); else pr_debug("Image signature found, resuming\n"); } else { - error = PTR_ERR(hib_resume_bdev); + error = PTR_ERR(hib_resume_bdev_handle); } if (error) @@ -1568,12 +1569,12 @@ int swsusp_check(bool snapshot_test) void swsusp_close(bool snapshot_test) { - if (IS_ERR(hib_resume_bdev)) { + if (IS_ERR(hib_resume_bdev_handle)) { pr_debug("Image device not initialised\n"); return; } - blkdev_put(hib_resume_bdev, snapshot_test ? &swsusp_holder : NULL); + bdev_release(hib_resume_bdev_handle); } /** From patchwork Fri Aug 11 11:04:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13350682 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5DAAC001DB for ; Fri, 11 Aug 2023 11:05:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236046AbjHKLFj (ORCPT ); Fri, 11 Aug 2023 07:05:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235523AbjHKLFL (ORCPT ); Fri, 11 Aug 2023 07:05:11 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CF2EE71; Fri, 11 Aug 2023 04:05:10 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4BE1821883; Fri, 11 Aug 2023 11:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1691751906; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6luzPVXSDVEUOtJJ3n3omPBoNUdDHogmn1iNnmk3SJ4=; b=SuVjHf5WZctl55n6lUk2h3uRI+BhXIwIdWDt8rp23E6w4P7Kn2iGwIG4j7wDQ9Fft/PeYJ fDppUURzbUyNYvGYnmtR2lN3Q5W3FjrbxLR3hEAdhG1vjpN9Pjd10snquZTTA0o/2qsiOr p3SouZolZvLFwID1OQVrfil2rFX7660= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1691751906; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6luzPVXSDVEUOtJJ3n3omPBoNUdDHogmn1iNnmk3SJ4=; b=jIaCi4urD01bjLEQl8bYVLVRhjAtYVf1qHwL70t6PUXgjFJVxmnSaVWYxsagJb3KezE1Rx z4VrU1e2Zny+SfDQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 3E2B5139FD; Fri, 11 Aug 2023 11:05:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id N38rD+IV1mRmRQAAMHmgww (envelope-from ); Fri, 11 Aug 2023 11:05:06 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 24D5FA0790; Fri, 11 Aug 2023 13:05:05 +0200 (CEST) From: Jan Kara To: Cc: , Christoph Hellwig , Jan Kara , linux-pm@vger.kernel.org Subject: [PATCH 17/29] PM: hibernate: Drop unused snapshot_test argument Date: Fri, 11 Aug 2023 13:04:48 +0200 Message-Id: <20230811110504.27514-17-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230810171429.31759-1-jack@suse.cz> References: <20230810171429.31759-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3450; i=jack@suse.cz; h=from:subject; bh=EYiYPYIKB+WJacuyKZgkGjy+mR31pBVUNTN/L6fc2bs=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBk1hXR/+ckoRxIzn1GaSHqLLvthVaos2lTm5L88vxE rm8UX3WJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZNYV0QAKCRCcnaoHP2RA2ek5B/ 9Pi82m0GTl08fRjdq0kEU1LfLdWe8eE/Un0pnOLzFHu/FLF7/o1AARu66tsRIu/f6mblm099QfGQVi E7qHzgthGg20b1dQz+uOgkNhqnNO7pBOBqsiBFBxvh8ALfl9WpVveGAof7/8bKe6f1r0cCixAA1yvE 8LIxzx2vBYQi2kNw8BhhP+7l2mZnvk8ebOKdvcroQrU12k0EM+ga2aYWO6zt4ltOFxaC+y2Z/ZlhP9 zXFhDphr1FpTeqGFbBxm5f21S7W30FXVImufnudg8KlwKBjr11hYxWOnNSW85ZZCi4d7Y0I7mLpCE9 tyQX61tgIk8qo6D1jw4l4x4Xn/0Xaa X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org snapshot_test argument is now unused in swsusp_close() and load_image_and_restore(). Drop it CC: linux-pm@vger.kernel.org Signed-off-by: Jan Kara Acked-by: Rafael J. Wysocki --- kernel/power/hibernate.c | 14 +++++++------- kernel/power/power.h | 2 +- kernel/power/swap.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index e1b4bfa938dd..6abeec0ae084 100644 --- a/kernel/power/hibernate.c +++ b/kernel/power/hibernate.c @@ -684,7 +684,7 @@ static void power_down(void) cpu_relax(); } -static int load_image_and_restore(bool snapshot_test) +static int load_image_and_restore(void) { int error; unsigned int flags; @@ -694,12 +694,12 @@ static int load_image_and_restore(bool snapshot_test) lock_device_hotplug(); error = create_basic_memory_bitmaps(); if (error) { - swsusp_close(snapshot_test); + swsusp_close(); goto Unlock; } error = swsusp_read(&flags); - swsusp_close(snapshot_test); + swsusp_close(); if (!error) error = hibernation_restore(flags & SF_PLATFORM_MODE); @@ -788,7 +788,7 @@ int hibernate(void) pm_pr_dbg("Checking hibernation image\n"); error = swsusp_check(snapshot_test); if (!error) - error = load_image_and_restore(snapshot_test); + error = load_image_and_restore(); } thaw_processes(); @@ -952,7 +952,7 @@ static int software_resume(void) /* The snapshot device should not be opened while we're running */ if (!hibernate_acquire()) { error = -EBUSY; - swsusp_close(false); + swsusp_close(); goto Unlock; } @@ -973,7 +973,7 @@ static int software_resume(void) goto Close_Finish; } - error = load_image_and_restore(false); + error = load_image_and_restore(); thaw_processes(); Finish: pm_notifier_call_chain(PM_POST_RESTORE); @@ -987,7 +987,7 @@ static int software_resume(void) pm_pr_dbg("Hibernation image not present or could not be loaded.\n"); return error; Close_Finish: - swsusp_close(false); + swsusp_close(); goto Finish; } diff --git a/kernel/power/power.h b/kernel/power/power.h index 46eb14dc50c3..bebf049a51c1 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h @@ -172,7 +172,7 @@ int swsusp_check(bool snapshot_test); extern void swsusp_free(void); extern int swsusp_read(unsigned int *flags_p); extern int swsusp_write(unsigned int flags); -void swsusp_close(bool snapshot_test); +void swsusp_close(void); #ifdef CONFIG_SUSPEND extern int swsusp_unmark(void); #endif diff --git a/kernel/power/swap.c b/kernel/power/swap.c index b475bee282ff..17e0dad5008e 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c @@ -444,7 +444,7 @@ static int get_swap_writer(struct swap_map_handle *handle) err_rel: release_swap_writer(handle); err_close: - swsusp_close(false); + swsusp_close(); return ret; } @@ -509,7 +509,7 @@ static int swap_writer_finish(struct swap_map_handle *handle, if (error) free_all_swap_pages(root_swap); release_swap_writer(handle); - swsusp_close(false); + swsusp_close(); return error; } @@ -1567,7 +1567,7 @@ int swsusp_check(bool snapshot_test) * swsusp_close - close swap device. */ -void swsusp_close(bool snapshot_test) +void swsusp_close(void) { if (IS_ERR(hib_resume_bdev_handle)) { pr_debug("Image device not initialised\n");