From patchwork Fri May 12 22:07:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 9724893 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5276D60348 for ; Fri, 12 May 2017 22:08:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 396FF28893 for ; Fri, 12 May 2017 22:08:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A5D828896; Fri, 12 May 2017 22:08:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E05F28893 for ; Fri, 12 May 2017 22:08:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932303AbdELWH7 (ORCPT ); Fri, 12 May 2017 18:07:59 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:33210 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932178AbdELWH6 (ORCPT ); Fri, 12 May 2017 18:07:58 -0400 Received: by mail-pf0-f181.google.com with SMTP id e193so36047938pfh.0 for ; Fri, 12 May 2017 15:07:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=osandov-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=d09Ydqtkvm1Y1TxEOXMHzhq+0Gn3zIhFau0yH4hJGmw=; b=LlMSGiiR2S9vccADevBYhRdV55nKv1VKI8gIzu5+iExOZ4ayQKY5In6IDKayK4BeGt x8tmtFdYBK79HfRcC2kSl6mQN3RTMWjDw3ZgtCbMirJvqTbvvUisc/cbhvLYxmifebZ5 2V84I/ezBjdGuEvoF8YOpK8kAGtJjTFOIUHCQQXiAbZK8Vf9wW1rdkGSbGxqsbPtPvID YbgpLsZGt3Dao3GBdWWvLmkLfUfWqLgb1stOKN0EknS3PWWfn6zOhyOa13FYHZVcGwgw n1EvYzWmA37Hak165y+eZ6sjc7hhqoUOMwzMXSMA7WkbDpjH0pFxW4aC0zZCQUvxeqE9 2tww== 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=d09Ydqtkvm1Y1TxEOXMHzhq+0Gn3zIhFau0yH4hJGmw=; b=t0/4pSKKZD2jjwl/hMhwy1UGaqv0eIqKpRmJjpzF565uq56EtoN55yZxzsf/E/VgqV 0/VKb2jpLM43HFKKVRU0M1XPwAGHHL2ahmloAIG7UqJmktkY1daKMo2MGn6nk0/qH5YP xwed/VDzd5viSxObTX7/cRyo8bsZhP+qX83EaiNdXtiMsX8jBJGKO+nKWSQ5rmIE6Yux /dk+sMPLyGS0AasMkYOW4dtTVHvD5R603/dcAIOGVKbR3Pnozg0E0Lk06taYc/XilDKt lzI47/fl0kVQOCR+BL5JfnPVybbDuNJge8v5HYSRd31vLNy51SknAQbpBYGzXCXqAkWn vemA== X-Gm-Message-State: AODbwcDhoSY4cc/FlVzX1ynyle6To0sbJq/uCPkZwEYFr+3OoO72YHad 5mGs6NQk22OEBNbV X-Received: by 10.98.29.196 with SMTP id d187mr6827722pfd.68.1494626878139; Fri, 12 May 2017 15:07:58 -0700 (PDT) Received: from vader.thefacebook.com ([2620:10d:c090:200::b:3252]) by smtp.gmail.com with ESMTPSA id s83sm7257099pfa.128.2017.05.12.15.07.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 12 May 2017 15:07:57 -0700 (PDT) From: Omar Sandoval To: linux-btrfs@vger.kernel.org Cc: kernel-team@fb.com, Yonghong Song Subject: [PATCH] Btrfs: add statx support Date: Fri, 12 May 2017 15:07:43 -0700 Message-Id: X-Mailer: git-send-email 2.13.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Yonghong Song Return enhanced file attributes from the btrfs, including: (1). inode creation time as stx_btime, and (2). Certain BTRFS_INODE_xxx flags are mapped to stx_attributes flags. Example output: [root@localhost ~]# cat t.sh touch t chattr +aic t ~/linux/samples/statx/test-statx t chattr -aic t touch t echo "========================================" ~/linux/samples/statx/test-statx t /bin/rm t [root@localhost ~]# ./t.sh statx(t) = 0 results=fff Size: 0 Blocks: 0 IO Block: 4096 regular file Device: 00:1c Inode: 63962 Links: 1 Access: (0644/-rw-r--r--) Uid: 0 Gid: 0 Access: 2017-05-11 16:03:13.999856591-0700 Modify: 2017-05-11 16:03:13.999856591-0700 Change: 2017-05-11 16:03:14.000856663-0700 Birth: 2017-05-11 16:03:13.999856591-0700 Attributes: 0000000000000034 (........ ........ ........ ........ ........ ........ ........ .-ai.c..) ======================================== statx(t) = 0 results=fff Size: 0 Blocks: 0 IO Block: 4096 regular file Device: 00:1c Inode: 63962 Links: 1 Access: (0644/-rw-r--r--) Uid: 0 Gid: 0 Access: 2017-05-11 16:03:14.006857097-0700 Modify: 2017-05-11 16:03:14.006857097-0700 Change: 2017-05-11 16:03:14.006857097-0700 Birth: 2017-05-11 16:03:13.999856591-0700 Attributes: 0000000000000000 (........ ........ ........ ........ ........ ........ ........ .---.-..) [root@localhost ~]# Reviewed-by: Omar Sandoval Signed-off-by: Yonghong Song Reviewed-by: David Sterba --- fs/btrfs/inode.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 17cbe9306faf..5143e4712f93 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -9564,6 +9564,24 @@ static int btrfs_getattr(const struct path *path, struct kstat *stat, u64 delalloc_bytes; struct inode *inode = d_inode(path->dentry); u32 blocksize = inode->i_sb->s_blocksize; + u32 bi_flags = BTRFS_I(inode)->flags; + + stat->result_mask |= STATX_BTIME; + stat->btime.tv_sec = BTRFS_I(inode)->i_otime.tv_sec; + stat->btime.tv_nsec = BTRFS_I(inode)->i_otime.tv_nsec; + if (bi_flags & BTRFS_INODE_APPEND) + stat->attributes |= STATX_ATTR_APPEND; + if (bi_flags & BTRFS_INODE_COMPRESS) + stat->attributes |= STATX_ATTR_COMPRESSED; + if (bi_flags & BTRFS_INODE_IMMUTABLE) + stat->attributes |= STATX_ATTR_IMMUTABLE; + if (bi_flags & BTRFS_INODE_NODUMP) + stat->attributes |= STATX_ATTR_NODUMP; + + stat->attributes_mask |= (STATX_ATTR_APPEND | + STATX_ATTR_COMPRESSED | + STATX_ATTR_IMMUTABLE | + STATX_ATTR_NODUMP); generic_fillattr(inode, stat); stat->dev = BTRFS_I(inode)->root->anon_dev;