From patchwork Fri Sep 11 12:32:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naohiro Aota X-Patchwork-Id: 11771179 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 2B70713B1 for ; Fri, 11 Sep 2020 17:44:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CA69221EB for ; Fri, 11 Sep 2020 17:44:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=wdc.com header.i=@wdc.com header.b="rZk2TWiE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726115AbgIKRo2 (ORCPT ); Fri, 11 Sep 2020 13:44:28 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:38370 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725905AbgIKMeR (ORCPT ); Fri, 11 Sep 2020 08:34:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1599827657; x=1631363657; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=G+eY6whLDHc/YKQ9K4YyAddscKcqtBOgwR1sNKYkpH8=; b=rZk2TWiEQqXKf5I1ZsxF+vbYznrCUCdVGPEAZLpxYIwtoburmOF8/mZA mjd81ngIiW/u999tNd/NtCPiVtJ2QtieqIeBpRL0HMNICUl1maSxyQmAf HeYMmrK5tjgbwpyO3szTvh8LJtGabmVafUlYxgpP4qUzQlNUboeNIXxph EXJsnyOMGgFGgMRUmrERVR6q02aF1eb4nQwhFWrdJpZqF5DJJwii53sIA c98bYHbJq4ru2b3yW8q1uG613OHpJlDIhLIVe159rNrnjE8y9PyUs0jLx nDyo3tP+1kevfS8VGD3276qN4suBr22ZGEuco4VgGS6iHxNQNQ7v3hUfM w==; IronPort-SDR: 12DQnn1IniLuHCQ9vhhw1w1WmW83JzGVxhlQrccTp7ezm9WhdxHfkPBaex7VKy/QJxIi8aBP/K V6gNOM5X8UPxgjVtqbB3cAvlloDaUkGeemohsnyLMXxGqRqOaBfkyEXMb/jBJbCEbauIaTu7fZ UT9X2qeONlXIV24YXmlP/HgSMPFTlIBC6NIGd+I0TVcIANM/XMYvs3NvGRJtz8vVuHmcbIZSZf cIs5J6ZvbMdMTM7s5SS3GeSPzWaNTCK4PmNL17RcMIFM/VoeNeKKvXtET4nLk5L8gaH2wdpKtf 33g= X-IronPort-AV: E=Sophos;i="5.76,415,1592841600"; d="scan'208";a="147125964" Received: from h199-255-45-15.hgst.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 11 Sep 2020 20:33:18 +0800 IronPort-SDR: 6sOxySGaDcvVsMTIBADmFyi/SFfrTFRLArHoO+cgMQLWSg/zmac60F/yHTS7IfLPWJUo+X2n4D 2mLo/0nQgTfQ== Received: from uls-op-cesaip02.wdc.com ([10.248.3.37]) by uls-op-cesaep02.wdc.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Sep 2020 05:19:39 -0700 IronPort-SDR: ofowNukk5ASuU0CR5DAMDfiPbO78TOUgbW618Ec9+WiXi+RyeS5pgYeMm8MBlVvDm7AKw4fDvj G2cKSDFS/Uzg== WDCIronportException: Internal Received: from naota.dhcp.fujisawa.hgst.com ([10.149.52.155]) by uls-op-cesaip02.wdc.com with ESMTP; 11 Sep 2020 05:33:16 -0700 From: Naohiro Aota To: linux-btrfs@vger.kernel.org, David Sterba Cc: Chris Mason , Josef Bacik , Hannes Reinecke , linux-fsdevel@vger.kernel.org, Naohiro Aota , Johannes Thumshirn Subject: [PATCH v7 07/39] btrfs: disable fallocate in ZONED mode Date: Fri, 11 Sep 2020 21:32:27 +0900 Message-Id: <20200911123259.3782926-8-naohiro.aota@wdc.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200911123259.3782926-1-naohiro.aota@wdc.com> References: <20200911123259.3782926-1-naohiro.aota@wdc.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org fallocate() is implemented by reserving actual extent instead of reservations. This can result in exposing the sequential write constraint of host-managed zoned block devices to the application, which would break the POSIX semantic for the fallocated file. To avoid this, report fallocate() as not supported when in ZONED mode for now. In the future, we may be able to implement "in-memory" fallocate() in ZONED mode by utilizing space_info->bytes_may_use or so. Reviewed-by: Johannes Thumshirn Reviewed-by: Josef Bacik Signed-off-by: Naohiro Aota --- fs/btrfs/file.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c index 1395e537ad32..8843696c7f74 100644 --- a/fs/btrfs/file.c +++ b/fs/btrfs/file.c @@ -3309,6 +3309,10 @@ static long btrfs_fallocate(struct file *file, int mode, alloc_end = round_up(offset + len, blocksize); cur_offset = alloc_start; + /* Do not allow fallocate in ZONED mode */ + if (btrfs_fs_incompat(btrfs_sb(inode->i_sb), ZONED)) + return -EOPNOTSUPP; + /* Make sure we aren't being give some crap mode */ if (mode & ~(FALLOC_FL_KEEP_SIZE | FALLOC_FL_PUNCH_HOLE | FALLOC_FL_ZERO_RANGE))