From patchwork Thu Aug 9 18:10:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naohiro Aota X-Patchwork-Id: 10561671 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3190613BB for ; Thu, 9 Aug 2018 18:12:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1D5342B7FB for ; Thu, 9 Aug 2018 18:12:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1176B2B814; Thu, 9 Aug 2018 18:12:34 +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=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,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 913C62B7FB for ; Thu, 9 Aug 2018 18:12:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727325AbeHIUhZ (ORCPT ); Thu, 9 Aug 2018 16:37:25 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:40697 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726882AbeHIUhZ (ORCPT ); Thu, 9 Aug 2018 16:37:25 -0400 Received: by mail-pg1-f196.google.com with SMTP id x5-v6so3110314pgp.7; Thu, 09 Aug 2018 11:11:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=NbmpInz5/joKYbzaioP/45OSGEcNKQUls8Zih/tMAyA=; b=PpDfi8/3zCXQAWOTly/hgj2fVILbBAR/v1v/oAR4VkoW0JyMySKDDJbh8tSSx7A5tP GWfBTZqXIm0Rr2sw3REdv6oX8lY0uG4U9ho4clFIn+7GYon4E0RvWSaETIG6H+iRLJR4 bu/uD9us01N1nxqsV/U6DZWi745nP2Qu/PUs/j9xxxivZ2Oxfe2LHL55UpSqvLb8fR9U /ZEGQ3gbkgg6CfdLjKLLfNxrC9rdnFz+K7KGQ6QfLF+OYweCbj3n6tnsBN/CMOOFRdlJ jI+Eo7ybOGqs76KmBmycTK2SCGSL7H5RDVpoKnlp+aFmzyo0BWeb5+UlMifP4L0RgXz2 YuuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=NbmpInz5/joKYbzaioP/45OSGEcNKQUls8Zih/tMAyA=; b=j43Tu96wsGPFNjfHI1JMN0YvsxyDGIQ1SWE0eW5I5YbCuhudZ5zwWcsr1sGqio8GW8 XPGsqg053VWe11Rsj7OZo4csPE2Z42gVi6v96NQ34pjSM5+Xmq46jPbt3HKuxU6S00Z/ VKUr88De/ttBSr4m6PaKwy6Kt6sbnHY+/uo/y0EBbuF7jjLanar0ka72IjSogZDu45Ae Bt1SP/fOJE9hPwZIruvrpjOktSoEq5yB825oUdIAHQ+Vcjo5qiUJaGfFhYlTDoDOJmrt AGg1Yue9enGBQqqayOmnT11dks0a9nN7G02ecSwRfCuf5izUvHzzU1536H9KI48/M2qU rlKw== X-Gm-Message-State: AOUpUlGEIFIFzT7d3EjUJxm7u8heCTtcy/t9wHFhfmN262omwmTt4jVB iJP2bfLEbAysc4nJc4diMlA= X-Google-Smtp-Source: AA+uWPw9TNS57HDQ/KEKkC4gS5NfT7obFwEDNPSStVTnwWkjjfhNU5gxk525k+iu+x1Qchubc0jnBQ== X-Received: by 2002:a63:4386:: with SMTP id q128-v6mr3130277pga.353.1533838284236; Thu, 09 Aug 2018 11:11:24 -0700 (PDT) Received: from localhost (h101-111-148-072.catv02.itscom.jp. [101.111.148.72]) by smtp.gmail.com with ESMTPSA id e14-v6sm9778335pff.128.2018.08.09.11.11.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Aug 2018 11:11:23 -0700 (PDT) From: Naohiro Aota To: David Sterba , linux-btrfs@vger.kernel.org Cc: Chris Mason , Josef Bacik , linux-kernel@vger.kernel.org, Hannes Reinecke , Damien Le Moal , Bart Van Assche , Matias Bjorling , Naohiro Aota Subject: [RFC PATCH 06/12] btrfs-progs: avoid writing super block to sequential zones Date: Fri, 10 Aug 2018 03:10:59 +0900 Message-Id: <20180809181105.12856-6-naota@elisp.net> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809181105.12856-1-naota@elisp.net> References: <20180809180450.5091-1-naota@elisp.net> <20180809181105.12856-1-naota@elisp.net> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is not possible to write a super block copy in sequential write required zones as this prevents in-place updates required for super blocks. This patch limits super block possible locations to zones accepting random writes. In particular, the zone containing the first block of the device or partition being formatted must accept random writes. Signed-off-by: Naohiro Aota --- disk-io.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/disk-io.c b/disk-io.c index 26e4f6e9..127d8cf4 100644 --- a/disk-io.c +++ b/disk-io.c @@ -1523,6 +1523,7 @@ static int write_dev_supers(struct btrfs_fs_info *fs_info, struct btrfs_super_block *sb, struct btrfs_device *device) { + struct btrfs_zone_info *zinfo = &device->zinfo; u64 bytenr; u32 crc; int i, ret; @@ -1534,6 +1535,11 @@ static int write_dev_supers(struct btrfs_fs_info *fs_info, BTRFS_SUPER_INFO_SIZE - BTRFS_CSUM_SIZE); btrfs_csum_final(crc, &sb->csum[0]); + if (!zone_is_random_write(zinfo, fs_info->super_bytenr)) { + ret = -EIO; + goto write_err; + } + /* * super_copy is BTRFS_SUPER_INFO_SIZE bytes and is * zero filled, we can use it directly @@ -1550,6 +1556,8 @@ static int write_dev_supers(struct btrfs_fs_info *fs_info, bytenr = btrfs_sb_offset(i); if (bytenr + BTRFS_SUPER_INFO_SIZE > device->total_bytes) break; + if (!zone_is_random_write(zinfo, bytenr)) + continue; btrfs_set_super_bytenr(sb, bytenr);