From patchwork Thu Feb 14 10:00:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10812265 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 9289313B4 for ; Thu, 14 Feb 2019 10:01:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80EFF2CA1A for ; Thu, 14 Feb 2019 10:01:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 742E22CCD9; Thu, 14 Feb 2019 10:01:07 +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,DKIM_SIGNED, DKIM_VALID,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 153672CA1A for ; Thu, 14 Feb 2019 10:01:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438145AbfBNKBG (ORCPT ); Thu, 14 Feb 2019 05:01:06 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:40786 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438135AbfBNKBF (ORCPT ); Thu, 14 Feb 2019 05:01:05 -0500 Received: by mail-pg1-f194.google.com with SMTP id z10so2810810pgp.7 for ; Thu, 14 Feb 2019 02:01:04 -0800 (PST) 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:in-reply-to:references :mime-version:content-transfer-encoding; bh=IqdSQkcumnBYhLQAnydEDsb1lAsWO+oD/FDDiPGvmEE=; b=usaAmZedAV+G4MMMkgGPc8S28KpQ++l9qQmbxyRM15MIgyq61pe2WF0wQdkEMDo5nH iKWh2WrcoAl6wZ6ERj72OMFr1YD0Wr2wM4HPxT/wzzqFoLQzAgdAB6FKvYj2dxEzINjw N4Cv0xGqzBMYp4G3vzyyY66JoIJEoOCTCZtwaMFmV+MFHuCP+UzKJCq/Tbul625qjjvn xXdzJeyEyRKbXV36HUJtBmgF/6F8lfpicQ9u1cVJMagXEpBHqAxFl7b2omFkpQgnGX81 25cJ8stplZONWlWNtfajsyQl4bJ1sDihwNYSpvXfiAHrvgJNNhDbliQZoNeAWgU0DIc+ d/oQ== 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=IqdSQkcumnBYhLQAnydEDsb1lAsWO+oD/FDDiPGvmEE=; b=G1HwaboNHqo8W1A/rZXwwu5eoS19nDAAGQKhZUUy4+TiAa6vzMto8lC6E23svbk98f GRh2wg1i89IN9WOMKW8oJiCPk6sFkh40MtofN1qJhlwY85GxfXCTGees5xrBNXoP66Nh 7m0sbpjdN9cCuVi/3AdjUFho6gD9DCaO5s30k7gJ5IupWoOP+8HvHeGF/hXfS+pTY0yr JwQJ+Cb5+nqnzNy7qN5VQuxqw3G4xFYvhWlS/meXAN6K/Tbg/TIgpMfKLn/yqOIvm10k nQ9VxwCJBr6X16HiQ0EnkDH8PTW7SxuIDVGkm7Kdox3g1WMCJUapzbMJvjplf+ELi7EU 2qyA== X-Gm-Message-State: AHQUAubJMaabDI6e4oEclgtkendg8lhuoqFfldo6DPxWZjxMP9af0w2Y 9vh7ZigQOy2sTqIl6TikbsygPjZ2XLo= X-Google-Smtp-Source: AHgI3Ib+xTdCQe6JlYsBbZpBuVD1MoJoHbkkyFc1cudFBlwMPakWlfu2ZUCo3JTBKeF8E9jagBZ9Iw== X-Received: by 2002:a63:4b60:: with SMTP id k32mr2950896pgl.186.1550138464181; Thu, 14 Feb 2019 02:01:04 -0800 (PST) Received: from vader.thefacebook.com ([2620:10d:c090:180::1:5849]) by smtp.gmail.com with ESMTPSA id i184sm2686952pfc.41.2019.02.14.02.01.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:01:03 -0800 (PST) From: Omar Sandoval To: linux-fsdevel@vger.kernel.org, Al Viro Cc: kernel-team@fb.com, linux-api@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org Subject: [RFC PATCH 4/6] ext4: add support for setting btime Date: Thu, 14 Feb 2019 02:00:11 -0800 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 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 From: Omar Sandoval The ext4 inode format includes btime (under the name crtime) if the inode is large enough (256 bytes). Signed-off-by: Omar Sandoval --- fs/ext4/inode.c | 15 +++++++++++++-- fs/ext4/super.c | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 34d7e0703cc6..7f4f83ef539d 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -5489,6 +5489,13 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode) } } +static bool ext4_inode_has_crtime(struct inode *inode) +{ + struct ext4_inode *raw_inode; + + return EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), i_crtime); +} + /* * ext4_setattr() * @@ -5520,6 +5527,9 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) int orphan = 0; const unsigned int ia_valid = attr->ia_valid; + if ((ia_valid & ATTR_BTIME) && !ext4_inode_has_crtime(inode)) + return -EOPNOTSUPP; + if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb)))) return -EIO; @@ -5671,6 +5681,8 @@ int ext4_setattr(struct dentry *dentry, struct iattr *attr) if (!error) { setattr_copy(inode, attr); + if (ia_valid & ATTR_BTIME) + EXT4_I(inode)->i_crtime = attr->ia_btime; mark_inode_dirty(inode); } @@ -5695,11 +5707,10 @@ int ext4_getattr(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int query_flags) { struct inode *inode = d_inode(path->dentry); - struct ext4_inode *raw_inode; struct ext4_inode_info *ei = EXT4_I(inode); unsigned int flags; - if (EXT4_FITS_IN_INODE(raw_inode, ei, i_crtime)) { + if (ext4_inode_has_crtime(inode)) { stat->result_mask |= STATX_BTIME; stat->btime.tv_sec = ei->i_crtime.tv_sec; stat->btime.tv_nsec = ei->i_crtime.tv_nsec; diff --git a/fs/ext4/super.c b/fs/ext4/super.c index fb12d3c17c1b..cdd3975de130 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c @@ -5976,7 +5976,7 @@ static struct file_system_type ext4_fs_type = { .name = "ext4", .mount = ext4_mount, .kill_sb = kill_block_super, - .fs_flags = FS_REQUIRES_DEV, + .fs_flags = FS_REQUIRES_DEV | FS_HAS_BTIME, }; MODULE_ALIAS_FS("ext4");