From patchwork Thu Feb 14 10:00:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10812255 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 11E8713B4 for ; Thu, 14 Feb 2019 10:01:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 009A72CCD5 for ; Thu, 14 Feb 2019 10:01:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E8F542CD42; Thu, 14 Feb 2019 10:01: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=-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 D1B1E2CCD5 for ; Thu, 14 Feb 2019 10:01:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437864AbfBNKBB (ORCPT ); Thu, 14 Feb 2019 05:01:01 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36321 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2395232AbfBNKBB (ORCPT ); Thu, 14 Feb 2019 05:01:01 -0500 Received: by mail-pf1-f195.google.com with SMTP id n22so2858071pfa.3 for ; Thu, 14 Feb 2019 02:01:00 -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=EVYMogBI4jH/67Zve0CCKF3qzn61yTaO8kNdGkw2lp0=; b=B5qmejP/7w2oWJWv/oV+8ZrB5ZN6/sze+t3hgFWrfkCM7axsOBafeMe9/ZeE1Vejqe oOkE46QjKxER2iUcnFlonsqAt94w6CKsARtz/U4VeGPISvM2VP9V24Y3CvUtwX2PnOhl RSUeuGmLajavqOBDi5ZRXL+RM8q/MtTyWdkzZSNc/+X7/1j5rn/J8Hdfw0H9Oh6Ca8z2 jOJLTa/fgDTVhff6K2+G1uIaRXXtvgbZivToTzeGOKfn1/UBdwK2jTYDDV8z+ycyDnh+ ASYhZfS4R0LMXt4O2vy9CyoSxtW9WhXeiwwwSyGC0BhavoWWNu8nMKSENkYpf9IXVwIV mIpw== 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=EVYMogBI4jH/67Zve0CCKF3qzn61yTaO8kNdGkw2lp0=; b=FTkVqoTI2RDgjCM4L8karKTRHqw5+kfwvXZaN/R9ZZevzliYjXftWBJ8gRDIcMbzhn kIrFIvJebC6p/+KSl01JmSnQDIUgqH4MVkDMxIE1AgzYj/HUe0L1aRS1Xs3sVSERlC1K XTllDDvnPJfF4ysGuX5w7WWfnegDEaYq0GzeCfrH1oEmmWKA2Wup3XsDmZwkkKOxfO/1 VVjaGX86/MMqlHNnpY6T+yYCnDcRhP+L76cnI+vq27Tjq3izdIk3sy+5YsItHngIFQTm 2iKO45eSE5JMsXMMMI+TlqluhcAa2eaiaBu0a15tKmQaQpwZZWlS2HgNfWuoqnbc6zNv eUUw== X-Gm-Message-State: AHQUAuaQ8dz5SqNl5xgyROcNUKvnD8dufDJdaiIfIAqLKjh3xvK58g2e QhuCCs+xmmKAzzQug7/qkbRQYLVfVjA= X-Google-Smtp-Source: AHgI3IYIKRGtWY+ZPKyvM7X4BGw9YR0Xss1EIlbxjpL9e1+gb7kdRN23yFkXwhVxYi1FPJUsq1SPHw== X-Received: by 2002:a63:7044:: with SMTP id a4mr2852696pgn.359.1550138459914; Thu, 14 Feb 2019 02:00:59 -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.00.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:00:59 -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 1/6] fs: add btime to struct iattr Date: Thu, 14 Feb 2019 02:00:08 -0800 Message-Id: <338b960e32ae2bebcf45c738af42a979af112e12.1550136164.git.osandov@fb.com> 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 Add btime as an attribute that can be updated through notify_change() if the filesystem supports it, which is indicated by FS_HAS_BTIME in file_system_type->fs_flags. Signed-off-by: Omar Sandoval --- fs/attr.c | 6 ++++++ include/linux/fs.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/fs/attr.c b/fs/attr.c index d22e8187477f..4831ef479951 100644 --- a/fs/attr.c +++ b/fs/attr.c @@ -233,6 +233,10 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de WARN_ON_ONCE(!inode_is_locked(inode)); + if ((ia_valid & ATTR_BTIME) && + !(inode->i_sb->s_type->fs_flags & FS_HAS_BTIME)) + return -EOPNOTSUPP; + if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) { if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) return -EPERM; @@ -267,6 +271,8 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de attr->ia_atime = now; if (!(ia_valid & ATTR_MTIME_SET)) attr->ia_mtime = now; + if (!(ia_valid & ATTR_BTIME_SET)) + attr->ia_btime = now; if (ia_valid & ATTR_KILL_PRIV) { error = security_inode_need_killpriv(dentry); if (error < 0) diff --git a/include/linux/fs.h b/include/linux/fs.h index 29d8e2cfed0e..d66040f7740b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -191,6 +191,8 @@ typedef int (dio_iodone_t)(struct kiocb *iocb, loff_t offset, #define ATTR_OPEN (1 << 15) /* Truncating from open(O_TRUNC) */ #define ATTR_TIMES_SET (1 << 16) #define ATTR_TOUCH (1 << 17) +#define ATTR_BTIME (1 << 18) +#define ATTR_BTIME_SET (1 << 19) /* * Whiteout is represented by a char device. The following constants define the @@ -217,6 +219,7 @@ struct iattr { struct timespec64 ia_atime; struct timespec64 ia_mtime; struct timespec64 ia_ctime; + struct timespec64 ia_btime; /* * Not an attribute, but an auxiliary info for filesystems wanting to @@ -2172,6 +2175,7 @@ struct file_system_type { #define FS_BINARY_MOUNTDATA 2 #define FS_HAS_SUBTYPE 4 #define FS_USERNS_MOUNT 8 /* Can be mounted by userns root */ +#define FS_HAS_BTIME 16 /* Supports getting/setting btime. */ #define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */ struct dentry *(*mount) (struct file_system_type *, int, const char *, void *); From patchwork Thu Feb 14 10:00:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10812259 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 7399113B4 for ; Thu, 14 Feb 2019 10:01:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 61BB02CA1A for ; Thu, 14 Feb 2019 10:01:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55D2D2CCD9; Thu, 14 Feb 2019 10:01:05 +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 B7B5D2CA1A for ; Thu, 14 Feb 2019 10:01:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437917AbfBNKBD (ORCPT ); Thu, 14 Feb 2019 05:01:03 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:38755 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393583AbfBNKBC (ORCPT ); Thu, 14 Feb 2019 05:01:02 -0500 Received: by mail-pg1-f195.google.com with SMTP id m2so552614pgl.5 for ; Thu, 14 Feb 2019 02:01:02 -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=TLQAdFNP+15JxlBI58SJ2nT9uYeBUgqzimf4OUiFWJc=; b=IC+Wyo0IblsVFiSxEyjsJ8rnNo4ZvFfbYe60h5J4MsnrTKmn8TyLuRtQ1Z6Zmk3yFI gDz8YNGyAeIFrwstdiGIgatkfHW2AtUZmiTLOGV2q1w0VKJtY/gRJV52e1m+udXWip14 vWOSbmdzrkLF6EIpA1ydbJesfE14v7+vsr8KYdMPYrf8lYB0xvW6vkmXi7TSeIkfiLbk 0775oHCg06HBHFqHWSN1RW8gr1ORZ/mCSAVcYy0mWBFlVDpUUTCsGG42Rw7c0eC32YjI 65RA51epvsDCsYUs0entnyQCn6es1hjZ/KnnR8kQR1VFRU/WnYs3k95VuN9a05T1GEJm mVpg== 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=TLQAdFNP+15JxlBI58SJ2nT9uYeBUgqzimf4OUiFWJc=; b=ICZz3cKoTJr30zapXk7CtJCHNvxfmL4Crl6YtLCkno9B1SAqxDKWmmQyXQV1HIoUFW JkUuEfAFkHtaLyaOe4ZEb4pV8dQWHW4sDTF8VIAUugLcv0saSXimdRKKNcseGOInIfcE 2AyxqROYlCGSFuA0yVO3Vp38zRxKKs6sAx13I8gREKWsaau60iAWCvEJ4iTU17BkexCd Zyz/yOf5VWs8Fhl+34EUwwE6nPKDP5FzRJUWeNflg/vwkxEkv6MB2YLUOrT1+buYWZmx BY6vHJMtfAhB5PbR4xqqssnTXrqd2iaWWayOXN9FdReBAQTI7tiYw+w9Gch42SREdKr3 KbhQ== X-Gm-Message-State: AHQUAuavg/Olr3HDWjDyaFeRMbJBmubBjDeVriGGFaCWFfInqJEjz/pf BAsAQ8eUdZzZ/a8VrEDJe1nq0awV2II= X-Google-Smtp-Source: AHgI3IaIZF8cQSfl1R7Zn9umrjvXrfwkmwtV4dKUogKICaSr3GY9IdmWyNzAWtPOpu9FRk7Pxl9Bog== X-Received: by 2002:a63:4e1d:: with SMTP id c29mr2961796pgb.433.1550138461256; Thu, 14 Feb 2019 02:01:01 -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.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:01:00 -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 2/6] fs: add AT_UTIME_BTIME for utimensat() Date: Thu, 14 Feb 2019 02:00:09 -0800 Message-Id: <383aea1b93edf69d4f96a898ef4878881867d33e.1550136164.git.osandov@fb.com> 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 Now that we have a btime iattr, use it to allow updating btime from utimensat(). We do so by adding a new AT_UTIME_BTIME flag. Iff this flag is given, the btime is set to times[2] (unless times is NULL, in which case the current time is used). Signed-off-by: Omar Sandoval --- fs/utimes.c | 86 +++++++++++++++++++++++--------------- include/uapi/linux/fcntl.h | 2 + 2 files changed, 55 insertions(+), 33 deletions(-) diff --git a/fs/utimes.c b/fs/utimes.c index bdcf2daf39c1..cb9fe77e5f91 100644 --- a/fs/utimes.c +++ b/fs/utimes.c @@ -16,7 +16,20 @@ static bool nsec_valid(long nsec) return nsec >= 0 && nsec <= 999999999; } -static int utimes_common(const struct path *path, struct timespec64 *times) +static void init_time_attr(struct iattr *newattrs, struct timespec64 *time_attr, + struct timespec64 time, unsigned int attr, + unsigned int attr_set) +{ + if (time.tv_nsec == UTIME_OMIT) { + newattrs->ia_valid &= ~attr; + } else { + *time_attr = time; + newattrs->ia_valid |= attr_set; + } +} + +static int utimes_common(const struct path *path, struct timespec64 *times, + bool btime) { int error; struct iattr newattrs; @@ -28,25 +41,21 @@ static int utimes_common(const struct path *path, struct timespec64 *times) goto out; if (times && times[0].tv_nsec == UTIME_NOW && - times[1].tv_nsec == UTIME_NOW) + times[1].tv_nsec == UTIME_NOW && + (!btime || times[2].tv_nsec == UTIME_NOW)) times = NULL; newattrs.ia_valid = ATTR_CTIME | ATTR_MTIME | ATTR_ATIME; + if (btime) + newattrs.ia_valid |= ATTR_BTIME; if (times) { - if (times[0].tv_nsec == UTIME_OMIT) - newattrs.ia_valid &= ~ATTR_ATIME; - else if (times[0].tv_nsec != UTIME_NOW) { - newattrs.ia_atime.tv_sec = times[0].tv_sec; - newattrs.ia_atime.tv_nsec = times[0].tv_nsec; - newattrs.ia_valid |= ATTR_ATIME_SET; - } - - if (times[1].tv_nsec == UTIME_OMIT) - newattrs.ia_valid &= ~ATTR_MTIME; - else if (times[1].tv_nsec != UTIME_NOW) { - newattrs.ia_mtime.tv_sec = times[1].tv_sec; - newattrs.ia_mtime.tv_nsec = times[1].tv_nsec; - newattrs.ia_valid |= ATTR_MTIME_SET; + init_time_attr(&newattrs, &newattrs.ia_atime, times[0], + ATTR_ATIME, ATTR_ATIME_SET); + init_time_attr(&newattrs, &newattrs.ia_mtime, times[1], + ATTR_MTIME, ATTR_MTIME_SET); + if (btime) { + init_time_attr(&newattrs, &newattrs.ia_btime, times[2], + ATTR_BTIME, ATTR_BTIME_SET); } /* * Tell setattr_prepare(), that this is an explicit time @@ -90,14 +99,16 @@ static int utimes_common(const struct path *path, struct timespec64 *times) long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, int flags) { + bool btime = flags & AT_UTIME_BTIME; int error = -EINVAL; if (times && (!nsec_valid(times[0].tv_nsec) || - !nsec_valid(times[1].tv_nsec))) { + !nsec_valid(times[1].tv_nsec) || + (btime && !nsec_valid(times[2].tv_nsec)))) { goto out; } - if (flags & ~AT_SYMLINK_NOFOLLOW) + if (flags & ~(AT_SYMLINK_NOFOLLOW | AT_UTIME_BTIME)) goto out; if (filename == NULL && dfd != AT_FDCWD) { @@ -111,7 +122,7 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, if (!f.file) goto out; - error = utimes_common(&f.file->f_path, times); + error = utimes_common(&f.file->f_path, times, btime); fdput(f); } else { struct path path; @@ -124,7 +135,7 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, if (error) goto out; - error = utimes_common(&path, times); + error = utimes_common(&path, times, btime); path_put(&path); if (retry_estale(error, lookup_flags)) { lookup_flags |= LOOKUP_REVAL; @@ -139,16 +150,20 @@ long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, SYSCALL_DEFINE4(utimensat, int, dfd, const char __user *, filename, struct __kernel_timespec __user *, utimes, int, flags) { - struct timespec64 tstimes[2]; + struct timespec64 tstimes[3]; if (utimes) { - if ((get_timespec64(&tstimes[0], &utimes[0]) || - get_timespec64(&tstimes[1], &utimes[1]))) - return -EFAULT; - + int i, n = (flags & AT_UTIME_BTIME) ? 3 : 2; + bool all_omit = true; + + for (i = 0; i < n; i++) { + if (get_timespec64(&tstimes[i], &utimes[i])) + return -EFAULT; + if (tstimes[i].tv_nsec != UTIME_OMIT) + all_omit = false; + } /* Nothing to do, we must not even check the path. */ - if (tstimes[0].tv_nsec == UTIME_OMIT && - tstimes[1].tv_nsec == UTIME_OMIT) + if (all_omit) return 0; } @@ -242,14 +257,19 @@ COMPAT_SYSCALL_DEFINE2(utime, const char __user *, filename, COMPAT_SYSCALL_DEFINE4(utimensat, unsigned int, dfd, const char __user *, filename, struct old_timespec32 __user *, t, int, flags) { - struct timespec64 tv[2]; + struct timespec64 tv[3]; if (t) { - if (get_old_timespec32(&tv[0], &t[0]) || - get_old_timespec32(&tv[1], &t[1])) - return -EFAULT; - - if (tv[0].tv_nsec == UTIME_OMIT && tv[1].tv_nsec == UTIME_OMIT) + int i, n = (flags & AT_UTIME_BTIME) ? 3 : 2; + bool all_omit = true; + + for (i = 0; i < n; i++) { + if (get_old_timespec32(&tv[i], &t[i])) + return -EFAULT; + if (tv[i].tv_nsec != UTIME_OMIT) + all_omit = false; + } + if (all_omit) return 0; } return do_utimes(dfd, filename, t ? tv : NULL, flags); diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h index 6448cdd9a350..fc5b02439697 100644 --- a/include/uapi/linux/fcntl.h +++ b/include/uapi/linux/fcntl.h @@ -90,5 +90,7 @@ #define AT_STATX_FORCE_SYNC 0x2000 /* - Force the attributes to be sync'd with the server */ #define AT_STATX_DONT_SYNC 0x4000 /* - Don't sync attributes with the server */ +#define AT_UTIME_BTIME 0x8000 /* Also update file creation time */ + #endif /* _UAPI_LINUX_FCNTL_H */ From patchwork Thu Feb 14 10:00:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10812263 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 9159213BF for ; Thu, 14 Feb 2019 10:01:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82C6E2CA1A for ; Thu, 14 Feb 2019 10:01:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 773102CCD5; Thu, 14 Feb 2019 10:01:06 +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=unavailable 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 2D0C42CA1A for ; Thu, 14 Feb 2019 10:01:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438139AbfBNKBF (ORCPT ); Thu, 14 Feb 2019 05:01:05 -0500 Received: from mail-pl1-f195.google.com ([209.85.214.195]:42362 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438128AbfBNKBD (ORCPT ); Thu, 14 Feb 2019 05:01:03 -0500 Received: by mail-pl1-f195.google.com with SMTP id s1so2890852plp.9 for ; Thu, 14 Feb 2019 02:01:03 -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=z1iJdJ3ICufViigzY8ArSNJ8k4Y0JN5jmw8hA8KfmFU=; b=flSeOV67kqykhRwclnrfrqoGKGW89REoU5Hj3g1pDXyBpBurQb2WVbHnHGfaabPXdH eKSDz9iBLVBH6TXcJNKLXZJap0/h8DRGo8G/gzkD0GUDf8FD/etzCzTTEqkkXDFXIdJc hjVZm9tfRGvQNK419c1V7l8hrPfdXq3wlRMPwfjeufOh/yml3DSYcVPBc2pga/OkMVfF nM5e+JjSOCkBu/xCvjduIggPnLBWzR8qLBjq2dQ2IyilRt/iJvogtDrMC9sgrgvNMDFE 490OtH/PMfgJUxT3sDxj3fMVRc2qOHjshCd52BoIM5c8zvZnS82pGDv5tLy8rBbHrWD1 IQIQ== 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=z1iJdJ3ICufViigzY8ArSNJ8k4Y0JN5jmw8hA8KfmFU=; b=shyiaBpFS75W80WspE1lvPccrfOUVWJRt2JGnrsiG8dd2RBoO9wSKZDMK5fyOirjkp 3+TLsm7LZeMMGrnHSByX/EAyTlxMDW1JxHCN+gUnzgMuert77E4I0KFHN/uU/VIGnznN +VGmUfHDiELT1LmODCz9qAkU/D02fm25+wRnswpVQKMXTDX+ESV4VSvsjDAz8C7ENfhz jpXXY29z2v6QrpJIENUduoAYVM33BvZyury3QM3gmy7a4+OKGrU/uoi6mxv9Opdeeq1b Lf55fWwULOfBNcjY5Tnb9Srcm7/cP+BZZZTTwSgACM/WTkUYF0iI6i4DWGvrVD57/a3X fpuw== X-Gm-Message-State: AHQUAuZ0uGfiS5E1o9OBYBKcHgAQtrDGskb5yTUfp7uxOFt0PCvxsj5N j7oLLGdaFvMXON5FjkEWBDqyKylp84w= X-Google-Smtp-Source: AHgI3Ibyqg3SB+jzXjDULbQ1xxmVIWOPdoCIOX55ghDRePdqF29R1HktJeP2hFm85ktvyjbG1CXwlw== X-Received: by 2002:a17:902:31a4:: with SMTP id x33mr3169876plb.198.1550138462471; Thu, 14 Feb 2019 02:01:02 -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.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:01:01 -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 3/6] Btrfs: add support for setting btime Date: Thu, 14 Feb 2019 02:00:10 -0800 Message-Id: <60b83d5151d3c80bf73bb257b971aeb66120d4d5.1550136164.git.osandov@fb.com> 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 Btrfs inode format has always included btime (under the name otime), so setting it is trivial. Signed-off-by: Omar Sandoval --- fs/btrfs/inode.c | 2 ++ fs/btrfs/super.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5c349667c761..49ad777d8057 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -5153,6 +5153,8 @@ static int btrfs_setattr(struct dentry *dentry, struct iattr *attr) if (attr->ia_valid) { setattr_copy(inode, attr); + if (attr->ia_valid & ATTR_BTIME) + BTRFS_I(inode)->i_otime = attr->ia_btime; inode_inc_iversion(inode); err = btrfs_dirty_inode(inode); diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 0a3f122dd61f..2af368cad2aa 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -2140,7 +2140,7 @@ static struct file_system_type btrfs_fs_type = { .name = "btrfs", .mount = btrfs_mount, .kill_sb = btrfs_kill_super, - .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA, + .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_HAS_BTIME, }; static struct file_system_type btrfs_root_fs_type = { @@ -2148,7 +2148,7 @@ static struct file_system_type btrfs_root_fs_type = { .name = "btrfs", .mount = btrfs_mount_root, .kill_sb = btrfs_kill_super, - .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA, + .fs_flags = FS_REQUIRES_DEV | FS_BINARY_MOUNTDATA | FS_HAS_BTIME, }; MODULE_ALIAS_FS("btrfs"); 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"); From patchwork Thu Feb 14 10:00:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10812267 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 2237413B4 for ; Thu, 14 Feb 2019 10:01:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 111FF2CA1A for ; Thu, 14 Feb 2019 10:01:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 053882CD1B; Thu, 14 Feb 2019 10:01:09 +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 7C2D92CA1A for ; Thu, 14 Feb 2019 10:01:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438126AbfBNKBH (ORCPT ); Thu, 14 Feb 2019 05:01:07 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35024 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438143AbfBNKBG (ORCPT ); Thu, 14 Feb 2019 05:01:06 -0500 Received: by mail-pf1-f193.google.com with SMTP id z15so2862353pfa.2 for ; Thu, 14 Feb 2019 02:01:06 -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=jgcWZgJ1s++4IqkbKKFPdm3Je4rg2/ot9AJodUrt5Dw=; b=ndqUsyCPjvFocNdflivCZ4Wr3PJ1duzo3UXDuOmetIZ3nvAAp1R56QH3Hm76rEt2p6 rtyU1witWlyDxDG3r2zg5/+sfQ9BSTZwCT0WlhzRYXpviNBenLUW2ADuSw5T+W/G5k5l FFX6mrPFKUv9mGsqfu1NOyUKsnkz8Uo2z4eYv9NGTpioOoWI1LS6rbWcW382TlaLBpjr FSLTe7gJl0E3XPpqb5BOlK/V/ZsEWxYx5WBNQojxn5mgdJGxqDaGYIk2zIhhds5x6bfb N1iTTcCL2kmsAtUZ5+/SrDH15J78MWo5TQve/AvU4K3YSZODeqlcuJfNac7GQyRWGJ4c l+Ww== 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=jgcWZgJ1s++4IqkbKKFPdm3Je4rg2/ot9AJodUrt5Dw=; b=tQuqTGDUS/550ONxK/VgQExT57A9JV5LXacswocyrjJs2Ikd/WiP6DXQ6RqZOE3FM6 RJ+tg98jftL/FKRbMu2jTv8zy+I2GM9gh7HQih1l7al08unJOp+PhLSaVOQ9OeUgl+t5 Uuw/n/+lppNVxxbqqzTO3NxLMWZfSb6HAp6Wy160iV6yhi6tE8BeUQUXA7QjD5MELAAZ aqZiI40DVuGye2kvS8NTBfu4yN4mxWg3dsOD6LhiOWHKnEz9dYcRt0sRqmd6g0JRYMtb zPwshel2Xw9cDZDfOgFufVRrGpiN+NfvnWFB8srHBSxXBz+Vpo02DuBjpDOTF11UZv0k x8Xw== X-Gm-Message-State: AHQUAubxFl4SRzXbhCmMNWZklJHJXQSXiSCye+2WPO6wq6A4bk84v5T/ Tou2qldvQPX+fJtfHv9SooUt8TfmTyU= X-Google-Smtp-Source: AHgI3IZW5aU5aO4ZI8ZDs3ZrKqLPsD9EB4vbxqf6ZbgyCQpgUZc33Rsa9YSKgmB9R7kLoSyhnn3T4g== X-Received: by 2002:a65:620c:: with SMTP id d12mr2935714pgv.328.1550138465568; Thu, 14 Feb 2019 02:01:05 -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.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:01:04 -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 5/6] f2fs: add support for setting btime Date: Thu, 14 Feb 2019 02:00:12 -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 f2fs inode format includes btime (under the name crtime) if the feature was enabled at mkfs time. Signed-off-by: Omar Sandoval --- fs/f2fs/file.c | 19 +++++++++++++++---- fs/f2fs/super.c | 2 +- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index bba56b39dcc5..6064d3e42987 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -690,17 +690,23 @@ int f2fs_truncate(struct inode *inode) return 0; } +static bool f2fs_inode_has_crtime(struct inode *inode) +{ + struct f2fs_inode *ri; + + return (f2fs_has_extra_attr(inode) && + f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)) && + F2FS_FITS_IN_INODE(ri, F2FS_I(inode)->i_extra_isize, i_crtime)); +} + int f2fs_getattr(const struct path *path, struct kstat *stat, u32 request_mask, unsigned int query_flags) { struct inode *inode = d_inode(path->dentry); struct f2fs_inode_info *fi = F2FS_I(inode); - struct f2fs_inode *ri; unsigned int flags; - if (f2fs_has_extra_attr(inode) && - f2fs_sb_has_inode_crtime(F2FS_I_SB(inode)) && - F2FS_FITS_IN_INODE(ri, fi->i_extra_isize, i_crtime)) { + if (f2fs_inode_has_crtime(inode)) { stat->result_mask |= STATX_BTIME; stat->btime.tv_sec = fi->i_crtime.tv_sec; stat->btime.tv_nsec = fi->i_crtime.tv_nsec; @@ -770,6 +776,9 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) int err; bool size_changed = false; + if ((attr->ia_valid & ATTR_BTIME) && !f2fs_inode_has_crtime(inode)) + return -EOPNOTSUPP; + if (unlikely(f2fs_cp_error(F2FS_I_SB(inode)))) return -EIO; @@ -848,6 +857,8 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr) } __setattr_copy(inode, attr); + if (attr->ia_valid & ATTR_BTIME) + F2FS_I(inode)->i_crtime = attr->ia_btime; if (attr->ia_valid & ATTR_MODE) { err = posix_acl_chmod(inode, f2fs_get_inode_mode(inode)); diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index c46a1d4318d4..e32070c8cb27 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3485,7 +3485,7 @@ static struct file_system_type f2fs_fs_type = { .name = "f2fs", .mount = f2fs_mount, .kill_sb = kill_f2fs_super, - .fs_flags = FS_REQUIRES_DEV, + .fs_flags = FS_REQUIRES_DEV | FS_HAS_BTIME, }; MODULE_ALIAS_FS("f2fs"); From patchwork Thu Feb 14 10:00:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Omar Sandoval X-Patchwork-Id: 10812293 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 7006513BF for ; Thu, 14 Feb 2019 10:01:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60EC52CCD9 for ; Thu, 14 Feb 2019 10:01:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54BF92CCF3; Thu, 14 Feb 2019 10:01:31 +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=unavailable 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 EB3322CD13 for ; Thu, 14 Feb 2019 10:01:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438185AbfBNKBW (ORCPT ); Thu, 14 Feb 2019 05:01:22 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:33818 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438152AbfBNKBI (ORCPT ); Thu, 14 Feb 2019 05:01:08 -0500 Received: by mail-pg1-f196.google.com with SMTP id i130so2827421pgd.1 for ; Thu, 14 Feb 2019 02:01:08 -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=fTk0FyiVC4C7S5X6h/HN++rzsGBLDjcJTciO7DC+crI=; b=y9Yaj6WcgjusayyYM5Aorfv4cGv5yMWbdVWmHpG76OC/LcK0upaLsLOdU4ca14Oxtg /jEZ2O/z/AMEwRW/68k8ycysACwXQAlb4kVmZuSxEsQgq+TttJ12uFsenUy1oofinIJW 584qHI+fSFc2N24PJM5KIksg154F4i734W6DTOUNfJWDRXh2qRl3fGt+xorIOhy0mTAK KBFkVC5Q62yIjyY5D3jNfPtp3Hn9jNL1E9psK50mdleOqVB7v8Tv0ew1yokCP2ZoiFlp Y35OyQFRmzmMw2hZbJBT6uNdwI64QHZisy2cTvIHKv/EAXiHshp5yYfPiCBQAkwusb4D Rgag== 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=fTk0FyiVC4C7S5X6h/HN++rzsGBLDjcJTciO7DC+crI=; b=GnzduPuOQuqGnSkXUZhBjPu5z6WRZ67rYSGQ8Zm8Cg+PAS0yCoOeuYNGHf0P7LtmY9 f2FrzvMp0JbEUAo7gMUwZGGbgDNeQ2k7+BuWzhK2UV+g3GzLeImNvLr48H4QDASh10RB hTTCjqLXaPReXXpgVuRomCn+M2SikkbU028DcOKNet99veFMtEQ0rwMS/fb9t6+CuKS+ cGht9NPU4aMiTqJm69XnXzqt67Oa0foPUrTr5vdXpYaSi42TDrRPCz6LrcrZ3uyJW9sp IvIb6KSdvWIkdDkHAkPZtB8B3bWc2BfJC4iGEJxvjGm8mJGldZXxJx3jgAXgItKJzHB1 5SDA== X-Gm-Message-State: AHQUAubY8CsHUEhDYNE2ilnsnRAFjBaZcn+pRMN218hv35hO4Bjh6QE6 48LPx3sn0hCodjsifxAGMFUOD8ZDyXk= X-Google-Smtp-Source: AHgI3IZx8Umv7Vjiiq1lW+1CsCbGd8SRwLIkK8mTGw+gp3D0GueHp0jnouvmQm42uVNCErrgJd9ZWg== X-Received: by 2002:a63:2a86:: with SMTP id q128mr2978793pgq.424.1550138467024; Thu, 14 Feb 2019 02:01:07 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 02:01:06 -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 6/6] xfs: add support for setting btime Date: Thu, 14 Feb 2019 02:00:13 -0800 Message-Id: <853e0dbdcd881e7dae13ada9dbb5924f6f5c4d9c.1550136164.git.osandov@fb.com> 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 XFS inode format includes btime (under the name crtime) in inode version 3. Also update the comments in libxfs to reflect that di_crtime can now change. Signed-off-by: Omar Sandoval --- fs/xfs/libxfs/xfs_format.h | 2 +- fs/xfs/libxfs/xfs_log_format.h | 2 +- fs/xfs/xfs_iops.c | 11 +++++++++-- fs/xfs/xfs_super.c | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 9bb3c48843ec..ff6cb860ae77 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -884,9 +884,9 @@ typedef struct xfs_dinode { __be64 di_flags2; /* more random flags */ __be32 di_cowextsize; /* basic cow extent size for file */ __u8 di_pad2[12]; /* more padding for future expansion */ + xfs_timestamp_t di_crtime; /* time created */ /* fields only written to during inode creation */ - xfs_timestamp_t di_crtime; /* time created */ __be64 di_ino; /* inode number */ uuid_t di_uuid; /* UUID of the filesystem */ diff --git a/fs/xfs/libxfs/xfs_log_format.h b/fs/xfs/libxfs/xfs_log_format.h index e5f97c69b320..5cb35b3db870 100644 --- a/fs/xfs/libxfs/xfs_log_format.h +++ b/fs/xfs/libxfs/xfs_log_format.h @@ -415,9 +415,9 @@ struct xfs_log_dinode { uint64_t di_flags2; /* more random flags */ uint32_t di_cowextsize; /* basic cow extent size for file */ uint8_t di_pad2[12]; /* more padding for future expansion */ + xfs_ictimestamp_t di_crtime; /* time created */ /* fields only written to during inode creation */ - xfs_ictimestamp_t di_crtime; /* time created */ xfs_ino_t di_ino; /* inode number */ uuid_t di_uuid; /* UUID of the filesystem */ diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index f48ffd7a8d3e..20570f61ffeb 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -582,6 +582,10 @@ xfs_setattr_time( inode->i_ctime = iattr->ia_ctime; if (iattr->ia_valid & ATTR_MTIME) inode->i_mtime = iattr->ia_mtime; + if (iattr->ia_valid & ATTR_BTIME) { + ip->i_d.di_crtime.t_sec = iattr->ia_btime.tv_sec; + ip->i_d.di_crtime.t_nsec = iattr->ia_btime.tv_nsec; + } } static int @@ -1025,11 +1029,14 @@ xfs_vn_setattr( struct dentry *dentry, struct iattr *iattr) { + struct inode *inode = d_inode(dentry); + struct xfs_inode *ip = XFS_I(inode); int error; + if ((iattr->ia_valid & ATTR_BTIME) && ip->i_d.di_version != 3) + return -EOPNOTSUPP; + if (iattr->ia_valid & ATTR_SIZE) { - struct inode *inode = d_inode(dentry); - struct xfs_inode *ip = XFS_I(inode); uint iolock; xfs_ilock(ip, XFS_MMAPLOCK_EXCL); diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index c9097cb0b955..54df86bc634b 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1860,7 +1860,7 @@ static struct file_system_type xfs_fs_type = { .name = "xfs", .mount = xfs_fs_mount, .kill_sb = kill_block_super, - .fs_flags = FS_REQUIRES_DEV, + .fs_flags = FS_REQUIRES_DEV | FS_HAS_BTIME, }; MODULE_ALIAS_FS("xfs");