Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp786561imm; Mon, 21 May 2018 14:26:11 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp+wXs/1HtRzcb34hj7NRXUmXjYZxUUr0IGX2Ba5bqkDJtafoGUGlislLvCxh9sr4GElG0y X-Received: by 2002:a17:902:a585:: with SMTP id az5-v6mr21822508plb.79.1526937971863; Mon, 21 May 2018 14:26:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526937971; cv=none; d=google.com; s=arc-20160816; b=OhHTsdRmLjRU4cIglounXhxRddsMBqd4hk79ct4iXrfq2Ew20A/d2JklAcMqH1E+aA iABxuMnbUIU0IaUf5iT92UnTS5mTD5Hk8hjPvLi1YDHVkQ6dCpLufNdKn5hhWyPdIDBY m1LzZ0Qc1ijPJeA3+jUqhyxO8E/I9cc809jD6Ly6DL0cRYYXlmc76F+fMiqWg9rhMphS MCPeaFFmuNSjP2g71Kwfrp2FChoCNv298KLwhfNnen4Xa4RTglZ+ciKWHxf7gNA1FvUm kpMMPA6mch+MzXZ7GL3JhMZNf0pF5lkBRerI+xXVSga4wMclci8L9Qn1LHUJwPnrEWuA i16A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=9WYMAVlUtwZnkBrDP0CMr5+bkLNuMIyN98pLMTcwi8E=; b=jQmCPHKX0yKpWBSVuxR7oJCEhT5cOLELFK+0vuCXdagRU7RldnBYbpreOl1Q2fXUps dEuXU7gpyCWX+O1UQWuY5XonCzKvHYLeTs/V11qutAQaa+g5ZS1E/hUm/Rq9btgfl/b6 rnqneUutaC1EgYVVj6MDalVzeyqX0kZIZn3WyvXX9wbwrYj2zdbas0d1y4kqbL+tSm/y cAEA9Q0OL+Ek874Jv9Y3e15qZPbUxHfvYwfakb00ggePq0Rylies6HBP182H8hOywFLs uUlplkNpn3Tn/kPx3PV6G3bbxnjqtUV0gn08SocRuzH7aczCD0W+7dmVRIhzcmxnebL1 dOPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wedlB5O6; 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 p1-v6si14262882pfn.269.2018.05.21.14.25.57; Mon, 21 May 2018 14:26:11 -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=pass header.i=@kernel.org header.s=default header.b=wedlB5O6; 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 S932315AbeEUVYm (ORCPT + 99 others); Mon, 21 May 2018 17:24:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:39470 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932302AbeEUVYf (ORCPT ); Mon, 21 May 2018 17:24:35 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7C73320871; Mon, 21 May 2018 21:24:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1526937875; bh=rbExQvEC5hKFbOtOUK0LcXtnZFFajbWE+m2leVQrPFY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wedlB5O6RSsHB2U3VpXu/ScX6zBNZ/IOFdzYpoYbQ/mBaDhyH3w8tRZZFYWVXcivp mdofXThf3cU7hxiz0cZi2B+nRoE1Q6KrRgcilCG60xmCpFhZapcIS8nfNx8wfqwKvR olBOHmYhDO9aQmeBHMJoCsHLh75h17hgP9KnXdOk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomohiro Misono , Anand Jain , David Sterba Subject: [PATCH 4.16 057/110] btrfs: property: Set incompat flag if lzo/zstd compression is set Date: Mon, 21 May 2018 23:11:54 +0200 Message-Id: <20180521210510.840166368@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180521210503.823249477@linuxfoundation.org> References: <20180521210503.823249477@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Misono Tomohiro commit 1a63c198ddb810c790101d693c7071cca703b3c7 upstream. Incompat flag of LZO/ZSTD compression should be set at: 1. mount time (-o compress/compress-force) 2. when defrag is done 3. when property is set Currently 3. is missing and this commit adds this. This could lead to a filesystem that uses ZSTD but is not marked as such. If a kernel without a ZSTD support encounteres a ZSTD compressed extent, it will handle that but this could be confusing to the user. Typically the filesystem is mounted with the ZSTD option, but the discrepancy can arise when a filesystem is never mounted with ZSTD and then the property on some file is set (and some new extents are written). A simple mount with -o compress=zstd will fix that up on an unpatched kernel. Same goes for LZO, but this has been around for a very long time (2.6.37) so it's unlikely that a pre-LZO kernel would be used. Fixes: 5c1aab1dd544 ("btrfs: Add zstd support") CC: stable@vger.kernel.org # 4.14+ Signed-off-by: Tomohiro Misono Reviewed-by: Anand Jain Reviewed-by: David Sterba [ add user visible impact ] Signed-off-by: David Sterba Signed-off-by: Greg Kroah-Hartman --- fs/btrfs/props.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/fs/btrfs/props.c +++ b/fs/btrfs/props.c @@ -393,6 +393,7 @@ static int prop_compression_apply(struct const char *value, size_t len) { + struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb); int type; if (len == 0) { @@ -403,14 +404,17 @@ static int prop_compression_apply(struct return 0; } - if (!strncmp("lzo", value, 3)) + if (!strncmp("lzo", value, 3)) { type = BTRFS_COMPRESS_LZO; - else if (!strncmp("zlib", value, 4)) + btrfs_set_fs_incompat(fs_info, COMPRESS_LZO); + } else if (!strncmp("zlib", value, 4)) { type = BTRFS_COMPRESS_ZLIB; - else if (!strncmp("zstd", value, len)) + } else if (!strncmp("zstd", value, len)) { type = BTRFS_COMPRESS_ZSTD; - else + btrfs_set_fs_incompat(fs_info, COMPRESS_ZSTD); + } else { return -EINVAL; + } BTRFS_I(inode)->flags &= ~BTRFS_INODE_NOCOMPRESS; BTRFS_I(inode)->flags |= BTRFS_INODE_COMPRESS;