From patchwork Thu Oct 18 13:11:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10647181 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5587617D4 for ; Thu, 18 Oct 2018 13:11:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 461C1288C6 for ; Thu, 18 Oct 2018 13:11:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A3BA288DB; Thu, 18 Oct 2018 13:11:37 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 C4A54288C6 for ; Thu, 18 Oct 2018 13:11:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727539AbeJRVMc (ORCPT ); Thu, 18 Oct 2018 17:12:32 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35555 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727343AbeJRVMb (ORCPT ); Thu, 18 Oct 2018 17:12:31 -0400 Received: by mail-wr1-f66.google.com with SMTP id w5-v6so33624580wrt.2 for ; Thu, 18 Oct 2018 06:11:31 -0700 (PDT) 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; bh=SMDQxmau8DWThpIhYjetUOOGiLigaeZDiZzGJtsaTwY=; b=GDuTGTDXqqaGWreroLCFGL1viUTpPiezooLgCpkz3lSo8NKWmfDNYRK97RJpxjNs0+ gxb6srO0uiUQk1SV68cxwW9Yy2d+b8uu8Yq+Ma7eDgVzNweT98wsL3bihnONTG4zsJ4+ G0doX8mV7+7vBg4auBZgThZOWkQ+xS1WGm8Ua6la3M3TiwdvD8GOP1xXci+NBbsR+DMH WhJBax+FK/SJvAe/FGk1A4EGNpeGlYx/7pqQz3zmm70B1mgZIet++pc8ULhTGSOnaDQZ 1KGsXTKDLVUQ3YcoqAIuS60/0m52Me0tgkJfJVBbP0Z/yhHDBbrFTxBv8zzgVWh8ao1Q WNlw== X-Gm-Message-State: ABuFfohTn9BUb2FZghv6i2Y671f85KJGm4T+Atu/+i9K0Da6cXrfHKST Oj+uMfZBkrcIBJip8AV3eb9Jdz7Br9w= X-Google-Smtp-Source: ACcGV609Nre9UfohobsKg8Q5C3X6Z5Ukg8Tabur8K3kEugM7t4lw5Dqa/Ff33qF8FDneozpL/VYjXw== X-Received: by 2002:adf:cc8a:: with SMTP id p10-v6mr7521732wrj.208.1539868290937; Thu, 18 Oct 2018 06:11:30 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id u5-v6sm22246965wru.16.2018.10.18.06.11.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 06:11:29 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, David Howells , Michael Kerrisk , Andreas Dilger , Florian Weimer , Amir Goldstein , Mike Marshall , Martin Brandenburg Subject: [PATCH 1/3] orangefs: fix request_mask misuse Date: Thu, 18 Oct 2018 15:11:23 +0200 Message-Id: <20181018131125.6303-1-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Orangefs only handles STATX_BASIC_STATS in its getattr implementation, so mask off all other flags. Not doing so results in statx(2) forcing a refresh of cached attributes on any other requested flag (i.e. STATX_BTIME currently) due to the following test in orangefs_inode_getattr(): (request_mask & orangefs_inode->getattr_mask) == request_mask Also clean up gratuitous uses of STATX_ALL. Signed-off-by: Miklos Szeredi Cc: Mike Marshall Cc: Martin Brandenburg Reviewed-by: Martin Brandenburg --- fs/orangefs/inode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c index 31932879b716..bd7f15a831dc 100644 --- a/fs/orangefs/inode.c +++ b/fs/orangefs/inode.c @@ -256,7 +256,8 @@ int orangefs_getattr(const struct path *path, struct kstat *stat, "orangefs_getattr: called on %pd\n", path->dentry); - ret = orangefs_inode_getattr(inode, 0, 0, request_mask); + ret = orangefs_inode_getattr(inode, 0, 0, + request_mask & STATX_BASIC_STATS); if (ret == 0) { generic_fillattr(inode, stat); @@ -408,7 +409,7 @@ struct inode *orangefs_iget(struct super_block *sb, if (!inode || !(inode->i_state & I_NEW)) return inode; - error = orangefs_inode_getattr(inode, 1, 1, STATX_ALL); + error = orangefs_inode_getattr(inode, 1, 1, STATX_BASIC_STATS); if (error) { iget_failed(inode); return ERR_PTR(error); @@ -453,7 +454,7 @@ struct inode *orangefs_new_inode(struct super_block *sb, struct inode *dir, orangefs_set_inode(inode, ref); inode->i_ino = hash; /* needed for stat etc */ - error = orangefs_inode_getattr(inode, 1, 1, STATX_ALL); + error = orangefs_inode_getattr(inode, 1, 1, STATX_BASIC_STATS); if (error) goto out_iput; From patchwork Thu Oct 18 13:11:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10647185 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 612223B73 for ; Thu, 18 Oct 2018 13:11:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52D17288C6 for ; Thu, 18 Oct 2018 13:11:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46FB6288C7; Thu, 18 Oct 2018 13:11:53 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 DA7FF288DB for ; Thu, 18 Oct 2018 13:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727608AbeJRVMd (ORCPT ); Thu, 18 Oct 2018 17:12:33 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:40694 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727526AbeJRVMc (ORCPT ); Thu, 18 Oct 2018 17:12:32 -0400 Received: by mail-wr1-f67.google.com with SMTP id d2-v6so33642981wro.7 for ; Thu, 18 Oct 2018 06:11:33 -0700 (PDT) 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; bh=YyfqgKkjEhHK1doopwRy4hxgyNxsDM7seik12mtBO10=; b=kSQ2RswclI7khkKv64I+JEiE25ORb2koZx4lQTvn0rIC7o2+0jx6ZzTBAgQIjNp/Le VLhqNwh2EkcLVBUwxZyxm39Tt8J/Kvj7Wa5zy2tkC304rwlKzBlFI5gXzMKLvD+UDSe4 agUPGW2Rz22At7isVUHVZodTrmJROZygb0cCT8fVehoYC2GzItFv9lO1QxeZ7zHsybuU RnhjgOdSUHaBQW12kKcbG3ZcoO99SDKjXKkusPSgNxe20K7ldPlYCzKrNidCk/Ac4isu sO+An4xdNRRHOYvVZtv8D+YDx9hZTNw8jWP6mOvv8/h2qQZodtJU8raEpgJs8iBsn4XU FuDg== X-Gm-Message-State: ABuFfohDsQXAsbYuzJ3azFQn8aNyxN4sYpX+dWSBo08xZgVbtRifcMaf lASYsHYNu0+E4yiDfU7nzf+7j5myWaw= X-Google-Smtp-Source: ACcGV62Ck2kCpd5V0KcC6yZ5th3yCp8Otnv65wjw0hASAeUmEZ54XyvW8HgOcwuzuEXuFLlxAPoJdg== X-Received: by 2002:adf:f404:: with SMTP id g4-v6mr7773386wro.198.1539868292412; Thu, 18 Oct 2018 06:11:32 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id u5-v6sm22246965wru.16.2018.10.18.06.11.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 06:11:31 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, David Howells , Michael Kerrisk , Andreas Dilger , Florian Weimer , Amir Goldstein Subject: [PATCH 2/3] uapi: get rid of STATX_ALL Date: Thu, 18 Oct 2018 15:11:24 +0200 Message-Id: <20181018131125.6303-2-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181018131125.6303-1-mszeredi@redhat.com> References: <20181018131125.6303-1-mszeredi@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Constants of the *_ALL type can be actively harmful due to the fact that developers will usually fail to consider the possible effects of future changes to the definition. Remove STATX_ALL from the uapi, while no damage has been done yet. We could keep something like this around in the kernel, but there's actually no point, since all filesystems should be explicitly checking flags that they support and not rely on the VFS masking unknown ones out: a flag could be known to the VFS, yet not known to the filesystem (see orangefs bug fixed in the previous patch). Signed-off-by: Miklos Szeredi Cc: David Howells Cc: Michael Kerrisk --- fs/stat.c | 1 - include/uapi/linux/stat.h | 2 +- samples/statx/test-statx.c | 2 +- tools/include/uapi/linux/stat.h | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/stat.c b/fs/stat.c index f8e6fb2c3657..8d297a279991 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -73,7 +73,6 @@ int vfs_getattr_nosec(const struct path *path, struct kstat *stat, memset(stat, 0, sizeof(*stat)); stat->result_mask |= STATX_BASIC_STATS; - request_mask &= STATX_ALL; query_flags &= KSTAT_QUERY_FLAGS; if (inode->i_op->getattr) return inode->i_op->getattr(path, stat, request_mask, diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h index 7b35e98d3c58..370f09d92fa6 100644 --- a/include/uapi/linux/stat.h +++ b/include/uapi/linux/stat.h @@ -148,7 +148,7 @@ struct statx { #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ -#define STATX_ALL 0x00000fffU /* All currently supported flags */ + #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ /* diff --git a/samples/statx/test-statx.c b/samples/statx/test-statx.c index d4d77b09412c..e354048dea3c 100644 --- a/samples/statx/test-statx.c +++ b/samples/statx/test-statx.c @@ -211,7 +211,7 @@ int main(int argc, char **argv) struct statx stx; int ret, raw = 0, atflag = AT_SYMLINK_NOFOLLOW; - unsigned int mask = STATX_ALL; + unsigned int mask = STATX_BASIC_STATS | STATX_BTIME; for (argv++; *argv; argv++) { if (strcmp(*argv, "-F") == 0) { diff --git a/tools/include/uapi/linux/stat.h b/tools/include/uapi/linux/stat.h index 7b35e98d3c58..370f09d92fa6 100644 --- a/tools/include/uapi/linux/stat.h +++ b/tools/include/uapi/linux/stat.h @@ -148,7 +148,7 @@ struct statx { #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ -#define STATX_ALL 0x00000fffU /* All currently supported flags */ + #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ /* From patchwork Thu Oct 18 13:11:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miklos Szeredi X-Patchwork-Id: 10647183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1A54517D4 for ; Thu, 18 Oct 2018 13:11:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05A2F288C6 for ; Thu, 18 Oct 2018 13:11:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EBB59288DC; Thu, 18 Oct 2018 13:11:52 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI 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 88D3E288C6 for ; Thu, 18 Oct 2018 13:11:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727550AbeJRVMt (ORCPT ); Thu, 18 Oct 2018 17:12:49 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:38004 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727567AbeJRVMd (ORCPT ); Thu, 18 Oct 2018 17:12:33 -0400 Received: by mail-wr1-f65.google.com with SMTP id a13-v6so33650304wrt.5 for ; Thu, 18 Oct 2018 06:11:34 -0700 (PDT) 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; bh=OtkmpEPbA/uDUjnzZb7wK0E7hpxNB+LznWScKZ/Q3fg=; b=KIpkCJwpv55kwPrP/fxJDP58dWDSdqFenNJjpjgMUANJvkhG7r/oHHQiurc6o7fnVk PF4RFI+6nCc2OsaNOfRUXT34ShhfVgAbBp1f/xi6coE4p3SCD+4qrBRxUeL0CcTejtPG 1zvD2TdFftZ2Ttkc5vADJlhOUwu6pCEi959KwyYGv7k1BxkfOi9OTVTKVqX18ja9W0Gb Slcp2CLAkNVz1N7k04wOo76NSObB7KIKN391YHnzE5aLHgws9Jzm698RqO79QBW4mT1k bB+fH6HGAmdOjVqlUcAsbA2nLp+w/6dFEyIogsVUyLMl833lwnLNpKOtTV4SJcXv5tCG 9OCw== X-Gm-Message-State: ABuFfohLdE3AkkwDJjFZSA06ly9q24DEFQ7jn+2jYKeNsEJNla7HU2yw oCEkGZt8QibJlj7PwOSIILJajq5tc60= X-Google-Smtp-Source: ACcGV63MdVp0Ch+GYIZzSyLP1v25GFOerViqQPcunER/yuj6bcxIZK32VFsRZSrw7vUVAxikIa5yFA== X-Received: by 2002:a5d:4292:: with SMTP id k18-v6mr27993795wrq.225.1539868293844; Thu, 18 Oct 2018 06:11:33 -0700 (PDT) Received: from veci.piliscsaba.redhat.com (catv-212-96-48-140.catv.broadband.hu. [212.96.48.140]) by smtp.gmail.com with ESMTPSA id u5-v6sm22246965wru.16.2018.10.18.06.11.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Oct 2018 06:11:33 -0700 (PDT) From: Miklos Szeredi To: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, David Howells , Michael Kerrisk , Andreas Dilger , Florian Weimer , Amir Goldstein Subject: [PATCH 3/3] statx: add STATX_ATTRIBUTES flag Date: Thu, 18 Oct 2018 15:11:25 +0200 Message-Id: <20181018131125.6303-3-mszeredi@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20181018131125.6303-1-mszeredi@redhat.com> References: <20181018131125.6303-1-mszeredi@redhat.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP FUSE will want to know if stx_attributes is interesting or not, because there's a non-zero cost of retreiving it. This is more of a "want" flag, since stx_attributes_mask already indicates whether we "got" stx_attributes or not. So for now we can just deal with this flag in the generic code. Signed-off-by: Miklos Szeredi Cc: David Howells Cc: Michael Kerrisk Reviewed-by: Andreas Dilger --- fs/stat.c | 3 +++ include/uapi/linux/stat.h | 1 + samples/statx/test-statx.c | 2 +- tools/include/uapi/linux/stat.h | 1 + 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/stat.c b/fs/stat.c index 8d297a279991..6bf86d57e2e3 100644 --- a/fs/stat.c +++ b/fs/stat.c @@ -535,6 +535,9 @@ cp_statx(const struct kstat *stat, struct statx __user *buffer) tmp.stx_size = stat->size; tmp.stx_blocks = stat->blocks; tmp.stx_attributes_mask = stat->attributes_mask; + /* Having anything in attributes_mask means attributes are valid. */ + if (tmp.stx_attributes_mask) + tmp.stx_mask |= STATX_ATTRIBUTES; tmp.stx_atime.tv_sec = stat->atime.tv_sec; tmp.stx_atime.tv_nsec = stat->atime.tv_nsec; tmp.stx_btime.tv_sec = stat->btime.tv_sec; diff --git a/include/uapi/linux/stat.h b/include/uapi/linux/stat.h index 370f09d92fa6..aef0aba5dfe7 100644 --- a/include/uapi/linux/stat.h +++ b/include/uapi/linux/stat.h @@ -148,6 +148,7 @@ struct statx { #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ +#define STATX_ATTRIBUTES 0x00001000U /* Want/got stx_attributes */ #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */ diff --git a/samples/statx/test-statx.c b/samples/statx/test-statx.c index e354048dea3c..deef9a68ff68 100644 --- a/samples/statx/test-statx.c +++ b/samples/statx/test-statx.c @@ -211,7 +211,7 @@ int main(int argc, char **argv) struct statx stx; int ret, raw = 0, atflag = AT_SYMLINK_NOFOLLOW; - unsigned int mask = STATX_BASIC_STATS | STATX_BTIME; + unsigned int mask = STATX_BASIC_STATS | STATX_BTIME | STATX_ATTRIBUTES; for (argv++; *argv; argv++) { if (strcmp(*argv, "-F") == 0) { diff --git a/tools/include/uapi/linux/stat.h b/tools/include/uapi/linux/stat.h index 370f09d92fa6..aef0aba5dfe7 100644 --- a/tools/include/uapi/linux/stat.h +++ b/tools/include/uapi/linux/stat.h @@ -148,6 +148,7 @@ struct statx { #define STATX_BLOCKS 0x00000400U /* Want/got stx_blocks */ #define STATX_BASIC_STATS 0x000007ffU /* The stuff in the normal stat struct */ #define STATX_BTIME 0x00000800U /* Want/got stx_btime */ +#define STATX_ATTRIBUTES 0x00001000U /* Want/got stx_attributes */ #define STATX__RESERVED 0x80000000U /* Reserved for future struct statx expansion */