From patchwork Fri Oct 28 08:45:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Damien Le Moal X-Patchwork-Id: 9401597 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6AF4560588 for ; Fri, 28 Oct 2016 08:46:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 617622A66F for ; Fri, 28 Oct 2016 08:46:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 563512A671; Fri, 28 Oct 2016 08:46:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C15552A66F for ; Fri, 28 Oct 2016 08:46:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758336AbcJ1Iqw (ORCPT ); Fri, 28 Oct 2016 04:46:52 -0400 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:7319 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756407AbcJ1Iqk (ORCPT ); Fri, 28 Oct 2016 04:46:40 -0400 X-IronPort-AV: E=Sophos;i="5.31,557,1473091200"; d="scan'";a="25250735" Received: from mail-bl2nam02lp0083.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([207.46.163.83]) by ob1.hgst.iphmx.com with ESMTP; 28 Oct 2016 16:46:38 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jcZzO+lNvSi+dTZi4ED3ZtDjL5NYwmzWJ1yYjKREd94=; b=lFF9mPVbNBipjjXYI61FGRUhdCCEY1J26ouWTWj/7GVTapPODS4fWNqr8ejkI9Q1ScZuWpll975WTl316uMqVyVdctldhdVTAi3HBRD6nn7vVLK7rO90rQo086P+Cr6rWyxDYwiiSi8ncVHwANSHjv9b9GNCmJcJEs0FAawETXI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Damien.LeMoal@wdc.com; Received: from washi.fujisawa.hgst.com (199.255.47.8) by BY2PR04MB1974.namprd04.prod.outlook.com (10.166.111.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.12; Fri, 28 Oct 2016 08:46:35 +0000 From: Damien Le Moal To: , CC: , , Hannes Reinecke , Shaun Tancheff , Damien Le Moal Subject: [PATCH v2 7/9] f2fs: Cache zoned block devices zone type Date: Fri, 28 Oct 2016 17:45:05 +0900 Message-ID: <1477644307-30115-8-git-send-email-damien.lemoal@wdc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1477644307-30115-1-git-send-email-damien.lemoal@wdc.com> References: <1477644307-30115-1-git-send-email-damien.lemoal@wdc.com> MIME-Version: 1.0 X-Originating-IP: [199.255.47.8] X-ClientProxiedBy: CY1PR19CA0030.namprd19.prod.outlook.com (10.162.38.168) To BY2PR04MB1974.namprd04.prod.outlook.com (10.166.111.14) X-MS-Office365-Filtering-Correlation-Id: d2bc1af9-6438-439b-c129-08d3ff0eed65 X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1974; 2:h1Md7ShA86EDiT5mgmQrZkj//dVQXNyScfAJedMZsJ0sRR5S8zKKoJ5clyqm1B1hYdUuUj6FAJ2Rl65xCcTZxDBJ+/xSTHY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vWfPRzDFZouOtvOFMg0NZb5y8hnFidxuyYdRSAO1JAj2Pz23Q= X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1974; 31:nJwAhq9lS/EtDaOQLjOS42C3Fbz5Csq6uFmxi2e+Zf7+4w7+evD6stRDeGrjw2xaEmkEsgxZu02Tuz4b5Tnkc0MbNI/xn12TyeCHEP4oCEHNqrdVxBZien107schI58WfTFeiWpoD5c7x1etsj7EKL/kz47Nhu8gpeBXM1+ejeP7BzJ/pI0laJGHIFtIRukw4YzG6yY6ftUAZEpw1w4DpnrDmp3T2i3yCoG92OK63auxzbNDonadPejYqKzcWkj41bbLHwUQ/0ShrjMfQDXnCQ==; 20:C5uRFwwpmxP9sS+/l+zEu3Lv7riyQu9+pwl8WjLVjB/FVWjXnT8qBBmSg/Li+eABHmGh1SU+G8X8EyY39i3Cur9LM7MYvV06mvNRFb1spMfNTm5bJ/pScwCW7FkgHySH/DAEtTR9GSwc40WOI44vCYMFsbIyGklvx4WipoKz4tZtAyiIlVU0JkDhB0dJrWjmA/gg7OuO4iXH1tlxYRCakV2CHMuxsChrhHy5V5yXzHnxn5u17QviYFsycCLxvChAw3pGqNSCrxHwJ20K1vk8B1l+6M89nAQhF6Wgb8nUq5y8VNMbWV7buY1cR5vZsTL/g+MHobckP+ZcutZu6D4rvaDLHLWWJWya8ev7angyUOt8PnCjsrTyvb8IesEHidKGDqisvjwRKsKv0jSKpywFc1Y4u144Xqi74gVcSZ6hEecINlACrI3pFkkPIFT2u4WMmdJEIfqXs5lIkef5Y4Ukx5s3WPj4ZMLv5SKr0JB0Mw7cmsFNIwoIfyr9vXU55DY3 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:BY2PR04MB1974; BCL:0; PCL:0; RULEID:; SRVR:BY2PR04MB1974; X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1974; 4:X1cZ5Li9o9gyaiE3fGHN3rdtzJ4Bil+ZiQ8ASRcXz1dHZ60FasKws/IyZWW7GKOIByY/KVhIIB/tfhmKZQrH+LJBEWZl5cgbOm7GEYl2uqHYK9oHtiDdNQqkoGEk/F2RmmzNZclIsKSCLslA7C4SZryB7l5s6rF8zyZNw+c8ch8Hk3jZ961gCWBnDh1Kq46I5DY5GWCKsNDaam6tR4trYiSC20UaeRSb6Kg0mamUggiDkCJOegx6Ge2WXCnx1gTRVMCFOw/bxMQdYNrfcLN3K1/3a9ryHcdo+EpYHMAzlrjwi4Ga4/on5czkdIY25JsoBQEdTVfRsT5FXuodgqqFd2lzHq7hxCBbQBE8RFOWjP1MK41RTL72Iv6iQ8K+idJBc7tiIwImYMhjoEJqDguK7zSn7fx4Vry066MsxA2+ZNY= X-Forefront-PRVS: 0109D382B0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(76176999)(2950100002)(50986999)(305945005)(42186005)(7846002)(6666003)(4326007)(86362001)(7736002)(5660300001)(106356001)(81166006)(81156014)(66066001)(47776003)(68736007)(48376002)(105586002)(8676002)(50466002)(5003940100001)(229853001)(92566002)(50226002)(101416001)(33646002)(19580405001)(586003)(6116002)(19580395003)(3846002)(36756003)(77096005)(189998001)(5001770100001)(2906002)(97736004)(7099028); DIR:OUT; SFP:1102; SCL:1; SRVR:BY2PR04MB1974; H:washi.fujisawa.hgst.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: wdc.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR04MB1974; 23:Uzhkff4S2SuoSHafloinRbEEQzUbWTyiykRNqt1Cj?= =?us-ascii?Q?/OUjLWJYCYu7gzeEXgsPIMHybtN0J2vQ5kvfm6fJpUXnqg4xdrbr7GQ+oBd4?= =?us-ascii?Q?QXC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HjKieDT9FK2xg1K1AH6Rj?= =?us-ascii?Q?GKy9kyvFD2ahIiNW5ktWWhvO1JBbqo9PVya5UA7xCg1yUEV+K1geQh1Aj6a6?= =?us-ascii?Q?uiJc8qhkObWCrxmM8mJhWKh2vkV?= X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1974; 6:6GUvVdCyUn+A7FgmYK0+c9LwLOM0nH+TYCrxhqiC3OZOzyjwU834F+UUEjl9carm5bmtLB69Y6ZjkevOktxosZewahc9vPUL5BNh/Yzwix90/GczBxaGnGNk1qKtLxdiCbUbhBHa2HR7CqpkIDrTQ6/eHDzsRtvnCz237Gv6w8djNF7HzH1g/pnfuLzyQ213GrXzzmE9I6tTcesyitrVEQ/Gh82krpx3xST2ssbO5z6UP44BYaVRPcUpRNuLSXsRWWLcwZ4xti1IEUC7zGIgph3l8XrLUNo3tc68wKLE4+nsL4+399O6OIVjqi+DqQxBRzxkAFcgvVpaRY5DvGsOaCFZCgIuCBDBYDhYzVRetM0=; 5:mJN9GwxQyTSDQkzI5Uid5IMtjHfWjU0bQsuXENPIyjy4OXTNkEmX8uAlZGi7N6Ay2G1P46iqv7G42Wi9QD8ENHgdX19XCJxJpV7Rwk52ryZGQPTTOQlnGBRago9xtao/UoJ2ZQ34hI3Y3xAYiKHaaQ==; 24:I/qmoGp+yhyinV1XDNO+xf+QEobm7PObEaveuqgLNYG8c2q4+Qeru6E1EresSpGKccizHIbEshfWhCU2ksQs5D7pIZYVZ+slYTHBIhYy+LM= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BY2PR04MB1974; 7:yyG6Vo5LjJdWj1QTxaQXoxkYouOREGm9F4qg9ak4tHzjV6L9i+foWgT4EiGXTWVD8sdxwUgjnQXSBYvSN0MaNUORLs/wJQ7DNwy+7dhMTwx1C1K6Iyf+1+Z3T+u+K8UGyhiUn6w8h25+so3tVjB7O0AzW4a82FznXfvsPSd0B18TwB+4M2JybaY8P1vYErcjkJpMpiWAAEOlZ/E0PomEaikkS3qRkYJLTo15k9FPXH50m8aw9XDbVPw9CFWEpr6r+U+iIm2lqkKg7Q3l9CKJLZpIcw4IsI0Svdq7y5LIUUPX56ae2X2lGAO/AV0m0gRKkQYt/2Z1Ig3qInDVDUCWu/ye+xvBhqCeI1/rc2MpfPE=; 20:oQU0g+T8qi1+c5WLVbkqrdc0Hh/d+q6v1YHlfk38yH9HhYcK1rPsxhxoqZBr9ULmgqlfDFjyjks8uk4wBu68HW+d8qsggqJJrAQ1Nazuu0urIwva8Yqg1YdeY02C84juyU7Du+duSXKOsUw7Bt7hO5g4hjxFkPmu5RqFywZ+pTB16U0ZUbkrJmDRDGhQ0hJ5j9TVJ9Pxei3DIbUDYC5k5Fc98DV2ME4vlv/udF8ywOqKj5EeJCdu9FgI72QMasj2 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2016 08:46:35.2153 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR04MB1974 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP With the zoned block device feature enabled, section discard need to do a zone reset for sections contained in sequential zones, and a regular discard (if supported) for sections stored in conventional zones. Avoid the need for a costly report zones to obtain a section zone type when discarding it by caching the types of the device zones in the super block information. This cache is initialized at mount time for mounts with the zoned block device feature enabled. Signed-off-by: Damien Le Moal --- fs/f2fs/f2fs.h | 18 +++++++++++++++ fs/f2fs/super.c | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index beb2093..a1a074d 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -750,6 +750,14 @@ struct f2fs_sb_info { u8 key_prefix[F2FS_KEY_DESC_PREFIX_SIZE]; u8 key_prefix_size; #endif + +#ifdef CONFIG_BLK_DEV_ZONED + unsigned int nr_blkz; /* Total number of zones */ + unsigned int blocks_per_blkz; /* F2FS blocks per zone */ + unsigned int log_blocks_per_blkz; /* log2 F2FS blocks per zone */ + u8 *blkz_type; /* Array of zones type */ +#endif + /* for node-related operations */ struct f2fs_nm_info *nm_info; /* node manager */ struct inode *node_inode; /* cache node blocks */ @@ -2410,6 +2418,16 @@ static inline int f2fs_sb_mounted_blkzoned(struct super_block *sb) return F2FS_HAS_FEATURE(sb, F2FS_FEATURE_BLKZONED); } +#ifdef CONFIG_BLK_DEV_ZONED +static inline int get_blkz_type(struct f2fs_sb_info *sbi, + block_t blkaddr) +{ + unsigned int zno = blkaddr >> sbi->log_blocks_per_blkz; + + return sbi->blkz_type[zno]; +} +#endif + static inline bool f2fs_discard_en(struct f2fs_sb_info *sbi) { struct request_queue *q = bdev_get_queue(sbi->sb->s_bdev); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 58fd69d..2b7880d 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -1515,6 +1515,65 @@ static int init_percpu_info(struct f2fs_sb_info *sbi) GFP_KERNEL); } +#ifdef CONFIG_BLK_DEV_ZONED +static int init_blkz_info(struct f2fs_sb_info *sbi) +{ + struct block_device *bdev = sbi->sb->s_bdev; + sector_t nr_sectors = bdev->bd_part->nr_sects; + sector_t sector = 0; + struct blk_zone *zones; + unsigned int i, nr_zones; + unsigned int n = 0; + int err = -EIO; + + if (!f2fs_sb_mounted_blkzoned(sbi->sb)) + return 0; + + sbi->blocks_per_blkz = SECTOR_TO_BLOCK(bdev_zone_size(bdev)); + sbi->log_blocks_per_blkz = __ilog2_u32(sbi->blocks_per_blkz); + sbi->nr_blkz = SECTOR_TO_BLOCK(nr_sectors) >> + sbi->log_blocks_per_blkz; + if (nr_sectors & (bdev_zone_size(bdev) - 1)) + sbi->nr_blkz++; + + sbi->blkz_type = kmalloc(sbi->nr_blkz, GFP_KERNEL); + if (!sbi->blkz_type) + return -ENOMEM; + +#define F2FS_REPORT_NR_ZONES 4096 + + zones = kcalloc(F2FS_REPORT_NR_ZONES, sizeof(struct blk_zone), + GFP_KERNEL); + if (!zones) + return -ENOMEM; + + /* Get block zones type */ + while (zones && sector < nr_sectors) { + + nr_zones = F2FS_REPORT_NR_ZONES; + err = blkdev_report_zones(bdev, sector, + zones, &nr_zones, + GFP_KERNEL); + if (err) + break; + if (!nr_zones) { + err = -EIO; + break; + } + + for (i = 0; i < nr_zones; i++) { + sbi->blkz_type[n] = zones[i].type; + sector += zones[i].len; + n++; + } + } + + kfree(zones); + + return err; +} +#endif + /* * Read f2fs raw super block. * Because we have two copies of super block, so read both of them @@ -1761,6 +1820,15 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) init_ino_entry_info(sbi); +#ifdef CONFIG_BLK_DEV_ZONED + err = init_blkz_info(sbi); + if (err) { + f2fs_msg(sb, KERN_ERR, + "Failed to initialize F2FS blkzone information"); + goto free_blkz; + } +#endif + /* setup f2fs internal modules */ err = build_segment_manager(sbi); if (err) { @@ -1932,6 +2000,10 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent) destroy_node_manager(sbi); free_sm: destroy_segment_manager(sbi); +#ifdef CONFIG_BLK_DEV_ZONED +free_blkz: + kfree(sbi->blkz_type); +#endif kfree(sbi->ckpt); free_meta_inode: make_bad_inode(sbi->meta_inode);