From patchwork Fri Jun 26 08:01:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11626797 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A992092A for ; Fri, 26 Jun 2020 08:02:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8EAC8208B6 for ; Fri, 26 Jun 2020 08:02:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="BFVCZMiF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728914AbgFZICQ (ORCPT ); Fri, 26 Jun 2020 04:02:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728897AbgFZICP (ORCPT ); Fri, 26 Jun 2020 04:02:15 -0400 Received: from casper.infradead.org (unknown [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF991C08C5DB; Fri, 26 Jun 2020 01:02:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Gfq1cduFYABDR3Fkx1QZk2YcbgFvT9xrFNMNKHVTMCk=; b=BFVCZMiF66jSFs2WZSzt5u3sXh Kt0mRsvbQWMJLalnuF8CWJe1ijTXjYfPsErTxAMsV5Qpw5yrjZxInpPpEIaR5MNjozZecaTXlSsER hEZW0EIdKutG50THPjik/dvqEtBmXzSwAf9vuRqGEpKHZmPvW8z9XauIB/G9pRU2ZS7blhdyWEInS LYpn6ompzFdQbQI/PZcThONE996q4V6fXk/3VtVPMB4/GTFOPqhfAmjSmIFdqhJqufOAjB06B6yZt 28poHFKuOZoyKbRyoA8hX71XP4c+XFPf1mCI59JVPSdbjkoPzS96yRJPD4PjvGGhdDk4Zn5L5JOgo kfMj9HRQ==; Received: from [2001:4bb8:184:76e3:2b32:1123:bea8:6121] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jojJA-0007U7-Fd; Fri, 26 Jun 2020 08:02:00 +0000 From: Christoph Hellwig To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] floppy: use block_size Date: Fri, 26 Jun 2020 10:01:52 +0200 Message-Id: <20200626080158.1998621-2-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200626080158.1998621-1-hch@lst.de> References: <20200626080158.1998621-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Use the block_size helper instead of open coding it. Also remove the check for a 0 block size, as that can't happen. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- drivers/block/floppy.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 3e9db22db2a8f5..09079aee8dc430 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -4205,7 +4205,6 @@ static int __floppy_read_block_0(struct block_device *bdev, int drive) struct bio_vec bio_vec; struct page *page; struct rb0_cbdata cbdata; - size_t size; page = alloc_page(GFP_NOIO); if (!page) { @@ -4213,15 +4212,11 @@ static int __floppy_read_block_0(struct block_device *bdev, int drive) return -ENOMEM; } - size = bdev->bd_block_size; - if (!size) - size = 1024; - cbdata.drive = drive; bio_init(&bio, &bio_vec, 1); bio_set_dev(&bio, bdev); - bio_add_page(&bio, page, size, 0); + bio_add_page(&bio, page, block_size(bdev), 0); bio.bi_iter.bi_sector = 0; bio.bi_flags |= (1 << BIO_QUIET); From patchwork Fri Jun 26 08:01:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11626793 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8F43060D for ; Fri, 26 Jun 2020 08:02:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 62F612080C for ; Fri, 26 Jun 2020 08:02:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Tr0LpnC7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728947AbgFZICS (ORCPT ); Fri, 26 Jun 2020 04:02:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728897AbgFZICS (ORCPT ); Fri, 26 Jun 2020 04:02:18 -0400 Received: from casper.infradead.org (unknown [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BE35C08C5C1; Fri, 26 Jun 2020 01:02:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=Ni2URhuc9te1qeMjNRucMQFs47oTeEDvY2kr+szm/Yg=; b=Tr0LpnC7W1v9s1FvHEZkSOLj0W NItkNofirCBDVRZ5XMw3Av7I6IdfdW8I9+n02PGXDDLCN+UFz3mG5DFSdSsQkoyOZ9Y+Rs9wXecOP eKH+GBFWgUWGxvbal5jSufk7DcCzzalQoA484KQUTuu4T2Ii3NS4ajO2+QeN/2WAZ57dqm43D1CbW oL12VARay11IIizloJRjw3oQHmBmQsG3WyB5S1bPF7dg73zAtR6bMP8DWF9u9vGfUi8OaNSzoaUC6 Y/WvmZGPZ1RvIjxNuPfP7d2JJa58vRxiIDe6S57of3W1/WuHl3GMaH7LQM85F59XDNWj3Zl4TQxpT Fzfuu9Kg==; Received: from [2001:4bb8:184:76e3:2b32:1123:bea8:6121] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jojJB-0007UF-JD; Fri, 26 Jun 2020 08:02:01 +0000 From: Christoph Hellwig To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] dcssblk: don't set bd_block_size in ->open Date: Fri, 26 Jun 2020 10:01:53 +0200 Message-Id: <20200626080158.1998621-3-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200626080158.1998621-1-hch@lst.de> References: <20200626080158.1998621-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org bd_block_size contains a value that matches the logic block size when opening, so the statement is redundant. Even if it wasn't the dumb assignment would cause a a mismatch with bd_inode->i_blkbits. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- drivers/s390/block/dcssblk.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 384edffe5cb4ae..9c22c6078a4662 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c @@ -833,7 +833,6 @@ dcssblk_open(struct block_device *bdev, fmode_t mode) goto out; } atomic_inc(&dev_info->use_count); - bdev->bd_block_size = 4096; rc = 0; out: return rc; From patchwork Fri Jun 26 08:01:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11626795 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4905E60D for ; Fri, 26 Jun 2020 08:02:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 266112080C for ; Fri, 26 Jun 2020 08:02:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Pj2a3nKj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728957AbgFZICn (ORCPT ); Fri, 26 Jun 2020 04:02:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728988AbgFZICT (ORCPT ); Fri, 26 Jun 2020 04:02:19 -0400 Received: from casper.infradead.org (unknown [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4256FC08C5C1; Fri, 26 Jun 2020 01:02:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=sFxMoqE2sgnbFCbegAWrrjwEvJ1szu0FusAr7R3A7+U=; b=Pj2a3nKjCPDnhBKe1cprUXuAso rogZ01V9oli2s1pfDjkyyLLz4sr1K6k0CLSJ4x0Mc+mRR0YwB7WNTQxfiAItS/waTrwk+2iGVDsq8 h/v/413uGqkSZlwp7VXdbkYhq8MNU5Sas9fxRYBclVi1F+YIIiyZor9go4vMJL10d3m5jbTAKc90Z n9ZmibmqV0c5MKeb6bLb3+w7+srfhGXqweRkd+fNx0EPQLO9ATBzyUupvAzF7beFYWF9yTm5HeRiK tURVS4oiN6YsDT89gS/3QsVgT4lZP8kh0GVfBPvsdknuQHh0e0b6egpkogFSqZl5/v5XWBOeE2cO7 VquVCCaA==; Received: from [2001:4bb8:184:76e3:2b32:1123:bea8:6121] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jojJC-0007UN-PI; Fri, 26 Jun 2020 08:02:02 +0000 From: Christoph Hellwig To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] block: simplify set_init_blocksize Date: Fri, 26 Jun 2020 10:01:54 +0200 Message-Id: <20200626080158.1998621-4-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200626080158.1998621-1-hch@lst.de> References: <20200626080158.1998621-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The loop to increase the initial block size doesn't really make any sense, as the AND operation won't match for powers of two if it didn't for the initial block size. Signed-off-by: Christoph Hellwig --- fs/block_dev.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 0e0d43dc27d331..8b7a9c76d33edf 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -106,13 +106,7 @@ EXPORT_SYMBOL(invalidate_bdev); static void set_init_blocksize(struct block_device *bdev) { unsigned bsize = bdev_logical_block_size(bdev); - loff_t size = i_size_read(bdev->bd_inode); - while (bsize < PAGE_SIZE) { - if (size & bsize) - break; - bsize <<= 1; - } bdev->bd_block_size = bsize; bdev->bd_inode->i_blkbits = blksize_bits(bsize); } From patchwork Fri Jun 26 08:01:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11626785 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76A9C60D for ; Fri, 26 Jun 2020 08:02:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EAFD208C7 for ; Fri, 26 Jun 2020 08:02:28 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="ZIgk6vuk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729014AbgFZICX (ORCPT ); Fri, 26 Jun 2020 04:02:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728991AbgFZICU (ORCPT ); Fri, 26 Jun 2020 04:02:20 -0400 Received: from casper.infradead.org (unknown [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7184CC08C5DB; Fri, 26 Jun 2020 01:02:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=VUTyrs7EBN/PE5iFqQDA52UEXg/oSXucsE4GbfE4658=; b=ZIgk6vukccFW6Vyo8Z8cULVTQy tb5sp/ROJU/u6OwDBCxg4nS2+1bQsg4sYf2BdCoZ+XEURqny+C63v4t31CbIJiawonhcpQ5X+tP8Z Wo1qgTgGSoUB4ONNk8WedM95EQYLkSLyO/hmQ2PuODUMo41PlckifS3jT2Yuw9bmR39OLEFgyBNft +ZEZceL+XT9ra949xi3l8JY47WaBIXlwnCGP0DW0+looYoyyCcAcpigXB+t4Pw04zL28RQoa0FeMf xZK7aPwQCQcDzWeUj+D4RdLBWIVr1Ed5Q1wuSsOa53zpoloGYP/aQk+7BpWP+4FLJ4YluQazVDAo3 ySxa7tMw==; Received: from [2001:4bb8:184:76e3:2b32:1123:bea8:6121] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jojJD-0007UT-V9; Fri, 26 Jun 2020 08:02:04 +0000 From: Christoph Hellwig To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] block: remove the bd_block_size field from struct block_device Date: Fri, 26 Jun 2020 10:01:55 +0200 Message-Id: <20200626080158.1998621-5-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200626080158.1998621-1-hch@lst.de> References: <20200626080158.1998621-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org We can trivially calculate the block size from the inodes i_blkbits variable. Use that instead of keeping two redundant copies of the information in slightly different formats. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- fs/block_dev.c | 9 ++------- include/linux/blk_types.h | 1 - include/linux/blkdev.h | 2 +- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 8b7a9c76d33edf..06d31e459048ad 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -105,10 +105,7 @@ EXPORT_SYMBOL(invalidate_bdev); static void set_init_blocksize(struct block_device *bdev) { - unsigned bsize = bdev_logical_block_size(bdev); - - bdev->bd_block_size = bsize; - bdev->bd_inode->i_blkbits = blksize_bits(bsize); + bdev->bd_inode->i_blkbits = blksize_bits(bdev_logical_block_size(bdev)); } int set_blocksize(struct block_device *bdev, int size) @@ -122,9 +119,8 @@ int set_blocksize(struct block_device *bdev, int size) return -EINVAL; /* Don't change the size if it is same as current */ - if (bdev->bd_block_size != size) { + if (bdev->bd_inode->i_blkbits != blksize_bits(size)) { sync_blockdev(bdev); - bdev->bd_block_size = size; bdev->bd_inode->i_blkbits = blksize_bits(size); kill_bdev(bdev); } @@ -889,7 +885,6 @@ struct block_device *bdget(dev_t dev) bdev->bd_contains = NULL; bdev->bd_super = NULL; bdev->bd_inode = inode; - bdev->bd_block_size = i_blocksize(inode); bdev->bd_part_count = 0; bdev->bd_invalidated = 0; inode->i_mode = S_IFBLK; diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index a602132cbe32c2..b01cd19bbe8a6e 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -33,7 +33,6 @@ struct block_device { struct list_head bd_holder_disks; #endif struct block_device * bd_contains; - unsigned bd_block_size; u8 bd_partno; struct hd_struct * bd_part; /* number of times partitions within this device have been opened. */ diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 15497782c17656..752a4b771e2f2f 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1548,7 +1548,7 @@ static inline unsigned int blksize_bits(unsigned int size) static inline unsigned int block_size(struct block_device *bdev) { - return bdev->bd_block_size; + return 1 << bdev->bd_inode->i_blkbits; } int kblockd_schedule_work(struct work_struct *work); From patchwork Fri Jun 26 08:01:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11626787 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7489060D for ; Fri, 26 Jun 2020 08:02:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5BA48208C7 for ; Fri, 26 Jun 2020 08:02:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="WgwKN5n/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729081AbgFZIC1 (ORCPT ); Fri, 26 Jun 2020 04:02:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729073AbgFZICZ (ORCPT ); Fri, 26 Jun 2020 04:02:25 -0400 Received: from casper.infradead.org (unknown [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDE6FC08C5DB; Fri, 26 Jun 2020 01:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=9TwHQN5otZ7PBNa1KtFbOqjvaBuTORubLW27TUGLV0I=; b=WgwKN5n/SDLSGIBhtCb+1ksjtQ nbZpZVKOSUPlcA4HFM7kMO1ljNUraod4RxKvD8VbMBA2rTEVit2i6WY86oqBhZbwIec8JNNa3PXmD d/lXHEoukxHDqTaOLyYlyC19d8uV/ELR8IKeMj8CoNYwWfnv7QBrmcmngiXAlxnrbgDmnCuMpALMA g2e82hLI3RbG51uYLsJpe6VI8Gp/P4i1sVcGLZ3QouKyNAE5pD0L6+DIGC/VegIFaZbORUFvbNkzX tx2ezkDZwKWjChynBctKqwBD/pJT62Ore7A05Pq0LUUd0Wrv6icxwftuOGz0zpCCuErFa0uWzyGtl 3/ueKifg==; Received: from [2001:4bb8:184:76e3:2b32:1123:bea8:6121] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jojJF-0007UY-27; Fri, 26 Jun 2020 08:02:05 +0000 From: Christoph Hellwig To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] block: remove the bd_queue field from struct block_device Date: Fri, 26 Jun 2020 10:01:56 +0200 Message-Id: <20200626080158.1998621-6-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200626080158.1998621-1-hch@lst.de> References: <20200626080158.1998621-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Just use bd_disk->queue instead. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- drivers/dax/super.c | 2 +- drivers/md/md.c | 2 +- drivers/nvme/target/core.c | 2 +- fs/block_dev.c | 11 ++++------- fs/direct-io.c | 4 ++-- fs/xfs/xfs_pwork.c | 2 +- include/linux/blk_types.h | 1 - mm/swapfile.c | 2 +- 8 files changed, 11 insertions(+), 15 deletions(-) diff --git a/drivers/dax/super.c b/drivers/dax/super.c index 8e32345be0f743..f508285263319b 100644 --- a/drivers/dax/super.c +++ b/drivers/dax/super.c @@ -59,7 +59,7 @@ EXPORT_SYMBOL(bdev_dax_pgoff); #if IS_ENABLED(CONFIG_FS_DAX) struct dax_device *fs_dax_get_by_bdev(struct block_device *bdev) { - if (!blk_queue_dax(bdev->bd_queue)) + if (!blk_queue_dax(bdev->bd_disk->queue)) return NULL; return dax_get_by_host(bdev->bd_disk->disk_name); } diff --git a/drivers/md/md.c b/drivers/md/md.c index f567f536b529bd..6f13c6d328ba7b 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -199,7 +199,7 @@ static int rdevs_init_serial(struct mddev *mddev) static int rdev_need_serial(struct md_rdev *rdev) { return (rdev && rdev->mddev->bitmap_info.max_write_behind > 0 && - rdev->bdev->bd_queue->nr_hw_queues != 1 && + rdev->bdev->bd_disk->queue->nr_hw_queues != 1 && test_bit(WriteMostly, &rdev->flags)); } diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c index 6e2f623e472e9f..6816507fba58a6 100644 --- a/drivers/nvme/target/core.c +++ b/drivers/nvme/target/core.c @@ -467,7 +467,7 @@ static int nvmet_p2pmem_ns_enable(struct nvmet_ns *ns) return -EINVAL; } - if (!blk_queue_pci_p2pdma(ns->bdev->bd_queue)) { + if (!blk_queue_pci_p2pdma(ns->bdev->bd_disk->queue)) { pr_err("peer-to-peer DMA is not supported by the driver of %s\n", ns->device_path); return -EINVAL; diff --git a/fs/block_dev.c b/fs/block_dev.c index 06d31e459048ad..68cb08bc1b7a65 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -693,12 +693,12 @@ int bdev_read_page(struct block_device *bdev, sector_t sector, if (!ops->rw_page || bdev_get_integrity(bdev)) return result; - result = blk_queue_enter(bdev->bd_queue, 0); + result = blk_queue_enter(bdev->bd_disk->queue, 0); if (result) return result; result = ops->rw_page(bdev, sector + get_start_sect(bdev), page, REQ_OP_READ); - blk_queue_exit(bdev->bd_queue); + blk_queue_exit(bdev->bd_disk->queue); return result; } @@ -729,7 +729,7 @@ int bdev_write_page(struct block_device *bdev, sector_t sector, if (!ops->rw_page || bdev_get_integrity(bdev)) return -EOPNOTSUPP; - result = blk_queue_enter(bdev->bd_queue, 0); + result = blk_queue_enter(bdev->bd_disk->queue, 0); if (result) return result; @@ -742,7 +742,7 @@ int bdev_write_page(struct block_device *bdev, sector_t sector, clean_page_buffers(page); unlock_page(page); } - blk_queue_exit(bdev->bd_queue); + blk_queue_exit(bdev->bd_disk->queue); return result; } @@ -1568,7 +1568,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) if (!bdev->bd_openers) { first_open = true; bdev->bd_disk = disk; - bdev->bd_queue = disk->queue; bdev->bd_contains = bdev; bdev->bd_partno = partno; @@ -1589,7 +1588,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) disk_put_part(bdev->bd_part); bdev->bd_part = NULL; bdev->bd_disk = NULL; - bdev->bd_queue = NULL; mutex_unlock(&bdev->bd_mutex); disk_unblock_events(disk); put_disk_and_module(disk); @@ -1666,7 +1664,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) disk_put_part(bdev->bd_part); bdev->bd_disk = NULL; bdev->bd_part = NULL; - bdev->bd_queue = NULL; if (bdev != bdev->bd_contains) __blkdev_put(bdev->bd_contains, mode, 1); bdev->bd_contains = NULL; diff --git a/fs/direct-io.c b/fs/direct-io.c index 6d5370eac2a8f2..183299892465af 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c @@ -1387,8 +1387,8 @@ ssize_t __blockdev_direct_IO(struct kiocb *iocb, struct inode *inode, * Attempt to prefetch the pieces we likely need later. */ prefetch(&bdev->bd_disk->part_tbl); - prefetch(bdev->bd_queue); - prefetch((char *)bdev->bd_queue + SMP_CACHE_BYTES); + prefetch(bdev->bd_disk->queue); + prefetch((char *)bdev->bd_disk->queue + SMP_CACHE_BYTES); return do_blockdev_direct_IO(iocb, inode, bdev, iter, get_block, end_io, submit_io, flags); diff --git a/fs/xfs/xfs_pwork.c b/fs/xfs/xfs_pwork.c index 4bcc3e61056c8c..b03333f1c84ad0 100644 --- a/fs/xfs/xfs_pwork.c +++ b/fs/xfs/xfs_pwork.c @@ -132,5 +132,5 @@ xfs_pwork_guess_datadev_parallelism( * For now we'll go with the most conservative setting possible, * which is two threads for an SSD and 1 thread everywhere else. */ - return blk_queue_nonrot(btp->bt_bdev->bd_queue) ? 2 : 1; + return blk_queue_nonrot(btp->bt_bdev->bd_disk->queue) ? 2 : 1; } diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index b01cd19bbe8a6e..667cd365fd048b 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -39,7 +39,6 @@ struct block_device { unsigned bd_part_count; int bd_invalidated; struct gendisk * bd_disk; - struct request_queue * bd_queue; struct backing_dev_info *bd_bdi; struct list_head bd_list; /* diff --git a/mm/swapfile.c b/mm/swapfile.c index 987276c557d1f1..6c26916e95fd4a 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2929,7 +2929,7 @@ static int claim_swapfile(struct swap_info_struct *p, struct inode *inode) * write only restriction. Hence zoned block devices are not * suitable for swapping. Disallow them here. */ - if (blk_queue_is_zoned(p->bdev->bd_queue)) + if (blk_queue_is_zoned(p->bdev->bd_disk->queue)) return -EINVAL; p->flags |= SWP_BLKDEV; } else if (S_ISREG(inode->i_mode)) { From patchwork Fri Jun 26 08:01:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11626789 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2AD1F60D for ; Fri, 26 Jun 2020 08:02:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CDE620857 for ; Fri, 26 Jun 2020 08:02:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="Y9/ALGJU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729079AbgFZIC1 (ORCPT ); Fri, 26 Jun 2020 04:02:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728991AbgFZICZ (ORCPT ); Fri, 26 Jun 2020 04:02:25 -0400 Received: from casper.infradead.org (unknown [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC7CFC08C5C1; Fri, 26 Jun 2020 01:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=fikc6nDJBnapn/gvMFVI+fD2hAoS13bz5dg08VzBCZU=; b=Y9/ALGJUTvdXtWSkpKPJm6MmT9 xrZ10E/+WGdPXyl4Q5xJ+RF2+E4+hF6zgCqLibmNbzY3o6S6BkUnKFxkM95p3g5GukPV7/LiizxJw CFkLFG8RFhW4wJ0K13YwbctmG0W6ZXit9ZO6dp/durhVredHL8JEUa4XPJ8V+sVUmBpy1BrNUtrLs 6rGm/wi4HgxlwTvs+qP7n42rwJ3LT3fbtMamMS+s40qH4M3nRkzdpzAWWAFBPmVRrybRMOhhN1/cO GRAhqPPzS2cq3Xi7k11bPypzFt51fjxzYcX6OYAcArg/RgAmcv515e66oMM5Vt4U3ejmvgjOZ5lfU EnFgOUEw==; Received: from [2001:4bb8:184:76e3:2b32:1123:bea8:6121] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jojJG-0007Ue-6K; Fri, 26 Jun 2020 08:02:06 +0000 From: Christoph Hellwig To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] block: remove the unused bd_private field from struct block_device Date: Fri, 26 Jun 2020 10:01:57 +0200 Message-Id: <20200626080158.1998621-7-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200626080158.1998621-1-hch@lst.de> References: <20200626080158.1998621-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- include/linux/blk_types.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index 667cd365fd048b..b5f7105806e492 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -41,13 +41,6 @@ struct block_device { struct gendisk * bd_disk; struct backing_dev_info *bd_bdi; struct list_head bd_list; - /* - * Private data. You must have bd_claim'ed the block_device - * to use this. NOTE: bd_claim allows an owner to claim - * the same device multiple times, the owner must take special - * care to not mess up bd_private for that case. - */ - unsigned long bd_private; /* The counter of freeze processes */ int bd_fsfreeze_count; From patchwork Fri Jun 26 08:01:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 11626791 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A818360D for ; Fri, 26 Jun 2020 08:02:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 90671208C7 for ; Fri, 26 Jun 2020 08:02:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SQz2Doyz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729076AbgFZIC1 (ORCPT ); Fri, 26 Jun 2020 04:02:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729074AbgFZICZ (ORCPT ); Fri, 26 Jun 2020 04:02:25 -0400 Received: from casper.infradead.org (unknown [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5416C08C5DC; Fri, 26 Jun 2020 01:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=skgjZNjZFXWr2WMevdTakzxqSkNOHAzF+vYdGSjzejg=; b=SQz2DoyzuT2Kt4EqYRMmazNc+B J93iFKFd/X7PfsiqeHP4etAWOHn1Kf+S6YYZXsJI/SeIm0YtheB12U+k6ZF862mKLRO90jdwjD9qt sXpr5BG1hP1YCHfB4QPp9cpTUDUTI4ARBNYIRTq7ft/ckQC8ordsuawOuA8Y98BkPl2Vto0bsXu05 /EMBcWWLrDvFnlunJgg8g05aqllM0lcbCEXc9HfKcPuziu3bwiSsdT6HWaZl/U2Xe78fkruK/pBKF 5GR/EQjhG18UhBmgVnnR5myqnuzCVAOTgrTXBxcw9jk9li2zi8UjWUnV8EC0A7CiYO1lX92Sy2st+ A0dFtkJA==; Received: from [2001:4bb8:184:76e3:2b32:1123:bea8:6121] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jojJH-0007Uk-9E; Fri, 26 Jun 2020 08:02:07 +0000 From: Christoph Hellwig To: axboe@kernel.dk Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/7] block: remove the all_bdevs list Date: Fri, 26 Jun 2020 10:01:58 +0200 Message-Id: <20200626080158.1998621-8-hch@lst.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200626080158.1998621-1-hch@lst.de> References: <20200626080158.1998621-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Instead just iterate over the inodes for the block device superblock. Signed-off-by: Christoph Hellwig Reviewed-by: Johannes Thumshirn --- fs/block_dev.c | 22 +++++++--------------- include/linux/blk_types.h | 1 - 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index 68cb08bc1b7a65..2d2fcb50e78eac 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -773,7 +773,6 @@ static void init_once(void *foo) memset(bdev, 0, sizeof(*bdev)); mutex_init(&bdev->bd_mutex); - INIT_LIST_HEAD(&bdev->bd_list); #ifdef CONFIG_SYSFS INIT_LIST_HEAD(&bdev->bd_holder_disks); #endif @@ -789,9 +788,6 @@ static void bdev_evict_inode(struct inode *inode) truncate_inode_pages_final(&inode->i_data); invalidate_inode_buffers(inode); /* is it needed here? */ clear_inode(inode); - spin_lock(&bdev_lock); - list_del_init(&bdev->bd_list); - spin_unlock(&bdev_lock); /* Detach inode from wb early as bdi_put() may free bdi->wb */ inode_detach_wb(inode); if (bdev->bd_bdi != &noop_backing_dev_info) { @@ -866,8 +862,6 @@ static int bdev_set(struct inode *inode, void *data) return 0; } -static LIST_HEAD(all_bdevs); - struct block_device *bdget(dev_t dev) { struct block_device *bdev; @@ -892,9 +886,6 @@ struct block_device *bdget(dev_t dev) inode->i_bdev = bdev; inode->i_data.a_ops = &def_blk_aops; mapping_set_gfp_mask(&inode->i_data, GFP_USER); - spin_lock(&bdev_lock); - list_add(&bdev->bd_list, &all_bdevs); - spin_unlock(&bdev_lock); unlock_new_inode(inode); } return bdev; @@ -915,13 +906,14 @@ EXPORT_SYMBOL(bdgrab); long nr_blockdev_pages(void) { - struct block_device *bdev; + struct inode *inode; long ret = 0; - spin_lock(&bdev_lock); - list_for_each_entry(bdev, &all_bdevs, bd_list) { - ret += bdev->bd_inode->i_mapping->nrpages; - } - spin_unlock(&bdev_lock); + + spin_lock(&blockdev_superblock->s_inode_list_lock); + list_for_each_entry(inode, &blockdev_superblock->s_inodes, i_sb_list) + ret += inode->i_mapping->nrpages; + spin_unlock(&blockdev_superblock->s_inode_list_lock); + return ret; } diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h index b5f7105806e492..07facaf62b727d 100644 --- a/include/linux/blk_types.h +++ b/include/linux/blk_types.h @@ -40,7 +40,6 @@ struct block_device { int bd_invalidated; struct gendisk * bd_disk; struct backing_dev_info *bd_bdi; - struct list_head bd_list; /* The counter of freeze processes */ int bd_fsfreeze_count;