From patchwork Sun Sep 17 00:36:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Satoru Takeuchi X-Patchwork-Id: 9954501 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 29B3D6028A for ; Sun, 17 Sep 2017 00:37:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 080FE2847D for ; Sun, 17 Sep 2017 00:37:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 06BC72861C; Sun, 17 Sep 2017 00:37:21 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, 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 8DC4A28682 for ; Sun, 17 Sep 2017 00:37:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751451AbdIQAgZ (ORCPT ); Sat, 16 Sep 2017 20:36:25 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:37511 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751198AbdIQAgZ (ORCPT ); Sat, 16 Sep 2017 20:36:25 -0400 Received: by mail-pf0-f196.google.com with SMTP id e69so2971139pfg.4 for ; Sat, 16 Sep 2017 17:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:from:to:subject:user-agent:mime-version; bh=1q+r+DHo368UNv2mqi4DOAD6LS3OeUjb/oWwvR7sSWk=; b=YHnGwqHmDtpCo6SRcpVxwHQqxMK/KUxhWfcJvDGJPy4EotCOSFwJp4rgQuRQDDmd/Y K7xsC28jiRQpy0IN0zC2XeOYVHRZ3lQ+vzywKrI8SWERZlbE2QrkWAD7EPNgLd/XiVtm GDsL3x9uJd1QtpEUHZz5fIDpYbxV3KUz2T4oJFlpZ8wxdBHycL478P0eeG/Yqu5/O+Uj L7V1sId192DciCyslqxABdoqzptvVXpAzQiuKTQjnmDKOJbHSsJ4hVYi/0oVTm8epZrp xH0JwS44jbYe6Pm/ejPQoVMbDfRmXMo0hgVRrpONlasOmSQa8d6snl7FJC7BJ3nI+S+J q6GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:from:to:subject:user-agent :mime-version; bh=1q+r+DHo368UNv2mqi4DOAD6LS3OeUjb/oWwvR7sSWk=; b=oUy86GDx/cf1Jwb4q5foGK/J7/07dLe8gY/NVRtB05e/CmkRu/RVyZ7tBiba3acKDM JxYUVuRMYp7hvdVhpCv7x9JqLMue82mET8AVxoQGU4GpDuRXGYUNj90jiD9uCtYBbyhy eCoK4Rqa4b5B7k3f9FPEO3bh88El+koT7FGCkIJAsl9tgwLbYWJo5RIQUTLRw9WE/I8K /DviGeHJzgFJ9VxCIKKe+YxNXaLHWE3awwV9WSCC5Km3ms+mmKRFKXSOqRyhTTPHRCEY sNVLePNYVKv58RQl7MjqG1MMAzyuFzj0G0B5hIkOO1u6gbiiZS/IP7WnAt7O0kNlaEDc 68Rg== X-Gm-Message-State: AHPjjUgWwCjxsnCqERx30I3Xrwk6RQkp7rKSw1lLpJWisfVM2b3Xl/UW dP831M/HrZmUe4tn X-Google-Smtp-Source: AOwi7QCMymyDxB/ShSfJi9lNd/BpAkZN+AGt6rIUvz6B0L40NzwroFFbOlfOwQDdMMMpsgygU9pYXQ== X-Received: by 10.84.235.72 with SMTP id g8mr2787994plt.86.1505608584062; Sat, 16 Sep 2017 17:36:24 -0700 (PDT) Received: from gopher.gmail.com (58-189-215-38f1.hyg2.eonet.ne.jp. [58.189.215.38]) by smtp.gmail.com with ESMTPSA id i2sm6759760pgq.81.2017.09.16.17.36.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 16 Sep 2017 17:36:23 -0700 (PDT) Date: Sun, 17 Sep 2017 09:36:25 +0900 Message-ID: <87poaqyxdi.wl-satoru.takeuchi@gmail.com> From: Satoru Takeuchi To: linux-btrfs@vger.kernel.org Subject: [PATCH] btrfs-progs: allow "no" to disable compression for convenience User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM/1.14.9 (=?ISO-8859-4?Q?Goj=F2?=) APEL/10.8 EasyPG/1.0.0 Emacs/24.5 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") 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's messy to use "" to disable compression. Introduce the new value "no" which can also be used for this purpose. Signed-off-by: Satoru Takeuchi --- Documentation/btrfs-property.asciidoc | 2 +- props.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/btrfs-property.asciidoc b/Documentation/btrfs-property.asciidoc index 7ed6a7d..97b90d6 100644 --- a/Documentation/btrfs-property.asciidoc +++ b/Documentation/btrfs-property.asciidoc @@ -43,7 +43,7 @@ read-only flag of subvolume: true or false label:::: label of device compression:::: -compression setting for an inode: lzo, zlib, zstd, or "" (empty string) +compression setting for an inode: lzo, zlib, zstd, no, or "" (empty string). Both no and "" are for disabling compression. *list* [-t ] :: Lists available properties with their descriptions for the given object. diff --git a/props.c b/props.c index a7e3e96..a2df868 100644 --- a/props.c +++ b/props.c @@ -142,9 +142,11 @@ static int prop_compression(enum prop_object_type type, memcpy(xattr_name + XATTR_BTRFS_PREFIX_LEN, name, strlen(name)); xattr_name[XATTR_BTRFS_PREFIX_LEN + strlen(name)] = '\0'; - if (value) + if (value) { + if (!strcmp(value, "no")) + value = ""; sret = fsetxattr(fd, xattr_name, value, strlen(value), 0); - else + } else sret = fgetxattr(fd, xattr_name, NULL, 0); if (sret < 0) { ret = -errno;