Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2343827imm; Thu, 9 Aug 2018 11:12:46 -0700 (PDT) X-Google-Smtp-Source: AA+uWPyKRPzp1Jkjvh1nIIez7ynvtKtbXzOZhzmpQw2PPSGjPEMgVpFbNyJ6UQ7yc10IWXFvaSWp X-Received: by 2002:a62:ad1:: with SMTP id 78-v6mr3455009pfk.57.1533838365942; Thu, 09 Aug 2018 11:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533838365; cv=none; d=google.com; s=arc-20160816; b=l5xY5u1ZG2PIhUbVxUegVgm/uni6yydCBl20mhmyxhKs8VygclZWH5DqLvI2CobIIZ thpp/D0wLaiSGbbF7lemlujkxRteoTj52settWuejtGsZmYLUrKyI/QqF1KjanSLG6y/ OJCQwz8AA6KjIUTWKKNfkX05xoAI+bI1KzqeH3ECRbaFmtDbSNxwvC5H9nCSsGv0uwHF 7JjIsGIaF8+e90qA6vGMwfbhJWY04w4x+vdQjUpz1LykWvZk5mHRzexUFJ6BFl0oys2o oR9Epwx/XJ2cYjUxIr+0XE3ulFOfbrlrZoU1MrvN++tQ1uGX+wAS6qdN+L20ADclJ2dI BLpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=NbmpInz5/joKYbzaioP/45OSGEcNKQUls8Zih/tMAyA=; b=zZqxqtnRTHszno1YKmqDhus34Tra0dbT0yjcGBNZxpLKGDcDxhpISrtRY+WtvYDORP xJG7UUsJ5DPPJNp9eGWaf0yrJ7CfQzhwnM/BbW4ReDy96e9H7H2njEPhJkGzmVt0Gz+R 6EEJ8hOFQla5TFX50RpBLXpBkx9Y6wnFKIj9MeNNbhq4t4qf3/d290pytSURmdGF6bMr pZr3VIfS9TBhzzfODTQm1DN5cqvIvApHdNJC5DRO4RrUi7nkxudp1F0JEnpVAqwVeSAG AM2tLusxTnf0sihR5dQmdTDhBH7ja6zYTItPta+ikLOUXfIdX27t+ZkssJjqBmPaZdju JNpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="PpDfi8/3"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k38-v6si6955007pgm.335.2018.08.09.11.12.31; Thu, 09 Aug 2018 11:12:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="PpDfi8/3"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727342AbeHIUhZ (ORCPT + 99 others); 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-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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); -- 2.18.0