From patchwork Tue Sep 7 15:35:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kari Argillander X-Patchwork-Id: 12478989 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0EC2CC433F5 for ; Tue, 7 Sep 2021 15:36:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E10D760F5E for ; Tue, 7 Sep 2021 15:36:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345383AbhIGPhT (ORCPT ); Tue, 7 Sep 2021 11:37:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236561AbhIGPhQ (ORCPT ); Tue, 7 Sep 2021 11:37:16 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19F24C061575; Tue, 7 Sep 2021 08:36:10 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id f2so17257510ljn.1; Tue, 07 Sep 2021 08:36:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oNKca7TdM6UOQ59W0PmuB6JI6yIXEnAZZ18j+cw9ZMM=; b=Pz+OHzmYb7NZvewbuGmn6sZLP6XjUa+szUycP+iSikdofQIQhYsukWjEP6JHkIZglA vnAHNyaPH3pfm5pOD7+89FRER5ZjOO3WHWPeDpeqIoce0Kb2jgStNhO4o9FvxhQzVm3O x1TzYeODELaHJzSSBzJXLYYP/jx0bP8amHZLP/cKZ0TDFuhcmvpV95xe1tq9r/82P7rQ zScseh3WBGAPX2ZGAjyrketx6Cru2F3qSz8ilU4/cj/YYqxPwG4rKXbz/hbtLwkUu7U4 Yph2awkIqbsqgoUVhmFSlJACxLNsFONOJ81iNSJrhZIFV3PdlRGQN9sJDSkYXS/WTKmT lAaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oNKca7TdM6UOQ59W0PmuB6JI6yIXEnAZZ18j+cw9ZMM=; b=bMB1/MSHYqUToyPgy/wkQ+cmCuJCfVWoApyN4pZWb1VLM9k8H1ONS36CE5F9YTnH9e Q+w2gy+z2gH2gwOmOSKFQVBWrm5q6QxdqY7yj2zdrq8QnN8FeDyWDE7BJcrKPk6WRQAL uwSnjUH+E2nfvZf0Lbxbk4nX5H2onz6JQD8hkOBraR7HVncuAIxjvm7OBjHxJwtk09wx T2kUIjgOTJcbcm8OrFKtIeXEKJr38pdsm7jYqXslhdiuYaEhKLelBWwByD01YgaRtOAd 4U1Of5SnaZsA0wldJ29U+fsLFeO7thR3gfvEkA9T9ih9AXo7QQXVSSNG5IDVhAXZWnM5 Uuow== X-Gm-Message-State: AOAM533fJSMxcig5b9VssUpVo0zhYdQHD8bPysSqRTwvD2aMkdUQE5tI QLKEuV6eQz7hCV830riEZ+jod+o0jTlUew== X-Google-Smtp-Source: ABdhPJyydmeiLotrIfztdpGIDFEPKD2CExvveV1n8c53u/SxRzM5CQhT82LVqNeMLAF3FqDyDK/DUA== X-Received: by 2002:a2e:b173:: with SMTP id a19mr15323585ljm.210.1631028968451; Tue, 07 Sep 2021 08:36:08 -0700 (PDT) Received: from kari-VirtualBox.telewell.oy ([31.132.12.44]) by smtp.gmail.com with ESMTPSA id p14sm1484458lji.56.2021.09.07.08.36.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 08:36:08 -0700 (PDT) From: Kari Argillander To: Konstantin Komarov , ntfs3@lists.linux.dev Cc: Kari Argillander , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Pali_Roh=C3=A1r?= , Matthew Wilcox , Christian Brauner Subject: [PATCH v4 1/9] fs/ntfs3: Remove unnecesarry mount option noatime Date: Tue, 7 Sep 2021 18:35:49 +0300 Message-Id: <20210907153557.144391-2-kari.argillander@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210907153557.144391-1-kari.argillander@gmail.com> References: <20210907153557.144391-1-kari.argillander@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Remove unnecesarry mount option noatime because this will be handled by VFS. Our option parser will never get opt like this. Acked-by: Christian Brauner Reviewed-by: Christoph Hellwig Signed-off-by: Kari Argillander Reviewed-by: Pali Rohár --- Documentation/filesystems/ntfs3.rst | 4 ---- fs/ntfs3/super.c | 7 ------- 2 files changed, 11 deletions(-) diff --git a/Documentation/filesystems/ntfs3.rst b/Documentation/filesystems/ntfs3.rst index ffe9ea0c1499..af7158de6fde 100644 --- a/Documentation/filesystems/ntfs3.rst +++ b/Documentation/filesystems/ntfs3.rst @@ -85,10 +85,6 @@ acl Support POSIX ACLs (Access Control Lists). Effective if supported by Kernel. Not to be confused with NTFS ACLs. The option specified as acl enables support for POSIX ACLs. -noatime All files and directories will not update their last access - time attribute if a partition is mounted with this parameter. - This option can speed up file system operation. - =============================================================================== ToDo list diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 55bbc9200a10..a18b99a3e3b5 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -223,7 +223,6 @@ enum Opt { Opt_nohidden, Opt_showmeta, Opt_acl, - Opt_noatime, Opt_nls, Opt_prealloc, Opt_no_acs_rules, @@ -242,7 +241,6 @@ static const match_table_t ntfs_tokens = { { Opt_sparse, "sparse" }, { Opt_nohidden, "nohidden" }, { Opt_acl, "acl" }, - { Opt_noatime, "noatime" }, { Opt_showmeta, "showmeta" }, { Opt_nls, "nls=%s" }, { Opt_prealloc, "prealloc" }, @@ -333,9 +331,6 @@ static noinline int ntfs_parse_options(struct super_block *sb, char *options, ntfs_err(sb, "support for ACL not compiled in!"); return -EINVAL; #endif - case Opt_noatime: - sb->s_flags |= SB_NOATIME; - break; case Opt_showmeta: opts->showmeta = 1; break; @@ -587,8 +582,6 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root) seq_puts(m, ",prealloc"); if (sb->s_flags & SB_POSIXACL) seq_puts(m, ",acl"); - if (sb->s_flags & SB_NOATIME) - seq_puts(m, ",noatime"); return 0; } From patchwork Tue Sep 7 15:35:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kari Argillander X-Patchwork-Id: 12478991 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1F699C433F5 for ; Tue, 7 Sep 2021 15:36:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0957F61108 for ; Tue, 7 Sep 2021 15:36:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345398AbhIGPh3 (ORCPT ); Tue, 7 Sep 2021 11:37:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345397AbhIGPhU (ORCPT ); Tue, 7 Sep 2021 11:37:20 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D652C061575; Tue, 7 Sep 2021 08:36:14 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id y6so17245915lje.2; Tue, 07 Sep 2021 08:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3wnl5XEhkh1MPnWBnjk0/9SddCZUQ/Patup1iPbeWRo=; b=TrcQyDIOury2E1YNGllTiyd9zQIT/S19byBaL6Tkko9MZoj++wOT6b4iYeAjiWY6u2 MsDFIXsUnf5r9rIOr3cYnlQVTX/u/9H9gqFhw89/QjV3GlFyOjuG6JBXvD3NRUATM+VV +ebQHQ8DFhzxIwBG+X2VAifnkbfcwKKRhqMvIcTPHYEQZ8YUkxbxKglVQ85p/+4hO723 Dbx98HjId2Yzs6YNVKGBoda/ojZU3K/EW4H+JLikgsn9ZgI1FoqVoiMNSd+GAUTC1gTt PhUdNHqFvCIDhyQTAzJpjV+c5hUF2qSJZgMY48va8ICmz2y6SbrkNM6EYNaDUYyrqIDi Tz8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3wnl5XEhkh1MPnWBnjk0/9SddCZUQ/Patup1iPbeWRo=; b=kZnUhuYpMqGKL4n1wD4KSHdz+rcPyLNyieOK7GpDofHpCg8HKzxXQnpH0gVUh9Dgys lVwMEn87SEfGKSROKjoQXPDLrKF6ayZZdcirfJjaHa+4soANH5TSLeFDwcmFEf46QU5s rcq9Y/5tbTiBgJVg2a6ZvcT4PzNO7kPEbZowKvF4rhrTIiTv9DE7gVvH2UswckEUJXd6 Q+cun5CecUnJKF9Heg0FZ+W3m450tSAJPhOMj1L31bOj58PT7G279OCKoexOwG/YE5ue MKnlhVF5bD558xTtmmT2uOl4EODhAZKVk+iGfNw54liCbTQfYgzkj/o+G+Ad/1QILHmp f2WQ== X-Gm-Message-State: AOAM531L9vzKIqwhmsFmwLQ+LNi7KS3Ii3bApL2cUViRXQp0xr01qp+C G2czYd9QlJM8LzQThN80LUo= X-Google-Smtp-Source: ABdhPJwgvFMH2G3rwok9ZZOeY6CuDzZMwUDdV5/PmUlytfXrNH3n0s6VNKjSUC7m/Fw8FKjqrkdkOA== X-Received: by 2002:a2e:8e8f:: with SMTP id z15mr14797242ljk.121.1631028971244; Tue, 07 Sep 2021 08:36:11 -0700 (PDT) Received: from kari-VirtualBox.telewell.oy ([31.132.12.44]) by smtp.gmail.com with ESMTPSA id p14sm1484458lji.56.2021.09.07.08.36.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 08:36:10 -0700 (PDT) From: Kari Argillander To: Konstantin Komarov , ntfs3@lists.linux.dev Cc: Kari Argillander , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Pali_Roh=C3=A1r?= , Matthew Wilcox , Christian Brauner Subject: [PATCH v4 2/9] fs/ntfs3: Remove unnecesarry remount flag handling Date: Tue, 7 Sep 2021 18:35:50 +0300 Message-Id: <20210907153557.144391-3-kari.argillander@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210907153557.144391-1-kari.argillander@gmail.com> References: <20210907153557.144391-1-kari.argillander@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Remove unnecesarry remount flag handling. This does not do anything for this driver. We have already set SB_NODIRATIME when we fill super. Also noatime should be set from mount option. Now for some reson we try to set it when remounting. Lazytime part looks like it is copied from f2fs and there is own mount parameter for it. That is why they use it. We do not set lazytime anywhere in our code. So basically this just blocks lazytime when remounting. Acked-by: Christian Brauner Reviewed-by: Christoph Hellwig Signed-off-by: Kari Argillander --- fs/ntfs3/super.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index a18b99a3e3b5..6cb689605089 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -417,8 +417,6 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *data) clear_mount_options(&old_opts); - *flags = (*flags & ~SB_LAZYTIME) | (sb->s_flags & SB_LAZYTIME) | - SB_NODIRATIME | SB_NOATIME; ntfs_info(sb, "re-mounted. Opts: %s", orig_data); err = 0; goto out; From patchwork Tue Sep 7 15:35:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kari Argillander X-Patchwork-Id: 12478993 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1735C433EF for ; Tue, 7 Sep 2021 15:36:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A927661052 for ; Tue, 7 Sep 2021 15:36:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345462AbhIGPha (ORCPT ); Tue, 7 Sep 2021 11:37:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345411AbhIGPhV (ORCPT ); Tue, 7 Sep 2021 11:37:21 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AE39C061757; Tue, 7 Sep 2021 08:36:14 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id y34so20306092lfa.8; Tue, 07 Sep 2021 08:36:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AEccaEZ1KuGRurG9d5/yDZXuAgzQP2nKlToTFKCBLFo=; b=FHDOe1xetglcLz0jatZldLk5KDxlFqDzWwfYNlAfi1gdq5/2Imwt5zb7yloc8bu2B7 mAu1K3Z19BKveUpU5E643e0QP4RTo5aCpoJJ0ep4CM/y57mEAZEOwdtQfK1qnD5zG0YS tOM4Qydtl3qzqZJKvN75PwmmzNM0WGPBr+535xsQ5Q3TEKAaTvS3cIeGVDZPoOjAdnSI 3JnUgIYbjwej4ZFuC6xYGMEqlTqZFjhdfl2b7vE8qNtyl73jdKd3aoTeFA9jnMnkPT2q GOGIgky+jwBkPX9aRPqSgA4/d1yZOUtc2pbgaBku7edcC3+Heoh/xqQhdtGt0OGuT6DI /oDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AEccaEZ1KuGRurG9d5/yDZXuAgzQP2nKlToTFKCBLFo=; b=Y41G3RW9FvskhfA5TCuJkOM4CSidyM49Ol9ai3ux1pBEa1gb9q8jYNSq3ZZ9cUk+lV nUWrQUuKKkuzZhAbRJKkvuG9mcPtAuYAW8N8KJ5sYOm2Y9IdSs5jUOsxyAXurZngIHZ9 a16nEuk/ESvzHU6OENv6YAlZC5O4kH4c02q8rc//wQVZKVcsCIuObcLlNtbe+/Tdr8BH cFI1LskaPhLOHoupAwfhNztp3JvtKwhNeau/k2Cfppt7jgbMI7H5ZEm/ZIX8GDgydMZp FNGIyUPnv0KjQKnmUOewPxJfurZF418hhvtkcQJEQnm1M4UWei/Jm79i8Zu20nvlVRXA /bIg== X-Gm-Message-State: AOAM533+d6v6lUGb+pW47sk7MJ/b3O8wr+QUY4UKM0on/FHSIG4wXLaK zkPcDS1AKWxZG+sZlykfj8I= X-Google-Smtp-Source: ABdhPJw0wqrFmfGqjcLoy3wYI7pynVCT2RkWmX+6wv/pWmkK5KKMKBUHtyVTdXdKZgpBO/6A1LFZnQ== X-Received: by 2002:a05:6512:2201:: with SMTP id h1mr13011940lfu.307.1631028972929; Tue, 07 Sep 2021 08:36:12 -0700 (PDT) Received: from kari-VirtualBox.telewell.oy ([31.132.12.44]) by smtp.gmail.com with ESMTPSA id p14sm1484458lji.56.2021.09.07.08.36.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 08:36:12 -0700 (PDT) From: Kari Argillander To: Konstantin Komarov , ntfs3@lists.linux.dev Cc: Kari Argillander , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Pali_Roh=C3=A1r?= , Matthew Wilcox , Christian Brauner Subject: [PATCH v4 3/9] fs/ntfs3: Convert mount options to pointer in sbi Date: Tue, 7 Sep 2021 18:35:51 +0300 Message-Id: <20210907153557.144391-4-kari.argillander@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210907153557.144391-1-kari.argillander@gmail.com> References: <20210907153557.144391-1-kari.argillander@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Use pointer to mount options. We want to do this because we will use new mount api which will benefit that we have spi and mount options in different allocations. When we remount we do not have to make whole new spi it is enough that we will allocate just mount options. Please note that we can do example remount lot cleaner but things will change in next patch so this should be just functional. Signed-off-by: Kari Argillander --- fs/ntfs3/attrib.c | 2 +- fs/ntfs3/dir.c | 8 ++++---- fs/ntfs3/file.c | 4 ++-- fs/ntfs3/inode.c | 12 ++++++------ fs/ntfs3/ntfs_fs.h | 2 +- fs/ntfs3/super.c | 31 +++++++++++++++++++------------ fs/ntfs3/xattr.c | 2 +- 7 files changed, 34 insertions(+), 27 deletions(-) diff --git a/fs/ntfs3/attrib.c b/fs/ntfs3/attrib.c index 34c4cbf7e29b..b1055b284c60 100644 --- a/fs/ntfs3/attrib.c +++ b/fs/ntfs3/attrib.c @@ -529,7 +529,7 @@ int attr_set_size(struct ntfs_inode *ni, enum ATTR_TYPE type, } else if (pre_alloc == -1) { pre_alloc = 0; if (type == ATTR_DATA && !name_len && - sbi->options.prealloc) { + sbi->options->prealloc) { CLST new_alen2 = bytes_to_cluster( sbi, get_pre_allocated(new_size)); pre_alloc = new_alen2 - new_alen; diff --git a/fs/ntfs3/dir.c b/fs/ntfs3/dir.c index 93f6d485564e..40440df021ef 100644 --- a/fs/ntfs3/dir.c +++ b/fs/ntfs3/dir.c @@ -24,7 +24,7 @@ int ntfs_utf16_to_nls(struct ntfs_sb_info *sbi, const struct le_str *uni, int ret, uni_len, warn; const __le16 *ip; u8 *op; - struct nls_table *nls = sbi->options.nls; + struct nls_table *nls = sbi->options->nls; static_assert(sizeof(wchar_t) == sizeof(__le16)); @@ -186,7 +186,7 @@ int ntfs_nls_to_utf16(struct ntfs_sb_info *sbi, const u8 *name, u32 name_len, { int ret, slen; const u8 *end; - struct nls_table *nls = sbi->options.nls; + struct nls_table *nls = sbi->options->nls; u16 *uname = uni->name; static_assert(sizeof(wchar_t) == sizeof(u16)); @@ -301,10 +301,10 @@ static inline int ntfs_filldir(struct ntfs_sb_info *sbi, struct ntfs_inode *ni, return 0; /* Skip meta files. Unless option to show metafiles is set. */ - if (!sbi->options.showmeta && ntfs_is_meta_file(sbi, ino)) + if (!sbi->options->showmeta && ntfs_is_meta_file(sbi, ino)) return 0; - if (sbi->options.nohidden && (fname->dup.fa & FILE_ATTRIBUTE_HIDDEN)) + if (sbi->options->nohidden && (fname->dup.fa & FILE_ATTRIBUTE_HIDDEN)) return 0; name_len = ntfs_utf16_to_nls(sbi, (struct le_str *)&fname->name_len, diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index 424450e77ad5..fef57141b161 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -737,7 +737,7 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry, umode_t mode = inode->i_mode; int err; - if (sbi->options.no_acs_rules) { + if (sbi->options->no_acs_rules) { /* "No access rules" - Force any changes of time etc. */ attr->ia_valid |= ATTR_FORCE; /* and disable for editing some attributes. */ @@ -1185,7 +1185,7 @@ static int ntfs_file_release(struct inode *inode, struct file *file) int err = 0; /* If we are last writer on the inode, drop the block reservation. */ - if (sbi->options.prealloc && ((file->f_mode & FMODE_WRITE) && + if (sbi->options->prealloc && ((file->f_mode & FMODE_WRITE) && atomic_read(&inode->i_writecount) == 1)) { ni_lock(ni); down_write(&ni->file.run_lock); diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c index db2a5a4c38e4..9f740fd301b2 100644 --- a/fs/ntfs3/inode.c +++ b/fs/ntfs3/inode.c @@ -49,8 +49,8 @@ static struct inode *ntfs_read_mft(struct inode *inode, inode->i_op = NULL; /* Setup 'uid' and 'gid' */ - inode->i_uid = sbi->options.fs_uid; - inode->i_gid = sbi->options.fs_gid; + inode->i_uid = sbi->options->fs_uid; + inode->i_gid = sbi->options->fs_gid; err = mi_init(&ni->mi, sbi, ino); if (err) @@ -229,7 +229,7 @@ static struct inode *ntfs_read_mft(struct inode *inode, t32 = le16_to_cpu(attr->nres.run_off); } - mode = S_IFREG | (0777 & sbi->options.fs_fmask_inv); + mode = S_IFREG | (0777 & sbi->options->fs_fmask_inv); if (!attr->non_res) { ni->ni_flags |= NI_FLAG_RESIDENT; @@ -272,7 +272,7 @@ static struct inode *ntfs_read_mft(struct inode *inode, goto out; mode = sb->s_root - ? (S_IFDIR | (0777 & sbi->options.fs_dmask_inv)) + ? (S_IFDIR | (0777 & sbi->options->fs_dmask_inv)) : (S_IFDIR | 0777); goto next_attr; @@ -443,7 +443,7 @@ static struct inode *ntfs_read_mft(struct inode *inode, goto out; } - if ((sbi->options.sys_immutable && + if ((sbi->options->sys_immutable && (std5->fa & FILE_ATTRIBUTE_SYSTEM)) && !S_ISFIFO(mode) && !S_ISSOCK(mode) && !S_ISLNK(mode)) { inode->i_flags |= S_IMMUTABLE; @@ -1244,7 +1244,7 @@ struct inode *ntfs_create_inode(struct user_namespace *mnt_userns, * } */ } else if (S_ISREG(mode)) { - if (sbi->options.sparse) { + if (sbi->options->sparse) { /* Sparsed regular file, cause option 'sparse'. */ fa = FILE_ATTRIBUTE_SPARSE_FILE | FILE_ATTRIBUTE_ARCHIVE; diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 97e682ebcfb9..98c90c399ee2 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -279,7 +279,7 @@ struct ntfs_sb_info { #endif } compress; - struct ntfs_mount_options options; + struct ntfs_mount_options *options; struct ratelimit_state msg_ratelimit; }; diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 6cb689605089..0f3820342051 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -389,11 +389,11 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *data) return -ENOMEM; /* Store original options. */ - memcpy(&old_opts, &sbi->options, sizeof(old_opts)); - clear_mount_options(&sbi->options); - memset(&sbi->options, 0, sizeof(sbi->options)); + memcpy(&old_opts, sbi->options, sizeof(old_opts)); + clear_mount_options(sbi->options); + memset(sbi->options, 0, sizeof(old_opts)); - err = ntfs_parse_options(sb, data, 0, &sbi->options); + err = ntfs_parse_options(sb, data, 0, sbi->options); if (err) goto restore_opts; @@ -409,7 +409,7 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *data) sync_filesystem(sb); if (ro_rw && (sbi->volume.flags & VOLUME_FLAG_DIRTY) && - !sbi->options.force) { + !sbi->options->force) { ntfs_warn(sb, "volume is dirty and \"force\" flag is not set!"); err = -EINVAL; goto restore_opts; @@ -422,8 +422,8 @@ static int ntfs_remount(struct super_block *sb, int *flags, char *data) goto out; restore_opts: - clear_mount_options(&sbi->options); - memcpy(&sbi->options, &old_opts, sizeof(old_opts)); + clear_mount_options(sbi->options); + memcpy(sbi->options, &old_opts, sizeof(old_opts)); out: kfree(orig_data); @@ -506,7 +506,8 @@ static noinline void put_ntfs(struct ntfs_sb_info *sbi) xpress_free_decompressor(sbi->compress.xpress); lzx_free_decompressor(sbi->compress.lzx); #endif - clear_mount_options(&sbi->options); + clear_mount_options(sbi->options); + kfree(sbi->options); kfree(sbi); } @@ -545,7 +546,7 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root) { struct super_block *sb = root->d_sb; struct ntfs_sb_info *sbi = sb->s_fs_info; - struct ntfs_mount_options *opts = &sbi->options; + struct ntfs_mount_options *opts = sbi->options; struct user_namespace *user_ns = seq_user_ns(m); if (opts->uid) @@ -930,6 +931,12 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent) if (!sbi) return -ENOMEM; + sbi->options = kzalloc(sizeof(struct ntfs_mount_options), GFP_NOFS); + if (!sbi->options) { + kfree(sbi); + return -ENOMEM; + } + sb->s_fs_info = sbi; sbi->sb = sb; sb->s_flags |= SB_NODIRATIME; @@ -942,7 +949,7 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent) ratelimit_state_init(&sbi->msg_ratelimit, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); - err = ntfs_parse_options(sb, data, silent, &sbi->options); + err = ntfs_parse_options(sb, data, silent, sbi->options); if (err) goto out; @@ -1074,7 +1081,7 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent) goto out; } } else if (sbi->volume.flags & VOLUME_FLAG_DIRTY) { - if (!is_ro && !sbi->options.force) { + if (!is_ro && !sbi->options->force) { ntfs_warn( sb, "volume is dirty and \"force\" flag is not set!"); @@ -1394,7 +1401,7 @@ int ntfs_discard(struct ntfs_sb_info *sbi, CLST lcn, CLST len) if (sbi->flags & NTFS_FLAGS_NODISCARD) return -EOPNOTSUPP; - if (!sbi->options.discard) + if (!sbi->options->discard) return -EOPNOTSUPP; lbo = (u64)lcn << sbi->cluster_bits; diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index b15d532e4a17..ac4b37bf8832 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -769,7 +769,7 @@ int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct inode *inode) int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode, int mask) { - if (ntfs_sb(inode->i_sb)->options.no_acs_rules) { + if (ntfs_sb(inode->i_sb)->options->no_acs_rules) { /* "No access rules" mode - Allow all changes. */ return 0; } From patchwork Tue Sep 7 15:35:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kari Argillander X-Patchwork-Id: 12478995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E149BC433FE for ; Tue, 7 Sep 2021 15:36:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C7DB761152 for ; Tue, 7 Sep 2021 15:36:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345434AbhIGPhc (ORCPT ); Tue, 7 Sep 2021 11:37:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345439AbhIGPh2 (ORCPT ); Tue, 7 Sep 2021 11:37:28 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17CE4C061796; Tue, 7 Sep 2021 08:36:17 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id t19so20284207lfe.13; Tue, 07 Sep 2021 08:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=THuXilS244BThSMPphop3J2z5Eh+ezw2C1FqNtcFHNs=; b=euQyRkc7M/m4bv+JSAvw0yoDP1PITF8v+nZzLLFSdryc6xY36+dlgAyBMQPDmZpTsm iG9bmwyCPbrRGYyo5s4Uu3YdfYmsgQNUbAlIAshbPvtbcB0Djs0s6ErHH0W9/7cFQ2sh 0olg/6pRsNWuXK97q7ot7gon2L1dPm7Zo3MnZX4BTJMFpHKndY8ZjxWOsfe9omgeTj5G x30Lrx7Ha2o1hUBojxsyVwElEHvgVcPHgayEeP5jBHUmy8Vtm8f+2Hah/YMRFHCuv/8B srAHwcaKSOCxMh985kWFAoIc3zCdsfwm94wLAPRRcS0PUzO4S4WM972chsE3hjqt+4ya t0VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=THuXilS244BThSMPphop3J2z5Eh+ezw2C1FqNtcFHNs=; b=HQhtaBKJUg0TiLWyGg0Fw79jE/f94IRuELSzyyaTnSvGoe/ANfU5OlKrlD84X4s/eX 6ANRcRiij8EJxJH/ncVRnH89orYXeyzJIePo5C0Qu4XVS8+0fPUKJlR8t4XbNcDeApOF eLtCz1x+kAcyT8dz+t+NhfLkbDlvhk6Bnm5xbraLQ6eCcWCG+6Btlfic/uM9cxSGHROO 0cmCGtmXPqHwIAcbzCd78U055QrP2rR+GqYwz8lVt7KUieRMdXCbJROYZwe6/jOm+k27 GLJsSHz/8JeBNjGLD5rMXfmNPY2+TmkLOgK99fGU8UPF8QYP7vwD0tleJVywiylFvccl aWQg== X-Gm-Message-State: AOAM5320Ik+g/24zn4C3vAIJ6yXseMjnvP27B9s+Uyi5Qgi5R4Rpk2Pm TVRI6cMfhp4KIjWeoUMZfbs= X-Google-Smtp-Source: ABdhPJxPmRtxk3S/NS+8vY8o78KzDkz3mxzZwGNyAbWnWfeStLRNFwKGyJwgztNTPSYGMk4Lub0OqQ== X-Received: by 2002:a05:6512:3f8c:: with SMTP id x12mr13483966lfa.320.1631028974975; Tue, 07 Sep 2021 08:36:14 -0700 (PDT) Received: from kari-VirtualBox.telewell.oy ([31.132.12.44]) by smtp.gmail.com with ESMTPSA id p14sm1484458lji.56.2021.09.07.08.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 08:36:14 -0700 (PDT) From: Kari Argillander To: Konstantin Komarov , ntfs3@lists.linux.dev Cc: Kari Argillander , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Pali_Roh=C3=A1r?= , Matthew Wilcox , Christian Brauner Subject: [PATCH v4 4/9] fs/ntfs3: Use new api for mounting Date: Tue, 7 Sep 2021 18:35:52 +0300 Message-Id: <20210907153557.144391-5-kari.argillander@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210907153557.144391-1-kari.argillander@gmail.com> References: <20210907153557.144391-1-kari.argillander@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org We have now new mount api as described in Documentation/filesystems. We should use it as it gives us some benefits which are desribed here lore.kernel.org/linux-fsdevel/159646178122.1784947.11705396571718464082.stgit@warthog.procyon.org.uk/ Nls loading is changed a to load with string. This did make code also little cleaner. Also try to use fsparam_flag_no as much as possible. This is just nice little touch and is not mandatory but it should not make any harm. It is just convenient that we can use example acl/noacl mount options. Signed-off-by: Kari Argillander --- fs/ntfs3/ntfs_fs.h | 1 + fs/ntfs3/super.c | 433 ++++++++++++++++++++++++--------------------- 2 files changed, 229 insertions(+), 205 deletions(-) diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 98c90c399ee2..aa18f12b7096 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -52,6 +52,7 @@ // clang-format on struct ntfs_mount_options { + char *nls_name; struct nls_table *nls; kuid_t fs_uid; diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 0f3820342051..befa78d3cb26 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -28,11 +28,12 @@ #include #include #include +#include +#include #include #include #include #include -#include #include #include @@ -205,9 +206,11 @@ void *ntfs_put_shared(void *ptr) return ret; } -static inline void clear_mount_options(struct ntfs_mount_options *options) +static inline void put_mount_options(struct ntfs_mount_options *options) { + kfree(options->nls_name); unload_nls(options->nls); + kfree(options); } enum Opt { @@ -229,205 +232,171 @@ enum Opt { Opt_err, }; -static const match_table_t ntfs_tokens = { - { Opt_uid, "uid=%u" }, - { Opt_gid, "gid=%u" }, - { Opt_umask, "umask=%o" }, - { Opt_dmask, "dmask=%o" }, - { Opt_fmask, "fmask=%o" }, - { Opt_immutable, "sys_immutable" }, - { Opt_discard, "discard" }, - { Opt_force, "force" }, - { Opt_sparse, "sparse" }, - { Opt_nohidden, "nohidden" }, - { Opt_acl, "acl" }, - { Opt_showmeta, "showmeta" }, - { Opt_nls, "nls=%s" }, - { Opt_prealloc, "prealloc" }, - { Opt_no_acs_rules, "no_acs_rules" }, - { Opt_err, NULL }, +static const struct fs_parameter_spec ntfs_fs_parameters[] = { + fsparam_u32("uid", Opt_uid), + fsparam_u32("gid", Opt_gid), + fsparam_u32oct("umask", Opt_umask), + fsparam_u32oct("dmask", Opt_dmask), + fsparam_u32oct("fmask", Opt_fmask), + fsparam_flag_no("sys_immutable", Opt_immutable), + fsparam_flag_no("discard", Opt_discard), + fsparam_flag_no("force", Opt_force), + fsparam_flag_no("sparse", Opt_sparse), + fsparam_flag("nohidden", Opt_nohidden), + fsparam_flag_no("acl", Opt_acl), + fsparam_flag_no("showmeta", Opt_showmeta), + fsparam_string("nls", Opt_nls), + fsparam_flag_no("prealloc", Opt_prealloc), + fsparam_flag("no_acs_rules", Opt_no_acs_rules), + {} }; -static noinline int ntfs_parse_options(struct super_block *sb, char *options, - int silent, - struct ntfs_mount_options *opts) +/* + * Load nls table or if @nls is utf8 then return NULL. + */ +static struct nls_table *ntfs_load_nls(char *nls) { - char *p; - substring_t args[MAX_OPT_ARGS]; - int option; - char nls_name[30]; - struct nls_table *nls; + struct nls_table *ret; - opts->fs_uid = current_uid(); - opts->fs_gid = current_gid(); - opts->fs_fmask_inv = opts->fs_dmask_inv = ~current_umask(); - nls_name[0] = 0; + if (!nls) + nls = CONFIG_NLS_DEFAULT; - if (!options) - goto out; + if (strcmp(nls, "utf8") == 0) + return NULL; - while ((p = strsep(&options, ","))) { - int token; + if (strcmp(nls, CONFIG_NLS_DEFAULT) == 0) + return load_nls_default(); - if (!*p) - continue; + ret = load_nls(nls); + if (ret) + return ret; - token = match_token(p, ntfs_tokens, args); - switch (token) { - case Opt_immutable: - opts->sys_immutable = 1; - break; - case Opt_uid: - if (match_int(&args[0], &option)) - return -EINVAL; - opts->fs_uid = make_kuid(current_user_ns(), option); - if (!uid_valid(opts->fs_uid)) - return -EINVAL; - opts->uid = 1; - break; - case Opt_gid: - if (match_int(&args[0], &option)) - return -EINVAL; - opts->fs_gid = make_kgid(current_user_ns(), option); - if (!gid_valid(opts->fs_gid)) - return -EINVAL; - opts->gid = 1; - break; - case Opt_umask: - if (match_octal(&args[0], &option)) - return -EINVAL; - opts->fs_fmask_inv = opts->fs_dmask_inv = ~option; - opts->fmask = opts->dmask = 1; - break; - case Opt_dmask: - if (match_octal(&args[0], &option)) - return -EINVAL; - opts->fs_dmask_inv = ~option; - opts->dmask = 1; - break; - case Opt_fmask: - if (match_octal(&args[0], &option)) - return -EINVAL; - opts->fs_fmask_inv = ~option; - opts->fmask = 1; - break; - case Opt_discard: - opts->discard = 1; - break; - case Opt_force: - opts->force = 1; - break; - case Opt_sparse: - opts->sparse = 1; - break; - case Opt_nohidden: - opts->nohidden = 1; - break; - case Opt_acl: + return ERR_PTR(-EINVAL); +} + +static int ntfs_fs_parse_param(struct fs_context *fc, + struct fs_parameter *param) +{ + struct ntfs_mount_options *opts = fc->fs_private; + struct fs_parse_result result; + int opt; + + opt = fs_parse(fc, ntfs_fs_parameters, param, &result); + if (opt < 0) + return opt; + + switch (opt) { + case Opt_uid: + opts->fs_uid = make_kuid(current_user_ns(), result.uint_32); + if (!uid_valid(opts->fs_uid)) + return invalf(fc, "ntfs3: Invalid value for uid."); + opts->uid = 1; + break; + case Opt_gid: + opts->fs_gid = make_kgid(current_user_ns(), result.uint_32); + if (!gid_valid(opts->fs_gid)) + return invalf(fc, "ntfs3: Invalid value for gid."); + opts->gid = 1; + break; + case Opt_umask: + if (result.uint_32 & ~07777) + return invalf(fc, "ntfs3: Invalid value for umask."); + opts->fs_fmask_inv = ~result.uint_32; + opts->fs_dmask_inv = ~result.uint_32; + opts->fmask = 1; + opts->dmask = 1; + break; + case Opt_dmask: + if (result.uint_32 & ~07777) + return invalf(fc, "ntfs3: Invalid value for dmask."); + opts->fs_dmask_inv = ~result.uint_32; + opts->dmask = 1; + break; + case Opt_fmask: + if (result.uint_32 & ~07777) + return invalf(fc, "ntfs3: Invalid value for fmask."); + opts->fs_fmask_inv = ~result.uint_32; + opts->fmask = 1; + break; + case Opt_immutable: + opts->sys_immutable = result.negated ? 0 : 1; + break; + case Opt_discard: + opts->discard = result.negated ? 0 : 1; + break; + case Opt_force: + opts->force = result.negated ? 0 : 1; + break; + case Opt_sparse: + opts->sparse = result.negated ? 0 : 1; + break; + case Opt_nohidden: + opts->nohidden = 1; + break; + case Opt_acl: + if (!result.negated) #ifdef CONFIG_NTFS3_FS_POSIX_ACL - sb->s_flags |= SB_POSIXACL; - break; + fc->sb_flags |= SB_POSIXACL; #else - ntfs_err(sb, "support for ACL not compiled in!"); - return -EINVAL; + return invalf(fc, "ntfs3: Support for ACL not compiled in!"); #endif - case Opt_showmeta: - opts->showmeta = 1; - break; - case Opt_nls: - match_strlcpy(nls_name, &args[0], sizeof(nls_name)); - break; - case Opt_prealloc: - opts->prealloc = 1; - break; - case Opt_no_acs_rules: - opts->no_acs_rules = 1; - break; - default: - if (!silent) - ntfs_err( - sb, - "Unrecognized mount option \"%s\" or missing value", - p); - //return -EINVAL; - } - } - -out: - if (!strcmp(nls_name[0] ? nls_name : CONFIG_NLS_DEFAULT, "utf8")) { - /* - * For UTF-8 use utf16s_to_utf8s()/utf8s_to_utf16s() - * instead of NLS. - */ - nls = NULL; - } else if (nls_name[0]) { - nls = load_nls(nls_name); - if (!nls) { - ntfs_err(sb, "failed to load \"%s\"", nls_name); - return -EINVAL; - } - } else { - nls = load_nls_default(); - if (!nls) { - ntfs_err(sb, "failed to load default nls"); - return -EINVAL; - } + else + fc->sb_flags &= ~SB_POSIXACL; + break; + case Opt_showmeta: + opts->showmeta = result.negated ? 0 : 1; + break; + case Opt_nls: + kfree(opts->nls_name); + opts->nls_name = param->string; + param->string = NULL; + break; + case Opt_prealloc: + opts->prealloc = result.negated ? 0 : 1; + break; + case Opt_no_acs_rules: + opts->no_acs_rules = 1; + break; + default: + /* Should not be here unless we forget add case. */ + return -EINVAL; } - opts->nls = nls; - return 0; } -static int ntfs_remount(struct super_block *sb, int *flags, char *data) +static int ntfs_fs_reconfigure(struct fs_context *fc) { - int err, ro_rw; + struct super_block *sb = fc->root->d_sb; struct ntfs_sb_info *sbi = sb->s_fs_info; - struct ntfs_mount_options old_opts; - char *orig_data = kstrdup(data, GFP_KERNEL); - - if (data && !orig_data) - return -ENOMEM; - - /* Store original options. */ - memcpy(&old_opts, sbi->options, sizeof(old_opts)); - clear_mount_options(sbi->options); - memset(sbi->options, 0, sizeof(old_opts)); - - err = ntfs_parse_options(sb, data, 0, sbi->options); - if (err) - goto restore_opts; + struct ntfs_mount_options *new_opts = fc->fs_private; + int ro_rw; - ro_rw = sb_rdonly(sb) && !(*flags & SB_RDONLY); + ro_rw = sb_rdonly(sb) && !(fc->sb_flags & SB_RDONLY); if (ro_rw && (sbi->flags & NTFS_FLAGS_NEED_REPLAY)) { - ntfs_warn( - sb, - "Couldn't remount rw because journal is not replayed. Please umount/remount instead\n"); - err = -EINVAL; - goto restore_opts; + errorf(fc, "ntfs3: Couldn't remount rw because journal is not replayed. Please umount/remount instead\n"); + return -EINVAL; + } + + new_opts->nls = ntfs_load_nls(new_opts->nls_name); + if (IS_ERR(new_opts->nls)) { + new_opts->nls = NULL; + errorf(fc, "ntfs3: Cannot load nls %s", new_opts->nls_name); + return -EINVAL; } + if (new_opts->nls != sbi->options->nls) + return invalf(fc, "ntfs3: Cannot use different nls when remounting!"); sync_filesystem(sb); if (ro_rw && (sbi->volume.flags & VOLUME_FLAG_DIRTY) && - !sbi->options->force) { - ntfs_warn(sb, "volume is dirty and \"force\" flag is not set!"); - err = -EINVAL; - goto restore_opts; + !new_opts->force) { + errorf(fc, "ntfs3: Volume is dirty and \"force\" flag is not set!"); + return -EINVAL; } - clear_mount_options(&old_opts); - - ntfs_info(sb, "re-mounted. Opts: %s", orig_data); - err = 0; - goto out; - -restore_opts: - clear_mount_options(sbi->options); - memcpy(sbi->options, &old_opts, sizeof(old_opts)); + memcpy(sbi->options, new_opts, sizeof(*new_opts)); -out: - kfree(orig_data); - return err; + return 0; } static struct kmem_cache *ntfs_inode_cachep; @@ -506,9 +475,6 @@ static noinline void put_ntfs(struct ntfs_sb_info *sbi) xpress_free_decompressor(sbi->compress.xpress); lzx_free_decompressor(sbi->compress.lzx); #endif - clear_mount_options(sbi->options); - kfree(sbi->options); - kfree(sbi); } @@ -519,7 +485,9 @@ static void ntfs_put_super(struct super_block *sb) /* Mark rw ntfs as clear, if possible. */ ntfs_set_state(sbi, NTFS_DIRTY_CLEAR); + put_mount_options(sbi->options); put_ntfs(sbi); + sb->s_fs_info = NULL; sync_blockdev(sb->s_bdev); } @@ -635,7 +603,6 @@ static const struct super_operations ntfs_sops = { .statfs = ntfs_statfs, .show_options = ntfs_show_options, .sync_fs = ntfs_sync_fs, - .remount_fs = ntfs_remount, .write_inode = ntfs3_write_inode, }; @@ -905,10 +872,10 @@ static int ntfs_init_from_boot(struct super_block *sb, u32 sector_size, /* * ntfs_fill_super - Try to mount. */ -static int ntfs_fill_super(struct super_block *sb, void *data, int silent) +static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) { int err; - struct ntfs_sb_info *sbi; + struct ntfs_sb_info *sbi = sb->s_fs_info; struct block_device *bdev = sb->s_bdev; struct inode *bd_inode = bdev->bd_inode; struct request_queue *rq = bdev_get_queue(bdev); @@ -927,17 +894,6 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent) ref.high = 0; - sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS); - if (!sbi) - return -ENOMEM; - - sbi->options = kzalloc(sizeof(struct ntfs_mount_options), GFP_NOFS); - if (!sbi->options) { - kfree(sbi); - return -ENOMEM; - } - - sb->s_fs_info = sbi; sbi->sb = sb; sb->s_flags |= SB_NODIRATIME; sb->s_magic = 0x7366746e; // "ntfs" @@ -949,9 +905,12 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent) ratelimit_state_init(&sbi->msg_ratelimit, DEFAULT_RATELIMIT_INTERVAL, DEFAULT_RATELIMIT_BURST); - err = ntfs_parse_options(sb, data, silent, sbi->options); - if (err) - goto out; + sbi->options->nls = ntfs_load_nls(sbi->options->nls_name); + if (IS_ERR(sbi->options->nls)) { + sbi->options->nls = NULL; + errorf(fc, "Cannot load nls %s", sbi->options->nls_name); + return -EINVAL; + } if (!rq || !blk_queue_discard(rq) || !rq->limits.discard_granularity) { ; @@ -1344,6 +1303,9 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent) goto out; } + fc->fs_private = NULL; + fc->s_fs_info = NULL; + return 0; out: @@ -1354,9 +1316,6 @@ static int ntfs_fill_super(struct super_block *sb, void *data, int silent) sb->s_root = NULL; } - put_ntfs(sbi); - - sb->s_fs_info = NULL; return err; } @@ -1426,19 +1385,83 @@ int ntfs_discard(struct ntfs_sb_info *sbi, CLST lcn, CLST len) return err; } -static struct dentry *ntfs_mount(struct file_system_type *fs_type, int flags, - const char *dev_name, void *data) +static int ntfs_fs_get_tree(struct fs_context *fc) +{ + return get_tree_bdev(fc, ntfs_fill_super); +} + +/* + * ntfs_fs_free - Free fs_context. + * + * Note that this will be called after fill_super and reconfigure + * even when they pass. So they have to take pointers if they pass. + */ +static void ntfs_fs_free(struct fs_context *fc) +{ + struct ntfs_mount_options *opts = fc->fs_private; + struct ntfs_sb_info *sbi = fc->s_fs_info; + + if (sbi) + put_ntfs(sbi); + + if (opts) + put_mount_options(opts); +} + +static const struct fs_context_operations ntfs_context_ops = { + .parse_param = ntfs_fs_parse_param, + .get_tree = ntfs_fs_get_tree, + .reconfigure = ntfs_fs_reconfigure, + .free = ntfs_fs_free, +}; + +/* + * ntfs_init_fs_context - Initialize spi and opts + * + * This will called when mount/remount. We will first initiliaze + * options so that if remount we can use just that. + */ +static int ntfs_init_fs_context(struct fs_context *fc) { - return mount_bdev(fs_type, flags, dev_name, data, ntfs_fill_super); + struct ntfs_mount_options *opts; + struct ntfs_sb_info *sbi; + + opts = kzalloc(sizeof(struct ntfs_mount_options), GFP_NOFS); + if (!opts) + return -ENOMEM; + + /* Default options. */ + opts->fs_uid = current_uid(); + opts->fs_gid = current_gid(); + opts->fs_fmask_inv = ~current_umask(); + opts->fs_dmask_inv = ~current_umask(); + + if (fc->purpose == FS_CONTEXT_FOR_RECONFIGURE) + goto ok; + + sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS); + if (!sbi) { + kfree(opts); + return -ENOMEM; + } + + sbi->options = opts; + fc->s_fs_info = sbi; +ok: + fc->fs_private = opts; + fc->ops = &ntfs_context_ops; + + return 0; } // clang-format off static struct file_system_type ntfs_fs_type = { - .owner = THIS_MODULE, - .name = "ntfs3", - .mount = ntfs_mount, - .kill_sb = kill_block_super, - .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, + .owner = THIS_MODULE, + .name = "ntfs3", + .init_fs_context = ntfs_init_fs_context, + .parameters = ntfs_fs_parameters, + .kill_sb = kill_block_super, + .fs_flags = FS_REQUIRES_DEV | FS_ALLOW_IDMAP, }; // clang-format on From patchwork Tue Sep 7 15:35:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kari Argillander X-Patchwork-Id: 12478997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 446EFC433F5 for ; Tue, 7 Sep 2021 15:36:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3038D61051 for ; Tue, 7 Sep 2021 15:36:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345497AbhIGPhf (ORCPT ); Tue, 7 Sep 2021 11:37:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345444AbhIGPh3 (ORCPT ); Tue, 7 Sep 2021 11:37:29 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C31EC0617AD; Tue, 7 Sep 2021 08:36:21 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id g14so17229075ljk.5; Tue, 07 Sep 2021 08:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OHuhtZ/zqVhWYfOx8LjsJO6P40iCzJqotJXfGUPKwnc=; b=B0F59id0u0nQtOm/ocn6TOkyxUaIoHlZF8W4Kgpux2eNqZR102GqOYBo1PtrOp/oHe 75CzGemW4B6iq/Z/6ypGu8xRBajPa5wuU9sE2lD1iBiyKnSmXSfRH9sjoUviGgRM8Mf/ jn2s3PlkTaM++9Fl6Wx8qm4xT/2h3coJ+Gmx0wkFuZQh4CbWw9FET8TAv9hMJ/x2z0q5 b2qhyraivB3dg0qqlOdaxH/w8yZ5Kjr1r6N8gbM2cPAXi1Dn83sxIc8GBMaXhUOUMxUI kppITuXWhZWGoLB0GY64Y4kcUFk4jvvRSLVrnOdR1EC7yTBvOlfs+2JkhjpFupXpQDFa 2nDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OHuhtZ/zqVhWYfOx8LjsJO6P40iCzJqotJXfGUPKwnc=; b=awhvoTxm1YAFCXKrpSk+ZW+qvvF01YBunXI+TBmQDc7GwuD0W4867kiTvfhebz5bFn 786bFE0A2J/3okEsSAy0bg7jLMXd6/GUKdtSjSDzB3HOMOhIn2ZLXNPWuFE4at4LUGYz I47EDGx83yzueUiqDfCzcNexpQ/4dm36QzNa8JoAdG/OgLJs3JJfhzSzcGjHzx4XdjKn 2TQ/Ei0/eb5TEBVG40P4LjRM4jTRFY2GBzfo2KOHuEDXOLd8jOgWqCUjkJPRPjzPI5SQ 3JRnjx03dbSGr44DIIEpYo8i85TIDmBUSOTjs33g9axHL+WgAKC2Tc00oG+gHOSJ+uz4 nSuQ== X-Gm-Message-State: AOAM530CFHLvpzSyG2ESJB2GMxYXkIVlsQ3rDS2XvR5jMQbpSPCBw5wS XZM+8wpoA1oU3IG+v7XfrxQ= X-Google-Smtp-Source: ABdhPJxIaHNrWfDtCM7EkmVxUJdKBYe5MzWlSTR6eQZpDWxOt0nYpNX0gUqMRMVAUaMVi6UJW9ldcw== X-Received: by 2002:a2e:8810:: with SMTP id x16mr15537678ljh.410.1631028978113; Tue, 07 Sep 2021 08:36:18 -0700 (PDT) Received: from kari-VirtualBox.telewell.oy ([31.132.12.44]) by smtp.gmail.com with ESMTPSA id p14sm1484458lji.56.2021.09.07.08.36.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 08:36:17 -0700 (PDT) From: Kari Argillander To: Konstantin Komarov , ntfs3@lists.linux.dev Cc: Kari Argillander , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Pali_Roh=C3=A1r?= , Matthew Wilcox , Christian Brauner Subject: [PATCH v4 5/9] fs/ntfs3: Init spi more in init_fs_context than fill_super Date: Tue, 7 Sep 2021 18:35:53 +0300 Message-Id: <20210907153557.144391-6-kari.argillander@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210907153557.144391-1-kari.argillander@gmail.com> References: <20210907153557.144391-1-kari.argillander@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org init_fs_context() is meant to initialize s_fs_info (spi). Move spi initializing code there which we can initialize before fill_super(). Signed-off-by: Kari Argillander --- fs/ntfs3/super.c | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index befa78d3cb26..420cd1409170 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -887,7 +887,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) const struct VOLUME_INFO *info; u32 idx, done, bytes; struct ATTR_DEF_ENTRY *t; - u16 *upcase = NULL; + u16 *upcase; u16 *shared; bool is_ro; struct MFT_REF ref; @@ -902,9 +902,6 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_time_gran = NTFS_TIME_GRAN; // 100 nsec sb->s_xattr = ntfs_xattr_handlers; - ratelimit_state_init(&sbi->msg_ratelimit, DEFAULT_RATELIMIT_INTERVAL, - DEFAULT_RATELIMIT_BURST); - sbi->options->nls = ntfs_load_nls(sbi->options->nls_name); if (IS_ERR(sbi->options->nls)) { sbi->options->nls = NULL; @@ -934,12 +931,6 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) sb->s_maxbytes = 0xFFFFFFFFull << sbi->cluster_bits; #endif - mutex_init(&sbi->compress.mtx_lznt); -#ifdef CONFIG_NTFS3_LZX_XPRESS - mutex_init(&sbi->compress.mtx_xpress); - mutex_init(&sbi->compress.mtx_lzx); -#endif - /* * Load $Volume. This should be done before $LogFile * 'cause 'sbi->volume.ni' is used 'ntfs_set_state'. @@ -1224,11 +1215,7 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc) goto out; } - sbi->upcase = upcase = kvmalloc(0x10000 * sizeof(short), GFP_KERNEL); - if (!upcase) { - err = -ENOMEM; - goto out; - } + upcase = sbi->upcase; for (idx = 0; idx < (0x10000 * sizeof(short) >> PAGE_SHIFT); idx++) { const __le16 *src; @@ -1440,10 +1427,21 @@ static int ntfs_init_fs_context(struct fs_context *fc) goto ok; sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS); - if (!sbi) { - kfree(opts); - return -ENOMEM; - } + if (!sbi) + goto free_opts; + + sbi->upcase = kvmalloc(0x10000 * sizeof(short), GFP_KERNEL); + if (!sbi->upcase) + goto free_sbi; + + ratelimit_state_init(&sbi->msg_ratelimit, DEFAULT_RATELIMIT_INTERVAL, + DEFAULT_RATELIMIT_BURST); + + mutex_init(&sbi->compress.mtx_lznt); +#ifdef CONFIG_NTFS3_LZX_XPRESS + mutex_init(&sbi->compress.mtx_xpress); + mutex_init(&sbi->compress.mtx_lzx); +#endif sbi->options = opts; fc->s_fs_info = sbi; @@ -1452,6 +1450,11 @@ static int ntfs_init_fs_context(struct fs_context *fc) fc->ops = &ntfs_context_ops; return 0; +free_opts: + kfree(opts); +free_sbi: + kfree(sbi); + return -ENOMEM; } // clang-format off From patchwork Tue Sep 7 15:35:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kari Argillander X-Patchwork-Id: 12478999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59EDDC433EF for ; Tue, 7 Sep 2021 15:36:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4799A61132 for ; Tue, 7 Sep 2021 15:36:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345503AbhIGPhg (ORCPT ); Tue, 7 Sep 2021 11:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345453AbhIGPh3 (ORCPT ); Tue, 7 Sep 2021 11:37:29 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F6EFC0617AE; Tue, 7 Sep 2021 08:36:21 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id m28so20332099lfj.6; Tue, 07 Sep 2021 08:36:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ZfTZD2BK9OlT42vnGAs2eW6uulsF/+Be/8upspiEcGI=; b=nn22WeONuQDWrItj4HpTHAQ7dwAX51UBc43MhAZjGfRsvushjj5dGhl96Tj/djaRXk lSawt8oBukDPxxNw+wmfezepiWpSmRJ9LEVm1+XEuzykX1R1d2DeIUH/RdYJnlQW8tk3 euXuamsehkVBr1qgdoyJVT34kwcv1vEGbuVUSvGlcDfZ9732AgqftgSDzbaijBIR58Ol eWWkQZK1TAa0atmDZJMqiHR3mmL9xybJCFFZxKsJQv3LQSOpspKXJy8yWs7ZM0m0pF15 LWDkz/2cojQ04z5BtTImODXX4nW/eBHDxbyHftO6Z9pVyA1HiIs1zSYgMlGBTFIo0BQb L4BQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZfTZD2BK9OlT42vnGAs2eW6uulsF/+Be/8upspiEcGI=; b=XBCK0vgVGesesczAdn0QQtEZgrS7fzoySzKApFpGk3TxJwjH35SiXQLwiEyt1253ZR dYzmlsUQ3gJOhLt/+GFgsNxu6SBkfd/ckKTluMetxwxDw5hmjCBwuBfGhcSf4a+30Pc1 XZ3impqcijyf6/Vd5tzHrQRfomxbodImLySm6kTp13sjLUyeQL8+VkiMj8yjMmu8T0Zj IfWGcmEsnh7H3Oc6VJE5IB7OBhB1tCDO5E3s/d4/4zhih1Fy73P5+0jMAMQ1BFxYBKRB i7pxD23VQ/N4DRnaeG5yUMH/VAA9pUkT1h24TDEHs8ZRu823ce/jgi6JumxhNZ0GkG6T abbA== X-Gm-Message-State: AOAM53014HwjkNAb7d16vj+HJANOjjVXFotGU4mD9gu1Uu1BT4ot2HEt +q+RBJUjCgsXYqZF0HH7x1A= X-Google-Smtp-Source: ABdhPJy3n1OhoIgD3JgIRKoHX/v4Q75f0ng1LbQuWlanfiAQN5PzM7HDJWkJcWYH0J3xw3H1k+67Fg== X-Received: by 2002:a05:6512:388e:: with SMTP id n14mr13431241lft.242.1631028979649; Tue, 07 Sep 2021 08:36:19 -0700 (PDT) Received: from kari-VirtualBox.telewell.oy ([31.132.12.44]) by smtp.gmail.com with ESMTPSA id p14sm1484458lji.56.2021.09.07.08.36.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 08:36:19 -0700 (PDT) From: Kari Argillander To: Konstantin Komarov , ntfs3@lists.linux.dev Cc: Kari Argillander , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Pali_Roh=C3=A1r?= , Matthew Wilcox , Christian Brauner Subject: [PATCH v4 6/9] fs/ntfs3: Make mount option nohidden more universal Date: Tue, 7 Sep 2021 18:35:54 +0300 Message-Id: <20210907153557.144391-7-kari.argillander@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210907153557.144391-1-kari.argillander@gmail.com> References: <20210907153557.144391-1-kari.argillander@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org If we call Opt_nohidden with just keyword hidden, then we can use hidden/nohidden when mounting. We already use this method for almoust all other parameters so it is just logical that this will use same method. Acked-by: Christian Brauner Reviewed-by: Christoph Hellwig Signed-off-by: Kari Argillander Reviewed-by: Pali Rohár --- fs/ntfs3/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 420cd1409170..729ead6f2fac 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -242,7 +242,7 @@ static const struct fs_parameter_spec ntfs_fs_parameters[] = { fsparam_flag_no("discard", Opt_discard), fsparam_flag_no("force", Opt_force), fsparam_flag_no("sparse", Opt_sparse), - fsparam_flag("nohidden", Opt_nohidden), + fsparam_flag_no("hidden", Opt_nohidden), fsparam_flag_no("acl", Opt_acl), fsparam_flag_no("showmeta", Opt_showmeta), fsparam_string("nls", Opt_nls), @@ -331,7 +331,7 @@ static int ntfs_fs_parse_param(struct fs_context *fc, opts->sparse = result.negated ? 0 : 1; break; case Opt_nohidden: - opts->nohidden = 1; + opts->nohidden = result.negated ? 1 : 0; break; case Opt_acl: if (!result.negated) From patchwork Tue Sep 7 15:35:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kari Argillander X-Patchwork-Id: 12479001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BFEEC433F5 for ; Tue, 7 Sep 2021 15:36:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 308EB61051 for ; Tue, 7 Sep 2021 15:36:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345469AbhIGPhg (ORCPT ); Tue, 7 Sep 2021 11:37:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345464AbhIGPhb (ORCPT ); Tue, 7 Sep 2021 11:37:31 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0248C061575; Tue, 7 Sep 2021 08:36:24 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id f2so17258778ljn.1; Tue, 07 Sep 2021 08:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Epwz9tOgzNdT5eJf6A6dPhiUiuiznCpEaozn8HC4mtE=; b=aclqQKLURedcL8YOp8JmRei8QCBPzB/+7FryeRIOuCxEZds/Y/yoOc01vpj3PYr0m7 pt+41iqBuvPhcEknCaPpRrWVrySfUaZ4NcymHreqFFbgaHqzVLb0UVG+p9936ebtzHGF iNA06ICMDybNjDoyARNj5eJtI1LF2qMTwj+oWZWacvQ4+FjZrmbazZPCM5wlmuSzLSly FW+O6QXiXorvQ8Q6tXQ9DlvImWPxC9O9+pB5E0xtncblo43QZoccUYT8wKG460IEufor wHxgzAdlnGC+izoS5Mda+gOR0gmWi3mnE9anr1k9a3pcvGWd3PYrWMUHpjBOtGRY6z/i xYFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Epwz9tOgzNdT5eJf6A6dPhiUiuiznCpEaozn8HC4mtE=; b=ai/KyBUDnLkeldUUiBLgKZbobPzp0toOQ/BTEFp7VHxCM1YuHvfbZCZra6VV17CEDj gBAwRUhbJdk8dJ6bCfGQP8zR/wymzm6A6X90x/aCn1SNOnOtmxQynlXsFiFCtLBaHdh2 Uuo0pQVRQfcbdRN5qh2Mzn5BtgQsYk5awa0HC4iPP+EK1+Qv53F1rTZN1bG0dkhcp/3Y Jfw1J4Uk6lp/TJA1Wy01UKuc7MFgLcu0cmZCxarK4Mlr8vX16hHrrV0Px6vvXlpVQtF7 xBQP2DCKFgog9nj6yOADsCszJ+wVkST2P2NSfhKCMVb9yjZ+SEDPm9nRUwRS4Dq1vxYy oHxg== X-Gm-Message-State: AOAM533dbgWcxIiTj+ImvcoHpN1qesqpMxVVHEZK9eME4NEDz0hUR4WH aXmpDPvDgJx0fJMFZ8uFu6o= X-Google-Smtp-Source: ABdhPJwx/9G/1Sh8TeuVIbvlSLdoKlW78mtKLU4Vm5q47XvdIemAJOanz3QYviGH/tliK3b2ezpGYA== X-Received: by 2002:a05:651c:178d:: with SMTP id bn13mr15428224ljb.530.1631028983294; Tue, 07 Sep 2021 08:36:23 -0700 (PDT) Received: from kari-VirtualBox.telewell.oy ([31.132.12.44]) by smtp.gmail.com with ESMTPSA id p14sm1484458lji.56.2021.09.07.08.36.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 08:36:22 -0700 (PDT) From: Kari Argillander To: Konstantin Komarov , ntfs3@lists.linux.dev Cc: Kari Argillander , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Pali_Roh=C3=A1r?= , Matthew Wilcox , Christian Brauner Subject: [PATCH v4 7/9] fs/ntfs3: Add iocharset= mount option as alias for nls= Date: Tue, 7 Sep 2021 18:35:55 +0300 Message-Id: <20210907153557.144391-8-kari.argillander@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210907153557.144391-1-kari.argillander@gmail.com> References: <20210907153557.144391-1-kari.argillander@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Other fs drivers are using iocharset= mount option for specifying charset. So add it also for ntfs3 and mark old nls= mount option as deprecated. Signed-off-by: Kari Argillander Reviewed-by: Pali Rohár --- Documentation/filesystems/ntfs3.rst | 4 ++-- fs/ntfs3/super.c | 18 +++++++++++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Documentation/filesystems/ntfs3.rst b/Documentation/filesystems/ntfs3.rst index af7158de6fde..ded706474825 100644 --- a/Documentation/filesystems/ntfs3.rst +++ b/Documentation/filesystems/ntfs3.rst @@ -32,12 +32,12 @@ generic ones. =============================================================================== -nls=name This option informs the driver how to interpret path +iocharset=name This option informs the driver how to interpret path strings and translate them to Unicode and back. If this option is not set, the default codepage will be used (CONFIG_NLS_DEFAULT). Examples: - 'nls=utf8' + 'iocharset=utf8' uid= gid= diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 729ead6f2fac..503e2e23f711 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -226,7 +226,7 @@ enum Opt { Opt_nohidden, Opt_showmeta, Opt_acl, - Opt_nls, + Opt_iocharset, Opt_prealloc, Opt_no_acs_rules, Opt_err, @@ -245,9 +245,13 @@ static const struct fs_parameter_spec ntfs_fs_parameters[] = { fsparam_flag_no("hidden", Opt_nohidden), fsparam_flag_no("acl", Opt_acl), fsparam_flag_no("showmeta", Opt_showmeta), - fsparam_string("nls", Opt_nls), fsparam_flag_no("prealloc", Opt_prealloc), fsparam_flag("no_acs_rules", Opt_no_acs_rules), + fsparam_string("iocharset", Opt_iocharset), + + __fsparam(fs_param_is_string, + "nls", Opt_iocharset, + fs_param_deprecated, NULL), {} }; @@ -346,7 +350,7 @@ static int ntfs_fs_parse_param(struct fs_context *fc, case Opt_showmeta: opts->showmeta = result.negated ? 0 : 1; break; - case Opt_nls: + case Opt_iocharset: kfree(opts->nls_name); opts->nls_name = param->string; param->string = NULL; @@ -380,11 +384,11 @@ static int ntfs_fs_reconfigure(struct fs_context *fc) new_opts->nls = ntfs_load_nls(new_opts->nls_name); if (IS_ERR(new_opts->nls)) { new_opts->nls = NULL; - errorf(fc, "ntfs3: Cannot load nls %s", new_opts->nls_name); + errorf(fc, "ntfs3: Cannot load iocharset %s", new_opts->nls_name); return -EINVAL; } if (new_opts->nls != sbi->options->nls) - return invalf(fc, "ntfs3: Cannot use different nls when remounting!"); + return invalf(fc, "ntfs3: Cannot use different iocharset when remounting!"); sync_filesystem(sb); @@ -528,9 +532,9 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root) if (opts->dmask) seq_printf(m, ",dmask=%04o", ~opts->fs_dmask_inv); if (opts->nls) - seq_printf(m, ",nls=%s", opts->nls->charset); + seq_printf(m, ",iocharset=%s", opts->nls->charset); else - seq_puts(m, ",nls=utf8"); + seq_puts(m, ",iocharset=utf8"); if (opts->sys_immutable) seq_puts(m, ",sys_immutable"); if (opts->discard) From patchwork Tue Sep 7 15:35:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kari Argillander X-Patchwork-Id: 12479003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C51DC433F5 for ; Tue, 7 Sep 2021 15:36:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 164DC6108D for ; Tue, 7 Sep 2021 15:36:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345614AbhIGPhr (ORCPT ); Tue, 7 Sep 2021 11:37:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345495AbhIGPhf (ORCPT ); Tue, 7 Sep 2021 11:37:35 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B376C06179A; Tue, 7 Sep 2021 08:36:28 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id h1so17223343ljl.9; Tue, 07 Sep 2021 08:36:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6IBOhrHMY/c1tfwUMPdU4gIC4AvL9Y2ZEu59nLM3Bis=; b=ecuY4YKKqY9hcXGVgcr5eF6494AIrirQii9krUItCo+qkAgsKVoph54s8t7Iy2wKDI ciFIB303/DuMBw8wqrCNcV2J0fZae4BNrYGctK33CNJpwEUdhP54Kgo4DwsmNbILVCgB g81DUJ3/Bbx6psqZeKu2zgxOJrJmGxEFi06NLa64SKUulTWhAHX9Qnfe4opfekArtskT zQJD2csRnZ4vRs3HqVmhtp4yHYGOLHm4ey/9julIymM1sk+No2FYfDGSEP8unMCHHsXr 3BXhx+y241cMSZiyz0im/U96+dd7gEnA+oJHq2IB/DAkwHKIzXNYo//8B+C4wt7TZle6 3xuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6IBOhrHMY/c1tfwUMPdU4gIC4AvL9Y2ZEu59nLM3Bis=; b=V+mHqlppl2OZqcBPgNLgNEN//rX4jiQ9DPul3/gZaVpd4mDnCNi5q/CFI9k7ZITddS UlOSlrQ7fbbhpcXDinrzJmj69fb2BY51NEx9AJId82tt32w0g+0rzHMQGU7pbDm83Mc8 g+iQHzIWod9Iry/SGzKuSTK/1sWusQEfN6LFRJ9QHxSnW1TrxYv7RdZYgOH7qDf2TjHf tI2eu93Jtwe9XzpaXeCaQIESzLqZJ0fXCvl+xLyQ/p01rTt8NlJlHZSt3QiGvQlcq2M+ eCWvhGlnDJO/6Q0l0pRZhx7A7Xtib6Vtl6absKMvLdslCRLNHbFJvv2esuwO+F+Wqc+W XJBg== X-Gm-Message-State: AOAM530GUe9xCaQ0jqMvR9f9BCaiRxo1jgwlbSERpgJj6k1ZJFcZhSEt u7fImBtJo6a5XM8oPH3Bwx0= X-Google-Smtp-Source: ABdhPJwpmkQPafKAJkRMMmr+44q6bqHZjG8USn5+w+wAveGGiMn9+GDaA6WHOcgJotZAMY4rGoeKmw== X-Received: by 2002:a2e:9dcb:: with SMTP id x11mr15667575ljj.137.1631028986922; Tue, 07 Sep 2021 08:36:26 -0700 (PDT) Received: from kari-VirtualBox.telewell.oy ([31.132.12.44]) by smtp.gmail.com with ESMTPSA id p14sm1484458lji.56.2021.09.07.08.36.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 08:36:26 -0700 (PDT) From: Kari Argillander To: Konstantin Komarov , ntfs3@lists.linux.dev Cc: Kari Argillander , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Pali_Roh=C3=A1r?= , Matthew Wilcox , Christian Brauner Subject: [PATCH v4 8/9] fs/ntfs3: Rename mount option no_acs_rules > (no)acsrules Date: Tue, 7 Sep 2021 18:35:56 +0300 Message-Id: <20210907153557.144391-9-kari.argillander@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210907153557.144391-1-kari.argillander@gmail.com> References: <20210907153557.144391-1-kari.argillander@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Rename mount option no_acs_rules to (no)acsrules. This allow us to use possibility to mount with options noaclrules or aclrules. Acked-by: Christian Brauner Reviewed-by: Christoph Hellwig Signed-off-by: Kari Argillander --- Documentation/filesystems/ntfs3.rst | 2 +- fs/ntfs3/file.c | 2 +- fs/ntfs3/ntfs_fs.h | 2 +- fs/ntfs3/super.c | 12 ++++++------ fs/ntfs3/xattr.c | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Documentation/filesystems/ntfs3.rst b/Documentation/filesystems/ntfs3.rst index ded706474825..7b6afe452197 100644 --- a/Documentation/filesystems/ntfs3.rst +++ b/Documentation/filesystems/ntfs3.rst @@ -73,7 +73,7 @@ prealloc Preallocate space for files excessively when file size is increasing on writes. Decreases fragmentation in case of parallel write operations to different files. -no_acs_rules "No access rules" mount option sets access rights for +noacsrules "No access rules" mount option sets access rights for files/folders to 777 and owner/group to root. This mount option absorbs all other permissions: - permissions change for files/folders will be reported diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c index fef57141b161..0743d806c567 100644 --- a/fs/ntfs3/file.c +++ b/fs/ntfs3/file.c @@ -737,7 +737,7 @@ int ntfs3_setattr(struct user_namespace *mnt_userns, struct dentry *dentry, umode_t mode = inode->i_mode; int err; - if (sbi->options->no_acs_rules) { + if (sbi->options->noacsrules) { /* "No access rules" - Force any changes of time etc. */ attr->ia_valid |= ATTR_FORCE; /* and disable for editing some attributes. */ diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index aa18f12b7096..15bab48bc1ad 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -70,7 +70,7 @@ struct ntfs_mount_options { showmeta : 1, /* Show meta files. */ nohidden : 1, /* Do not show hidden files. */ force : 1, /* Rw mount dirty volume. */ - no_acs_rules : 1, /*Exclude acs rules. */ + noacsrules : 1, /*Exclude acs rules. */ prealloc : 1 /* Preallocate space when file is growing. */ ; }; diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 503e2e23f711..0690e7e4f00d 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -228,7 +228,7 @@ enum Opt { Opt_acl, Opt_iocharset, Opt_prealloc, - Opt_no_acs_rules, + Opt_noacsrules, Opt_err, }; @@ -246,7 +246,7 @@ static const struct fs_parameter_spec ntfs_fs_parameters[] = { fsparam_flag_no("acl", Opt_acl), fsparam_flag_no("showmeta", Opt_showmeta), fsparam_flag_no("prealloc", Opt_prealloc), - fsparam_flag("no_acs_rules", Opt_no_acs_rules), + fsparam_flag_no("acsrules", Opt_noacsrules), fsparam_string("iocharset", Opt_iocharset), __fsparam(fs_param_is_string, @@ -358,8 +358,8 @@ static int ntfs_fs_parse_param(struct fs_context *fc, case Opt_prealloc: opts->prealloc = result.negated ? 0 : 1; break; - case Opt_no_acs_rules: - opts->no_acs_rules = 1; + case Opt_noacsrules: + opts->noacsrules = result.negated ? 1 : 0; break; default: /* Should not be here unless we forget add case. */ @@ -547,8 +547,8 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root) seq_puts(m, ",nohidden"); if (opts->force) seq_puts(m, ",force"); - if (opts->no_acs_rules) - seq_puts(m, ",no_acs_rules"); + if (opts->noacsrules) + seq_puts(m, ",noacsrules"); if (opts->prealloc) seq_puts(m, ",prealloc"); if (sb->s_flags & SB_POSIXACL) diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c index ac4b37bf8832..6f88cb77a17f 100644 --- a/fs/ntfs3/xattr.c +++ b/fs/ntfs3/xattr.c @@ -769,7 +769,7 @@ int ntfs_acl_chmod(struct user_namespace *mnt_userns, struct inode *inode) int ntfs_permission(struct user_namespace *mnt_userns, struct inode *inode, int mask) { - if (ntfs_sb(inode->i_sb)->options->no_acs_rules) { + if (ntfs_sb(inode->i_sb)->options->noacsrules) { /* "No access rules" mode - Allow all changes. */ return 0; } From patchwork Tue Sep 7 15:35:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kari Argillander X-Patchwork-Id: 12479005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 43ABEC433F5 for ; Tue, 7 Sep 2021 15:36:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2B4BC6108D for ; Tue, 7 Sep 2021 15:36:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345649AbhIGPhw (ORCPT ); Tue, 7 Sep 2021 11:37:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345515AbhIGPhh (ORCPT ); Tue, 7 Sep 2021 11:37:37 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73448C061757; Tue, 7 Sep 2021 08:36:30 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id m28so20332960lfj.6; Tue, 07 Sep 2021 08:36:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Ylxb5RZ+eMJvrKhxMzlFWiAiShFTuT1l3TN+viEp6UY=; b=bTiYvWMbHeuqnhR0ZZ7sF/A3QNiMGYrTuIy1x4pDCfq3Hy57eWQFfLIzLCjvMbOCh9 y8KHuUa2g3U32Rt49yN2OuzEpXFWKEokWQYVW71+8okQuJCVFh9G+xhkmllEgvUEgZa2 e6bKeeb7t05489op6NF2PBSNmIXueAGSkYAJQGYlwQM27dNd7i9IeJFOWv/e+6hMHKrt adZHBIT71wUuJs6drLNSGmIIZiRMjYsgtGY2m6CT3DD/maxM0ZqsdScSXVXD6JnFXust Xc/qZ6AQ/VsKM/cmober/QfbUL2b+L8eEXnjHXP3iSvzrY2S21tDYZGMfmh5ZCyv0Cxs r8+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Ylxb5RZ+eMJvrKhxMzlFWiAiShFTuT1l3TN+viEp6UY=; b=Udw1R7krJ6G1+PdPmbv0MHA3f3t6Poo2mi61di/uS9EyfuvjclQTvCJhEOvnyGH2hE swkZJ/e5jCn5jta5rJa8grh/vlkUZMdhbBDfUNx1VCZviQoFhCzHtgtAPEvmA1mHyGAN tic29E33oB56tBBk640BhQ71iUEveF+2IOdIJi1+H8vbMSwS6LljD9v26UzdA0AOAPVy rcn+zTXR3g4X0c/s3J6/hw+BhYWpdvgn4sNvmmsev57vePBVCzhv0frRiX8VHxysqN9j gAb7MERDAAMJFctE4ZZTrizbNiT4TiW19BCc0NJpfsAKqTPSsx8DGnJWOjxYoYJCKuGV 23CA== X-Gm-Message-State: AOAM530BZ6etPHDDsT6IDX/6nqIWYW9Za/65itnaZrcYplj+rO3hbqdU eCdMUpZtmj0FlXMBB2z1glI= X-Google-Smtp-Source: ABdhPJww8obqgjqp+QMqrJ/aiJi9o7nTCoVkSIvWmlT0cZSwVG8oFr0dlhrzE6CWhirxyPi5ckXNYA== X-Received: by 2002:ac2:4906:: with SMTP id n6mr13046916lfi.381.1631028988446; Tue, 07 Sep 2021 08:36:28 -0700 (PDT) Received: from kari-VirtualBox.telewell.oy ([31.132.12.44]) by smtp.gmail.com with ESMTPSA id p14sm1484458lji.56.2021.09.07.08.36.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Sep 2021 08:36:28 -0700 (PDT) From: Kari Argillander To: Konstantin Komarov , ntfs3@lists.linux.dev Cc: Kari Argillander , Christoph Hellwig , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, =?utf-8?q?Pali_Roh=C3=A1r?= , Matthew Wilcox , Christian Brauner Subject: [PATCH v4 9/9] fs/ntfs3: Show uid/gid always in show_options() Date: Tue, 7 Sep 2021 18:35:57 +0300 Message-Id: <20210907153557.144391-10-kari.argillander@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210907153557.144391-1-kari.argillander@gmail.com> References: <20210907153557.144391-1-kari.argillander@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Show options should show option according documentation when some value is not default or when ever coder wants. Uid/gid are problematic because it is hard to know which are defaults. In file system there is many different implementation for this problem. Some file systems show uid/gid when they are different than root, some when user has set them and some show them always. There is also problem that what if root uid/gid change. This code just choose to show them always. This way we do not need to think this any more. Signed-off-by: Kari Argillander --- fs/ntfs3/ntfs_fs.h | 23 ++++++++++------------- fs/ntfs3/super.c | 12 ++++-------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h index 15bab48bc1ad..372cda697dd4 100644 --- a/fs/ntfs3/ntfs_fs.h +++ b/fs/ntfs3/ntfs_fs.h @@ -60,19 +60,16 @@ struct ntfs_mount_options { u16 fs_fmask_inv; u16 fs_dmask_inv; - unsigned uid : 1, /* uid was set. */ - gid : 1, /* gid was set. */ - fmask : 1, /* fmask was set. */ - dmask : 1, /* dmask was set. */ - sys_immutable : 1, /* Immutable system files. */ - discard : 1, /* Issue discard requests on deletions. */ - sparse : 1, /* Create sparse files. */ - showmeta : 1, /* Show meta files. */ - nohidden : 1, /* Do not show hidden files. */ - force : 1, /* Rw mount dirty volume. */ - noacsrules : 1, /*Exclude acs rules. */ - prealloc : 1 /* Preallocate space when file is growing. */ - ; + unsigned fmask : 1; /* fmask was set. */ + unsigned dmask : 1; /*dmask was set. */ + unsigned sys_immutable : 1; /* Immutable system files. */ + unsigned discard : 1; /* Issue discard requests on deletions. */ + unsigned sparse : 1; /* Create sparse files. */ + unsigned showmeta : 1; /* Show meta files. */ + unsigned nohidden : 1; /* Do not show hidden files. */ + unsigned force : 1; /* RW mount dirty volume. */ + unsigned noacsrules : 1; /* Exclude acs rules. */ + unsigned prealloc : 1; /* Preallocate space when file is growing. */ }; /* Special value to unpack and deallocate. */ diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c index 0690e7e4f00d..3cba0b5e7ac7 100644 --- a/fs/ntfs3/super.c +++ b/fs/ntfs3/super.c @@ -294,13 +294,11 @@ static int ntfs_fs_parse_param(struct fs_context *fc, opts->fs_uid = make_kuid(current_user_ns(), result.uint_32); if (!uid_valid(opts->fs_uid)) return invalf(fc, "ntfs3: Invalid value for uid."); - opts->uid = 1; break; case Opt_gid: opts->fs_gid = make_kgid(current_user_ns(), result.uint_32); if (!gid_valid(opts->fs_gid)) return invalf(fc, "ntfs3: Invalid value for gid."); - opts->gid = 1; break; case Opt_umask: if (result.uint_32 & ~07777) @@ -521,12 +519,10 @@ static int ntfs_show_options(struct seq_file *m, struct dentry *root) struct ntfs_mount_options *opts = sbi->options; struct user_namespace *user_ns = seq_user_ns(m); - if (opts->uid) - seq_printf(m, ",uid=%u", - from_kuid_munged(user_ns, opts->fs_uid)); - if (opts->gid) - seq_printf(m, ",gid=%u", - from_kgid_munged(user_ns, opts->fs_gid)); + seq_printf(m, ",uid=%u", + from_kuid_munged(user_ns, opts->fs_uid)); + seq_printf(m, ",gid=%u", + from_kgid_munged(user_ns, opts->fs_gid)); if (opts->fmask) seq_printf(m, ",fmask=%04o", ~opts->fs_fmask_inv); if (opts->dmask)