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=-9.0 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 CE6BAC10F04 for ; Thu, 14 Feb 2019 10:01:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A07F8222A1 for ; Thu, 14 Feb 2019 10:01:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=osandov-com.20150623.gappssmtp.com header.i=@osandov-com.20150623.gappssmtp.com header.b="usaAmZed" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438204AbfBNKBc (ORCPT ); Thu, 14 Feb 2019 05:01:32 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42860 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438132AbfBNKBF (ORCPT ); Thu, 14 Feb 2019 05:01:05 -0500 Received: by mail-pf1-f193.google.com with SMTP id n74so2842521pfi.9 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=i70caJnvBbZkDwOCO0XlRmGrMdMO57irDIEUUv15YVaruPxrGcspk2hBX8AoJf3WYq 1ZBT0dWnm8H0J8m+Rcrn1j/w2sc+/le6jKXISAmWbX5PQAGQ5oIf412/5EXMGRM9jg+l 7lTGuwZ8ToLw3WGAedWw1fLlOFM5ybnkAAmo2W0KED1ahcdjp4n3kOKhNi/20J2IFPNY UVUwe8EL0GqEcLfRpHzPIKBXqWtdiniYy84tTj1yuIHlASp5kvxSLiqjF3oMN8d1SxWO I/GAhLUiIVReEHF32QWsKyC9hQBowBZyuowja6b/00JHKfoVI1UluUR14/8rDIaaOD9r ro1w== X-Gm-Message-State: AHQUAuaT4JP6ZcbuY48ttMyLnr4qe7wxRW0mU5y4Lr9YSBNk40/8MRqI g/anQtncFv5nfoLMrP3I+K/3Qg== 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 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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"); -- 2.20.1